aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobody <nobody@localhost>2000-02-05 06:25:36 +0800
committernobody <nobody@localhost>2000-02-05 06:25:36 +0800
commit3217818ba6886892eadd568c65d154b83d053f96 (patch)
tree5e5c8f9e4d0929a39b0295b10a322997006e4afc
parentdec6d6b0971480b8910c301daa6218abe3f2eee0 (diff)
downloadgsoc2013-evolution-LIBGTOP_1_90_2.tar
gsoc2013-evolution-LIBGTOP_1_90_2.tar.gz
gsoc2013-evolution-LIBGTOP_1_90_2.tar.bz2
gsoc2013-evolution-LIBGTOP_1_90_2.tar.lz
gsoc2013-evolution-LIBGTOP_1_90_2.tar.xz
gsoc2013-evolution-LIBGTOP_1_90_2.tar.zst
gsoc2013-evolution-LIBGTOP_1_90_2.zip
This commit was manufactured by cvs2svn to create tagLIBGTOP_1_90_2
'LIBGTOP_1_90_2'. svn path=/tags/LIBGTOP_1_90_2/; revision=1676
-rw-r--r--calendar/.cvsignore12
-rw-r--r--calendar/AUTHORS4
-rw-r--r--calendar/ChangeLog2625
-rw-r--r--calendar/GnomeCal.idl125
-rw-r--r--calendar/Makefile.am271
-rw-r--r--calendar/TODO68
-rw-r--r--calendar/alarm.c250
-rw-r--r--calendar/alarm.h12
-rw-r--r--calendar/bell.xpm83
-rw-r--r--calendar/cal-backend.c498
-rw-r--r--calendar/cal-backend.h75
-rw-r--r--calendar/cal-client.c473
-rw-r--r--calendar/cal-client.h80
-rw-r--r--calendar/cal-client/cal-client.c473
-rw-r--r--calendar/cal-client/cal-client.h80
-rw-r--r--calendar/cal-client/cal-listener.c439
-rw-r--r--calendar/cal-client/cal-listener.h86
-rw-r--r--calendar/cal-common.h41
-rw-r--r--calendar/cal-factory.c517
-rw-r--r--calendar/cal-factory.h70
-rw-r--r--calendar/cal-listener.c439
-rw-r--r--calendar/cal-listener.h86
-rw-r--r--calendar/cal-util/calobj.c1490
-rw-r--r--calendar/cal-util/calobj.h215
-rw-r--r--calendar/cal.c346
-rw-r--r--calendar/cal.h67
-rw-r--r--calendar/cal_struct.h27
-rw-r--r--calendar/calendar-conduit-control-applet.c360
-rw-r--r--calendar/calendar-conduit-control-applet.desktop7
-rw-r--r--calendar/calendar-conduit.c1416
-rw-r--r--calendar/calendar-conduit.h138
-rw-r--r--calendar/calendar-pilot-sync.c658
-rw-r--r--calendar/calendar.c646
-rw-r--r--calendar/calendar.h88
-rw-r--r--calendar/calobj.c1490
-rw-r--r--calendar/calobj.h215
-rw-r--r--calendar/conduits/calendar/calendar-conduit-control-applet.c360
-rw-r--r--calendar/conduits/calendar/calendar-conduit-control-applet.desktop7
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c1416
-rw-r--r--calendar/conduits/calendar/calendar-conduit.h138
-rw-r--r--calendar/conduits/todo/todo-conduit-control-applet.c287
-rw-r--r--calendar/conduits/todo/todo-conduit-control-applet.desktop6
-rw-r--r--calendar/conduits/todo/todo-conduit.c256
-rw-r--r--calendar/conduits/todo/todo-conduit.h59
-rw-r--r--calendar/corba-cal-factory.c130
-rw-r--r--calendar/corba-cal-factory.h11
-rw-r--r--calendar/corba-cal.c361
-rw-r--r--calendar/corba-cal.h6
-rw-r--r--calendar/doc/.cvsignore2
-rw-r--r--calendar/doc/C/.cvsignore5
-rw-r--r--calendar/doc/C/Makefile.am44
-rw-r--r--calendar/doc/C/gnomecal.sgml465
-rw-r--r--calendar/doc/C/images/cal-props.gifbin8929 -> 0 bytes
-rw-r--r--calendar/doc/C/images/calday.gifbin16264 -> 0 bytes
-rw-r--r--calendar/doc/C/images/calmonth.gifbin13299 -> 0 bytes
-rw-r--r--calendar/doc/C/images/calweek.gifbin14650 -> 0 bytes
-rw-r--r--calendar/doc/C/images/calyear.gifbin27058 -> 0 bytes
-rw-r--r--calendar/doc/C/topic.dat2
-rw-r--r--calendar/doc/Makefile.am1
-rw-r--r--calendar/eventedit.c1583
-rw-r--r--calendar/eventedit.h83
-rw-r--r--calendar/evolution-calendar.idl79
-rw-r--r--calendar/getdate.y1001
-rw-r--r--calendar/gncal-day-panel.c277
-rw-r--r--calendar/gncal-day-panel.h65
-rw-r--r--calendar/gncal-day-view.c396
-rw-r--r--calendar/gncal-day-view.h56
-rw-r--r--calendar/gncal-full-day.c2287
-rw-r--r--calendar/gncal-full-day.h74
-rw-r--r--calendar/gncal-todo.c877
-rw-r--r--calendar/gncal-todo.h55
-rw-r--r--calendar/gncal-week-view.c255
-rw-r--r--calendar/gncal-week-view.h57
-rw-r--r--calendar/gncal.desktop37
-rw-r--r--calendar/gnome-cal.c613
-rw-r--r--calendar/gnome-cal.h82
-rw-r--r--calendar/gnome-cal.html44
-rw-r--r--calendar/gnome-calendar-conduit.pngbin3000 -> 0 bytes
-rw-r--r--calendar/gnome-month-item.c1246
-rw-r--r--calendar/gnome-month-item.h165
-rw-r--r--calendar/gnomecal.gnorba11
-rw-r--r--calendar/goto.c323
-rw-r--r--calendar/gui/GnomeCal.idl125
-rw-r--r--calendar/gui/Makefile.am271
-rw-r--r--calendar/gui/alarm-notify/alarm.c250
-rw-r--r--calendar/gui/alarm-notify/alarm.h12
-rw-r--r--calendar/gui/alarm.c250
-rw-r--r--calendar/gui/alarm.h12
-rw-r--r--calendar/gui/bell.xpm83
-rw-r--r--calendar/gui/cal_struct.h27
-rw-r--r--calendar/gui/calendar-conduit-control-applet.c360
-rw-r--r--calendar/gui/calendar-conduit-control-applet.desktop7
-rw-r--r--calendar/gui/calendar-conduit.c1416
-rw-r--r--calendar/gui/calendar-conduit.h138
-rw-r--r--calendar/gui/calendar-pilot-sync.c658
-rw-r--r--calendar/gui/calendar.c646
-rw-r--r--calendar/gui/calendar.h88
-rw-r--r--calendar/gui/corba-cal-factory.c130
-rw-r--r--calendar/gui/corba-cal-factory.h11
-rw-r--r--calendar/gui/corba-cal.c361
-rw-r--r--calendar/gui/corba-cal.h6
-rw-r--r--calendar/gui/eventedit.c1583
-rw-r--r--calendar/gui/eventedit.h83
-rw-r--r--calendar/gui/getdate.y1001
-rw-r--r--calendar/gui/gncal-day-panel.c277
-rw-r--r--calendar/gui/gncal-day-panel.h65
-rw-r--r--calendar/gui/gncal-day-view.c396
-rw-r--r--calendar/gui/gncal-day-view.h56
-rw-r--r--calendar/gui/gncal-full-day.c2287
-rw-r--r--calendar/gui/gncal-full-day.h74
-rw-r--r--calendar/gui/gncal-todo.c877
-rw-r--r--calendar/gui/gncal-todo.h55
-rw-r--r--calendar/gui/gncal-week-view.c255
-rw-r--r--calendar/gui/gncal-week-view.h57
-rw-r--r--calendar/gui/gncal.desktop37
-rw-r--r--calendar/gui/gnome-cal.c613
-rw-r--r--calendar/gui/gnome-cal.h82
-rw-r--r--calendar/gui/gnome-cal.html44
-rw-r--r--calendar/gui/gnome-calendar-conduit.pngbin3000 -> 0 bytes
-rw-r--r--calendar/gui/gnome-month-item.c1246
-rw-r--r--calendar/gui/gnome-month-item.h165
-rw-r--r--calendar/gui/gnomecal.gnorba11
-rw-r--r--calendar/gui/goto.c323
-rw-r--r--calendar/gui/icalendar-types39
-rw-r--r--calendar/gui/layout.c287
-rw-r--r--calendar/gui/layout.h37
-rw-r--r--calendar/gui/main.c1059
-rw-r--r--calendar/gui/main.h101
-rw-r--r--calendar/gui/mark.c269
-rw-r--r--calendar/gui/mark.h58
-rw-r--r--calendar/gui/month-view.c798
-rw-r--r--calendar/gui/month-view.h72
-rw-r--r--calendar/gui/popup-menu.c37
-rw-r--r--calendar/gui/popup-menu.h25
-rw-r--r--calendar/gui/prop.c927
-rw-r--r--calendar/gui/quick-view.c274
-rw-r--r--calendar/gui/quick-view.h59
-rw-r--r--calendar/gui/recur.xpm83
-rw-r--r--calendar/gui/test.vcf133
-rw-r--r--calendar/gui/todo-conduit-control-applet.c287
-rw-r--r--calendar/gui/todo-conduit-control-applet.desktop6
-rw-r--r--calendar/gui/todo-conduit.c256
-rw-r--r--calendar/gui/todo-conduit.h59
-rw-r--r--calendar/gui/topic.dat2
-rw-r--r--calendar/gui/view-utils.c201
-rw-r--r--calendar/gui/view-utils.h28
-rw-r--r--calendar/gui/week-view.c100
-rw-r--r--calendar/gui/week-view.h63
-rw-r--r--calendar/gui/year-view.c741
-rw-r--r--calendar/gui/year-view.h77
-rw-r--r--calendar/html-month.c110
-rw-r--r--calendar/icalendar-types39
-rw-r--r--calendar/idl/evolution-calendar.idl79
-rw-r--r--calendar/job.c98
-rw-r--r--calendar/job.h35
-rw-r--r--calendar/layout.c287
-rw-r--r--calendar/layout.h37
-rw-r--r--calendar/main.c1059
-rw-r--r--calendar/main.h101
-rw-r--r--calendar/mark.c269
-rw-r--r--calendar/mark.h58
-rw-r--r--calendar/month-view.c798
-rw-r--r--calendar/month-view.h72
-rw-r--r--calendar/pcs/cal-backend.c498
-rw-r--r--calendar/pcs/cal-backend.h75
-rw-r--r--calendar/pcs/cal-common.h41
-rw-r--r--calendar/pcs/cal-factory.c517
-rw-r--r--calendar/pcs/cal-factory.h70
-rw-r--r--calendar/pcs/cal.c346
-rw-r--r--calendar/pcs/cal.h67
-rw-r--r--calendar/pcs/calobj.c1490
-rw-r--r--calendar/pcs/calobj.h215
-rw-r--r--calendar/pcs/job.c98
-rw-r--r--calendar/pcs/job.h35
-rw-r--r--calendar/pcs/tlacuache.c126
-rw-r--r--calendar/pcs/tlacuache.gnorba5
-rw-r--r--calendar/popup-menu.c37
-rw-r--r--calendar/popup-menu.h25
-rw-r--r--calendar/prop.c927
-rw-r--r--calendar/quick-view.c274
-rw-r--r--calendar/quick-view.h59
-rw-r--r--calendar/recur.xpm83
-rw-r--r--calendar/test.vcf133
-rw-r--r--calendar/timeutil.c501
-rw-r--r--calendar/timeutil.h81
-rw-r--r--calendar/tlacuache.c126
-rw-r--r--calendar/tlacuache.gnorba5
-rw-r--r--calendar/todo-conduit-control-applet.c287
-rw-r--r--calendar/todo-conduit-control-applet.desktop6
-rw-r--r--calendar/todo-conduit.c256
-rw-r--r--calendar/todo-conduit.h59
-rw-r--r--calendar/topic.dat2
-rw-r--r--calendar/view-utils.c201
-rw-r--r--calendar/view-utils.h28
-rw-r--r--calendar/week-view.c100
-rw-r--r--calendar/week-view.h63
-rw-r--r--calendar/year-view.c741
-rw-r--r--calendar/year-view.h77
-rw-r--r--libversit/.cvsignore3
-rw-r--r--libversit/Makefile.am13
-rw-r--r--libversit/README.TXT951
-rw-r--r--libversit/port.h88
-rw-r--r--libversit/vcaltest.c118
-rw-r--r--libversit/vcaltmp.c337
-rw-r--r--libversit/vcaltmp.h128
-rw-r--r--libversit/vcc.h80
-rw-r--r--libversit/vcc.y1218
-rw-r--r--libversit/vctest.c95
-rw-r--r--libversit/vobject.c1452
-rw-r--r--libversit/vobject.h366
-rw-r--r--macros/ChangeLog85
-rw-r--r--macros/Makefile.am3
-rw-r--r--macros/autogen.sh19
-rw-r--r--macros/compiler-flags.m44
-rw-r--r--macros/gnome-bonobo-check.m44
-rw-r--r--macros/gnome-libgtop-check.m420
-rw-r--r--macros/gnome-pilot.m4114
-rw-r--r--macros/gnome-xml-check.m42
-rw-r--r--widgets/.cvsignore9
-rw-r--r--widgets/LICENSE1
-rw-r--r--widgets/Makefile.am57
-rw-r--r--widgets/e-canvas-utils.c36
-rw-r--r--widgets/e-canvas-utils.h24
-rw-r--r--widgets/e-canvas.c301
-rw-r--r--widgets/e-canvas.h71
-rw-r--r--widgets/e-cursors.c128
-rw-r--r--widgets/e-cursors.h33
-rw-r--r--widgets/e-minicard-label.c456
-rw-r--r--widgets/e-minicard-label.h84
-rw-r--r--widgets/e-minicard.c462
-rw-r--r--widgets/e-minicard.h91
-rw-r--r--widgets/e-minicard/e-minicard-label.c456
-rw-r--r--widgets/e-minicard/e-minicard-label.h84
-rw-r--r--widgets/e-minicard/e-minicard.c462
-rw-r--r--widgets/e-minicard/e-minicard.h91
-rw-r--r--widgets/e-minicard/e-reflow.c787
-rw-r--r--widgets/e-minicard/e-reflow.h104
-rw-r--r--widgets/e-minicard/test-minicard-label.c125
-rw-r--r--widgets/e-minicard/test-minicard.c115
-rw-r--r--widgets/e-minicard/test-reflow.c161
-rw-r--r--widgets/e-reflow.c787
-rw-r--r--widgets/e-reflow.h104
-rw-r--r--widgets/e-reflow/e-reflow.c787
-rw-r--r--widgets/e-reflow/e-reflow.h104
-rw-r--r--widgets/e-table/.cvsignore7
-rw-r--r--widgets/e-table/ChangeLog583
-rw-r--r--widgets/e-table/LICENSE1
-rw-r--r--widgets/e-table/Makefile.am60
-rw-r--r--widgets/e-table/ROADMAP.e-table113
-rw-r--r--widgets/e-table/TODO24
-rw-r--r--widgets/e-table/add-col.xpm22
-rw-r--r--widgets/e-table/check-empty.xpm21
-rw-r--r--widgets/e-table/check-filled.xpm21
-rw-r--r--widgets/e-table/e-cell-checkbox.c44
-rw-r--r--widgets/e-table/e-cell-checkbox.h24
-rw-r--r--widgets/e-table/e-cell-string.c9
-rw-r--r--widgets/e-table/e-cell-text.c508
-rw-r--r--widgets/e-table/e-cell-text.h28
-rw-r--r--widgets/e-table/e-cell-toggle.c298
-rw-r--r--widgets/e-table/e-cell-toggle.h35
-rw-r--r--widgets/e-table/e-cell.c176
-rw-r--r--widgets/e-table/e-cell.h73
-rw-r--r--widgets/e-table/e-table-col-dnd.h10
-rw-r--r--widgets/e-table/e-table-col.c64
-rw-r--r--widgets/e-table/e-table-col.h44
-rw-r--r--widgets/e-table/e-table-column-item.c199
-rw-r--r--widgets/e-table/e-table-column-item.h20
-rw-r--r--widgets/e-table/e-table-column-model.h5
-rw-r--r--widgets/e-table/e-table-column.c293
-rw-r--r--widgets/e-table/e-table-group.c269
-rw-r--r--widgets/e-table/e-table-group.h63
-rw-r--r--widgets/e-table/e-table-header-item.c793
-rw-r--r--widgets/e-table/e-table-header-item.h56
-rw-r--r--widgets/e-table/e-table-header.c342
-rw-r--r--widgets/e-table/e-table-header.h65
-rw-r--r--widgets/e-table/e-table-item.c1316
-rw-r--r--widgets/e-table/e-table-item.h106
-rw-r--r--widgets/e-table/e-table-model.c176
-rw-r--r--widgets/e-table/e-table-model.h58
-rw-r--r--widgets/e-table/e-table-render.c20
-rw-r--r--widgets/e-table/e-table-render.h21
-rw-r--r--widgets/e-table/e-table-simple.c112
-rw-r--r--widgets/e-table/e-table-simple.h37
-rw-r--r--widgets/e-table/e-table-sorted.c89
-rw-r--r--widgets/e-table/e-table-sorted.h29
-rw-r--r--widgets/e-table/e-table-subset.c178
-rw-r--r--widgets/e-table/e-table-subset.h32
-rw-r--r--widgets/e-table/e-table-tree.h19
-rw-r--r--widgets/e-table/e-table.c558
-rw-r--r--widgets/e-table/e-table.h48
-rw-r--r--widgets/e-table/image1.pngbin1858 -> 0 bytes
-rw-r--r--widgets/e-table/image2.pngbin1987 -> 0 bytes
-rw-r--r--widgets/e-table/image3.pngbin2051 -> 0 bytes
-rw-r--r--widgets/e-table/remove-col.xpm22
-rw-r--r--widgets/e-table/sample.table11
-rw-r--r--widgets/e-table/table-test.c43
-rw-r--r--widgets/e-table/table-test.h4
-rw-r--r--widgets/e-table/test-check.c153
-rw-r--r--widgets/e-table/test-cols.c196
-rw-r--r--widgets/e-table/test-table.c304
-rw-r--r--widgets/e-table/test.c17
-rw-r--r--widgets/e-text-event-processor-emacs-like.c357
-rw-r--r--widgets/e-text-event-processor-emacs-like.h68
-rw-r--r--widgets/e-text-event-processor-types.h136
-rw-r--r--widgets/e-text-event-processor.c103
-rw-r--r--widgets/e-text-event-processor.h74
-rw-r--r--widgets/e-text.c2391
-rw-r--r--widgets/e-text.h192
-rw-r--r--widgets/e-text/e-text-event-processor-emacs-like.c357
-rw-r--r--widgets/e-text/e-text-event-processor-emacs-like.h68
-rw-r--r--widgets/e-text/e-text-event-processor-types.h136
-rw-r--r--widgets/e-text/e-text-event-processor.c103
-rw-r--r--widgets/e-text/e-text-event-processor.h74
-rw-r--r--widgets/e-text/e-text.c2391
-rw-r--r--widgets/e-text/e-text.h192
-rw-r--r--widgets/meeting-time-sel/.cvsignore7
-rw-r--r--widgets/meeting-time-sel/LICENSE1
-rw-r--r--widgets/meeting-time-sel/Makefile.am30
-rw-r--r--widgets/meeting-time-sel/e-meeting-time-sel-item.c924
-rw-r--r--widgets/meeting-time-sel/e-meeting-time-sel-item.h78
-rw-r--r--widgets/meeting-time-sel/e-meeting-time-sel-list-item.c303
-rw-r--r--widgets/meeting-time-sel/e-meeting-time-sel-list-item.h74
-rw-r--r--widgets/meeting-time-sel/e-meeting-time-sel-mail.xpm135
-rw-r--r--widgets/meeting-time-sel/e-meeting-time-sel-no-mail.xpm123
-rw-r--r--widgets/meeting-time-sel/e-meeting-time-sel.c3065
-rw-r--r--widgets/meeting-time-sel/e-meeting-time-sel.h496
-rw-r--r--widgets/meeting-time-sel/test-meeting-time-sel.c236
-rw-r--r--widgets/misc/e-canvas-utils.c36
-rw-r--r--widgets/misc/e-canvas-utils.h24
-rw-r--r--widgets/misc/e-canvas.c301
-rw-r--r--widgets/misc/e-canvas.h71
-rw-r--r--widgets/misc/e-colors.c73
-rw-r--r--widgets/misc/e-colors.h14
-rw-r--r--widgets/misc/e-cursors.c38
-rw-r--r--widgets/misc/e-cursors.h38
-rw-r--r--widgets/misc/e-gui-utils.c58
-rw-r--r--widgets/misc/e-gui-utils.h12
-rw-r--r--widgets/misc/e-reflow.c787
-rw-r--r--widgets/misc/e-reflow.h104
-rw-r--r--widgets/misc/pixmaps/cursor_cross.xpm38
-rw-r--r--widgets/misc/pixmaps/cursor_hand_closed.xpm38
-rw-r--r--widgets/misc/pixmaps/cursor_hand_open.xpm38
-rw-r--r--widgets/misc/pixmaps/cursor_zoom_in.xpm37
-rw-r--r--widgets/misc/pixmaps/cursor_zoom_out.xpm37
-rw-r--r--widgets/shortcut-bar/.cvsignore7
-rw-r--r--widgets/shortcut-bar/LICENSE1
-rw-r--r--widgets/shortcut-bar/Makefile.am33
-rw-r--r--widgets/shortcut-bar/e-clipped-label.c361
-rw-r--r--widgets/shortcut-bar/e-clipped-label.h90
-rw-r--r--widgets/shortcut-bar/e-group-bar.c1498
-rw-r--r--widgets/shortcut-bar/e-group-bar.h171
-rw-r--r--widgets/shortcut-bar/e-icon-bar-bg-item.c361
-rw-r--r--widgets/shortcut-bar/e-icon-bar-bg-item.h72
-rw-r--r--widgets/shortcut-bar/e-icon-bar-text-item.c1696
-rw-r--r--widgets/shortcut-bar/e-icon-bar-text-item.h158
-rw-r--r--widgets/shortcut-bar/e-icon-bar.c1450
-rw-r--r--widgets/shortcut-bar/e-icon-bar.h222
-rw-r--r--widgets/shortcut-bar/e-shortcut-bar.c562
-rw-r--r--widgets/shortcut-bar/e-shortcut-bar.h114
-rw-r--r--widgets/shortcut-bar/e-vscrolled-bar.c652
-rw-r--r--widgets/shortcut-bar/e-vscrolled-bar.h97
-rw-r--r--widgets/shortcut-bar/test-shortcut-bar.c445
-rw-r--r--widgets/table/.cvsignore7
-rw-r--r--widgets/table/add-col.xpm22
-rw-r--r--widgets/table/check-empty.xpm21
-rw-r--r--widgets/table/check-filled.xpm21
-rw-r--r--widgets/table/e-cell-checkbox.c44
-rw-r--r--widgets/table/e-cell-checkbox.h24
-rw-r--r--widgets/table/e-cell-string.c9
-rw-r--r--widgets/table/e-cell-text.c508
-rw-r--r--widgets/table/e-cell-text.h28
-rw-r--r--widgets/table/e-cell-toggle.c298
-rw-r--r--widgets/table/e-cell-toggle.h35
-rw-r--r--widgets/table/e-cell.c176
-rw-r--r--widgets/table/e-cell.h73
-rw-r--r--widgets/table/e-table-col-dnd.h10
-rw-r--r--widgets/table/e-table-col.c64
-rw-r--r--widgets/table/e-table-col.h44
-rw-r--r--widgets/table/e-table-column-item.c199
-rw-r--r--widgets/table/e-table-column-item.h20
-rw-r--r--widgets/table/e-table-column-model.h5
-rw-r--r--widgets/table/e-table-column.c293
-rw-r--r--widgets/table/e-table-group.c269
-rw-r--r--widgets/table/e-table-group.h63
-rw-r--r--widgets/table/e-table-header-item.c793
-rw-r--r--widgets/table/e-table-header-item.h56
-rw-r--r--widgets/table/e-table-header.c342
-rw-r--r--widgets/table/e-table-header.h65
-rw-r--r--widgets/table/e-table-item.c1316
-rw-r--r--widgets/table/e-table-item.h106
-rw-r--r--widgets/table/e-table-model.c176
-rw-r--r--widgets/table/e-table-model.h58
-rw-r--r--widgets/table/e-table-render.c20
-rw-r--r--widgets/table/e-table-render.h21
-rw-r--r--widgets/table/e-table-simple.c112
-rw-r--r--widgets/table/e-table-simple.h37
-rw-r--r--widgets/table/e-table-sorted.c89
-rw-r--r--widgets/table/e-table-sorted.h29
-rw-r--r--widgets/table/e-table-subset.c178
-rw-r--r--widgets/table/e-table-subset.h32
-rw-r--r--widgets/table/e-table-tree.h19
-rw-r--r--widgets/table/e-table.c558
-rw-r--r--widgets/table/e-table.h48
-rw-r--r--widgets/table/image1.pngbin1858 -> 0 bytes
-rw-r--r--widgets/table/image2.pngbin1987 -> 0 bytes
-rw-r--r--widgets/table/image3.pngbin2051 -> 0 bytes
-rw-r--r--widgets/table/remove-col.xpm22
-rw-r--r--widgets/table/sample.table11
-rw-r--r--widgets/table/table-test.c43
-rw-r--r--widgets/table/table-test.h4
-rw-r--r--widgets/table/test-check.c153
-rw-r--r--widgets/table/test-cols.c196
-rw-r--r--widgets/table/test-table.c304
-rw-r--r--widgets/table/test.c17
-rw-r--r--widgets/test-minicard-label.c125
-rw-r--r--widgets/test-minicard.c115
-rw-r--r--widgets/test-reflow.c161
-rw-r--r--widgets/text/e-text-event-processor-emacs-like.c357
-rw-r--r--widgets/text/e-text-event-processor-emacs-like.h68
-rw-r--r--widgets/text/e-text-event-processor-types.h136
-rw-r--r--widgets/text/e-text-event-processor.c103
-rw-r--r--widgets/text/e-text-event-processor.h74
-rw-r--r--widgets/text/e-text.c2391
-rw-r--r--widgets/text/e-text.h192
424 files changed, 29 insertions, 109822 deletions
diff --git a/calendar/.cvsignore b/calendar/.cvsignore
deleted file mode 100644
index 7f966ac096..0000000000
--- a/calendar/.cvsignore
+++ /dev/null
@@ -1,12 +0,0 @@
-Makefile.in
-Makefile
-.deps
-_libs
-.libs
-gncal
-gnomecal
-getdate.c
-GnomeCal-skels.c
-GnomeCal-common.c
-GnomeCal.h
-calendar-pilot-sync
diff --git a/calendar/AUTHORS b/calendar/AUTHORS
deleted file mode 100644
index 7e482aef97..0000000000
--- a/calendar/AUTHORS
+++ /dev/null
@@ -1,4 +0,0 @@
-Miguel de Icaza <miguel@kernel.org>
-Federico Mena <federico@helixcode.com>
-Arturo Esponosa <arturo@nuclecu.unam.mx>
-Russell Steinthal <rms39@columbia.edu>
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
deleted file mode 100644
index 489b0f319c..0000000000
--- a/calendar/ChangeLog
+++ /dev/null
@@ -1,2625 +0,0 @@
-2000-02-04 Federico Mena Quintero <federico@helixcode.com>
-
- * cal-backend.c (get_calendar_base_vobject): New function to
- create the base VObject for a calendar.
- (cal_backend_get_object): Create the base calendar and add the
- sought object to it, then stringify it.
-
- * evolution-calendar.idl (Listener::obj_added
- Listener::obj_changed): Now these pass in just the UIDs, not the
- complete objects.
-
- * cal-listener.c (Listener_obj_added): Changed to pass in the uid,
- not the object.
- (Listener_obj_changed): Likewise.
-
- * cal-client.h (CalClientClass): Made the obj_added and
- obj_changed signals take in the UIDs, not the full objects.
-
- * cal-client.c (obj_added_cb): Likewise.
- (obj_changed_cb): Likewise.
-
-2000-02-04 Federico Mena Quintero <federico@helixcode.com>
-
- * cal-backend.c (CalBackendPrivate): Renamed the event_hash field
- to object_hash. Now we hash all the calendar's objects here based
- on their UIDs.
- (ensure_uid): New function to create UIDs for calendar objects
- that don't have them.
- (add_object): Ensure the object has an UID before inserting it in
- the calendar.
- (cal_backend_get_object): New function.
-
-2000-02-03 Federico Mena Quintero <federico@helixcode.com>
-
- * evolution-calendar.idl (Cal): Added the get_object() method.
-
- * cal-client.c (cal_client_get_object): New function to get a
- calendar object by its UID.
-
- * cal.c (Cal_get_object): Implemented.
-
- * cal-backend.c (cal_backend_get_object): New unfinished backend
- function. We need some reorganizing of how the calendar objects
- are stored.
-
-2000-02-02 Federico Mena Quintero <federico@helixcode.com>
-
- * Makefile.am (gnomecal_SOURCES): Added the CORBA generated
- sources.
-
-2000-02-01 Federico Mena Quintero <federico@helixcode.com>
-
- * cal-client.c (cal_loaded): Handle the cal_loaded signal from the
- listener. Store the calendar client interface object, and emit
- our own cal_loaded signal.
- (cal_client_load_calendar): Connect to the listener's signals.
- (cal_client_class_init): Added the "obj_added", "obj_removed",
- öbj_changed" signals.
- (obj_added_cb): Handle the signal from the listener.
- (obj_removed_cb): Likewise.
- (obj_changed_cb): Likewise.
-
-2000-01-30 Federico Mena Quintero <federico@helixcode.com>
-
- * Makefile.am (gnomecal_SOURCES): Added cal-client.[ch] and
- cal-listener.[ch].
-
-2000-01-30 Federico Mena Quintero <federico@helixcode.com>
-
- * evolution-calendar.idl: Changed the namespace from
- GNOME::Calendar to Evolution::Calendar.
- (Listener::LoadStatus): Fixed SUCESSS -> SUCCESS typo. And I
- never noticed it in the implementation. Ain't M-/ grand?
-
- * Makefile.am: Changed ocurrences of gnome-calendar.idl to
- evolution-calendar.idl.
-
- * *.[ch]: Changed GNOME_Calendar_foo identifiers to
- Evolution_Calendar_foo.
-
-2000-01-25 Federico Mena Quintero <federico@helixcode.com>
-
- * cal-client.c cal-client.h: New files with the calendar client
- object.
-
-2000-01-25 Federico Mena Quintero <federico@helixcode.com>
-
- * cal-factory.c (CalFactory_load): Check that the listener is not
- nil and emit and exception if it is.
-
- * gnome-calendar.idl (CalFactory::load CalFactory::create): Now
- these raise the NilListener exception.
-
- * tlacuache.c (calendar_notify): Error stub for alarms.
- (alarm_defaults): Stub array.
- (debug_alarms): Stub variable.
- (main): Initialize gnome-vfs.
-
-2000-01-24 Federico Mena Quintero <federico@helixcode.com>
-
- * tlacuache.c: New main module for the Tlacuache personal calendar
- server.
-
- * tlacuache.gnorba: New gnorba file for Tlacuache, the GNOME
- personal calendar server.
-
- * Makefile.am: Added the stuff necessary to build Tlacuache.
-
- * cal.c (Cal_get_uri): Convert the URI to a string before
- returning it.
-
- * cal-factory.c (CalFactory_create): Doh, this function is void.
-
- * job.c (job_add): Use g_idle_add(), not gtk_idle_add().
-
-2000-01-24 Federico Mena Quintero <federico@helixcode.com>
-
- * cal-backend.c (cal_backend_remove_cal): New function to remove a
- calendar client interface object from a backend.
- (cal_backend_load): Convert the URI to string and use
- Parse_MIME_FromFileName(). The conversion is not very smart,
- though.
-
- * cal-factory.c (load_backend): Moved most of the error handling
- upstream to load_fn().
- (load_fn): Handle failure in case the backend could not be loaded.
- (cal_factory_destroy): Free the backends and the backend hash
- table.
- (add_calendar_client): Implemented. We create a Cal client
- interface object and attach it to the backend, and we notify the
- listener.
-
-2000-01-22 Federico Mena Quintero <federico@helixcode.com>
-
- * cal-factory.c (lookup_backend): Renamed from lookup_calendar().
- Also, return a backend instead of a Cal client object.
-
- * cal-backend.c (cal_backend_load): Take in a GnomeVFSURI, not a
- string.
-
- * cal-listener.c (Listener_cal_loaded): Pass the load status to
- the signal.
- (cal_listener_destroy): Better error checking.
- (cal_listener_new): Better error checking.
-
- * cal-listener.h (CalListenerLoadStatus): New enum for the load
- status of a calendar.
- (CalListenerClass): Added the status argument to the cal_loaded
- signal.
-
- * gnome-calendar.idl (cal_loaded): Added a load status code.
-
- * cal-backend.h (CalBackendLoadStatus): Renamed from
- CalBackendLoadResult.
-
-2000-01-18 Federico Mena Quintero <federico@helixcode.com>
-
- * cal-backend.c cal-backend.h: Moved the calendar backend here.
- This is the actual calendar-handling object.
- (load_from_vobject): Moved over from calendar.c. Modified to use
- a CalBackend instead of the old Calendar structure.
- (add_object): Likewise.
-
- * cal.c: Now the Cal object is just a calendar client interface
- object; we use it as a "viewport" onto a CalBackend. This also
- lets us do correct resource management.
-
- * cal-common.h: New file with common forward declarations; we
- can't have circular dependencies between headers.
-
-2000-01-18 Federico Mena Quintero <federico@helixcode.com>
-
- * cal-factory.c (cal_factory_load): Queue a load job.
- (load_fn): Load job handler. Lookup the calendar by URI, load it
- if it is not loaded, or just report it to the new listener if it is.
-
- * job.c job.h: New files with a simple job queue manager.
-
- * gnome-calendar.idl (Listener::cal_loaded): Do not return the
- whole calendar object string. The client will be able to query
- the calendar for the events it needs.
-
- * cal-listener.c (Listener_cal_loaded): Ref the calendar GNOME
- object. We unref it when the listener is destroyed.
-
-2000-01-17 Federico Mena Quintero <federico@helixcode.com>
-
- The files from the gncal directory of the gnome-pim module on CVS
- were moved here, to evolution/calendar, in preparation for the
- Evolution work. The calendar is being split into a model/view
- architecture. The model is a personal calendar server (PAS): it
- provides storage, notification, and event generation; the
- views/controllers are the calendar user agents and things like
- Pilot synchronizers.
-
-2000-01-11 Federico Mena Quintero <federico@helixcode.com>
-
- * cal.c: Removed the CORBA listener methods, adjusted for the new
- IDL.
-
- * cal-listener.c (cal_listener_init): Create the private
- structure. In it we hold a reference to the calendar the listener
- is watching.
- (cal_listener_destroy): Destroy the private structure and unref
- the calendar.
- (Listener_cal_loaded): Stuff the calendar into our private data.
- (Listener_obj_added): Adjusted for new IDL.
- (Listener_obj_removed): Likewise.
-
- * gnome-calendar.idl: New IDL for the personal calendar server.
-
- * cal.h cal.c: New files with the calendar object.
-
- * cal-listener.h cal-listener.c: New files with the calendar
- listener object.
-
- * cal-factory.h cal-factory.c: New files with the calendar factory
- object.
-
-2000-01-09 Eskil Heyn Olsen <deity@eskil.dk>
-
- * Makefile.am: Changes to remove todo capplet stuff from distro.
-
-2000-01-08 Vadim Strizhevsky <vadim@optonline.net>
-
- * calendar-conduit-control-applet.c: Added pilotID argument to
- gpilotd_conduit_mgmt_new.
-
-
-2000-01-05 Eskil Heyn Olsen <deity@eskil.dk>
-
- * GnomeCal.idl: Added an argument to get_number_of_objects, so you
- can choose which state the object should have
- (any/new/modified/...). Will also add one to choose type
- (event/journal etc).
-
- * corba-cal.c (cal_repo_get_number_of_objects): Implemented the
- new version of get_number_of_objects.
-
- * calendar-conduit.c (pre_sync): Calls various
- gnome_pilot_conduit_standard_abs_set_num_yadayda to get progress bars.
-
-2000-01-04 Eskil Heyn Olsen <deity@eskil.dk>
-
- * calendar-conduit.c (start_calendar_server): Let's not call
- g_error, but g_warning instead.
- (pre_sync): Get record numbers info, total, new, deleted etc, and
- tell gpilotd.
-
-1999-12-31 Eskil Heyn Olsen <deity@eskil.dk>
-
- * eventedit.c (ee_store_recur_end_to_ical): Adds 86400 secs (1
- day) to the date chooses by the user. This ensures the recurrence
- also occurs on that date.
- (ee_rp_init_ending_date): And subtracts 86400 secs when about to
- redisplay the box.
-
- * calendar.h: Added an argument to calendar_new, to enable certain
- features, such as initing alarms or nor.
-
- * calendar.c (calendar_new): Implemented support for the
- CALENDAR_INIT_ALARMS option to calendar_new.
-
- * corba-cal.c (cal_repo_get_updated_objects): Added
- CALENDAR_INIT_ALARMS to calendar_new calls.
-
- * main.c: Added CALENDAR_INIT_ALARMS to calendar_new calls. This
- should probably be CALENDAR_INIT_NIL, but I'm not sure, guess
- steintr should check it.
-
- * gnome-cal.c: Added CALENDAR_INIT_ALARMS to calendar_new calls.
-
- * calendar-pilot-sync.c: Added CALENDAR_INIT_NIL to calendar_new calls.
-
-1999-12-10 Russell Steinthal <rms39@columbia.edu>
-
- * eventedit.c (ee_create_ae): Fix sensitivity bug when used to
- create default alarm box (widgets in that box should always be
- sensitive, even if the enabled checkbutton is not set)
-
-1999-12-08 Eskil Heyn Olsen <deity@eskil.dk>
-
- * calendar-conduit-control-applet.c (setSettings): Capplets now
- sets first_sync on enable, this should make the conduit copy old
- entries from the pilot to gnomecal.
-
-1999-12-07 Eskil Heyn Olsen <deity@eskil.dk>
-
- * calendar-conduit.c (pre_sync): Check if local store is
- empty. If, force slow sync.
-
- * GnomeCal.idl (GNOME): Added get_number_of_objects.
-
- * corba-cal.c (cal_repo_get_number_of_objects): implemented the
- get_number_of_objects.
-
- * calendar-conduit-control-applet.c (setStateCfg): Fixed bug that
- caused the capplet to always set the sync action to Disable upon start.
-
-1999-12-05 Eskil Heyn Olsen <deity@eskil.dk>
-
- * Makefile.am (Conduits_second_DATA): Also install .desktop files
- for conduit capplets in the gnome/apps menu dir.
-
->>>>>>> 1.252
-1999-12-04 Eskil Heyn Olsen <deity@eskil.dk>
-
- * Makefile.am (EXTRA_DIST): Added .desktop files to EXTRA_DIST.
-
-1999-10-12 Clifford R. Conover <rusty@zootweb.com>
-
- * gncal-todo.c Todo List improvements.
-
- Cleaned up todo item highlighting, added support for highlighting
- events due today, and events not due yet. Colors are configurable
- on the Colors Tab of the properties window.
-
- Renamed Frame in Properties window to Colors rather then Month
- Colors since we are now asking for Todo item colors.
-
- Added ability to display time until todo item is due in list, it
- automatically selects the best denomination of time (up to weeks)
- and down to seconds to display. This should be made configurable
- in a future version.
-
- Changed Todo dialog to ask for time that event is due. This
- allows more accurate tracking of then the item is due, before the
- dialog was only asking for the date of the todo item.
-
-1999-12-03 Eskil Heyn Olsen <deity@eskil.dk>
-
- * calendar-conduit.c: undef DEBUG_CALCONDUT, suppresses debug output.
-
-1999-12-02 Russell Steinthal <rms39@columbia.edu>
-
- * alarm.c: Enhanced debug support: can be toggled on and off by
- SIGUSR1, reports alarms which could not be added
-
- * gnome-cal.c, main.[ch], prop.c: Add snooze capability for audio
- and display alarms. Snooze interval can be configured in the
- Properties box.
-
-1999-11-30 Eskil Heyn Olsen <deity@eskil.dk>
-
- * calendar-conduit.c (compare): Fixed compare bug. Also neated up
- some of the if's in set_status.
-
-1999-11-22 Russell Steinthal <rms39@columbia.edu>
-
- * Merged todo list coloring patch from stable
- * Added myself to AUTHORS, about box (per Miguel)
-
-1999-11-22 Eskil Heyn Olsen <deity@eskil.dk>
-
- * calendar-conduit.c (pre_sync): Writes some warning
- messages when pre_sync fails.
-
-1999-11-14 Eskil Heyn Olsen <deity@eskil.dk>
-
- * Makefile.am: Stupid misplaced endif cause gncal to depend on an
- install gnome-pilot... fixed... sorry.
-
-1999-11-12 Eskil Heyn Olsen <deity@eskil.dk>
-
- * Makefile.am (extra_pilot_bins): Fixed the if then else problem,
- using solution suggested by James Henstridge, appears to be caused
- by a (by now fixed) bug in my automake.
-
-1999-11-12 Russell Steinthal <rms39@columbia.edu>
-
- * prop.c: Config code for timeout, make Alarms property page use a
- vbox instead of an hbox so that the propbox stays a reasonable width.
-
- * gnome-cal.c, main.[ch]: Add timeout for audio alarms, code to load
- from config file
-
- * eventedit.c: Give some static functions external linkage so they
- can be used elsewhere (make_spin_button); add some prototypes to
- appease gcc.
-
-1999-11-11 Russell Steinthal <rms39@columbia.edu>
-
- * calendar.c (calendar_day_change): Add call to
- calendar_init_alarms() to schedule another day change alarm.
-
-1999-11-09 Eskil Heyn Olsen <deity@eskil.dk>
-
- * calendar-conduit.c: Enabled debug output. Sets a g_log_domain,
- now version 0.8.5. Consistent use of GSList/GList. Implemented
- compare, default uses one that compares the contents of a struct
- Appointment, but also has #ifdeffed code that does a field level
- comparison, not complete, but perhaps educational.
-
- * Makefile.am (#todo_conduit_control_applet_SOURCES): Fixed an
- unwanted conditional on libcalendar_conduit_la_LDFLAGS
-
-1999-11-05 Eskil Heyn Olsen <deity@eskil.dk>
-
- * calendar-conduit-control-applet.c (readStateCfg): Commented the
- code out, thus the capplet works again.
-
-1999-11-04 Eskil Olsen <deity@eskil.dk>
-
- * Makefile.am: Uses the PISOCK_LIBDIR, for people with odd install
- dirs for their pilot-link. Also install a pretty icon for the
- calendar-conduit.
-
- * calendar-conduit-control-applet.c: Modfied the
- try/revert/ok/cancel scheme to be more intuitive, also uses a
- GtkOptionMenu for the possible sync methods.
-
- * calendar-conduit-control-applet.desktop: use the nice icon...
-
- * calendar-conduit.c: Ack, had to define debug_alarms and
- alarm_default, otherwise they are undefined. Is gncal code messy
- or is this considered a way of configuring the cal engine ?
- Implemented delete_all syncabs methods.
-
- * calendar-pilot-sync.c: also had to declare debug_alarms and
- alarm_defaults, just as ugly.
-
-1999-11-02 Russell Steinthal <rms39@columbia.edu>
-
- * prop.c: Add new alarm page to properties box
-
- * prop.c, calobj.c, main.[ch] eventedit.c: New support for default
- alarms, configurable in the properties box.
-
- * gnome-cal.c, prop.c, main.[ch]: add option to beep on Display
- alarms
-
-1999-10-23 Russell Steinthal <rms39@columbia.edu>
-
- * calendar.c (calendar_new): Correctly initialize calendar_day_end
- and calendar_day_begin *before* installing day-change alarm.
-
-1999-10-21 Russell Steinthal <rms39@columbia.edu>
-
- * alarm.c, main.c: Added alarm debugging code
-
- * main.c (open_ok): Show an error box if the user tries to open a
- non-existent file; fixes bug #1818
-
-1999-10-19 Russell Steinthal <rms39@columbia.edu>
-
- * gnome-cal.c (calendar_notify): Fix typos which were causing
- invalid times in audio notification dialogs; fixes Bug #2561
-
-1999-10-18 Russell Steinthal <rms39@columbia.edu>
-
- * gncal-day-panel.c (gncal_day_panel_new): Placed the various
- elements of the day view in paned windows so that the user can
- adjust the relative sizes of the daily schedule, monthly calendar,
- and to-do list.
-
-1999-10-18 Martin Norbäck <norpan@bigfoot.com>
-
- * gncal.desktop: Added swedish translation
-
-1999-10-13 Eskil Olsen <deity@eskil.dk>
-
- * Makefile.am: Hopefully the fixes the much-hated
- gnome-pilot dependency.
-
-1999-10-07 Eskil Olsen <deity@eskil.dk>
-
- * calendar.c (calendar_object_changed): moved the pilot_status =
- MOD up, so even a CHANGE_SUMMARY will set the modified flag.
-
- * calendar-conduit.c: more _free calls, vamped the noise on output.
-
-1999-10-06 Eskil Olsen <deity@eskil.dk>
-
- * *conduit*[ch]: checks return values from gpilotd_init/connect.
-
- * calender.c (vcalendar_create_from_calendar): removed a set
- of cleanVObject cleanStrTbl, since the freed memory that the
- function returned.
-
-1999-09-27 Timur Bakeyev <mc@bat.ru>
-
- * timeutil.c (time_from_isodate): Use tm.gmtoff or timezone to get
- correct offset from UTC, according to HAVE_TM_GMTOFF or HAVE_TIMEZONE.
- See also 1999-07-19 Matt Martin <matt@abacusnet.net>
-
-1999-09-27 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * month-view.c (add_event): ditto
- (mark_current_day): ditto
- (month_view_set): ditto
-
- * goto.c (goto_dialog): ditto.
-
- * gnome-month-item.c (gnome_month_item_init): ditto.
-
- * gncal-day-panel.c (gncal_day_panel_new): ditto.
-
- * getdate.c (RelativeDate): ditto.
-
- * eventedit.c (set_all_day): ditto.
- (ee_rp_init_rule): ditto.
-
- * calendar.c (vcalendar_create_from_calendar): ditto.
-
- * calendar-conduit.c (update_record): ditto.
-
- * calobj.c (ical_object_generate_events): Get rid of pointers to
- values returned from localtime, as it uses a static buffer.
-
-1999-09-26 Eskil Olsen <deity@eskil.dk>
-
- * corba-cal.c: the g_free that was commented out since glib said
- was a duplicate free, was supposed to be a free.
-
- * GnomeCal.idl/corba-cal.c: added a get_object_id_list and a
- get_objects_by_id_list. Latter is not done.
-
- * calendar-conduit.c: rewrote the way the conduit iterates over
- records. It no longers fetches all entries (since that didn't work
- with more then 285 entries. It now fetches the id list, and gets
- each record. (will be using get_objects_by_id_list to get records
- in amounts of 10 or so later, to reduce amount of corba calls).
-
- * calendar-conduit.c: now sets alarm parameters when transferring
- from gnomecal to pilot.
-
-1999-09-23 Eskil Olsen <deity@eskil.dk>
-
- * calendar-conduit.c: better merge of summary/description
- when doing ical_from_remote (update_record), also handles
- import from gnomecal to pilot better, and on both ways, repeat
- events are much better now.
-
-1999-09-22 Eskil Olsen <deity@eskil.dk>
-
- * corba-cal.c: commented out a g_free that glib reported
- as being a duplicate free.
- * calendar-conduit.c: got gnomecal->pilot up and runnning.
-
-1999-02-06 Lauris Kaplinski <lauris@ariman.ee>
-
- * gncal.desktop: Added Estonian translations.
-
-1999-09-14 Federico Mena Quintero <federico@redhat.com>
-
- * gncal-full-day.c (child_popup_menu): Set the data pointers for
- all the items.
-
-1999-09-14 Kjartan Maraas <kmaraas@online.no>
-
- * doc/C/gnomecal.sgml: Merge from gnome-pim-1-0. Synced with newest
- user-guide.
-
-1999-09-01 Miguel de Icaza <miguel@gnu.org>
-
- * eventedit.c (ee_create_buttons): Make the OK button the default
- button per Russell's suggestion.
-
-1999-08-30 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calendar.c (calendar_object_changed): Modify the
- object->last_mod field.
- (calendar_add_object): Ditto.
-
- Closes bug #676
-
- * main.c (save_calendar_cmd): Fix problem in which we warned the
- user about the calendar being modified the first time the calendar
- was used.
-
-1999-08-22 Tomas Ogren <stric@ing.umu.se>
-
- * gnomecal.gnorba: "GenericFactoy" is wrong...
-
-1999-08-15 Miguel de Icaza <miguel@gnu.org>
-
- * calobj.c (ical_gen_uid): Fix the hostname part.
-
-1999-08-07 Peter Teichman <pat4@acpub.duke.edu>
-
- * calendar-pilot-sync.c (sync_pilot): sync correctly for objects
- created on the pilot, but not dirty (because they have been synced
- with some other program in the past)
-
-1999-07-30 Miguel de Icaza <miguel@gnu.org>
-
- * month-view.c (month_view_init): Release points here.
-
-1999-08-02 Peter Teichman <pat4@acpub.duke.edu>
-
- * Makefile.am (libcalendar_conduit_la_LDFLAGS):
- libcalendar_conduit now installs
-
- * calendar-pilot-sync.c (sync_pilot): do deletion of appointments
- correctly, when they are deleted on the pilot
- (conduit_free_Appointment): protect against double-freeing parts
- of the Appointment structure
- (update_record): all-day events from the pilot are handled a bit
- more reasonably
-
-1999-08-01 Peter Teichman <pat4@acpub.duke.edu>
-
- * calendar-pilot-sync.c (sync_object_to_pilot): The multi-day
- appointment corruption bug is dead. Whoo!
-
-1999-07-31 Peter Teichman <pat4@acpub.duke.edu>
-
- * Makefile.am: fixed this up slightly with respect to pilot conduits
-
-1999-07-30 Jonathan Blandford <jrb@redhat.com>
-
- * Makefile.am (libcalendar_conduit_la_LIBADD): More autoconf-stuff
-
-1999-07-29 Jonathan Blandford <jrb@redhat.com>
-
- * gnome-cal.c (setup_widgets): Add scrolling to the yearview.
-
-1999-07-28 Miguel de Icaza <miguel@gnu.org>
-
- * calendar-pilot-sync.c: (sync_object_to_pilot): If the enddate is
- not set, set the repeatForever to 1. This fixes all of the
- birthdays problems I had.
-
- Make the code not take arguments
- (sync_cal_to_pilot): Nice event update information
-
- * calendar.c (calendar_new): Add Event UID hash table.
- (calendar_add_object): Add events to the hash table here.
- (calendar_remove_object): Remove events here.
- (calendar_object_find_event): Use the hash table here.
-
- * main.c (save_calendar_cmd): The object is already destroyed by
- gnome_dialog_run.
-
- * calendar-pilot-sync.c (sync_object_to_pilot): Do not turn
- archived bit on.
-
- * calobj.c (ical_gen_uid): Use the hostname, not the domain name.
- (ical_gen_uid): Add a serial number. Isodates can be small.
-
- * corba-cal.c (cal_repo_update_pilot_id): New method to update the
- pilot status.
- (cal_repo_get_updated_objects): New method. Returns a list of
- modified and not-sycned objects
-
- * calendar-pilot-sync.c (sync_cal_to_pilot): New function to sync
- from the GnomeCalendar to the pilot.
- (sync_object_to_pilot): Sync a single event to the pilot.
- (try_alarm): Alarm syncing code.
-
-1999-07-27 Miguel de Icaza <miguel@gnu.org>
-
- * calendar-pilot-sync.c: New file. Implements PalmPilot
- syncronization with the Gnome Calendar.
-
- * calobj.c (ical_object_new_from_string): New function. Creates
- an iCalObject from a vCalendar string that is supposed to contain
- only one vEvent.
-
- * calendar.c:
- (calendar_save): Split this routine in two.
-
- * gnome-cal.c (gnome_calendar_new): Create the corba server here.
-
- * main.c: Include gnorba.h, and corba-cal-factory.h here
- (close_cmd): Kill the calendar server on shutdown.
-
- * calobj.c (load_recur_yearly_day): Added a fixme comment. WE
- need to handle intervals in the years.
-
- * calendar.c (calendar_object_find_in_list, calendar_object_find,
- calendar_object_find_todo, calendar_object_find_event): New
- functions for looking up information.
-
- * main.c (gnome_calendar_locate): New function.
-
- * corba-cal.c (calendar_create_object): New file. Implements the
- corba server.
-
- * calendar.c (calendar_object_changed): Flag pilot-status as changed.
-
- * calobj.c (ical_object_to_vobject): Save pilot information for syncing.
- (ical_object_create_from_vobject): Load syncing information for
- pilot. Do it in a way compatible with KOrganizer.
-
-1999-07-26 Miguel de Icaza <miguel@gnu.org>
-
- * calobj.c (ical_object_create_from_vobject): Generate unique IDs
- on Vevents we load that lack it. WE need this for the old
- gnome calendar generated files (ie, before now :-).
-
- Required to sync with the Palm
-
-1999-07-26 Miguel de Icaza <miguel@gnu.org>
-
- * calobj.c (ical_object_create_from_vobject): Generate unique IDs
- on Vevents we load that lack it. WE need this for the old
- gnome calendar generated files (ie, before now :-).
-
- Required to sync with the Palm
-
-1999-07-19 Matt Martin <matt@abacusnet.net>
-
- * timeutil.c (time_from_isodate): Handle the 'Z' parameter to the
- ISO date format to convert from GMT time.
-
-1999-07-17 Nat Friedman <nat@gnome-support.com>
-
- * calendar.c (calendar_add_object): Copy the new UID into the
- iCalObject structure.
-
-1999-07-16 Miguel de Icaza <miguel@gnu.org>
-
- * gnome-month-item.c (gnome_month_item_set_arg): Merge fix from
- gnome-pim-1-0: Fixed cut&paste bug for day fontsets.
-
-1999-07-14 Miguel de Icaza <miguel@gnu.org>
-
- * calobj.c (ical_gen_uid): Returns a UID.
- (ical_object_new): Use a UID when creating an event. Should get
- syncing done easier.
-
-1999-07-14 Nicholas J Kreucher <nick@poetic.com>
-
- * calobj.c (skip_numbers): Actually skip over the numbers.
- (ical_object_to_vobject): Test the proper variable for storing the
- proper information.
-
-1999-07-14 Jean-Noel Guiheneuf <jean-noel.guiheneuf@wanadoo.fr>
-
- * timeutil.c (time_add_month): Fixed the problem with next month
- going from a 31-day to a 30-day by adjusting the date to the
- closest day at the end of the month.
-
-1999-06-07 Mike McEwan <mike@lotusland.demon.co.uk>
-
- * timeutil.c (time_add_month): Tell ktime' that we don't know
- about daylight saving time so that it does *not* make adjustments
- when we traverse a DST boundary.
- (time_year_begin): ditto.
- (time_year_end): ditto.
- (time_month_begin): ditto.
- (time_month_end): ditto.
-
-1999-06-16 Anders Carlsson <anders.carlsson@tordata.se>
-
- * main.c (new_calendar): Realize the toplevel widget when
- --hidden is passed to gnomecal. This fixes a segfault.
-
-1999-06-04 Robert Brady <rwb197@ecs.soton.ac.uk>
-
- * gnome-cal.h, gnome-cal.c: Fix abort() problem with the year view.
- (Bug #1367). Thanks to Owen Cliffe <oc197@ecs.soton.ac.uk> for
- helping track it down.
-
-1999-06-03 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c (daynumberlist): One line bug fix from Sergey I Panov.
-
-1999-06-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * view-utils.c (nicetime): Use %H instead of %k, as %k is a GNU
- extension, not available in other systems.
-
-1999-06-01 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c (daynumberlist): Work around broken software that
- writes a broken month-of-day as "zero". Use the dtstart date for
- this on this event.
-
-1999-05-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * Makefile.am (install-data-local): help files be gone. They are
- now installed from the Docbook stuff.
-
-1999-05-26 Russell Steinthal <steintr@condor.penguinpowered.com>
-
- * gncal-todo.c main.c main.h prop.c: Added support for priorities
- for todo items. Doesn't do much, but you can set them and sort by
- them. (Use the properties box to enable them; should they be on
- by default?)
-
-1999-05-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * main.c (parse_an_arg): Added missing break here. It was causing
- core dumps when invoked with --userfile.
-
- * gnome-cal.c (gnome_calendar_set_view): Add some assertions here,
- to pin point the bug reported on gnome-list.
-
- * calobj.c (load_recurrence): Make intervals always exist. a 0
- interval is wrong.
-
-1999-05-25 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * year-view.c: Removed unused macro CALENDAR_HEIGHT.
-
-1999-05-25 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * year-view.c (idle_handler): Set the canvas scroll region here,
- not in size_allocate(). Also, use the correct width and height
- based on the allocation and the precomputed minimum width/height
- values.
-
- * gnome-cal.c (setup_widgets): Set the scrollbar policy of the
- scrolled window.
-
- * main.c (setup_appbar): Use the correct type for the appbar.
-
- * gncal-day-view.c: Removed unused function switch_to_day().
-
- * gncal-day-panel.c (calendar_day_selected): Removed unused variable.
-
-1999-05-25 Nat Friedman <nat@nat.org>
-
- * doc/C/gnomecal.sgml: Fixed a typo.
-
- * gnome-cal.c (setup_widgets): Added a scrolled window widget into
- which the year view is placed.
-
- * year-view.c (CALENDAR_HEIGHT): The height of the total year view
- inside the scrolled window.
- (idle_handler): Set the height of the year view to
- CALENDAR_HEIGHT.
- (year_view_size_allocate): Set the scroll region of the year view
- canvas to allocation->width, CALENDAR_HEIGHT.
-
-1999-04-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * main.c (dump_todo): Add --todo flag to dump the todo contents.
-
-1999-04-19 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-todo.c (add_activated): Use same hack used in edit_activated
-
-1999-04-16 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-todo.c (edit_activated): Kill all grabs from the CList
- before running the new dialog box.
-
- This fixes the problem of button-3/Edit on the todo item blocking
- the GUI (actually, the main window responds, but not the todo
- window).
-
-1999-04-08 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-todo.c (gncal_todo_init): Make sure we can get events for
- button3. The code for the nice popup menu was there but was not
- getting invoked.
-
-1999-04-01 Steve Murphy <murf@e-tools.com>
-
- * calobj.c (weekdaynum): Added this routine so Monthly recurrences
- use the weekday field as a simple integer for a single weekday.
-
- * calobj.c (load_recur_monthly_pos): Call weekdaynum instead of
- weekdaylist. The interface only lets the user input a single value
- anyway.
-
- * calobj.c (ical_object_to_vobject): instead of code to output day
- names from a bit array, use instead the value as an int and output
- a single dayname.
-
- * calobj.c (ical_object_generate_events): first_week_day gets the
- day int instead of the first entry in the bit field. I inserted a
- fair chunk of code to avoid calling generate if the day is out of
- range for a month. It may be unneccessary, because mktime will
- turn the extra days into a valid date the next month. But not all
- mktimes are equal, I fear.
-
- * eventedit.c (ee_store_recur_rule_to_ical): For case 3,
- (Monthly), I added code to set the interval slot of the recur
- struct; without this value, selecting a monthly recursing, by
- date, would lead to an infinite loop broken only by a failure to
- alloc more memory. Also, in the "by position" case, both
- u.month_pos and u.month_day were being assigned values. This is a
- mistake, as they are both part of an union, and the same
- thing. The weekday field should get the recur_rr_month_weekday
- value.
-
- * eventedit.c (ee_rp_init_rule): set default day from the weekday
- field instead of the u.month_day field, which is really the
- month_pos value.
-
- * gnome-cal.c (gnome_calendar_tag_calendar): Month days start with
- 1, not 0; thus, setting tm.tm_mday = 0, and then calling mktime
- will generate a time corresponding to the end of the previous
- month, which may have a mday anywhere from 28 to 31. The end time
- just adds 1 to the month, so your end time may not cover the last
- few days of this month, depending on what the biggest mday of last
- month was. I changed it so tm_mday is set to 1 instead.
-
-1999-03-30 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-todo.c (convert_time_t_to_char): Made static. Make it use
- the full year format for strftime().
-
-1999-03-27 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
-
- * calobj.c: Include <config.h> So that strings get translated.
-
-1999-03-26 Tomas Ogren <stric@ing.umu.se>
-
- * prop.c (build_hours_menu): Made it respect 12/24h settings..
- Doesn't show until next time you open the dialog.. yet..
-
-1999-03-24 Tomas Ogren <stric@ing.umu.se>
-
- * gncal-week-view.c (gncal_week_view_set): Did some i18n work
- * eventedit.c (get_exception_string): Did some i18n work
-
-1999-03-24 Tomas Ogren <stric@ing.umu.se>
-
- * gncal-todo.c (gncal_todo_init): Made clist titles i18n:able
- * main.c (poptOption): Added which views that are possible for
- --view in the --help text (closes #367)
- * main.c (dump_events): Added (short) month to the strftime and made
- the strings i18n:able
-
-1999-03-23 Tomas Ogren <stric@ing.umu.se>
-
- * gncal/calobj.c: Added 2 paranthesis..
- "foobar = d / 60*60" is _NOT_ the same as "foobar = d / (60*60)"
- which caused heavy alarm-corruption with alarms between 2 hrs and
- 2 days.
-
-1999-03-23 Nat Friedman <nat@nat.org>
-
- * eventedit.c (ee_store_recur_rule_to_ical): Set the
- recur->interval to the value of the recur_rr_month_period spin
- button if the event is being set "by day." This closes bug #675
- as reported by bagfors@hpc2n.umu.se. Thanks for the report!
-
-1999-03-10 Clifford R. Conover <rconover@montana.edu>
-
- * gncal-todo.c (simple_todo_editor): Add support for Due Date when
- adding a TODO item here.
- (column_resized): New function
- (init_column_sorting): New function.
- (todo_click_column): New function.
- (convert_time_t_to_char, make_overdue_todo_style): New functions.
-
- * gnome-cal.c (gnome_calendar_todo_properties_changed): New
- function used to update the TODO when the properties have been
- chagned for it.
-
- * prop.c (prop_apply_todo): Apply TODO properties.
-
- * gncal-day-panel.c (todo_list_properties_changed): Update the
- TODO display here.
-
- * eventedit.c (date_edit_new): Made public
-
-1999-03-10 Craig A Soules (soules+@andrew.cmu.edu)
-
- * timeutil.c, calendar.c, calobj.c, gncal-day-panel.c: Add support
- for daylight time savings.
-
-1999-02-28 Martin Baulig <martin@home-of-linux.org>
-
- * gncal-full-day.c (recompute_motion): For DRAG_MOVE, DRAG_SIZE_TOP
- and DRAG_SIZE_BOTTOM: call child_focus_out () if the child currently
- has the focus.
-
-1999-02-27 Changwoo Ryu <cwryu@adam.kaist.ac.kr>
-
- * quick-view.c (QUICK_VIEW_FONTSET): Added Korean font to the
- fontset string.
- * mark.h (*_FONTSET): Likewise.
-
-1999-02-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c (ical_object_to_vobject): Save the owner/organizer of
- the event.
- (ical_object_create_from_vobject): Load the owner/organizer of the event.
-
- * gncal-full-day.c (delete_occurance): Assign child to data (fixes
- crash on "delete this occurrance").
-
-1999-02-22 Timur Bakeyev <mc@bat.ru>
-
- * calendar.c: According to configured values, use either tm.tm_zone
- or tzname. In last case, also declare it extern.
-
- * prop.c: langinfo.h not available everywhere. Wrapped. BTW, works
- fine without it.
-
-1999-02-20 Tomas Ogren <stric@ing.umu.se>
-
- * main.c (init_username): Made use of g_get_{user,real}_name() instead
- of our own home-brew...
-
-1999-02-17 Sergey Panov <sipan@mit.edu>
-
- * gnome-month-item.c,gnome-month-item.h,goto.c,mark.h,
- month-view.c,prop.c,quick-view.c,year-view.c: will define
- fonts via fontset. Friendlier to locales that use iso8859-[^1]
- and koi8-r encodings. Does not solve problem for Asian languiges
- --- better solution is needed (e.g. standart GNOME fontstyles
- defined in gtkrc).
-
-1999-02-16 Sergey Panov <sipan@mit.edu>
-
- * main.c: Use N_() macro for color settings labels in
- color_props structure.
-
-1999-02-15 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * goto.c (goto_dialog): Indentation fixes.
-
-1999-02-15 Tomas Ogren <stric@ing.umu.se>
-
- * goto.c: Made a private copy of what localtime() returns, to be able
- to keep the data after more calls to localtime().
-
-1999-02-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * main.c (save_default_calendar): New function. Saves the
- calendar if it is the user's default calendar
-
- * gncal-full-day.c (unrecur_appointment):
- * gncal-day-panel.c (day_view_range_activated):
- * eventedit.c (ee_ok):
- * gncal-todo.c (ok_button): Added autosave for the default
- calendar.
-
-1999-02-09 Tomas Ogren <stric@ing.umu.se>
-
- * main.c: Removed the gtk_widget_realize call.
-
-1999-02-06 Changwoo Ryu <cwryu@adam.kaist.ac.kr>
-
- * gncal.desktop: Added Korean translations.
-
-1999-02-04 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c (date_edit_new): New convenience function to create
- a properly-configured date editor widget.
-
-1999-02-03 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-week-view.c (gncal_week_view_new): Make the calendar start
- weeks on Monday if appropriate.
- (gncal_week_view_time_format_changed): New function to notify the
- week view that the time format has changed.
-
- * gncal-day-panel.c (gncal_day_panel_new): Make the calendar start
- weeks on Monday if appropriate.
- (gncal_day_panel_time_format_changed): New function to notify the
- day panel that the time format has changed.
-
- * gnome-cal.c (gnome_calendar_time_format_changed): Tell the day
- and week views that the time format has changed.
-
-1999-02-01 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c (event_editor_init): Set the title of the event
- editor window.
-
-1999-01-31 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-day-view.c (gncal_day_view_expose): Do not remove the
- clipping rectangle here.
-
- * view-utils.c (view_utils_draw_events): Remove the clipping
- rectangle here, since the user of this function should not know
- about it.
-
-1999-01-30 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * view-utils.c (view_utils_draw_events): Improve this draw
- routine. Now it can split the text in lines and fit as many
- events as possible.
- (nicetime): Return strings without spaces at the beginning.
-
- * gncal-day-view.c (gncal_day_view_expose): Move clip-clear
- operation here.
-
-1999-01-29 Jason Tackaberry <tack@dok.org>
-
- * gncal-full-day.c (child_popup_menu): if the user clicks on an
- event that is an occurance, the menu will allow the user to delete
- all occurances of this event, or just the selected occurance.
- (delete_occurance): added.
-
- * eventedit.c (append_exception): force the clist to select the
- new exception. (fixes segfault)
- (delete_exception): if the last exception in the clist is deleted,
- move the selection index up. (fixes segfault)
-
-1999-01-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * main.c (parse_an_arg): Add --hidden key to hide the calendar at
- startup. Only works with GNOME window managers though :-(
-
- * calendar.c (calendar_day_change): Reschedule alarms for the new day.
-
- (calendar_init_alarms): Schedule an alarm for midnight to change
- the calendar_day_begin/calendar_day_end.
-
- * alarm.c (alarm_ready): If we reschedule, there is no need to
- activate any pending alarms.
-
-1999-01-28 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (child_new): Insert the summary text here.
- (child_focus_in): No need to raise the window, since we have
- Spiffo(tm) layout code. Boy, this is old code.
- (gncal_full_day_focus_child): Now that GtkText works better, we
- can avoid synthesizing a click which was causing grief, anyway.
- (child_button_press): Grab the focus before popping up the menu.
-
- * layout.c (find_index): Added a sanity check.
-
- * gncal-full-day.c (child_destroy): Unmap and unrealize the child
- before unparenting/destroying it.
- (child_unrealize): Unrealize the widget. What was I thinking?
- (child_new): Save the focus_out_event signal connection id in
- Child structure (in a new field).
- (child_destroy): Disconnect from the focus_out_event signal, since
- we don't want to get such an event when the widget is destroyed.
- (gncal_full_day_destroy): Destroy the children properly; it was
- leaking memory.
-
-1999-01-27 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * main.c (save_calendar_cmd): Warn if the calendar file has
- changed.
-
- * calendar.c (calendar_load, calendar_save): Keep track of the
- modification time for the calendar file.
-
-1999-01-20 Nat Friedman <nat@nat.org>
-
- * gncal-full-day.c (gncal_full_day_key_press): Only trap printable
- characters such that hotkeys work.
- (UNSELECT_TIMEOUT): Changed to 0. Much saner behavior.
-
- * prop.c (properties): Connect gnome_help_pbox_display to the
- GnomePropertyBox help button.
-
-1999-01-19 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * quick-view.c (quick_view_do_popup): Do not grab the mouse here
- (it was being grabbed incorrectly, anyways).
- (quick_view_map_event): Grab the mouse when the window is mapped.
- This avoids the ugly "while (xGrabPointer () != Success)" hack.
- (quick_view_button_release): Handle button releases here.
-
-1999-01-19 Tomas Ogren <stric@ing.umu.se>
-
- * main.c: do gtk_widget_realize on the toplevel window..
-
-1999-01-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-day-panel.c (gncal_day_panel_new): Make the little
- calendar start up with the correct date.
-
- * gncal-week-view.c (gncal_week_view_set): Add the month to the
- date range display label.
-
-1999-01-08 Nat Friedman <nat@nat.org>
-
- * main.c: Converted some more stuff to use the standards.
-
-1999-01-08 Nat Friedman <nat@nat.org>
-
- * main.c (setup_appbar): New function to create the status bar.
- (setup_menu): Install menu hints.
-
- Menu items updated to match the standards. New Settings menu
- created.
-
-1998-12-30 Jeff Garzik <jgarzik@pobox.com>
-
- * gncal/calendar.c, gncal/gnome-cal.c, gncal/main.c,
- gncal/quick-view.c:
- s/g_copy_strings/g_strconcat/
-
-1998-12-16 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- Rewrote the old and broken alarm system. It never actually
- worked properly. Now it works properly, and I figured a nice way
- to get the Audio alarm do something nicer (it is now like an alarm
- clock :-).
-
- * gnome-cal.c (calendar_notify): Now we take a CalendarAlarm to
- actually distinguish which alarm was triggered.
-
- * alarm.c (alarm_ready): The code was only activating the first
- alarm. Reschedule the timer upon delivery of an alarm.
-
-1998-12-14 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * year-view.c (idle_handler): Use the allocation size instead of
- the old fields in the canvas structure.
-
- * goto.c (create_days): Use gtk_widget_set_usize() instead of
- gnome_canvas_set_size().
- * quick-view.c (setup_event_list): Likewise.
-
-1998-12-09 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-todo.c (simple_todo_editor): Use gnome_dialog_set_parent.
- * goto.c (goto_dialog): ditto
- * prop.c (properties): ditto.
-
-1998-11-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * eventedit.c (ee_rp_init_exceptions): Update GtkClist usage.
-
-1998-11-23 Andrew T. Veliath <andrewtv@usa.net>
-
- * gncal-day-panel.c (gncal_day_panel_new): Use
- gtk_scrolled_window_add_with_viewport instead of
- gtk_container_add (gtk changes).
-
-1998-11-23 Herbert V. Riedel <hvr@hvrlab.ml.org>
-
- * eventedit.c: use GPOINTER_TO_INT
-
- * gncal-todo.c: same.
-
-1998-11-22 Matthew Wilson <msw@redhat.com>
-
- * main.c: Fixed the popt event parsing callback to have the
- correct number of arguments. This stops it from segfaulting.
-
-1998-11-16 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c (ee_classification_widgets): Doh. Fixed stupid bug
- where the classification buttons were not being set correctly.
- (ee_store_general_values_to_ical): Take into account the fact that
- radio group lists are stored in reverse order of insertion.
-
- * gncal-todo.c (gncal_todo_init): Use a scrolled window to put the
- clist into.
-
-1998-11-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calendar.c (calendar_save): Backup the old file before saving
- the caledar.
-
-1998-11-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c: Add ctype.h
-
-1998-10-31 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gnome-cal.c (gnome_calendar_direction): Add the offset from the
- beginning of the current time unit (day/month/etc), otherwise it
- does not work right, for example, you are on the 31st day of a
- month and the next month is a 30-day one and you jump to the next
- month.
-
-1998-10-16 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * month-view.c: Changed a lot of stuff not to use the layout code
- -- the month view's days are too small to display layout
- usefully. Now they display a little list of the events in each
- day. We also have a popup menu for the days in the month view.
-
- * calendar.c (calendar_get_objects_in_range): Reverse the list so
- that it is returned in increasing order.
-
- * eventedit.c (event_editor_new_whole_day): New public function to
- create an event for the complete span of day_begin to day_end.
-
- * year-view.c (new_appointment): Use event_editor_new_whole_day().
-
- * year-view.c (yv_popup_menu): Mark strings for i18n.
-
-1998-10-12 Ji Lee <g@ucsd.edu>
-
- * eventedit.c (ee_store_recur_rule_to_ical): The interval was
- never being loaded from the spin button.
-
-1998-10-09 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * month-view.c (month_view_update): Create a list of children and
- lay them out nicely. Lots of functions added for this purpose.
- (adjust_segment): Main event segment adjustment routine.
- (adjust_children): Adjusts all the children in the month view.
- (child_create_segments): Creates the segments for a particular event.
- (layout_children): Uses the generic layout engine to organize the children.
-
-1998-10-08 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-todo.c (clist_row_selected): Set the sensitivity of the
- edit/delete buttons.
- (gncal_todo_update): Likewise. Thanks to Dirk Luetjens for the
- bug report.
-
- * layout.c: Do some cleanup; now we pass a struct with the layout
- algorithm's state instead of passing a trillion parameters around.
-
- * gncal-full-day.c (layout_children): Use the new generic layout
- engine.
- (child_compare): Sort keys are start time then end time, not just
- start time. This produces somewhat nicer results for the layout
- algorithm.
-
- The new layout code uses a partition of the time range occupied by
- the events, rather than using a fixed time granularity. This is
- better since the different parts of the program that use the
- layout module will have different semantics regarding snapping the
- event bounds to a fixed "time grid".
-
-1998-10-07 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * layout.[ch]: New files that abstract the event layout code from
- gncal-full-day.c into something useful for other parts of the
- program. Now all event layout is done here.
-
- * Makefile.am (gnomecal_SOURCES): Added layout.[ch] to the list of
- sources.
-
-1998-10-07 Carsten Schaar <nhadcasc@fs-maphy.uni-hannover.de>
-
- * main.c (main): Replaced the 'gnome_client_new_default' call with
- 'gnome_master_client'.
-
-1998-10-02 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * timeutil.c (time_day_begin): Changed name from
- time_start_of_day() to be consistent with the other begin/end functions.
- (time_day_end): Likewise.
-
- * calobj.c (ical_object_get_first_weekday): New public function to
- get the first toggled day in a weekday mask. Since we do not
- support multiple weekdays in a monthly-by-pos rule, we just fetch
- the first toggled one.
- (ical_object_generate_events): Added a missing break statement.
-
- * timeutil.c (time_month_end): Made it consistent with the rest of
- the time begin/end functions -- now it returns the first second of
- the *next* month.
- (time_week_end): Actually implemented this function. It will be
- used when the week view is rewritten.
-
- * calobj.c (time_in_range): Fix off-by-one in the comparison of
- the time against the end time.
-
- * gncal-full-day.c (expand_space): Fixed bug where the columns not
- were being expanded due to a missing "slot + j".
-
-1998-10-01 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * month-view.c (month_view_init): Use the font #defines.
- (month_view_new): Set the colors of the month view upon creation.
- (mark_current_day): New function to mark the current day in the
- month view.
- (month_view_set): Mark the current day.
- (month_view_colors_changed): Mark the current day and colorify the
- month item appropriately.
-
- * month-view.h: Added year and month fields to the MonthView
- structure.
-
- * main.c: Renamed the Appointments color property, since it will
- be used by the month view as well.
-
- * goto.c (update): Set the current day's font and color.
-
- * year-view.c (year_view_init): Set the fonts of the month items
- when creating them.
-
- * mark.h: Added new #defines for HEADING_FONT and TITLE_FONT.
-
- * year-view.c (year_view_init): Use the new font #defines.
-
- * prop.c (prop_apply_colors): Fixed to work with the
- I-am-paranoid-and-I-need-to-size-my-ints changes to
- GnomeColorPicker.
- (color_spec_from_picker): Likewise.
-
-1998-09-30 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * goto.c (create_days): Colorify the month item and prepare it for
- prelighting here.
-
- * main.c (color_props): Changed the default colors to something
- not dull.
-
- * year-view.c (compute_min_size): New function to compute the
- minimum size of the year view properly.
- (year_view_size_request): Added two new fields to the year view
- structure that contain the minimum size. Return this in the
- size_request method.
- (year_view_new): Call compute_min_size to save the minimum size
- for later use.
- (idle_handler): Make it resize the items correctly.
-
- * gnome-month-item.c (gnome_month_item_set_arg): Reshape when
- necessary. This is needed becaues we now actually calculate a
- minimum size for the month item based on the font sizes and paddings.
- (check_heading_sizes): New function to calculate a minimum size
- based on the headings' dimensions.
- (check_day_sizes): New function to calculate a minimum size based
- on the day number labels' dimensions.
- (check_sizes): New function that computes a minimum size for the
- month item.
- (reshape): Now calls check_sizes() to ensure a minimum size for
- the month item.
-
- * year-view.c (mark_current_day): New function to mark the current
- day in the year view.
-
- * mark.c: Removed mark_current_day from here.
-
-1998-09-29 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * prop.c (fetch_color_spec): Changed name from fetch_prelight_spec
- and made it conform to the new prelighting mechanism.
- (fake_mark_days): Set the proper day attributes.
- (reconfigure_month): Use colorify_month_item().
- (fake_mark_days): Use mark_month_item_index().
-
- * mark.c (colorify_month_item): New public function to reset the
- colors in a month item.
- (get_attributes): New internal function that creates an array of
- attributes for the days in a month item. This is the basis of all
- the new optimizations to month item marking.
- (unmark_month_item): Now it uses the attributes array to unmark
- only the days that need unmarking.
- (mark_event_in_month): Update the day attributes array.
- (month_item_prepare_prelight): Changed the definition of the
- prelight color query function. Use the new function.
- (day_event): Do color changes based on the day attributes array.
- (mark_month_item_index): New public function to mark a single day
- by index.
- (mark_event_in_month): Use mark_month_item_index().
-
- * gnome-month-item.c (gnome_month_item_num2child): Now takes an
- int, not a GnomeMonthItemChild.
- (gnome_month_item_child2num): Now returns an int, not a
- GnomeMonthItemChild.
- (gnome_month_item_num2day): Now takes an int, not a
- GnomeMonthItemChild.
-
- * goto.c (goto_dialog): Create the days before the year spin
- button, because the year_changed callback expects the month item
- to be created. The new semantics of the spin button cause it to
- emit a value_changed signal on the adjustment upon creation -- is
- this the behavior we want from it?
- (goto_dialog): Use gtk_window_set_modal() instead of the
- deprectaed gnome_dialog_set_modal().
-
- * quick-view.c (quick_view_new): Make it look not as crappy by
- putting the title inside the frame.
- (quick_view_do_popup): Fixed the pointer grab and added a cursor.
- (create_items_for_event): Query the text width/height from the
- text item using the new object arguments, so that the size of the
- popup window can be set properly.
-
- * year-view.c (do_quick_view_popup): Calculate a nice date string
- for the popup window.
-
-1998-09-28 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * quick-view.[ch]: New file that presents a quick view of the
- events in a particular day when the mouse is clicked on the year
- view. Work in progress.
-
- * year-view.c (do_quick_view_popup): New function that creates a
- quick view for the events in a day.
-
- * Makefile.am (gnomecal_SOURCES): Added quick-view.[ch] to the
- list of sources.
-
-1998-09-27 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * main.c: Hotkey for File/Exit should be C-q, not C-x.
-
-1998-09-24 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * year-view.c (do_popup_menu): New function to execute the popup
- menu in the year view.
- (day_event): Invoke the popup menu with the context set to days.
- (new_appointment): New function to create a new appointment from
- the year view.
- (do_jump): New function to do the appropriate view/date jumping
- from the popup menu.
-
- * main.c: Fixed two icons in the File menu.
-
-1998-09-21 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * main.c: Added underlined shortcuts and accelerators to the main menu.
-
-1998-09-16 Raja R Harinath <harinath@cs.umn.edu>
-
- * gncal-week-view.c (<gtk/gtklabel.h>): Include.
- * gncal-week-view.h (<gtk/gtkvbox.h>): Include.
-
-1998-09-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gnome-cal.c (mail_notify): Fixed the bug reported about the mail
- notification not beint sent until the program was terminated.
-
-1998-09-03 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (gncal_full_day_forall): Updated foreach ->
- forall from Gtk changes, bleah.
-
- * year-view.c (day_event): New function to handle events from
- days. Jumps to the day that is clicked.
-
- * main.c: Use a watch cursor while the previous/today/next
- functions are doing their job.
-
- * mark.c (month_item_prepare_prelight): New public utility
- function to prepare a month item for prelighting. It will store
- the proper prelight information and attach the appropriate signals.
- (mark_current_day): Make the current day bold as well (useful for
- color-blind people, I guess).
-
- * prop.c (set_current_day): Reset the date in the sample calendar
- and mark the current day.
- (fake_mark_days): Mark fake events in the sample calendar.
-
- * year-view.c (year_view_set): Use the general prelighting engine.
-
- * goto.c (day_event): Just process button presses, as prelighting
- is done behind the scenes now.
- (update): Use the general prelighting engine.
-
- * prop.c (create_colors_page): We can now configure the colors of
- the monthly calendars! Wheeeeee! There are still some nits to be
- fixed, which are listed in the TODO file.
- (build_color_spec): New function to build color specifications.
- (parse_color_spec): New function to parse color specifications.
-
- * mark.c: Modified all functions to use the configured colors.
- * goto.c: Likewise.
-
- * main.c (colors_changed): New function that notifies all
- calendars that colors have changed.
-
- * gnome-cal.c (gnome_calendar_colors_changed): New function that
- notifies all the views that the colors have changed.
-
- * month-view.c (month_view_colors_changed): New function that
- notifies the month view that colors have changed.
-
- * year-view.c (year_view_colors_changed): New function that
- notifies the year view that colors have changed.
-
- * gnome-month-item.h (struct _GnomeMonthItem): Added fields for
- outline and day box colors.
-
- * gnome-month-item.c (gnome_month_item_set_arg): Added
- outline_color, outline_color_gdk, day_box_color, and
- day_box_color_gdk arguments to month items. These are convenient
- to quickly set the colors of the month item.
- (gnome_month_item_get_arg): Likewise.
-
- * main.[ch]: Added a global array of structures for color preferences.
-
-1998-08-31 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * goto.c: Small code cleanup.
- (day_event): Upon receiving a LeaveNotify event, Reset the day's
- background to the correct color.
-
-1998-08-29 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * mark.[ch]: New files with utility functions to mark calendars
- with their events.
-
- * mark.c (mark_month_item): New public function to mark a month
- item with events.
- (unmark_month_item): New public function to unmark all the days in
- a month item to their default appearance.
-
- * year-view.c (year_view_set): Use the new unmark_month_item() and
- mark_month_item() to mark the months with events.
-
- * goto.c (update): New function that updates the calendar in the
- Go-to dialog by marking the days.
-
- * timeutil.c (time_year_begin): Modified to take a time_t value.
- (time_year_end): Likewise.
- (time_month_begin): Actually implemented this function, which was
- in the header file but not here.
- (time_days_in_month): New public function that returns the number
- of days in a month.
-
- * Makefile.am (gnomecal_SOURCES): Added mark.[ch] to the sources.
-
- * year-view.c (unmark_days): Use unmark_month_item().
-
- * gncal-full-day.c (gncal_full_day_destroy): Fixed crash when
- destroying the full day view. The full day's destroy method is
- unusual in that it destroys the list of child widgets itself, as
- it does not have a remove method, so it needs to reset the list to
- NULL.
-
-1998-08-27 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gnome-month-item.c (build_month): Now does the correct thing
- when the user wants weeks to start on Monday. Now all the Monday
- special casing, as far as day numbering is concerned, is only in
- this function.
-
- * year-view.c (mark_days): This function marks the days that have
- events in them. It also fixes a memory leak in the old
- implementation (it was leaking the whole list).
- (unmark_days): New function used to unmark all the days in the
- year view.
- (mark_event): New function that marks all the days that are
- spanned by a time range. It also fixes the bug in the old
- implementation where it could possibly mark days past the ends of
- the year (if the event crosses year boundaries, for example).
-
- * timeutil.c (time_year_begin): Take the year parameter since year
- 1, not 1900.
- (time_year_end): Likewise.
-
- * year-view.c (year_view_size_allocate): Now changing the size of
- the calendars is done in the idle loop.
- (idle_handler): This function actually does the resizing of the items.
-
- * year-view.h (struct _YearView): Added idle_id and need_resize
- fields.
-
-1998-08-26 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * year-view.c: Beginning of the new year view. Sizing and event
- marking needs to be finished.
-
- * gnome-cal.c: Updated for year-view.
- (gnome_calendar_time_format_changed): Use year_view_time_format_changed().
-
- * year-view.[ch]: Renamed the gncal-year-view.[ch] files to
- year-view.[ch].
-
- * Makefile.am (gnomecal_SOURCES): Updated year-view.[ch] in the
- list of source files.
-
-1998-08-25 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * goto.c (create_days): Set the heading color of the month item.
-
- * main.c: Use GNOME_STOCK_PIXMAP_JUMP_TO, now that it exists,
- instead of goto.xpm. Also, removed goto.xpm from cvs.
-
- * gnome-month-item.h (struct _GnomeMonthItem): Added fields for
- the heading and day number fonts. Added fields for heading and
- day number label colors.
-
- * gnome-month-item.c (gnome_month_item_class_init): ARG_DAY_NAMES
- should be write-only. Also, added arguments for heading and day
- number fonts. Added arguments for heading and day number colors.
-
-1998-08-24 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * prop.c (build_two_radio_group): Doh. Set the state of the radio
- buttons properly.
-
- * month-view.c (month_view_time_format_changed): New public
- function that notifies the month view of a time format change.
-
- * gnome-cal.c (gnome_calendar_time_format_changed): New public
- function that notifies the calendar of a time format change.
-
- * main.c (time_format_changed): Use gnome_calendar_time_format_changed().
-
- * month-view.c (month_view_update): New public function to update
- the month view when an event changes. This is still unfinished.
- (month_view_set): New public function to set the month in the
- month view.
-
- * gnome-cal.c (gnome_calendar_direction): Add case for month view.
- (gnome_calendar_set_view): Likewise.
- (gnome_calendar_update_all): Likewise.
-
- * timeutil.c (time_add_week): Implemented the time_add_week()
- function, which was on the header file.
- (time_add_month): Added public month-adding routine.
-
- * gnome-cal.c (gnome_calendar_get_current_view_name): Add case for
- month view.
- (gnome_calendar_goto): Likewise, and set the time on the month view.
-
- * month-view.c (month_view_new): Now it takes the calendar plus
- the time_t representing the month.
-
- * gnome-month-item.h: Added documentation on the object arguments
- for the month item.
-
- * month-view.c (month_view_init): Added a month/year heading to
- the month view.
-
- * TODO: Updated the TODO list a bit.
-
- * main.c (gnome_cal_file_menu): The preferences menu option should
- go in the File menu.
- (gnome_cal_edit_menu): Added stock pixmaps to the menu items.
- (gnome_cal_menu): Renamed the Calendar menu to Edit.
- (gnome_cal_help_menu): Use "About Gnomecal", not just "About".
-
- * prop.c (hour_activated): Notify the property box that it has changed.
-
- * main.c: Changed the Properties menu item to Preferences. These
- are global application preferences, not a single calendar's
- properties.
-
- * prop.c (prop_apply): Save the week_starts_on_monday flag to the
- configuration file.
- (properties): Added a check button for weeks starting on Monday.
- (properties): Beautified the Preferences dialog.
-
- * month-view.c (month_view_init):
- * goto.c (create_days): Set the month item to start weeks on
- Monday if appropriate.
-
- * main.c (init_calendar): A boolean is not an hour, so don't
- range_check_hour() on it.
- (init_calendar): Added a global week_starts_on_monday flag.
-
- * main.h: Added global week_starts_on_monday flag.
-
-1998-08-21 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c (ical_object_create_from_vobject): If mail alarm or
- program alarm are missing the action, then set an empty default.
-
-1998-08-18 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gnome-month-item.c (gnome_month_item_day2index): New public
- function to get the displayed day index of the specified date.
-
- * gnome-cal.c (gnome_calendar_goto_today): New public function to
- jump to the current day.
-
- * goto.c (day_event): Jump to the selected day when the user
- clicks the mouse, and prelight days as appropriate.
-
- * timeutil.c (time_from_day): New public function to build a
- time_t from a year/month/day triplet.
-
- * gnome-month-item.c (gnome_month_item_num2child):
- (gnome_month_item_child2num): New public functions to convert an
- index into a child and vice-versa, respectively.
- (gnome_month_item_num2day): New public function to convert a child
- number into a displayed day number.
-
- * goto.c (goto_dialog): Doh, use gnome-dialog properly :-)
-
- * gnome-month-item.c (create_items): Use g_strdup()ed day names
- from the start.
-
-1998-08-17 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * main.c (gnome_toolbar): Made it use goto.xpm.
-
- * Makefile.am (EXTRA_DIST): Added goto.xpm to the list of files.
-
-1998-08-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gnome-month-item.c (gnome_month_item_set_arg): Doh. Actually
- recalculate the days using the month and year.
-
- * main.c: Added "Go to" button to quickly jump to a specific date.
-
- * goto.c: New file that defines the quick go-to date dialog.
-
- * Makefile.am (gnomecal_SOURCES): Added goto.c to the sources.
-
-1998-08-11 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
-
- * main.c (new_calendar): Made title i18n friendly. This was bug
- #215.
-
- * eventedit.c (ee_store_recur_end_to_ical): Set recur->enddate to
- recur->_enddate, not to itself, when adding recurring event and
- supplying an end date. This fixes (at least part of) bug #99.
-
-1998-08-10 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * month-view.[ch]: Start of the month view widget. This will use
- the generic month item and extend it to have the semantics desired
- for the gnomecal month view.
-
- * gnome-month-item.[ch]: New generic canvas item for the month
- view and the "small calendars". This is intended to be a
- high-level display engine for monthly calendars. This is a work
- in progress.
-
- * gnome-cal.h (GnomeCalendar): Added a month_view field.
-
- * gnome-cal.c (setup_widgets): Create the month view and insert it
- into the notebook.
-
- * Makefile.am: Added month-view.[ch] and gnome-month-item.[ch] to
- the sources.
-
-1998-08-03 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * main.c (about_calendar_cmd): Use an array of const strings to
- keep gcc happy.
-
- * alarm.c (alarm_compare_by_time): Use gconstpointer to keep gcc happy.
- * calendar.c (calendar_object_compare_by_start): Likewise.
- * gncal-full-day.c (child_compare_by_start): Likewise.
-
-1998-07-07 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * main.c: Add support for --view flag.
- (session_save_state): Save the view mode;
- (new_calendar): Now takes a view mode flag.
-
- * gnome-cal.c (gnome_calendar_get_current_view_name): New
- function for enhancing the session management support for
- gnomecal.
- (gnome_calendar_set_view): New function that makes a given page
- active.
-
-1998-07-01 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
-
- * gncal.desktop: Added Portuguese translation.
-
-Mon Jun 22 13:01:16 1998 Havoc Pennington <hp@pobox.com>
-
- * main.c (session_save_state): Use gnome_geometry_string to get
- the geometry string.
-
-1998-06-04 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c (ee_rp_init_rule): Do not subtract 1 from
- tm->tm_mday for the default_day.
-
- * gnome-cal.c (gnome_calendar_new):
- (gnome_calendar_goto): Use the start of the day -- things expect
- it to be that way.
-
-1998-05-27 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
-
- * eventedit.c (ee_store_recur_rule_to_ical): Fill in
- ical->recur->interval from value in spin_button. This ixed an
- infinnite loop.
-
-1998-05-30 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (child_draw): Paint the decorations correctly.
- (child_draw_decor): Paint the recurrence/bell icons correctly.
-
-1998-05-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * eventedit.c (ee_rp_init_rule): Use the contents of
- ee->ical->dtstart for computing the predefined values of the recurrence.
-
- * gncal-full-day.c (gncal_full_day_unrealize): Fix the gc
- destruction in the unrealization code and fix the pixmap unrefing.
-
- * main.c (close_cmd): Remove a bad hack that disabled calendar
- widget destruction.
-
- * calobj.c (ical_object_generate_events): Fix for the weekly event
- generation. Was reported on the bug tracking system.
-
-1998-05-18 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-full-day.c (layout_children): Implemented ultra-cool
- layout for the events that share the same time range. Gals and
- guys you can now drop Outlook on the recycle bin.
-
- Which reminds me. We do not have a recycle bin. How could that
- happen in a project as cool as this one? Someone explain this to
- me.
-
-1998-05-18 Federico Mena <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (paint_back): Eliminated unnecessary border repainting.
-
-Sun May 17 17:55:03 1998 Havoc Pennington <hp@pobox.com>
-
- * gncal-todo.c (simple_todo_editor): Close dialog when return is pressed.
-
-1998-05-15 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gnome-cal.c (mark_gtk_calendar_day): Bug free version of the
- range computation in place.
-
- * gncal-year-view.c (year_view_mark_day): Use the same new version
- of the range computation here.
-
- * calobj.c (ical_object_generate_events): Fix the begin/end
- condition.
-
-1998-05-14 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * timeutil.c (isodate_from_time_t): Do not add the spurious
- padding.
-
- * calobj.c (store_date_list): Bug fix: I was using the wrong
- pointer when saving the exception date list.
- (set_date_list): Bug fix: load correctly the complete exception
- date list.
- (set_date_list): Use ',' for the exception date separator as the
- versit people can not get their standard right.
-
- * gncal-full-day.c (unrecur_appointment): Support for making an
- existing recurrent event `movable' for a day.
-
- * calobj.c (ical_object_add_exdate): New routine, used to add
- exception dates.
- (ical_object_duplicate): New routine: used to do the magic
- recur->no-recur event.
-
-1998-05-08 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-full-day.c (new_appointment): Use gtk_calendar freeze/thaw
-
- * gncal-year-view.c (gncal_year_view_set_year): Use gtkcalendar freeze/thaw.
-
- * eventedit.c (event_editor_init): Use gnome_dialog_set_close to
- avoid the ugly warning.
-
- * main.c (display_objedit): Default to the day the user is looking
- at.
-
-1998-05-05 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-day-panel.c (full_day_size_allocated): Do not emit a value
- changed signal if the value is the same.
-
-1998-05-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * prop.c (prop_apply): Only run the apply code once.
-
-1998-05-03 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-day-panel.c (update): Draw the day at startup.
- (gncal_day_panel_set): Fix selected-day display.
- (gncal_day_panel_new): Switch day on double clicks, not on single
- clicks.
-
- * calobj.c (ical_object_compute_end): Removed debug messages.
-
-1998-04-30 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * prop.c (prop_apply): Do not call prop_cancel, ths is now using
- GnomePropertyDialog.
-
-1998-04-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-week-view.c (sync_week): Use gnome_calendar_tag_calendar.
-
- * gnome-cal.c (gnome_calendar_tag_calendar): New routine used to
- fill a gtk_calendar with the events on a GnomeCalendar object.
-
- * gncal-week-view.c (gncal_week_view_new): Set the week to the day
- we double clicked.
-
-1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gnome-cal.c (calendar_notify): Apply black magic to get mail
- notifications to work.
-
- * gncal-full-day.c (child_focus_out): Temporary optimization, the
- child_focus_out is constantly calling the
- gnome_calendar_object_changed when the property editor has been
- invoked. This happens every time the mouse moves crosses the main
- window.
-
- * calendar.c (calendar_object_changed): Reschedule alarms when a
- calendar object has changed its times.
-
-Sat Apr 25 22:20:45 1998 Havoc Pennington <hp@pobox.com>
-
- * eventedit.c, eventedit.h: Descend from GnomeDialog. Took vbox
- out of class structure; use GnomeDialog vbox
- instead. gnome_dialog_set_destroy instead of destroying in button
- callbacks. Don't create buttons, separator, or vbox manually.
- #include <libgnomeui/gnome-dialog.h>.
-
-1998-04-24 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c (ical_object_create_from_vobject): Fixed alarm loading;
- Load snooze time and snooze count
-
-1998-04-23 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * calendar.c (calendar_save): Actually save the to-do entries.
-
- * gncal-todo.c (simple_todo_editor): Now you can add and edit
- to-do entries.
-
-1998-04-22 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c: Made it use popup_menu().
-
- * popup-menu.c: New file with utility functions for creating popup
- menus. Maybe such a thing would be useful in libgnomeui, a la
- gnome-app-helper?
-
- * Makefile.am (gnomecal_SOURCES): Added popup-menu.[ch] to the sources.
-
-1998-04-22 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * prop.c (properties): Added Calendar properties editor.
- (properties): Make the code use a propery box.
-
- * main.c: Save/load properties (fix to old commit).
-
-1998-04-21 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-todo.c: New widget for editing TODO lists. This will be
- worked on a lot.
-
- * Makefile.am (gnomecal_SOURCES): Added gncal-todo.[ch] to the sources.
-
- * gncal-day-panel.c: Make it use the new TODO widget.
-
-1998-04-21 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * timeutil.c (isodate_from_time_t): Do not save with the global
- time flag (Z at the end of the isodate). When we figure out a way
- to load times in GMT time, we will add this back
-
- * view-utils.c (popup_menu): Moved this routine here as there are
- more users of this code.
-
- * gncal-day-view.c (gncal_day_view_class_init): Add button press
- handler.
- (new_appointment): New routine for creating appointments on a day.
-
-
-
- * main.c (save_ok): Added call to gtk_window_set_wmclass.
-
- * gncal-day-panel.c (calendar_day_selected): Fix, years for mktime
- should substract 1900 and gtk_calendar stores years relative to
- year 0.
-
- * gncal-week-view.c (gncal_week_view_new): Make the week view
- descend from VBox so that we can add a label to it.
- (gncal_week_view_set): Display the ending day of the week
- correctly.
-
- Added a label that displays the week range.
-
-1998-04-21 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gnome-cal.c: Made it use GncalDayPanel.
-
- * gncal-day-panel.c: New widget for the day view in the main
- calendar toplevel. It basically takes care of everything
- gnome-cal did by hand with respect to the day view.
-
- * Makefile.am (gnomecal_SOURCES): Added gncal-day-panel.[ch] to
- the rules.
-
- * main.c: Added a separator between the About menu item and the
- help topics.
-
-1998-04-20 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * eventedit.c (ee_ok): Mark the event as non-new after accepting changes.
-
-1998-04-20 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (gncal_full_day_get_day_start_yoffset): New
- public function that returns the y offset for the row
- corresponding to the "day begin" time.
-
- * gncal-full-day.c (gncal_full_day_key_press): Now any printable
- keystroke (not just Return) will activate the selected range.
-
- * gncal-full-day.c (paint_back): Made it use the new paint_row
- function instead of painting everything directly. We calculate
- areas in a smarter way so there is even less flicker than before,
- especially when selecting regions.
-
- * eventedit.c: Sensitize recurrence widgets properly.
-
- * calobj.c (duration_callback): Pass the correct pointer type to
- is_date_in_list().
-
-1998-04-20 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c (duration_callback): Take exception dates into
- account.
-
- * gncal-full-day.c (new_appointment): Setup the event editor dates
- to those of the currently displayed day.
- (gncal_full_day_selection_range): Use sensible values in the case
- no range is selected.
- (new_appointment): Events now use the current day for event creation.
-
- * view-utils.c: Pretty up the time display.
-
- * calobj.c (ical_object_compute_end): Initialize
- ico->recur->enddate, otherwise we loop forever during final date computation.
-
- * eventedit.c: Now recurrence is toggled by a radio button in the
- recurrence page, as the checkbox is confusing.
-
- * calobj.c (is_date_in_list): Add support for the exclussion
- dates.
-
-1998-04-18 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-year-view.c (double_click): Fix this routine as well.
-
- * gncal-week-view.c (jump_to_day): Bind the gtkcalendar signals to
- the week.
-
- * gncal-year-view.c (gncal_year_view_set_year): Put things in the
- proper range. Now the year view actually matches this year.
-
- * gnome-cal.html: Added small documentation.
-
- * main.c: Add more icons to the menus; Rename some menubar
- entries; Add `new' icon to the toolbar.
- (dump_events): Added argument handling and dumping of events from
- the command line. Extremely cool.
-
- * getdate.y: Taken from the CVS source code. Used for date
- parsing in the command line.
-
- Internationalized getdate.y. Wee! It even works with spanish.
-
- * calobj.c (ical_object_to_vobject): Add Quoted printable property
- to items containing new lines.
- (duration): Use unsigned integers, to work around buggy calendar
- files generated by korganizer.
-
- * main.c (save_calendar_cmd): Do not ask for file name if we are
- saving.
- (save_as_calendar_cmd): New command.
-
-
-1998-04-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * alarm.c (alarm_kill, alarm_init, alarm_add): Implement the alarm
- management framework.
-
-1998-04-17 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * calobj.c (ical_new): Added mandatory status property.
- (ical_object_to_vobject): Only store "related" list if it exists.
- (store_list): Add terminating null char and free the correct data.
-
- * main.c (save_calendar_cmd): Implemented calendar saving.
- (open_calendar_cmd): Implemented calendar loading.
- (new_calendar_cmd): Implemented calendar creation.
- (new_calendar): Don't load our test calendar by default.
-
- * gncal-full-day.c (delete_appointment): Delete appointment implemented.
-
- * eventedit.c (ee_store_recur_values_to_ical): Free/create
- ical's recurrence appropriately.
- (ee_rp_init_rule): Initialize all missing parameters from ical.
- (ee_rp_init_ending_date): Initialize missing fields from ical.
-
-1998-04-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gnome-cal.c (gnome_calendar_remove_object): Add support for
- removing objects.
-
-1998-04-17 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c (ee_init_recurrence_page): New function that creates
- the recurrence page in the toplevel notebook.
- (ee_store_recur_values_to_ical): Now we can also store the recurrences.
-
-1998-04-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c (ical_object_generate_events): Implement
- RECUR_MONTHLY_BY_POS implemented.
- (ical_object_create_from_vobject): Fix the alarm
- initialization code.
- (save_alarm): Save alarms.
- (ical_object_generate_events): Fixed the recurrent code to take
- into account the recur->endate field (if at all specified).
-
- (ical_object_to_vobject): Implement recurrence rule saving.
-
-1998-04-16 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c (ee_store_alarm): Use menu_shell->children, not
- menu->children. Why does GtkMenu have a children field in the
- object structure?
- (check_dates): New function that insures that start_date < end_date.
- (check_times): In addition to checking whether the event spans the
- whole day, now it insures that start_time < end_time.
-
- * gncal-full-day.c (child_set_size): Now children get bigger
- temporarily while they are focused. This allows the handles not
- to "overlap" the rows used by the child and thus allow editing of
- very thin events.
- (recompute_motion): Fix for new child coordinates.
- (gncal_full_day_expose): Make it use find_child_by_window()
- instead of looking for it by hand.
-
- * bell.xpm recur.xpm: XPM files for events with alarm and
- recurrence, respectively.
-
-1998-04-15 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (button_1): Preserve the up/down cursor while dragging.
-
- * gncal-full-day.c (child_draw): Now children have a vertical
- handle as well. This can be used to move the child anytime, not
- only when it is focused.
- (recompute_motion): Modified for new drag behavior.
-
- * eventedit.c (ee_init_general_page): The general_owner may be
- null. Do the proper thing when creating the label.
- (ee_ok): Update the gnome calendar appropriately.
-
- * timeutil.h:
- * gncal-year-view.h: Add some missing prototypes.
-
- * gncal-full-day.c (child_popup_menu): Set the sensitivity of menu
- items according to whether the ical object is being edited or not.
-
- * eventedit.c (event_editor_new): Set the "being edited" flag on
- the ical object (stored as the ical object's user data).
- (event_editor_destroy): Release the flag.
-
- * calobj.h: The iCalObject structure now has a generic user_data pointer.
- * calobj.c (ical_object_set_user_data ical_object_get_user_data):
- Functions to set this data.
-
- * gncal-full-day.c (child_button_press): Do child popup menu correctly.
-
- * main.c (about_calendar_cmd): Fixed my address and added Arturo
- to the authors in the about box.
-
- * gncal-full-day.c (find_child_by_window): Compare child's widget
- windows by user_data (which will be the parent widget, that is,
- the text widget). We cannot assume that child->widget->window
- will be *the* window we are interested on because there may be
- child widgets with multiple windows.
-
-1998-04-15 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * calobj.c (ical_foreach): Define iterator routine.
-
-1998-04-15 Arturo Espinosa Aldama <arturo@nuclecu.unam.mx>
-
- * gncal-year-view.[hc]: Now using time_t for new and set.
- Random fixes, as well.
-
-1998-04-15 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (button_3): New popup menus activated with
- mouse button 3.
- (create_appointment): Create a new appointment from the popup
- menus. See the FIXME.
-
-1998-04-15 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-full-day.c (layout_kill_rows): Routine to destory rows
- array properly.
-
- * gncal-year-view.c (gncal_year_view_new): Add missing year in
- call to strftime.
-
- * calobj.c (ical_object_create_from_vobject): Fixed memory leaks
- from the return values of versit's fakeCString.
-
-1998-04-14 Arturo Espinosa Aldama <arturo@nuclecu.unam.mx>
-
- * gncal-year-view.[hc]: New widget for the year view.
- * Makefile.am: added required compilation of the new files.
-
-1998-04-14 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c (event_editor_setup_time_frame): Fixed some table
- expansions to make the dialog look nicer when resized.
-
- * calobj.c (ignore_space): Fixed compiler warning about unused
- computed value.
- (ocurrencelist): Replace str by p confusion. Removed unused
- variables value and q.
- (daynumber): Fixed a couple of warnings about unused values.
- (load_recurrence): Removed unused variable c. Added a default
- clause to the switch(type).
-
- * eventedit.c (ee_rp_init_frequency): Removed unused variable content.
- Fixed a compiler warning by adding a missing cast.
-
- * calobj.c (ical_object_create_from_vobject): Make the
- load_recurrence() part work correctly. Eliminated use of
- syntax_error variable.
-
-1998-04-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (child_key_press): Unfocus the child and focus
- the parent fullday widget when the user presses Esc.
-
- * gncal-week-view.c (gncal_week_view_update): Now takes object and
- flags parameters.
- * gncal-day-view.c (gncal_day_view_update): Likewise.
- * gncal-full-day.c (gncal_full_day_update): Likewise.
- (child_focus_in): New function. In conjunction with
- child_focus_out(), these only display the handles in the child
- when it is focused. The result is that the user can see more of
- the child's text when nothing is focused, and we can also display
- fatter and nicer drag handles.
-
- * gnome-cal.c (gnome_calendar_object_changed): Now takes an
- additional flags parameter
- (gnome_calendar_update_all): Made function static. Now takes
- changed object and flags parameters as well.
- (gnome_calendar_object_changed): Now takes additional flags
- parameter to indicate what changed in the specified object.
-
- * calobj.h (CalObjectChange): New enum with flags to describe what
- has been changed in an object.
-
- * gncal-full-day.h:
- * gncal-full-day.c (gncal_full_day_focus_child): New function to
- let the outside world decide which child to focus.
- (gncal_full_day_focus_child): Bleah. We have to synthesize a
- click because GtkText will not set the cursor when you focus it.
-
- * gnome-cal.c (day_view_range_activated): Focus the new child in
- the full day widget.
-
- * eventedit.c (event_editor_setup_time_frame): Re-aligned some
- widgets to make it look prettier.
- (ee_alarm_widgets): Likewise.
- (ee_init_general_page): Likewise.
- (ee_classification_widgets): Likewise.
- (event_editor_init_widgets): Likewise.
-
- * gnome-cal.c (day_view_range_activated): Create new object and
- add it to the calendar. You can now select a range in the
- full-day view, hit Return, and a new event will be added at the
- selected range. I still have to figure out how to focus this new child.
-
- * gncal-full-day.c (paint_back): Rewrote function to avoid
- painting an area more than once -- eliminate flicker.
- (paint_back_rows): New function that calls paint_back() only for
- the area of the specified rows.
- (gncal_full_day_button_press):
- (gncal_full_day_button_release):
- (gncal_full_day_motion): Made these functions use
- paint_back_rows() instead of paint_back(), to eliminate flicker. Wheee!
-
-1998-04-12 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gnome-cal.c (setup_day_view): We now connect to the
- range_activated signal of the fullday widget instead of catching
- key presses ourselves.
- (day_view_range_activated): New function that creates a new
- iCalObject and inserts it into the calendar, not finished yet.
-
-1998-04-11 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (get_time_from_rows): New function, calculates
- a pair of time_t values from the specified start and number of rows.
-
- * gncal-full-day.h (GncalFullDayClass): New signal
- "range_activated". It is emitted when a range is selected and the
- user hits Return.
- (gncal_full_day_selection_range): New function, returns the
- selected range.
-
- * gncal-full-day.c (struct drag_info): Moved selection information
- to their own fields instead of sharing the child's drag fields.
- This allows us to keep the selection when a child is moved.
- (recompute_motion): Made the case when (row < di->sel_click_row)
- work correctly.
-
-1998-04-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gnome-cal.c (gnome_calendar_goto): Add support for navigating
- on the day view.
-
- * timeutil.c (time_start_of_day, time_end_of_day, time_day_hour):
- New time manipulation functions.
-
- * eventedit.c (ee_rp_init_frequency): Add the different frequency
- editors to a notebook. Make the notebook startup on the entry
- selected recurrence type;
-
-1998-04-11 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c (recompute_motion): Now we support selecting a
- range in the main window (by clicking+dragging). It flickers
- horribly and is not perfect, but it is a start.
-
-1998-04-09 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c: #include <string.h>
-
- * gncal-full-day.c (child_map): Show instead of just map the child
- widget (otherwise the text widget gets confused and will not focus).
-
- * calobj.c (ical_object_to_vobject): Quote chars as 'x', not "x".
-
- * calobj.h: Added prototype for ical_object_to_vobject().
-
- * gnome-cal.c (gnome_calendar_object_changed): New function. This
- should be called when a calendar object is changed.
-
- * gncal-full-day.c (update_from_drag_info): Call
- gnome_calendar_object_changed() instead of updating manually.
-
- * calendar.c (calendar_add_object):
- (calendar_remove_object): Set the modified flag to true.
-
- * gncal-full-day.c (gncal_full_day_draw): Finished implementing
- this function.
-
-1998-04-08 Raja R Harinath <harinath@cs.umn.edu>
-
- * gncal.c (update_calendar): Say `#if 0', not `#ifdef 0'.
-
-1998-04-07 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c: Removed unused global variable parent_class.
-
- * eventedit.h: Renamed gtk_window field to window.
- Made the parent_class field in the EventEditorClass structure be a
- GtkWindowClass, not a gnome property box class.
- Added prototype for event_editor_get_type().
-
-1998-04-06 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-week-view.c (gncal_week_view_new): Use the new
- gtk_table_set_homogeneous() instead of setting the variable directly.
-
-1998-04-03 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * eventedit.c (ee_create_ae): Make it return void.
- (ee_alarm_widgets): Remove some unused variables.
- (ee_store_alarm): Make it return void.
- #include <string.h>
-
- * eventedit.h: #include "gnome-cal.h"
-
- * calobj.c (list_free): Don't use g_free in the g_list_foreach.
-
- * calendar.h: Add prototype for calendar_load().
-
- * timeutil.h: Add prototypes for time_add_*().
-
- * calendar.c:
- * calobj.c:
- * eventedit.c:
- * gnome-cal.c: #include "timeutil.h"
-
- * gncal-day-view.c (gncal_day_view_size_request): Make the minimum
- width equal or larger to the title width.
-
- * main.c: #include "eventedit.h"
- (main): Add a return statement.
- (new_calendar): Show stuff *after* the calendar has been loaded.
-
- * gnome-cal.c (gnome_calendar_load): Update the day view.
- (setup_widgets): Hackish setup of a day view widget - will fix later.
- (gnome_calendar_init): Initialize all fields.
-
- * gnome-cal.h: Added day_view field. Maybe this should be changed
- when the a complete day view panel is complete.
-
- * gncal-day-view.c (gncal_day_view_update): Draw after update, not
- before.
-
-1998-04-06 Carsten Schaar <nhadcasc@fs-maphy.uni-hannover.de>
-
- * versit/.cvsignore: New file.
-
-Fri Apr 3 22:31:54 1998 Tom Tromey <tromey@cygnus.com>
-
- * calendar.c: Include <config.h>.
-
-1998-04-03 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * timeutil.c (time_add_year, time_add_year, time_add_week):
- Routines for time manipulation.
-
- * calobj.c (ical_object_destroy): Full destruction of the object.
-
- * eventedit.c: Finished the main event editor form; It still
- lacks the details and the recurrence bits. It now adds events
- and cancels.
-
-1998-04-03 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * view-utils.c (view_utils_draw_events): The "better" format
- string for strftime() wasn't better, after all :-(
-
-1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-full-day.c: New full-day widget. It is still a work in
- progress. It will be similar to M$ Schedule's nifty full day view
- widget, but with Gtk's elegance :-)
-
- * Makefile.am (gnomecal_SOURCES): Added gncal-full-day.[ch] to the sources.
-
-1998-04-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * eventedit.c: Object editor widget. We dropped ObjEdit.
-
- * timeutil.c (time_from_isodate): Fix.
-
- * view-utils.c (view_utils_draw_events): Changed the display
- formats.
-
-1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * view-utils.c (view_utils_draw_events): Use better format
- specifier for strftime().
- (view_utils_draw_textured_frame): Ultra-nifty function to draw
- textured "metal" frames, like Netscape's handles.
-
-1998-04-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * gncal-day-view.c (gncal_day_view_update): Day events are now
- cached inside the widget. They get initialized at this time.
-
- * view-utils.c (view_utils_draw_events): Use the list of events.
-
-1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-day-view.c (gncal_day_view_set_shadow): New customization
- function. We can't decide on a stupid border type :-)
- (gncal_day_view_init): Made GTK_SHADOW_ETCHED_IN be the default
- shadow type. Looks good.
-
-1998-04-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * main.c: New main program that uses our new datatypes and
- objects.
-
- * calendar.c (calendar_load_from_vobject, calendar_load):
- Implement loading of vCalendar objects and vCalendar files.
-
- * calobj.c (ical_object_create_from_vobject): Implement loading of
- vCalendar event and todo objects.
-
- * timeutil.c (isodate_from_time_t): New function.
-
- * gnome-cal.c, gnome-cal.h: Implement a toplevel widget, derived
- from GnomeApp. It holds all of the day views and arbitrates the
- display.
-
-1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-week-view.[ch]: New week view composite widget. This
- provides a full week view (7 day views plus busy time display --
- the latter is currently unimplemented).
-
-1998-04-01 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal-day-view.c: New day view widget. It is intended to be a
- child widget of the week view composite widget.
-
- * calendar.c (calendar_get_objects_in_range):
- (calendar_get_events_in_range):
- (calendar_get_journal_in_range):
- (calendar_get_journal_in_range): These functions now take a
- sort_func parameter, which is of type GCompareFunc. If the
- specified value is non-NULL, it will return a sorted list.
- Otherwise, it will return an unordered list.
- (calendar_compare_by_dtstart): Provide a generic sorting routine
- for calendar objects.
-
-1998-04-01 Miguel de Icaza <miguel@kernel.org>
-
- * Start from scratch
-
-Tue Mar 31 23:46:50 1998 Tom Tromey <tromey@cygnus.com>
-
- * timeutil.c (format_simple_hour): `buf' now static.
-
-1998-03-31 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal.c: Removed #include "gtkcalendar.h", because it now comes
- from libgnomeui.
-
- * Makefile.am (gncal_SOURCES): Added new source files to the rules.
-
- * timeutil.c (format_simple_hour): New function, formats an
- hour/am_pm pair into a string of the form "3am", "12pm", "05h",
- "19h", etc. It is used by the day view widget for its labels.
-
-1998-03-31 Craig Small <csmall@small.dropbear.id.au>
-
- * Now has (non working) session maangement
- * Uses a clist for the dailylist like gtt
-
-Sat Mar 21 15:43:20 1998 Tom Tromey <tromey@cygnus.com>
-
- * gncal.c: Use gnome_message_box_*, not gnome_messagebox_*.
-
-1998-03-12 Craig Small <csmall@small.dropbear.id.au>
-
- * Now linked (in some horrible way) to the gtkcalendar widget.
-
-Sun Mar 8 16:38:10 1998 Tom Tromey <tromey@cygnus.com>
-
- * Makefile.am (INCLUDES): Added GNOME_INCLUDEDIR.
- (gncal_LDADD): Don't include libsupport.a.
-
- * gncal.c (main): Use new gnome_init.
-
-1998-02-19 Federico Mena Quintero <federico@nuclecu.unam.mx>
-
- * gncal.c (main): Added app_id "gncal".
-
-1998-02-19 Carsten Schaar <nhadcasc@fs-maphy.uni-hannover.de>
-
- * Makefile.am (gncal_LDADD): Added '$(INTLLIBS)'
-
-1998-02-18 Raja R Harinath <harinath@cs.umn.edu>
-
- * Makefile.am (gncal_LDADD): Include `libsupport.a'.
-
- * calcs.c (month_atoi): Replace buggy explicit loop string compare
- with strcasecmp.
- (day_atoi): Likewise.
-
-Sun Jan 25 23:38:30 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
-
- * menus.c: Replace "Quit" with "Exit".
diff --git a/calendar/GnomeCal.idl b/calendar/GnomeCal.idl
deleted file mode 100644
index 1e426fae36..0000000000
--- a/calendar/GnomeCal.idl
+++ /dev/null
@@ -1,125 +0,0 @@
-#include <Bonobo.idl>
-
-module GNOME {
-
- module Calendar {
-
- interface Repository {
-
- exception NotFound {};
- typedef sequence<string> String_Sequence;
-
- /*
- * get_object:
- * @uid: Unique Identifier for the object
- *
- * Returns a vCalendar object for the object
- * that matches the UID @uid.
- */
- string get_object (in string uid)
- raises (NotFound);
-
- /*
- * get_objects_by_id_list:
- * @uid_list: a sequence of Unique Identifiers
- *
- * Returns a vCalendar object for the objects
- * that matches the given UID list @uid_list;
- * NotFound is raised if any of the given UIDs
- * were not found.
- */
- string get_objects_by_id_list (in String_Sequence uid)
- raises (NotFound);
-
- /*
- * get_object_by_pilot_id:
- * @pilot_id: the pilot id
- *
- * Returns the object that has the @pilot_id
- * identifier.
- */
- string get_object_by_pilot_id (in long pilot_id)
- raises (NotFound);
-
- /*
- * get_id_from_pilot_id:
- * @pilot_id: the pilot id
- *
- * Returns the object id that matches the @pilot_id
- * identifier.
- */
- string get_id_from_pilot_id (in long pilot_id)
- raises (NotFound);
-
- /*
- * delete_object:
- * @uid: Unique Identifier for the object
- */
- void delete_object (in string uid)
- raises (NotFound);
-
- /*
- * update_object:
- * @uid: uid of object to update
- * @object: vcard object to update
- */
- void update_object (in string uid, in string object);
-
- /*
- * update_pilot_id:
- * @uid: Unique identifier for the event we want to update
- * @pilot_id: new ID assigned by the pilot
- * @pilot_status: Status to flag the event with
- */
- void update_pilot_id (in string uid, in long pilot_id, in long pilot_status)
- raises (NotFound);
-
- /*
- * get_objects:
- *
- * Danger Will Robinson : This can result in a
- * huge string, namely the size of all your entries.
- * Returns a vCalendar with all the objects
- */
- string get_objects ();
-
- /*
- * get_object_id_list
- *
- * Returns a sequence of the UID's of the entries
- */
- String_Sequence get_object_id_list();
-
- /*
- * get_updated_objects:
- *
- * Returns a vCalendar with all the objects that have been
- * modified since the last Pilot Sync
- */
- string get_updated_objects ();
-
- /*
- * Returns the number of objects of a specific type in the calendar
- * repository.
- */
-
- enum RecordStatus {
- ANY, /* This means all records */
- NEW,
- MODIFIED,
- DELETED
- };
-
- long get_number_of_objects(in RecordStatus record_status);
-
- /*
- * done:
- *
- * Informs the calendar that we are done using it,
- * gets a chance to destroy windows and save information.
- */
- void done ();
- };
- };
-};
-
diff --git a/calendar/Makefile.am b/calendar/Makefile.am
deleted file mode 100644
index 408f80dd76..0000000000
--- a/calendar/Makefile.am
+++ /dev/null
@@ -1,271 +0,0 @@
-SUBDIRS = doc
-
-idldir = $(datadir)/idl
-idl_DATA = \
- GnomeCal.idl \
- evolution-calendar.idl
-
-gnorbadir = $(sysconfdir)/CORBA/servers
-gnorba_DATA = \
- gnomecal.gnorba \
- tlacuache.gnorba
-
-help_base = $(datadir)/gnome/help/cal
-
-if HAVE_GNOME_PILOT
-extra_pilot_bins = \
- calendar-conduit-control-applet \
- calendar-pilot-sync
-endif
-
-bin_PROGRAMS = gnomecal tlacuache $(extra_pilot_bins)
-
-INCLUDES = \
- -I$(includedir) \
- $(GNOME_INCLUDEDIR) \
- $(GNOME_CONDUIT_INCLUDEDIR) \
- $(PISOCK_INCLUDEDIR) \
- -DGNOMELOCALEDIR=\""$(datadir)/locale"\"
-
-GNOMECAL_CORBA_GENERATED = \
- GnomeCal.h \
- GnomeCal.c \
- GnomeCal-common.c \
- GnomeCal-skels.c \
- GnomeCal-stubs.c
-
-$(GNOMECAL_CORBA_GENERATED): GnomeCal.idl
- orbit-idl $(srcdir)/GnomeCal.idl
-
-corba-cal.c \
-corba-cal.h \
-corba-cal-factory.c \
-corba-cal-factory.h: GnomeCal.h
-
-GNOME_CALENDAR_CORBA_GENERATED = \
- evolution-calendar.h \
- evolution-calendar-common.c \
- evolution-calendar-skels.c \
- evolution-calendar-stubs.c
-
-$(GNOME_CALENDAR_CORBA_GENERATED): evolution-calendar.idl
- orbit-idl -I`$(GNOME_CONFIG) --datadir`/idl $(srcdir)/evolution-calendar.idl
-
-gnomecal_SOURCES = \
- $(GNOME_CALENDAR_CORBA_GENERATED) \
- GnomeCal-common.c \
- GnomeCal-skels.c \
- GnomeCal.h \
- alarm.c \
- alarm.h \
- cal-client.c \
- cal-client.h \
- cal-listener.c \
- cal-listener.h \
- calendar.c \
- calendar.h \
- calendar-conduit.h \
- calobj.c \
- calobj.h \
- eventedit.c \
- eventedit.h \
- corba-cal.c \
- corba-cal.h \
- corba-cal-factory.c \
- corba-cal-factory.h \
- getdate.y \
- gncal-day-panel.c \
- gncal-day-panel.h \
- gncal-day-view.c \
- gncal-day-view.h \
- gncal-full-day.c \
- gncal-full-day.h \
- gncal-week-view.c \
- gncal-week-view.h \
- gncal-todo.c \
- gncal-todo.h \
- gnome-month-item.c \
- gnome-month-item.h \
- gnome-cal.c \
- gnome-cal.h \
- html-month.c \
- goto.c \
- layout.c \
- layout.h \
- main.c \
- main.h \
- mark.c \
- mark.h \
- month-view.c \
- month-view.h \
- popup-menu.c \
- popup-menu.h \
- prop.c \
- quick-view.c \
- quick-view.h \
- timeutil.c \
- timeutil.h \
- todo-conduit.h \
- view-utils.h \
- view-utils.c \
- year-view.c \
- year-view.h
-
-calendar_pilot_sync_SOURCES = \
- GnomeCal-common.c \
- GnomeCal-stubs.c \
- alarm.c \
- calendar-pilot-sync.c \
- calobj.c \
- calobj.h \
- calendar.c \
- calendar.h \
- timeutil.c \
- timeutil.h
-
-tlacuache_SOURCES = \
- $(GNOME_CALENDAR_CORBA_GENERATED) \
- alarm.c \
- alarm.h \
- cal.c \
- cal.h \
- cal-backend.c \
- cal-backend.h \
- cal-common.h \
- cal-factory.c \
- cal-factory.h \
- calobj.c \
- calobj.h \
- job.c \
- job.h \
- timeutil.c \
- timeutil.h \
- tlacuache.c
-
-LINK_FLAGS = \
- $(BONOBO_VFS_GNOME_LIBS) \
- $(INTLLIBS) \
- ../libversit/libversit.la
-
-tlacuache_INCLUDES = \
- $(INCLUDES) \
- -DG_LOG_DOMAIN=\"tlacuache\"
-
-tlacuache_LDADD = \
- $(BONOBO_VFS_GNOME_LIBS) \
- ../libversit/libversit.la
-
-calendar_pilot_sync_LDADD = \
- $(PISOCK_LIBDIR) $(PISOCK_LIBS) \
- $(LINK_FLAGS)
-
-if HAVE_GNOME_PILOT
-#calendar_conduit
-calendar_conduitsdir=$(libdir)/gnome-pilot/conduits
-
-calendar_conduits_LTLIBRARIES = libcalendar_conduit.la
-endif
-
-libcalendar_conduit_la_SOURCES = \
- GnomeCal-common.c \
- GnomeCal-stubs.c \
- calendar-conduit.c \
- calobj.c \
- alarm.c \
- calendar.c \
- timeutil.c
-
-calendar-conduit.c: my_gnomecal_idl
-
-libcalendar_conduit_la_LDFLAGS = \
- -rpath $(libdir)
-
-libcalendar_conduit_la_LIBADD = \
- ../libversit/libversit.la \
- $(PISOCK_LIBDIR) $(PISOCK_LIBS) \
- $(GNOME_LIBDIR) \
- $(GNOME_LIBS)
-
-calendar_conduit_control_applet_SOURCES = \
- calendar-conduit-control-applet.c
-
-calendar_conduit_control_applet_LDADD = \
- $(CAPPLET_LIBS) \
- $(GNOME_LIBDIR) \
- $(GNOME_CAPPLET_LIBS) \
- $(PISOCK_LIBDIR) $(PISOCK_LIBS) \
- $(GNOMEUI_LIBS) \
- $(GNOME_PILOT_LIBS) \
- $(INTLLIBS)
-
-#todo_conduit
-#todo_conduitsdir=$(libdir)/gnome-pilot/conduits
-
-#todo_conduits_LTLIBRARIES = libtodo_conduit.la
-
-#libtodo_conduit_la_LDFLAGS = \
-# -rpath $(libdir)
-
-#libtodo_conduit_la_LIBADD = \
-# $(GNOME_LIBDIR) \
-# $(GNOME_LIBS)
-
-#libtodo_conduit_la_SOURCES = \
-# todo-conduit.c
-
-#todo-conduit.c: GnomeCal.h
-
-#todo_conduit_control_applet_SOURCES = \
-# todo-conduit-control-applet.c
-
-#todo_conduit_control_applet_LDADD = \
-# $(CAPPLET_LIBS) \
-# $(GNOME_LIBDIR) \
-# $(GNOME_CAPPLET_LIBS) \
-# $(PISOCK_LIBDIR) $(PISOCK_LIBS) \
-# $(GNOMEUI_LIBS) \
-# $(GNOME_PILOT_LIBS) \
-# $(INTLLIBS)
-
-gnomecal_INCLUDES = \
- $(INCLUDES) \
- -DG_LOG_DOMAIN=\"gnomecal\"
-
-gnomecal_LDADD = $(LINK_FLAGS)
-
-if HAVE_GNOME_PILOT
-ccenterdir = $(datadir)/control-center
-Rootdir = $(ccenterdir)
-PalmPilotdir = $(ccenterdir)/Peripherals/PalmPilot
-Conduitsdir = $(PalmPilotdir)/Conduits
-
-Conduits_DATA = \
- calendar-conduit-control-applet.desktop
-# todo-conduit-control-applet.desktop
-
-Conduits_seconddir = $(datadir)/gnome/apps/Settings/Peripherals/PalmPilot/Conduits/
-Conduits_second_DATA = $(Conduits_DATA)
-endif
-
-EXTRA_DIST = \
- gncal.desktop \
- calendar-conduit-control-applet.desktop \
- bell.xpm \
- recur.xpm \
- $(idl_DATA) \
- $(gnorba_DATA) \
- gnome-calendar-conduit.png
-
-# todo-conduit-control-applet.desktop \
-
-
-appicondir = $(datadir)/pixmaps
-appicon_DATA = gnome-calendar-conduit.png
-
-Productivitydir = $(datadir)/gnome/apps/Applications
-
-Productivity_DATA = gncal.desktop
-
-install-data-local:
- $(mkinstalldirs) $(DESTDIR)$(help_base)/C
- $(mkinstalldirs) $(Conduitsdir)
diff --git a/calendar/TODO b/calendar/TODO
deleted file mode 100644
index 2dbd29cdbb..0000000000
--- a/calendar/TODO
+++ /dev/null
@@ -1,68 +0,0 @@
-Pilot:
-
-* Better support for untimed events (we have none now).
-
-* Hash objects based on their UIDs.
-
-* Add placeholders for deleted events, so that we can kill those
- when syncing to the pilot.
-
-BUGS:
-
-- Recurrence end date is wrong. An event that repeats daily will not
- be included in the ending date of the recurrence (off-by-one
- error?).
-
-- X-fields (extensions) are stripped from a vCal file when it is
- saved. They should be preserved.
-
-Features:
-
-- Add a calendar-week so that people know which week of the year it is
-
-Year view:
-
-- See why it is so fucking slow when opening its notebook page for the
- first time.
-
-Month view:
-
-- Popup menu like in the year view.
-
-- Double click on a day takes you to the day view.
-
-- DnD of appointments to move them around.
-
-Week view:
-
-- Nice display as in the Palm Pilot.
-
-Day view:
-
-- Rewrite in terms of the canvas and make it pretty.
-
-Preferences:
-
-- BUG: 12/24 hours stuff is not consistent - I remember that on editing
- new appointment you get the time-selectors always on 12-hr format
-
-Event editor dialog:
-
-- Make it figure out whether the alarm is in
- minutes/hours/days/etc. (via a cascade of conditions) and set the
- widgets appropriately.
-
-Gnome date selection widget:
-
-- Make the displayed date be localized properly -- use strftime().
-
-General:
-
-- Write online help. Nice help. Lots of help.
-
-- If you leave the calendar running overnight, the "current day"
- marker in the GnomeMonthItems does not get updated.
-
-- Add categories support. Color-coded categories.
-
-- Untimed events
diff --git a/calendar/alarm.c b/calendar/alarm.c
deleted file mode 100644
index cf1cd8fb60..0000000000
--- a/calendar/alarm.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Alarm handling for the GNOME Calendar.
- *
- * (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-#include <config.h>
-#include <time.h>
-#include <gnome.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/time.h>
-#include "calobj.h"
-#include "alarm.h"
-
-/* The pipes used to notify about an alarm */
-int alarm_pipes [2];
-
-/* The list of pending alarms */
-static GList *alarms;
-
-static void *head_alarm;
-
-typedef struct {
- time_t activation_time;
- AlarmFunction fn;
- void *closure;
- CalendarAlarm *alarm;
-} AlarmRecord;
-
-enum DebugAction {
- ALARM_ACTIVATED,
- ALARM_ADDED,
- ALARM_NOT_ADDED
-};
-
-void debug_alarm (AlarmRecord* ar, enum DebugAction action);
-void calendar_notify (time_t time, CalendarAlarm *which, void *data);
-extern int debug_alarms;
-
-/*
- * SIGALRM handler. Notifies the callback about the alarm
- */
-static void
-alarm_activate ()
-{
- char c = 0;
-
- write (alarm_pipes [1], &c, 1);
-}
-
-/*
- * SIGUSR1 handler. Toggles debugging output
- */
-static void
-toggle_debugging ()
-{
- debug_alarms = !debug_alarms;
-}
-
-static void
-alarm_ready (void *closure, int fd, GdkInputCondition cond)
-{
- AlarmRecord *ar = head_alarm;
- time_t now = time (NULL);
- char c;
-
- if (read (alarm_pipes [0], &c, 1) != 1)
- return;
-
- if (ar == NULL){
- g_warning ("Empty events. This should not happen\n");
- return;
- }
-
- while (head_alarm){
- if (debug_alarms)
- debug_alarm (ar, ALARM_ACTIVATED);
- (*ar->fn)(ar->activation_time, ar->alarm, ar->closure);
- alarms = g_list_remove (alarms, head_alarm);
-
- /* Schedule next alarm */
- if (alarms){
- AlarmRecord *next;
-
- head_alarm = alarms->data;
- next = head_alarm;
-
- if (next->activation_time > now){
- struct itimerval itimer;
-
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_sec = next->activation_time - now;
- itimer.it_value.tv_usec = 0;
- setitimer (ITIMER_REAL, &itimer, NULL);
- break;
- } else {
- g_free (ar);
- ar = next;
- }
- } else
- head_alarm = NULL;
- }
- g_free (ar);
-}
-
-static int
-alarm_compare_by_time (gconstpointer a, gconstpointer b)
-{
- const AlarmRecord *ara = a;
- const AlarmRecord *arb = b;
- time_t diff;
-
- diff = ara->activation_time - arb->activation_time;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-/**
- * alarm_add:
- *
- * Tries to schedule @alarm.
- *
- * Returns TRUE if the alarm was scheduled.
- */
-gboolean
-alarm_add (CalendarAlarm *alarm, AlarmFunction fn, void *closure)
-{
- time_t now = time (NULL);
- AlarmRecord *ar;
- time_t alarm_time = alarm->trigger;
-
- ar = g_new0 (AlarmRecord, 1);
- ar->activation_time = alarm_time;
- ar->fn = fn;
- ar->closure = closure;
- ar->alarm = alarm;
-
- /* If it already expired, do not add it */
- if (alarm_time < now) {
- if (debug_alarms)
- debug_alarm (ar, ALARM_NOT_ADDED);
- return FALSE;
- }
-
- alarms = g_list_insert_sorted (alarms, ar, alarm_compare_by_time);
-
- /* If first alarm is not the previous first alarm, reschedule SIGALRM */
- if (head_alarm != alarms->data){
- struct itimerval itimer;
- int v;
-
- /* Set the timer to disable upon activation */
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_sec = alarm_time - now;
- itimer.it_value.tv_usec = 0;
- v = setitimer (ITIMER_REAL, &itimer, NULL);
- head_alarm = alarms->data;
- }
- if (debug_alarms)
- debug_alarm (ar, ALARM_ADDED);
- return TRUE;
-}
-
-int
-alarm_kill (void *closure_key)
-{
- GList *p;
-
- for (p = alarms; p; p = p->next){
- AlarmRecord *ar = p->data;
-
- if (ar->closure == closure_key){
- alarms = g_list_remove (alarms, p->data);
- if (alarms)
- head_alarm = alarms->data;
- else
- head_alarm = NULL;
- return 1;
- }
- }
- return 0;
-}
-
-void
-alarm_init (void)
-{
- struct sigaction sa;
- struct sigaction debug_sa;
- int flags = 0;
-
- pipe (alarm_pipes);
-
- /* set non blocking mode */
- fcntl (alarm_pipes [0], F_GETFL, &flags);
- fcntl (alarm_pipes [0], F_SETFL, flags | O_NONBLOCK);
- gdk_input_add (alarm_pipes [0], GDK_INPUT_READ, alarm_ready, 0);
-
- /* Setup the signal handler */
- sa.sa_handler = alarm_activate;
- sigemptyset (&sa.sa_mask);
- sa.sa_flags = SA_RESTART;
- sigaction (SIGALRM, &sa, NULL);
-
- /* Setup a signal handler to toggle debugging */
- debug_sa.sa_handler = toggle_debugging;
- sigemptyset (&debug_sa.sa_mask);
- debug_sa.sa_flags = SA_RESTART;
- sigaction (SIGUSR1, &debug_sa, NULL);
-}
-
-void
-debug_alarm (AlarmRecord* ar, enum DebugAction action)
-{
- time_t now = time (NULL);
- iCalObject *ico = ar->closure;
- printf ("%s", ctime(&now));
- switch (action) {
- case ALARM_ADDED:
- printf ("Added alarm for %s", ctime(&ar->activation_time));
- break;
- case ALARM_NOT_ADDED:
- printf ("Alarm not added for %s", ctime(&ar->activation_time));
- break;
- case ALARM_ACTIVATED:
- printf ("Activated alarm\n");
- break;
- }
-
- if (ar->fn!=&calendar_notify) return;
- printf ("--- Summary: %s\n", ico->summary);
- switch (ar->alarm->type) {
- case ALARM_MAIL:
- printf ("--- Type: Mail\n");
- break;
- case ALARM_PROGRAM:
- printf ("--- Type: Program\n");
- break;
- case ALARM_DISPLAY:
- printf ("--- Type: Display\n");
- break;
- case ALARM_AUDIO:
- printf ("--- Type: Audio\n");
- break;
- }
-}
-
-
diff --git a/calendar/alarm.h b/calendar/alarm.h
deleted file mode 100644
index 81710bda5e..0000000000
--- a/calendar/alarm.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef ALARM_H
-#define ALARM_H
-
-#include <time.h>
-
-typedef void (*AlarmFunction)(time_t time, CalendarAlarm *which, void *closuse);
-
-void alarm_init (void);
-gboolean alarm_add (CalendarAlarm *alarm, AlarmFunction fn, void *closure);
-int alarm_kill (void *closure);
-
-#endif
diff --git a/calendar/bell.xpm b/calendar/bell.xpm
deleted file mode 100644
index b1ab537a17..0000000000
--- a/calendar/bell.xpm
+++ /dev/null
@@ -1,83 +0,0 @@
-/* XPM */
-static char * bell_xpm[] = {
-"16 16 64 1",
-" c None",
-". c #000000",
-"+ c #E3BB43",
-"@ c #E6C049",
-"# c #EED275",
-"$ c #F4E193",
-"% c #F4DF8C",
-"& c #EAC95C",
-"* c #EFD57A",
-"= c #FAEFBB",
-"- c #FDF6D3",
-"; c #FDF5C6",
-"> c #F4E18F",
-", c #E4BD43",
-"' c #F6E295",
-") c #FEF9D8",
-"! c #FFFFFF",
-"~ c #FFFADA",
-"{ c #FCEEAA",
-"] c #EBCA5A",
-"^ c #E9C550",
-"/ c #FAEA9C",
-"( c #FEF7CB",
-"_ c #FFF8CC",
-": c #FDF1A8",
-"< c #EED060",
-"[ c #D39D12",
-"} c #F2D55D",
-"| c #FCEC91",
-"1 c #FFF4AE",
-"2 c #FFF5B6",
-"3 c #FEEF97",
-"4 c #F3D65E",
-"5 c #D5A216",
-"6 c #FAE05C",
-"7 c #FFED7C",
-"8 c #FFEF8C",
-"9 c #FFF092",
-"0 c #FDEB7A",
-"a c #F4D750",
-"b c #D8A717",
-"c c #EAC01D",
-"d c #F6D83E",
-"e c #FAE255",
-"f c #FAE362",
-"g c #F9E161",
-"h c #F6DE5B",
-"i c #F1D145",
-"j c #E6BE28",
-"k c #D09B09",
-"l c #B67E00",
-"m c #CE9100",
-"n c #D69F04",
-"o c #E0B011",
-"p c #E6BA1D",
-"q c #E3B721",
-"r c #E0B21E",
-"s c #DCAB16",
-"t c #D7A20D",
-"u c #CC9303",
-"v c #BE8400",
-"w c #AC7500",
-"x c #A06B00",
-"y c #FFDD00",
-" ",
-" .. ",
-" .+@. ",
-" .#$%&. ",
-" .*=-;>,. ",
-" .')!~{]. ",
-" .^/(~_:<[. ",
-" .}|121345. ",
-" .678980ab. ",
-" .cdefghijkl. ",
-" .mnopqrstuvwx. ",
-" .............. ",
-" .8y. ",
-" .. ",
-" ",
-" "};
diff --git a/calendar/cal-backend.c b/calendar/cal-backend.c
deleted file mode 100644
index 72315e3882..0000000000
--- a/calendar/cal-backend.c
+++ /dev/null
@@ -1,498 +0,0 @@
-/* Evolution calendar backend
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include "cal-backend.h"
-#include "calobj.h"
-#include "../libversit/vcc.h"
-
-
-
-/* VCalendar product ID */
-#define PRODID "-//Helix Code//NONSGML Tlacuache//EN"
-
-
-
-/* Private part of the CalBackend structure */
-typedef struct {
- /* URI where the calendar data is stored */
- GnomeVFSURI *uri;
-
- /* List of Cal client interface objects, each with its listener */
- GList *clients;
-
- /* All the iCalObject structures in the calendar, hashed by UID. The
- * hash key *is* icalobj->uid; it is not copied, so don't free it when
- * you remove an object from the hash table.
- */
- GHashTable *object_hash;
-
- /* All events, TODOs, and journals in the calendar */
- GList *events;
- GList *todos;
- GList *journals;
-
- /* Whether a calendar has been loaded */
- guint loaded : 1;
-} CalBackendPrivate;
-
-
-
-static void cal_backend_class_init (CalBackendClass *class);
-static void cal_backend_init (CalBackend *backend);
-static void cal_backend_destroy (GtkObject *object);
-
-static GtkObjectClass *parent_class;
-
-
-
-/**
- * cal_backend_get_type:
- * @void:
- *
- * Registers the #CalBackend class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the #CalBackend class.
- **/
-GtkType
-cal_backend_get_type (void)
-{
- static GtkType cal_backend_type = 0;
-
- if (!cal_backend_type) {
- static const GtkTypeInfo cal_backend_info = {
- "CalBackend",
- sizeof (CalBackend),
- sizeof (CalBackendClass),
- (GtkClassInitFunc) cal_backend_class_init,
- (GtkObjectInitFunc) cal_backend_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- cal_backend_type = gtk_type_unique (GTK_TYPE_OBJECT, &cal_backend_info);
- }
-
- return cal_backend_type;
-}
-
-/* Class initialization function for the calendar backend */
-static void
-cal_backend_class_init (CalBackendClass *class)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) class;
-
- parent_class = gtk_type_class (GTK_TYPE_OBJECT);
-
- object_class->destroy = cal_backend_destroy;
-}
-
-/* Object initialization function for the calendar backend */
-static void
-cal_backend_init (CalBackend *backend)
-{
- CalBackendPrivate *priv;
-
- priv = g_new0 (CalBackendPrivate, 1);
- backend->priv = priv;
-}
-
-/* Destroy handler for the calendar backend */
-static void
-cal_backend_destroy (GtkObject *object)
-{
- CalBackend *backend;
- CalBackendPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL_BACKEND (object));
-
- backend = CAL_BACKEND (object);
- priv = backend->priv;
-
- /* FIXME: free stuff */
-
- g_free (priv);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-
-
-/* iCalObject manipulation functions */
-
-/* Ensures that an iCalObject has a unique identifier. If it doesn't have one,
- * it will create one for it. Returns whether an UID was created or not.
- */
-static gboolean
-ensure_uid (iCalObject *ico)
-{
- char *buf;
- gulong str_time;
- static guint seqno = 0;
-
- if (ico->uid)
- return FALSE;
-
- str_time = (gulong) time (NULL);
-
- /* Is this good enough? */
-
- buf = g_strdup_printf ("Evolution-Tlacuache-%d-%ld-%u", (int) getpid(), str_time, seqno++);
- ico->uid = buf;
-
- return TRUE;
-}
-
-/* Adds an object to the calendar backend. Does *not* perform notification to
- * calendar clients.
- */
-static void
-add_object (CalBackend *backend, iCalObject *ico)
-{
- CalBackendPrivate *priv;
-
- g_assert (ico != NULL);
- priv = backend->priv;
-
-#if 0
- /* FIXME: gnomecal old code */
- ico->new = 0;
-#endif
-
- if (ensure_uid (ico))
- /* FIXME: mark the calendar as dirty so that we can re-save it
- * with the object's new UID.
- */
- ;
-
- g_hash_table_insert (priv->object_hash, ico->uid, ico);
-
- switch (ico->type) {
- case ICAL_EVENT:
- priv->events = g_list_prepend (priv->events, ico);
-#if 0
- /* FIXME: gnomecal old code */
- ical_object_try_alarms (ico);
-# ifdef DEBUGGING_MAIL_ALARM
- ico->malarm.trigger = 0;
- calendar_notify (0, ico);
-# endif
-#endif
- break;
-
- case ICAL_TODO:
- priv->todos = g_list_prepend (priv->todos, ico);
- break;
-
- case ICAL_JOURNAL:
- priv->journals = g_list_prepend (priv->journals, ico);
- break;
-
- default:
- g_assert_not_reached ();
- }
-
-#if 0
- /* FIXME: gnomecal old code */
- ico->last_mod = time (NULL);
-#endif
-}
-
-/* Load a calendar from a VObject */
-static void
-load_from_vobject (CalBackend *backend, VObject *vobject)
-{
- CalBackendPrivate *priv;
- VObjectIterator i;
-
- priv = backend->priv;
-
- g_assert (!priv->loaded);
- g_assert (priv->object_hash == NULL);
- priv->object_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
- initPropIterator (&i, vobject);
-
- while (moreIteration (&i)) {
- VObject *this;
- iCalObject *ical;
- const char *object_name;
-
- this = nextVObject (&i);
- object_name = vObjectName (this);
-#if 0
- /* FIXME? What is this used for in gnomecal? */
- if (strcmp (object_name, VCDCreatedProp) == 0) {
- cal->created = time_from_isodate (str_val (this));
- continue;
- }
-#endif
- if (strcmp (object_name, VCLocationProp) == 0)
- continue; /* FIXME: imlement */
-
- if (strcmp (object_name, VCProdIdProp) == 0)
- continue; /* FIXME: implement */
-
- if (strcmp (object_name, VCVersionProp) == 0)
- continue; /* FIXME: implement */
-
- if (strcmp (object_name, VCTimeZoneProp) == 0)
- continue; /* FIXME: implement */
-
- ical = ical_object_create_from_vobject (this, object_name);
-
- if (ical)
- add_object (backend, ical);
- }
-}
-
-/* Creates a VObject with the base information of a calendar */
-static VObject *
-get_calendar_base_vobject (CalBackend *backend)
-{
- VObject *vobj;
- time_t now;
- struct tm tm;
-
- /* We call localtime for the side effect of setting tzname */
-
- now = time (NULL);
- tm = *localtime (&now);
-
- vobj = newVObject (VCCalProp);
-
- addPropValue (vobj, VCProdIdProp, PRODID);
-
-#if defined (HAVE_TM_ZONE)
- addPropValue (vobj, VCTimeZoneProp, tm.tm_zone);
-#elif defined (HAVE_TZNAME)
- addPropValue (vobj, VCTimeZoneProp, tzname[0]);
-#endif
-
- /* Per the vCalendar spec, this must be "1.0" */
- addPropValue (vobj, VCVersionProp, "1.0");
-
- return vobj;
-}
-
-
-
-/**
- * cal_backend_new:
- * @void:
- *
- * Creates a new empty calendar backend. A calendar must then be loaded or
- * created before the backend can be used.
- *
- * Return value: A newly-created calendar backend.
- **/
-CalBackend *
-cal_backend_new (void)
-{
- return CAL_BACKEND (gtk_type_new (CAL_BACKEND_TYPE));
-}
-
-/**
- * cal_backend_get_uri:
- * @backend: A calendar backend.
- *
- * Queries the URI of a calendar backend, which must already have a loaded
- * calendar.
- *
- * Return value: The URI where the calendar is stored.
- **/
-GnomeVFSURI *
-cal_backend_get_uri (CalBackend *backend)
-{
- CalBackendPrivate *priv;
-
- g_return_val_if_fail (backend != NULL, NULL);
- g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
-
- priv = backend->priv;
- g_return_val_if_fail (priv->loaded, NULL);
- g_assert (priv->uri != NULL);
-
- return priv->uri;
-}
-
-/**
- * cal_backend_add_cal:
- * @backend: A calendar backend.
- * @cal: A calendar client interface object.
- *
- * Adds a calendar client interface object to a calendar @backend. The calendar
- * backend must already have a loaded calendar.
- **/
-void
-cal_backend_add_cal (CalBackend *backend, Cal *cal)
-{
- CalBackendPrivate *priv;
-
- g_return_if_fail (backend != NULL);
- g_return_if_fail (IS_CAL_BACKEND (backend));
-
- priv = backend->priv;
- g_return_if_fail (priv->loaded);
-
- g_return_if_fail (cal != NULL);
- g_return_if_fail (IS_CAL (cal));
-
- gtk_object_ref (GTK_OBJECT (cal));
- priv->clients = g_list_prepend (priv->clients, cal);
-}
-
-/**
- * cal_backend_remove_cal:
- * @backend: A calendar backend.
- * @cal: A calendar client interface object.
- *
- * Removes a calendar client interface object from a calendar backend. The
- * calendar backend must already have a loaded calendar.
- **/
-void
-cal_backend_remove_cal (CalBackend *backend, Cal *cal)
-{
- CalBackendPrivate *priv;
- GList *l;
-
- g_return_if_fail (backend != NULL);
- g_return_if_fail (IS_CAL_BACKEND (backend));
-
- priv = backend->priv;
- g_return_if_fail (priv->loaded);
-
- g_return_if_fail (cal != NULL);
- g_return_if_fail (IS_CAL (cal));
-
- l = g_list_find (priv->clients, cal);
- if (!l)
- return;
-
- gtk_object_unref (GTK_OBJECT (cal));
- priv->clients = g_list_remove_link (priv->clients, l);
- g_list_free_1 (l);
-}
-
-/**
- * cal_backend_load:
- * @backend: A calendar backend.
- * @uri: URI that contains the calendar data.
- *
- * Loads a calendar backend with data from a calendar stored at the specified
- * URI.
- *
- * Return value: An operation status code.
- **/
-CalBackendLoadStatus
-cal_backend_load (CalBackend *backend, GnomeVFSURI *uri)
-{
- CalBackendPrivate *priv;
- VObject *vobject;
- char *str_uri;
-
- g_return_val_if_fail (backend != NULL, CAL_BACKEND_LOAD_ERROR);
- g_return_val_if_fail (IS_CAL_BACKEND (backend), CAL_BACKEND_LOAD_ERROR);
- g_return_val_if_fail (uri != NULL, CAL_BACKEND_LOAD_ERROR);
-
- priv = backend->priv;
- g_return_val_if_fail (!priv->loaded, CAL_BACKEND_LOAD_ERROR);
-
- /* FIXME: this looks rather bad; maybe we should check for local files
- * and fail if they are remote.
- */
-
- str_uri = gnome_vfs_uri_to_string (uri,
- (GNOME_VFS_URI_HIDE_USER_NAME
- | GNOME_VFS_URI_HIDE_PASSWORD
- | GNOME_VFS_URI_HIDE_HOST_NAME
- | GNOME_VFS_URI_HIDE_HOST_PORT
- | GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD));
-
- vobject = Parse_MIME_FromFileName (str_uri);
- g_free (str_uri);
-
- if (!vobject)
- return CAL_BACKEND_LOAD_ERROR;
-
- load_from_vobject (backend, vobject);
- cleanVObject (vobject);
- cleanStrTbl ();
-
- gnome_vfs_uri_ref (uri);
-
- priv->uri = uri;
- priv->loaded = TRUE;
- return CAL_BACKEND_LOAD_SUCCESS;
-}
-
-/**
- * cal_backend_get_object:
- * @backend: A calendar backend.
- * @uid: Unique identifier for a calendar object.
- *
- * Queries a calendar backend for a calendar object based on its unique
- * identifier.
- *
- * Return value: The string representation of a complete calendar wrapping the
- * the sought object, or NULL if no object had the specified UID. A complete
- * calendar is returned because you also need the timezone data.
- **/
-char *
-cal_backend_get_object (CalBackend *backend, const char *uid)
-{
- CalBackendPrivate *priv;
- iCalObject *ico;
- VObject *vcalobj, *vobj;
- char *buf;
-
- g_return_val_if_fail (backend != NULL, NULL);
- g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
-
- priv = backend->priv;
- g_return_val_if_fail (priv->loaded, NULL);
-
- g_return_val_if_fail (uid != NULL, NULL);
-
- g_assert (priv->object_hash != NULL);
-
- ico = g_hash_table_lookup (priv->objec_hash, uid);
-
- if (!ico)
- return NULL;
-
- vcalobj = get_calendar_base_vobject (backend);
- vobj = ical_object_to_vobject (ico);
- addVObjectProp (vcalobj, vobj);
-
- buf = writeMemVObject (NULL, NULL, vcalobj);
-
- cleanVObject (vcalobj);
- cleanStrTbl ();
-
- return buf;
-}
diff --git a/calendar/cal-backend.h b/calendar/cal-backend.h
deleted file mode 100644
index e972cbd59e..0000000000
--- a/calendar/cal-backend.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Evolution calendar backend
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CAL_BACKEND_H
-#define CAL_BACKEND_H
-
-#include <libgnome/gnome-defs.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include "evolution-calendar.h"
-#include "cal-common.h"
-#include "cal.h"
-
-BEGIN_GNOME_DECLS
-
-
-
-#define CAL_BACKEND_TYPE (cal_backend_get_type ())
-#define CAL_BACKEND(obj) (GTK_CHECK_CAST ((obj), CAL_BACKEND_TYPE, CalBackend))
-#define CAL_BACKEND_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_BACKEND_TYPE, \
- CalBackendClass))
-#define IS_CAL_BACKEND(obj) (GTK_CHECK_TYPE ((obj), CAL_BACKEND_TYPE))
-#define IS_CAL_BACKEND_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_TYPE))
-
-typedef enum {
- CAL_BACKEND_LOAD_SUCCESS, /* Loading OK */
- CAL_BACKEND_LOAD_ERROR /* We need better error reporting in libversit */
-} CalBackendLoadStatus;
-
-struct _CalBackend {
- GtkObject object;
-
- /* Private data */
- gpointer priv;
-};
-
-struct _CalBackendClass {
- GtkObjectClass parent_class;
-};
-
-GtkType cal_backend_get_type (void);
-
-CalBackend *cal_backend_new (void);
-
-GnomeVFSURI *cal_backend_get_uri (CalBackend *backend);
-
-void cal_backend_add_cal (CalBackend *backend, Cal *cal);
-void cal_backend_remove_cal (CalBackend *backend, Cal *cal);
-
-CalBackendLoadStatus cal_backend_load (CalBackend *backend, GnomeVFSURI *uri);
-
-char *cal_backend_get_object (CalBackend *backend, const char *uid);
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/cal-client.c b/calendar/cal-client.c
deleted file mode 100644
index 63d33610f6..0000000000
--- a/calendar/cal-client.c
+++ /dev/null
@@ -1,473 +0,0 @@
-/* Evolution calendar client
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include <libgnorba/gnorba.h>
-#include "cal-client.h"
-#include "cal-listener.h"
-
-
-
-/* Loading state for the calendar client */
-typedef enum {
- LOAD_STATE_NOT_LOADED,
- LOAD_STATE_LOADING,
- LOAD_STATE_LOADED
-} LoadState;
-
-/* Private part of the CalClient structure */
-typedef struct {
- /* Load state to avoid multiple loads */
- LoadState load_state;
-
- /* The calendar factory we are contacting */
- Evolution_Calendar_CalFactory factory;
-
- /* Our calendar listener */
- CalListener *listener;
-
- /* The calendar client interface object we are contacting */
- Evolution_Calendar_Cal cal;
-} CalClientPrivate;
-
-
-
-/* Signal IDs */
-enum {
- CAL_LOADED,
- OBJ_ADDED,
- OBJ_REMOVED,
- OBJ_CHANGED,
- LAST_SIGNAL
-};
-
-static void cal_client_class_init (CalClientClass *class);
-static void cal_client_init (CalClient *client);
-static void cal_client_destroy (GtkObject *object);
-
-static guint cal_client_signals[LAST_SIGNAL];
-
-static GtkObjectClass *parent_class;
-
-
-
-/**
- * cal_client_get_type:
- * @void:
- *
- * Registers the #CalClient class if necessary, and returns the type ID assigned
- * to it.
- *
- * Return value: The type ID of the #CalClient class.
- **/
-GtkType
-cal_client_get_type (void)
-{
- static GtkType cal_client_type = 0;
-
- if (!cal_client_type) {
- static const GtkTypeInfo cal_client_info = {
- "CalClient",
- sizeof (CalClient),
- sizeof (CalClientClass),
- (GtkClassInitFunc) cal_client_class_init,
- (GtkObjectInitFunc) cal_client_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- cal_client_type = gtk_type_unique (GTK_TYPE_OBJECT, &cal_client_info);
- }
-
- return cal_client_type;
-}
-
-/* Class initialization function for the calendar client */
-static void
-cal_client_class_init (CalClientClass *class)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) class;
-
- parent_class = gtk_type_class (GTK_TYPE_OBJECT);
-
- cal_client_signals[CAL_LOADED] =
- gtk_signal_new ("cal_loaded",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalClientClass, cal_loaded),
- gtk_marshal_NONE__ENUM,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_ENUM);
- cal_client_signals[OBJ_ADDED] =
- gtk_signal_new ("obj_added",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalClientClass, obj_added),
- gtk_marshal_NONE__STRING,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_STRING);
- cal_client_signals[OBJ_REMOVED] =
- gtk_signal_new ("obj_removed",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalClientClass, obj_removed),
- gtk_marshal_NONE__STRING,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_STRING);
- cal_client_signals[OBJ_CHANGED] =
- gtk_signal_new ("obj_changed",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalClientClass, obj_changed),
- gtk_marshal_NONE__STRING,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_STRING);
-
- gtk_object_class_add_signals (object_class, cal_client_signals, LAST_SIGNAL);
-
- object_class->destroy = cal_client_destroy;
-}
-
-/* Object initialization function for the calendar client */
-static void
-cal_client_init (CalClient *client)
-{
- CalClientPrivate *priv;
-
- priv = g_new0 (CalClientPrivate, 1);
- client->priv = priv;
-
- priv->factory = CORBA_OBJECT_NIL;
- priv->load_state = LOAD_STATE_NOT_LOADED;
-}
-
-/* Destroy handler for the calendar client */
-static void
-cal_client_destroy (GtkObject *object)
-{
- CalClient *client;
- CalClientPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL_CLIENT (object));
-
- client = CAL_CLIENT (object);
- priv = client->priv;
-
- /* FIXME */
-
- g_free (priv);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-
-
-/* Signal handlers for the listener's signals */
-
-/* Handle the cal_loaded signal from the listener */
-static void
-cal_loaded_cb (CalListener *listener,
- CalListenerLoadStatus status,
- Evolution_Calendar_Cal cal,
- gpointer data)
-{
- CalClient *client;
- CalClientPrivate *priv;
- CORBA_Environment ev;
- Evolution_Calendar_Cal cal_copy;
-
- client = CAL_CLIENT (data);
- priv = client->priv;
-
- g_assert (priv->load_state == LOAD_STATE_LOADING);
-
- switch (status) {
- case CAL_LISTENER_LOAD_SUCCESS:
- CORBA_exception_init (&ev);
- cal_copy = CORBA_Object_duplicate (cal, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_loaded(): could not duplicate the calendar client interface");
- CORBA_exception_free (&ev);
- goto error;
- }
- CORBA_exception_free (&ev);
-
- priv->cal = cal_copy;
- priv->load_state = LOAD_STATE_LOADED;
-
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[CAL_LOADED],
- CAL_CLIENT_LOAD_SUCCESS);
- goto out;
-
- case CAL_LISTENER_LOAD_ERROR:
- goto error;
-
- default:
- g_assert_not_reached ();
- }
-
- error:
-
- gtk_object_unref (GTK_OBJECT (priv->listener));
- priv->listener = NULL;
- priv->load_state = LOAD_STATE_NOT_LOADED;
-
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[CAL_LOADED],
- CAL_CLIENT_LOAD_ERROR);
-
- out:
- g_assert (priv->load_state != LOAD_STATE_LOADING);
-}
-
-/* Handle the obj_added signal from the listener */
-static void
-obj_added_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data)
-{
- CalClient *client;
-
- client = CAL_CLIENT (data);
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_ADDED], uid);
-}
-
-/* Handle the obj_removed signal from the listener */
-static void
-obj_removed_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data)
-{
- CalClient *client;
-
- client = CAL_CLIENT (data);
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_REMOVED], uid);
-}
-
-/* Handle the obj_changed signal from the listener */
-static void
-obj_changed_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data)
-{
- CalClient *client;
-
- client = CAL_CLIENT (data);
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_CHANGED], uid);
-}
-
-
-
-/**
- * cal_client_construct:
- * @client: A calendar client.
- *
- * Constructs a calendar client object by contacting the calendar factory of the
- * calendar server.
- *
- * Return value: The same object as the @client argument, or NULL if the
- * calendar factory could not be contacted.
- **/
-CalClient *
-cal_client_construct (CalClient *client)
-{
- CalClientPrivate *priv;
- Evolution_Calendar_CalFactory factory, factory_copy;
- CORBA_Environment ev;
- int result;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
-
- factory = (Evolution_Calendar_CalFactory) goad_server_activate_with_id (
- NULL,
- "calendar:cal-factory",
- GOAD_ACTIVATE_REMOTE,
- NULL);
-
- CORBA_exception_init (&ev);
- result = CORBA_Object_is_nil (factory, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_client_construct(): could not see if the factory is NIL");
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- if (result) {
- g_message ("cal_client_construct(): could not contact Tlacuache, "
- "the personal calendar server");
- return NULL;
- }
-
- CORBA_exception_init (&ev);
- factory_copy = CORBA_Object_duplicate (factory, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_client_construct(): could not duplicate the calendar factory");
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- priv->factory = factory_copy;
- return client;
-}
-
-/**
- * cal_client_new:
- * @void:
- *
- * Creates a new calendar client. It should be initialized by calling
- * cal_client_load_calendar() or cal_client_create_calendar().
- *
- * Return value: A newly-created calendar client, or NULL if the client could
- * not be constructed because it could not contact the calendar server.
- **/
-CalClient *
-cal_client_new (void)
-{
- CalClient *client;
-
- client = gtk_type_new (CAL_CLIENT_TYPE);
-
- if (!cal_client_construct (client)) {
- g_message ("cal_client_new(): could not construct the calendar client");
- gtk_object_unref (GTK_OBJECT (client));
- return NULL;
- }
-
- return client;
-}
-
-/**
- * cal_client_load_calendar:
- * @client: A calendar client.
- * @str_uri: URI of calendar to load.
- *
- * Makes a calendar client initiate a request to load a calendar. The calendar
- * client will emit the "cal_loaded" signal when the response from the server is
- * received.
- *
- * Return value: TRUE on success, FALSE on failure to issue the load request.
- **/
-gboolean
-cal_client_load_calendar (CalClient *client, const char *str_uri)
-{
- CalClientPrivate *priv;
- Evolution_Calendar_Listener corba_listener;
- CORBA_Environment ev;
-
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == LOAD_STATE_NOT_LOADED, FALSE);
-
- g_return_val_if_fail (str_uri != NULL, FALSE);
-
- priv->listener = cal_listener_new ();
- if (!priv->listener) {
- g_message ("cal_client_load_calendar(): could not create the listener");
- return FALSE;
- }
-
- gtk_signal_connect (GTK_OBJECT (priv->listener), "cal_loaded",
- GTK_SIGNAL_FUNC (cal_loaded_cb),
- client);
- gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_added",
- GTK_SIGNAL_FUNC (obj_added_cb),
- client);
- gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_removed",
- GTK_SIGNAL_FUNC (obj_removed_cb),
- client);
- gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_changed",
- GTK_SIGNAL_FUNC (obj_changed_cb),
- client);
-
- corba_listener = (Evolution_Calendar_Listener) bonobo_object_corba_objref (
- BONOBO_OBJECT (priv->listener));
-
- CORBA_exception_init (&ev);
-
- priv->load_state = LOAD_STATE_LOADING;
- Evolution_Calendar_CalFactory_load (priv->factory, str_uri, corba_listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_client_load_calendar(): load request failed");
- gtk_object_unref (GTK_OBJECT (priv->listener));
- priv->listener = NULL;
- priv->load_state = LOAD_STATE_NOT_LOADED;
- CORBA_exception_free (&ev);
- return FALSE;
- }
- CORBA_exception_free (&ev);
-
- return TRUE;
-}
-
-/**
- * cal_client_get_object:
- * @client: A calendar client.
- * @uid: Unique identifier for a calendar object.
- *
- * Queries a calendar for a calendar object based on its unique identifier.
- *
- * Return value: The string representation of a complete calendar wrapping the
- * sought object, or NULL if no object had the specified UID. A complete
- * calendar is returned because you also need the timezone data.
- **/
-char *
-cal_client_get_object (CalClient *client, const char *uid)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- Evolution_Calendar_CalObj calobj;
- char *retval;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL);
-
- g_return_val_if_fail (uid != NULL, NULL);
-
- retval = NULL;
-
- CORBA_exception_init (&ev);
- calobj = Evolution_Calendar_Cal_get_object (priv->cal, uid, &ev);
-
- if (ev._major == CORBA_USER_EXCEPTION
- && strcmp (CORBA_exception_id (&ev), ex_Evolution_Calendar_Cal_NotFound) == 0)
- goto out;
- else if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_client_get_object(): could not get the object");
- goto out;
- }
-
- retval = g_strdup (calobj);
-
- out:
- CORBA_exception_free (&ev);
- return retval;
-}
diff --git a/calendar/cal-client.h b/calendar/cal-client.h
deleted file mode 100644
index 2f9ae5e1f8..0000000000
--- a/calendar/cal-client.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Evolution calendar client
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CAL_CLIENT_H
-#define CAL_CLIENT_H
-
-#include <libgnome/gnome-defs.h>
-#include <gtk/gtkobject.h>
-
-BEGIN_GNOME_DECLS
-
-
-
-#define CAL_CLIENT_TYPE (cal_client_get_type ())
-#define CAL_CLIENT(obj) (GTK_CHECK_CAST ((obj), CAL_CLIENT_TYPE, CalClient))
-#define CAL_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_CLIENT_TYPE, CalClientClass))
-#define IS_CAL_CLIENT(obj) (GTK_CHECK_TYPE ((obj), CAL_CLIENT_TYPE))
-#define IS_CAL_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_CLIENT_TYPE))
-
-typedef struct _CalClient CalClient;
-typedef struct _CalClientClass CalClientClass;
-
-/* Load status for the cal_loaded signal */
-typedef enum {
- CAL_CLIENT_LOAD_SUCCESS,
- CAL_CLIENT_LOAD_ERROR
-} CalClientLoadStatus;
-
-struct _CalClient {
- GtkObject object;
-
- /* Private data */
- gpointer priv;
-};
-
-struct _CalClientClass {
- GtkObjectClass parent_class;
-
- /* Notification signals */
-
- void (* cal_loaded) (CalClient *client, CalClientLoadStatus status);
-
- void (* obj_added) (CalClient *client, const char *uid);
- void (* obj_removed) (CalClient *client, const char *uid);
- void (* obj_changed) (CalClient *client, const char *uid);
-};
-
-GtkType cal_client_get_type (void);
-
-CalClient *cal_client_construct (CalClient *client);
-
-CalClient *cal_client_new (void);
-
-gboolean cal_client_load_calendar (CalClient *client, const char *str_uri);
-
-char *cal_client_get_object (CalClient *client, const char *uid);
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
deleted file mode 100644
index 63d33610f6..0000000000
--- a/calendar/cal-client/cal-client.c
+++ /dev/null
@@ -1,473 +0,0 @@
-/* Evolution calendar client
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include <libgnorba/gnorba.h>
-#include "cal-client.h"
-#include "cal-listener.h"
-
-
-
-/* Loading state for the calendar client */
-typedef enum {
- LOAD_STATE_NOT_LOADED,
- LOAD_STATE_LOADING,
- LOAD_STATE_LOADED
-} LoadState;
-
-/* Private part of the CalClient structure */
-typedef struct {
- /* Load state to avoid multiple loads */
- LoadState load_state;
-
- /* The calendar factory we are contacting */
- Evolution_Calendar_CalFactory factory;
-
- /* Our calendar listener */
- CalListener *listener;
-
- /* The calendar client interface object we are contacting */
- Evolution_Calendar_Cal cal;
-} CalClientPrivate;
-
-
-
-/* Signal IDs */
-enum {
- CAL_LOADED,
- OBJ_ADDED,
- OBJ_REMOVED,
- OBJ_CHANGED,
- LAST_SIGNAL
-};
-
-static void cal_client_class_init (CalClientClass *class);
-static void cal_client_init (CalClient *client);
-static void cal_client_destroy (GtkObject *object);
-
-static guint cal_client_signals[LAST_SIGNAL];
-
-static GtkObjectClass *parent_class;
-
-
-
-/**
- * cal_client_get_type:
- * @void:
- *
- * Registers the #CalClient class if necessary, and returns the type ID assigned
- * to it.
- *
- * Return value: The type ID of the #CalClient class.
- **/
-GtkType
-cal_client_get_type (void)
-{
- static GtkType cal_client_type = 0;
-
- if (!cal_client_type) {
- static const GtkTypeInfo cal_client_info = {
- "CalClient",
- sizeof (CalClient),
- sizeof (CalClientClass),
- (GtkClassInitFunc) cal_client_class_init,
- (GtkObjectInitFunc) cal_client_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- cal_client_type = gtk_type_unique (GTK_TYPE_OBJECT, &cal_client_info);
- }
-
- return cal_client_type;
-}
-
-/* Class initialization function for the calendar client */
-static void
-cal_client_class_init (CalClientClass *class)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) class;
-
- parent_class = gtk_type_class (GTK_TYPE_OBJECT);
-
- cal_client_signals[CAL_LOADED] =
- gtk_signal_new ("cal_loaded",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalClientClass, cal_loaded),
- gtk_marshal_NONE__ENUM,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_ENUM);
- cal_client_signals[OBJ_ADDED] =
- gtk_signal_new ("obj_added",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalClientClass, obj_added),
- gtk_marshal_NONE__STRING,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_STRING);
- cal_client_signals[OBJ_REMOVED] =
- gtk_signal_new ("obj_removed",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalClientClass, obj_removed),
- gtk_marshal_NONE__STRING,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_STRING);
- cal_client_signals[OBJ_CHANGED] =
- gtk_signal_new ("obj_changed",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalClientClass, obj_changed),
- gtk_marshal_NONE__STRING,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_STRING);
-
- gtk_object_class_add_signals (object_class, cal_client_signals, LAST_SIGNAL);
-
- object_class->destroy = cal_client_destroy;
-}
-
-/* Object initialization function for the calendar client */
-static void
-cal_client_init (CalClient *client)
-{
- CalClientPrivate *priv;
-
- priv = g_new0 (CalClientPrivate, 1);
- client->priv = priv;
-
- priv->factory = CORBA_OBJECT_NIL;
- priv->load_state = LOAD_STATE_NOT_LOADED;
-}
-
-/* Destroy handler for the calendar client */
-static void
-cal_client_destroy (GtkObject *object)
-{
- CalClient *client;
- CalClientPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL_CLIENT (object));
-
- client = CAL_CLIENT (object);
- priv = client->priv;
-
- /* FIXME */
-
- g_free (priv);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-
-
-/* Signal handlers for the listener's signals */
-
-/* Handle the cal_loaded signal from the listener */
-static void
-cal_loaded_cb (CalListener *listener,
- CalListenerLoadStatus status,
- Evolution_Calendar_Cal cal,
- gpointer data)
-{
- CalClient *client;
- CalClientPrivate *priv;
- CORBA_Environment ev;
- Evolution_Calendar_Cal cal_copy;
-
- client = CAL_CLIENT (data);
- priv = client->priv;
-
- g_assert (priv->load_state == LOAD_STATE_LOADING);
-
- switch (status) {
- case CAL_LISTENER_LOAD_SUCCESS:
- CORBA_exception_init (&ev);
- cal_copy = CORBA_Object_duplicate (cal, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_loaded(): could not duplicate the calendar client interface");
- CORBA_exception_free (&ev);
- goto error;
- }
- CORBA_exception_free (&ev);
-
- priv->cal = cal_copy;
- priv->load_state = LOAD_STATE_LOADED;
-
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[CAL_LOADED],
- CAL_CLIENT_LOAD_SUCCESS);
- goto out;
-
- case CAL_LISTENER_LOAD_ERROR:
- goto error;
-
- default:
- g_assert_not_reached ();
- }
-
- error:
-
- gtk_object_unref (GTK_OBJECT (priv->listener));
- priv->listener = NULL;
- priv->load_state = LOAD_STATE_NOT_LOADED;
-
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[CAL_LOADED],
- CAL_CLIENT_LOAD_ERROR);
-
- out:
- g_assert (priv->load_state != LOAD_STATE_LOADING);
-}
-
-/* Handle the obj_added signal from the listener */
-static void
-obj_added_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data)
-{
- CalClient *client;
-
- client = CAL_CLIENT (data);
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_ADDED], uid);
-}
-
-/* Handle the obj_removed signal from the listener */
-static void
-obj_removed_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data)
-{
- CalClient *client;
-
- client = CAL_CLIENT (data);
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_REMOVED], uid);
-}
-
-/* Handle the obj_changed signal from the listener */
-static void
-obj_changed_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data)
-{
- CalClient *client;
-
- client = CAL_CLIENT (data);
- gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_CHANGED], uid);
-}
-
-
-
-/**
- * cal_client_construct:
- * @client: A calendar client.
- *
- * Constructs a calendar client object by contacting the calendar factory of the
- * calendar server.
- *
- * Return value: The same object as the @client argument, or NULL if the
- * calendar factory could not be contacted.
- **/
-CalClient *
-cal_client_construct (CalClient *client)
-{
- CalClientPrivate *priv;
- Evolution_Calendar_CalFactory factory, factory_copy;
- CORBA_Environment ev;
- int result;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
-
- factory = (Evolution_Calendar_CalFactory) goad_server_activate_with_id (
- NULL,
- "calendar:cal-factory",
- GOAD_ACTIVATE_REMOTE,
- NULL);
-
- CORBA_exception_init (&ev);
- result = CORBA_Object_is_nil (factory, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_client_construct(): could not see if the factory is NIL");
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- if (result) {
- g_message ("cal_client_construct(): could not contact Tlacuache, "
- "the personal calendar server");
- return NULL;
- }
-
- CORBA_exception_init (&ev);
- factory_copy = CORBA_Object_duplicate (factory, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_client_construct(): could not duplicate the calendar factory");
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- priv->factory = factory_copy;
- return client;
-}
-
-/**
- * cal_client_new:
- * @void:
- *
- * Creates a new calendar client. It should be initialized by calling
- * cal_client_load_calendar() or cal_client_create_calendar().
- *
- * Return value: A newly-created calendar client, or NULL if the client could
- * not be constructed because it could not contact the calendar server.
- **/
-CalClient *
-cal_client_new (void)
-{
- CalClient *client;
-
- client = gtk_type_new (CAL_CLIENT_TYPE);
-
- if (!cal_client_construct (client)) {
- g_message ("cal_client_new(): could not construct the calendar client");
- gtk_object_unref (GTK_OBJECT (client));
- return NULL;
- }
-
- return client;
-}
-
-/**
- * cal_client_load_calendar:
- * @client: A calendar client.
- * @str_uri: URI of calendar to load.
- *
- * Makes a calendar client initiate a request to load a calendar. The calendar
- * client will emit the "cal_loaded" signal when the response from the server is
- * received.
- *
- * Return value: TRUE on success, FALSE on failure to issue the load request.
- **/
-gboolean
-cal_client_load_calendar (CalClient *client, const char *str_uri)
-{
- CalClientPrivate *priv;
- Evolution_Calendar_Listener corba_listener;
- CORBA_Environment ev;
-
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == LOAD_STATE_NOT_LOADED, FALSE);
-
- g_return_val_if_fail (str_uri != NULL, FALSE);
-
- priv->listener = cal_listener_new ();
- if (!priv->listener) {
- g_message ("cal_client_load_calendar(): could not create the listener");
- return FALSE;
- }
-
- gtk_signal_connect (GTK_OBJECT (priv->listener), "cal_loaded",
- GTK_SIGNAL_FUNC (cal_loaded_cb),
- client);
- gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_added",
- GTK_SIGNAL_FUNC (obj_added_cb),
- client);
- gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_removed",
- GTK_SIGNAL_FUNC (obj_removed_cb),
- client);
- gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_changed",
- GTK_SIGNAL_FUNC (obj_changed_cb),
- client);
-
- corba_listener = (Evolution_Calendar_Listener) bonobo_object_corba_objref (
- BONOBO_OBJECT (priv->listener));
-
- CORBA_exception_init (&ev);
-
- priv->load_state = LOAD_STATE_LOADING;
- Evolution_Calendar_CalFactory_load (priv->factory, str_uri, corba_listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_client_load_calendar(): load request failed");
- gtk_object_unref (GTK_OBJECT (priv->listener));
- priv->listener = NULL;
- priv->load_state = LOAD_STATE_NOT_LOADED;
- CORBA_exception_free (&ev);
- return FALSE;
- }
- CORBA_exception_free (&ev);
-
- return TRUE;
-}
-
-/**
- * cal_client_get_object:
- * @client: A calendar client.
- * @uid: Unique identifier for a calendar object.
- *
- * Queries a calendar for a calendar object based on its unique identifier.
- *
- * Return value: The string representation of a complete calendar wrapping the
- * sought object, or NULL if no object had the specified UID. A complete
- * calendar is returned because you also need the timezone data.
- **/
-char *
-cal_client_get_object (CalClient *client, const char *uid)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- Evolution_Calendar_CalObj calobj;
- char *retval;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL);
-
- g_return_val_if_fail (uid != NULL, NULL);
-
- retval = NULL;
-
- CORBA_exception_init (&ev);
- calobj = Evolution_Calendar_Cal_get_object (priv->cal, uid, &ev);
-
- if (ev._major == CORBA_USER_EXCEPTION
- && strcmp (CORBA_exception_id (&ev), ex_Evolution_Calendar_Cal_NotFound) == 0)
- goto out;
- else if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_client_get_object(): could not get the object");
- goto out;
- }
-
- retval = g_strdup (calobj);
-
- out:
- CORBA_exception_free (&ev);
- return retval;
-}
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
deleted file mode 100644
index 2f9ae5e1f8..0000000000
--- a/calendar/cal-client/cal-client.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Evolution calendar client
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CAL_CLIENT_H
-#define CAL_CLIENT_H
-
-#include <libgnome/gnome-defs.h>
-#include <gtk/gtkobject.h>
-
-BEGIN_GNOME_DECLS
-
-
-
-#define CAL_CLIENT_TYPE (cal_client_get_type ())
-#define CAL_CLIENT(obj) (GTK_CHECK_CAST ((obj), CAL_CLIENT_TYPE, CalClient))
-#define CAL_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_CLIENT_TYPE, CalClientClass))
-#define IS_CAL_CLIENT(obj) (GTK_CHECK_TYPE ((obj), CAL_CLIENT_TYPE))
-#define IS_CAL_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_CLIENT_TYPE))
-
-typedef struct _CalClient CalClient;
-typedef struct _CalClientClass CalClientClass;
-
-/* Load status for the cal_loaded signal */
-typedef enum {
- CAL_CLIENT_LOAD_SUCCESS,
- CAL_CLIENT_LOAD_ERROR
-} CalClientLoadStatus;
-
-struct _CalClient {
- GtkObject object;
-
- /* Private data */
- gpointer priv;
-};
-
-struct _CalClientClass {
- GtkObjectClass parent_class;
-
- /* Notification signals */
-
- void (* cal_loaded) (CalClient *client, CalClientLoadStatus status);
-
- void (* obj_added) (CalClient *client, const char *uid);
- void (* obj_removed) (CalClient *client, const char *uid);
- void (* obj_changed) (CalClient *client, const char *uid);
-};
-
-GtkType cal_client_get_type (void);
-
-CalClient *cal_client_construct (CalClient *client);
-
-CalClient *cal_client_new (void);
-
-gboolean cal_client_load_calendar (CalClient *client, const char *str_uri);
-
-char *cal_client_get_object (CalClient *client, const char *uid);
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/cal-client/cal-listener.c b/calendar/cal-client/cal-listener.c
deleted file mode 100644
index fee7e96024..0000000000
--- a/calendar/cal-client/cal-listener.c
+++ /dev/null
@@ -1,439 +0,0 @@
-/* Evolution calendar listener
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include "cal-listener.h"
-
-
-
-/* Private part of the CalListener structure */
-typedef struct {
- /* The calendar this listener refers to */
- Evolution_Calendar_Cal cal;
-} CalListenerPrivate;
-
-
-
-/* Signal IDs */
-enum {
- CAL_LOADED,
- OBJ_ADDED,
- OBJ_REMOVED,
- OBJ_CHANGED,
- LAST_SIGNAL
-};
-
-static void cal_listener_class_init (CalListenerClass *class);
-static void cal_listener_init (CalListener *listener);
-static void cal_listener_destroy (GtkObject *object);
-
-static void marshal_cal_loaded (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args);
-
-static POA_Evolution_Calendar_Listener__vepv cal_listener_vepv;
-
-static guint cal_listener_signals[LAST_SIGNAL];
-
-static BonoboObjectClass *parent_class;
-
-
-
-/**
- * cal_listener_get_type:
- * @void:
- *
- * Registers the #CalListener class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the #CalListener class.
- **/
-GtkType
-cal_listener_get_type (void)
-{
- static GtkType cal_listener_type = 0;
-
- if (!cal_listener_type) {
- static const GtkTypeInfo cal_listener_info = {
- "CalListener",
- sizeof (CalListener),
- sizeof (CalListenerClass),
- (GtkClassInitFunc) cal_listener_class_init,
- (GtkObjectInitFunc) cal_listener_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- cal_listener_type = gtk_type_unique (bonobo_object_get_type (), &cal_listener_info);
- }
-
- return cal_listener_type;
-}
-
-/* CORBA class initialization function for the calendar listener */
-static void
-init_cal_listener_corba_class (void)
-{
- cal_listener_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
- cal_listener_vepv.Evolution_Calendar_Listener_epv = cal_listener_get_epv ();
-}
-
-/* Class initialization function for the calendar listener */
-static void
-cal_listener_class_init (CalListenerClass *class)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) class;
-
- parent_class = gtk_type_class (bonobo_object_get_type ());
-
- cal_listener_signals[CAL_LOADED] =
- gtk_signal_new ("cal_loaded",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalListenerClass, cal_loaded),
- marshal_cal_loaded,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_ENUM,
- GTK_TYPE_POINTER);
- cal_listener_signals[OBJ_ADDED] =
- gtk_signal_new ("obj_added",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalListenerClass, obj_added),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
- cal_listener_signals[OBJ_REMOVED] =
- gtk_signal_new ("obj_removed",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalListenerClass, obj_removed),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
- cal_listener_signals[OBJ_CHANGED] =
- gtk_signal_new ("obj_changed",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalListenerClass, obj_changed),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
-
- gtk_object_class_add_signals (object_class, cal_listener_signals, LAST_SIGNAL);
-
- object_class->destroy = cal_listener_destroy;
-
- init_cal_listener_corba_class ();
-}
-
-/* Object initialization function for the calendar listener */
-static void
-cal_listener_init (CalListener *listener)
-{
- CalListenerPrivate *priv;
-
- priv = g_new0 (CalListenerPrivate, 1);
- listener->priv = priv;
-
- priv->cal = CORBA_OBJECT_NIL;
-}
-
-/* Destroy handler for the calendar listener */
-static void
-cal_listener_destroy (GtkObject *object)
-{
- CalListener *listener;
- CalListenerPrivate *priv;
- CORBA_Environment ev;
- gboolean result;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL_LISTENER (object));
-
- listener = CAL_LISTENER (object);
- priv = listener->priv;
-
- CORBA_exception_init (&ev);
- result = CORBA_Object_is_nil (priv->cal, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("cal_listener_destroy(): could not see if the calendar was NIL");
- else if (!result) {
- CORBA_exception_free (&ev);
-
- CORBA_exception_init (&ev);
- CORBA_Object_release (priv->cal, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("cal_listener_destroy(): could not release the calendar");
- }
- CORBA_exception_free (&ev);
-
- g_free (priv);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-
-
-/* Marshalers */
-
-typedef void (* CalLoadedFunc) (GtkObject *object, gint status, gpointer cal, gpointer data);
-
-static void
-marshal_cal_loaded (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args)
-{
- CalLoadedFunc rfunc;
-
- rfunc = (CalLoadedFunc) func;
- (* rfunc) (object, GTK_VALUE_ENUM (args[0]), GTK_VALUE_POINTER (args[1]), data);
-}
-
-
-
-/* CORBA servant implementation */
-
-/* Listener::cal_loaded method */
-static void
-Listener_cal_loaded (PortableServer_Servant servant,
- Evolution_Calendar_Listener_LoadStatus status,
- Evolution_Calendar_Cal cal,
- CORBA_Environment *ev)
-{
- CalListener *listener;
- CalListenerPrivate *priv;
- CORBA_Environment aev;
- Evolution_Calendar_Cal cal_copy;
- CalListenerLoadStatus load_status;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- priv = listener->priv;
-
- if (priv->cal != CORBA_OBJECT_NIL) {
- g_message ("Listener_cal_loaded(): calendar was already loaded!");
- return;
- }
-
- CORBA_exception_init (&aev);
- cal_copy = CORBA_Object_duplicate (cal, &aev);
-
- if (aev._major != CORBA_NO_EXCEPTION) {
- g_message ("Listener_cal_loaded(): could not duplicate the calendar");
- CORBA_exception_free (&aev);
- return;
- }
- CORBA_exception_free (&aev);
-
- priv->cal = cal_copy;
-
- switch (status) {
- case Evolution_Calendar_Listener_SUCCESS:
- load_status = CAL_LISTENER_LOAD_SUCCESS;
- break;
-
- case Evolution_Calendar_Listener_ERROR:
- load_status = CAL_LISTENER_LOAD_ERROR;
- break;
-
- default:
- load_status = CAL_LISTENER_LOAD_ERROR; /* keep gcc happy */
- g_assert_not_reached ();
- }
-
- gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[CAL_LOADED],
- load_status, cal);
-}
-
-/* Listener::obj_added method */
-static void
-Listener_obj_added (PortableServer_Servant servant,
- Evolution_Calendar_CalObjUID uid,
- CORBA_Environment *ev)
-{
- CalListener *listener;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_ADDED],
- uid);
-}
-
-/* Listener::obj_removed method */
-static void
-Listener_obj_removed (PortableServer_Servant servant,
- Evolution_Calendar_CalObjUID uid,
- CORBA_Environment *ev)
-{
- CalListener *listener;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_REMOVED],
- uid);
-}
-
-/* Listener::obj_changed method */
-static void
-Listener_obj_changed (PortableServer_Servant servant,
- Evolution_Calendar_CalObjUID uid,
- CORBA_Environment *ev)
-{
- CalListener *listener;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_CHANGED],
- uid);
-}
-
-/**
- * cal_listener_get_epv:
- * @void:
- *
- * Creates an EPV for the Listener CORBA class.
- *
- * Return value: A newly-allocated EPV.
- **/
-POA_Evolution_Calendar_Listener__epv *
-cal_listener_get_epv (void)
-{
- POA_Evolution_Calendar_Listener__epv *epv;
-
- epv = g_new0 (POA_Evolution_Calendar_Listener__epv, 1);
- epv->cal_loaded = Listener_cal_loaded;
- epv->obj_added = Listener_obj_added;
- epv->obj_removed = Listener_obj_removed;
- epv->obj_changed = Listener_obj_changed;
-
- return epv;
-}
-
-
-
-/**
- * cal_listener_construct:
- * @listener: A calendar listener.
- * @corba_listener: CORBA object for the calendar listener.
- *
- * Constructs a calendar listener by binding the corresponding CORBA object to
- * it.
- *
- * Return value: the same object as the @listener argument.
- **/
-CalListener *
-cal_listener_construct (CalListener *listener, Evolution_Calendar_Listener corba_listener)
-{
- g_return_val_if_fail (listener != NULL, NULL);
- g_return_val_if_fail (IS_CAL_LISTENER (listener), NULL);
-
- bonobo_object_construct (BONOBO_OBJECT (listener), corba_listener);
- return listener;
-}
-
-/**
- * cal_listener_corba_object_create:
- * @object: #BonoboObject that will wrap the CORBA object.
- *
- * Creates and activates the CORBA object that is wrapped by the specified
- * calendar listener @object.
- *
- * Return value: An activated object reference or #CORBA_OBJECT_NIL in case of
- * failure.
- **/
-Evolution_Calendar_Listener
-cal_listener_corba_object_create (BonoboObject *object)
-{
- POA_Evolution_Calendar_Listener *servant;
- CORBA_Environment ev;
-
- g_return_val_if_fail (object != NULL, CORBA_OBJECT_NIL);
- g_return_val_if_fail (IS_CAL_LISTENER (object), CORBA_OBJECT_NIL);
-
- servant = (POA_Evolution_Calendar_Listener *) g_new0 (BonoboObjectServant, 1);
- servant->vepv = &cal_listener_vepv;
-
- CORBA_exception_init (&ev);
- POA_Evolution_Calendar_Listener__init ((PortableServer_Servant) servant, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_free (servant);
- CORBA_exception_free (&ev);
- return CORBA_OBJECT_NIL;
- }
-
- CORBA_exception_free (&ev);
- return (Evolution_Calendar_Listener) bonobo_object_activate_servant (object, servant);
-}
-
-/**
- * cal_listener_new:
- * @void:
- *
- * Creates a new #CalListener object.
- *
- * Return value: A newly-created #CalListener, or NULL if its corresponding
- * CORBA object could not be created.
- **/
-CalListener *
-cal_listener_new (void)
-{
- CalListener *listener;
- CORBA_Environment ev;
- Evolution_Calendar_Listener corba_listener;
- gboolean result;
-
- listener = gtk_type_new (CAL_LISTENER_TYPE);
-
- corba_listener = cal_listener_corba_object_create (BONOBO_OBJECT (listener));
-
- CORBA_exception_init (&ev);
- result = CORBA_Object_is_nil (corba_listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION || result) {
- g_message ("cal_listener_new(): could not create the CORBA listener");
- gtk_object_unref (GTK_OBJECT (listener));
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- return cal_listener_construct (listener, corba_listener);
-}
-
-/**
- * cal_listener_get_calendar:
- * @listener: A calendar listener.
- *
- * Queries the calendar that a listener is watching.
- *
- * Return value: The calendar that the listener is watching.
- **/
-Evolution_Calendar_Cal
-cal_listener_get_calendar (CalListener *listener)
-{
- CalListenerPrivate *priv;
-
- g_return_val_if_fail (listener != NULL, CORBA_OBJECT_NIL);
- g_return_val_if_fail (IS_CAL_LISTENER (listener), CORBA_OBJECT_NIL);
-
- priv = listener->priv;
- return priv->cal;
-}
diff --git a/calendar/cal-client/cal-listener.h b/calendar/cal-client/cal-listener.h
deleted file mode 100644
index 8988148f34..0000000000
--- a/calendar/cal-client/cal-listener.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Evolution calendar listener
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CAL_LISTENER_H
-#define CAL_LISTENER_H
-
-#include <libgnome/gnome-defs.h>
-#include <bonobo/bonobo-object.h>
-#include "evolution-calendar.h"
-
-BEGIN_GNOME_DECLS
-
-
-
-#define CAL_LISTENER_TYPE (cal_listener_get_type ())
-#define CAL_LISTENER(obj) (GTK_CHECK_CAST ((obj), CAL_LISTENER_TYPE, CalListener))
-#define CAL_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_LISTENER_TYPE, \
- CalListenerClass))
-#define IS_CAL_LISTENER(obj) (GTK_CHECK_TYPE ((obj), CAL_LISTENER_TYPE))
-#define IS_CAL_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_LISTENER_TYPE))
-
-typedef struct _CalListener CalListener;
-typedef struct _CalListenerClass CalListenerClass;
-
-/* Load status for the cal_loaded signal. We need better error reporting. */
-typedef enum {
- CAL_LISTENER_LOAD_SUCCESS,
- CAL_LISTENER_LOAD_ERROR
-} CalListenerLoadStatus;
-
-struct _CalListener {
- BonoboObject object;
-
- /* Private data */
- gpointer priv;
-};
-
-struct _CalListenerClass {
- BonoboObjectClass parent_class;
-
- /* Notification signals */
-
- void (* cal_loaded) (CalListener *listener,
- CalListenerLoadStatus status,
- Evolution_Calendar_Cal cal);
- void (* obj_added) (CalListener *listener, const Evolution_Calendar_CalObjUID uid);
- void (* obj_removed) (CalListener *listener, const Evolution_Calendar_CalObjUID uid);
- void (* obj_changed) (CalListener *listener, const Evolution_Calendar_CalObjUID uid);
-};
-
-GtkType cal_listener_get_type (void);
-
-CalListener *cal_listener_construct (CalListener *listener,
- Evolution_Calendar_Listener corba_listener);
-
-Evolution_Calendar_Listener cal_listener_corba_object_create (BonoboObject *object);
-
-CalListener *cal_listener_new (void);
-
-Evolution_Calendar_Cal cal_listener_get_calendar (CalListener *listener);
-
-POA_Evolution_Calendar_Listener__epv *cal_listener_get_epv (void);
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/cal-common.h b/calendar/cal-common.h
deleted file mode 100644
index e51ddf1bdd..0000000000
--- a/calendar/cal-common.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Evolution calendar server - common declarations
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CAL_COMMON_H
-#define CAL_COMMON_H
-
-#include <libgnome/gnome-defs.h>
-
-BEGIN_GNOME_DECLS
-
-
-
-typedef struct _CalBackend CalBackend;
-typedef struct _CalBackendClass CalBackendClass;
-
-typedef struct _Cal Cal;
-typedef struct _CalClass CalClass;
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/cal-factory.c b/calendar/cal-factory.c
deleted file mode 100644
index d5b79ef423..0000000000
--- a/calendar/cal-factory.c
+++ /dev/null
@@ -1,517 +0,0 @@
-/* Evolution calendar factory
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include "cal.h"
-#include "cal-backend.h"
-#include "cal-factory.h"
-#include "job.h"
-
-
-
-/* Private part of the CalFactory structure */
-typedef struct {
- /* Hash table from GnomeVFSURI structures to CalBackend objects */
- GHashTable *backends;
-} CalFactoryPrivate;
-
-
-
-static void cal_factory_class_init (CalFactoryClass *class);
-static void cal_factory_init (CalFactory *factory);
-static void cal_factory_destroy (GtkObject *object);
-
-static POA_Evolution_Calendar_CalFactory__vepv cal_factory_vepv;
-
-static BonoboObjectClass *parent_class;
-
-
-
-/**
- * cal_factory_get_type:
- * @void:
- *
- * Registers the #CalFactory class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the #CalFactory class.
- **/
-GtkType
-cal_factory_get_type (void)
-{
- static GtkType cal_factory_type = 0;
-
- if (!cal_factory_type) {
- static const GtkTypeInfo cal_factory_info = {
- "CalFactory",
- sizeof (CalFactory),
- sizeof (CalFactoryClass),
- (GtkClassInitFunc) cal_factory_class_init,
- (GtkObjectInitFunc) cal_factory_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- cal_factory_type = gtk_type_unique (bonobo_object_get_type (), &cal_factory_info);
- }
-
- return cal_factory_type;
-}
-
-/* CORBA class initialization function for the calendar factory */
-static void
-init_cal_factory_corba_class (void)
-{
- cal_factory_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
- cal_factory_vepv.Evolution_Calendar_CalFactory_epv = cal_factory_get_epv ();
-}
-
-/* Class initialization function for the calendar factory */
-static void
-cal_factory_class_init (CalFactoryClass *class)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) class;
-
- parent_class = gtk_type_class (bonobo_object_get_type ());
-
- object_class->destroy = cal_factory_destroy;
-
- init_cal_factory_corba_class ();
-}
-
-/* Object initialization function for the calendar factory */
-static void
-cal_factory_init (CalFactory *factory)
-{
- CalFactoryPrivate *priv;
-
- priv = g_new0 (CalFactoryPrivate, 1);
- factory->priv = priv;
-
- priv->backends = g_hash_table_new (gnome_vfs_uri_hash, gnome_vfs_uri_hequal);
-}
-
-/* Frees a uri/backend pair from the backends hash table */
-static void
-free_backend (gpointer key, gpointer value, gpointer data)
-{
- GnomeVFSURI *uri;
- CalBackend *backend;
-
- uri = key;
- backend = value;
-
- gnome_vfs_uri_unref (uri);
- gtk_object_unref (GTK_OBJECT (backend));
-}
-
-/* Destroy handler for the calendar */
-static void
-cal_factory_destroy (GtkObject *object)
-{
- CalFactory *factory;
- CalFactoryPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL_FACTORY (object));
-
- factory = CAL_FACTORY (object);
- priv = factory->priv;
-
- g_hash_table_foreach (priv->backends, free_backend, NULL);
- g_hash_table_destroy (priv->backends);
- priv->backends = NULL;
-
- g_free (priv);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-
-
-/* CORBA servant implementation */
-
-/* CalFactory::load method */
-static void
-CalFactory_load (PortableServer_Servant servant,
- const CORBA_char *uri,
- Evolution_Calendar_Listener listener,
- CORBA_Environment *ev)
-{
- CalFactory *factory;
- CalFactoryPrivate *priv;
- CORBA_Environment ev2;
- gboolean result;
-
- factory = CAL_FACTORY (bonobo_object_from_servant (servant));
- priv = factory->priv;
-
- CORBA_exception_init (&ev2);
- result = CORBA_Object_is_nil (listener, &ev2);
-
- if (ev2._major != CORBA_NO_EXCEPTION || result) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_Evolution_Calendar_CalFactory_NilListener,
- NULL);
-
- CORBA_exception_free (&ev2);
- return;
- }
- CORBA_exception_free (&ev2);
-
- cal_factory_load (factory, uri, listener);
-}
-
-/* CalFactory::create method */
-static void
-CalFactory_create (PortableServer_Servant servant,
- const CORBA_char *uri,
- Evolution_Calendar_Listener listener,
- CORBA_Environment *ev)
-{
- CalFactory *factory;
- CalFactoryPrivate *priv;
-
- factory = CAL_FACTORY (bonobo_object_from_servant (servant));
- priv = factory->priv;
-
- cal_factory_create (factory, uri, listener);
-}
-
-/**
- * cal_factory_get_epv:
- * @void:
- *
- * Creates an EPV for the CalFactory CORBA class.
- *
- * Return value: A newly-allocated EPV.
- **/
-POA_Evolution_Calendar_CalFactory__epv *
-cal_factory_get_epv (void)
-{
- POA_Evolution_Calendar_CalFactory__epv *epv;
-
- epv = g_new0 (POA_Evolution_Calendar_CalFactory__epv, 1);
- epv->load = CalFactory_load;
- epv->create = CalFactory_create;
-
- return epv;
-}
-
-
-
-/* Loading and creating calendars */
-
-/* Job data */
-typedef struct {
- CalFactory *factory;
- char *uri;
- Evolution_Calendar_Listener listener;
-} LoadCreateJobData;
-
-/* Looks up a calendar backend in a factory's hash table of uri->cal */
-static CalBackend *
-lookup_backend (CalFactory *factory, GnomeVFSURI *uri)
-{
- CalFactoryPrivate *priv;
- CalBackend *backend;
-
- priv = factory->priv;
-
- backend = g_hash_table_lookup (priv->backends, uri);
- return backend;
-}
-
-/* Loads a calendar backend and puts it in the factory's backend hash table */
-static CalBackend *
-load_backend (CalFactory *factory, GnomeVFSURI *uri, Evolution_Calendar_Listener listener)
-{
- CalFactoryPrivate *priv;
- CalBackend *backend;
- CalBackendLoadStatus status;
-
- priv = factory->priv;
-
- backend = cal_backend_new ();
- if (!backend) {
- g_message ("load_backend(): could not create the backend");
- return NULL;
- }
-
- status = cal_backend_load (backend, uri);
-
- switch (status) {
- case CAL_BACKEND_LOAD_SUCCESS:
- gnome_vfs_uri_ref (uri);
- g_hash_table_insert (priv->backends, uri, backend);
-
- return backend;
-
- case CAL_BACKEND_LOAD_ERROR:
- gtk_object_unref (GTK_OBJECT (backend));
- return NULL;
-
- default:
- g_assert_not_reached ();
- return NULL;
- }
-}
-
-/* Adds a listener to a calendar backend by creating a calendar client interface
- * object.
- */
-static void
-add_calendar_client (CalFactory *factory, CalBackend *backend, Evolution_Calendar_Listener listener)
-{
- Cal *cal;
- CORBA_Environment ev;
-
- cal = cal_new (backend, listener);
- if (!cal) {
- g_message ("add_calendar_client(): could not create the calendar client interface");
-
- CORBA_exception_init (&ev);
- Evolution_Calendar_Listener_cal_loaded (listener,
- Evolution_Calendar_Listener_ERROR,
- CORBA_OBJECT_NIL,
- &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("add_calendar_client(): could not notify the listener");
-
- CORBA_exception_free (&ev);
- return;
- }
-
- cal_backend_add_cal (backend, cal);
-
- CORBA_exception_init (&ev);
- Evolution_Calendar_Listener_cal_loaded (listener,
- Evolution_Calendar_Listener_SUCCESS,
- bonobo_object_corba_objref (BONOBO_OBJECT (cal)),
- &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("add_calendar_client(): could not notify the listener");
- cal_backend_remove_cal (backend, cal);
- }
-
- gtk_object_unref (GTK_OBJECT (cal));
-}
-
-/* Job handler for the load calendar command */
-static void
-load_fn (gpointer data)
-{
- LoadCreateJobData *jd;
- CalFactory *factory;
- GnomeVFSURI *uri;
- Evolution_Calendar_Listener listener;
- CalBackend *backend;
- CORBA_Environment ev;
-
- jd = data;
-
- /* Look up the calendar */
-
- uri = gnome_vfs_uri_new (jd->uri);
- g_free (jd->uri);
-
- factory = jd->factory;
- listener = jd->listener;
- g_free (jd);
-
- backend = lookup_backend (factory, uri);
-
- if (!backend)
- backend = load_backend (factory, uri, listener);
-
- gnome_vfs_uri_unref (uri);
-
- if (!backend) {
- g_message ("load_fn(): could not load the backend");
- CORBA_exception_init (&ev);
- Evolution_Calendar_Listener_cal_loaded (listener,
- Evolution_Calendar_Listener_ERROR,
- CORBA_OBJECT_NIL,
- &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("load_fn(): could not notify the listener");
-
- CORBA_exception_free (&ev);
- goto out;
- }
-
- add_calendar_client (factory, backend, listener);
-
- out:
-
- CORBA_exception_init (&ev);
- CORBA_Object_release (listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("load_fn(): could not release the listener");
-
- CORBA_exception_free (&ev);
-}
-
-
-
-/**
- * cal_factory_construct:
- * @factory: A calendar factory.
- * @corba_factory: CORBA object for the calendar factory.
- *
- * Constructs a calendar factory by binding the corresponding CORBA object to
- * it.
- *
- * Return value: The same object as the @factory argument.
- **/
-CalFactory *
-cal_factory_construct (CalFactory *factory, Evolution_Calendar_CalFactory corba_factory)
-{
- g_return_val_if_fail (factory != NULL, NULL);
- g_return_val_if_fail (IS_CAL_FACTORY (factory), NULL);
-
- bonobo_object_construct (BONOBO_OBJECT (factory), corba_factory);
- return factory;
-}
-
-/**
- * cal_factory_corba_object_create:
- * @object: #BonoboObject that will wrap the CORBA object.
- *
- * Creates and activates the CORBA object that is wrapped by the specified
- * calendar factory @object.
- *
- * Return value: An activated object reference or #CORBA_OBJECT_NIL in case of
- * failure.
- **/
-Evolution_Calendar_CalFactory
-cal_factory_corba_object_create (BonoboObject *object)
-{
- POA_Evolution_Calendar_CalFactory *servant;
- CORBA_Environment ev;
-
- g_return_val_if_fail (object != NULL, CORBA_OBJECT_NIL);
- g_return_val_if_fail (IS_CAL_FACTORY (object), CORBA_OBJECT_NIL);
-
- servant = (POA_Evolution_Calendar_CalFactory *) g_new0 (BonoboObjectServant, 1);
- servant->vepv = &cal_factory_vepv;
-
- CORBA_exception_init (&ev);
- POA_Evolution_Calendar_CalFactory__init ((PortableServer_Servant) servant, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_factory_corba_object_create(): could not init the servant");
- g_free (servant);
- CORBA_exception_free (&ev);
- return CORBA_OBJECT_NIL;
- }
-
- CORBA_exception_free (&ev);
- return (Evolution_Calendar_CalFactory) bonobo_object_activate_servant (object, servant);
-}
-
-/**
- * cal_factory_new:
- * @void:
- *
- * Creates a new #CalFactory object.
- *
- * Return value: A newly-created #CalFactory, or NULL if its corresponding CORBA
- * object could not be created.
- **/
-CalFactory *
-cal_factory_new (void)
-{
- CalFactory *factory;
- CORBA_Environment ev;
- Evolution_Calendar_CalFactory corba_factory;
- gboolean retval;
-
- factory = gtk_type_new (CAL_FACTORY_TYPE);
-
- corba_factory = cal_factory_corba_object_create (BONOBO_OBJECT (factory));
-
- CORBA_exception_init (&ev);
- retval = CORBA_Object_is_nil (corba_factory, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION || retval) {
- g_message ("cal_factory_new(): could not create the CORBA factory");
- gtk_object_unref (GTK_OBJECT (factory));
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- return cal_factory_construct (factory, corba_factory);
-}
-
-void
-cal_factory_load (CalFactory *factory, const char *uri, Evolution_Calendar_Listener listener)
-{
- LoadCreateJobData *jd;
- CORBA_Environment ev;
- Evolution_Calendar_Listener listener_copy;
- gboolean result;
-
- CORBA_exception_init (&ev);
- result = CORBA_Object_is_nil (listener, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_factory_load(): could not see if the listener was NIL");
- CORBA_exception_free (&ev);
- return;
- }
- CORBA_exception_free (&ev);
-
- if (result) {
- g_message ("cal_factory_load(): cannot operate on a NIL listener!");
- return;
- }
-
- listener_copy = CORBA_Object_duplicate (listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_factory_load(): could not duplicate the listener");
- CORBA_exception_free (&ev);
- return;
- }
-
- CORBA_exception_free (&ev);
-
- jd = g_new (LoadCreateJobData, 1);
- jd->factory = factory;
- jd->uri = g_strdup (uri);
- jd->listener = listener_copy;
-
- job_add (load_fn, jd);
-}
-
-void
-cal_factory_create (CalFactory *factory, const char *uri, Evolution_Calendar_Listener listener)
-{
- /* FIXME */
-}
diff --git a/calendar/cal-factory.h b/calendar/cal-factory.h
deleted file mode 100644
index 9d5fd57e2c..0000000000
--- a/calendar/cal-factory.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Evolution calendar factory
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CAL_FACTORY_H
-#define CAL_FACTORY_H
-
-#include <libgnome/gnome-defs.h>
-#include <bonobo/bonobo-object.h>
-#include "evolution-calendar.h"
-
-BEGIN_GNOME_DECLS
-
-
-
-#define CAL_FACTORY_TYPE (cal_factory_get_type ())
-#define CAL_FACTORY(obj) (GTK_CHECK_CAST ((obj), CAL_FACTORY_TYPE, CalFactory))
-#define CAL_FACTORY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_FACTORY_TYPE, \
- CalFactoryClass))
-#define IS_CAL_FACTORY(obj) (GTK_CHECK_TYPE ((obj), CAL_FACTORY_TYPE))
-#define IS_CAL_FACTORY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_FACTORY_TYPE))
-
-typedef struct _CalFactory CalFactory;
-typedef struct _CalFactoryClass CalFactoryClass;
-
-struct _CalFactory {
- BonoboObject object;
-
- /* Private data */
- gpointer priv;
-};
-
-struct _CalFactoryClass {
- BonoboObjectClass parent_class;
-};
-
-GtkType cal_factory_get_type (void);
-
-CalFactory *cal_factory_construct (CalFactory *factory, Evolution_Calendar_CalFactory corba_factory);
-Evolution_Calendar_CalFactory cal_factory_corba_object_create (BonoboObject *object);
-
-CalFactory *cal_factory_new (void);
-
-void cal_factory_load (CalFactory *factory, const char *uri, Evolution_Calendar_Listener listener);
-void cal_factory_create (CalFactory *factory, const char *uri, Evolution_Calendar_Listener listener);
-
-POA_Evolution_Calendar_CalFactory__epv *cal_factory_get_epv (void);
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/cal-listener.c b/calendar/cal-listener.c
deleted file mode 100644
index fee7e96024..0000000000
--- a/calendar/cal-listener.c
+++ /dev/null
@@ -1,439 +0,0 @@
-/* Evolution calendar listener
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include "cal-listener.h"
-
-
-
-/* Private part of the CalListener structure */
-typedef struct {
- /* The calendar this listener refers to */
- Evolution_Calendar_Cal cal;
-} CalListenerPrivate;
-
-
-
-/* Signal IDs */
-enum {
- CAL_LOADED,
- OBJ_ADDED,
- OBJ_REMOVED,
- OBJ_CHANGED,
- LAST_SIGNAL
-};
-
-static void cal_listener_class_init (CalListenerClass *class);
-static void cal_listener_init (CalListener *listener);
-static void cal_listener_destroy (GtkObject *object);
-
-static void marshal_cal_loaded (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args);
-
-static POA_Evolution_Calendar_Listener__vepv cal_listener_vepv;
-
-static guint cal_listener_signals[LAST_SIGNAL];
-
-static BonoboObjectClass *parent_class;
-
-
-
-/**
- * cal_listener_get_type:
- * @void:
- *
- * Registers the #CalListener class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the #CalListener class.
- **/
-GtkType
-cal_listener_get_type (void)
-{
- static GtkType cal_listener_type = 0;
-
- if (!cal_listener_type) {
- static const GtkTypeInfo cal_listener_info = {
- "CalListener",
- sizeof (CalListener),
- sizeof (CalListenerClass),
- (GtkClassInitFunc) cal_listener_class_init,
- (GtkObjectInitFunc) cal_listener_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- cal_listener_type = gtk_type_unique (bonobo_object_get_type (), &cal_listener_info);
- }
-
- return cal_listener_type;
-}
-
-/* CORBA class initialization function for the calendar listener */
-static void
-init_cal_listener_corba_class (void)
-{
- cal_listener_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
- cal_listener_vepv.Evolution_Calendar_Listener_epv = cal_listener_get_epv ();
-}
-
-/* Class initialization function for the calendar listener */
-static void
-cal_listener_class_init (CalListenerClass *class)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) class;
-
- parent_class = gtk_type_class (bonobo_object_get_type ());
-
- cal_listener_signals[CAL_LOADED] =
- gtk_signal_new ("cal_loaded",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalListenerClass, cal_loaded),
- marshal_cal_loaded,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_ENUM,
- GTK_TYPE_POINTER);
- cal_listener_signals[OBJ_ADDED] =
- gtk_signal_new ("obj_added",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalListenerClass, obj_added),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
- cal_listener_signals[OBJ_REMOVED] =
- gtk_signal_new ("obj_removed",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalListenerClass, obj_removed),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
- cal_listener_signals[OBJ_CHANGED] =
- gtk_signal_new ("obj_changed",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalListenerClass, obj_changed),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
-
- gtk_object_class_add_signals (object_class, cal_listener_signals, LAST_SIGNAL);
-
- object_class->destroy = cal_listener_destroy;
-
- init_cal_listener_corba_class ();
-}
-
-/* Object initialization function for the calendar listener */
-static void
-cal_listener_init (CalListener *listener)
-{
- CalListenerPrivate *priv;
-
- priv = g_new0 (CalListenerPrivate, 1);
- listener->priv = priv;
-
- priv->cal = CORBA_OBJECT_NIL;
-}
-
-/* Destroy handler for the calendar listener */
-static void
-cal_listener_destroy (GtkObject *object)
-{
- CalListener *listener;
- CalListenerPrivate *priv;
- CORBA_Environment ev;
- gboolean result;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL_LISTENER (object));
-
- listener = CAL_LISTENER (object);
- priv = listener->priv;
-
- CORBA_exception_init (&ev);
- result = CORBA_Object_is_nil (priv->cal, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("cal_listener_destroy(): could not see if the calendar was NIL");
- else if (!result) {
- CORBA_exception_free (&ev);
-
- CORBA_exception_init (&ev);
- CORBA_Object_release (priv->cal, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("cal_listener_destroy(): could not release the calendar");
- }
- CORBA_exception_free (&ev);
-
- g_free (priv);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-
-
-/* Marshalers */
-
-typedef void (* CalLoadedFunc) (GtkObject *object, gint status, gpointer cal, gpointer data);
-
-static void
-marshal_cal_loaded (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args)
-{
- CalLoadedFunc rfunc;
-
- rfunc = (CalLoadedFunc) func;
- (* rfunc) (object, GTK_VALUE_ENUM (args[0]), GTK_VALUE_POINTER (args[1]), data);
-}
-
-
-
-/* CORBA servant implementation */
-
-/* Listener::cal_loaded method */
-static void
-Listener_cal_loaded (PortableServer_Servant servant,
- Evolution_Calendar_Listener_LoadStatus status,
- Evolution_Calendar_Cal cal,
- CORBA_Environment *ev)
-{
- CalListener *listener;
- CalListenerPrivate *priv;
- CORBA_Environment aev;
- Evolution_Calendar_Cal cal_copy;
- CalListenerLoadStatus load_status;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- priv = listener->priv;
-
- if (priv->cal != CORBA_OBJECT_NIL) {
- g_message ("Listener_cal_loaded(): calendar was already loaded!");
- return;
- }
-
- CORBA_exception_init (&aev);
- cal_copy = CORBA_Object_duplicate (cal, &aev);
-
- if (aev._major != CORBA_NO_EXCEPTION) {
- g_message ("Listener_cal_loaded(): could not duplicate the calendar");
- CORBA_exception_free (&aev);
- return;
- }
- CORBA_exception_free (&aev);
-
- priv->cal = cal_copy;
-
- switch (status) {
- case Evolution_Calendar_Listener_SUCCESS:
- load_status = CAL_LISTENER_LOAD_SUCCESS;
- break;
-
- case Evolution_Calendar_Listener_ERROR:
- load_status = CAL_LISTENER_LOAD_ERROR;
- break;
-
- default:
- load_status = CAL_LISTENER_LOAD_ERROR; /* keep gcc happy */
- g_assert_not_reached ();
- }
-
- gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[CAL_LOADED],
- load_status, cal);
-}
-
-/* Listener::obj_added method */
-static void
-Listener_obj_added (PortableServer_Servant servant,
- Evolution_Calendar_CalObjUID uid,
- CORBA_Environment *ev)
-{
- CalListener *listener;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_ADDED],
- uid);
-}
-
-/* Listener::obj_removed method */
-static void
-Listener_obj_removed (PortableServer_Servant servant,
- Evolution_Calendar_CalObjUID uid,
- CORBA_Environment *ev)
-{
- CalListener *listener;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_REMOVED],
- uid);
-}
-
-/* Listener::obj_changed method */
-static void
-Listener_obj_changed (PortableServer_Servant servant,
- Evolution_Calendar_CalObjUID uid,
- CORBA_Environment *ev)
-{
- CalListener *listener;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_CHANGED],
- uid);
-}
-
-/**
- * cal_listener_get_epv:
- * @void:
- *
- * Creates an EPV for the Listener CORBA class.
- *
- * Return value: A newly-allocated EPV.
- **/
-POA_Evolution_Calendar_Listener__epv *
-cal_listener_get_epv (void)
-{
- POA_Evolution_Calendar_Listener__epv *epv;
-
- epv = g_new0 (POA_Evolution_Calendar_Listener__epv, 1);
- epv->cal_loaded = Listener_cal_loaded;
- epv->obj_added = Listener_obj_added;
- epv->obj_removed = Listener_obj_removed;
- epv->obj_changed = Listener_obj_changed;
-
- return epv;
-}
-
-
-
-/**
- * cal_listener_construct:
- * @listener: A calendar listener.
- * @corba_listener: CORBA object for the calendar listener.
- *
- * Constructs a calendar listener by binding the corresponding CORBA object to
- * it.
- *
- * Return value: the same object as the @listener argument.
- **/
-CalListener *
-cal_listener_construct (CalListener *listener, Evolution_Calendar_Listener corba_listener)
-{
- g_return_val_if_fail (listener != NULL, NULL);
- g_return_val_if_fail (IS_CAL_LISTENER (listener), NULL);
-
- bonobo_object_construct (BONOBO_OBJECT (listener), corba_listener);
- return listener;
-}
-
-/**
- * cal_listener_corba_object_create:
- * @object: #BonoboObject that will wrap the CORBA object.
- *
- * Creates and activates the CORBA object that is wrapped by the specified
- * calendar listener @object.
- *
- * Return value: An activated object reference or #CORBA_OBJECT_NIL in case of
- * failure.
- **/
-Evolution_Calendar_Listener
-cal_listener_corba_object_create (BonoboObject *object)
-{
- POA_Evolution_Calendar_Listener *servant;
- CORBA_Environment ev;
-
- g_return_val_if_fail (object != NULL, CORBA_OBJECT_NIL);
- g_return_val_if_fail (IS_CAL_LISTENER (object), CORBA_OBJECT_NIL);
-
- servant = (POA_Evolution_Calendar_Listener *) g_new0 (BonoboObjectServant, 1);
- servant->vepv = &cal_listener_vepv;
-
- CORBA_exception_init (&ev);
- POA_Evolution_Calendar_Listener__init ((PortableServer_Servant) servant, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_free (servant);
- CORBA_exception_free (&ev);
- return CORBA_OBJECT_NIL;
- }
-
- CORBA_exception_free (&ev);
- return (Evolution_Calendar_Listener) bonobo_object_activate_servant (object, servant);
-}
-
-/**
- * cal_listener_new:
- * @void:
- *
- * Creates a new #CalListener object.
- *
- * Return value: A newly-created #CalListener, or NULL if its corresponding
- * CORBA object could not be created.
- **/
-CalListener *
-cal_listener_new (void)
-{
- CalListener *listener;
- CORBA_Environment ev;
- Evolution_Calendar_Listener corba_listener;
- gboolean result;
-
- listener = gtk_type_new (CAL_LISTENER_TYPE);
-
- corba_listener = cal_listener_corba_object_create (BONOBO_OBJECT (listener));
-
- CORBA_exception_init (&ev);
- result = CORBA_Object_is_nil (corba_listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION || result) {
- g_message ("cal_listener_new(): could not create the CORBA listener");
- gtk_object_unref (GTK_OBJECT (listener));
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- return cal_listener_construct (listener, corba_listener);
-}
-
-/**
- * cal_listener_get_calendar:
- * @listener: A calendar listener.
- *
- * Queries the calendar that a listener is watching.
- *
- * Return value: The calendar that the listener is watching.
- **/
-Evolution_Calendar_Cal
-cal_listener_get_calendar (CalListener *listener)
-{
- CalListenerPrivate *priv;
-
- g_return_val_if_fail (listener != NULL, CORBA_OBJECT_NIL);
- g_return_val_if_fail (IS_CAL_LISTENER (listener), CORBA_OBJECT_NIL);
-
- priv = listener->priv;
- return priv->cal;
-}
diff --git a/calendar/cal-listener.h b/calendar/cal-listener.h
deleted file mode 100644
index 8988148f34..0000000000
--- a/calendar/cal-listener.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Evolution calendar listener
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CAL_LISTENER_H
-#define CAL_LISTENER_H
-
-#include <libgnome/gnome-defs.h>
-#include <bonobo/bonobo-object.h>
-#include "evolution-calendar.h"
-
-BEGIN_GNOME_DECLS
-
-
-
-#define CAL_LISTENER_TYPE (cal_listener_get_type ())
-#define CAL_LISTENER(obj) (GTK_CHECK_CAST ((obj), CAL_LISTENER_TYPE, CalListener))
-#define CAL_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_LISTENER_TYPE, \
- CalListenerClass))
-#define IS_CAL_LISTENER(obj) (GTK_CHECK_TYPE ((obj), CAL_LISTENER_TYPE))
-#define IS_CAL_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_LISTENER_TYPE))
-
-typedef struct _CalListener CalListener;
-typedef struct _CalListenerClass CalListenerClass;
-
-/* Load status for the cal_loaded signal. We need better error reporting. */
-typedef enum {
- CAL_LISTENER_LOAD_SUCCESS,
- CAL_LISTENER_LOAD_ERROR
-} CalListenerLoadStatus;
-
-struct _CalListener {
- BonoboObject object;
-
- /* Private data */
- gpointer priv;
-};
-
-struct _CalListenerClass {
- BonoboObjectClass parent_class;
-
- /* Notification signals */
-
- void (* cal_loaded) (CalListener *listener,
- CalListenerLoadStatus status,
- Evolution_Calendar_Cal cal);
- void (* obj_added) (CalListener *listener, const Evolution_Calendar_CalObjUID uid);
- void (* obj_removed) (CalListener *listener, const Evolution_Calendar_CalObjUID uid);
- void (* obj_changed) (CalListener *listener, const Evolution_Calendar_CalObjUID uid);
-};
-
-GtkType cal_listener_get_type (void);
-
-CalListener *cal_listener_construct (CalListener *listener,
- Evolution_Calendar_Listener corba_listener);
-
-Evolution_Calendar_Listener cal_listener_corba_object_create (BonoboObject *object);
-
-CalListener *cal_listener_new (void);
-
-Evolution_Calendar_Cal cal_listener_get_calendar (CalListener *listener);
-
-POA_Evolution_Calendar_Listener__epv *cal_listener_get_epv (void);
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c
deleted file mode 100644
index f3004ddb13..0000000000
--- a/calendar/cal-util/calobj.c
+++ /dev/null
@@ -1,1490 +0,0 @@
-/*
- * Calendar objects implementations.
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org)
- */
-#include <config.h>
-#include <string.h>
-#include <glib.h>
-#include <ctype.h>
-#include <unistd.h>
-#include "calobj.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
-
-extern CalendarAlarm alarm_defaults[4];
-
-static char *
-ical_gen_uid (void)
-{
- static char *hostname;
- time_t t = time (NULL);
- static int serial;
-
- if (!hostname){
- char buffer [128];
-
- if ((gethostname (buffer, sizeof (buffer)-1) == 0) &&
- (buffer [0] != 0))
- hostname = g_strdup (buffer);
- else
- hostname = g_strdup ("localhost");
- }
-
- return g_strdup_printf (
- "%s-%d-%d-%d-%d@%s",
- isodate_from_time_t (t),
- getpid (),
- getgid (),
- getppid (),
- serial++,
- hostname);
-}
-
-iCalObject *
-ical_object_new (void)
-{
- iCalObject *ico;
-
- ico = g_new0 (iCalObject, 1);
-
- ico->seq = -1;
- ico->dtstamp = time (NULL);
- ico->uid = ical_gen_uid ();
-
- ico->pilot_id = 0;
- ico->pilot_status = ICAL_PILOT_SYNC_MOD;
-
- return ico;
-}
-
-static void
-default_alarm (iCalObject *ical, CalendarAlarm *alarm, char *def_mail, enum AlarmType type)
-{
- alarm->type = type;
- alarm->enabled = alarm_defaults[type].enabled;
- alarm->count = alarm_defaults[type].count;
- alarm->units = alarm_defaults[type].units;
- if (alarm_defaults[type].data)
- alarm->data = g_strdup (alarm_defaults[type].data);
- else
- alarm->data = g_strdup ("");
-}
-
-iCalObject *
-ical_new (char *comment, char *organizer, char *summary)
-{
- iCalObject *ico;
-
- ico = ical_object_new ();
-
- ico->comment = g_strdup (comment);
- ico->organizer = g_strdup (organizer);
- ico->summary = g_strdup (summary);
- ico->class = g_strdup ("PUBLIC");
- ico->status = g_strdup ("NEEDS ACTION");
-
- default_alarm (ico, &ico->dalarm, organizer, ALARM_DISPLAY);
- default_alarm (ico, &ico->palarm, organizer, ALARM_PROGRAM);
- default_alarm (ico, &ico->malarm, organizer, ALARM_MAIL);
- default_alarm (ico, &ico->aalarm, organizer, ALARM_AUDIO);
-
- return ico;
-}
-
-static void
-my_free (gpointer data, gpointer user_dat_ignored)
-{
- g_free (data);
-}
-
-static void
-list_free (GList *list)
-{
- g_list_foreach (list, my_free, 0);
- g_list_free (list);
-}
-
-#define free_if_defined(x) if (x){ g_free (x); x = 0; }
-#define lfree_if_defined(x) if (x){ list_free (x); x = 0; }
-void
-ical_object_destroy (iCalObject *ico)
-{
- /* Regular strings */
- free_if_defined (ico->comment);
- free_if_defined (ico->organizer);
- free_if_defined (ico->summary);
- free_if_defined (ico->uid);
- free_if_defined (ico->status);
- free_if_defined (ico->class);
- free_if_defined (ico->url);
- free_if_defined (ico->recur);
-
- /* Lists */
- lfree_if_defined (ico->exdate);
- lfree_if_defined (ico->categories);
- lfree_if_defined (ico->resources);
- lfree_if_defined (ico->related);
- lfree_if_defined (ico->attach);
-
- /* Alarms */
- g_free (ico->dalarm.data);
- g_free (ico->palarm.data);
- g_free (ico->malarm.data);
- g_free (ico->aalarm.data);
-
- g_free (ico);
-}
-
-static GList *
-set_list (char *str)
-{
- GList *list = 0;
- char *s;
-
- for (s = strtok (str, ";"); s; s = strtok (NULL, ";"))
- list = g_list_prepend (list, g_strdup (s));
-
- return list;
-}
-
-static GList *
-set_date_list (char *str)
-{
- GList *list = 0;
- char *s;
-
- for (s = strtok (str, ";,"); s; s = strtok (NULL, ";,")){
- time_t *t = g_new (time_t, 1);
-
- while (*s && isspace (*s))
- s++;
- *t = time_from_isodate (s);
- list = g_list_prepend (list, t);
- }
- return list;
-}
-
-void
-ical_object_add_exdate (iCalObject *o, time_t t)
-{
- time_t *pt = g_new (time_t, 1);
-
- *pt = t;
- o->exdate = g_list_prepend (o->exdate, pt);
-}
-
-static void
-ignore_space(char **str)
-{
- while (**str && isspace (**str))
- (*str)++;
-}
-
-static void
-skip_numbers (char **str)
-{
- while (**str){
- ignore_space (str);
- if (!isdigit (**str))
- return;
- while (**str && isdigit (**str))
- (*str)++;
- }
-}
-
-static void
-weekdaylist (iCalObject *o, char **str)
-{
- int i;
- struct {
- char first_letter, second_letter;
- int index;
- } days [] = {
- { 'S', 'U', 0 },
- { 'M', 'O', 1 },
- { 'T', 'U', 2 },
- { 'W', 'E', 3 },
- { 'T', 'H', 4 },
- { 'F', 'R', 5 },
- { 'S', 'A', 6 }
- };
-
- ignore_space (str);
- do {
- for (i = 0; i < 7; i++){
- if (**str == days [i].first_letter && *(*str+1) == days [i].second_letter){
- o->recur->weekday |= 1 << i;
- *str += 2;
- if (**str == ' ')
- (*str)++;
- }
- }
- } while (isalpha (**str));
-
- if (o->recur->weekday == 0){
- struct tm tm = *localtime (&o->dtstart);
-
- o->recur->weekday = 1 << tm.tm_wday;
- }
-}
-
-static void
-weekdaynum (iCalObject *o, char **str)
-{
- int i;
- struct {
- char first_letter, second_letter;
- int index;
- } days [] = {
- { 'S', 'U', 0 },
- { 'M', 'O', 1 },
- { 'T', 'U', 2 },
- { 'W', 'E', 3 },
- { 'T', 'H', 4 },
- { 'F', 'R', 5 },
- { 'S', 'A', 6 }
- };
-
- ignore_space (str);
- do {
- for (i = 0; i < 7; i++){
- if (**str == days [i].first_letter && *(*str+1) == days [i].second_letter){
- o->recur->weekday = i;
- *str += 2;
- if (**str == ' ')
- (*str)++;
- }
- }
- } while (isalpha (**str));
-}
-
-static void
-ocurrencelist (iCalObject *o, char **str)
-{
- char *p;
-
- ignore_space (str);
- p = *str;
- if (!isdigit (*p))
- return;
-
- if (!(*p >= '1' && *p <= '5'))
- return;
-
- if (!(*(p+1) == '+' || *(p+1) == '-'))
- return;
-
- o->recur->u.month_pos = (*p-'0') * (*(p+1) == '+' ? 1 : -1);
- *str += 2;
-}
-
-static void
-daynumber (iCalObject *o, char **str)
-{
- int val = 0;
- char *p = *str;
-
- ignore_space (str);
- if (strcmp (p, "LD")){
- o->recur->u.month_day = DAY_LASTDAY;
- *str += 2;
- return;
- }
-
- if (!(isdigit (*p)))
- return;
-
- while (**str && isdigit (**str)){
- val = val * 10 + (**str - '0');
- (*str)++;
- }
-
- if (**str == '+')
- (*str)++;
-
- if (**str == '-')
- val *= -1;
- o->recur->u.month_day = val;
-}
-
-static void
-daynumberlist (iCalObject *o, char **str)
-{
- int first = 0;
- int val = 0;
-
- ignore_space (str);
-
- while (**str){
- if (!isdigit (**str))
- return;
- while (**str && isdigit (**str)){
- val = 10 * val + (**str - '0');
- (*str)++;
- }
- if (!first){
- /*
- * Some broken applications set this to zero
- */
- if (val == 0){
- struct tm day = *localtime (&o->dtstart);
-
- val = day.tm_mday;
- }
- o->recur->u.month_day = val;
- first = 1;
- val = 0;
- }
- }
-}
-
-static void
-load_recur_weekly (iCalObject *o, char **str)
-{
- weekdaylist (o, str);
-}
-
-static void
-load_recur_monthly_pos (iCalObject *o, char **str)
-{
- ocurrencelist (o, str);
- weekdaynum (o, str);
-}
-
-static void
-load_recur_monthly_day (iCalObject *o, char **str)
-{
- daynumberlist (o, str);
-}
-
-static void
-load_recur_yearly_month (iCalObject *o, char **str)
-{
- /* Skip as we do not support multiple months and we do expect
- * the dtstart to agree with the value on this field
- */
- skip_numbers (str);
-}
-
-static void
-load_recur_yearly_day (iCalObject *o, char **str)
-{
- /* Skip as we do not support multiple days and we do expect
- * the dtstart to agree with the value on this field
- *
- * FIXME: we should support every-n-years
- */
- skip_numbers (str);
-}
-
-static void
-duration (iCalObject *o, char **str)
-{
- unsigned int duration = 0;
-
- ignore_space (str);
- if (**str != '#')
- return;
- (*str)++;
- while (**str && isdigit (**str)){
- duration = duration * 10 + (**str - '0');
- (*str)++;
- }
- o->recur->duration = duration;
-}
-
-static void
-enddate (iCalObject *o, char **str)
-{
- ignore_space (str);
- if (isdigit (**str)){
- o->recur->_enddate = time_from_isodate (*str);
- *str += 16;
- }
-}
-
-static int
-load_recurrence (iCalObject *o, char *str)
-{
- enum RecurType type;
- int interval = 0;
-
- type = -1;
- switch (*str++){
- case 'D':
- type = RECUR_DAILY;
- break;
-
- case 'W':
- type = RECUR_WEEKLY;
- break;
-
- case 'M':
- if (*str == 'P')
- type = RECUR_MONTHLY_BY_POS;
- else if (*str == 'D')
- type = RECUR_MONTHLY_BY_DAY;
- str++;
- break;
-
- case 'Y':
- if (*str == 'M')
- type = RECUR_YEARLY_BY_MONTH;
- else if (*str == 'D')
- type = RECUR_YEARLY_BY_DAY;
- str++;
- break;
- }
- if (type == -1)
- return 0;
-
- o->recur = g_new0 (Recurrence, 1);
- o->recur->type = type;
- ignore_space (&str);
-
- /* Get the interval */
- for (;*str && isdigit (*str);str++)
- interval = interval * 10 + (*str-'0');
-
- if (interval == 0)
- interval = 1;
-
- o->recur->interval = interval;
-
- /* this is the default per the spec */
- o->recur->duration = 2;
-
- ignore_space (&str);
-
- switch (type){
- case RECUR_DAILY:
- break;
- case RECUR_WEEKLY:
- load_recur_weekly (o, &str);
- break;
- case RECUR_MONTHLY_BY_POS:
- load_recur_monthly_pos (o, &str);
- break;
- case RECUR_MONTHLY_BY_DAY:
- load_recur_monthly_day (o, &str);
- break;
- case RECUR_YEARLY_BY_MONTH:
- load_recur_yearly_month (o, &str);
- break;
- case RECUR_YEARLY_BY_DAY:
- load_recur_yearly_day (o, &str);
- break;
- default:
- g_warning ("Unimplemented recurrence type %d", (int) type);
- break;
- }
- duration (o, &str);
- enddate (o, &str);
-
- /* Compute the enddate */
- if (o->recur->_enddate == 0){
- if (o->recur->duration != 0){
- ical_object_compute_end (o);
- } else
- o->recur->enddate = 0;
- } else {
- o->recur->enddate = o->recur->_enddate;
- }
- return 1;
-}
-
-#define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop)
-#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj))
-#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
-
-/*
- * FIXME: This is loosing precission. Enhanec the thresholds
- */
-#define HOURS(n) (n*(60*60))
-
-static void
-setup_alarm_at (iCalObject *ico, CalendarAlarm *alarm, char *iso_time, VObject *vo)
-{
- time_t alarm_time = time_from_isodate (iso_time);
- time_t base = ico->dtstart;
- int d = difftime (base, alarm_time);
- VObject *a;
- char *the_str;
-
- alarm->enabled = 1;
- if (d > HOURS (2)){
- if (d > HOURS (48)){
- alarm->count = d / HOURS (24);
- alarm->units = ALARM_DAYS;
- } else {
- alarm->count = d / (60*60);
- alarm->units = ALARM_HOURS;
- }
- } else {
- alarm->count = d / 60;
- alarm->units = ALARM_MINUTES;
- }
-
- if ((a = is_a_prop_of (vo, VCSnoozeTimeProp))){
- alarm->snooze_secs = isodiff_to_secs (str_val (a));
- free (the_str);
- }
-
- if ((a = is_a_prop_of (vo, VCRepeatCountProp))){
- alarm->snooze_repeat = atoi (str_val (a));
- free (the_str);
- }
-}
-
-/*
- * Duplicates an iCalObject. Implementation is a grand hack
- */
-iCalObject *
-ical_object_duplicate (iCalObject *o)
-{
- VObject *vo;
- iCalObject *new;
-
- vo = ical_object_to_vobject (o);
- switch (o->type){
- case ICAL_EVENT:
- new = ical_object_create_from_vobject (vo, VCEventProp);
- break;
- case ICAL_TODO:
- new = ical_object_create_from_vobject (vo, VCTodoProp);
- break;
- default:
- new = NULL;
- }
-
- cleanVObject (vo);
- return new;
-}
-
-/* FIXME: we need to load the recurrence properties */
-iCalObject *
-ical_object_create_from_vobject (VObject *o, const char *object_name)
-{
- time_t now = time (NULL);
- iCalObject *ical;
- VObject *vo, *a;
- VObjectIterator i;
- char *the_str;
-
- ical = g_new0 (iCalObject, 1);
-
- if (strcmp (object_name, VCEventProp) == 0)
- ical->type = ICAL_EVENT;
- else if (strcmp (object_name, VCTodoProp) == 0)
- ical->type = ICAL_TODO;
- else {
- g_free (ical);
- return 0;
- }
-
- /* uid */
- if (has (o, VCUniqueStringProp)){
- ical->uid = g_strdup (str_val (vo));
- free (the_str);
- } else {
- ical->uid = ical_gen_uid ();
- }
-
- /* seq */
- if (has (o, VCSequenceProp)){
- ical->seq = atoi (str_val (vo));
- free (the_str);
- } else
- ical->seq = 0;
-
- /* dtstart */
- if (has (o, VCDTstartProp)){
- ical->dtstart = time_from_isodate (str_val (vo));
- free (the_str);
- } else
- ical->dtstart = 0;
-
- /* dtend */
- ical->dtend = 0; /* default value */
- if (ical->type == ICAL_EVENT){
- if (has (o, VCDTendProp)){
- ical->dtend = time_from_isodate (str_val (vo));
- free (the_str);
- }
- } else if (ical->type == ICAL_TODO){
- if (has (o, VCDueProp)){
- ical->dtend = time_from_isodate (str_val (vo));
- free (the_str);
- }
- }
-
- /* dcreated */
- if (has (o, VCDCreatedProp)){
- ical->created = time_from_isodate (str_val (vo));
- free (the_str);
- }
-
- /* completed */
- if (has (o, VCCompletedProp)){
- ical->completed = time_from_isodate (str_val (vo));
- free (the_str);
- }
-
- /* last_mod */
- if (has (o, VCLastModifiedProp)){
- ical->last_mod = time_from_isodate (str_val (vo));
- free (the_str);
- } else
- ical->last_mod = now;
-
- /* exdate */
- if (has (o, VCExpDateProp)){
- ical->exdate = set_date_list (str_val (vo));
- free (the_str);
- }
-
- /* description/comment */
- if (has (o, VCDescriptionProp)){
- ical->comment = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* summary */
- if (has (o, VCSummaryProp)){
- ical->summary = g_strdup (str_val (vo));
- free (the_str);
- } else
- ical->summary = g_strdup ("");
-
- /* status */
- if (has (o, VCStatusProp)){
- ical->status = g_strdup (str_val (vo));
- free (the_str);
- } else
- ical->status = g_strdup ("NEEDS ACTION");
-
- if (has (o, VCClassProp)){
- ical->class = g_strdup (str_val (vo));
- free (the_str);
- } else
- ical->class = "PUBLIC";
-
- /* categories */
- if (has (o, VCCategoriesProp)){
- ical->categories = set_list (str_val (vo));
- free (the_str);
- }
-
- /* resources */
- if (has (o, VCResourcesProp)){
- ical->resources = set_list (str_val (vo));
- free (the_str);
- }
-
- /* priority */
- if (has (o, VCPriorityProp)){
- ical->priority = atoi (str_val (vo));
- free (the_str);
- }
-
- /* tranparency */
- if (has (o, VCTranspProp)){
- ical->transp = atoi (str_val (vo)) ? ICAL_TRANSPARENT : ICAL_OPAQUE;
- free (the_str);
- }
-
- /* Organizer */
- if (has (o, VCOrgNameProp)){
- ical->organizer = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* related */
- if (has (o, VCRelatedToProp)){
- ical->related = set_list (str_val (vo));
- free (the_str);
- }
-
- /* attach */
- initPropIterator (&i, o);
- while (moreIteration (&i)){
- vo = nextVObject (&i);
- if (strcmp (vObjectName (vo), VCAttachProp) == 0){
- ical->attach = g_list_prepend (ical->attach, g_strdup (str_val (vo)));
- free (the_str);
- }
- }
-
- /* url */
- if (has (o, VCURLProp)){
- ical->url = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* dalarm */
- ical->dalarm.type = ALARM_DISPLAY;
- ical->dalarm.enabled = 0;
- if (has (o, VCDAlarmProp)){
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->dalarm, str_val (a), vo);
- free (the_str);
- }
- }
-
- /* aalarm */
- ical->aalarm.type = ALARM_AUDIO;
- ical->aalarm.enabled = 0;
- if (has (o, VCAAlarmProp)){
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->aalarm, str_val (a), vo);
- free (the_str);
- }
- }
-
- /* palarm */
- ical->palarm.type = ALARM_PROGRAM;
- ical->palarm.enabled = 0;
- if (has (o, VCPAlarmProp)){
- ical->palarm.type = ALARM_PROGRAM;
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->palarm, str_val (a), vo);
- free (the_str);
-
- if ((a = is_a_prop_of (vo, VCProcedureNameProp))){
- ical->palarm.data = g_strdup (str_val (a));
- free (the_str);
- } else
- ical->palarm.data = g_strdup ("");
- }
- }
-
- /* malarm */
- ical->malarm.type = ALARM_MAIL;
- ical->malarm.enabled = 0;
- if (has (o, VCMAlarmProp)){
- ical->malarm.type = ALARM_MAIL;
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->malarm, str_val (a), vo);
- free (the_str);
-
- if ((a = is_a_prop_of (vo, VCEmailAddressProp))){
- ical->malarm.data = g_strdup (str_val (a));
- free (the_str);
- } else
- ical->malarm.data = g_strdup ("");
- }
- }
-
- /* rrule */
- if (has (o, VCRRuleProp)){
- if (!load_recurrence (ical, str_val (vo))) {
- ical_object_destroy (ical);
- return NULL;
- }
- free (the_str);
- }
-
- /*
- * Pilot
- */
- if (has (o, XPilotIdProp)){
- ical->pilot_id = atoi (str_val (vo));
- free (the_str);
- } else
- ical->pilot_id = 0;
-
- if (has (o, XPilotStatusProp)){
- ical->pilot_status = atoi (str_val (vo));
- free (the_str);
- } else
- ical->pilot_status = ICAL_PILOT_SYNC_MOD;
-
- return ical;
-}
-
-static char *
-to_str (int num)
-{
- static char buf [40];
-
- sprintf (buf, "%d", num);
- return buf;
-}
-
-/*
- * stores a GList in the property.
- */
-static void
-store_list (VObject *o, char *prop, GList *values)
-{
- GList *l;
- int len;
- char *result, *p;
-
- for (len = 0, l = values; l; l = l->next)
- len += strlen (l->data) + 1;
-
- result = g_malloc (len);
-
- for (p = result, l = values; l; l = l->next) {
- int len = strlen (l->data);
-
- strcpy (p, l->data);
-
- if (l->next) {
- p [len] = ';';
- p += len+1;
- } else
- p += len;
- }
-
- *p = 0;
-
- addPropValue (o, prop, result);
- g_free (result);
-}
-
-static void
-store_date_list (VObject *o, char *prop, GList *values)
-{
- GList *l;
- int size, len;
- char *s, *p;
-
- size = g_list_length (values);
- s = p = g_malloc ((size * 17 + 1) * sizeof (char));
-
- for (l = values; l; l = l->next){
- strcpy (s, isodate_from_time_t (*(time_t *)l->data));
- len = strlen (s);
- s [len] = ',';
- s += len + 1;
- }
- s--;
- *s = 0;
- addPropValue (o, prop, p);
- g_free (p);
-}
-
-static char *recur_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" };
-static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" };
-static char *alarm_names [] = { VCMAlarmProp, VCPAlarmProp, VCDAlarmProp, VCAAlarmProp };
-
-static VObject *
-save_alarm (VObject *o, CalendarAlarm *alarm, iCalObject *ical)
-{
- VObject *alarm_object;
- struct tm tm;
- time_t alarm_time;
-
- if (!alarm->enabled)
- return NULL;
- tm = *localtime (&ical->dtstart);
- switch (alarm->units){
- case ALARM_MINUTES:
- tm.tm_min -= alarm->count;
- break;
-
- case ALARM_HOURS:
- tm.tm_hour -= alarm->count;
- break;
-
- case ALARM_DAYS:
- tm.tm_mday -= alarm->count;
- break;
- }
-
- alarm_time = mktime (&tm);
- alarm_object = addProp (o, alarm_names [alarm->type]);
- addPropValue (alarm_object, VCRunTimeProp, isodate_from_time_t (alarm_time));
-
- if (alarm->snooze_secs)
- addPropValue (alarm_object, VCSnoozeTimeProp, isodiff_from_secs (alarm->snooze_secs));
- else
- addPropValue (alarm_object, VCSnoozeTimeProp, "");
-
- if (alarm->snooze_repeat){
- char buf [20];
-
- sprintf (buf, "%d", alarm->snooze_repeat);
- addPropValue (alarm_object, VCRepeatCountProp, buf);
- } else
- addPropValue (alarm_object, VCRepeatCountProp, "");
- return alarm_object;
-}
-
-VObject *
-ical_object_to_vobject (iCalObject *ical)
-{
- VObject *o, *alarm, *s;
- GList *l;
-
- if (ical->type == ICAL_EVENT)
- o = newVObject (VCEventProp);
- else
- o = newVObject (VCTodoProp);
-
- /* uid */
- if (ical->uid)
- addPropValue (o, VCUniqueStringProp, ical->uid);
-
- /* seq */
- addPropValue (o, VCSequenceProp, to_str (ical->seq));
-
- /* dtstart */
- addPropValue (o, VCDTstartProp, isodate_from_time_t (ical->dtstart));
-
- /* dtend */
- if (ical->type == ICAL_EVENT){
- addPropValue (o, VCDTendProp, isodate_from_time_t (ical->dtend));
- } else if (ical->type == ICAL_TODO){
- addPropValue (o, VCDueProp, isodate_from_time_t (ical->dtend));
- }
-
- /* dcreated */
- addPropValue (o, VCDCreatedProp, isodate_from_time_t (ical->created));
-
- /* completed */
- if (ical->completed)
- addPropValue (o, VCDTendProp, isodate_from_time_t (ical->completed));
-
- /* last_mod */
- addPropValue (o, VCLastModifiedProp, isodate_from_time_t (ical->last_mod));
-
- /* exdate */
- if (ical->exdate)
- store_date_list (o, VCExpDateProp, ical->exdate);
-
- /* description/comment */
- if (ical->comment && strlen (ical->comment)){
- s = addPropValue (o, VCDescriptionProp, ical->comment);
- if (strchr (ical->comment, '\n'))
- addProp (s, VCQuotedPrintableProp);
- }
-
- /* summary */
- if (strlen (ical->summary)){
- s = addPropValue (o, VCSummaryProp, ical->summary);
- if (strchr (ical->summary, '\n'))
- addProp (s, VCQuotedPrintableProp);
- } else {
- addPropValue (o, VCSummaryProp, _("Appointment"));
- }
-
- /* status */
- addPropValue (o, VCStatusProp, ical->status);
-
- /* class */
- addPropValue (o, VCClassProp, ical->class);
-
- /* categories */
- if (ical->categories)
- store_list (o, VCCategoriesProp, ical->categories);
-
- /* resources */
- if (ical->resources)
- store_list (o, VCCategoriesProp, ical->resources);
-
- /* priority */
- addPropValue (o, VCPriorityProp, to_str (ical->priority));
-
- /* transparency */
- addPropValue (o, VCTranspProp, to_str (ical->transp));
-
- /* Owenr/organizer */
- if (ical->organizer)
- addPropValue (o, VCOrgNameProp, ical->organizer);
-
- /* related */
- if (ical->related)
- store_list (o, VCRelatedToProp, ical->related);
-
- /* attach */
- for (l = ical->attach; l; l = l->next)
- addPropValue (o, VCAttachProp, l->data);
-
- /* url */
- if (ical->url)
- addPropValue (o, VCURLProp, ical->url);
-
- if (ical->recur){
- char result [256];
- char buffer [80];
- int i;
-
- sprintf (result, "%s%d ", recur_type_name [ical->recur->type], ical->recur->interval);
- switch (ical->recur->type){
- case RECUR_DAILY:
- break;
-
- case RECUR_WEEKLY:
- for (i = 0; i < 7; i++){
- if (ical->recur->weekday & (1 << i)){
- sprintf (buffer, "%s ", recur_day_list [i]);
- strcat (result, buffer);
- }
- }
- break;
-
- case RECUR_MONTHLY_BY_POS: {
- int nega = ical->recur->u.month_pos < 0;
-
- sprintf (buffer, "%d%s ", nega ? -ical->recur->u.month_pos : ical->recur->u.month_pos,
- nega ? "-" : "+");
- strcat (result, buffer);
- /* the gui is set up for a single day, not a set here in this case */
- sprintf (buffer, "%s ", recur_day_list [ical->recur->weekday]);
- strcat (result, buffer);
- }
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- sprintf (buffer, "%d ", ical->recur->u.month_pos);
- strcat (result, buffer);
- break;
-
- case RECUR_YEARLY_BY_MONTH:
- break;
-
- case RECUR_YEARLY_BY_DAY:
- break;
- }
- if (ical->recur->_enddate == 0)
- sprintf (buffer, "#%d ",ical->recur->duration);
- else
- sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
- strcat (result, buffer);
- addPropValue (o, VCRRuleProp, result);
- }
-
- save_alarm (o, &ical->aalarm, ical);
- save_alarm (o, &ical->dalarm, ical);
-
- if ((alarm = save_alarm (o, &ical->palarm, ical)))
- addPropValue (alarm, VCProcedureNameProp, ical->palarm.data);
- if ((alarm = save_alarm (o, &ical->malarm, ical)))
- addPropValue (alarm, VCEmailAddressProp, ical->malarm.data);
-
- /* Pilot */
- {
- char buffer [20];
-
- sprintf (buffer, "%d", ical->pilot_id);
- addPropValue (o, XPilotIdProp, buffer);
- sprintf (buffer, "%d", ical->pilot_status);
- addPropValue (o, XPilotStatusProp, buffer);
- }
-
- return o;
-}
-
-void
-ical_foreach (GList *events, calendarfn fn, void *closure)
-{
- for (; events; events = events->next){
- iCalObject *ical = events->data;
-
- (*fn) (ical, ical->dtstart, ical->dtend, closure);
- }
-}
-
-static int
-is_date_in_list (GList *list, struct tm *date)
-{
- struct tm tm;
-
- for (; list; list = list->next){
- time_t *timep = list->data;
-
- tm = *localtime (timep);
- if (date->tm_mday == tm.tm_mday &&
- date->tm_mon == tm.tm_mon &&
- date->tm_year == tm.tm_year){
- return 1;
- }
- }
- return 0;
-}
-
-static int
-generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure)
-{
- struct tm dt_start, dt_end, ref;
- time_t s_t, e_t;
-
- dt_start = *localtime (&ico->dtstart);
- dt_end = *localtime (&ico->dtend);
- ref = *localtime (&reference);
-
- dt_start.tm_mday = ref.tm_mday;
- dt_start.tm_mon = ref.tm_mon;
- dt_start.tm_year = ref.tm_year;
-
- dt_end.tm_mday = ref.tm_mday;
- dt_end.tm_mon = ref.tm_mon;
- dt_end.tm_year = ref.tm_year;
-
-
- if (ref.tm_isdst > dt_start.tm_isdst){
- dt_start.tm_hour--;
- dt_end.tm_hour--;
- } else if (ref.tm_isdst < dt_start.tm_isdst){
- dt_start.tm_hour++;
- dt_end.tm_hour++;
- }
-
- s_t = mktime (&dt_start);
-
- if (ico->exdate && is_date_in_list (ico->exdate, &dt_start))
- return 1;
-
- e_t = mktime (&dt_end);
-
- if ((s_t == -1) || (e_t == -1)) {
- g_warning ("Produced invalid dates!\n");
- return 0;
- }
-
- return (*cb) (ico, s_t, e_t, closure);
-}
-
-int
-ical_object_get_first_weekday (int weekday_mask)
-{
- int i;
-
- for (i = 0; i < 7; i++)
- if (weekday_mask & (1 << i))
- return i;
-
- return -1;
-}
-
-#define time_in_range(t, a, b) ((t >= a) && (b ? (t < b) : 1))
-#define recur_in_range(t, r) (r->enddate ? (t < r->enddate) : 1)
-
-/*
- * Generate every possible event. Invokes the callback routine for
- * every occurrence of the event in the [START, END] time interval.
- *
- * If END is zero, the event is generated forever.
- * The callback routine is expected to return 0 when no further event
- * generation is requested.
- */
-void
-ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure)
-{
- time_t current;
- int first_week_day;
-
- /* If there is no recurrence, just check ranges */
-
- if (!ico->recur) {
- if ((end && (ico->dtstart < end) && (ico->dtend > start))
- || ((end == 0) && (ico->dtend > start))) {
- time_t ev_s, ev_e;
-
- /* Clip range */
-
- ev_s = MAX (ico->dtstart, start);
- ev_e = MIN (ico->dtend, end);
-
- (* cb) (ico, ev_s, ev_e, closure);
- }
- return;
- }
-
- /* The event has a recurrence rule -- check that we will generate at least one instance */
-
- if (end != 0) {
- if (ico->dtstart > end)
- return;
-
- if (!IS_INFINITE (ico->recur) && (ico->recur->enddate < start))
- return;
- }
-
- /* Generate the instances */
-
- current = ico->dtstart;
-
- switch (ico->recur->type) {
- case RECUR_DAILY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, current, cb, closure))
- return;
-
- /* Advance */
-
- current = time_add_day (current, ico->recur->interval);
-
- if (current == -1) {
- g_warning ("RECUR_DAILY: time_add_day() returned invalid time");
- return;
- }
- } while ((current < end) || (end == 0));
-
- break;
-
- case RECUR_WEEKLY:
- do {
- struct tm tm;
-
- tm = *localtime (&current);
-
- if (time_in_range (current, start, end) && recur_in_range (current, ico->recur)) {
- /* Weekdays to recur on are specified as a bitmask */
- if (ico->recur->weekday & (1 << tm.tm_wday)) {
- if (!generate (ico, current, cb, closure))
- return;
- }
- }
-
- /* Advance by day for scanning the week or by interval at week end */
-
- if (tm.tm_wday == 6)
- current = time_add_day (current, (ico->recur->interval - 1) * 7 + 1);
- else
- current = time_add_day (current, 1);
-
- if (current == -1) {
- g_warning ("RECUR_WEEKLY: time_add_day() returned invalid time\n");
- return;
- }
- } while (current < end || (end == 0));
-
- break;
-
- case RECUR_MONTHLY_BY_POS:
- /* FIXME: We only deal with positives now */
- if (ico->recur->u.month_pos < 0) {
- g_warning ("RECUR_MONTHLY_BY_POS does not support negative positions yet");
- return;
- }
-
- if (ico->recur->u.month_pos == 0)
- return;
-
- first_week_day = /* ical_object_get_first_weekday (ico->recur->weekday); */
- ico->recur->weekday; /* the i/f only lets you choose a single day of the week! */
-
- /* This should not happen, but take it into account */
- if (first_week_day == -1) {
- g_warning ("ical_object_get_first_weekday() returned -1");
- return;
- }
-
- do {
- struct tm tm;
- time_t t;
- int week_day_start;
-
- tm = *localtime (&current);
- tm.tm_mday = 1;
- t = mktime (&tm);
- tm = *localtime (&t);
- week_day_start = tm.tm_wday;
-
- tm.tm_mday = (7 * (ico->recur->u.month_pos - ((week_day_start <= first_week_day ) ? 1 : 0))
- - (week_day_start - first_week_day) + 1);
- if( tm.tm_mday > 31 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
-
- switch( tm.tm_mon )
- {
- case 3:
- case 5:
- case 8:
- case 10:
- if( tm.tm_mday > 30 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
- break;
- case 1:
- if( ((tm.tm_year+1900)%4) == 0
- && ((tm.tm_year+1900)%400) != 100
- && ((tm.tm_year+1900)%400) != 200
- && ((tm.tm_year+1900)%400) != 300 )
- {
-
- if( tm.tm_mday > 29 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
- }
- else
- {
- if( tm.tm_mday > 28 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
- }
- break;
- }
-
- t = mktime (&tm);
-
- if (time_in_range (t, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance by the appropriate number of months */
-
- current = mktime (&tm);
-
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
-
- if (current == -1) {
- g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
- return;
- }
- } while ((current < end) || (end == 0));
-
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- do {
- struct tm tm;
- time_t t;
- int p;
-
- tm = *localtime (&current);
-
- p = tm.tm_mday;
- tm.tm_mday = ico->recur->u.month_day;
- t = mktime (&tm);
- if (time_in_range (t, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance by the appropriate number of months */
-
- tm.tm_mday = p;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
-
- if (current == -1) {
- g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
- return;
- }
- } while (current < end || (end == 0));
-
- break;
-
- case RECUR_YEARLY_BY_MONTH:
- case RECUR_YEARLY_BY_DAY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, current, cb, closure))
- return;
-
- /* Advance */
-
- current = time_add_year (current, ico->recur->interval);
- } while (current < end || (end == 0));
-
- break;
-
- default:
- g_assert_not_reached ();
- }
-}
-
-static int
-duration_callback (iCalObject *ico, time_t start, time_t end, void *closure)
-{
- int *count = closure;
- struct tm tm;
-
- tm = *localtime (&start);
-
- (*count)++;
- if (ico->recur->duration == *count) {
- ico->recur->enddate = time_day_end (end);
- return 0;
- }
- return 1;
-}
-
-/* Computes ico->recur->enddate from ico->recur->duration */
-void
-ical_object_compute_end (iCalObject *ico)
-{
- int count = 0;
-
- g_return_if_fail (ico->recur != NULL);
-
- ico->recur->_enddate = 0;
- ico->recur->enddate = 0;
- ical_object_generate_events (ico, ico->dtstart, 0, duration_callback, &count);
-}
-
-int
-alarm_compute_offset (CalendarAlarm *a)
-{
- if (!a->enabled)
- return -1;
- switch (a->units){
- case ALARM_MINUTES:
- a->offset = a->count * 60;
- break;
- case ALARM_HOURS:
- a->offset = a->count * 3600;
- break;
- case ALARM_DAYS:
- a->offset = a->count * 24 * 3600;
- }
- return a->offset;
-}
-
-iCalObject *
-ical_object_new_from_string (const char *vcal_string)
-{
- iCalObject *ical = NULL;
- VObject *cal, *event;
- VObjectIterator i;
- const char *object_name;
-
- cal = Parse_MIME (vcal_string, strlen (vcal_string));
-
- initPropIterator (&i, cal);
-
- while (moreIteration (&i)){
- event = nextVObject (&i);
-
- object_name = vObjectName (event);
-
- if (strcmp (object_name, VCEventProp) == 0){
- ical = ical_object_create_from_vobject (event, object_name);
- break;
- }
- }
-
- cleanVObject (cal);
- cleanStrTbl ();
-
- return ical;
-}
-
diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h
deleted file mode 100644
index fbc92a41c5..0000000000
--- a/calendar/cal-util/calobj.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Internal representation of a Calendar object. This is modeled after the
- * iCalendar/vCalendar specificiation
- *
- * Authors: Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org).
- */
-#ifndef CALOBJ_H
-#define CALOBJ_H
-
-#include <libgnome/libgnome.h>
-#include "../libversit/vcc.h"
-
-BEGIN_GNOME_DECLS
-
-enum AlarmType {
- ALARM_MAIL,
- ALARM_PROGRAM,
- ALARM_DISPLAY,
- ALARM_AUDIO
-};
-
-enum AlarmUnit {
- ALARM_MINUTES,
- ALARM_HOURS,
- ALARM_DAYS
-};
-
-typedef struct {
- enum AlarmType type;
- int enabled;
- int count;
- enum AlarmUnit units;
- char *data;
-
- /* Does not get saved, internally used */
- time_t offset;
- time_t trigger;
-
- int snooze_secs;
- int snooze_repeat;
-
- /* Widgets */
- void *w_count; /* A GtkEntry */
- void *w_enabled; /* A GtkChecButton */
- void *w_timesel; /* A GtkMenu */
- void *w_entry; /* A GnomeEntryFile/GtkEntry for PROGRAM/MAIL */
- void *w_label;
-} CalendarAlarm;
-
-/* Calendar object type */
-typedef enum {
- ICAL_EVENT,
- ICAL_TODO,
- ICAL_JOURNAL,
- ICAL_FBREQUEST,
- ICAL_FBREPLY,
- ICAL_BUSYTIME,
- ICAL_TIMEZONE
-} iCalType;
-
-/* For keys that might contain binary or text/binary */
-typedef struct {
- char *data;
- int len;
-} iCalValue;
-
-typedef enum {
- ICAL_PILOT_SYNC_NONE = 0,
- ICAL_PILOT_SYNC_MOD = 1,
- ICAL_PILOT_SYNC_DEL = 3
-} iCalPilotState;
-
-typedef struct {
- int valid; /* true if the Geography was specified */
- double latitude;
- double longitude;
-} iCalGeo;
-
-typedef enum {
- ICAL_OPAQUE,
- ICAL_TRANSPARENT
-} iCalTransp;
-
-typedef char NotYet;
-
-enum RecurType {
- RECUR_DAILY,
- RECUR_WEEKLY,
- RECUR_MONTHLY_BY_POS,
- RECUR_MONTHLY_BY_DAY,
- RECUR_YEARLY_BY_MONTH,
- RECUR_YEARLY_BY_DAY,
-};
-
-#define DAY_LASTDAY 10000
-
-typedef struct {
- enum RecurType type;
-
- int interval;
-
- /* Used for recur computation */
- time_t enddate; /* If the value is zero, it is an infinite event
- * otherwise, it is either the _enddate value (if
- * this is what got specified) or it is our computed
- * ending date (computed from the duration item).
- */
-
- int weekday;
-
- union {
- int month_pos;
- int month_day;
- } u;
-
- int duration;
- time_t _enddate; /* As found on the vCalendar file */
- int __count;
-} Recurrence;
-
-#define IS_INFINITE(r) (r->duration == 0)
-
-/* Flags to indicate what has changed in an object */
-typedef enum {
- CHANGE_NEW = 1 << 0, /* new object */
- CHANGE_SUMMARY = 1 << 1, /* summary */
- CHANGE_DATES = 1 << 2, /* dtstart / dtend */
- CHANGE_ALL = CHANGE_SUMMARY | CHANGE_DATES
-} CalObjectChange;
-
-/*
- * This describes an iCalendar object, note that we never store durations, instead we
- * always compute the end time computed from the start + duration.
- */
-typedef struct {
- iCalType type;
-
- GList *attach; /* type: one or more URIs or binary data */
- GList *attendee; /* type: CAL-ADDRESS */
- GList *categories; /* type: one or more TEXT */
- char *class;
-
- char *comment; /* we collapse one or more TEXTs into one */
- time_t completed;
- time_t created;
- GList *contact; /* type: one or more TEXT */
- time_t dtstamp;
- time_t dtstart;
- time_t dtend;
- GList *exdate; /* type: one or more time_t's */
- GList *exrule; /* type: one or more RECUR */
- iCalGeo geo;
- time_t last_mod;
- char *location;
- char *organizer;
- int percent;
- int priority;
- char *rstatus; /* request status for freebusy */
- GList *related; /* type: one or more TEXT */
- GList *resources; /* type: one or more TEXT */
- GList *rdate; /* type: one or more recurrence date */
- GList *rrule; /* type: one or more recurrence rules */
- int seq;
- char *status;
- char *summary;
- iCalTransp transp;
- char *uid;
- char *url;
- time_t recurid;
-
- CalendarAlarm dalarm;
- CalendarAlarm aalarm;
- CalendarAlarm palarm;
- CalendarAlarm malarm;
-
- Recurrence *recur;
-
- int new;
- void *user_data; /* Generic data pointer */
-
- /* Pilot */
- iCalPilotState pilot_status; /* Status information */
- guint32 pilot_id; /* Pilot ID */
-} iCalObject;
-
-/* The callback for the recurrence generator */
-typedef int (*calendarfn) (iCalObject *, time_t, time_t, void *);
-
-iCalObject *ical_new (char *comment, char *organizer, char *summary);
-iCalObject *ical_object_new (void);
-iCalObject *ical_object_new_from_string (const char *vcalendar_string);
-void ical_object_destroy (iCalObject *ico);
-iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name);
-VObject *ical_object_to_vobject (iCalObject *ical);
-iCalObject *ical_object_duplicate (iCalObject *o);
-void ical_foreach (GList *events, calendarfn fn, void *closure);
-void ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure);
-void ical_object_add_exdate (iCalObject *o, time_t t);
-
-/* Computes the enddate field of the recurrence based on the duration */
-void ical_object_compute_end (iCalObject *ico);
-
-/* Returns the first toggled day in a weekday mask -- we do this because we do not support multiple
- * days on a monthly-by-pos recurrence. If no days are toggled, it returns -1.
- */
-int ical_object_get_first_weekday (int weekday_mask);
-
-/* Returns the number of seconds configured to trigger the alarm in advance to an event */
-int alarm_compute_offset (CalendarAlarm *a);
-
-END_GNOME_DECLS
-
-#endif
-
diff --git a/calendar/cal.c b/calendar/cal.c
deleted file mode 100644
index 1ce1d91716..0000000000
--- a/calendar/cal.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/* Evolution calendar client interface object
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include "cal.h"
-#include "cal-backend.h"
-
-
-
-/* Private part of the Cal structure */
-typedef struct {
- /* Our backend */
- CalBackend *backend;
-
- /* Listener on the client we notify */
- Evolution_Calendar_Listener listener;
-} CalPrivate;
-
-
-
-static void cal_class_init (CalClass *class);
-static void cal_init (Cal *cal);
-static void cal_destroy (GtkObject *object);
-
-static POA_Evolution_Calendar_Cal__vepv cal_vepv;
-
-static BonoboObjectClass *parent_class;
-
-
-
-/**
- * cal_get_type:
- * @void:
- *
- * Registers the #Cal class if necessary, and returns the type ID associated to
- * it.
- *
- * Return value: The type ID of the #Cal class.
- **/
-GtkType
-cal_get_type (void)
-{
- static GtkType cal_type = 0;
-
- if (!cal_type) {
- static const GtkTypeInfo cal_info = {
- "Cal",
- sizeof (Cal),
- sizeof (CalClass),
- (GtkClassInitFunc) cal_class_init,
- (GtkObjectInitFunc) cal_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- cal_type = gtk_type_unique (BONOBO_OBJECT_TYPE, &cal_info);
- }
-
- return cal_type;
-}
-
-/* CORBA class initialzation function for the calendar */
-static void
-init_cal_corba_class (void)
-{
- cal_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
- cal_vepv.Evolution_Calendar_Cal_epv = cal_get_epv ();
-}
-
-/* Class initialization function for the calendar */
-static void
-cal_class_init (CalClass *class)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) class;
-
- parent_class = gtk_type_class (BONOBO_OBJECT_TYPE);
-
- object_class->destroy = cal_destroy;
-
- init_cal_corba_class ();
-}
-
-/* Object initialization function for the calendar */
-static void
-cal_init (Cal *cal)
-{
- CalPrivate *priv;
-
- priv = g_new0 (CalPrivate, 1);
- cal->priv = priv;
-
- priv->listener = CORBA_OBJECT_NIL;
-}
-
-/* Destroy handler for the calendar */
-static void
-cal_destroy (GtkObject *object)
-{
- Cal *cal;
- CalPrivate *priv;
- CORBA_Environment ev;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL (object));
-
- cal = CAL (object);
- priv = cal->priv;
-
- CORBA_exception_init (&ev);
- CORBA_Object_release (priv->listener, &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("cal_destroy(): could not release the listener");
-
- CORBA_exception_free (&ev);
-
- g_free (priv);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-
-
-/* CORBA servant implementation */
-
-/* Cal::get_uri method */
-static CORBA_char *
-Cal_get_uri (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- Cal *cal;
- CalPrivate *priv;
- GnomeVFSURI *uri;
- char *str_uri;
- CORBA_char *str_uri_copy;
-
- cal = CAL (bonobo_object_from_servant (servant));
- priv = cal->priv;
-
- uri = cal_backend_get_uri (priv->backend);
- str_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
- str_uri_copy = CORBA_string_dup (str_uri);
- g_free (str_uri);
-
- return str_uri_copy;
-
-}
-
-/* Cal::get_object method */
-static Evolution_Calendar_CalObj
-Cal_get_object (PortableServer_Servant servant,
- const Evolution_Calendar_CalObjUID uid,
- CORBA_Environment *ev)
-{
- Cal *cal;
- CalPrivate *priv;
- char *calobj;
-
- cal = CAL (bonobo_object_from_servant (servant));
- priv = cal->priv;
-
- calobj = cal_backend_get_object (priv->backend, uid);
-
- if (calobj) {
- CORBA_char *calobj_copy;
-
- calobj_copy = CORBA_string_dup (calobj);
- g_free (calobj);
- return calobj_copy;
- } else {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_Evolution_Calendar_Cal_NotFound,
- NULL);
- return NULL;
- }
-}
-
-/**
- * cal_get_epv:
- * @void:
- *
- * Creates an EPV for the Cal CORBA class.
- *
- * Return value: A newly-allocated EPV.
- **/
-POA_Evolution_Calendar_Cal__epv *
-cal_get_epv (void)
-{
- POA_Evolution_Calendar_Cal__epv *epv;
-
- epv = g_new0 (POA_Evolution_Calendar_Cal__epv, 1);
- epv->_get_uri = Cal_get_uri;
- epv->get_object = Cal_get_object;
-
- return epv;
-}
-
-
-
-/**
- * cal_construct:
- * @cal: A calendar client interface.
- * @corba_cal: CORBA object for the calendar.
- * @backend: Calendar backend that this @cal presents an interface to.
- * @listener: Calendar listener for notification.
- *
- * Constructs a calendar client interface object by binding the corresponding
- * CORBA object to it. The calendar interface is bound to the specified
- * @backend, and will notify the @listener about changes to the calendar.
- *
- * Return value: The same object as the @cal argument.
- **/
-Cal *
-cal_construct (Cal *cal,
- Evolution_Calendar_Cal corba_cal,
- CalBackend *backend,
- Evolution_Calendar_Listener listener)
-{
- CalPrivate *priv;
- CORBA_Environment ev;
-
- g_return_val_if_fail (cal != NULL, NULL);
- g_return_val_if_fail (IS_CAL (cal), NULL);
- g_return_val_if_fail (backend != NULL, NULL);
- g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
-
- priv = cal->priv;
-
- CORBA_exception_init (&ev);
- priv->listener = CORBA_Object_duplicate (listener, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_construct: could not duplicate the listener");
- priv->listener = CORBA_OBJECT_NIL;
- CORBA_exception_free (&ev);
- return NULL;
- }
-
- CORBA_exception_free (&ev);
-
- priv->backend = backend;
-
- bonobo_object_construct (BONOBO_OBJECT (cal), corba_cal);
- return cal;
-}
-
-/**
- * cal_corba_object_create:
- * @object: #BonoboObject that will wrap the CORBA object.
- *
- * Creates and activates the CORBA object that is wrapped by the specified
- * calendar client interface @object.
- *
- * Return value: An activated object reference or #CORBA_OBJECT_NIL in case of
- * failure.
- **/
-Evolution_Calendar_Cal
-cal_corba_object_create (BonoboObject *object)
-{
- POA_Evolution_Calendar_Cal *servant;
- CORBA_Environment ev;
-
- g_return_val_if_fail (object != NULL, CORBA_OBJECT_NIL);
- g_return_val_if_fail (IS_CAL (object), CORBA_OBJECT_NIL);
-
- servant = (POA_Evolution_Calendar_Cal *) g_new0 (BonoboObjectServant, 1);
- servant->vepv = &cal_vepv;
-
- CORBA_exception_init (&ev);
- POA_Evolution_Calendar_Cal__init ((PortableServer_Servant) servant, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_corba_object_create(): could not init the servant");
- g_free (servant);
- CORBA_exception_free (&ev);
- return CORBA_OBJECT_NIL;
- }
-
- CORBA_exception_free (&ev);
- return (Evolution_Calendar_Cal) bonobo_object_activate_servant (object, servant);
-}
-
-/**
- * cal_new:
- * @backend: A calendar backend.
- * @listener: A calendar listener.
- *
- * Creates a new calendar client interface object and binds it to the specified
- * @backend and @listener objects.
- *
- * Return value: A newly-created #Cal calendar client interface object, or NULL
- * if its corresponding CORBA object could not be created.
- **/
-Cal *
-cal_new (CalBackend *backend, Evolution_Calendar_Listener listener)
-{
- Cal *cal, *retval;
- Evolution_Calendar_Cal corba_cal;
- CORBA_Environment ev;
- gboolean ret;
-
- g_return_val_if_fail (backend != NULL, NULL);
- g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
-
- cal = CAL (gtk_type_new (CAL_TYPE));
- corba_cal = cal_corba_object_create (BONOBO_OBJECT (cal));
-
- CORBA_exception_init (&ev);
- ret = CORBA_Object_is_nil ((CORBA_Object) corba_cal, &ev);
- if (ev._major != CORBA_NO_EXCEPTION || ret) {
- g_message ("cal_new(): could not create the CORBA object");
- gtk_object_unref (GTK_OBJECT (cal));
- CORBA_exception_free (&ev);
- return NULL;
- }
-
- CORBA_exception_free (&ev);
-
- retval = cal_construct (cal, corba_cal, backend, listener);
- if (!retval) {
- g_message ("cal_new(): could not construct the calendar client interface");
- gtk_object_unref (GTK_OBJECT (cal));
- return NULL;
- }
-
- return retval;
-}
diff --git a/calendar/cal.h b/calendar/cal.h
deleted file mode 100644
index b866470437..0000000000
--- a/calendar/cal.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Evolution calendar client interface object
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CAL_H
-#define CAL_H
-
-#include <libgnome/gnome-defs.h>
-#include <bonobo/bonobo-object.h>
-#include "evolution-calendar.h"
-#include "cal-common.h"
-
-BEGIN_GNOME_DECLS
-
-
-
-#define CAL_TYPE (cal_get_type ())
-#define CAL(obj) (GTK_CHECK_CAST ((obj), CAL_TYPE, Cal))
-#define CAL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_TYPE, CalClass))
-#define IS_CAL(obj) (GTK_CHECK_TYPE ((obj), CAL_TYPE))
-#define IS_CAL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_TYPE))
-
-struct _Cal {
- BonoboObject object;
-
- /* Private data */
- gpointer priv;
-};
-
-struct _CalClass {
- BonoboObjectClass parent_class;
-};
-
-GtkType cal_get_type (void);
-
-Cal *cal_construct (Cal *cal,
- Evolution_Calendar_Cal corba_cal,
- CalBackend *backend,
- Evolution_Calendar_Listener listener);
-Evolution_Calendar_Cal cal_corba_object_create (BonoboObject *object);
-
-Cal *cal_new (CalBackend *backend, Evolution_Calendar_Listener listener);
-
-POA_Evolution_Calendar_Cal__epv *cal_get_epv (void);
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/cal_struct.h b/calendar/cal_struct.h
deleted file mode 100644
index 411036c7aa..0000000000
--- a/calendar/cal_struct.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#define MAX_SZ 30
-
-enum RepeatType {
- Single,
- Days,
- Months,
- WeekDays,
- MonthDays
-};
-
-
-struct actionitem {
- char date[MAX_SZ];
- int time; /* Minutes past midnight */
-};
-
-struct event {
- struct actionitem start;
- struct actionitem end;
-
- enum RepeatType repeat;
- int repeatcount;
- char description[MAX_SZ];
- char subtype[MAX_SZ];
- GList *properties;
-};
-
diff --git a/calendar/calendar-conduit-control-applet.c b/calendar/calendar-conduit-control-applet.c
deleted file mode 100644
index 2d6fb60ef5..0000000000
--- a/calendar/calendar-conduit-control-applet.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/* Control applet ("capplet") for the gnome-pilot calendar conduit, */
-/* based on */
-/* gpilotd control applet ('capplet') for use with the GNOME control center */
-/* $Id$ */
-
-#include <pwd.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <gnome.h>
-#include <ctype.h>
-
-#include <config.h>
-#include <capplet-widget.h>
-
-#include <gpilotd/gpilotd-conduit-mgmt.h>
-#include <gpilotd/gpilotd-app.h>
-#include <gpilotd/gpilotd-app-dummy-callbacks.h>
-
-#include "calendar-conduit.h"
-
-/* tell changes callbacks to ignore changes or not */
-static gboolean ignore_changes=FALSE;
-
-/* capplet widget */
-static GtkWidget *capplet=NULL;
-
-/* host/device/pilot configuration windows */
-GtkWidget *cfgOptionsWindow=NULL;
-GtkWidget *cfgStateWindow=NULL;
-GtkWidget *dialogWindow=NULL;
-
-GnomePilotConduitMgmt *conduit;
-
-static void doTrySettings(GtkWidget *widget, gpointer);
-static void doRevertSettings(GtkWidget *widget, gpointer);
-static void doSaveSettings(GtkWidget *widget, gpointer);
-
-static void readStateCfg(GtkWidget *w,GCalConduitCfg *cfg);
-static void setStateCfg(GtkWidget *w,GCalConduitCfg *cfg);
-void about_cb (GtkWidget *, gpointer);
-GCalConduitCfg *origState = NULL;
-GCalConduitCfg *curState = NULL;
-
-gint pilotId;
-CORBA_Environment ev;
-
-/* This array must be in the same order as enumerations
- in GnomePilotConduitSyncType as they are used as index.
- Custom type implies Disabled state.
-*/
-static gchar* sync_options[] ={ N_("Disabled"),
- N_("Synchronize"),
- N_("Copy From Pilot"),
- N_("Copy To Pilot"),
- N_("Merge From Pilot"),
- N_("Merge To Pilot")};
-#define SYNC_OPTIONS_COUNT 6
-
-static void
-setSettings(GCalConduitCfg* conduitCfg)
-{
- if(conduitCfg->sync_type!=GnomePilotConduitSyncTypeCustom)
- gpilotd_conduit_mgmt_enable_with_first_sync(conduit,pilotId,
- conduitCfg->sync_type,
- conduitCfg->sync_type,
- TRUE);
- else
- gpilotd_conduit_mgmt_disable(conduit,pilotId);
-
- gcalconduit_save_configuration(conduitCfg);
-}
-
-static void
-doTrySettings(GtkWidget *widget, gpointer whatever)
-{
- readStateCfg(cfgStateWindow,curState);
- setSettings(curState);
-}
-
-static void
-doSaveSettings(GtkWidget *widget, gpointer whatever)
-{
- doTrySettings(widget,whatever);
-}
-
-static void
-doCancelSettings(GtkWidget *widget, gpointer whatever)
-{
- setSettings(origState);
-}
-
-static void
-doRevertSettings(GtkWidget *widget, gpointer whatever)
-{
- gcalconduit_destroy_configuration(&curState);
- curState = gcalconduit_dupe_configuration(origState);
- setStateCfg(cfgStateWindow,curState);
- setSettings(curState);
-}
-
-static void
-insert_dir_callback (GtkEditable *editable, const gchar *text,
- gint len, gint *position, void *data)
-{
- gint i;
- gchar *curname;
-
- curname = gtk_entry_get_text(GTK_ENTRY(editable));
- if (*curname == '\0' && len > 0) {
- if (isspace(text[0])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text");
- return;
- }
- } else {
- for (i=0; i<len; i++) {
- if (isspace(text[i])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable),
- "insert_text");
- return;
- }
- }
- }
-}
-static void
-insert_dir_callback2(GtkEditable *editable, const gchar *text,
- gint length, gint *position,
- void *data)
-{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-static void
-clist_changed(GtkWidget *widget, gpointer data)
-{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-void about_cb (GtkWidget *widget, gpointer data) {
- GtkWidget *about;
- const gchar *authors[] = {_("Eskil Heyn Olsen <deity@eskil.dk>"),NULL};
-
- about = gnome_about_new(_("GnomeCalendar Conduit"), VERSION,
- _("(C) 1998"),
- authors,
- _("Configuration utility for the calendar conduit.\n"),
- _("gnome-calendar-conduit.png"));
- gtk_widget_show (about);
-
- return;
-}
-
-static void toggled_cb(GtkWidget *widget, gpointer data) {
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-/* called by the sync_type GtkOptionMenu */
-static void
-sync_action_selection(GtkMenuShell *widget, gpointer unused)
-{
- if (!ignore_changes) {
- capplet_widget_state_changed(CAPPLET_WIDGET (capplet), TRUE);
- }
-}
-
-/* called by the sync_type GtkOptionMenu */
-static void
-activate_sync_type(GtkMenuItem *widget, gpointer data)
-{
- curState->sync_type = GPOINTER_TO_INT(data);
- if(!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-static GtkWidget
-*createStateCfgWindow(void)
-{
- GtkWidget *vbox, *table;
- GtkWidget *label;
- GtkWidget *optionMenu,*menuItem;
- GtkMenu *menu;
- gint i;
-
- vbox = gtk_vbox_new(FALSE, GNOME_PAD);
-
- table = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD);
-
- label = gtk_label_new(_("Synchronize Action"));
- gtk_box_pack_start(GTK_BOX(table), label, FALSE, FALSE, GNOME_PAD);
-
- optionMenu=gtk_option_menu_new();
- gtk_object_set_data(GTK_OBJECT(vbox), "conduit_state", optionMenu);
- menu = GTK_MENU(gtk_menu_new());
-
- for (i=0; i<SYNC_OPTIONS_COUNT;i++) {
- sync_options[i]=_(sync_options[i]);
- menuItem = gtk_menu_item_new_with_label(sync_options[i]);
- gtk_widget_show(menuItem);
- gtk_signal_connect(GTK_OBJECT(menuItem),"activate",
- GTK_SIGNAL_FUNC(activate_sync_type),
- GINT_TO_POINTER(i));
- gtk_menu_append(menu,menuItem);
- }
-
- gtk_option_menu_set_menu(GTK_OPTION_MENU(optionMenu),GTK_WIDGET(menu));
- gtk_signal_connect(GTK_OBJECT(menu), "selection-done",
- GTK_SIGNAL_FUNC(sync_action_selection),
- NULL);
-
- gtk_box_pack_start(GTK_BOX(table), optionMenu, FALSE, FALSE, 0);
-
- return vbox;
-}
-
-static void
-setStateCfg(GtkWidget *widget,GCalConduitCfg *cfg)
-{
- GtkOptionMenu *optionMenu;
- GtkMenu *menu;
-
- optionMenu = gtk_object_get_data(GTK_OBJECT(widget), "conduit_state");
- g_assert(optionMenu!=NULL);
- menu = GTK_MENU(gtk_option_menu_get_menu(optionMenu));
-
-
- ignore_changes = TRUE;
- /* Here were are relying on the items in menu being the same
- order as in GnomePilotConduitSyncType. */
- gtk_option_menu_set_history(optionMenu,(int)cfg->sync_type);
- ignore_changes = FALSE;
-}
-
-
-static void
-readStateCfg(GtkWidget *w,GCalConduitCfg *cfg)
-{
-/*
- GtkWidget *button;
-
- button = gtk_object_get_data(GTK_OBJECT(w), "conduit_on_off");
-
- g_assert(button!=NULL);
-
- activated = GTK_TOGGLE_BUTTON(button)->active;
-*/
-}
-
-static void
-pilot_capplet_setup(void)
-{
- GtkWidget *frame, *table;
-
- capplet = capplet_widget_new();
-
- table = gtk_table_new(1, 2, FALSE);
- gtk_container_border_width(GTK_CONTAINER(table), GNOME_PAD);
- gtk_container_add(GTK_CONTAINER(capplet), table);
-
- frame = gtk_frame_new(_("Conduit state"));
- gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL);
- gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1);
- cfgStateWindow = createStateCfgWindow();
- gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow);
-
- gtk_signal_connect(GTK_OBJECT(capplet), "try",
- GTK_SIGNAL_FUNC(doTrySettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "revert",
- GTK_SIGNAL_FUNC(doRevertSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "ok",
- GTK_SIGNAL_FUNC(doSaveSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "cancel",
- GTK_SIGNAL_FUNC(doCancelSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "help",
- GTK_SIGNAL_FUNC(about_cb), NULL);
-
-
- setStateCfg(cfgStateWindow,curState);
-
- gtk_widget_show_all(capplet);
-}
-
-static void
-run_error_dialog(gchar *mesg,...) {
- char tmp[80];
- va_list ap;
-
- va_start(ap,mesg);
- vsnprintf(tmp,79,mesg,ap);
- dialogWindow = gnome_message_box_new(mesg,GNOME_MESSAGE_BOX_ERROR,GNOME_STOCK_BUTTON_OK,NULL);
- gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow));
- va_end(ap);
-}
-
-gint get_pilot_id_from_gpilotd() {
- gint *pilots;
- int i;
-
- i=0;
- gpilotd_get_pilot_ids(&pilots);
- if(pilots) {
- while(pilots[i]!=-1) { g_message("pilot %d = \"%d\"",i,pilots[i]); i++; }
- if(i==0) {
- run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
- return -1;
- } else {
- if(i==1)
- return pilots[0];
- else {
- g_message("too many pilots...");
- return pilots[0];
- }
- }
- } else {
- run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
- return -1;
- }
-}
-
-int
-main( int argc, char *argv[] )
-{
- /* we're a capplet */
- gnome_capplet_init ("calendar conduit control applet", NULL, argc, argv,
- NULL,
- 0, NULL);
-
- /* get pilot name from gpilotd */
- /* 1. initialize the gpilotd connection */
- if (gpilotd_init(&argc,argv)!=0) {
- run_error_dialog(_("Cannot initialze the GnomePilot Daemon"));
- g_error(_("Cannot initialze the GnomePilot Daemon"));
- return -1;
- }
-
- /* 2 connect to gpilotd */
- if (gpilotd_connect()!=0) {
- run_error_dialog(_("Cannot connect to the GnomePilot Daemon"));
- g_error(_("Cannot connect to the GnomePilot Daemon"));
- return -1;
- }
-
- pilotId = get_pilot_id_from_gpilotd();
- if(!pilotId) return -1;
-
- /* put all code to set things up in here */
- conduit = gpilotd_conduit_mgmt_new("calendar_conduit",pilotId);
- gcalconduit_load_configuration(&origState,pilotId);
- gpilotd_conduit_mgmt_get_sync_type(conduit,pilotId,&origState->sync_type);
-
- curState = gcalconduit_dupe_configuration(origState);
-
- pilot_capplet_setup();
-
-
- /* done setting up, now run main loop */
- capplet_gtk_main();
- return 0;
-}
diff --git a/calendar/calendar-conduit-control-applet.desktop b/calendar/calendar-conduit-control-applet.desktop
deleted file mode 100644
index 43c429ef97..0000000000
--- a/calendar/calendar-conduit-control-applet.desktop
+++ /dev/null
@@ -1,7 +0,0 @@
-[Desktop Entry]
-Name=GnomeCalendar
-Comment=Configure the GnomeCal conduit
-Exec=calendar-conduit-control-applet --cap-id=1
-Terminal=0
-Type=Application
-Icon=gnome-calendar-conduit.png
diff --git a/calendar/calendar-conduit.c b/calendar/calendar-conduit.c
deleted file mode 100644
index 9c758b3263..0000000000
--- a/calendar/calendar-conduit.c
+++ /dev/null
@@ -1,1416 +0,0 @@
-/* $Id$ */
-
-#include <glib.h>
-#include <gnome.h>
-
-#include <pi-source.h>
-#include <pi-socket.h>
-#include <pi-file.h>
-#include <pi-dlp.h>
-#include <pi-version.h>
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <utime.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <signal.h>
-#include <errno.h>
-
-#include <libgnorba/gnorba.h>
-#include <libgnorba/gnome-factory.h>
-
-#include <gpilotd/gnome-pilot-conduit.h>
-#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
-
-#include "GnomeCal.h"
-#include "calobj.h"
-#include "calendar.h"
-#include "timeutil.h"
-
-#include "calendar-conduit.h"
-
-int debug_alarms = 0; /* needed to satisfy some other part of gncal */
-/* Default values for alarms */ /* needed to satisfy some other part of gncal */
-CalendarAlarm alarm_defaults[4] = {
- { ALARM_MAIL, 0, 15, ALARM_MINUTES },
- { ALARM_PROGRAM, 0, 15, ALARM_MINUTES },
- { ALARM_DISPLAY, 0, 15, ALARM_MINUTES },
- { ALARM_AUDIO, 0, 15, ALARM_MINUTES }
-};
-
-GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
-void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
-void local_record_from_icalobject(GCalLocalRecord *local,iCalObject *obj);
-
-#define CONDUIT_VERSION "0.8.11"
-#ifdef G_LOG_DOMAIN
-#undef G_LOG_DOMAIN
-#endif
-#define G_LOG_DOMAIN "gcalconduit"
-
-#define DEBUG_CALCONDUIT
-#undef DEBUG_CALCONDUIT
-
-#ifdef DEBUG_CALCONDUIT
-#define show_exception(e) g_warning ("Exception: %s\n", CORBA_exception_id (e))
-#define LOG(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e)
-#else
-#define show_exception(e)
-#define LOG(e...)
-#endif
-
-#define WARN(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING, e)
-#define INFO(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e)
-
-#define catch_ret_val(_env,ret) \
- if (_env._major != CORBA_NO_EXCEPTION) { \
- g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE,"%s:%d: Caught exception",__FILE__,__LINE__); \
- g_warning ("Exception: %s\n", CORBA_exception_id (&(_env))); \
- CORBA_exception_free(&(_env)); \
- return ret; \
- }
-
-static int
-start_calendar_server (GnomePilotConduitStandardAbs *conduit,
- GCalConduitContext *ctxt)
-{
-
- g_return_val_if_fail(conduit!=NULL,-2);
- g_return_val_if_fail(ctxt!=NULL,-2);
-
- ctxt->calendar = goad_server_activate_with_id (NULL,
- "IDL:GNOME:Calendar:Repository:1.0",
- 0, NULL);
- if (ctxt->calendar == CORBA_OBJECT_NIL) {
- g_warning ("Can not communicate with GnomeCalendar server");
- return -1;
- }
-
- if (ctxt->ev._major != CORBA_NO_EXCEPTION){
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- }
- return 0;
-}
-
-
-/* Just a stub to link with */
-void
-calendar_notify (time_t time, CalendarAlarm *which, void *data)
-{
-}
-
-static GSList *
-get_calendar_objects(GnomePilotConduitStandardAbs *conduit,
- gboolean *status,
- GCalConduitContext *ctxt)
-{
- GSList *result;
- GNOME_Calendar_Repository_String_Sequence *uids;
-
- g_return_val_if_fail(conduit!=NULL,NULL);
- g_return_val_if_fail(ctxt!=NULL,NULL);
-
- result = NULL;
- uids = GNOME_Calendar_Repository_get_object_id_list (ctxt->calendar, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- if(status!=NULL) (*status) = FALSE;
- return NULL;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- if(status!=NULL) (*status) = FALSE;
- return NULL;
- }
-
- if(status!=NULL) (*status) = TRUE;
- if(uids->_length>0) {
- int i;
- for(i=0;i<uids->_length;i++) {
- result = g_slist_prepend(result,g_strdup(uids->_buffer[i]));
- }
- } else {
- INFO ("No entries found");
- }
-
- CORBA_free(uids);
-
- return result;
-}
-
-static void
-local_record_from_ical_uid(GCalLocalRecord *local,
- char *uid,
- GCalConduitContext *ctxt)
-{
- iCalObject *obj;
- char *vcalendar_string;
-
- g_assert(local!=NULL);
-
- vcalendar_string = GNOME_Calendar_Repository_get_object(ctxt->calendar, uid, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- }
- g_return_if_fail(vcalendar_string!=NULL);
-
- obj = ical_object_new_from_string (vcalendar_string);
-
- local_record_from_icalobject(local,obj);
-
- return;
-}
-
-
-/*
- * converts a iCalObject to a GCalLocalRecord
- */
-
-void
-local_record_from_icalobject(GCalLocalRecord *local,
- iCalObject *obj)
-{
- g_return_if_fail(local!=NULL);
- g_return_if_fail(obj!=NULL);
-
- local->ical = obj;
- local->local.ID = local->ical->pilot_id;
-
-/*
- LOG ("local->Id = %ld [%s], status = %d",
- local->local.ID,obj->summary,local->ical->pilot_status);
-*/
- switch(local->ical->pilot_status) {
- case ICAL_PILOT_SYNC_NONE:
- local->local.attr = GnomePilotRecordNothing;
- break;
- case ICAL_PILOT_SYNC_MOD:
- local->local.attr = GnomePilotRecordModified;
- break;
- case ICAL_PILOT_SYNC_DEL:
- local->local.attr = GnomePilotRecordDeleted;
- break;
- }
-
- /* Records without a pilot_id are new */
- if(local->local.ID == 0)
- local->local.attr = GnomePilotRecordNew;
-
- local->local.secret = 0;
- if(obj->class!=NULL)
- if(strcmp(obj->class,"PRIVATE")==0)
- local->local.secret = 1;
-
- local->local.archived = 0;
-}
-
-/*
- * Given a PilotRecord, find the matching record in
- * the calendar repository. If no match, return NULL
- */
-static GCalLocalRecord *
-find_record_in_repository(GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- char *vcal_string;
- GCalLocalRecord *loc;
-
- g_return_val_if_fail(conduit!=NULL,NULL);
- g_return_val_if_fail(remote!=NULL,NULL);
-
- LOG ("requesting %ld", remote->ID);
-
- vcal_string =
- GNOME_Calendar_Repository_get_object_by_pilot_id (ctxt->calendar, remote->ID, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return NULL;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return NULL;
- } else {
- LOG ("Found");
- loc = g_new0(GCalLocalRecord,1);
- /* memory allocated in new_from_string is freed in free_match */
- local_record_from_icalobject(loc,
- ical_object_new_from_string (vcal_string));
- /* g_free(vcal_string); FIXME: this coredumps, but won't it leak without ? */
- return loc;
- }
-
- return NULL;
-}
-
-/*
- * updates an given iCalObject in the repository
- */
-static void
-update_calendar_entry_in_repository(GnomePilotConduitStandardAbs *conduit,
- iCalObject *obj,
- GCalConduitContext *ctxt)
-{
- char *str;
-
- g_return_if_fail(conduit!=NULL);
- g_return_if_fail(obj!=NULL);
-
- str = calendar_string_from_object (obj);
-
- GNOME_Calendar_Repository_update_object (ctxt->calendar, obj->uid, str, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- }
-
- free (str);
-}
-
-static iCalObject *
-ical_from_remote_record(GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- iCalObject *in_obj)
-{
- iCalObject *obj;
- int i;
- struct Appointment a;
- time_t now;
-
- now = time (NULL);
-
- g_return_val_if_fail(remote!=NULL,NULL);
- memset(&a,0,sizeof(struct Appointment));
- unpack_Appointment(&a,remote->record,remote->length);
-
- if (in_obj == NULL)
- obj = ical_new (a.note ? a.note : "",
- g_get_user_name (),
- a.description ? a.description : "");
- else
- obj = in_obj;
-
- if (a.note) {
- g_free(obj->comment);
- obj->comment = g_strdup(a.note);
- }
- if (a.description) {
- g_free(obj->summary);
- obj->summary = g_strdup(a.description);
- }
-
- obj->created = now;
- obj->last_mod = now;
- obj->priority = 0;
- obj->transp = 0;
- obj->related = NULL;
- obj->pilot_id = remote->ID;
- obj->pilot_status = ICAL_PILOT_SYNC_NONE;
-
- /*
- * Begin and end
- */
-
- if (a.event)
- {
- /* turn day-long events into a full day's appointment
- FIXME: get settings from gnomecal */
- a.begin.tm_sec = 0;
- a.begin.tm_min = 0;
- a.begin.tm_hour = 0;
-
- a.end.tm_sec = 0;
- a.end.tm_min =59;
- a.end.tm_hour = 23;
- }
-
- obj->dtstart = mktime (&a.begin);
- obj->dtend = mktime (&a.end);
-
- /* Special case: daily repetitions are converted to a multi-day event */
- /* This sucketh, a pilot event scheduled for dailyRepeat, freq 1, end on
- whatever is cleary converted wrong
- if (a.repeatType == repeatDaily){
- time_t newt = time_add_day (obj->dtend, a.repeatFrequency);
-
- obj->dtend = newt;
- }
- */
-
- /*
- * Alarm
- */
- if (a.alarm){
- obj->aalarm.type = ALARM_AUDIO;
- obj->aalarm.enabled = 1;
- obj->aalarm.count = a.advance;
-
- switch (a.advanceUnits){
- case advMinutes:
- obj->aalarm.units = ALARM_MINUTES;
- break;
-
- case advHours:
- obj->aalarm.units = ALARM_HOURS;
- break;
-
- case advDays:
- obj->aalarm.units = ALARM_DAYS;
- break;
- default:
- }
- }
-
- /*
- * Recurrence
- */
- if (a.repeatFrequency){
- obj->recur = g_new0 (Recurrence, 1);
-
- switch (a.repeatType){
- case repeatDaily:
- /*
- * In the Pilot daily repetitions are actually
- * multi-day events
- */
- obj->recur->type = RECUR_DAILY;
- break;
-
- case repeatMonthlyByDate:
- obj->recur->type = RECUR_MONTHLY_BY_DAY;
- obj->recur->u.month_day = a.repeatFrequency;
- break;
-
- case repeatWeekly:
- {
- int wd;
-
- obj->recur->type = RECUR_WEEKLY;
- for (wd = 0; wd < 7; wd++)
- if (a.repeatDays [wd])
- obj->recur->weekday |= 1 << wd;
-
- if (obj->recur->weekday == 0){
- struct tm tm = *localtime (&obj->dtstart);
-
- obj->recur->weekday = 1 << tm.tm_wday;
- }
- break;
- }
-
- case repeatMonthlyByDay:
- obj->recur->type = RECUR_MONTHLY_BY_POS;
- obj->recur->u.month_pos = a.repeatFrequency;
- obj->recur->weekday = (a.repeatDay / 7);
- break;
-
- case repeatYearly:
- obj->recur->type = RECUR_YEARLY_BY_DAY;
- break;
-
- default:
- g_assert_not_reached();
- }
-
- if (a.repeatForever)
- obj->recur->duration = 0;
- else
- obj->recur->_enddate = mktime (&a.repeatEnd);
-
- obj->recur->interval = a.repeatFrequency;
- }
-
- /*
- * Load exception dates
- */
- obj->exdate = NULL;
- for (i = 0; i < a.exceptions; i++){
- time_t *t = g_new (time_t, 1);
-
- *t = mktime (&(a.exception [i]));
- obj->exdate = g_list_prepend (obj->exdate, t);
- }
-
- g_free (obj->class);
-
- if (remote->attr & dlpRecAttrSecret)
- obj->class = g_strdup ("PRIVATE");
- else
- obj->class = g_strdup ("PUBLIC");
-
-
- free_Appointment(&a);
-
- return obj;
-}
-
-/* Code blatantly stolen from
- * calendar-pilot-sync.c:
- *
- * (C) 1999 International GNOME Support
- *
- * Author:
- * Miguel de Icaza (miguel@gnome-support.com)
- *
- */
-static gint
-update_record (GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- char *vcal_string;
- iCalObject *obj;
- struct Appointment a;
-
- g_return_val_if_fail(remote!=NULL,-1);
-
- memset(&a,0,sizeof(struct Appointment));
- unpack_Appointment(&a,remote->record,remote->length);
-
- obj = ical_new (a.note ? a.note : "",
- g_get_user_name (),
- a.description ? a.description : "");
-
- LOG ("requesting %ld [%s]", remote->ID, a.description);
- vcal_string = GNOME_Calendar_Repository_get_object_by_pilot_id (ctxt->calendar, remote->ID, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- LOG ("Object did not exist, creating a new one");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- ical_from_remote_record(conduit,remote,obj);
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- ical_object_destroy (obj);
- free_Appointment(&a);
- return -1;
- } else {
- LOG ("Found");
- ical_object_destroy (obj);
- obj = ical_object_new_from_string (vcal_string);
- ical_from_remote_record(conduit,remote,obj);
- CORBA_free(vcal_string);
- }
-
- /* update record on server */
-
- update_calendar_entry_in_repository(conduit,obj,ctxt);
-
- /*
- * Shutdown
- */
- ical_object_destroy (obj);
- free_Appointment(&a);
-
- return 0;
-}
-
-static void
-check_for_slow_setting(GnomePilotConduit *c,
- GCalConduitContext *ctxt)
-{
- CORBA_long entry_number;
- entry_number =
- GNOME_Calendar_Repository_get_number_of_objects(ctxt->calendar,
- GNOME_Calendar_Repository_ANY,
- &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- } else {
- LOG (_("Calendar holds %d entries"),entry_number);
- /* If the local base is empty, do a slow sync */
- if ( entry_number <= 0) {
- gnome_pilot_conduit_standard_set_slow(GNOME_PILOT_CONDUIT_STANDARD(c));
- }
- }
-}
-
-static gint
-pre_sync(GnomePilotConduit *c,
- GnomePilotDBInfo *dbi,
- GCalConduitContext *ctxt)
-{
- int l;
- gint num_records;
- unsigned char *buf;
-
- g_message ("GnomeCal Conduit v.%s",CONDUIT_VERSION);
-
- ctxt->calendar = CORBA_OBJECT_NIL;
-
- if (start_calendar_server(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),ctxt) != 0) {
- WARN(_("Could not start gnomecal server"));
- gnome_pilot_conduit_error(GNOME_PILOT_CONDUIT(c),
- _("Could not start gnomecal server"));
- return -1;
- }
-
- /* Set the counters for the progress bar crap */
- num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_ANY, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
- num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_MODIFIED, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_updated_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
- num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_NEW, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_new_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
- num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_DELETED, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_deleted_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
-
- gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi);
-
- /* load_records(c); */
-
- buf = (unsigned char*)g_malloc(0xffff);
- if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff)) < 0) {
- WARN(_("Could not read pilot's DateBook application block"));
- WARN("dlp_ReadAppBlock(...) = %d",l);
- gnome_pilot_conduit_error(GNOME_PILOT_CONDUIT(c),
- _("Could not read pilot's DateBook application block"));
- return -1;
- }
- unpack_AppointmentAppInfo(&(ctxt->ai),buf,l);
- g_free(buf);
-
- check_for_slow_setting(c,ctxt);
-
- return 0;
-}
-
-/**
- * Find (if possible) the local record which matches
- * the given PilotRecord.
- * if successfull, return non-zero and set *local to
- * a non-null value (the located local record),
- * otherwise return 0 and set *local = NULL;
- */
-
-static gint
-match_record (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord **local,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- LOG ("in match_record");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
-
- *local = find_record_in_repository(conduit,remote,ctxt);
-
- if (*local==NULL) return -1;
- return 0;
-}
-
-/**
- * Free the data allocated by a previous match_record call.
- * If successfull, return non-zero and ser *local=NULL, otherwise
- * return 0.
- */
-static gint
-free_match (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord **local,
- GCalConduitContext *ctxt)
-{
- LOG ("entering free_match");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(*local!=NULL,-1);
-
- ical_object_destroy (GCAL_LOCALRECORD(*local)->ical);
- g_free(*local);
-
- *local = NULL;
- return 0;
-}
-
-/*
- Move to archive and set status to Nothing
- */
-static gint
-archive_local (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- GCalConduitContext *ctxt)
-{
- LOG ("entering archive_local");
-
- g_return_val_if_fail(local!=NULL,-1);
-
- return -1;
-}
-
-/*
- Store in archive and set status to Nothing
- */
-static gint
-archive_remote (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- LOG ("entering archive_remote");
-
- g_return_val_if_fail(remote!=NULL,-1);
- g_return_val_if_fail(local!=NULL,-1);
-
- return -1;
-}
-
-/*
- Store and set status to Nothing
- */
-static gint
-store_remote (GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- LOG ("entering store_remote");
-
- g_return_val_if_fail(remote!=NULL,-1);
- remote->attr = GnomePilotRecordNothing;
-
- return update_record(conduit,remote,ctxt);
-}
-
-static gint
-clear_status_archive_local (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- GCalConduitContext *ctxt)
-{
- LOG ("entering clear_status_archive_local");
-
- g_return_val_if_fail(local!=NULL,-1);
-
- return -1;
-}
-
-static gint
-iterate (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord **local,
- GCalConduitContext *ctxt)
-{
- static GSList *events,*iterator;
- static int hest;
-
- g_return_val_if_fail(local!=NULL,-1);
-
- if(*local==NULL) {
- LOG ("beginning iteration");
-
- events = get_calendar_objects(conduit,NULL,ctxt);
- hest = 0;
-
- if(events!=NULL) {
- LOG ("iterating over %d records",g_slist_length(events));
- *local = g_new0(GCalLocalRecord,1);
-
- local_record_from_ical_uid(*local,(gchar*)events->data,ctxt);
- iterator = events;
- } else {
- LOG ("no events");
- (*local) = NULL;
- }
- } else {
- /*LOG ("continuing iteration");*/
- hest++;
- if(g_slist_next(iterator)==NULL) {
- GSList *l;
-
- LOG ("ending");
- /** free stuff allocated for iteration */
- g_free((*local));
-
- LOG ("iterated over %d records",hest);
- for(l=events;l;l=l->next)
- g_free(l->data);
-
- g_slist_free(events);
-
- /* ends iteration */
- (*local) = NULL;
- return 0;
- } else {
- iterator = g_slist_next(iterator);
- local_record_from_ical_uid(*local,(gchar*)(iterator->data),ctxt);
- }
- }
- return 1;
-}
-
-static gint
-iterate_specific (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord **local,
- gint flag,
- gint archived,
- GCalConduitContext *ctxt)
-{
-#ifdef DEBUG_CALCONDUIT
- {
- gchar *tmp;
- switch (flag) {
- case GnomePilotRecordNothing: tmp = g_strdup("RecordNothing"); break;
- case GnomePilotRecordModified: tmp = g_strdup("RecordModified"); break;
- case GnomePilotRecordNew: tmp = g_strdup("RecordNew"); break;
- default: tmp = g_strdup_printf("0x%x",flag); break;
- }
- LOG ("entering iterate_specific(flag = %s)",tmp);
- g_free(tmp);
- }
-#endif
- g_return_val_if_fail(local!=NULL,-1);
-
- /* iterate until a record meets the criteria */
- while(gnome_pilot_conduit_standard_abs_iterate(conduit,(LocalRecord**)local)) {
- if((*local)==NULL) break;
- if(archived && ((*local)->local.archived==archived)) break;
- if(((*local)->local.attr == flag)) break;
- }
-
- return (*local)==NULL?0:1;
-}
-
-static gint
-purge (GnomePilotConduitStandardAbs *conduit,
- GCalConduitContext *ctxt)
-{
- LOG ("entering purge");
-
-
- /* HEST, gem posterne her */
-
- return -1;
-}
-
-static gint
-set_status (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- gint status,
- GCalConduitContext *ctxt)
-{
- LOG ("entering set_status(status=%d)",status);
-
- g_return_val_if_fail(local!=NULL,-1);
-
- g_assert(local->ical!=NULL);
-
- local->local.attr = status;
- switch(status) {
- case GnomePilotRecordPending:
- case GnomePilotRecordNothing:
- local->ical->pilot_status = ICAL_PILOT_SYNC_NONE;
- break;
- case GnomePilotRecordDeleted:
- break;
- case GnomePilotRecordNew:
- case GnomePilotRecordModified:
- local->ical->pilot_status = ICAL_PILOT_SYNC_MOD;
- break;
- }
-
- if ( status == GnomePilotRecordDeleted) {
- GNOME_Calendar_Repository_delete_object(ctxt->calendar,local->ical->uid,&(ctxt->ev));
- } else {
- GNOME_Calendar_Repository_update_pilot_id(ctxt->calendar,
- local->ical->uid,
- local->local.ID,
- local->ical->pilot_status,
- &(ctxt->ev));
- }
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- LOG ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- }
- return 0;
-}
-
-static gint
-set_archived (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- gint archived,
- GCalConduitContext *ctxt)
-{
- LOG ("entering set_archived");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_assert(local->ical!=NULL);
-
- local->local.archived = archived;
- update_calendar_entry_in_repository(conduit,local->ical,ctxt);
- /* FIXME: This should move the entry into a speciel
- calendar file, eg. Archive, or (by config option), simply
- delete it */
- return 0;
-}
-
-static gint
-set_pilot_id (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- guint32 ID,
- GCalConduitContext *ctxt)
-{
- LOG ("entering set_pilot_id(id=%d)",ID);
-
- g_return_val_if_fail(local!=NULL,-1);
- g_assert(local->ical!=NULL);
-
- local->local.ID = ID;
- local->ical->pilot_id = ID;
- GNOME_Calendar_Repository_update_pilot_id(ctxt->calendar,
- local->ical->uid,
- local->local.ID,
- local->ical->pilot_status,
- &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- LOG ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- }
- return 0;
-}
-
-static gint
-transmit (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord **remote,
- GCalConduitContext *ctxt)
-{
- PilotRecord *p;
- int daycount;
-
- LOG ("entering transmit");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
- g_assert(local->ical!=NULL);
-
- p = g_new0(PilotRecord,1);
-
- p->ID = local->local.ID;
- p->attr = local->local.attr;
- p->archived = local->local.archived;
- p->secret = local->local.secret;
-
- local->a = g_new0(struct Appointment,1);
-
- local->a->event = 0; /* if no start time, leave at 1 */
- local->a->begin = *localtime(&local->ical->dtstart);
- local->a->end = *localtime(&local->ical->dtend);
-
- /* set the Audio Alarm parameters */
- if(local->ical->aalarm.enabled) {
- local->a->alarm = 1;
- local->a->advance = local->ical->aalarm.count;
- switch(local->ical->aalarm.units) {
- case ALARM_MINUTES:
- local->a->advanceUnits = advMinutes;
- break;
- case ALARM_HOURS:
- local->a->advanceUnits = advHours;
- break;
- case ALARM_DAYS:
- local->a->advanceUnits = advDays;
- break;
- }
- } else {
- local->a->alarm = 0;
- local->a->advance = 0;
- local->a->advanceUnits = advMinutes;
- }
-
- /* set the recurrence parameters */
- if (local->ical->recur != NULL) {
- switch (local->ical->recur->type) {
- case RECUR_DAILY:
- local->a->repeatType = repeatDaily;
- break;
- case RECUR_WEEKLY:
- local->a->repeatType = repeatWeekly;
- break;
- case RECUR_MONTHLY_BY_POS:
- local->a->repeatType = repeatMonthlyByDate;
- break;
- case RECUR_MONTHLY_BY_DAY:
- local->a->repeatType = repeatMonthlyByDay;
- break;
- case RECUR_YEARLY_BY_MONTH:
- local->a->repeatType = repeatYearly;
- break;
- case RECUR_YEARLY_BY_DAY:
- local->a->repeatType = repeatYearly;
- break;
- }
- if (local->ical->recur->duration == 0) {
- local->a->repeatForever = 1;
- } else {
- local->a->repeatForever = 0;
- local->a->repeatEnd = *localtime(&local->ical->recur->_enddate);
- }
- local->a->repeatFrequency = local->ical->recur->interval;
-
-
- for ( daycount=0; daycount<7; daycount++ ) {
- if (local->ical->recur->weekday & (1 << daycount))
- local->a->repeatDays[daycount] = 1;
- }
- } else {
- local->a->repeatType = repeatNone;
- local->a->repeatForever = 0;
- local->a->repeatEnd = local->a->end;
- local->a->repeatFrequency = 0;
- local->a->repeatDay = dom1stSun;
- local->a->repeatDays[0] = 0;
- local->a->repeatDays[1] = 0;
- local->a->repeatDays[2] = 0;
- local->a->repeatDays[3] = 0;
- local->a->repeatDays[4] = 0;
- local->a->repeatDays[5] = 0;
- local->a->repeatDays[6] = 0;
- local->a->repeatWeekstart = 0;
- local->a->exceptions = 0;
- local->a->exception = NULL;
- }
-
- /* STOP: don't replace these with g_strdup, since free_Appointment
- uses free to deallocte */
- local->a->note =
- local->ical->comment==NULL?NULL:strdup(local->ical->comment);
- local->a->description =
- local->ical->summary==NULL?NULL:strdup(local->ical->summary);
-
- /* Generate pilot record structure */
- p->record = g_new0(char,0xffff);
- p->length = pack_Appointment(local->a,p->record,0xffff);
-
-#if 0
- /* This is some debug code that hexdumps the calendar entry...
- You won't need this. */
- {
- int x,y;
- g_message("calconduit: new item from %s to %s",asctime(&(local->a->begin)),asctime(&(local->a->end)));
-
- g_message("local->a->note = %s",local->a->note);
- g_message("local->a->description = %s",local->a->description);
- g_message("sizeof(p->record) = %d, length is %d",sizeof(p->record),p->length);
- for(x=0;x<p->length;x+=32) {
- for(y=x;y<x+32;y++)
- if(p->record[y]<33 || p->record[y]>128)
- printf("%02X",p->record[y]);
- else
- printf(" %c",p->record[y]);
- printf("\n");
- }
- }
-#endif
-
- *remote = p;
-
- return 0;
-}
-
-static gint
-free_transmit (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord **remote,
- GCalConduitContext *ctxt)
-{
- LOG ("entering free_transmit");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
-
- free_Appointment(local->a);
- g_free((*remote)->record);
- *remote = NULL;
- return 0;
-}
-
-static gint
-compare (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- /* used by the quick compare */
- PilotRecord *remoteOfLocal;
- int err;
- int retval;
-
- /* used by the tedious compare */
- struct Appointment a;
- int daycount;
-
- g_message ("entering compare");
-
- g_return_val_if_fail (local!=NULL,-1);
- g_return_val_if_fail (remote!=NULL,-1);
-#if 1
- err = transmit(conduit,local,&remoteOfLocal,ctxt);
- if (err != 0) return err;
-
- retval = 0;
- if (remote->length == remoteOfLocal->length) {
- if (memcmp(remoteOfLocal->record,remote->record,remote->length)!=0) {
- g_message("compare failed on contents");
- retval = 1;
- }
- } else {
- g_message("compare failed on length");
- retval = 1;
- }
-
- free_transmit(conduit,local,&remoteOfLocal,ctxt);
- return retval;
-
-#else
- /** FIXME: All the { LOG("yadayada"); return 1; } bloat is for debug purposes.
- Once this is known to work, compact to return 1;'s */
-
- /* Check record attributes */
- if (local->local.ID != remote->ID) {
- LOG("failed local->local.ID == remote->ID");
- return 1;
- }
- if (local->local.attr != remote->attr) {
- LOG("failed local->local.attr == remote->attr");
- return 1;
- }
- if (local->local.archived != remote->archived) {
- LOG("failed local->local.archived == remote->archived");
- return 1;
- }
- if (local->local.secret != remote->secret) {
- LOG("failed local->local.secret == remote->secret");
- return 1;
- }
-
- unpack_Appointment(&a,remote->record,remote->length);
-
- /* Check records begin/end time */
- if (a.event==0) {
-/* FIXME
- if (a.begin != *localtime(&local->ical->dtstart)) {
- LOG("a.begin == *localtime(&local->ical->dtstart)");
- return 1;
- }
- if (a.end != *localtime(&local->ical->dtend)) {
- LOG("a.end == *localtime(&local->ical->dtend)");
- return 1;
- }
-*/
- } else {
- LOG("failed local->a.event != 0, unsupported by gnomecal");
- return 1;
- }
-
- /* Check records alarm settings */
- if(a.alarm == 1) {
- if (local->ical->aalarm.enabled == 1) {
- if (a.advance != local->ical->aalarm.count) {
- LOG("failed a.advance == local->ical->aalarm.count");
- return 1;
- }
- switch(local->ical->aalarm.units) {
- case ALARM_MINUTES:
- if (a.advanceUnits != advMinutes) {
- LOG("failed local->ical->aalarm.units == a.advanceUnits");
- return 1;
- }
- break;
- case ALARM_HOURS:
- if (a.advanceUnits != advHours) {
- LOG("failed local->ical->aalarm.units == a.advanceUnits");
- return 1;
- }
- break;
- case ALARM_DAYS:
- if (a.advanceUnits != advDays) {
- LOG("failed local->ical->aalarm.units == a.advanceUnits");
- return 1;
- }
- break;
- }
- } else {
- LOG("failed a.alarm == 1 && local->ical->aalarm.enabled == 1");
- return 1;
- }
- } else if (local->ical->aalarm.enabled == 1) {
- LOG("failed a.alarm != 1 && local->ical->aalarm.enabled != 1");
- return 1;
- }
-
- /* Check records recurrence settings */
- /* If this code is broken, a more or less safe although not efficient
- approach is (other the fixing the bug), if either has recurrence,
- return 1, thus failing the comparision */
- if (local->ical->recur != NULL) {
- if (a.repeatType == repeatNone) {
- LOG("failed: local->ical->recur != NULL && a.repeatType != repeatNone");
- return 1;
- }
- switch (local->ical->recur->type) {
- case RECUR_DAILY:
- if (a.repeatType != repeatDaily) {
- LOG("failed a.repeatType == repeatDaily");
- return 1; }
- break;
- case RECUR_WEEKLY:
- if (a.repeatType != repeatWeekly) {
- LOG("failed a.repeatType == repeatWeekly");
- return 1; }
- break;
- case RECUR_MONTHLY_BY_POS:
- if (a.repeatType != repeatMonthlyByDate) {
- LOG("failed a.repeatType == repeatMonthlyByDate");
- return 1; }
- break;
- case RECUR_MONTHLY_BY_DAY:
- if (a.repeatType != repeatMonthlyByDay) {
- LOG("failed a.repeatType == repeatMonthlyByDay");
- return 1; }
- break;
- case RECUR_YEARLY_BY_MONTH:
- if (a.repeatType != repeatYearly) {
- LOG("failed a.repeatType == repeatYearly");
- return 1; }
- break;
- case RECUR_YEARLY_BY_DAY:
- if (a.repeatType != repeatYearly) {
- LOG("failed a.repeatType == repeatYearly");
- return 1; }
- break;
- }
- if (local->ical->recur->duration == 0) {
- if(a.repeatForever != 1) {
- LOG("failed local->ical->recur->duration == 0 && a.repeatForever == 1");
- return 1;
- }
- } else {
- if(a.repeatForever != 0) {
- LOG("failed local->ical->recur->duration != 0 && ! a.repeatForever == 0");
- return 1;
- }
-/* FIXME
- if(a.repeatEnd != *localtime(&local->ical->recur->_enddate)) {
- LOG("failed a.repeatEnd == *localtime(&local->ical->recur->_enddate)");
- return 1;
- }
-*/
- }
- if (a.repeatFrequency != local->ical->recur->interval) {
- LOG("failed a.repeatFrequency == local->ical->recur->interval");
- return 1;
- }
- for (daycount = 0; daycount<7; daycount++) {
- if(local->ical->recur->weekday & (1<<daycount)) {
- if (a.repeatDays[daycount]!=1) {
- LOG("failed local->ical->recur->weekday & (1<<daycount) && a.repeatDays[daycount]==1");
- return 1;
- }
- } else {
- if (a.repeatDays[daycount]!=0) {
- LOG("failed local->ical->recur->weekday &! (1<<daycount) && a.repeatDays[daycount]==0");
- return 1;
- }
- }
- }
- } else if (a.repeatType != repeatNone ) {
- LOG("failed: local->ical->recur == NULL && a.repeatType == repeatNone");
- return 1;
- }
-
- /* check the note and description */
- if(a.note!=NULL) {
- if(local->ical->comment==NULL) {
- LOG("failed a.note != NULL && local->ical->coment != NULL");
- return 1;
- }
- if(strcmp(local->ical->comment,a.note)!=0) {
- LOG("failed strcmp(local->ical->comment,a.note)==0");
- return 1;
- }
- } if(local->ical->comment!=NULL) {
- LOG("failed a.note == NULL && local->ical->coment == NULL");
- return 1;
- }
- if(a.description!=NULL) {
- if(local->ical->summary==NULL) {
- LOG("failed a.description != NULL && local->ical->coment != NULL");
- return 1;
- }
- if(strcmp(local->ical->summary,a.description)!=0) {
- LOG("failed strcmp(local->ical->summary,a.description)==0");
- return 1;
- }
- } if(local->ical->summary!=NULL) {
- LOG("failed a.description == NULL && local->ical->coment == NULL");
- return 1;
- }
-#endif
- return 0;
-}
-
-static gint
-compare_backup (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- LOG ("entering compare_backup");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
-
- return -1;
-}
-
-static gint
-delete_all (GnomePilotConduitStandardAbs *conduit,
- GCalConduitContext *ctxt)
-{
- GSList *events,*it;
- gboolean error;
-
- events = get_calendar_objects(conduit,&error,ctxt);
-
- if (error == FALSE) return -1;
- for (it=events;it;it = g_slist_next(it)) {
- GNOME_Calendar_Repository_delete_object(ctxt->calendar,
- it->data,
- &(ctxt->ev));
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- /* destroy loop, free data */
- for (it=events;it;it = g_slist_next(it)) g_free(it->data);
- g_slist_free(events);
- return -1;
- }
- g_free(it->data);
- }
- g_slist_free(events);
- return -1;
-}
-
-GnomePilotConduit *
-conduit_get_gpilot_conduit (guint32 pilotId)
-{
- GtkObject *retval;
- GCalConduitCfg *cfg;
- GCalConduitContext *ctxt;
-
-
- retval = gnome_pilot_conduit_standard_abs_new ("DatebookDB", 0x64617465);
- g_assert (retval != NULL);
- gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"GnomeCalConduit");
-
- gcalconduit_load_configuration(&cfg,pilotId);
- gtk_object_set_data(retval,"gcalconduit_cfg",cfg);
-
- gcalconduit_new_context(&ctxt,cfg);
- gtk_object_set_data(GTK_OBJECT(retval),"gcalconduit_context",ctxt);
-
- gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, ctxt);
- gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt);
- gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, ctxt);
- gtk_signal_connect (retval, "archive_remote", (GtkSignalFunc) archive_remote, ctxt);
- gtk_signal_connect (retval, "store_remote", (GtkSignalFunc) store_remote, ctxt);
- gtk_signal_connect (retval, "clear_status_archive_local", (GtkSignalFunc) clear_status_archive_local, ctxt);
- gtk_signal_connect (retval, "iterate", (GtkSignalFunc) iterate, ctxt);
- gtk_signal_connect (retval, "iterate_specific", (GtkSignalFunc) iterate_specific, ctxt);
- gtk_signal_connect (retval, "purge", (GtkSignalFunc) purge, ctxt);
- gtk_signal_connect (retval, "set_status", (GtkSignalFunc) set_status, ctxt);
- gtk_signal_connect (retval, "set_archived", (GtkSignalFunc) set_archived, ctxt);
- gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, ctxt);
- gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, ctxt);
- gtk_signal_connect (retval, "compare_backup", (GtkSignalFunc) compare_backup, ctxt);
- gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, ctxt);
- gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, ctxt);
- gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, ctxt);
- gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, ctxt);
-
- return GNOME_PILOT_CONDUIT (retval);
-}
-
-void
-conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
-{
- GCalConduitCfg *cc;
- GCalConduitContext *ctxt;
-
- cc = GET_GCALCONFIG(conduit);
- ctxt = GET_GCALCONTEXT(conduit);
-
- if(ctxt->calendar!=CORBA_OBJECT_NIL)
- GNOME_Calendar_Repository_done (ctxt->calendar, &(ctxt->ev));
-
- gcalconduit_destroy_configuration(&cc);
-
- gcalconduit_destroy_context(&ctxt);
-
- gtk_object_destroy (GTK_OBJECT (conduit));
-
-}
-
-
diff --git a/calendar/calendar-conduit.h b/calendar/calendar-conduit.h
deleted file mode 100644
index 711609e96a..0000000000
--- a/calendar/calendar-conduit.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* $Id$ */
-
-#ifndef __CALENDAR_CONDUIT_H__
-#define __CALENDAR_CONDUIT_H__
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <pi-datebook.h>
-#include <gnome.h>
-
-#include "GnomeCal.h"
-#include "calobj.h"
-#include "calendar.h"
-#include "timeutil.h"
-
-#include <gpilotd/gnome-pilot-conduit.h>
-#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
-
-/* This is the local record structure for the GnomeCal conduit. */
-typedef struct _GCalLocalRecord GCalLocalRecord;
-struct _GCalLocalRecord {
- /* The stuff from gnome-pilot-conduit-standard-abs.h
- Must be first in the structure, or instances of this
- structure cannot be used by gnome-pilot-conduit-standard-abs.
- */
- LocalRecord local;
- /* The corresponding iCal object, as found by GnomeCal. */
- iCalObject *ical;
- /* pilot-link appointment structure, used for implementing Transmit. */
- struct Appointment *a;
-};
-#define GCAL_LOCALRECORD(s) ((GCalLocalRecord*)(s))
-
-/* This is the configuration of the GnomeCal conduit. */
-typedef struct _GCalConduitCfg GCalConduitCfg;
-struct _GCalConduitCfg {
- gboolean open_secret;
- guint32 pilotId;
- GnomePilotConduitSyncType sync_type; /* only used by capplet */
-};
-#define GET_GCALCONFIG(c) ((GCalConduitCfg*)gtk_object_get_data(GTK_OBJECT(c),"gcalconduit_cfg"))
-
-/* This is the context for all the GnomeCal conduit methods. */
-typedef struct _GCalConduitContext GCalConduitContext;
-struct _GCalConduitContext {
- struct AppointmentAppInfo ai;
- GCalConduitCfg *cfg;
- GNOME_Calendar_Repository calendar;
- CORBA_Environment ev;
- CORBA_ORB orb;
-};
-#define GET_GCALCONTEXT(c) ((GCalConduitContext*)gtk_object_get_data(GTK_OBJECT(c),"gcalconduit_context"))
-
-/* Given a GCalConduitCfg*, allocates the structure and
- loads the configuration data for the given pilot. */
-static void
-gcalconduit_load_configuration(GCalConduitCfg **c,
- guint32 pilotId)
-{
- gchar prefix[256];
- g_snprintf(prefix,255,"/gnome-pilot.d/calendard-conduit/Pilot_%u/",pilotId);
-
- *c = g_new0(GCalConduitCfg,1);
- g_assert(*c != NULL);
- gnome_config_push_prefix(prefix);
- (*c)->open_secret = gnome_config_get_bool("open_secret=FALSE");
- (*c)->sync_type = GnomePilotConduitSyncTypeCustom; /* set in capplets main */
- gnome_config_pop_prefix();
-
- (*c)->pilotId = pilotId;
-}
-
-/* Saves the configuration data. */
-static void
-gcalconduit_save_configuration(GCalConduitCfg *c)
-{
- gchar prefix[256];
-
- g_snprintf(prefix,255,"/gnome-pilot.d/calendar-conduit/Pilot_%u/",c->pilotId);
-
- gnome_config_push_prefix(prefix);
- gnome_config_set_bool("open_secret",c->open_secret);
- gnome_config_pop_prefix();
-
- gnome_config_sync();
- gnome_config_drop_all();
-}
-
-/* Creates a duplicate of the configuration data */
-static GCalConduitCfg*
-gcalconduit_dupe_configuration(GCalConduitCfg *c) {
- GCalConduitCfg *retval;
- g_return_val_if_fail(c!=NULL,NULL);
- retval = g_new0(GCalConduitCfg,1);
- retval->sync_type = c->sync_type;
- retval->open_secret = c->open_secret;
- retval->pilotId = c->pilotId;
- return retval;
-}
-
-/* Destroys any data allocated by gcalconduit_load_configuration
- and deallocates the given configuration. */
-static void
-gcalconduit_destroy_configuration(GCalConduitCfg **c)
-{
- g_return_if_fail(c!=NULL);
- g_return_if_fail(*c!=NULL);
- g_free(*c);
- *c = NULL;
-}
-
-/* Given a GCalConduitContxt*, allocates the structure */
-static void
-gcalconduit_new_context(GCalConduitContext **ctxt,
- GCalConduitCfg *c)
-{
- *ctxt = g_new0(GCalConduitContext,1);
- g_assert(ctxt!=NULL);
- (*ctxt)->cfg = c;
- CORBA_exception_init (&((*ctxt)->ev));
-}
-
-/* Destroys any data allocated by gcalconduit_new_context
- and deallocates its data. */
-static void
-gcalconduit_destroy_context(GCalConduitContext **ctxt)
-{
- g_return_if_fail(ctxt!=NULL);
- g_return_if_fail(*ctxt!=NULL);
-/*
- if ((*ctxt)->cfg!=NULL)
- gcalconduit_destroy_configuration(&((*ctxt)->cfg));
-*/
- g_free(*ctxt);
- *ctxt = NULL;
-}
-#endif __CALENDAR_CONDUIT_H__
diff --git a/calendar/calendar-pilot-sync.c b/calendar/calendar-pilot-sync.c
deleted file mode 100644
index 5039bb37b7..0000000000
--- a/calendar/calendar-pilot-sync.c
+++ /dev/null
@@ -1,658 +0,0 @@
-/*
- * calendar-pilot-sync.c:
- *
- * (C) 1999 International GNOME Support
- *
- * Author:
- * Miguel de Icaza (miguel@gnome-support.com)
- *
- */
-#include <config.h>
-#include <gnome.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <libgnorba/gnome-factory.h>
-#include <libgnorba/gnorba.h>
-#include "calobj.h"
-#include "calendar.h"
-#include "timeutil.h"
-#include "GnomeCal.h"
-#include "pi-source.h"
-#include "pi-socket.h"
-#include "pi-datebook.h"
-#include "pi-dlp.h"
-
-/* the CORBA ORB */
-CORBA_ORB orb;
-
-/* The default port to communicate with */
-char *pilot_port = "/dev/pilot";
-
-CORBA_Environment ev;
-
-/* Our pi-socket address where we connect to */
-struct pi_sockaddr addr;
-
-/* The Pilot DB identifier for DateBook */
-int db;
-
-/* If true, enable debug output for alarms */
-int debug_alarms = 0;
-
-/* True if you want to dump the flags bits from the records */
-int debug_attrs = 0;
-
-/* Default values for alarms */
-CalendarAlarm alarm_defaults[4] = {
- { ALARM_MAIL, 0, 15, ALARM_MINUTES },
- { ALARM_PROGRAM, 0, 15, ALARM_MINUTES },
- { ALARM_DISPLAY, 0, 15, ALARM_MINUTES },
- { ALARM_AUDIO, 0, 15, ALARM_MINUTES }
-};
-
-int only_desktop_to_pilot = 0;
-
-int only_pilot_to_desktop = 0;
-
-const struct poptOption calendar_sync_options [] = {
- { "pilot", 0, POPT_ARG_STRING, &pilot_port, 0,
- N_("Specifies the port on which the Pilot is"), N_("PORT") },
- { "debug-attrs", 0, POPT_ARG_NONE, &debug_attrs, 0,
- N_("If you want to debug the attributes on records"), NULL },
- { "only-desktop", 0, POPT_ARG_NONE, &only_desktop_to_pilot, 0,
- N_("Only syncs from desktop to pilot"), NULL },
- { "only-pilot", 0, POPT_ARG_INT, &only_pilot_to_desktop, 0,
- N_("Only syncs from pilot to desktop"), NULL },
- { NULL, '\0', 0, NULL, 0 }
-};
-
-static void
-conduit_free_Appointment (struct Appointment *a)
-{
- /* free_Appointment is brain-dead with respect to guarding against
- double-frees */
-
- free_Appointment (a);
- a->exception = 0;
- a->description = 0;
- a->note = 0;
-}
-
-static int
-setup_connection (void)
-{
- int socket;
- int ret, news;
-
- if (!(socket = pi_socket(PI_AF_SLP, PI_SOCK_STREAM, PI_PF_PADP)))
- g_error (_("Can not create Pilot socket\n"));
-
- addr.pi_family = PI_AF_SLP;
- strncpy ((void *) &addr.pi_device, pilot_port, sizeof (addr.pi_device));
-
- ret = pi_bind (socket, (struct sockaddr *)&addr, sizeof (addr));
- if (ret == -1)
- g_error (_("Can not bind to device %s\n"), pilot_port);
-
- if (pi_listen (socket, 1) == -1)
- g_error (_("Failed to get a connection from the Pilot device"));
-
- if ((news = pi_accept (socket, 0, 0)) == -1)
- g_error (_("pi_accept failed"));
-
- return news;
-}
-
-static GNOME_Calendar_Repository
-locate_calendar_server (void)
-{
- GNOME_Calendar_Repository repo;
-
- repo = goad_server_activate_with_id (
- NULL, "IDL:GNOME:Calendar:Repository:1.0",
- 0, NULL);
-
- if (repo == CORBA_OBJECT_NIL)
- g_error ("Can not communicate with GnomeCalendar server");
-
- if (ev._major != CORBA_NO_EXCEPTION){
- printf ("Exception: %s\n", CORBA_exception_id (&ev));
- abort ();
- }
-
- return repo;
-}
-
-static void
-delete_record (GNOME_Calendar_Repository repo, int id)
-{
- char *uid;
-
- uid = GNOME_Calendar_Repository_get_id_from_pilot_id (repo, id, &ev);
-
- /* The record was already deleted */
- if (ev._major != CORBA_NO_EXCEPTION)
- return;
-
- GNOME_Calendar_Repository_delete_object (repo, uid, &ev);
- CORBA_free (uid);
-}
-
-static void
-update_record (GNOME_Calendar_Repository repo, int id, struct Appointment *a, int attr)
-{
- char *vcal_string;
- iCalObject *obj;
- int i;
- char *str;
-
- obj = ical_new (a->note ? a->note : "",
- g_get_user_name (),
- a->description ? a->description : "");
-
- printf ("requesting %d [%s]\n", id, a->description);
- vcal_string = GNOME_Calendar_Repository_get_object_by_pilot_id (repo, id, &ev);
-
- if (ev._major == CORBA_USER_EXCEPTION){
- time_t now = time (NULL);
-
- obj->created = now;
- obj->last_mod = now;
- obj->priority = 0;
- obj->transp = 0;
- obj->related = NULL;
- obj->pilot_id = id;
- obj->pilot_status = ICAL_PILOT_SYNC_NONE;
- printf (_("\tObject did not exist, creating a new one\n"));
- } else {
- printf ("\tFound\n");
- obj = ical_object_new_from_string (vcal_string);
- }
-
- if (obj->pilot_status == ICAL_PILOT_SYNC_MOD){
- printf (_("\tObject has been modified on desktop and on the pilot, desktop takes precedence\n"));
- ical_object_destroy (obj);
- return;
- }
-
- /*
- * Begin and end
- */
-
- if (a->event)
- {
- /* turn day-long events into a full day's appointment */
- a->begin.tm_sec = 0;
- a->begin.tm_min = 0;
- a->begin.tm_hour = 6;
-
- a->end.tm_sec = 0;
- a->end.tm_min = 0;
- a->end.tm_hour = 10;
- }
-
- obj->dtstart = mktime (&a->begin);
- obj->dtend = mktime (&a->end);
-
- /* Special case: daily repetitions are converted to a multi-day event */
- if (a->repeatType == repeatDaily){
- time_t newt = time_add_day (obj->dtend, a->repeatFrequency);
-
- obj->dtend = newt;
- }
-
- /*
- * Alarm
- */
- if (a->alarm){
- obj->aalarm.type = ALARM_AUDIO;
- obj->aalarm.enabled = 1;
- obj->aalarm.count = a->advance;
-
- switch (a->advanceUnits){
- case advMinutes:
- obj->aalarm.units = ALARM_MINUTES;
- break;
-
- case advHours:
- obj->aalarm.units = ALARM_HOURS;
- break;
-
- case advDays:
- obj->aalarm.units = ALARM_DAYS;
- break;
- default:
- }
- }
-
- /*
- * Recurrence
- */
- if (a->repeatFrequency && a->repeatType != repeatDaily){
- obj->recur = g_new0 (Recurrence, 1);
-
- switch (a->repeatType){
- case repeatDaily:
- /*
- * In the Pilot daily repetitions are actually
- * multi-day events
- */
- g_warning ("Should not have got here");
- break;
-
- case repeatMonthlyByDate:
- obj->recur->type = RECUR_MONTHLY_BY_DAY;
- obj->recur->u.month_day = a->repeatFrequency;
- break;
-
- case repeatWeekly:
- {
- int wd;
-
- obj->recur->type = RECUR_WEEKLY;
- for (wd = 0; wd < 7; wd++)
- if (a->repeatDays [wd])
- obj->recur->weekday |= 1 << wd;
-
- if (obj->recur->weekday == 0){
- struct tm tm = *localtime (&obj->dtstart);
-
- obj->recur->weekday = 1 << tm.tm_wday;
- }
- break;
- }
-
- case repeatMonthlyByDay:
- obj->recur->type = RECUR_MONTHLY_BY_POS;
- obj->recur->u.month_pos = a->repeatFrequency;
- obj->recur->weekday = (a->repeatDay / 7);
- break;
-
- case repeatYearly:
- obj->recur->type = RECUR_YEARLY_BY_DAY;
- break;
-
- default:
- g_warning ("Unhandled repeate case");
- }
-
- if (a->repeatForever)
- obj->recur->duration = 0;
- else
- obj->recur->_enddate = mktime (&a->repeatEnd);
- }
-
- /*
- * Load exception dates
- */
- obj->exdate = NULL;
- for (i = 0; i < a->exceptions; i++){
- time_t *t = g_new (time_t, 1);
-
- *t = mktime (&(a->exception [i]));
- obj->exdate = g_list_prepend (obj->exdate, t);
- }
-
- g_free (obj->class);
-
- if (attr & dlpRecAttrSecret)
- obj->class = g_strdup ("PRIVATE");
- else
- obj->class = g_strdup ("PUBLIC");
-
- /*
- * Now, convert the in memory iCalObject to a full vCalendar we can send
- */
- str = calendar_string_from_object (obj);
-
- GNOME_Calendar_Repository_update_object (repo, obj->uid, str, &ev);
-
- free (str);
-
- /*
- * Shutdown
- */
- ical_object_destroy (obj);
-}
-
-/*
- * Sets the alarm for Appointment based on @alarm
- */
-static int
-try_alarm (CalendarAlarm *alarm, struct Appointment *a)
-{
- if (!alarm->enabled)
- return 0;
-
- a->advance = alarm->count;
- switch (alarm->type){
- case ALARM_DAYS:
- a->advanceUnits = advDays;
- break;
-
- case ALARM_HOURS:
- a->advanceUnits = advHours;
- break;
-
- case ALARM_MINUTES:
- a->advanceUnits = advMinutes;
- break;
-
- default:
- return 0;
- }
- a->alarm = 1;
- return 1;
-}
-
-static void
-sync_object_to_pilot (GNOME_Calendar_Repository repo, iCalObject *obj, int pilot_fd)
-{
- char buffer [65536];
- struct Appointment *a;
- int wd, i, idx, attr, cat, rec_len;
- recordid_t new_id;
- GList *l;
-
- a = g_new0 (struct Appointment, 1);
-
- attr = 0;
- cat = 0;
- idx = 0;
-
- if (obj->pilot_id){
- rec_len = dlp_ReadRecordById (pilot_fd, db, obj->pilot_id,
- buffer, &idx, &rec_len, &attr, &cat);
-
- if (rec_len > 0)
- unpack_Appointment (a, buffer, rec_len);
- } else {
- attr = 0;
- cat = 0;
- }
-
- /* a contains the appointment either cleared or with the data from the Pilot */
- a->begin = *localtime (&obj->dtstart);
- a->end = *localtime (&obj->dtend);
-
- /* FIXME: add support for timeless */
- a->event = 0;
-
- /* Alarms, try the various ones. Probably we should only do Audio?
- * Otherwise going gnomecal->pilot->gnomecal would get the gnomecal
- * with *possibly* an alarm that was not originally defined.
- */
- a->alarm = 0;
- if (try_alarm (&obj->aalarm, a) == 0)
- if (try_alarm (&obj->dalarm, a) == 0)
- try_alarm (&obj->palarm, a);
-
- /* Recurrence */
- if (obj->recur){
- a->repeatFrequency = obj->recur->interval;
-
- switch (obj->recur->type){
- case RECUR_MONTHLY_BY_POS:
- a->repeatType = repeatMonthlyByDay;
- a->repeatFrequency = obj->recur->u.month_pos;
- a->repeatDay = obj->recur->weekday * 7;
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- a->repeatType = repeatMonthlyByDate;
- a->repeatFrequency = obj->recur->u.month_day;
- break;
-
- case RECUR_YEARLY_BY_DAY:
- a->repeatType = repeatYearly;
- break;
-
- case RECUR_WEEKLY:
- for (wd = 0; wd < 7; wd++)
- if (obj->recur->weekday & (1 << wd))
- a->repeatDays [wd] = 1;
- a->repeatType = repeatWeekly;
- break;
- case RECUR_DAILY:
-
- default:
- a->repeatType = repeatNone;
- break;
- }
- if (obj->recur->enddate == 0){
- a->repeatForever = 1;
- } else
- a->repeatEnd = *localtime (&obj->recur->enddate);
- }
-
- /*
- * Pilot uses a repeat-daily for a multi-day event, adjust for that case
- */
- if ((a->end.tm_mday != a->begin.tm_mday) ||
- (a->end.tm_mon != a->begin.tm_mon) ||
- (a->end.tm_year != a->begin.tm_year)){
- a->event = 1;
- a->begin.tm_sec = 0;
- a->begin.tm_min = 0;
- a->begin.tm_hour = 0;
-
- a->end.tm_sec = 0;
- a->end.tm_min = 0;
- a->end.tm_hour = 0;
-
- a->repeatEnd = a->end;
- a->repeatForever = 0;
- a->repeatFrequency = 1;
- a->repeatType = repeatDaily;
- }
-
- /*
- * Exceptions
- */
- a->exceptions = g_list_length (obj->exdate);
- a->exception = (struct tm *) malloc (sizeof (struct tm) * a->exceptions);
- for (i = 0, l = obj->exdate; l; l = l->next, i++){
- time_t *exdate = l->data;
-
- a->exception [i] = *localtime (exdate);
- }
-
- /*
- * Description and note.
- *
- * We use strdup to be correct. free_Appointment assumes we used
- * malloc.
- */
- if (obj->comment)
- a->note = strdup (obj->comment);
- else
- a->note = 0;
-
- if (obj->summary)
- a->description = strdup (obj->summary);
- else
- a->description = strdup (_("No description"));
-
- if (strcmp (obj->class, "PUBLIC") != 0)
- attr |= dlpRecAttrSecret;
- else
- attr &= ~dlpRecAttrSecret;
-
- /*
- * Send the appointment to the pilot
- */
- rec_len = pack_Appointment (a, buffer, sizeof (buffer));
- attr &= ~dlpRecAttrDirty;
-
- dlp_WriteRecord (
- pilot_fd, db, 0,
- obj->pilot_id, 0, buffer, rec_len, &new_id);
-
- GNOME_Calendar_Repository_update_pilot_id (repo, obj->uid, new_id, ICAL_PILOT_SYNC_NONE, &ev);
-
- conduit_free_Appointment (a);
- g_free (a);
-}
-
-static void
-sync_cal_to_pilot (GNOME_Calendar_Repository repo, Calendar *cal, int pilot_fd)
-{
- GList *l;
- int c = g_list_length (cal->events);
- int i;
-
- printf ("\n");
- for (i = 0, l = cal->events; l; l = l->next, i++){
- iCalObject *obj = l->data;
-
- printf ("Syncing desktop to pilot: %d/%d\r", i + 1, c);
- fflush (stdout);
- if (obj->pilot_status != ICAL_PILOT_SYNC_MOD){
- g_warning ("Strange, we were supposed to get only a dirty object");
- continue;
- }
-
- sync_object_to_pilot (repo, obj, pilot_fd);
- }
- printf ("\n");
-}
-
-static void
-dump_attr (int flags)
-{
- if (flags & dlpRecAttrDeleted)
- fprintf(stderr, " Deleted");
- if (flags & dlpRecAttrDirty)
- fprintf(stderr, " Dirty");
- if (flags & dlpRecAttrBusy)
- fprintf(stderr, " Busy");
- if (flags & dlpRecAttrSecret)
- fprintf(stderr, " Secret");
- if (flags & dlpRecAttrArchived)
- fprintf(stderr, " Archive");
- fprintf (stderr, "\n");
-}
-
-static void
-sync_pilot (GNOME_Calendar_Repository repo, int pilot_fd)
-{
- struct PilotUser user_info;
- int record;
- unsigned char buffer [65536];
- Calendar *dirty_cal;
- char *vcalendar_string;
- char *error;
-
- printf (_("Syncing with the pilot..."));
- dlp_ReadUserInfo (pilot_fd, &user_info);
-
- /* This informs the user of the progress on the Pilot */
- dlp_OpenConduit (pilot_fd);
-
- if (dlp_OpenDB (pilot_fd, 0, 0x80 | 0x40, "DatebookDB", &db) < 0){
- g_warning (_("Could not open DatebookDB on the Pilot"));
- dlp_AddSyncLogEntry (pilot_fd, _("Unable to open DatebookDB"));
- pi_close (pilot_fd);
- exit (1);
- }
-
- /*
- * 1. Pull all the records from the Pilot, and make any updates
- * required on the desktop side
- */
- if (!only_desktop_to_pilot){
- for (record = 0;; record++){
- struct Appointment a;
- int rec_len, attr, size;
- recordid_t id;
-
- rec_len = dlp_ReadRecordByIndex (
- pilot_fd, db,
- record, buffer, &id, &size, &attr, 0);
-
- if (rec_len < 0)
- break;
-
- printf ("processing record %d\n", record);
- unpack_Appointment (&a, buffer, rec_len);
-
- if (debug_attrs)
- dump_attr (attr);
-
- /* If the object was deleted, remove it from the database */
- if (attr & dlpRecAttrDeleted){
- printf ("Deleting id %ld\n", id);
- delete_record (repo, id);
- conduit_free_Appointment (&a);
- dlp_DeleteRecord (pilot_fd, db, 0, id);
- continue;
- }
-
- if (attr & dlpRecAttrArchived)
- continue;
-
- printf ("updating record\n");
- update_record (repo, id, &a, attr);
-
- conduit_free_Appointment (&a);
- }
- }
-
- /*
- * 2. Pull all the records from the Calendar, and move any new items
- * to the pilot
- */
- if (!only_pilot_to_desktop){
- vcalendar_string = GNOME_Calendar_Repository_get_updated_objects (repo, &ev);
- dirty_cal = calendar_new ("Temporal",CALENDAR_INIT_NIL);
- error = calendar_load_from_memory (dirty_cal, vcalendar_string);
- if (!error)
- sync_cal_to_pilot (repo, dirty_cal, pilot_fd);
- calendar_destroy (dirty_cal);
- }
-
-
- dlp_CloseDB (pilot_fd, db);
- dlp_AddSyncLogEntry (pilot_fd, _("Synced DateBook from Pilot to GnomeCal"));
- pi_close (pilot_fd);
-}
-
-int
-main (int argc, char *argv [])
-{
- int link;
- GNOME_Calendar_Repository repository;
-
- CORBA_exception_init (&ev);
- orb = gnome_CORBA_init_with_popt_table (
- "calendar-pilot-sync", VERSION, &argc, argv,
- calendar_sync_options, 0, NULL, 0, &ev);
-
- printf ("Please, press HotSync button on the palm...");
- fflush (stdout);
- link = setup_connection ();
- printf ("Connected\n");
-
- printf ("Launching GnomeCal...");
- fflush (stdout);
- repository = locate_calendar_server ();
- printf ("Done\n");
-
- printf ("<Syncing>\n");
- sync_pilot (repository, link);
- printf ("</Syncing>\n");
-
- GNOME_Calendar_Repository_done (repository, &ev);
-
- CORBA_exception_free (&ev);
-
- return 0;
-}
-
-/* Just a stub to link with */
-void
-calendar_notify (time_t time, CalendarAlarm *which, void *data)
-{
-}
-
diff --git a/calendar/calendar.c b/calendar/calendar.c
deleted file mode 100644
index db31ba016b..0000000000
--- a/calendar/calendar.c
+++ /dev/null
@@ -1,646 +0,0 @@
-/*
- * Calendar manager object
- *
- * This keeps track of a given calendar. Eventually this will abtract everything
- * related to getting calendars/saving calendars locally or to a remote Calendar Service
- *
- * Copyright (C) 1998, 1999 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org)
- *
- */
-
-#include <gnome.h>
-#include <stdio.h>
-#include <config.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include "calendar.h"
-#include "alarm.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
-
-#ifdef HAVE_TZNAME
-extern char *tzname[2];
-#endif
-
-/* Our day range */
-time_t calendar_day_begin, calendar_day_end;
-
-static void calendar_init_alarms (Calendar *cal);
-static void calendar_set_day (void);
-
-Calendar *
-calendar_new (char *title,CalendarNewOptions options)
-{
- Calendar *cal;
-
- cal = g_new0 (Calendar, 1);
-
- cal->title = g_strdup (title);
-
- if ((calendar_day_begin == 0) || (calendar_day_end == 0))
- calendar_set_day ();
-
- cal->event_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
- if (options & CALENDAR_INIT_ALARMS) {
- calendar_init_alarms (cal);
- }
-
- return cal;
-}
-
-static void
-try_add (iCalObject *ico, CalendarAlarm *alarm, time_t start, time_t end)
-{
- alarm->trigger = start-alarm->offset;
-
- if (alarm->trigger < calendar_day_begin)
- return;
- if (alarm->trigger > calendar_day_end)
- return;
- alarm_add (alarm, &calendar_notify, ico);
-}
-
-static int
-add_object_alarms (iCalObject *obj, time_t start, time_t end, void *closure)
-{
- if (obj->aalarm.enabled)
- try_add (obj, &obj->aalarm, start, end);
- if (obj->dalarm.enabled)
- try_add (obj, &obj->dalarm, start, end);
- if (obj->palarm.enabled)
- try_add (obj,&obj->palarm, start, end);
- if (obj->malarm.enabled)
- try_add (obj, &obj->malarm, start, end);
-
- return TRUE;
-}
-
-#define max(a,b) ((a > b) ? a : b)
-
-static void
-ical_object_try_alarms (iCalObject *obj)
-{
- int ao, po, od, mo;
- int max_o;
-
- ao = alarm_compute_offset (&obj->aalarm);
- po = alarm_compute_offset (&obj->palarm);
- od = alarm_compute_offset (&obj->dalarm);
- mo = alarm_compute_offset (&obj->malarm);
-
- max_o = max (ao, max (po, max (od, mo)));
- if (max_o == -1)
- return;
-
- ical_object_generate_events (obj, calendar_day_begin, calendar_day_end + max_o, add_object_alarms, obj);
-}
-
-void
-calendar_add_object (Calendar *cal, iCalObject *obj)
-{
- g_return_if_fail (cal != NULL);
- g_return_if_fail (obj != NULL);
- g_return_if_fail (obj->uid != NULL);
-
- obj->new = 0;
- switch (obj->type){
- case ICAL_EVENT:
- g_hash_table_insert (cal->event_hash, obj->uid, obj);
- cal->events = g_list_prepend (cal->events, obj);
- ical_object_try_alarms (obj);
-#ifdef DEBUGGING_MAIL_ALARM
- obj->malarm.trigger = 0;
- calendar_notify (0, obj);
-#endif
- break;
-
- case ICAL_TODO:
- cal->todo = g_list_prepend (cal->todo, obj);
- break;
-
- case ICAL_JOURNAL:
- cal->journal = g_list_prepend (cal->journal, obj);
- break;
- default:
- g_assert_not_reached ();
- }
-
- if (!obj->uid){
- char buffer [80];
-
- snprintf (buffer, sizeof (buffer), "GnomeCalendar-%ld\n", time (NULL));
- obj->uid = g_strdup (buffer);
- }
-
- cal->modified = TRUE;
-
- obj->last_mod = time (NULL);
-}
-
-void
-calendar_remove_object (Calendar *cal, iCalObject *obj)
-{
- switch (obj->type){
- case ICAL_EVENT:
- cal->events = g_list_remove (cal->events, obj);
- g_hash_table_remove (cal->event_hash, obj->uid);
- break;
-
- case ICAL_TODO:
- cal->todo = g_list_remove (cal->todo, obj);
- break;
-
- case ICAL_JOURNAL:
- cal->journal = g_list_remove (cal->journal, obj);
- break;
- default:
- g_assert_not_reached ();
- }
-
- cal->modified = TRUE;
-}
-
-void
-calendar_destroy (Calendar *cal)
-{
- g_list_foreach (cal->events, (GFunc) ical_object_destroy, NULL);
- g_list_free (cal->events);
-
- g_list_foreach (cal->todo, (GFunc) ical_object_destroy, NULL);
- g_list_free (cal->todo);
-
- g_list_foreach (cal->journal, (GFunc) ical_object_destroy, NULL);
- g_list_free (cal->journal);
-
- g_hash_table_destroy (cal->event_hash);
-
- if (cal->title)
- g_free (cal->title);
- if (cal->filename)
- g_free (cal->filename);
-
- g_free (cal);
-}
-
-void
-calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure)
-{
- for (; objects; objects = objects->next){
- iCalObject *object = objects->data;
-
- ical_object_generate_events (object, start, end, cb, closure);
- }
-}
-
-void
-calendar_iterate (Calendar *cal, time_t start, time_t end, calendarfn cb, void *closure)
-{
- calendar_iterate_on_objects (cal->events, start, end, cb, closure);
-}
-
-GList *
-calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func)
-{
- GList *new_events = 0;
-
- for (; objects; objects = objects->next){
- iCalObject *object = objects->data;
-
- if ((start <= object->dtstart) && (object->dtend <= end)){
- if (sort_func)
- new_events = g_list_insert_sorted (new_events, object, sort_func);
- else
- new_events = g_list_prepend (new_events, object);
- }
- }
-
- /* Put the list in increasing order if no sort function was specified */
-
- if (!sort_func)
- new_events = g_list_reverse (new_events);
-
- return new_events;
-}
-
-GList *
-calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func)
-{
- return calendar_get_objects_in_range (cal->todo, start, end, sort_func);
-}
-
-GList *
-calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func)
-{
- return calendar_get_objects_in_range (cal->journal, start, end, sort_func);
-}
-
-gint
-calendar_compare_by_dtstart (gpointer a, gpointer b)
-{
- iCalObject *obj1, *obj2;
- time_t diff;
-
- obj1 = a;
- obj2 = b;
-
- diff = obj1->dtstart - obj2->dtstart;
-
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-#define str_val(obj) (char *) vObjectUStringZValue (obj)
-
-/* Loads our calendar contents from a vObject */
-void
-calendar_load_from_vobject (Calendar *cal, VObject *vcal)
-{
- VObjectIterator i;
-
- initPropIterator (&i, vcal);
-
- while (moreIteration (&i)){
- VObject *this = nextVObject (&i);
- iCalObject *ical;
- const char *object_name = vObjectName (this);
-
- if (strcmp (object_name, VCDCreatedProp) == 0){
- cal->created = time_from_isodate (str_val (this));
- continue;
- }
-
- if (strcmp (object_name, VCLocationProp) == 0)
- continue; /* FIXME: imlement */
-
- if (strcmp (object_name, VCProdIdProp) == 0)
- continue; /* FIXME: implement */
-
- if (strcmp (object_name, VCVersionProp) == 0)
- continue; /* FIXME: implement */
-
- if (strcmp (object_name, VCTimeZoneProp) == 0)
- continue; /* FIXME: implement */
-
- ical = ical_object_create_from_vobject (this, object_name);
-
- if (ical)
- calendar_add_object (cal, ical);
- }
-}
-
-static void
-calendar_set_day (void)
-{
- time_t calendar_today;
-
- calendar_today = time (NULL);
- calendar_day_begin = time_day_begin (calendar_today);
- calendar_day_end = time_day_end (calendar_today);
-}
-
-/* Loads a calendar from a file */
-char *
-calendar_load (Calendar *cal, char *fname)
-{
- VObject *vcal;
- struct stat s;
-
- if (cal->filename){
- g_warning ("Calendar load called again\n");
- return "Internal error";
- }
-
- cal->filename = g_strdup (fname);
- vcal = Parse_MIME_FromFileName (fname);
- if (!vcal)
- return "Could not load the calendar";
-
- stat (fname, &s);
- cal->file_time = s.st_mtime;
-
- calendar_set_day ();
-
- calendar_load_from_vobject (cal, vcal);
- cleanVObject (vcal);
- cleanStrTbl ();
- return NULL;
-}
-
-/*
- * calendar_load_from_memory:
- * @cal: calendar on which we load the information
- * @buffer: A buffer that contains a vCalendar file
- *
- * Loads the information from the vCalendar information in @buffer
- * into the Calendar
- */
-char *
-calendar_load_from_memory (Calendar *cal, const char *buffer)
-{
- VObject *vcal;
-
- g_return_val_if_fail (buffer != NULL, NULL);
-
- cal->filename = g_strdup ("memory-based-calendar");
- vcal = Parse_MIME (buffer, strlen (buffer));
- if (!vcal)
- return "Could not load the calendar";
-
- cal->file_time = time (NULL);
- calendar_load_from_vobject (cal, vcal);
- cleanVObject (vcal);
- cleanStrTbl ();
-
- return NULL;
-}
-
-static VObject *
-vcalendar_create_from_calendar (Calendar *cal)
-{
- VObject *vcal;
- GList *l;
- time_t now = time (NULL);
- struct tm tm;
-
- /* WE call localtime for the side effect of setting tzname */
- tm = *localtime (&now);
-
- vcal = newVObject (VCCalProp);
- addPropValue (vcal, VCProdIdProp, "-//GNOME//NONSGML GnomeCalendar//EN");
-#if defined(HAVE_TM_ZONE)
- addPropValue (vcal, VCTimeZoneProp, tm.tm_zone);
-#elif defined(HAVE_TZNAME)
- addPropValue (vcal, VCTimeZoneProp, tzname[0]);
-#endif
- addPropValue (vcal, VCVersionProp, VERSION);
- cal->temp = vcal;
-
- /* Events */
-
- for (l = cal->events; l; l = l->next) {
- VObject *obj;
-
- obj = ical_object_to_vobject ((iCalObject *) l->data);
- addVObjectProp (vcal, obj);
- }
-
- /* To-do entries */
-
- for (l = cal->todo; l; l = l->next) {
- VObject *obj;
-
- obj = ical_object_to_vobject ((iCalObject *) l->data);
- addVObjectProp (vcal, obj);
- }
-
- return vcal;
-}
-
-void
-calendar_save (Calendar *cal, char *fname)
-{
- VObject *vcal;
- FILE *fp;
- GtkWidget *dlg;
- struct stat s;
- int status;
-
- if (fname == NULL)
- fname = cal->filename;
-
- vcal = vcalendar_create_from_calendar (cal);
- if (g_file_exists (fname)){
- char *backup_name = g_strconcat (fname, "~", NULL);
-
- if (g_file_exists (backup_name)){
- unlink (backup_name);
- }
- rename (fname, backup_name);
- g_free (backup_name);
- }
-
- fp = fopen(fname,"w");
- if (fp) {
- writeVObject(fp, vcal);
- fclose(fp);
- if (strcmp(cal->filename, fname)) {
- if (cal->filename)
- g_free (cal->filename);
- cal->filename = g_strdup (fname);
- }
- status = stat (fname, &s);
- cal->file_time = s.st_mtime;
- } else {
- dlg = gnome_message_box_new(_("Failed to save calendar!"),
- GNOME_MESSAGE_BOX_ERROR, "Ok", NULL);
- gtk_widget_show(dlg);
- }
-
- cleanVObject (vcal);
- cleanStrTbl ();
-}
-
-char *
-calendar_get_as_vcal_string (Calendar *cal)
-{
- VObject *vcal;
- char *result;
-
- g_return_val_if_fail (cal != NULL, NULL);
-
- vcal = vcalendar_create_from_calendar (cal);
- result = writeMemVObject (NULL, 0, vcal);
-
- cleanVObject (vcal);
- cleanStrTbl ();
-
- return result;
-}
-
-static gint
-calendar_object_compare_by_start (gconstpointer a, gconstpointer b)
-{
- const CalendarObject *ca = a;
- const CalendarObject *cb = b;
- time_t diff;
-
- diff = ca->ev_start - cb->ev_start;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-static int
-assemble_event_list (iCalObject *obj, time_t start, time_t end, void *c)
-{
- CalendarObject *co;
- GList **l = c;
-
- co = g_new (CalendarObject, 1);
-
- co->ev_start = start;
- co->ev_end = end;
- co->ico = obj;
- *l = g_list_insert_sorted (*l, co, calendar_object_compare_by_start);
-
- return 1;
-}
-
-void
-calendar_destroy_event_list (GList *l)
-{
- GList *p;
-
- for (p = l; p; p = p->next)
- g_free (p->data);
- g_list_free (l);
-}
-
-GList *
-calendar_get_events_in_range (Calendar *cal, time_t start, time_t end)
-{
- GList *l = 0;
-
- calendar_iterate (cal, start, end, assemble_event_list, &l);
- return l;
-}
-
-void
-calendar_object_changed (Calendar *cal, iCalObject *obj, int flags)
-{
- obj->last_mod = time (NULL);
- obj->pilot_status = ICAL_PILOT_SYNC_MOD;
-
- if (!(flags & CHANGE_DATES))
- return;
-
- /* Remove any alarms on the alarm list for this object */
- while (alarm_kill (obj))
- ;
-
- ical_object_try_alarms (obj);
-}
-
-static void
-calendar_day_change (time_t time, CalendarAlarm *which, void *closure)
-{
- GList *events;
- Calendar *cal = closure;
-
- calendar_set_day ();
- calendar_init_alarms (cal);
-
- for (events = cal->events; events; events = events->next){
- iCalObject *obj = events->data;
-
- ical_object_try_alarms (obj);
- }
-}
-
-static void
-calendar_init_alarms (Calendar *cal)
-{
- CalendarAlarm day_change_alarm;
-
- day_change_alarm.trigger = calendar_day_end;
- alarm_add (&day_change_alarm, calendar_day_change, cal);
-}
-
-static iCalObject *
-calendar_object_find_in_list (Calendar *cal, GList *list, const char *uid)
-{
- GList *l;
-
- for (l = list; l; l = l->next){
- iCalObject *obj = l->data;
-
- if (strcmp (obj->uid, uid) == 0)
- return obj;
- }
-
- return NULL;
-}
-
-iCalObject *
-calendar_object_find_event (Calendar *cal, const char *uid)
-{
- g_return_val_if_fail (cal != NULL, NULL);
- g_return_val_if_fail (uid != NULL, NULL);
-
- return g_hash_table_lookup (cal->event_hash, uid);
-}
-
-iCalObject *
-calendar_object_find_todo (Calendar *cal, const char *uid)
-{
- g_return_val_if_fail (cal != NULL, NULL);
- g_return_val_if_fail (uid != NULL, NULL);
-
- return calendar_object_find_in_list (cal, cal->todo, uid);
-}
-
-iCalObject *
-calendar_object_find (Calendar *cal, const char *uid)
-{
- iCalObject *obj;
-
- g_return_val_if_fail (cal != NULL, NULL);
- g_return_val_if_fail (uid != NULL, NULL);
-
- obj = calendar_object_find_in_list (cal, cal->todo, uid);
-
- if (obj == NULL)
- obj = calendar_object_find_in_list (cal, cal->events, uid);
-
- return obj;
-}
-
-iCalObject *
-calendar_object_find_by_pilot (Calendar *cal, int pilot_id)
-{
- GList *l;
-
- g_return_val_if_fail (cal != NULL, NULL);
-
- for (l = cal->events; l; l = l->next){
- iCalObject *obj = l->data;
-
- if (obj->pilot_id == pilot_id)
- return obj;
- }
-
- for (l = cal->todo; l; l = l->next){
- iCalObject *obj = l->data;
-
- if (obj->pilot_id == pilot_id)
- return obj;
- }
-
- return NULL;
-}
-
-/*
- * calendar_string_from_object:
- *
- * Returns the iCalObject @object armored around a vCalendar
- * object as a string.
- */
-char *
-calendar_string_from_object (iCalObject *object)
-{
- Calendar *cal;
- char *str;
-
- g_return_val_if_fail (object != NULL, NULL);
-
- cal = calendar_new ("Temporal",CALENDAR_INIT_NIL);
- calendar_add_object (cal, object);
- str = calendar_get_as_vcal_string (cal);
- calendar_remove_object (cal, object);
-
- calendar_destroy (cal);
-
- return str;
-}
diff --git a/calendar/calendar.h b/calendar/calendar.h
deleted file mode 100644
index 858f0151ca..0000000000
--- a/calendar/calendar.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef CALENDAR_H
-#define CALENDAR_H
-
-#include "calobj.h"
-
-BEGIN_GNOME_DECLS
-
-typedef struct {
- /* This calendar's title */
- char *title;
-
- /* backing store for this calendar object */
- char *filename;
-
- /* The list of events; todo's and journal entries */
- GList *events;
- GList *todo;
- GList *journal;
-
- GHashTable *event_hash;
-
- /* Time at which the calendar was created */
- time_t created;
-
- /* Timestamp in the filename */
- time_t file_time;
-
- /* If the calendar was last modified */
- int modified;
- void *temp;
-
- void *corba_server;
-} Calendar;
-
-/* This is only used by the calendar_get_events_in_range routine to get
- * a list of objects that recur on a specific date
- */
-typedef struct {
- time_t ev_start;
- time_t ev_end;
- iCalObject *ico;
-} CalendarObject;
-
-typedef enum {
- CALENDAR_INIT_NIL = 0,
- CALENDAR_INIT_ALARMS = 1 << 0
-} CalendarNewOptions;
-
-Calendar *calendar_new (char *title,CalendarNewOptions options);
-char *calendar_get_as_vcal_string (Calendar *cal);
-char *calendar_string_from_object (iCalObject *object);
-
-char *calendar_load (Calendar *cal, char *fname);
-char *calendar_load_from_memory (Calendar *cal, const char *buffer);
-void calendar_load_from_vobject (Calendar *cal, VObject *vcal);
-void calendar_save (Calendar *cal, char *fname);
-void calendar_add_object (Calendar *cal, iCalObject *obj);
-void calendar_remove_object (Calendar *cal, iCalObject *obj);
-void calendar_destroy (Calendar *cal);
-GList *calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func);
-GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
-GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
-gint calendar_compare_by_dtstart (gpointer a, gpointer b);
-
-void calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure);
-void calendar_iterate (Calendar *cal, time_t start, time_t end, calendarfn cb, void *closure);
-
-/* Returns a list of CalendarObject structures. These represent the events in the calendar that are
- * in the specified range.
- */
-GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end);
-
-/* Destroy list returned by calendar_get_events_in_range() with this function */
-void calendar_destroy_event_list (GList *l);
-
-/* Informs the calendar that obj information has changed */
-void calendar_object_changed (Calendar *cal, iCalObject *obj, int flags);
-
-void calendar_notify (time_t time, CalendarAlarm *which, void *data);
-
-iCalObject *calendar_object_find_event (Calendar *cal, const char *uid);
-iCalObject *calendar_object_find_todo (Calendar *cal, const char *uid);
-iCalObject *calendar_object_find (Calendar *cal, const char *uid);
-iCalObject *calendar_object_find_by_pilot (Calendar *cal, int pilot_id);
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/calobj.c b/calendar/calobj.c
deleted file mode 100644
index f3004ddb13..0000000000
--- a/calendar/calobj.c
+++ /dev/null
@@ -1,1490 +0,0 @@
-/*
- * Calendar objects implementations.
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org)
- */
-#include <config.h>
-#include <string.h>
-#include <glib.h>
-#include <ctype.h>
-#include <unistd.h>
-#include "calobj.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
-
-extern CalendarAlarm alarm_defaults[4];
-
-static char *
-ical_gen_uid (void)
-{
- static char *hostname;
- time_t t = time (NULL);
- static int serial;
-
- if (!hostname){
- char buffer [128];
-
- if ((gethostname (buffer, sizeof (buffer)-1) == 0) &&
- (buffer [0] != 0))
- hostname = g_strdup (buffer);
- else
- hostname = g_strdup ("localhost");
- }
-
- return g_strdup_printf (
- "%s-%d-%d-%d-%d@%s",
- isodate_from_time_t (t),
- getpid (),
- getgid (),
- getppid (),
- serial++,
- hostname);
-}
-
-iCalObject *
-ical_object_new (void)
-{
- iCalObject *ico;
-
- ico = g_new0 (iCalObject, 1);
-
- ico->seq = -1;
- ico->dtstamp = time (NULL);
- ico->uid = ical_gen_uid ();
-
- ico->pilot_id = 0;
- ico->pilot_status = ICAL_PILOT_SYNC_MOD;
-
- return ico;
-}
-
-static void
-default_alarm (iCalObject *ical, CalendarAlarm *alarm, char *def_mail, enum AlarmType type)
-{
- alarm->type = type;
- alarm->enabled = alarm_defaults[type].enabled;
- alarm->count = alarm_defaults[type].count;
- alarm->units = alarm_defaults[type].units;
- if (alarm_defaults[type].data)
- alarm->data = g_strdup (alarm_defaults[type].data);
- else
- alarm->data = g_strdup ("");
-}
-
-iCalObject *
-ical_new (char *comment, char *organizer, char *summary)
-{
- iCalObject *ico;
-
- ico = ical_object_new ();
-
- ico->comment = g_strdup (comment);
- ico->organizer = g_strdup (organizer);
- ico->summary = g_strdup (summary);
- ico->class = g_strdup ("PUBLIC");
- ico->status = g_strdup ("NEEDS ACTION");
-
- default_alarm (ico, &ico->dalarm, organizer, ALARM_DISPLAY);
- default_alarm (ico, &ico->palarm, organizer, ALARM_PROGRAM);
- default_alarm (ico, &ico->malarm, organizer, ALARM_MAIL);
- default_alarm (ico, &ico->aalarm, organizer, ALARM_AUDIO);
-
- return ico;
-}
-
-static void
-my_free (gpointer data, gpointer user_dat_ignored)
-{
- g_free (data);
-}
-
-static void
-list_free (GList *list)
-{
- g_list_foreach (list, my_free, 0);
- g_list_free (list);
-}
-
-#define free_if_defined(x) if (x){ g_free (x); x = 0; }
-#define lfree_if_defined(x) if (x){ list_free (x); x = 0; }
-void
-ical_object_destroy (iCalObject *ico)
-{
- /* Regular strings */
- free_if_defined (ico->comment);
- free_if_defined (ico->organizer);
- free_if_defined (ico->summary);
- free_if_defined (ico->uid);
- free_if_defined (ico->status);
- free_if_defined (ico->class);
- free_if_defined (ico->url);
- free_if_defined (ico->recur);
-
- /* Lists */
- lfree_if_defined (ico->exdate);
- lfree_if_defined (ico->categories);
- lfree_if_defined (ico->resources);
- lfree_if_defined (ico->related);
- lfree_if_defined (ico->attach);
-
- /* Alarms */
- g_free (ico->dalarm.data);
- g_free (ico->palarm.data);
- g_free (ico->malarm.data);
- g_free (ico->aalarm.data);
-
- g_free (ico);
-}
-
-static GList *
-set_list (char *str)
-{
- GList *list = 0;
- char *s;
-
- for (s = strtok (str, ";"); s; s = strtok (NULL, ";"))
- list = g_list_prepend (list, g_strdup (s));
-
- return list;
-}
-
-static GList *
-set_date_list (char *str)
-{
- GList *list = 0;
- char *s;
-
- for (s = strtok (str, ";,"); s; s = strtok (NULL, ";,")){
- time_t *t = g_new (time_t, 1);
-
- while (*s && isspace (*s))
- s++;
- *t = time_from_isodate (s);
- list = g_list_prepend (list, t);
- }
- return list;
-}
-
-void
-ical_object_add_exdate (iCalObject *o, time_t t)
-{
- time_t *pt = g_new (time_t, 1);
-
- *pt = t;
- o->exdate = g_list_prepend (o->exdate, pt);
-}
-
-static void
-ignore_space(char **str)
-{
- while (**str && isspace (**str))
- (*str)++;
-}
-
-static void
-skip_numbers (char **str)
-{
- while (**str){
- ignore_space (str);
- if (!isdigit (**str))
- return;
- while (**str && isdigit (**str))
- (*str)++;
- }
-}
-
-static void
-weekdaylist (iCalObject *o, char **str)
-{
- int i;
- struct {
- char first_letter, second_letter;
- int index;
- } days [] = {
- { 'S', 'U', 0 },
- { 'M', 'O', 1 },
- { 'T', 'U', 2 },
- { 'W', 'E', 3 },
- { 'T', 'H', 4 },
- { 'F', 'R', 5 },
- { 'S', 'A', 6 }
- };
-
- ignore_space (str);
- do {
- for (i = 0; i < 7; i++){
- if (**str == days [i].first_letter && *(*str+1) == days [i].second_letter){
- o->recur->weekday |= 1 << i;
- *str += 2;
- if (**str == ' ')
- (*str)++;
- }
- }
- } while (isalpha (**str));
-
- if (o->recur->weekday == 0){
- struct tm tm = *localtime (&o->dtstart);
-
- o->recur->weekday = 1 << tm.tm_wday;
- }
-}
-
-static void
-weekdaynum (iCalObject *o, char **str)
-{
- int i;
- struct {
- char first_letter, second_letter;
- int index;
- } days [] = {
- { 'S', 'U', 0 },
- { 'M', 'O', 1 },
- { 'T', 'U', 2 },
- { 'W', 'E', 3 },
- { 'T', 'H', 4 },
- { 'F', 'R', 5 },
- { 'S', 'A', 6 }
- };
-
- ignore_space (str);
- do {
- for (i = 0; i < 7; i++){
- if (**str == days [i].first_letter && *(*str+1) == days [i].second_letter){
- o->recur->weekday = i;
- *str += 2;
- if (**str == ' ')
- (*str)++;
- }
- }
- } while (isalpha (**str));
-}
-
-static void
-ocurrencelist (iCalObject *o, char **str)
-{
- char *p;
-
- ignore_space (str);
- p = *str;
- if (!isdigit (*p))
- return;
-
- if (!(*p >= '1' && *p <= '5'))
- return;
-
- if (!(*(p+1) == '+' || *(p+1) == '-'))
- return;
-
- o->recur->u.month_pos = (*p-'0') * (*(p+1) == '+' ? 1 : -1);
- *str += 2;
-}
-
-static void
-daynumber (iCalObject *o, char **str)
-{
- int val = 0;
- char *p = *str;
-
- ignore_space (str);
- if (strcmp (p, "LD")){
- o->recur->u.month_day = DAY_LASTDAY;
- *str += 2;
- return;
- }
-
- if (!(isdigit (*p)))
- return;
-
- while (**str && isdigit (**str)){
- val = val * 10 + (**str - '0');
- (*str)++;
- }
-
- if (**str == '+')
- (*str)++;
-
- if (**str == '-')
- val *= -1;
- o->recur->u.month_day = val;
-}
-
-static void
-daynumberlist (iCalObject *o, char **str)
-{
- int first = 0;
- int val = 0;
-
- ignore_space (str);
-
- while (**str){
- if (!isdigit (**str))
- return;
- while (**str && isdigit (**str)){
- val = 10 * val + (**str - '0');
- (*str)++;
- }
- if (!first){
- /*
- * Some broken applications set this to zero
- */
- if (val == 0){
- struct tm day = *localtime (&o->dtstart);
-
- val = day.tm_mday;
- }
- o->recur->u.month_day = val;
- first = 1;
- val = 0;
- }
- }
-}
-
-static void
-load_recur_weekly (iCalObject *o, char **str)
-{
- weekdaylist (o, str);
-}
-
-static void
-load_recur_monthly_pos (iCalObject *o, char **str)
-{
- ocurrencelist (o, str);
- weekdaynum (o, str);
-}
-
-static void
-load_recur_monthly_day (iCalObject *o, char **str)
-{
- daynumberlist (o, str);
-}
-
-static void
-load_recur_yearly_month (iCalObject *o, char **str)
-{
- /* Skip as we do not support multiple months and we do expect
- * the dtstart to agree with the value on this field
- */
- skip_numbers (str);
-}
-
-static void
-load_recur_yearly_day (iCalObject *o, char **str)
-{
- /* Skip as we do not support multiple days and we do expect
- * the dtstart to agree with the value on this field
- *
- * FIXME: we should support every-n-years
- */
- skip_numbers (str);
-}
-
-static void
-duration (iCalObject *o, char **str)
-{
- unsigned int duration = 0;
-
- ignore_space (str);
- if (**str != '#')
- return;
- (*str)++;
- while (**str && isdigit (**str)){
- duration = duration * 10 + (**str - '0');
- (*str)++;
- }
- o->recur->duration = duration;
-}
-
-static void
-enddate (iCalObject *o, char **str)
-{
- ignore_space (str);
- if (isdigit (**str)){
- o->recur->_enddate = time_from_isodate (*str);
- *str += 16;
- }
-}
-
-static int
-load_recurrence (iCalObject *o, char *str)
-{
- enum RecurType type;
- int interval = 0;
-
- type = -1;
- switch (*str++){
- case 'D':
- type = RECUR_DAILY;
- break;
-
- case 'W':
- type = RECUR_WEEKLY;
- break;
-
- case 'M':
- if (*str == 'P')
- type = RECUR_MONTHLY_BY_POS;
- else if (*str == 'D')
- type = RECUR_MONTHLY_BY_DAY;
- str++;
- break;
-
- case 'Y':
- if (*str == 'M')
- type = RECUR_YEARLY_BY_MONTH;
- else if (*str == 'D')
- type = RECUR_YEARLY_BY_DAY;
- str++;
- break;
- }
- if (type == -1)
- return 0;
-
- o->recur = g_new0 (Recurrence, 1);
- o->recur->type = type;
- ignore_space (&str);
-
- /* Get the interval */
- for (;*str && isdigit (*str);str++)
- interval = interval * 10 + (*str-'0');
-
- if (interval == 0)
- interval = 1;
-
- o->recur->interval = interval;
-
- /* this is the default per the spec */
- o->recur->duration = 2;
-
- ignore_space (&str);
-
- switch (type){
- case RECUR_DAILY:
- break;
- case RECUR_WEEKLY:
- load_recur_weekly (o, &str);
- break;
- case RECUR_MONTHLY_BY_POS:
- load_recur_monthly_pos (o, &str);
- break;
- case RECUR_MONTHLY_BY_DAY:
- load_recur_monthly_day (o, &str);
- break;
- case RECUR_YEARLY_BY_MONTH:
- load_recur_yearly_month (o, &str);
- break;
- case RECUR_YEARLY_BY_DAY:
- load_recur_yearly_day (o, &str);
- break;
- default:
- g_warning ("Unimplemented recurrence type %d", (int) type);
- break;
- }
- duration (o, &str);
- enddate (o, &str);
-
- /* Compute the enddate */
- if (o->recur->_enddate == 0){
- if (o->recur->duration != 0){
- ical_object_compute_end (o);
- } else
- o->recur->enddate = 0;
- } else {
- o->recur->enddate = o->recur->_enddate;
- }
- return 1;
-}
-
-#define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop)
-#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj))
-#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
-
-/*
- * FIXME: This is loosing precission. Enhanec the thresholds
- */
-#define HOURS(n) (n*(60*60))
-
-static void
-setup_alarm_at (iCalObject *ico, CalendarAlarm *alarm, char *iso_time, VObject *vo)
-{
- time_t alarm_time = time_from_isodate (iso_time);
- time_t base = ico->dtstart;
- int d = difftime (base, alarm_time);
- VObject *a;
- char *the_str;
-
- alarm->enabled = 1;
- if (d > HOURS (2)){
- if (d > HOURS (48)){
- alarm->count = d / HOURS (24);
- alarm->units = ALARM_DAYS;
- } else {
- alarm->count = d / (60*60);
- alarm->units = ALARM_HOURS;
- }
- } else {
- alarm->count = d / 60;
- alarm->units = ALARM_MINUTES;
- }
-
- if ((a = is_a_prop_of (vo, VCSnoozeTimeProp))){
- alarm->snooze_secs = isodiff_to_secs (str_val (a));
- free (the_str);
- }
-
- if ((a = is_a_prop_of (vo, VCRepeatCountProp))){
- alarm->snooze_repeat = atoi (str_val (a));
- free (the_str);
- }
-}
-
-/*
- * Duplicates an iCalObject. Implementation is a grand hack
- */
-iCalObject *
-ical_object_duplicate (iCalObject *o)
-{
- VObject *vo;
- iCalObject *new;
-
- vo = ical_object_to_vobject (o);
- switch (o->type){
- case ICAL_EVENT:
- new = ical_object_create_from_vobject (vo, VCEventProp);
- break;
- case ICAL_TODO:
- new = ical_object_create_from_vobject (vo, VCTodoProp);
- break;
- default:
- new = NULL;
- }
-
- cleanVObject (vo);
- return new;
-}
-
-/* FIXME: we need to load the recurrence properties */
-iCalObject *
-ical_object_create_from_vobject (VObject *o, const char *object_name)
-{
- time_t now = time (NULL);
- iCalObject *ical;
- VObject *vo, *a;
- VObjectIterator i;
- char *the_str;
-
- ical = g_new0 (iCalObject, 1);
-
- if (strcmp (object_name, VCEventProp) == 0)
- ical->type = ICAL_EVENT;
- else if (strcmp (object_name, VCTodoProp) == 0)
- ical->type = ICAL_TODO;
- else {
- g_free (ical);
- return 0;
- }
-
- /* uid */
- if (has (o, VCUniqueStringProp)){
- ical->uid = g_strdup (str_val (vo));
- free (the_str);
- } else {
- ical->uid = ical_gen_uid ();
- }
-
- /* seq */
- if (has (o, VCSequenceProp)){
- ical->seq = atoi (str_val (vo));
- free (the_str);
- } else
- ical->seq = 0;
-
- /* dtstart */
- if (has (o, VCDTstartProp)){
- ical->dtstart = time_from_isodate (str_val (vo));
- free (the_str);
- } else
- ical->dtstart = 0;
-
- /* dtend */
- ical->dtend = 0; /* default value */
- if (ical->type == ICAL_EVENT){
- if (has (o, VCDTendProp)){
- ical->dtend = time_from_isodate (str_val (vo));
- free (the_str);
- }
- } else if (ical->type == ICAL_TODO){
- if (has (o, VCDueProp)){
- ical->dtend = time_from_isodate (str_val (vo));
- free (the_str);
- }
- }
-
- /* dcreated */
- if (has (o, VCDCreatedProp)){
- ical->created = time_from_isodate (str_val (vo));
- free (the_str);
- }
-
- /* completed */
- if (has (o, VCCompletedProp)){
- ical->completed = time_from_isodate (str_val (vo));
- free (the_str);
- }
-
- /* last_mod */
- if (has (o, VCLastModifiedProp)){
- ical->last_mod = time_from_isodate (str_val (vo));
- free (the_str);
- } else
- ical->last_mod = now;
-
- /* exdate */
- if (has (o, VCExpDateProp)){
- ical->exdate = set_date_list (str_val (vo));
- free (the_str);
- }
-
- /* description/comment */
- if (has (o, VCDescriptionProp)){
- ical->comment = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* summary */
- if (has (o, VCSummaryProp)){
- ical->summary = g_strdup (str_val (vo));
- free (the_str);
- } else
- ical->summary = g_strdup ("");
-
- /* status */
- if (has (o, VCStatusProp)){
- ical->status = g_strdup (str_val (vo));
- free (the_str);
- } else
- ical->status = g_strdup ("NEEDS ACTION");
-
- if (has (o, VCClassProp)){
- ical->class = g_strdup (str_val (vo));
- free (the_str);
- } else
- ical->class = "PUBLIC";
-
- /* categories */
- if (has (o, VCCategoriesProp)){
- ical->categories = set_list (str_val (vo));
- free (the_str);
- }
-
- /* resources */
- if (has (o, VCResourcesProp)){
- ical->resources = set_list (str_val (vo));
- free (the_str);
- }
-
- /* priority */
- if (has (o, VCPriorityProp)){
- ical->priority = atoi (str_val (vo));
- free (the_str);
- }
-
- /* tranparency */
- if (has (o, VCTranspProp)){
- ical->transp = atoi (str_val (vo)) ? ICAL_TRANSPARENT : ICAL_OPAQUE;
- free (the_str);
- }
-
- /* Organizer */
- if (has (o, VCOrgNameProp)){
- ical->organizer = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* related */
- if (has (o, VCRelatedToProp)){
- ical->related = set_list (str_val (vo));
- free (the_str);
- }
-
- /* attach */
- initPropIterator (&i, o);
- while (moreIteration (&i)){
- vo = nextVObject (&i);
- if (strcmp (vObjectName (vo), VCAttachProp) == 0){
- ical->attach = g_list_prepend (ical->attach, g_strdup (str_val (vo)));
- free (the_str);
- }
- }
-
- /* url */
- if (has (o, VCURLProp)){
- ical->url = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* dalarm */
- ical->dalarm.type = ALARM_DISPLAY;
- ical->dalarm.enabled = 0;
- if (has (o, VCDAlarmProp)){
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->dalarm, str_val (a), vo);
- free (the_str);
- }
- }
-
- /* aalarm */
- ical->aalarm.type = ALARM_AUDIO;
- ical->aalarm.enabled = 0;
- if (has (o, VCAAlarmProp)){
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->aalarm, str_val (a), vo);
- free (the_str);
- }
- }
-
- /* palarm */
- ical->palarm.type = ALARM_PROGRAM;
- ical->palarm.enabled = 0;
- if (has (o, VCPAlarmProp)){
- ical->palarm.type = ALARM_PROGRAM;
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->palarm, str_val (a), vo);
- free (the_str);
-
- if ((a = is_a_prop_of (vo, VCProcedureNameProp))){
- ical->palarm.data = g_strdup (str_val (a));
- free (the_str);
- } else
- ical->palarm.data = g_strdup ("");
- }
- }
-
- /* malarm */
- ical->malarm.type = ALARM_MAIL;
- ical->malarm.enabled = 0;
- if (has (o, VCMAlarmProp)){
- ical->malarm.type = ALARM_MAIL;
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->malarm, str_val (a), vo);
- free (the_str);
-
- if ((a = is_a_prop_of (vo, VCEmailAddressProp))){
- ical->malarm.data = g_strdup (str_val (a));
- free (the_str);
- } else
- ical->malarm.data = g_strdup ("");
- }
- }
-
- /* rrule */
- if (has (o, VCRRuleProp)){
- if (!load_recurrence (ical, str_val (vo))) {
- ical_object_destroy (ical);
- return NULL;
- }
- free (the_str);
- }
-
- /*
- * Pilot
- */
- if (has (o, XPilotIdProp)){
- ical->pilot_id = atoi (str_val (vo));
- free (the_str);
- } else
- ical->pilot_id = 0;
-
- if (has (o, XPilotStatusProp)){
- ical->pilot_status = atoi (str_val (vo));
- free (the_str);
- } else
- ical->pilot_status = ICAL_PILOT_SYNC_MOD;
-
- return ical;
-}
-
-static char *
-to_str (int num)
-{
- static char buf [40];
-
- sprintf (buf, "%d", num);
- return buf;
-}
-
-/*
- * stores a GList in the property.
- */
-static void
-store_list (VObject *o, char *prop, GList *values)
-{
- GList *l;
- int len;
- char *result, *p;
-
- for (len = 0, l = values; l; l = l->next)
- len += strlen (l->data) + 1;
-
- result = g_malloc (len);
-
- for (p = result, l = values; l; l = l->next) {
- int len = strlen (l->data);
-
- strcpy (p, l->data);
-
- if (l->next) {
- p [len] = ';';
- p += len+1;
- } else
- p += len;
- }
-
- *p = 0;
-
- addPropValue (o, prop, result);
- g_free (result);
-}
-
-static void
-store_date_list (VObject *o, char *prop, GList *values)
-{
- GList *l;
- int size, len;
- char *s, *p;
-
- size = g_list_length (values);
- s = p = g_malloc ((size * 17 + 1) * sizeof (char));
-
- for (l = values; l; l = l->next){
- strcpy (s, isodate_from_time_t (*(time_t *)l->data));
- len = strlen (s);
- s [len] = ',';
- s += len + 1;
- }
- s--;
- *s = 0;
- addPropValue (o, prop, p);
- g_free (p);
-}
-
-static char *recur_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" };
-static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" };
-static char *alarm_names [] = { VCMAlarmProp, VCPAlarmProp, VCDAlarmProp, VCAAlarmProp };
-
-static VObject *
-save_alarm (VObject *o, CalendarAlarm *alarm, iCalObject *ical)
-{
- VObject *alarm_object;
- struct tm tm;
- time_t alarm_time;
-
- if (!alarm->enabled)
- return NULL;
- tm = *localtime (&ical->dtstart);
- switch (alarm->units){
- case ALARM_MINUTES:
- tm.tm_min -= alarm->count;
- break;
-
- case ALARM_HOURS:
- tm.tm_hour -= alarm->count;
- break;
-
- case ALARM_DAYS:
- tm.tm_mday -= alarm->count;
- break;
- }
-
- alarm_time = mktime (&tm);
- alarm_object = addProp (o, alarm_names [alarm->type]);
- addPropValue (alarm_object, VCRunTimeProp, isodate_from_time_t (alarm_time));
-
- if (alarm->snooze_secs)
- addPropValue (alarm_object, VCSnoozeTimeProp, isodiff_from_secs (alarm->snooze_secs));
- else
- addPropValue (alarm_object, VCSnoozeTimeProp, "");
-
- if (alarm->snooze_repeat){
- char buf [20];
-
- sprintf (buf, "%d", alarm->snooze_repeat);
- addPropValue (alarm_object, VCRepeatCountProp, buf);
- } else
- addPropValue (alarm_object, VCRepeatCountProp, "");
- return alarm_object;
-}
-
-VObject *
-ical_object_to_vobject (iCalObject *ical)
-{
- VObject *o, *alarm, *s;
- GList *l;
-
- if (ical->type == ICAL_EVENT)
- o = newVObject (VCEventProp);
- else
- o = newVObject (VCTodoProp);
-
- /* uid */
- if (ical->uid)
- addPropValue (o, VCUniqueStringProp, ical->uid);
-
- /* seq */
- addPropValue (o, VCSequenceProp, to_str (ical->seq));
-
- /* dtstart */
- addPropValue (o, VCDTstartProp, isodate_from_time_t (ical->dtstart));
-
- /* dtend */
- if (ical->type == ICAL_EVENT){
- addPropValue (o, VCDTendProp, isodate_from_time_t (ical->dtend));
- } else if (ical->type == ICAL_TODO){
- addPropValue (o, VCDueProp, isodate_from_time_t (ical->dtend));
- }
-
- /* dcreated */
- addPropValue (o, VCDCreatedProp, isodate_from_time_t (ical->created));
-
- /* completed */
- if (ical->completed)
- addPropValue (o, VCDTendProp, isodate_from_time_t (ical->completed));
-
- /* last_mod */
- addPropValue (o, VCLastModifiedProp, isodate_from_time_t (ical->last_mod));
-
- /* exdate */
- if (ical->exdate)
- store_date_list (o, VCExpDateProp, ical->exdate);
-
- /* description/comment */
- if (ical->comment && strlen (ical->comment)){
- s = addPropValue (o, VCDescriptionProp, ical->comment);
- if (strchr (ical->comment, '\n'))
- addProp (s, VCQuotedPrintableProp);
- }
-
- /* summary */
- if (strlen (ical->summary)){
- s = addPropValue (o, VCSummaryProp, ical->summary);
- if (strchr (ical->summary, '\n'))
- addProp (s, VCQuotedPrintableProp);
- } else {
- addPropValue (o, VCSummaryProp, _("Appointment"));
- }
-
- /* status */
- addPropValue (o, VCStatusProp, ical->status);
-
- /* class */
- addPropValue (o, VCClassProp, ical->class);
-
- /* categories */
- if (ical->categories)
- store_list (o, VCCategoriesProp, ical->categories);
-
- /* resources */
- if (ical->resources)
- store_list (o, VCCategoriesProp, ical->resources);
-
- /* priority */
- addPropValue (o, VCPriorityProp, to_str (ical->priority));
-
- /* transparency */
- addPropValue (o, VCTranspProp, to_str (ical->transp));
-
- /* Owenr/organizer */
- if (ical->organizer)
- addPropValue (o, VCOrgNameProp, ical->organizer);
-
- /* related */
- if (ical->related)
- store_list (o, VCRelatedToProp, ical->related);
-
- /* attach */
- for (l = ical->attach; l; l = l->next)
- addPropValue (o, VCAttachProp, l->data);
-
- /* url */
- if (ical->url)
- addPropValue (o, VCURLProp, ical->url);
-
- if (ical->recur){
- char result [256];
- char buffer [80];
- int i;
-
- sprintf (result, "%s%d ", recur_type_name [ical->recur->type], ical->recur->interval);
- switch (ical->recur->type){
- case RECUR_DAILY:
- break;
-
- case RECUR_WEEKLY:
- for (i = 0; i < 7; i++){
- if (ical->recur->weekday & (1 << i)){
- sprintf (buffer, "%s ", recur_day_list [i]);
- strcat (result, buffer);
- }
- }
- break;
-
- case RECUR_MONTHLY_BY_POS: {
- int nega = ical->recur->u.month_pos < 0;
-
- sprintf (buffer, "%d%s ", nega ? -ical->recur->u.month_pos : ical->recur->u.month_pos,
- nega ? "-" : "+");
- strcat (result, buffer);
- /* the gui is set up for a single day, not a set here in this case */
- sprintf (buffer, "%s ", recur_day_list [ical->recur->weekday]);
- strcat (result, buffer);
- }
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- sprintf (buffer, "%d ", ical->recur->u.month_pos);
- strcat (result, buffer);
- break;
-
- case RECUR_YEARLY_BY_MONTH:
- break;
-
- case RECUR_YEARLY_BY_DAY:
- break;
- }
- if (ical->recur->_enddate == 0)
- sprintf (buffer, "#%d ",ical->recur->duration);
- else
- sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
- strcat (result, buffer);
- addPropValue (o, VCRRuleProp, result);
- }
-
- save_alarm (o, &ical->aalarm, ical);
- save_alarm (o, &ical->dalarm, ical);
-
- if ((alarm = save_alarm (o, &ical->palarm, ical)))
- addPropValue (alarm, VCProcedureNameProp, ical->palarm.data);
- if ((alarm = save_alarm (o, &ical->malarm, ical)))
- addPropValue (alarm, VCEmailAddressProp, ical->malarm.data);
-
- /* Pilot */
- {
- char buffer [20];
-
- sprintf (buffer, "%d", ical->pilot_id);
- addPropValue (o, XPilotIdProp, buffer);
- sprintf (buffer, "%d", ical->pilot_status);
- addPropValue (o, XPilotStatusProp, buffer);
- }
-
- return o;
-}
-
-void
-ical_foreach (GList *events, calendarfn fn, void *closure)
-{
- for (; events; events = events->next){
- iCalObject *ical = events->data;
-
- (*fn) (ical, ical->dtstart, ical->dtend, closure);
- }
-}
-
-static int
-is_date_in_list (GList *list, struct tm *date)
-{
- struct tm tm;
-
- for (; list; list = list->next){
- time_t *timep = list->data;
-
- tm = *localtime (timep);
- if (date->tm_mday == tm.tm_mday &&
- date->tm_mon == tm.tm_mon &&
- date->tm_year == tm.tm_year){
- return 1;
- }
- }
- return 0;
-}
-
-static int
-generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure)
-{
- struct tm dt_start, dt_end, ref;
- time_t s_t, e_t;
-
- dt_start = *localtime (&ico->dtstart);
- dt_end = *localtime (&ico->dtend);
- ref = *localtime (&reference);
-
- dt_start.tm_mday = ref.tm_mday;
- dt_start.tm_mon = ref.tm_mon;
- dt_start.tm_year = ref.tm_year;
-
- dt_end.tm_mday = ref.tm_mday;
- dt_end.tm_mon = ref.tm_mon;
- dt_end.tm_year = ref.tm_year;
-
-
- if (ref.tm_isdst > dt_start.tm_isdst){
- dt_start.tm_hour--;
- dt_end.tm_hour--;
- } else if (ref.tm_isdst < dt_start.tm_isdst){
- dt_start.tm_hour++;
- dt_end.tm_hour++;
- }
-
- s_t = mktime (&dt_start);
-
- if (ico->exdate && is_date_in_list (ico->exdate, &dt_start))
- return 1;
-
- e_t = mktime (&dt_end);
-
- if ((s_t == -1) || (e_t == -1)) {
- g_warning ("Produced invalid dates!\n");
- return 0;
- }
-
- return (*cb) (ico, s_t, e_t, closure);
-}
-
-int
-ical_object_get_first_weekday (int weekday_mask)
-{
- int i;
-
- for (i = 0; i < 7; i++)
- if (weekday_mask & (1 << i))
- return i;
-
- return -1;
-}
-
-#define time_in_range(t, a, b) ((t >= a) && (b ? (t < b) : 1))
-#define recur_in_range(t, r) (r->enddate ? (t < r->enddate) : 1)
-
-/*
- * Generate every possible event. Invokes the callback routine for
- * every occurrence of the event in the [START, END] time interval.
- *
- * If END is zero, the event is generated forever.
- * The callback routine is expected to return 0 when no further event
- * generation is requested.
- */
-void
-ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure)
-{
- time_t current;
- int first_week_day;
-
- /* If there is no recurrence, just check ranges */
-
- if (!ico->recur) {
- if ((end && (ico->dtstart < end) && (ico->dtend > start))
- || ((end == 0) && (ico->dtend > start))) {
- time_t ev_s, ev_e;
-
- /* Clip range */
-
- ev_s = MAX (ico->dtstart, start);
- ev_e = MIN (ico->dtend, end);
-
- (* cb) (ico, ev_s, ev_e, closure);
- }
- return;
- }
-
- /* The event has a recurrence rule -- check that we will generate at least one instance */
-
- if (end != 0) {
- if (ico->dtstart > end)
- return;
-
- if (!IS_INFINITE (ico->recur) && (ico->recur->enddate < start))
- return;
- }
-
- /* Generate the instances */
-
- current = ico->dtstart;
-
- switch (ico->recur->type) {
- case RECUR_DAILY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, current, cb, closure))
- return;
-
- /* Advance */
-
- current = time_add_day (current, ico->recur->interval);
-
- if (current == -1) {
- g_warning ("RECUR_DAILY: time_add_day() returned invalid time");
- return;
- }
- } while ((current < end) || (end == 0));
-
- break;
-
- case RECUR_WEEKLY:
- do {
- struct tm tm;
-
- tm = *localtime (&current);
-
- if (time_in_range (current, start, end) && recur_in_range (current, ico->recur)) {
- /* Weekdays to recur on are specified as a bitmask */
- if (ico->recur->weekday & (1 << tm.tm_wday)) {
- if (!generate (ico, current, cb, closure))
- return;
- }
- }
-
- /* Advance by day for scanning the week or by interval at week end */
-
- if (tm.tm_wday == 6)
- current = time_add_day (current, (ico->recur->interval - 1) * 7 + 1);
- else
- current = time_add_day (current, 1);
-
- if (current == -1) {
- g_warning ("RECUR_WEEKLY: time_add_day() returned invalid time\n");
- return;
- }
- } while (current < end || (end == 0));
-
- break;
-
- case RECUR_MONTHLY_BY_POS:
- /* FIXME: We only deal with positives now */
- if (ico->recur->u.month_pos < 0) {
- g_warning ("RECUR_MONTHLY_BY_POS does not support negative positions yet");
- return;
- }
-
- if (ico->recur->u.month_pos == 0)
- return;
-
- first_week_day = /* ical_object_get_first_weekday (ico->recur->weekday); */
- ico->recur->weekday; /* the i/f only lets you choose a single day of the week! */
-
- /* This should not happen, but take it into account */
- if (first_week_day == -1) {
- g_warning ("ical_object_get_first_weekday() returned -1");
- return;
- }
-
- do {
- struct tm tm;
- time_t t;
- int week_day_start;
-
- tm = *localtime (&current);
- tm.tm_mday = 1;
- t = mktime (&tm);
- tm = *localtime (&t);
- week_day_start = tm.tm_wday;
-
- tm.tm_mday = (7 * (ico->recur->u.month_pos - ((week_day_start <= first_week_day ) ? 1 : 0))
- - (week_day_start - first_week_day) + 1);
- if( tm.tm_mday > 31 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
-
- switch( tm.tm_mon )
- {
- case 3:
- case 5:
- case 8:
- case 10:
- if( tm.tm_mday > 30 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
- break;
- case 1:
- if( ((tm.tm_year+1900)%4) == 0
- && ((tm.tm_year+1900)%400) != 100
- && ((tm.tm_year+1900)%400) != 200
- && ((tm.tm_year+1900)%400) != 300 )
- {
-
- if( tm.tm_mday > 29 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
- }
- else
- {
- if( tm.tm_mday > 28 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
- }
- break;
- }
-
- t = mktime (&tm);
-
- if (time_in_range (t, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance by the appropriate number of months */
-
- current = mktime (&tm);
-
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
-
- if (current == -1) {
- g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
- return;
- }
- } while ((current < end) || (end == 0));
-
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- do {
- struct tm tm;
- time_t t;
- int p;
-
- tm = *localtime (&current);
-
- p = tm.tm_mday;
- tm.tm_mday = ico->recur->u.month_day;
- t = mktime (&tm);
- if (time_in_range (t, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance by the appropriate number of months */
-
- tm.tm_mday = p;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
-
- if (current == -1) {
- g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
- return;
- }
- } while (current < end || (end == 0));
-
- break;
-
- case RECUR_YEARLY_BY_MONTH:
- case RECUR_YEARLY_BY_DAY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, current, cb, closure))
- return;
-
- /* Advance */
-
- current = time_add_year (current, ico->recur->interval);
- } while (current < end || (end == 0));
-
- break;
-
- default:
- g_assert_not_reached ();
- }
-}
-
-static int
-duration_callback (iCalObject *ico, time_t start, time_t end, void *closure)
-{
- int *count = closure;
- struct tm tm;
-
- tm = *localtime (&start);
-
- (*count)++;
- if (ico->recur->duration == *count) {
- ico->recur->enddate = time_day_end (end);
- return 0;
- }
- return 1;
-}
-
-/* Computes ico->recur->enddate from ico->recur->duration */
-void
-ical_object_compute_end (iCalObject *ico)
-{
- int count = 0;
-
- g_return_if_fail (ico->recur != NULL);
-
- ico->recur->_enddate = 0;
- ico->recur->enddate = 0;
- ical_object_generate_events (ico, ico->dtstart, 0, duration_callback, &count);
-}
-
-int
-alarm_compute_offset (CalendarAlarm *a)
-{
- if (!a->enabled)
- return -1;
- switch (a->units){
- case ALARM_MINUTES:
- a->offset = a->count * 60;
- break;
- case ALARM_HOURS:
- a->offset = a->count * 3600;
- break;
- case ALARM_DAYS:
- a->offset = a->count * 24 * 3600;
- }
- return a->offset;
-}
-
-iCalObject *
-ical_object_new_from_string (const char *vcal_string)
-{
- iCalObject *ical = NULL;
- VObject *cal, *event;
- VObjectIterator i;
- const char *object_name;
-
- cal = Parse_MIME (vcal_string, strlen (vcal_string));
-
- initPropIterator (&i, cal);
-
- while (moreIteration (&i)){
- event = nextVObject (&i);
-
- object_name = vObjectName (event);
-
- if (strcmp (object_name, VCEventProp) == 0){
- ical = ical_object_create_from_vobject (event, object_name);
- break;
- }
- }
-
- cleanVObject (cal);
- cleanStrTbl ();
-
- return ical;
-}
-
diff --git a/calendar/calobj.h b/calendar/calobj.h
deleted file mode 100644
index fbc92a41c5..0000000000
--- a/calendar/calobj.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Internal representation of a Calendar object. This is modeled after the
- * iCalendar/vCalendar specificiation
- *
- * Authors: Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org).
- */
-#ifndef CALOBJ_H
-#define CALOBJ_H
-
-#include <libgnome/libgnome.h>
-#include "../libversit/vcc.h"
-
-BEGIN_GNOME_DECLS
-
-enum AlarmType {
- ALARM_MAIL,
- ALARM_PROGRAM,
- ALARM_DISPLAY,
- ALARM_AUDIO
-};
-
-enum AlarmUnit {
- ALARM_MINUTES,
- ALARM_HOURS,
- ALARM_DAYS
-};
-
-typedef struct {
- enum AlarmType type;
- int enabled;
- int count;
- enum AlarmUnit units;
- char *data;
-
- /* Does not get saved, internally used */
- time_t offset;
- time_t trigger;
-
- int snooze_secs;
- int snooze_repeat;
-
- /* Widgets */
- void *w_count; /* A GtkEntry */
- void *w_enabled; /* A GtkChecButton */
- void *w_timesel; /* A GtkMenu */
- void *w_entry; /* A GnomeEntryFile/GtkEntry for PROGRAM/MAIL */
- void *w_label;
-} CalendarAlarm;
-
-/* Calendar object type */
-typedef enum {
- ICAL_EVENT,
- ICAL_TODO,
- ICAL_JOURNAL,
- ICAL_FBREQUEST,
- ICAL_FBREPLY,
- ICAL_BUSYTIME,
- ICAL_TIMEZONE
-} iCalType;
-
-/* For keys that might contain binary or text/binary */
-typedef struct {
- char *data;
- int len;
-} iCalValue;
-
-typedef enum {
- ICAL_PILOT_SYNC_NONE = 0,
- ICAL_PILOT_SYNC_MOD = 1,
- ICAL_PILOT_SYNC_DEL = 3
-} iCalPilotState;
-
-typedef struct {
- int valid; /* true if the Geography was specified */
- double latitude;
- double longitude;
-} iCalGeo;
-
-typedef enum {
- ICAL_OPAQUE,
- ICAL_TRANSPARENT
-} iCalTransp;
-
-typedef char NotYet;
-
-enum RecurType {
- RECUR_DAILY,
- RECUR_WEEKLY,
- RECUR_MONTHLY_BY_POS,
- RECUR_MONTHLY_BY_DAY,
- RECUR_YEARLY_BY_MONTH,
- RECUR_YEARLY_BY_DAY,
-};
-
-#define DAY_LASTDAY 10000
-
-typedef struct {
- enum RecurType type;
-
- int interval;
-
- /* Used for recur computation */
- time_t enddate; /* If the value is zero, it is an infinite event
- * otherwise, it is either the _enddate value (if
- * this is what got specified) or it is our computed
- * ending date (computed from the duration item).
- */
-
- int weekday;
-
- union {
- int month_pos;
- int month_day;
- } u;
-
- int duration;
- time_t _enddate; /* As found on the vCalendar file */
- int __count;
-} Recurrence;
-
-#define IS_INFINITE(r) (r->duration == 0)
-
-/* Flags to indicate what has changed in an object */
-typedef enum {
- CHANGE_NEW = 1 << 0, /* new object */
- CHANGE_SUMMARY = 1 << 1, /* summary */
- CHANGE_DATES = 1 << 2, /* dtstart / dtend */
- CHANGE_ALL = CHANGE_SUMMARY | CHANGE_DATES
-} CalObjectChange;
-
-/*
- * This describes an iCalendar object, note that we never store durations, instead we
- * always compute the end time computed from the start + duration.
- */
-typedef struct {
- iCalType type;
-
- GList *attach; /* type: one or more URIs or binary data */
- GList *attendee; /* type: CAL-ADDRESS */
- GList *categories; /* type: one or more TEXT */
- char *class;
-
- char *comment; /* we collapse one or more TEXTs into one */
- time_t completed;
- time_t created;
- GList *contact; /* type: one or more TEXT */
- time_t dtstamp;
- time_t dtstart;
- time_t dtend;
- GList *exdate; /* type: one or more time_t's */
- GList *exrule; /* type: one or more RECUR */
- iCalGeo geo;
- time_t last_mod;
- char *location;
- char *organizer;
- int percent;
- int priority;
- char *rstatus; /* request status for freebusy */
- GList *related; /* type: one or more TEXT */
- GList *resources; /* type: one or more TEXT */
- GList *rdate; /* type: one or more recurrence date */
- GList *rrule; /* type: one or more recurrence rules */
- int seq;
- char *status;
- char *summary;
- iCalTransp transp;
- char *uid;
- char *url;
- time_t recurid;
-
- CalendarAlarm dalarm;
- CalendarAlarm aalarm;
- CalendarAlarm palarm;
- CalendarAlarm malarm;
-
- Recurrence *recur;
-
- int new;
- void *user_data; /* Generic data pointer */
-
- /* Pilot */
- iCalPilotState pilot_status; /* Status information */
- guint32 pilot_id; /* Pilot ID */
-} iCalObject;
-
-/* The callback for the recurrence generator */
-typedef int (*calendarfn) (iCalObject *, time_t, time_t, void *);
-
-iCalObject *ical_new (char *comment, char *organizer, char *summary);
-iCalObject *ical_object_new (void);
-iCalObject *ical_object_new_from_string (const char *vcalendar_string);
-void ical_object_destroy (iCalObject *ico);
-iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name);
-VObject *ical_object_to_vobject (iCalObject *ical);
-iCalObject *ical_object_duplicate (iCalObject *o);
-void ical_foreach (GList *events, calendarfn fn, void *closure);
-void ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure);
-void ical_object_add_exdate (iCalObject *o, time_t t);
-
-/* Computes the enddate field of the recurrence based on the duration */
-void ical_object_compute_end (iCalObject *ico);
-
-/* Returns the first toggled day in a weekday mask -- we do this because we do not support multiple
- * days on a monthly-by-pos recurrence. If no days are toggled, it returns -1.
- */
-int ical_object_get_first_weekday (int weekday_mask);
-
-/* Returns the number of seconds configured to trigger the alarm in advance to an event */
-int alarm_compute_offset (CalendarAlarm *a);
-
-END_GNOME_DECLS
-
-#endif
-
diff --git a/calendar/conduits/calendar/calendar-conduit-control-applet.c b/calendar/conduits/calendar/calendar-conduit-control-applet.c
deleted file mode 100644
index 2d6fb60ef5..0000000000
--- a/calendar/conduits/calendar/calendar-conduit-control-applet.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/* Control applet ("capplet") for the gnome-pilot calendar conduit, */
-/* based on */
-/* gpilotd control applet ('capplet') for use with the GNOME control center */
-/* $Id$ */
-
-#include <pwd.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <gnome.h>
-#include <ctype.h>
-
-#include <config.h>
-#include <capplet-widget.h>
-
-#include <gpilotd/gpilotd-conduit-mgmt.h>
-#include <gpilotd/gpilotd-app.h>
-#include <gpilotd/gpilotd-app-dummy-callbacks.h>
-
-#include "calendar-conduit.h"
-
-/* tell changes callbacks to ignore changes or not */
-static gboolean ignore_changes=FALSE;
-
-/* capplet widget */
-static GtkWidget *capplet=NULL;
-
-/* host/device/pilot configuration windows */
-GtkWidget *cfgOptionsWindow=NULL;
-GtkWidget *cfgStateWindow=NULL;
-GtkWidget *dialogWindow=NULL;
-
-GnomePilotConduitMgmt *conduit;
-
-static void doTrySettings(GtkWidget *widget, gpointer);
-static void doRevertSettings(GtkWidget *widget, gpointer);
-static void doSaveSettings(GtkWidget *widget, gpointer);
-
-static void readStateCfg(GtkWidget *w,GCalConduitCfg *cfg);
-static void setStateCfg(GtkWidget *w,GCalConduitCfg *cfg);
-void about_cb (GtkWidget *, gpointer);
-GCalConduitCfg *origState = NULL;
-GCalConduitCfg *curState = NULL;
-
-gint pilotId;
-CORBA_Environment ev;
-
-/* This array must be in the same order as enumerations
- in GnomePilotConduitSyncType as they are used as index.
- Custom type implies Disabled state.
-*/
-static gchar* sync_options[] ={ N_("Disabled"),
- N_("Synchronize"),
- N_("Copy From Pilot"),
- N_("Copy To Pilot"),
- N_("Merge From Pilot"),
- N_("Merge To Pilot")};
-#define SYNC_OPTIONS_COUNT 6
-
-static void
-setSettings(GCalConduitCfg* conduitCfg)
-{
- if(conduitCfg->sync_type!=GnomePilotConduitSyncTypeCustom)
- gpilotd_conduit_mgmt_enable_with_first_sync(conduit,pilotId,
- conduitCfg->sync_type,
- conduitCfg->sync_type,
- TRUE);
- else
- gpilotd_conduit_mgmt_disable(conduit,pilotId);
-
- gcalconduit_save_configuration(conduitCfg);
-}
-
-static void
-doTrySettings(GtkWidget *widget, gpointer whatever)
-{
- readStateCfg(cfgStateWindow,curState);
- setSettings(curState);
-}
-
-static void
-doSaveSettings(GtkWidget *widget, gpointer whatever)
-{
- doTrySettings(widget,whatever);
-}
-
-static void
-doCancelSettings(GtkWidget *widget, gpointer whatever)
-{
- setSettings(origState);
-}
-
-static void
-doRevertSettings(GtkWidget *widget, gpointer whatever)
-{
- gcalconduit_destroy_configuration(&curState);
- curState = gcalconduit_dupe_configuration(origState);
- setStateCfg(cfgStateWindow,curState);
- setSettings(curState);
-}
-
-static void
-insert_dir_callback (GtkEditable *editable, const gchar *text,
- gint len, gint *position, void *data)
-{
- gint i;
- gchar *curname;
-
- curname = gtk_entry_get_text(GTK_ENTRY(editable));
- if (*curname == '\0' && len > 0) {
- if (isspace(text[0])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text");
- return;
- }
- } else {
- for (i=0; i<len; i++) {
- if (isspace(text[i])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable),
- "insert_text");
- return;
- }
- }
- }
-}
-static void
-insert_dir_callback2(GtkEditable *editable, const gchar *text,
- gint length, gint *position,
- void *data)
-{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-static void
-clist_changed(GtkWidget *widget, gpointer data)
-{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-void about_cb (GtkWidget *widget, gpointer data) {
- GtkWidget *about;
- const gchar *authors[] = {_("Eskil Heyn Olsen <deity@eskil.dk>"),NULL};
-
- about = gnome_about_new(_("GnomeCalendar Conduit"), VERSION,
- _("(C) 1998"),
- authors,
- _("Configuration utility for the calendar conduit.\n"),
- _("gnome-calendar-conduit.png"));
- gtk_widget_show (about);
-
- return;
-}
-
-static void toggled_cb(GtkWidget *widget, gpointer data) {
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-/* called by the sync_type GtkOptionMenu */
-static void
-sync_action_selection(GtkMenuShell *widget, gpointer unused)
-{
- if (!ignore_changes) {
- capplet_widget_state_changed(CAPPLET_WIDGET (capplet), TRUE);
- }
-}
-
-/* called by the sync_type GtkOptionMenu */
-static void
-activate_sync_type(GtkMenuItem *widget, gpointer data)
-{
- curState->sync_type = GPOINTER_TO_INT(data);
- if(!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-static GtkWidget
-*createStateCfgWindow(void)
-{
- GtkWidget *vbox, *table;
- GtkWidget *label;
- GtkWidget *optionMenu,*menuItem;
- GtkMenu *menu;
- gint i;
-
- vbox = gtk_vbox_new(FALSE, GNOME_PAD);
-
- table = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD);
-
- label = gtk_label_new(_("Synchronize Action"));
- gtk_box_pack_start(GTK_BOX(table), label, FALSE, FALSE, GNOME_PAD);
-
- optionMenu=gtk_option_menu_new();
- gtk_object_set_data(GTK_OBJECT(vbox), "conduit_state", optionMenu);
- menu = GTK_MENU(gtk_menu_new());
-
- for (i=0; i<SYNC_OPTIONS_COUNT;i++) {
- sync_options[i]=_(sync_options[i]);
- menuItem = gtk_menu_item_new_with_label(sync_options[i]);
- gtk_widget_show(menuItem);
- gtk_signal_connect(GTK_OBJECT(menuItem),"activate",
- GTK_SIGNAL_FUNC(activate_sync_type),
- GINT_TO_POINTER(i));
- gtk_menu_append(menu,menuItem);
- }
-
- gtk_option_menu_set_menu(GTK_OPTION_MENU(optionMenu),GTK_WIDGET(menu));
- gtk_signal_connect(GTK_OBJECT(menu), "selection-done",
- GTK_SIGNAL_FUNC(sync_action_selection),
- NULL);
-
- gtk_box_pack_start(GTK_BOX(table), optionMenu, FALSE, FALSE, 0);
-
- return vbox;
-}
-
-static void
-setStateCfg(GtkWidget *widget,GCalConduitCfg *cfg)
-{
- GtkOptionMenu *optionMenu;
- GtkMenu *menu;
-
- optionMenu = gtk_object_get_data(GTK_OBJECT(widget), "conduit_state");
- g_assert(optionMenu!=NULL);
- menu = GTK_MENU(gtk_option_menu_get_menu(optionMenu));
-
-
- ignore_changes = TRUE;
- /* Here were are relying on the items in menu being the same
- order as in GnomePilotConduitSyncType. */
- gtk_option_menu_set_history(optionMenu,(int)cfg->sync_type);
- ignore_changes = FALSE;
-}
-
-
-static void
-readStateCfg(GtkWidget *w,GCalConduitCfg *cfg)
-{
-/*
- GtkWidget *button;
-
- button = gtk_object_get_data(GTK_OBJECT(w), "conduit_on_off");
-
- g_assert(button!=NULL);
-
- activated = GTK_TOGGLE_BUTTON(button)->active;
-*/
-}
-
-static void
-pilot_capplet_setup(void)
-{
- GtkWidget *frame, *table;
-
- capplet = capplet_widget_new();
-
- table = gtk_table_new(1, 2, FALSE);
- gtk_container_border_width(GTK_CONTAINER(table), GNOME_PAD);
- gtk_container_add(GTK_CONTAINER(capplet), table);
-
- frame = gtk_frame_new(_("Conduit state"));
- gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL);
- gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1);
- cfgStateWindow = createStateCfgWindow();
- gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow);
-
- gtk_signal_connect(GTK_OBJECT(capplet), "try",
- GTK_SIGNAL_FUNC(doTrySettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "revert",
- GTK_SIGNAL_FUNC(doRevertSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "ok",
- GTK_SIGNAL_FUNC(doSaveSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "cancel",
- GTK_SIGNAL_FUNC(doCancelSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "help",
- GTK_SIGNAL_FUNC(about_cb), NULL);
-
-
- setStateCfg(cfgStateWindow,curState);
-
- gtk_widget_show_all(capplet);
-}
-
-static void
-run_error_dialog(gchar *mesg,...) {
- char tmp[80];
- va_list ap;
-
- va_start(ap,mesg);
- vsnprintf(tmp,79,mesg,ap);
- dialogWindow = gnome_message_box_new(mesg,GNOME_MESSAGE_BOX_ERROR,GNOME_STOCK_BUTTON_OK,NULL);
- gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow));
- va_end(ap);
-}
-
-gint get_pilot_id_from_gpilotd() {
- gint *pilots;
- int i;
-
- i=0;
- gpilotd_get_pilot_ids(&pilots);
- if(pilots) {
- while(pilots[i]!=-1) { g_message("pilot %d = \"%d\"",i,pilots[i]); i++; }
- if(i==0) {
- run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
- return -1;
- } else {
- if(i==1)
- return pilots[0];
- else {
- g_message("too many pilots...");
- return pilots[0];
- }
- }
- } else {
- run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
- return -1;
- }
-}
-
-int
-main( int argc, char *argv[] )
-{
- /* we're a capplet */
- gnome_capplet_init ("calendar conduit control applet", NULL, argc, argv,
- NULL,
- 0, NULL);
-
- /* get pilot name from gpilotd */
- /* 1. initialize the gpilotd connection */
- if (gpilotd_init(&argc,argv)!=0) {
- run_error_dialog(_("Cannot initialze the GnomePilot Daemon"));
- g_error(_("Cannot initialze the GnomePilot Daemon"));
- return -1;
- }
-
- /* 2 connect to gpilotd */
- if (gpilotd_connect()!=0) {
- run_error_dialog(_("Cannot connect to the GnomePilot Daemon"));
- g_error(_("Cannot connect to the GnomePilot Daemon"));
- return -1;
- }
-
- pilotId = get_pilot_id_from_gpilotd();
- if(!pilotId) return -1;
-
- /* put all code to set things up in here */
- conduit = gpilotd_conduit_mgmt_new("calendar_conduit",pilotId);
- gcalconduit_load_configuration(&origState,pilotId);
- gpilotd_conduit_mgmt_get_sync_type(conduit,pilotId,&origState->sync_type);
-
- curState = gcalconduit_dupe_configuration(origState);
-
- pilot_capplet_setup();
-
-
- /* done setting up, now run main loop */
- capplet_gtk_main();
- return 0;
-}
diff --git a/calendar/conduits/calendar/calendar-conduit-control-applet.desktop b/calendar/conduits/calendar/calendar-conduit-control-applet.desktop
deleted file mode 100644
index 43c429ef97..0000000000
--- a/calendar/conduits/calendar/calendar-conduit-control-applet.desktop
+++ /dev/null
@@ -1,7 +0,0 @@
-[Desktop Entry]
-Name=GnomeCalendar
-Comment=Configure the GnomeCal conduit
-Exec=calendar-conduit-control-applet --cap-id=1
-Terminal=0
-Type=Application
-Icon=gnome-calendar-conduit.png
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
deleted file mode 100644
index 9c758b3263..0000000000
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ /dev/null
@@ -1,1416 +0,0 @@
-/* $Id$ */
-
-#include <glib.h>
-#include <gnome.h>
-
-#include <pi-source.h>
-#include <pi-socket.h>
-#include <pi-file.h>
-#include <pi-dlp.h>
-#include <pi-version.h>
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <utime.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <signal.h>
-#include <errno.h>
-
-#include <libgnorba/gnorba.h>
-#include <libgnorba/gnome-factory.h>
-
-#include <gpilotd/gnome-pilot-conduit.h>
-#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
-
-#include "GnomeCal.h"
-#include "calobj.h"
-#include "calendar.h"
-#include "timeutil.h"
-
-#include "calendar-conduit.h"
-
-int debug_alarms = 0; /* needed to satisfy some other part of gncal */
-/* Default values for alarms */ /* needed to satisfy some other part of gncal */
-CalendarAlarm alarm_defaults[4] = {
- { ALARM_MAIL, 0, 15, ALARM_MINUTES },
- { ALARM_PROGRAM, 0, 15, ALARM_MINUTES },
- { ALARM_DISPLAY, 0, 15, ALARM_MINUTES },
- { ALARM_AUDIO, 0, 15, ALARM_MINUTES }
-};
-
-GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
-void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
-void local_record_from_icalobject(GCalLocalRecord *local,iCalObject *obj);
-
-#define CONDUIT_VERSION "0.8.11"
-#ifdef G_LOG_DOMAIN
-#undef G_LOG_DOMAIN
-#endif
-#define G_LOG_DOMAIN "gcalconduit"
-
-#define DEBUG_CALCONDUIT
-#undef DEBUG_CALCONDUIT
-
-#ifdef DEBUG_CALCONDUIT
-#define show_exception(e) g_warning ("Exception: %s\n", CORBA_exception_id (e))
-#define LOG(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e)
-#else
-#define show_exception(e)
-#define LOG(e...)
-#endif
-
-#define WARN(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING, e)
-#define INFO(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e)
-
-#define catch_ret_val(_env,ret) \
- if (_env._major != CORBA_NO_EXCEPTION) { \
- g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE,"%s:%d: Caught exception",__FILE__,__LINE__); \
- g_warning ("Exception: %s\n", CORBA_exception_id (&(_env))); \
- CORBA_exception_free(&(_env)); \
- return ret; \
- }
-
-static int
-start_calendar_server (GnomePilotConduitStandardAbs *conduit,
- GCalConduitContext *ctxt)
-{
-
- g_return_val_if_fail(conduit!=NULL,-2);
- g_return_val_if_fail(ctxt!=NULL,-2);
-
- ctxt->calendar = goad_server_activate_with_id (NULL,
- "IDL:GNOME:Calendar:Repository:1.0",
- 0, NULL);
- if (ctxt->calendar == CORBA_OBJECT_NIL) {
- g_warning ("Can not communicate with GnomeCalendar server");
- return -1;
- }
-
- if (ctxt->ev._major != CORBA_NO_EXCEPTION){
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- }
- return 0;
-}
-
-
-/* Just a stub to link with */
-void
-calendar_notify (time_t time, CalendarAlarm *which, void *data)
-{
-}
-
-static GSList *
-get_calendar_objects(GnomePilotConduitStandardAbs *conduit,
- gboolean *status,
- GCalConduitContext *ctxt)
-{
- GSList *result;
- GNOME_Calendar_Repository_String_Sequence *uids;
-
- g_return_val_if_fail(conduit!=NULL,NULL);
- g_return_val_if_fail(ctxt!=NULL,NULL);
-
- result = NULL;
- uids = GNOME_Calendar_Repository_get_object_id_list (ctxt->calendar, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- if(status!=NULL) (*status) = FALSE;
- return NULL;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- if(status!=NULL) (*status) = FALSE;
- return NULL;
- }
-
- if(status!=NULL) (*status) = TRUE;
- if(uids->_length>0) {
- int i;
- for(i=0;i<uids->_length;i++) {
- result = g_slist_prepend(result,g_strdup(uids->_buffer[i]));
- }
- } else {
- INFO ("No entries found");
- }
-
- CORBA_free(uids);
-
- return result;
-}
-
-static void
-local_record_from_ical_uid(GCalLocalRecord *local,
- char *uid,
- GCalConduitContext *ctxt)
-{
- iCalObject *obj;
- char *vcalendar_string;
-
- g_assert(local!=NULL);
-
- vcalendar_string = GNOME_Calendar_Repository_get_object(ctxt->calendar, uid, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- }
- g_return_if_fail(vcalendar_string!=NULL);
-
- obj = ical_object_new_from_string (vcalendar_string);
-
- local_record_from_icalobject(local,obj);
-
- return;
-}
-
-
-/*
- * converts a iCalObject to a GCalLocalRecord
- */
-
-void
-local_record_from_icalobject(GCalLocalRecord *local,
- iCalObject *obj)
-{
- g_return_if_fail(local!=NULL);
- g_return_if_fail(obj!=NULL);
-
- local->ical = obj;
- local->local.ID = local->ical->pilot_id;
-
-/*
- LOG ("local->Id = %ld [%s], status = %d",
- local->local.ID,obj->summary,local->ical->pilot_status);
-*/
- switch(local->ical->pilot_status) {
- case ICAL_PILOT_SYNC_NONE:
- local->local.attr = GnomePilotRecordNothing;
- break;
- case ICAL_PILOT_SYNC_MOD:
- local->local.attr = GnomePilotRecordModified;
- break;
- case ICAL_PILOT_SYNC_DEL:
- local->local.attr = GnomePilotRecordDeleted;
- break;
- }
-
- /* Records without a pilot_id are new */
- if(local->local.ID == 0)
- local->local.attr = GnomePilotRecordNew;
-
- local->local.secret = 0;
- if(obj->class!=NULL)
- if(strcmp(obj->class,"PRIVATE")==0)
- local->local.secret = 1;
-
- local->local.archived = 0;
-}
-
-/*
- * Given a PilotRecord, find the matching record in
- * the calendar repository. If no match, return NULL
- */
-static GCalLocalRecord *
-find_record_in_repository(GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- char *vcal_string;
- GCalLocalRecord *loc;
-
- g_return_val_if_fail(conduit!=NULL,NULL);
- g_return_val_if_fail(remote!=NULL,NULL);
-
- LOG ("requesting %ld", remote->ID);
-
- vcal_string =
- GNOME_Calendar_Repository_get_object_by_pilot_id (ctxt->calendar, remote->ID, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return NULL;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return NULL;
- } else {
- LOG ("Found");
- loc = g_new0(GCalLocalRecord,1);
- /* memory allocated in new_from_string is freed in free_match */
- local_record_from_icalobject(loc,
- ical_object_new_from_string (vcal_string));
- /* g_free(vcal_string); FIXME: this coredumps, but won't it leak without ? */
- return loc;
- }
-
- return NULL;
-}
-
-/*
- * updates an given iCalObject in the repository
- */
-static void
-update_calendar_entry_in_repository(GnomePilotConduitStandardAbs *conduit,
- iCalObject *obj,
- GCalConduitContext *ctxt)
-{
- char *str;
-
- g_return_if_fail(conduit!=NULL);
- g_return_if_fail(obj!=NULL);
-
- str = calendar_string_from_object (obj);
-
- GNOME_Calendar_Repository_update_object (ctxt->calendar, obj->uid, str, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- }
-
- free (str);
-}
-
-static iCalObject *
-ical_from_remote_record(GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- iCalObject *in_obj)
-{
- iCalObject *obj;
- int i;
- struct Appointment a;
- time_t now;
-
- now = time (NULL);
-
- g_return_val_if_fail(remote!=NULL,NULL);
- memset(&a,0,sizeof(struct Appointment));
- unpack_Appointment(&a,remote->record,remote->length);
-
- if (in_obj == NULL)
- obj = ical_new (a.note ? a.note : "",
- g_get_user_name (),
- a.description ? a.description : "");
- else
- obj = in_obj;
-
- if (a.note) {
- g_free(obj->comment);
- obj->comment = g_strdup(a.note);
- }
- if (a.description) {
- g_free(obj->summary);
- obj->summary = g_strdup(a.description);
- }
-
- obj->created = now;
- obj->last_mod = now;
- obj->priority = 0;
- obj->transp = 0;
- obj->related = NULL;
- obj->pilot_id = remote->ID;
- obj->pilot_status = ICAL_PILOT_SYNC_NONE;
-
- /*
- * Begin and end
- */
-
- if (a.event)
- {
- /* turn day-long events into a full day's appointment
- FIXME: get settings from gnomecal */
- a.begin.tm_sec = 0;
- a.begin.tm_min = 0;
- a.begin.tm_hour = 0;
-
- a.end.tm_sec = 0;
- a.end.tm_min =59;
- a.end.tm_hour = 23;
- }
-
- obj->dtstart = mktime (&a.begin);
- obj->dtend = mktime (&a.end);
-
- /* Special case: daily repetitions are converted to a multi-day event */
- /* This sucketh, a pilot event scheduled for dailyRepeat, freq 1, end on
- whatever is cleary converted wrong
- if (a.repeatType == repeatDaily){
- time_t newt = time_add_day (obj->dtend, a.repeatFrequency);
-
- obj->dtend = newt;
- }
- */
-
- /*
- * Alarm
- */
- if (a.alarm){
- obj->aalarm.type = ALARM_AUDIO;
- obj->aalarm.enabled = 1;
- obj->aalarm.count = a.advance;
-
- switch (a.advanceUnits){
- case advMinutes:
- obj->aalarm.units = ALARM_MINUTES;
- break;
-
- case advHours:
- obj->aalarm.units = ALARM_HOURS;
- break;
-
- case advDays:
- obj->aalarm.units = ALARM_DAYS;
- break;
- default:
- }
- }
-
- /*
- * Recurrence
- */
- if (a.repeatFrequency){
- obj->recur = g_new0 (Recurrence, 1);
-
- switch (a.repeatType){
- case repeatDaily:
- /*
- * In the Pilot daily repetitions are actually
- * multi-day events
- */
- obj->recur->type = RECUR_DAILY;
- break;
-
- case repeatMonthlyByDate:
- obj->recur->type = RECUR_MONTHLY_BY_DAY;
- obj->recur->u.month_day = a.repeatFrequency;
- break;
-
- case repeatWeekly:
- {
- int wd;
-
- obj->recur->type = RECUR_WEEKLY;
- for (wd = 0; wd < 7; wd++)
- if (a.repeatDays [wd])
- obj->recur->weekday |= 1 << wd;
-
- if (obj->recur->weekday == 0){
- struct tm tm = *localtime (&obj->dtstart);
-
- obj->recur->weekday = 1 << tm.tm_wday;
- }
- break;
- }
-
- case repeatMonthlyByDay:
- obj->recur->type = RECUR_MONTHLY_BY_POS;
- obj->recur->u.month_pos = a.repeatFrequency;
- obj->recur->weekday = (a.repeatDay / 7);
- break;
-
- case repeatYearly:
- obj->recur->type = RECUR_YEARLY_BY_DAY;
- break;
-
- default:
- g_assert_not_reached();
- }
-
- if (a.repeatForever)
- obj->recur->duration = 0;
- else
- obj->recur->_enddate = mktime (&a.repeatEnd);
-
- obj->recur->interval = a.repeatFrequency;
- }
-
- /*
- * Load exception dates
- */
- obj->exdate = NULL;
- for (i = 0; i < a.exceptions; i++){
- time_t *t = g_new (time_t, 1);
-
- *t = mktime (&(a.exception [i]));
- obj->exdate = g_list_prepend (obj->exdate, t);
- }
-
- g_free (obj->class);
-
- if (remote->attr & dlpRecAttrSecret)
- obj->class = g_strdup ("PRIVATE");
- else
- obj->class = g_strdup ("PUBLIC");
-
-
- free_Appointment(&a);
-
- return obj;
-}
-
-/* Code blatantly stolen from
- * calendar-pilot-sync.c:
- *
- * (C) 1999 International GNOME Support
- *
- * Author:
- * Miguel de Icaza (miguel@gnome-support.com)
- *
- */
-static gint
-update_record (GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- char *vcal_string;
- iCalObject *obj;
- struct Appointment a;
-
- g_return_val_if_fail(remote!=NULL,-1);
-
- memset(&a,0,sizeof(struct Appointment));
- unpack_Appointment(&a,remote->record,remote->length);
-
- obj = ical_new (a.note ? a.note : "",
- g_get_user_name (),
- a.description ? a.description : "");
-
- LOG ("requesting %ld [%s]", remote->ID, a.description);
- vcal_string = GNOME_Calendar_Repository_get_object_by_pilot_id (ctxt->calendar, remote->ID, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- LOG ("Object did not exist, creating a new one");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- ical_from_remote_record(conduit,remote,obj);
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- ical_object_destroy (obj);
- free_Appointment(&a);
- return -1;
- } else {
- LOG ("Found");
- ical_object_destroy (obj);
- obj = ical_object_new_from_string (vcal_string);
- ical_from_remote_record(conduit,remote,obj);
- CORBA_free(vcal_string);
- }
-
- /* update record on server */
-
- update_calendar_entry_in_repository(conduit,obj,ctxt);
-
- /*
- * Shutdown
- */
- ical_object_destroy (obj);
- free_Appointment(&a);
-
- return 0;
-}
-
-static void
-check_for_slow_setting(GnomePilotConduit *c,
- GCalConduitContext *ctxt)
-{
- CORBA_long entry_number;
- entry_number =
- GNOME_Calendar_Repository_get_number_of_objects(ctxt->calendar,
- GNOME_Calendar_Repository_ANY,
- &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- } else {
- LOG (_("Calendar holds %d entries"),entry_number);
- /* If the local base is empty, do a slow sync */
- if ( entry_number <= 0) {
- gnome_pilot_conduit_standard_set_slow(GNOME_PILOT_CONDUIT_STANDARD(c));
- }
- }
-}
-
-static gint
-pre_sync(GnomePilotConduit *c,
- GnomePilotDBInfo *dbi,
- GCalConduitContext *ctxt)
-{
- int l;
- gint num_records;
- unsigned char *buf;
-
- g_message ("GnomeCal Conduit v.%s",CONDUIT_VERSION);
-
- ctxt->calendar = CORBA_OBJECT_NIL;
-
- if (start_calendar_server(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),ctxt) != 0) {
- WARN(_("Could not start gnomecal server"));
- gnome_pilot_conduit_error(GNOME_PILOT_CONDUIT(c),
- _("Could not start gnomecal server"));
- return -1;
- }
-
- /* Set the counters for the progress bar crap */
- num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_ANY, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
- num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_MODIFIED, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_updated_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
- num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_NEW, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_new_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
- num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_DELETED, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_deleted_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
-
- gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi);
-
- /* load_records(c); */
-
- buf = (unsigned char*)g_malloc(0xffff);
- if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff)) < 0) {
- WARN(_("Could not read pilot's DateBook application block"));
- WARN("dlp_ReadAppBlock(...) = %d",l);
- gnome_pilot_conduit_error(GNOME_PILOT_CONDUIT(c),
- _("Could not read pilot's DateBook application block"));
- return -1;
- }
- unpack_AppointmentAppInfo(&(ctxt->ai),buf,l);
- g_free(buf);
-
- check_for_slow_setting(c,ctxt);
-
- return 0;
-}
-
-/**
- * Find (if possible) the local record which matches
- * the given PilotRecord.
- * if successfull, return non-zero and set *local to
- * a non-null value (the located local record),
- * otherwise return 0 and set *local = NULL;
- */
-
-static gint
-match_record (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord **local,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- LOG ("in match_record");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
-
- *local = find_record_in_repository(conduit,remote,ctxt);
-
- if (*local==NULL) return -1;
- return 0;
-}
-
-/**
- * Free the data allocated by a previous match_record call.
- * If successfull, return non-zero and ser *local=NULL, otherwise
- * return 0.
- */
-static gint
-free_match (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord **local,
- GCalConduitContext *ctxt)
-{
- LOG ("entering free_match");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(*local!=NULL,-1);
-
- ical_object_destroy (GCAL_LOCALRECORD(*local)->ical);
- g_free(*local);
-
- *local = NULL;
- return 0;
-}
-
-/*
- Move to archive and set status to Nothing
- */
-static gint
-archive_local (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- GCalConduitContext *ctxt)
-{
- LOG ("entering archive_local");
-
- g_return_val_if_fail(local!=NULL,-1);
-
- return -1;
-}
-
-/*
- Store in archive and set status to Nothing
- */
-static gint
-archive_remote (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- LOG ("entering archive_remote");
-
- g_return_val_if_fail(remote!=NULL,-1);
- g_return_val_if_fail(local!=NULL,-1);
-
- return -1;
-}
-
-/*
- Store and set status to Nothing
- */
-static gint
-store_remote (GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- LOG ("entering store_remote");
-
- g_return_val_if_fail(remote!=NULL,-1);
- remote->attr = GnomePilotRecordNothing;
-
- return update_record(conduit,remote,ctxt);
-}
-
-static gint
-clear_status_archive_local (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- GCalConduitContext *ctxt)
-{
- LOG ("entering clear_status_archive_local");
-
- g_return_val_if_fail(local!=NULL,-1);
-
- return -1;
-}
-
-static gint
-iterate (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord **local,
- GCalConduitContext *ctxt)
-{
- static GSList *events,*iterator;
- static int hest;
-
- g_return_val_if_fail(local!=NULL,-1);
-
- if(*local==NULL) {
- LOG ("beginning iteration");
-
- events = get_calendar_objects(conduit,NULL,ctxt);
- hest = 0;
-
- if(events!=NULL) {
- LOG ("iterating over %d records",g_slist_length(events));
- *local = g_new0(GCalLocalRecord,1);
-
- local_record_from_ical_uid(*local,(gchar*)events->data,ctxt);
- iterator = events;
- } else {
- LOG ("no events");
- (*local) = NULL;
- }
- } else {
- /*LOG ("continuing iteration");*/
- hest++;
- if(g_slist_next(iterator)==NULL) {
- GSList *l;
-
- LOG ("ending");
- /** free stuff allocated for iteration */
- g_free((*local));
-
- LOG ("iterated over %d records",hest);
- for(l=events;l;l=l->next)
- g_free(l->data);
-
- g_slist_free(events);
-
- /* ends iteration */
- (*local) = NULL;
- return 0;
- } else {
- iterator = g_slist_next(iterator);
- local_record_from_ical_uid(*local,(gchar*)(iterator->data),ctxt);
- }
- }
- return 1;
-}
-
-static gint
-iterate_specific (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord **local,
- gint flag,
- gint archived,
- GCalConduitContext *ctxt)
-{
-#ifdef DEBUG_CALCONDUIT
- {
- gchar *tmp;
- switch (flag) {
- case GnomePilotRecordNothing: tmp = g_strdup("RecordNothing"); break;
- case GnomePilotRecordModified: tmp = g_strdup("RecordModified"); break;
- case GnomePilotRecordNew: tmp = g_strdup("RecordNew"); break;
- default: tmp = g_strdup_printf("0x%x",flag); break;
- }
- LOG ("entering iterate_specific(flag = %s)",tmp);
- g_free(tmp);
- }
-#endif
- g_return_val_if_fail(local!=NULL,-1);
-
- /* iterate until a record meets the criteria */
- while(gnome_pilot_conduit_standard_abs_iterate(conduit,(LocalRecord**)local)) {
- if((*local)==NULL) break;
- if(archived && ((*local)->local.archived==archived)) break;
- if(((*local)->local.attr == flag)) break;
- }
-
- return (*local)==NULL?0:1;
-}
-
-static gint
-purge (GnomePilotConduitStandardAbs *conduit,
- GCalConduitContext *ctxt)
-{
- LOG ("entering purge");
-
-
- /* HEST, gem posterne her */
-
- return -1;
-}
-
-static gint
-set_status (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- gint status,
- GCalConduitContext *ctxt)
-{
- LOG ("entering set_status(status=%d)",status);
-
- g_return_val_if_fail(local!=NULL,-1);
-
- g_assert(local->ical!=NULL);
-
- local->local.attr = status;
- switch(status) {
- case GnomePilotRecordPending:
- case GnomePilotRecordNothing:
- local->ical->pilot_status = ICAL_PILOT_SYNC_NONE;
- break;
- case GnomePilotRecordDeleted:
- break;
- case GnomePilotRecordNew:
- case GnomePilotRecordModified:
- local->ical->pilot_status = ICAL_PILOT_SYNC_MOD;
- break;
- }
-
- if ( status == GnomePilotRecordDeleted) {
- GNOME_Calendar_Repository_delete_object(ctxt->calendar,local->ical->uid,&(ctxt->ev));
- } else {
- GNOME_Calendar_Repository_update_pilot_id(ctxt->calendar,
- local->ical->uid,
- local->local.ID,
- local->ical->pilot_status,
- &(ctxt->ev));
- }
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- LOG ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- }
- return 0;
-}
-
-static gint
-set_archived (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- gint archived,
- GCalConduitContext *ctxt)
-{
- LOG ("entering set_archived");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_assert(local->ical!=NULL);
-
- local->local.archived = archived;
- update_calendar_entry_in_repository(conduit,local->ical,ctxt);
- /* FIXME: This should move the entry into a speciel
- calendar file, eg. Archive, or (by config option), simply
- delete it */
- return 0;
-}
-
-static gint
-set_pilot_id (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- guint32 ID,
- GCalConduitContext *ctxt)
-{
- LOG ("entering set_pilot_id(id=%d)",ID);
-
- g_return_val_if_fail(local!=NULL,-1);
- g_assert(local->ical!=NULL);
-
- local->local.ID = ID;
- local->ical->pilot_id = ID;
- GNOME_Calendar_Repository_update_pilot_id(ctxt->calendar,
- local->ical->uid,
- local->local.ID,
- local->ical->pilot_status,
- &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- LOG ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- }
- return 0;
-}
-
-static gint
-transmit (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord **remote,
- GCalConduitContext *ctxt)
-{
- PilotRecord *p;
- int daycount;
-
- LOG ("entering transmit");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
- g_assert(local->ical!=NULL);
-
- p = g_new0(PilotRecord,1);
-
- p->ID = local->local.ID;
- p->attr = local->local.attr;
- p->archived = local->local.archived;
- p->secret = local->local.secret;
-
- local->a = g_new0(struct Appointment,1);
-
- local->a->event = 0; /* if no start time, leave at 1 */
- local->a->begin = *localtime(&local->ical->dtstart);
- local->a->end = *localtime(&local->ical->dtend);
-
- /* set the Audio Alarm parameters */
- if(local->ical->aalarm.enabled) {
- local->a->alarm = 1;
- local->a->advance = local->ical->aalarm.count;
- switch(local->ical->aalarm.units) {
- case ALARM_MINUTES:
- local->a->advanceUnits = advMinutes;
- break;
- case ALARM_HOURS:
- local->a->advanceUnits = advHours;
- break;
- case ALARM_DAYS:
- local->a->advanceUnits = advDays;
- break;
- }
- } else {
- local->a->alarm = 0;
- local->a->advance = 0;
- local->a->advanceUnits = advMinutes;
- }
-
- /* set the recurrence parameters */
- if (local->ical->recur != NULL) {
- switch (local->ical->recur->type) {
- case RECUR_DAILY:
- local->a->repeatType = repeatDaily;
- break;
- case RECUR_WEEKLY:
- local->a->repeatType = repeatWeekly;
- break;
- case RECUR_MONTHLY_BY_POS:
- local->a->repeatType = repeatMonthlyByDate;
- break;
- case RECUR_MONTHLY_BY_DAY:
- local->a->repeatType = repeatMonthlyByDay;
- break;
- case RECUR_YEARLY_BY_MONTH:
- local->a->repeatType = repeatYearly;
- break;
- case RECUR_YEARLY_BY_DAY:
- local->a->repeatType = repeatYearly;
- break;
- }
- if (local->ical->recur->duration == 0) {
- local->a->repeatForever = 1;
- } else {
- local->a->repeatForever = 0;
- local->a->repeatEnd = *localtime(&local->ical->recur->_enddate);
- }
- local->a->repeatFrequency = local->ical->recur->interval;
-
-
- for ( daycount=0; daycount<7; daycount++ ) {
- if (local->ical->recur->weekday & (1 << daycount))
- local->a->repeatDays[daycount] = 1;
- }
- } else {
- local->a->repeatType = repeatNone;
- local->a->repeatForever = 0;
- local->a->repeatEnd = local->a->end;
- local->a->repeatFrequency = 0;
- local->a->repeatDay = dom1stSun;
- local->a->repeatDays[0] = 0;
- local->a->repeatDays[1] = 0;
- local->a->repeatDays[2] = 0;
- local->a->repeatDays[3] = 0;
- local->a->repeatDays[4] = 0;
- local->a->repeatDays[5] = 0;
- local->a->repeatDays[6] = 0;
- local->a->repeatWeekstart = 0;
- local->a->exceptions = 0;
- local->a->exception = NULL;
- }
-
- /* STOP: don't replace these with g_strdup, since free_Appointment
- uses free to deallocte */
- local->a->note =
- local->ical->comment==NULL?NULL:strdup(local->ical->comment);
- local->a->description =
- local->ical->summary==NULL?NULL:strdup(local->ical->summary);
-
- /* Generate pilot record structure */
- p->record = g_new0(char,0xffff);
- p->length = pack_Appointment(local->a,p->record,0xffff);
-
-#if 0
- /* This is some debug code that hexdumps the calendar entry...
- You won't need this. */
- {
- int x,y;
- g_message("calconduit: new item from %s to %s",asctime(&(local->a->begin)),asctime(&(local->a->end)));
-
- g_message("local->a->note = %s",local->a->note);
- g_message("local->a->description = %s",local->a->description);
- g_message("sizeof(p->record) = %d, length is %d",sizeof(p->record),p->length);
- for(x=0;x<p->length;x+=32) {
- for(y=x;y<x+32;y++)
- if(p->record[y]<33 || p->record[y]>128)
- printf("%02X",p->record[y]);
- else
- printf(" %c",p->record[y]);
- printf("\n");
- }
- }
-#endif
-
- *remote = p;
-
- return 0;
-}
-
-static gint
-free_transmit (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord **remote,
- GCalConduitContext *ctxt)
-{
- LOG ("entering free_transmit");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
-
- free_Appointment(local->a);
- g_free((*remote)->record);
- *remote = NULL;
- return 0;
-}
-
-static gint
-compare (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- /* used by the quick compare */
- PilotRecord *remoteOfLocal;
- int err;
- int retval;
-
- /* used by the tedious compare */
- struct Appointment a;
- int daycount;
-
- g_message ("entering compare");
-
- g_return_val_if_fail (local!=NULL,-1);
- g_return_val_if_fail (remote!=NULL,-1);
-#if 1
- err = transmit(conduit,local,&remoteOfLocal,ctxt);
- if (err != 0) return err;
-
- retval = 0;
- if (remote->length == remoteOfLocal->length) {
- if (memcmp(remoteOfLocal->record,remote->record,remote->length)!=0) {
- g_message("compare failed on contents");
- retval = 1;
- }
- } else {
- g_message("compare failed on length");
- retval = 1;
- }
-
- free_transmit(conduit,local,&remoteOfLocal,ctxt);
- return retval;
-
-#else
- /** FIXME: All the { LOG("yadayada"); return 1; } bloat is for debug purposes.
- Once this is known to work, compact to return 1;'s */
-
- /* Check record attributes */
- if (local->local.ID != remote->ID) {
- LOG("failed local->local.ID == remote->ID");
- return 1;
- }
- if (local->local.attr != remote->attr) {
- LOG("failed local->local.attr == remote->attr");
- return 1;
- }
- if (local->local.archived != remote->archived) {
- LOG("failed local->local.archived == remote->archived");
- return 1;
- }
- if (local->local.secret != remote->secret) {
- LOG("failed local->local.secret == remote->secret");
- return 1;
- }
-
- unpack_Appointment(&a,remote->record,remote->length);
-
- /* Check records begin/end time */
- if (a.event==0) {
-/* FIXME
- if (a.begin != *localtime(&local->ical->dtstart)) {
- LOG("a.begin == *localtime(&local->ical->dtstart)");
- return 1;
- }
- if (a.end != *localtime(&local->ical->dtend)) {
- LOG("a.end == *localtime(&local->ical->dtend)");
- return 1;
- }
-*/
- } else {
- LOG("failed local->a.event != 0, unsupported by gnomecal");
- return 1;
- }
-
- /* Check records alarm settings */
- if(a.alarm == 1) {
- if (local->ical->aalarm.enabled == 1) {
- if (a.advance != local->ical->aalarm.count) {
- LOG("failed a.advance == local->ical->aalarm.count");
- return 1;
- }
- switch(local->ical->aalarm.units) {
- case ALARM_MINUTES:
- if (a.advanceUnits != advMinutes) {
- LOG("failed local->ical->aalarm.units == a.advanceUnits");
- return 1;
- }
- break;
- case ALARM_HOURS:
- if (a.advanceUnits != advHours) {
- LOG("failed local->ical->aalarm.units == a.advanceUnits");
- return 1;
- }
- break;
- case ALARM_DAYS:
- if (a.advanceUnits != advDays) {
- LOG("failed local->ical->aalarm.units == a.advanceUnits");
- return 1;
- }
- break;
- }
- } else {
- LOG("failed a.alarm == 1 && local->ical->aalarm.enabled == 1");
- return 1;
- }
- } else if (local->ical->aalarm.enabled == 1) {
- LOG("failed a.alarm != 1 && local->ical->aalarm.enabled != 1");
- return 1;
- }
-
- /* Check records recurrence settings */
- /* If this code is broken, a more or less safe although not efficient
- approach is (other the fixing the bug), if either has recurrence,
- return 1, thus failing the comparision */
- if (local->ical->recur != NULL) {
- if (a.repeatType == repeatNone) {
- LOG("failed: local->ical->recur != NULL && a.repeatType != repeatNone");
- return 1;
- }
- switch (local->ical->recur->type) {
- case RECUR_DAILY:
- if (a.repeatType != repeatDaily) {
- LOG("failed a.repeatType == repeatDaily");
- return 1; }
- break;
- case RECUR_WEEKLY:
- if (a.repeatType != repeatWeekly) {
- LOG("failed a.repeatType == repeatWeekly");
- return 1; }
- break;
- case RECUR_MONTHLY_BY_POS:
- if (a.repeatType != repeatMonthlyByDate) {
- LOG("failed a.repeatType == repeatMonthlyByDate");
- return 1; }
- break;
- case RECUR_MONTHLY_BY_DAY:
- if (a.repeatType != repeatMonthlyByDay) {
- LOG("failed a.repeatType == repeatMonthlyByDay");
- return 1; }
- break;
- case RECUR_YEARLY_BY_MONTH:
- if (a.repeatType != repeatYearly) {
- LOG("failed a.repeatType == repeatYearly");
- return 1; }
- break;
- case RECUR_YEARLY_BY_DAY:
- if (a.repeatType != repeatYearly) {
- LOG("failed a.repeatType == repeatYearly");
- return 1; }
- break;
- }
- if (local->ical->recur->duration == 0) {
- if(a.repeatForever != 1) {
- LOG("failed local->ical->recur->duration == 0 && a.repeatForever == 1");
- return 1;
- }
- } else {
- if(a.repeatForever != 0) {
- LOG("failed local->ical->recur->duration != 0 && ! a.repeatForever == 0");
- return 1;
- }
-/* FIXME
- if(a.repeatEnd != *localtime(&local->ical->recur->_enddate)) {
- LOG("failed a.repeatEnd == *localtime(&local->ical->recur->_enddate)");
- return 1;
- }
-*/
- }
- if (a.repeatFrequency != local->ical->recur->interval) {
- LOG("failed a.repeatFrequency == local->ical->recur->interval");
- return 1;
- }
- for (daycount = 0; daycount<7; daycount++) {
- if(local->ical->recur->weekday & (1<<daycount)) {
- if (a.repeatDays[daycount]!=1) {
- LOG("failed local->ical->recur->weekday & (1<<daycount) && a.repeatDays[daycount]==1");
- return 1;
- }
- } else {
- if (a.repeatDays[daycount]!=0) {
- LOG("failed local->ical->recur->weekday &! (1<<daycount) && a.repeatDays[daycount]==0");
- return 1;
- }
- }
- }
- } else if (a.repeatType != repeatNone ) {
- LOG("failed: local->ical->recur == NULL && a.repeatType == repeatNone");
- return 1;
- }
-
- /* check the note and description */
- if(a.note!=NULL) {
- if(local->ical->comment==NULL) {
- LOG("failed a.note != NULL && local->ical->coment != NULL");
- return 1;
- }
- if(strcmp(local->ical->comment,a.note)!=0) {
- LOG("failed strcmp(local->ical->comment,a.note)==0");
- return 1;
- }
- } if(local->ical->comment!=NULL) {
- LOG("failed a.note == NULL && local->ical->coment == NULL");
- return 1;
- }
- if(a.description!=NULL) {
- if(local->ical->summary==NULL) {
- LOG("failed a.description != NULL && local->ical->coment != NULL");
- return 1;
- }
- if(strcmp(local->ical->summary,a.description)!=0) {
- LOG("failed strcmp(local->ical->summary,a.description)==0");
- return 1;
- }
- } if(local->ical->summary!=NULL) {
- LOG("failed a.description == NULL && local->ical->coment == NULL");
- return 1;
- }
-#endif
- return 0;
-}
-
-static gint
-compare_backup (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- LOG ("entering compare_backup");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
-
- return -1;
-}
-
-static gint
-delete_all (GnomePilotConduitStandardAbs *conduit,
- GCalConduitContext *ctxt)
-{
- GSList *events,*it;
- gboolean error;
-
- events = get_calendar_objects(conduit,&error,ctxt);
-
- if (error == FALSE) return -1;
- for (it=events;it;it = g_slist_next(it)) {
- GNOME_Calendar_Repository_delete_object(ctxt->calendar,
- it->data,
- &(ctxt->ev));
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- /* destroy loop, free data */
- for (it=events;it;it = g_slist_next(it)) g_free(it->data);
- g_slist_free(events);
- return -1;
- }
- g_free(it->data);
- }
- g_slist_free(events);
- return -1;
-}
-
-GnomePilotConduit *
-conduit_get_gpilot_conduit (guint32 pilotId)
-{
- GtkObject *retval;
- GCalConduitCfg *cfg;
- GCalConduitContext *ctxt;
-
-
- retval = gnome_pilot_conduit_standard_abs_new ("DatebookDB", 0x64617465);
- g_assert (retval != NULL);
- gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"GnomeCalConduit");
-
- gcalconduit_load_configuration(&cfg,pilotId);
- gtk_object_set_data(retval,"gcalconduit_cfg",cfg);
-
- gcalconduit_new_context(&ctxt,cfg);
- gtk_object_set_data(GTK_OBJECT(retval),"gcalconduit_context",ctxt);
-
- gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, ctxt);
- gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt);
- gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, ctxt);
- gtk_signal_connect (retval, "archive_remote", (GtkSignalFunc) archive_remote, ctxt);
- gtk_signal_connect (retval, "store_remote", (GtkSignalFunc) store_remote, ctxt);
- gtk_signal_connect (retval, "clear_status_archive_local", (GtkSignalFunc) clear_status_archive_local, ctxt);
- gtk_signal_connect (retval, "iterate", (GtkSignalFunc) iterate, ctxt);
- gtk_signal_connect (retval, "iterate_specific", (GtkSignalFunc) iterate_specific, ctxt);
- gtk_signal_connect (retval, "purge", (GtkSignalFunc) purge, ctxt);
- gtk_signal_connect (retval, "set_status", (GtkSignalFunc) set_status, ctxt);
- gtk_signal_connect (retval, "set_archived", (GtkSignalFunc) set_archived, ctxt);
- gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, ctxt);
- gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, ctxt);
- gtk_signal_connect (retval, "compare_backup", (GtkSignalFunc) compare_backup, ctxt);
- gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, ctxt);
- gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, ctxt);
- gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, ctxt);
- gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, ctxt);
-
- return GNOME_PILOT_CONDUIT (retval);
-}
-
-void
-conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
-{
- GCalConduitCfg *cc;
- GCalConduitContext *ctxt;
-
- cc = GET_GCALCONFIG(conduit);
- ctxt = GET_GCALCONTEXT(conduit);
-
- if(ctxt->calendar!=CORBA_OBJECT_NIL)
- GNOME_Calendar_Repository_done (ctxt->calendar, &(ctxt->ev));
-
- gcalconduit_destroy_configuration(&cc);
-
- gcalconduit_destroy_context(&ctxt);
-
- gtk_object_destroy (GTK_OBJECT (conduit));
-
-}
-
-
diff --git a/calendar/conduits/calendar/calendar-conduit.h b/calendar/conduits/calendar/calendar-conduit.h
deleted file mode 100644
index 711609e96a..0000000000
--- a/calendar/conduits/calendar/calendar-conduit.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* $Id$ */
-
-#ifndef __CALENDAR_CONDUIT_H__
-#define __CALENDAR_CONDUIT_H__
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <pi-datebook.h>
-#include <gnome.h>
-
-#include "GnomeCal.h"
-#include "calobj.h"
-#include "calendar.h"
-#include "timeutil.h"
-
-#include <gpilotd/gnome-pilot-conduit.h>
-#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
-
-/* This is the local record structure for the GnomeCal conduit. */
-typedef struct _GCalLocalRecord GCalLocalRecord;
-struct _GCalLocalRecord {
- /* The stuff from gnome-pilot-conduit-standard-abs.h
- Must be first in the structure, or instances of this
- structure cannot be used by gnome-pilot-conduit-standard-abs.
- */
- LocalRecord local;
- /* The corresponding iCal object, as found by GnomeCal. */
- iCalObject *ical;
- /* pilot-link appointment structure, used for implementing Transmit. */
- struct Appointment *a;
-};
-#define GCAL_LOCALRECORD(s) ((GCalLocalRecord*)(s))
-
-/* This is the configuration of the GnomeCal conduit. */
-typedef struct _GCalConduitCfg GCalConduitCfg;
-struct _GCalConduitCfg {
- gboolean open_secret;
- guint32 pilotId;
- GnomePilotConduitSyncType sync_type; /* only used by capplet */
-};
-#define GET_GCALCONFIG(c) ((GCalConduitCfg*)gtk_object_get_data(GTK_OBJECT(c),"gcalconduit_cfg"))
-
-/* This is the context for all the GnomeCal conduit methods. */
-typedef struct _GCalConduitContext GCalConduitContext;
-struct _GCalConduitContext {
- struct AppointmentAppInfo ai;
- GCalConduitCfg *cfg;
- GNOME_Calendar_Repository calendar;
- CORBA_Environment ev;
- CORBA_ORB orb;
-};
-#define GET_GCALCONTEXT(c) ((GCalConduitContext*)gtk_object_get_data(GTK_OBJECT(c),"gcalconduit_context"))
-
-/* Given a GCalConduitCfg*, allocates the structure and
- loads the configuration data for the given pilot. */
-static void
-gcalconduit_load_configuration(GCalConduitCfg **c,
- guint32 pilotId)
-{
- gchar prefix[256];
- g_snprintf(prefix,255,"/gnome-pilot.d/calendard-conduit/Pilot_%u/",pilotId);
-
- *c = g_new0(GCalConduitCfg,1);
- g_assert(*c != NULL);
- gnome_config_push_prefix(prefix);
- (*c)->open_secret = gnome_config_get_bool("open_secret=FALSE");
- (*c)->sync_type = GnomePilotConduitSyncTypeCustom; /* set in capplets main */
- gnome_config_pop_prefix();
-
- (*c)->pilotId = pilotId;
-}
-
-/* Saves the configuration data. */
-static void
-gcalconduit_save_configuration(GCalConduitCfg *c)
-{
- gchar prefix[256];
-
- g_snprintf(prefix,255,"/gnome-pilot.d/calendar-conduit/Pilot_%u/",c->pilotId);
-
- gnome_config_push_prefix(prefix);
- gnome_config_set_bool("open_secret",c->open_secret);
- gnome_config_pop_prefix();
-
- gnome_config_sync();
- gnome_config_drop_all();
-}
-
-/* Creates a duplicate of the configuration data */
-static GCalConduitCfg*
-gcalconduit_dupe_configuration(GCalConduitCfg *c) {
- GCalConduitCfg *retval;
- g_return_val_if_fail(c!=NULL,NULL);
- retval = g_new0(GCalConduitCfg,1);
- retval->sync_type = c->sync_type;
- retval->open_secret = c->open_secret;
- retval->pilotId = c->pilotId;
- return retval;
-}
-
-/* Destroys any data allocated by gcalconduit_load_configuration
- and deallocates the given configuration. */
-static void
-gcalconduit_destroy_configuration(GCalConduitCfg **c)
-{
- g_return_if_fail(c!=NULL);
- g_return_if_fail(*c!=NULL);
- g_free(*c);
- *c = NULL;
-}
-
-/* Given a GCalConduitContxt*, allocates the structure */
-static void
-gcalconduit_new_context(GCalConduitContext **ctxt,
- GCalConduitCfg *c)
-{
- *ctxt = g_new0(GCalConduitContext,1);
- g_assert(ctxt!=NULL);
- (*ctxt)->cfg = c;
- CORBA_exception_init (&((*ctxt)->ev));
-}
-
-/* Destroys any data allocated by gcalconduit_new_context
- and deallocates its data. */
-static void
-gcalconduit_destroy_context(GCalConduitContext **ctxt)
-{
- g_return_if_fail(ctxt!=NULL);
- g_return_if_fail(*ctxt!=NULL);
-/*
- if ((*ctxt)->cfg!=NULL)
- gcalconduit_destroy_configuration(&((*ctxt)->cfg));
-*/
- g_free(*ctxt);
- *ctxt = NULL;
-}
-#endif __CALENDAR_CONDUIT_H__
diff --git a/calendar/conduits/todo/todo-conduit-control-applet.c b/calendar/conduits/todo/todo-conduit-control-applet.c
deleted file mode 100644
index 54a26715ef..0000000000
--- a/calendar/conduits/todo/todo-conduit-control-applet.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/* Control applet ("capplet") for the gnome-pilot todo conduit, */
-/* based on */
-/* gpilotd control applet ('capplet') for use with the GNOME control center */
-/* $Id$ */
-
-#include <pwd.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <gnome.h>
-
-#include <config.h>
-#include <capplet-widget.h>
-
-#include <gpilotd/gpilotd-conduit-mgmt.h>
-#include <gpilotd/gpilotd-app.h>
-#include <gpilotd/gpilotd-app-dummy-callbacks.h>
-
-#include "todo-conduit.h"
-
-/* tell changes callbacks to ignore changes or not */
-static gboolean ignore_changes=FALSE;
-
-/* capplet widget */
-static GtkWidget *capplet=NULL;
-
-/* host/device/pilot configuration windows */
-GtkWidget *cfgOptionsWindow=NULL;
-GtkWidget *cfgStateWindow=NULL;
-GtkWidget *dialogWindow=NULL;
-
-gboolean activated,org_activation_state;
-GnomePilotConduitMgmt *conduit;
-
-static void doTrySettings(GtkWidget *widget, ConduitCfg *conduitCfg);
-static void doRevertSettings(GtkWidget *widget, ConduitCfg *conduitCfg);
-static void doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg);
-
-static void readStateCfg(GtkWidget *w);
-static void setStateCfg(GtkWidget *w);
-
-gint pilotId;
-CORBA_Environment ev;
-
-static void
-doTrySettings(GtkWidget *widget, ConduitCfg *conduitCfg)
-{
- readStateCfg(cfgStateWindow);
- if(activated)
- gpilotd_conduit_mgmt_enable(conduit,pilotId,GnomePilotConduitSyncTypeSynchronize);
- else
- gpilotd_conduit_mgmt_disable(conduit,pilotId);
-}
-
-static void
-doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg)
-{
- doTrySettings(widget, conduitCfg);
- save_configuration(NULL);
-}
-
-
-static void
-doRevertSettings(GtkWidget *widget, ConduitCfg *conduitCfg)
-{
- activated = org_activation_state;
- setStateCfg(cfgStateWindow);
-}
-
-static void
-insert_dir_callback (GtkEditable *editable, const gchar *text,
- gint len, gint *position, void *data)
-{
- gint i;
- gchar *curname;
-
- curname = gtk_entry_get_text(GTK_ENTRY(editable));
- if (*curname == '\0' && len > 0) {
- if (isspace(text[0])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text");
- return;
- }
- } else {
- for (i=0; i<len; i++) {
- if (isspace(text[i])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable),
- "insert_text");
- return;
- }
- }
- }
-}
-static void
-insert_dir_callback2(GtkEditable *editable, const gchar *text,
- gint length, gint *position,
- void *data)
-{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-static void
-clist_changed(GtkWidget *widget, gpointer data)
-{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-void about_cb (GtkWidget *widget, gpointer data) {
- GtkWidget *about;
- const gchar *authors[] = {_("Eskil Heyn Olsen <deity@eskil.dk>"),NULL};
-
- about = gnome_about_new(_("Gpilotd todo conduit"), VERSION,
- _("(C) 1998 the Free Software Foundation"),
- authors,
- _("Configuration utility for the todo conduit.\n"),
- _("gnome-unknown.xpm"));
- gtk_widget_show (about);
-
- return;
-}
-
-static void toggled_cb(GtkWidget *widget, gpointer data) {
- gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(widget)->active);
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-static GtkWidget
-*createStateCfgWindow(void)
-{
- GtkWidget *vbox, *table;
- GtkWidget *entry, *label;
- GtkWidget *button;
-
- vbox = gtk_vbox_new(FALSE, GNOME_PAD);
-
- table = gtk_table_new(2, 2, FALSE);
- gtk_table_set_row_spacings(GTK_TABLE(table), 4);
- gtk_table_set_col_spacings(GTK_TABLE(table), 10);
- gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD);
-
- label = gtk_label_new(_("Enabled"));
- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1,2);
-
- button = gtk_check_button_new();
- gtk_object_set_data(GTK_OBJECT(vbox), "conduit_on_off", button);
- gtk_signal_connect(GTK_OBJECT(button), "toggled",
- GTK_SIGNAL_FUNC(toggled_cb),
- NULL);
- gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 1,2);
-
- return vbox;
-}
-
-static void
-setStateCfg(GtkWidget *cfg)
-{
- GtkWidget *button;
- gchar num[40];
-
- button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off");
-
- g_assert(button!=NULL);
-
- ignore_changes = TRUE;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),activated);
- gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(button)->active);
- ignore_changes = FALSE;
-}
-
-
-static void
-readStateCfg(GtkWidget *cfg)
-{
- GtkWidget *button;
-
- button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off");
-
- g_assert(button!=NULL);
-
- activated = GTK_TOGGLE_BUTTON(button)->active;
-}
-
-static void
-pilot_capplet_setup(void)
-{
- GtkWidget *frame, *table;
-
- capplet = capplet_widget_new();
-
- table = gtk_table_new(1, 2, FALSE);
- gtk_container_border_width(GTK_CONTAINER(table), GNOME_PAD);
- gtk_container_add(GTK_CONTAINER(capplet), table);
-
- frame = gtk_frame_new(_("Conduit state"));
- gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL);
- gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1);
- cfgStateWindow = createStateCfgWindow();
- gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow);
-
- gtk_signal_connect(GTK_OBJECT(capplet), "try",
- GTK_SIGNAL_FUNC(doTrySettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "revert",
- GTK_SIGNAL_FUNC(doRevertSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "ok",
- GTK_SIGNAL_FUNC(doSaveSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "help",
- GTK_SIGNAL_FUNC(about_cb), NULL);
-
-
- setStateCfg(cfgStateWindow);
-
- gtk_widget_show_all(capplet);
-}
-
-void run_error_dialog(gchar *mesg,...) {
- char tmp[80];
- va_list ap;
-
- va_start(ap,mesg);
- vsnprintf(tmp,79,mesg,ap);
- dialogWindow = gnome_message_box_new(mesg,GNOME_MESSAGE_BOX_ERROR,GNOME_STOCK_BUTTON_OK,NULL);
- gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow));
- va_end(ap);
-}
-
-gint get_pilot_id_from_gpilotd() {
- gint *pilots;
- int i;
-
- i=0;
- gpilotd_get_pilot_ids(&pilots);
- if(pilots) {
- while(pilots[i]!=-1) { g_message("pilot %d = \"%d\"",i,pilots[i]); i++; }
- if(i==0) {
- run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
- return -1;
- } else {
- if(i==1)
- return pilots[0];
- else {
- g_message("too many pilots...");
- return pilots[0];
- }
- }
- } else {
- run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
- return -1;
- }
-}
-
-int
-main( int argc, char *argv[] )
-{
- /* we're a capplet */
- gnome_capplet_init ("todo conduit control applet", NULL, argc, argv,
- NULL,
- 0, NULL);
-
- /* put all code to set things up in here */
- conduit = gpilotd_conduit_mgmt_new("todo_conduit");
-
- /* get pilot name from gpilotd */
- /* 1. initialize the gpilotd connection */
- if (gpilotd_init(&argc,argv)!=0) {
- run_error_dialog(_("Cannot initialze the GnomePilot Daemon"));
- g_error(_("Cannot initialze the GnomePilot Daemon"));
- return -1;
- }
-
- /* 2 connect to gpilotd */
- if (gpilotd_connect()!=0) {
- run_error_dialog(_("Cannot connect to the GnomePilot Daemon"));
- g_error(_("Cannot connect to the GnomePilot Daemon"));
- return -1;
- }
-
- pilotId = get_pilot_id_from_gpilotd();
- if(!pilotId) return -1;
- org_activation_state = activated = gpilotd_conduit_mgmt_is_enabled(conduit,pilotId);
-
- pilot_capplet_setup();
-
-
- /* done setting up, now run main loop */
- capplet_gtk_main();
- return 0;
-}
diff --git a/calendar/conduits/todo/todo-conduit-control-applet.desktop b/calendar/conduits/todo/todo-conduit-control-applet.desktop
deleted file mode 100644
index 87788bde08..0000000000
--- a/calendar/conduits/todo/todo-conduit-control-applet.desktop
+++ /dev/null
@@ -1,6 +0,0 @@
-[Desktop Entry]
-Name=Todo conduit
-Comment=Configure the todo conduit
-Exec=todo-conduit-control-applet --cap-id=1
-Terminal=0
-Type=Application
diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c
deleted file mode 100644
index 3a543816af..0000000000
--- a/calendar/conduits/todo/todo-conduit.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/* $Id$ */
-
-#include <glib.h>
-#include <gnome.h>
-
-#include <pi-source.h>
-#include <pi-socket.h>
-#include <pi-file.h>
-#include <pi-dlp.h>
-#include <pi-version.h>
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <utime.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <signal.h>
-#include <errno.h>
-#include <gpilotd/gnome-pilot-conduit.h>
-#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
-
-#include "todo-conduit.h"
-
-static gint
-load_records(GnomePilotConduit *c)
-{
- return 0;
-}
-
-static gint
-pre_sync(GnomePilotConduit *c, GnomePilotDBInfo *dbi) {
- int l;
- unsigned char *buf;
-
- gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi);
-
- load_records(c);
-
- buf = (unsigned char*)g_malloc(0xffff);
- if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff))<0) {
- return -1;
- }
- unpack_ToDoAppInfo(&(GET_DATA(c)->ai),buf,l);
- g_free(buf);
-
- return 0;
-}
-
-static gint
-post_sync(GnomePilotConduit *c) {
- return 0;
-}
-
-static gint
-match_record (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord **local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("in match_record\n");
- return 0;
-}
-static gint
-free_match (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord **local,
- gpointer data)
-{
- g_print ("entering free_match\n");
- *local = NULL;
-
- return 0;
-}
-static gint
-archive_local (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gpointer data)
-{
- g_print ("entering archive_local\n");
- return 1;
-
-}
-static gint
-archive_remote (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering archive_remote\n");
- return 1;
-}
-static gint
-store_remote (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering store_remote\n");
- g_print ("Rec:%s:\nLength:%d\n", remote->record, remote->length);
- return 1;
-}
-static gint
-clear_status_archive_local (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gpointer data)
-{
- g_print ("entering clear_status_archive_local\n");
- return 1;
-}
-static gint
-iterate (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord **local,
- gpointer data)
-{
- g_print ("entering iterate\n");
- return 1;
-}
-static gint
-iterate_specific (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord **local,
- gint flag,
- gint archived,
- gpointer data)
-{
- g_print ("entering iterate_specific\n");
- return 1;
-}
-static gint
-purge (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- gpointer data)
-{
- g_print ("entering purge\n");
- return 1;
-}
-static gint
-set_status (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gint status,
- gpointer data)
-{
- g_print ("entering set_status\n");
- return 1;
-}
-static gint
-set_archived (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gint archived,
- gpointer data)
-{
- g_print ("entering set_archived\n");
- return 1;
-}
-static gint
-set_pilot_id (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- guint32 ID,
- gpointer data)
-{
- g_print ("entering set_pilot_id\n");
- return 1;
-}
-static gint
-compare (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering compare\n");
- return 1;
-}
-static gint
-compare_backup (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering compare_backup\n");
- return 1;
-}
-static gint
-free_transmit (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering free_transmit\n");
- return 1;
-}
-static gint
-delete_all (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- gpointer data)
-{
- g_print ("entering delete_all\n");
- return 1;
-}
-static PilotRecord *
-transmit (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gpointer data)
-{
- g_print ("entering transmit\n");
- return NULL;
-}
-
-static GnomePilotConduit *
-conduit_get_gpilot_conduit (guint32 pilotId)
-{
- GtkObject *retval;
- ConduitCfg *cfg;
- ConduitData *cdata;
-
- g_print ("creating our new conduit\n");
- retval = gnome_pilot_conduit_standard_abs_new ("TodoDB", 0x0);
- g_assert (retval != NULL);
- gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"todo");
-
- cfg = g_new0(ConduitCfg,1);
- g_assert(cfg != NULL);
- gtk_object_set_data(retval,"conduit_cfg",cfg);
-
- cdata = g_new0(ConduitData,1);
- g_assert(cdata != NULL);
- gtk_object_set_data(retval,"conduit_data",cdata);
-
- gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, NULL);
- gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, NULL);
- gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, NULL);
- gtk_signal_connect (retval, "archive_remote", (GtkSignalFunc) archive_remote, NULL);
- gtk_signal_connect (retval, "store_remote", (GtkSignalFunc) store_remote, NULL);
- gtk_signal_connect (retval, "clear_status_archive_local", (GtkSignalFunc) clear_status_archive_local, NULL);
- gtk_signal_connect (retval, "iterate", (GtkSignalFunc) iterate, NULL);
- gtk_signal_connect (retval, "iterate_specific", (GtkSignalFunc) iterate_specific, NULL);
- gtk_signal_connect (retval, "purge", (GtkSignalFunc) purge, NULL);
- gtk_signal_connect (retval, "set_status", (GtkSignalFunc) set_status, NULL);
- gtk_signal_connect (retval, "set_archived", (GtkSignalFunc) set_archived, NULL);
- gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, NULL);
- gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, NULL);
- gtk_signal_connect (retval, "compare_backup", (GtkSignalFunc) compare_backup, NULL);
- gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, NULL);
- gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, NULL);
- gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, NULL);
- gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, NULL);
- gtk_signal_connect (retval, "post_sync", (GtkSignalFunc) post_sync, NULL);
-
- load_configuration(&cfg,pilotId);
-
- return GNOME_PILOT_CONDUIT (retval);
-}
-static void
-conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
-{
- ConduitCfg *cc;
- cc = GET_CONFIG(conduit);
- destroy_configuration(&cc);
- gtk_object_destroy (GTK_OBJECT (conduit));
-}
-
-
diff --git a/calendar/conduits/todo/todo-conduit.h b/calendar/conduits/todo/todo-conduit.h
deleted file mode 100644
index c224b2b1f3..0000000000
--- a/calendar/conduits/todo/todo-conduit.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* $Id$ */
-
-#ifndef __TODO_CONDUIT_H__
-#define __TODO_CONDUIT_H__
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <pi-todo.h>
-#include <gnome.h>
-
-typedef struct _ConduitCfg ConduitCfg;
-
-struct _ConduitCfg {
- gboolean open_secret;
- guint32 pilotId;
-};
-
-#define GET_CONFIG(c) ((ConduitCfg*)gtk_object_get_data(GTK_OBJECT(c),"conduit_cfg"))
-
-typedef struct _ConduitData ConduitData;
-
-struct _ConduitData {
- struct ToDoAppInfo ai;
-};
-
-#define GET_DATA(c) ((ConduitData*)gtk_object_get_data(GTK_OBJECT(c),"conduit_data"))
-
-static void load_configuration(ConduitCfg **c,guint32 pilotId) {
- gchar prefix[256];
- g_snprintf(prefix,255,"/gnome-pilot.d/todod-conduit/Pilot_%u/",pilotId);
-
- *c = g_new0(ConduitCfg,1);
- gnome_config_push_prefix(prefix);
- (*c)->open_secret = gnome_config_get_bool("open secret=FALSE");
- gnome_config_pop_prefix();
-
- (*c)->pilotId = pilotId;
-}
-
-static void save_configuration(ConduitCfg *c) {
- gchar prefix[256];
-
- g_snprintf(prefix,255,"/gnome-pilot.d/todo-conduit/Pilot_%u/",c->pilotId);
-
- gnome_config_push_prefix(prefix);
- gnome_config_set_bool("open secret",c->open_secret);
- gnome_config_pop_prefix();
-
- gnome_config_sync();
- gnome_config_drop_all();
-}
-
-static void destroy_configuration(ConduitCfg **c) {
- g_free(*c);
- *c = NULL;
-}
-
-#endif __TODO_CONDUIT_H__
diff --git a/calendar/corba-cal-factory.c b/calendar/corba-cal-factory.c
deleted file mode 100644
index a86af3c238..0000000000
--- a/calendar/corba-cal-factory.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * corba-cal-factory.c: Service that provides access to the calendar repositories.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- */
-
-#include <config.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include "gnome-cal.h"
-#include "main.h"
-#include "alarm.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
-#include <libgnorba/gnorba.h>
-#include <bonobo.h>
-#include "GnomeCal.h"
-#include "corba-cal-factory.h"
-#include "corba-cal.h"
-
-CORBA_ORB orb;
-PortableServer_POA poa;
-PortableServer_POAManager poa_manager;
-
-static POA_Bonobo_GenericFactory__epv calendar_epv;
-static POA_Bonobo_GenericFactory__vepv calendar_vepv;
-
-/*
- * Servant and Object Factory
- */
-static POA_Bonobo_GenericFactory calendar_servant;
-static Bonobo_GenericFactory calendar_factory;
-
-static CORBA_boolean
-calendar_supports (PortableServer_Servant servant,
- CORBA_char * obj_goad_id,
- CORBA_Environment * ev)
-{
- if (strcmp (obj_goad_id, "IDL:GNOME:Calendar:Repository:1.0") == 0)
- return CORBA_TRUE;
- else
- return CORBA_FALSE;
-}
-
-static CORBA_Object
-calendar_create_object (PortableServer_Servant servant,
- CORBA_char *goad_id,
- const GNOME_stringlist *params,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal;
- struct stat s;
- char *name;
-
- if (params->_length == 1)
- name = params->_buffer [0];
- else
- name = NULL;
-
- if (strcmp (goad_id, "IDL:GNOME:Calendar:Repository:1.0") != 0){
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_Bonobo_GenericFactory_CannotActivate,
- NULL);
- return CORBA_OBJECT_NIL;
- }
-
- gcal = gnome_calendar_locate (name);
- if (gcal != NULL)
- return CORBA_Object_duplicate (gcal->cal->corba_server, ev);
-
- if (stat (name, &s) != 0){
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_Bonobo_GenericFactory_CannotActivate,
- NULL);
- return CORBA_OBJECT_NIL;
- }
-
- gcal = new_calendar ("", name, NULL, NULL, FALSE);
-
- return CORBA_Object_duplicate (gcal->cal->corba_server, ev);
-}
-
-void
-init_corba_server (void)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- poa_manager = PortableServer_POA__get_the_POAManager (poa, &ev);
- if (ev._major != CORBA_NO_EXCEPTION){
- g_warning ("Can not get the POA manager");
- CORBA_exception_free (&ev);
- return;
- }
-
- PortableServer_POAManager_activate (poa_manager, &ev);
-
- /* First create the locator for the repositories as a factory object */
- calendar_vepv.Bonobo_GenericFactory_epv = &calendar_epv;
- calendar_epv.supports = calendar_supports;
- calendar_epv.create_object = calendar_create_object;
-
- calendar_servant.vepv = &calendar_vepv;
- POA_Bonobo_GenericFactory__init ((PortableServer_Servant) &calendar_servant, &ev);
- CORBA_free (PortableServer_POA_activate_object (
- poa, (PortableServer_Servant)&calendar_servant, &ev));
-
- calendar_factory = PortableServer_POA_servant_to_reference (
- poa, (PortableServer_Servant) &calendar_servant, &ev);
-
- goad_server_register (
- CORBA_OBJECT_NIL, calendar_factory,
- "IDL:GNOME:Calendar:RepositoryLocator:1.0", "object", &ev);
- CORBA_exception_free (&ev);
-}
-
-void
-unregister_calendar_services (void)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
- goad_server_unregister (
- CORBA_OBJECT_NIL,
- "IDL:GNOME:Calendar:RepositoryLocator:1.0", "object", &ev);
- CORBA_exception_free (&ev);
-}
diff --git a/calendar/corba-cal-factory.h b/calendar/corba-cal-factory.h
deleted file mode 100644
index 5d3bcb3140..0000000000
--- a/calendar/corba-cal-factory.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _CORBA_CAL_FACTORY_H_
-#define _CORBA_CAL_FACTORY_H_
-
-/* The CORBA globals */
-CORBA_ORB orb;
-PortableServer_POA poa;
-
-void corba_server_init (void);
-void unregister_calendar_services (void);
-
-#endif /* _CORBA_CAL_FACTORY_H_ */
diff --git a/calendar/corba-cal.c b/calendar/corba-cal.c
deleted file mode 100644
index 74afc0e76a..0000000000
--- a/calendar/corba-cal.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * corba-cal.c: Service that provides access to the calendar repository
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- */
-
-#include <config.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include "calendar.h"
-#include "gnome-cal.h"
-#include "alarm.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
-#include <libgnorba/gnome-factory.h>
-#include "GnomeCal.h"
-#include "corba-cal-factory.h"
-#include "corba-cal.h"
-
-typedef struct {
- POA_GNOME_Calendar_Repository servant;
- GnomeCalendar *calendar;
-} CalendarServant;
-
-/*
- * Vectors
- */
-static POA_GNOME_Calendar_Repository__epv calendar_repository_epv;
-static POA_GNOME_Calendar_Repository__vepv calendar_repository_vepv;
-
-/*
- * Servant and Object Factory
- */
-static POA_GNOME_Calendar_Repository calendar_repository_servant;
-
-static inline GnomeCalendar *
-gnomecal_from_servant (PortableServer_Servant servant)
-{
- CalendarServant *cs = (CalendarServant *) servant;
-
- return cs->calendar;
-}
-
-static CORBA_char *
-cal_repo_get_object (PortableServer_Servant servant,
- const CORBA_char *uid,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- iCalObject *obj;
- char *buffer;
- CORBA_char *ret;
-
- obj = calendar_object_find_event (gcal->cal, uid);
- if (obj == NULL){
- GNOME_Calendar_Repository_NotFound *exn;
-
- exn = GNOME_Calendar_Repository_NotFound__alloc();
- CORBA_exception_set (
- ev,
- CORBA_USER_EXCEPTION,
- ex_GNOME_Calendar_Repository_NotFound,
- exn);
- return NULL;
- }
-
- buffer = calendar_string_from_object (obj);
- ret = CORBA_string_dup (buffer);
- free (buffer);
-
- return ret;
-}
-
-static CORBA_char *
-cal_repo_get_object_by_pilot_id (PortableServer_Servant servant,
- CORBA_long pilot_id,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- iCalObject *obj;
- char *buffer;
- CORBA_char *ret;
-
- obj = calendar_object_find_by_pilot (gcal->cal, pilot_id);
- if (obj == NULL){
- GNOME_Calendar_Repository_NotFound *exn;
-
- exn = GNOME_Calendar_Repository_NotFound__alloc();
- CORBA_exception_set (ev,
- CORBA_USER_EXCEPTION,
- ex_GNOME_Calendar_Repository_NotFound, exn);
- return NULL;
- }
-
- buffer = calendar_string_from_object (obj);
- ret = CORBA_string_dup (buffer);
- free (buffer);
-
- return ret;
-
-}
-
-static CORBA_char *
-cal_repo_get_id_from_pilot_id (PortableServer_Servant servant,
- CORBA_long pilot_id,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- iCalObject *obj;
-
- obj = calendar_object_find_by_pilot (gcal->cal, pilot_id);
- if (obj == NULL){
- GNOME_Calendar_Repository_NotFound *exn;
-
- exn = GNOME_Calendar_Repository_NotFound__alloc();
- CORBA_exception_set (ev,
- CORBA_USER_EXCEPTION,
- ex_GNOME_Calendar_Repository_NotFound, exn);
- return NULL;
- }
-
- return CORBA_string_dup (obj->uid);
-}
-
-static void
-cal_repo_delete_object (PortableServer_Servant servant,
- const CORBA_char *uid,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- iCalObject *obj;
-
- obj = calendar_object_find_event (gcal->cal, uid);
- if (obj == NULL){
- GNOME_Calendar_Repository_NotFound *exn;
-
- exn = GNOME_Calendar_Repository_NotFound__alloc();
- CORBA_exception_set (ev,
- CORBA_USER_EXCEPTION,
- ex_GNOME_Calendar_Repository_NotFound, exn);
- return;
- }
-
- gnome_calendar_remove_object (gcal, obj);
-}
-
-static void
-cal_repo_update_object (PortableServer_Servant servant,
- const CORBA_char *uid,
- const CORBA_char *vcalendar_object,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- iCalObject *obj;
- iCalObject *new_object;
-
- new_object = ical_object_new_from_string (vcalendar_object);
-
- obj = calendar_object_find_event (gcal->cal, uid);
- if (obj != NULL){
- calendar_remove_object (gcal->cal, obj);
- }
-
- calendar_add_object (gcal->cal, new_object);
-}
-
-static void
-cal_repo_update_pilot_id (PortableServer_Servant servant,
- const CORBA_char *uid,
- const CORBA_long pilot_id,
- const CORBA_long pilot_status,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- iCalObject *obj;
-
- obj = calendar_object_find_event (gcal->cal, uid);
- if (obj == NULL){
- GNOME_Calendar_Repository_NotFound *exn;
-
- exn = GNOME_Calendar_Repository_NotFound__alloc();
- CORBA_exception_set (
- ev,
- CORBA_USER_EXCEPTION,
- ex_GNOME_Calendar_Repository_NotFound,
- exn);
- return;
- }
-
- obj->pilot_id = pilot_id;
- obj->pilot_status = pilot_status;
-}
-
-static CORBA_char *
-cal_repo_get_objects (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- char *str;
- CORBA_char *res;
-
- str = calendar_get_as_vcal_string (gcal->cal);
- g_message("length of result is %d",strlen(str));
- res = CORBA_string_dup (str);
- free(str); /* ...get_as_vcal calls writeMemVObject, which uses realloc to
- allocate this string */
-
- return res;
-}
-
-static CORBA_long
-cal_repo_get_number_of_objects (PortableServer_Servant servant,
- GNOME_Calendar_Repository_RecordStatus record_status,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- CORBA_long res;
- GList *l;
- iCalPilotState real_record_status;
-
- if (record_status == GNOME_Calendar_Repository_ANY) {
- return g_list_length(gcal->cal->events);
- }
-
- switch (record_status) {
- case GNOME_Calendar_Repository_NEW:
- real_record_status = ICAL_PILOT_SYNC_MOD;
- break;
- case GNOME_Calendar_Repository_MODIFIED:
- real_record_status = ICAL_PILOT_SYNC_MOD;
- break;
- case GNOME_Calendar_Repository_DELETED:
- real_record_status = ICAL_PILOT_SYNC_DEL;
- break;
- }
-
- res = 0;
-
- for (l = gcal->cal->events; l; l = l->next){
- iCalObject *obj = l->data;
-
- if (obj->pilot_status == real_record_status)
- res ++;
- }
-
- return res;
-}
-
-static GNOME_Calendar_Repository_String_Sequence*
-cal_repo_get_object_id_list(PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- GList *l;
- GNOME_Calendar_Repository_String_Sequence *result;
- int counter;
-
- result = GNOME_Calendar_Repository_String_Sequence__alloc();
- result->_length = g_list_length(gcal->cal->events);
- result->_buffer = CORBA_sequence_CORBA_string_allocbuf(result->_length);
-
- counter = 0;
- for (l = gcal->cal->events ; l; l = l->next){
- iCalObject *obj = l->data;
- result->_buffer[counter] = CORBA_string_dup(obj->uid);
- counter++;
- }
-
- return result;
-}
-
-static CORBA_char *
-cal_repo_get_updated_objects (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- Calendar *dirty_cal;
- GList *l;
- CORBA_char *res;
- char *str;
-
- dirty_cal = calendar_new ("Temporal",CALENDAR_INIT_NIL);
-
- for (l = gcal->cal->events; l; l = l->next){
- iCalObject *obj = l->data;
-
- if (obj->pilot_status != ICAL_PILOT_SYNC_MOD)
- continue;
-
- obj = ical_object_duplicate (l->data);
-
- calendar_add_object (dirty_cal, obj);
- }
- str = calendar_get_as_vcal_string (dirty_cal);
- res = CORBA_string_dup (str);
- g_free (str);
- calendar_destroy (dirty_cal);
-
- return res;
-}
-
-static void
-cal_repo_done (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
-
- calendar_save (gcal->cal, NULL);
-}
-
-static void
-init_calendar_repo_class (void)
-{
- calendar_repository_epv.get_object = cal_repo_get_object;
- calendar_repository_epv.get_object_by_pilot_id = cal_repo_get_object_by_pilot_id;
- calendar_repository_epv.get_id_from_pilot_id = cal_repo_get_id_from_pilot_id;
- calendar_repository_epv.delete_object = cal_repo_delete_object;
- calendar_repository_epv.update_object = cal_repo_update_object;
- calendar_repository_epv.get_objects = cal_repo_get_objects;
- calendar_repository_epv.get_number_of_objects = cal_repo_get_number_of_objects;
- calendar_repository_epv.get_updated_objects = cal_repo_get_updated_objects;
- calendar_repository_epv.update_pilot_id = cal_repo_update_pilot_id;
- calendar_repository_epv.get_object_id_list = cal_repo_get_object_id_list;
-
- calendar_repository_epv.done = cal_repo_done;
-
- calendar_repository_vepv.GNOME_Calendar_Repository_epv =
- &calendar_repository_epv;
-
- calendar_repository_servant.vepv = &calendar_repository_vepv;
-}
-
-/*
- * Initializes the CORBA parts of the @calendar object
- */
-void
-gnome_calendar_create_corba_server (GnomeCalendar *calendar)
-{
- static gboolean class_inited = FALSE;
- CalendarServant *calendar_servant;
- CORBA_Environment ev;
-
- if (!class_inited){
- init_calendar_repo_class ();
- class_inited = TRUE;
- }
-
- calendar_servant = g_new0 (CalendarServant, 1);
- calendar_servant->servant.vepv = &calendar_repository_vepv;
- calendar_servant->calendar = calendar;
-
- CORBA_exception_init (&ev);
- POA_GNOME_Calendar_Repository__init ((PortableServer_Servant) calendar_servant, &ev);
- CORBA_free (
- PortableServer_POA_activate_object (poa, calendar_servant, &ev));
- calendar->cal->corba_server = PortableServer_POA_servant_to_reference (
- poa, calendar_servant, &ev);
- CORBA_exception_free (&ev);
-}
diff --git a/calendar/corba-cal.h b/calendar/corba-cal.h
deleted file mode 100644
index 47caacba70..0000000000
--- a/calendar/corba-cal.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _CORBA_CAL_H_
-#define _CORBA_CAL_H_
-
-void gnome_calendar_create_corba_server (GnomeCalendar *calendar);
-
-#endif /* _CORBA_CAL_H_ */
diff --git a/calendar/doc/.cvsignore b/calendar/doc/.cvsignore
deleted file mode 100644
index 282522db03..0000000000
--- a/calendar/doc/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/calendar/doc/C/.cvsignore b/calendar/doc/C/.cvsignore
deleted file mode 100644
index 93942d6aa5..0000000000
--- a/calendar/doc/C/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-Makefile
-Makefile.in
-gnomecal
-gnomecal.html
-gnomecal.junk
diff --git a/calendar/doc/C/Makefile.am b/calendar/doc/C/Makefile.am
deleted file mode 100644
index fbd3b63acf..0000000000
--- a/calendar/doc/C/Makefile.am
+++ /dev/null
@@ -1,44 +0,0 @@
-gnomecal_helpdir = $(datadir)/gnome/help/gnomecal/C
-
-gnomecal_help_DATA = \
- gnomecal.html \
- topic.dat
-
-SGML_FILES = \
- gnomecal.sgml
-
-EXTRA_DIST = \
- topic.dat \
- $(SGML_FILES)
-
-all:
-
-gnomecal.html: gnomecal/gnomecal.html
- -cp gnomecal/gnomecal.html .
-
-gnomecal/gnomecal.html: $(SGML_FILES)
- -db2html gnomecal.sgml
-
-dist-hook:
- mkdir $(distdir)/gnomecal
- -cp gnomecal/*.html gnomecal/*.css $(distdir)/gnomecal
- -cp gnomecal.html $(distdir)
- mkdir $(distdir)/images
- -cp images/*.gif images/*.jpg $(distdir)/images
-
-install-data-local: gnomecal.html
- $(mkinstalldirs) $(DESTDIR)$(gnomecal_helpdir)/images
- -for file in $(srcdir)/gnomecal/*.html $(srcdir)/gnomecal/*.css; do \
- basefile=`basename $$file`; \
- $(INSTALL_DATA) $(srcdir)/$$file $(DESTDIR)$(gnomecal_helpdir)/$$basefile; \
- done
- -for file in $(srcdir)/images/*.jpg $(srcdir)/images/*.gif; do \
- $(INSTALL_DATA) $(srcdir)/$$file $(DESTDIR)$(gnomecal_helpdir)/images;\
- done
-
-gnomecal.ps: gnomecal.sgml
- -db2ps $<
-
-gnomecal.rtf: gnomecal.sgml
- -db2rtf $<
-
diff --git a/calendar/doc/C/gnomecal.sgml b/calendar/doc/C/gnomecal.sgml
deleted file mode 100644
index 00c9c8bb72..0000000000
--- a/calendar/doc/C/gnomecal.sgml
+++ /dev/null
@@ -1,465 +0,0 @@
-<!DOCTYPE book PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [
-]>
-
-<book id="gnomecal">
- <bookinfo>
- <title>GNOME calendar user's manual</title>
- <authorgroup>
- <author>
- <firstname>Dave</firstname> <surname>Mason</surname>
- <affiliation>
- <address>
- <email>dcm@redhat.com</email>
- </address>
- </affiliation>
- </author>
- <author>
- <firstname>Miguel</firstname> <surname>de Icaza
- Amozurrutia</surname>
- <affiliation>
- <address>
- <email>miguel@gnu.org</email>
- </address>
- </affiliation>
- </author>
- </authorgroup>
- <copyright>
- <year>1998, 1999</year> <holder>Miguel de Icaza, Dave Mason</holder>
- </copyright>
- <legalnotice>
- <para>This documentation is free software; you can redistribute
- it and/or modify it under the terms of the GNU General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later
- version.</para>
-
- <para>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.</para>
-
- <para>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., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA</para>
-
- <para>For more details see the file COPYING in the source
- distribution of GNOME.</para>
- </legalnotice>
- </bookinfo>
-
- <toc></toc>
-
- <chapter id="cmdline">
- <title>Command line options</title>
-
- <para>
- The following command line options are recognized by the
- <filename>gnomecal</filename> program. You can use these
- options to alter the behaviour of the program or to quickly
- query the program for appointments, and to do items from the
- command line without requiring an X display. These are useful
- for example to include in scripts.
- </para>
-
- <para>
- <itemizedlist>
-
- <listitem>
- <para>
- <emphasis>--events</emphasis>. Displays the events for the
- date specified (or today, if no date is specified).
- </para>
- </listitem>
-
- <listitem>
- <para>
- <emphasis>--from DATE</emphasis>. Define the beginning of
- the range for the event display, or the startup day on the
- calenday views. By default, the event will span the whole
- day specified in DATE.
- </para>
- </listitem>
-
- <listitem>
- <para>
- <emphasis>--to DATE</emphasis>. Define the range end for
- the event display. If this is not specified, it will
- default to the end of the day specified by the
- <emphasis>--from</emphasis> option.
- </para>
- </listitem>
-
- <listitem>
- <para>
- <emphasis>--file FILE</emphasis>. Set the calendar to the
- <emphasis>FILE</emphasis> specified on the command line.
- </para>
- </listitem>
-
- <listitem>
- <para>
- <emphasis>--todo</emphasis>. Dumps the to-do values to
- standard output.
- </para>
- </listitem>
-
- <listitem>
- <para>
- <emphasis>--userfile</emphasis>. Use this if you want to
- force the file to be loaded to be the default user's
- calendar (this is the default, only used to override the
- --file if you have some sort of macro.
- </para>
- </listitem>
-
- <listitem>
- <para>
- <emphasis>--geometry</emphasis>. Used to specity the
- startup geometry of the application (location and size).
- </para>
- </listitem>
-
- <listitem>
- <para>
- <emphasis>--view VIEWMODE</emphasis>. Use this to specify
- the startup view that should be used.
- <emphasis>VIEWMODE</emphasis> is one of: dayview,
- weekview, monthview, yearview.
- </para>
- </listitem>
-
- </itemizedlist>
- </para>
-
- <para>
- <emphasis>DATE</emphasis> is interpreted as being in the local
- time-zone, unless a specific timezone is specified. Examples
- of valid date specifications include: "1 month ago", "2 hours
- ago", "400000 seconds ago", "last year", "last Monday",
- "yesterday", "a fortnight ago", "3/31/92 10:00:07 PST", "January
- 23, 1987 10:05pm", "22:00 GMT".
- </para>
- </chapter>
-
- <chapter id="tech.html">
- <title>Technical information about the GNOME calendar</title>
-
- <para>
- Currently, the GNOME calendar uses the vCal file format standard
- for storing and loading its appointment and todo database. This
- standard is widely used in various other calendar applications,
- so it provides a good mechanism for exchanging appointments.
- </para>
- <para>
- In the future the GNOME calendar will support the upcoming
- iCalendar specification as well.
- </para>
- <para>
- If you want to know more about the vCal specification, you can
- check the <ulink url="http://www.imc.org" type=http>Internet
- Mail Consortium (http://www.imc.org)</ulink> for the details.
- </para>
- </chapter>
-
- <chapter id="gcal">
- <title>The GNOME Calendar</title>
- <sect1>
- <title>Introduction</title>
- <para>
- <indexterm>
- <primary>
- GNOME Calendar
- </primary>
- </indexterm>
- <indexterm>
- <primary>
- Calendar
- </primary>
- </indexterm>
- The GNOME Calendar is a simple calendar applications which can be quite
- useful in your daily work. The Calendar, like much of GNOME, is in its
- infancy and while it is a very useful application, there is some very
- impressive functionality still to come like network shared calendar usage,
- and syncing capability with Palm Pilots and other hand held PDAs. The
- Calendar can be launched from the <guimenu>Applications</guimenu> submenu of
- the Main Menu.
- </para>
- <para>
- The Calendar is broken up into four main tabs: Day, Week, Month,
- and Year. Each view allows you to view the respective time period
- but will also allow you to schedule appointments from any one of
- the tabs.
- </para>
- <figure>
- <title>The GNOME Calendar</title>
- <screenshot>
- <screeninfo>The GNOME Calendar</screeninfo>
- <Graphic Format="gif" Fileref="images/calday" srccredit="dcm">
- </graphic>
- </screenshot>
- </figure>
- </sect1>
- <sect1 id="calsetup" <title>Setting Up the GNOME Calendar</title>
- <para>
- The GNOME Calendar can be used in the state which it is shipped but there
- are tools available to make sure it is setup the way you would like it to
- be. The first place you should go is the GNOME Calendar Preferences. You
- can find the Preferences dialog by selecting the
- <guimenuitem>Preferences</guimenuitem> menu item from the <guimenu>
- Settings</guimenu> menu.
- <figure>
- <title>The GNOME Calendar Preferences</title>
- <screenshot>
- <screeninfo>The GNOME Calendar Preferences.</screeninfo>
- <Graphic Format="gif" Fileref="images/cal-props" srccredit="dcm">
- </graphic>
- </screenshot>
- </figure>
- </para>
- <para>
- The Calendar Preferences dialog is broken up into three tabs, Time display,
- Colors, and Todo list.
- </para>
- <para>
- Time - This tab is broken up into three main sections: Time format, Weeks
- start on, and Day range.
- </para>
- <para>
- Time format - This allows you to choose between a 12 or 24 hour format
- clock.
- </para>
- <para>
- Weeks start on - This allows you to define what day your week will start
- on, Sunday or Monday. This will affect how the calendar is laid out in the
- Day and Week views.
- </para>
- <para>
- Day range - This section lets you choose what time your days will start
- and end. Any hours outside the range selected will be shaded on your Day
- view.
- </para>
- <para>
- Colors - This tab allows you to change the default colors used in the
- Calendar. There are seven color choices you can customize: Outline,
- Headings, Empty days, Appointments, Highlighted day, Day numbers, and
- Current day's number. Each choice has a small color selector box next to
- it. When you press this box you will be given a color selector dialog in
- which you can choose the color you want. Once you have selected a color the
- small sample calendar on the right side of the tab will preview your choice.
- </para>
- <para>
- Todo List - This tab allows you to define which columns will be shown in the
- Todo List in the Day View. You can set the Summary, Due Date, and Priority
- columns.
- </para>
- <para>
- Once you have made the changes to the Calendar Preferences you may press the
- <guibutton>Apply</guibutton> button to apply them.
- </para>
- </sect1>
- <sect1 id="caluse">
- <title>Using the GNOME Calendar</title>
- <para>
- Using the GNOME Calendar is quite simple and most tasks can be performed
- from any of the major views, Day, Week, Month or Year. Probably one of the
- most important features to remember is that at any time you may right mouse
- click on a particular day and add a new appointment. There are many other
- features which will be described below in each of the major views.
- </para>
- <sect2 id="calday">
- <title>The Day View</title>
- <para>
- The Day tab is probably the most useful view in the GNOME Calendar as it
- acts just as a day timer would. On the left of the tab is the hour listing
- for the current day. The light grey coloring in the hour list separates the
- work hours from the non-work hours. If you would like to change the work
- hours displayed in light grey you can do so in <xref
- LinkEnd="calsetup">.
- </para>
- <figure>
- <title>The Day View</title>
- <screenshot>
- <screeninfo>The Day View</screeninfo>
- <Graphic Format="gif" Fileref="images/calday" srccredit="dcm">
- </graphic>
- </screenshot>
- </figure>
- <tip>
- <title>TIP</title>
- <para>
- One tip for adding a new appointment in the Day View is to select a few
- hours in the hours list by clicking and dragging your mouse down the hours
- list. Once the correct range of time has been selected you may press Enter
- and type in the appointment. This will allow you to skip the Create New
- Appointment dialog.
- </para>
- </tip>
- <para>
- Next to the hours listing in the top right hand corner is a small full
- month calendar. You may change the month or year of the small month
- calendar by pressing the forward and backward arrows on the top. You may
- use the small month calendar to navigate the days as well. Double clicking
- on any day in the small month calendar will move the current day view to
- that particular day.
- </para>
- <para>
- Below the small month calendar is your Todo list. The Todo list is a
- simple list where you can keep all your tasks on hand. To add an item to
- the Todo list press the <guibutton>Add</guibutton> button. This will
- launch a small editing box where you can type in the item. Once you have
- entered an item in the Todo list you may use the
- <guibutton>Edit</guibutton> and <guibutton>Delete</guibutton> to manage
- your items. The Todo items are available no matter which days are displayed
- in the Day View and can only be deleted with the
- <guibutton>Delete</guibutton> button.
- </para>
- </sect2>
- <sect2 id="calweek">
- <title>The Week View</title>
- <para>
- The Week View shows the current week with detailed descriptions of your
- appointments. If you would like to add an appointment for any of the days
- in the week view you may right mouse click on the day and select the
- <guimenuitem>New appointment</guimenuitem> menu item from the
- <guimenu>pop-up</guimenu> menu. You may also use the week view to navigate
- to particular days in the Day View. Double-click on any day in the Week
- View and you will go to that day in the Day View.
- </para>
- <figure>
- <title>The Week View</title>
- <screenshot>
- <screeninfo>The Week View</screeninfo>
- <Graphic Format="gif" Fileref="images/calweek" srccredit="dcm">
- </graphic>
- </screenshot>
- </figure>
- <para>
- In the lower left corner of the Week View there is a small month calendar.
- You may change the month or year of the small month calendar by pressing
- the forward and backward arrows on the top. You may use the small month
- calendar to navigate the days as well. Double clicking on any day in the
- small month calendar will move the current week view to that particular
- week.
- </para>
- </sect2>
- <sect2 id="calmonth">
- <title>The Month View</title>
- <para>
- The Month View shows the entire month with brief detailed descriptions of
- your appointments. The Month View makes use of the customized colors
- available in the Calendar. You may read about how to set these colors in
- <xref Linkend="calsetup">. For any day with a brief description of an
- appointment you may click on the day to display a detailed description of
- the appointment in a pop-up window. If you would like to add an appointment
- to a day in the Month View you may right mouse click on any day and select
- the <guimenuitem>New Appointment in this day</guimenuitem> item from the
- <guimenu>pop-up</guimenu> menu. You may use the items in the
- <guimenu>pop-up</guimenu> menu to navigate in the Day, Week, and Year views
- by selecting either <guimenuitem>Jump to this day</guimenuitem>,
- <guimenuitem>Jump to this week</guimenuitem>, or<guimenuitem>Jump to this
- Year</guimenuitem>.
- </para>
- <figure>
- <title>The Month View</title>
- <screenshot>
- <screeninfo>The Month View</screeninfo>
- <Graphic Format="gif" Fileref="images/calmonth" srccredit="dcm">
- </graphic>
- </screenshot>
- </figure>
- </sect2>
- <sect2 id="calyear">
- <title>The Year View</title>
- <para>
- The Year View shows you the entire year with no descriptions of
- appointments. Like the Month View, the Year View makes use of the
- customized colors available in the Calendar. You may read about how to set
- these colors in <xref Linkend="calsetup">. If you have an appointment on a
- day you may click on that day and a description of the appointment will be
- displayed in the pop-up window. If you would like to add an appointment to
- a day in the Year View you may right mouse click on any day and select the
- <guimenuitem>New Appointment in this day</guimenuitem> item from the
- <guimenu>pop-up</guimenu> menu. You may use the items in the
- <guimenu>pop-up</guimenu> menu to navigate in the Day, Week, and Month
- views by selecting either <guimenuitem>Jump to this day</guimenuitem>,
- <guimenuitem>Jump to this week</guimenuitem>, or <guimenuitem>Jump to this
- Month</guimenuitem>.
- </para>
- <figure>
- <title>The Year View</title>
- <screenshot>
- <screeninfo>The Year View</screeninfo>
- <Graphic Format="gif" Fileref="images/calyear" srccredit="dcm">
- </graphic>
- </screenshot>
- </figure>
- </sect2>
- </sect1>
- <sect1 id="calappoint">
- <title>Making a New Appointment</title>
- <para>
- There are many methods for making a new appointment in the GNOME Calendar,
- the easiest is by pressing the <guibutton>New</guibutton> button on the
- button bar. Whenever you make a new appointment you will launch the Create
- New Appointment dialog that allows you to set the properties of that
- appointment. The Create New Appointment dialog is broken into two
- different tabs, the General and the Recurrence tabs.
- </para>
- <para>
- General - The General tab is the area in which you specify the time of the
- appointment and set reminders for yourself. There are four different areas
- on the General tab: Summary, Time, Alarms, and Classification.
- <ITEMIZEDLIST MARK="bullet">
- <listitem>
- <para>
- Summary - The Summary box allows you to type a description of the
- appointment. Keep in mind that only a portion of this description will
- be available in the Week and Month Views.
- </para>
- </listitem>
- <listitem>
- <para>
- Time - The Time area allows you to set the time range for the
- appointment by selecting the date and hours. To the right of the start
- and end days there is a small selection box named Calendar. This will
- bring up a small Calendar when pressed. You may select the start and end
- date in the small calendar. To the right of the start en end hours
- there is a small button which will display the hours of the day when
- pressed. Each hour in the list will have a sub menu displaying each
- quarter hour so you may select them. The hours are restricted to those
- included in the Day Range.
- </para>
- </listitem>
- <listitem>
- <para>
- Alarms - The Alarms area allows you to set up an alarm to remind you of
- an appointment. There are four different types of alarms you may use to
- remind yourself of appointments: Display, Audio, Program, and Mail. The
- Display alarm will display a message on your screen in the time you
- set. The Audio alarm will play an audio file at the time you set. The
- Program alarm will run a program you specify at the time you set. The
- Mail alarm will send email to the user specified at the time you set.
- </para>
- </listitem>
- <!-- <listitem>
- <para>
- Classification - TO BE DONE
- </para>
- </listitem> -->
- </itemizedlist>
- </para>
- <para>
- Recurrence - The Recurrence tab allows you to specify how often an
- appointment should recur, if at all. The first property you should set if
- you want a recurring appointment is the Recurrence rule. You may choose
- among None, Daily, Weekly, Monthly, and Yearly. For each selection you may
- adjust the recurrence properties for your selection. In the Ending date
- area you may set a rule which will stop the recurrence of your appointment
- or allow it to repeat forever. In the Exceptions area you may make
- exceptions to the recurring appointment by double-clicking the date and
- pressing the <guibutton>Add</guibutton> button.
- </para>
- </sect1>
- </chapter>
-</book>
diff --git a/calendar/doc/C/images/cal-props.gif b/calendar/doc/C/images/cal-props.gif
deleted file mode 100644
index 4a3ca0c706..0000000000
--- a/calendar/doc/C/images/cal-props.gif
+++ /dev/null
Binary files differ
diff --git a/calendar/doc/C/images/calday.gif b/calendar/doc/C/images/calday.gif
deleted file mode 100644
index d708cbb2e7..0000000000
--- a/calendar/doc/C/images/calday.gif
+++ /dev/null
Binary files differ
diff --git a/calendar/doc/C/images/calmonth.gif b/calendar/doc/C/images/calmonth.gif
deleted file mode 100644
index be20d3255c..0000000000
--- a/calendar/doc/C/images/calmonth.gif
+++ /dev/null
Binary files differ
diff --git a/calendar/doc/C/images/calweek.gif b/calendar/doc/C/images/calweek.gif
deleted file mode 100644
index 04820f9470..0000000000
--- a/calendar/doc/C/images/calweek.gif
+++ /dev/null
Binary files differ
diff --git a/calendar/doc/C/images/calyear.gif b/calendar/doc/C/images/calyear.gif
deleted file mode 100644
index 6e2333f419..0000000000
--- a/calendar/doc/C/images/calyear.gif
+++ /dev/null
Binary files differ
diff --git a/calendar/doc/C/topic.dat b/calendar/doc/C/topic.dat
deleted file mode 100644
index 23af169d62..0000000000
--- a/calendar/doc/C/topic.dat
+++ /dev/null
@@ -1,2 +0,0 @@
-gnomecal.html Manual
-cmdline.html Command line options
diff --git a/calendar/doc/Makefile.am b/calendar/doc/Makefile.am
deleted file mode 100644
index 42ffacc264..0000000000
--- a/calendar/doc/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-SUBDIRS = C
diff --git a/calendar/eventedit.c b/calendar/eventedit.c
deleted file mode 100644
index 31fbf11225..0000000000
--- a/calendar/eventedit.c
+++ /dev/null
@@ -1,1583 +0,0 @@
-/*
- * EventEditor widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors: Miguel de Icaza (miguel@kernel.org)
- * Federico Mena (quartic@gimp.org)
- */
-#include <config.h>
-#include <gnome.h>
-#include <string.h>
-#include "calendar.h"
-#include "eventedit.h"
-#include "main.h"
-#include "timeutil.h"
-
-
-static void event_editor_class_init (EventEditorClass *class);
-static void event_editor_init (EventEditor *ee);
-static void event_editor_destroy (GtkObject *object);
-
-GtkWidget* make_spin_button (int val, int low, int high);
-void ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type,
- int y, gboolean control_sens, GtkSignalFunc dirty_func);
-void ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type);
-
-/* Note: do not i18n these strings, they are part of the vCalendar protocol */
-static char *class_names [] = { "PUBLIC", "PRIVATE", "CONFIDENTIAL" };
-
-static GnomeDialogClass *parent_class;
-
-struct numbered_item {
- char *text;
- int num;
-};
-
-
-guint
-event_editor_get_type (void)
-{
- static guint event_editor_type = 0;
-
- if(!event_editor_type) {
- GtkTypeInfo event_editor_info = {
- "EventEditor",
- sizeof(EventEditor),
- sizeof(EventEditorClass),
- (GtkClassInitFunc) event_editor_class_init,
- (GtkObjectInitFunc) event_editor_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL,
- };
- event_editor_type = gtk_type_unique (gnome_dialog_get_type (), &event_editor_info);
- }
- return event_editor_type;
-}
-
-static void
-event_editor_class_init (EventEditorClass *class)
-{
- GtkObjectClass *object_class;
-
- parent_class = gtk_type_class (gnome_dialog_get_type ());
- object_class = (GtkObjectClass*) class;
- object_class->destroy = event_editor_destroy;
-}
-
-GtkWidget *
-make_spin_button (int val, int low, int high)
-{
- GtkAdjustment *adj;
- GtkWidget *spin;
-
- adj = GTK_ADJUSTMENT (gtk_adjustment_new (val, low, high, 1, 10, 10));
- spin = gtk_spin_button_new (adj, 0.5, 0);
- gtk_widget_set_usize (spin, 60, 0);
-
- return spin;
-}
-
-/*
- * Checks if the day range occupies all the day, and if so, check the
- * box accordingly
- */
-static void
-ee_check_all_day (EventEditor *ee)
-{
- time_t ev_start, ev_end;
-
- ev_start = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- ev_end = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (get_time_t_hour (ev_start) <= day_begin && get_time_t_hour (ev_end) >= day_end)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->general_allday), 1);
- else
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->general_allday), 0);
-}
-
-/*
- * Callback: checks that the dates are start < end
- */
-static void
-check_dates (GnomeDateEdit *gde, EventEditor *ee)
-{
- time_t start, end;
- struct tm tm_start, tm_end;
-
- start = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- end = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (start > end) {
- tm_start = *localtime (&start);
- tm_end = *localtime (&end);
-
- if (GTK_WIDGET (gde) == ee->start_time) {
- tm_end.tm_year = tm_start.tm_year;
- tm_end.tm_mon = tm_start.tm_mon;
- tm_end.tm_mday = tm_start.tm_mday;
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (&tm_end));
- } else if (GTK_WIDGET (gde) == ee->end_time) {
- tm_start.tm_year = tm_end.tm_year;
- tm_start.tm_mon = tm_end.tm_mon;
- tm_start.tm_mday = tm_end.tm_mday;
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->start_time), mktime (&tm_start));
- }
- }
-}
-
-/*
- * Callback: checks that start_time < end_time and whether the
- * selected hour range spans all of the day
- */
-static void
-check_times (GnomeDateEdit *gde, EventEditor *ee)
-{
- time_t start, end;
- struct tm tm_start, tm_end;
-
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gdk_flush ();
-
- start = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- end = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (start >= end) {
- tm_start = *localtime (&start);
- tm_end = *localtime (&end);
-
- if (GTK_WIDGET (gde) == ee->start_time) {
- tm_end.tm_min = tm_start.tm_min;
- tm_end.tm_sec = tm_start.tm_sec;
-
- tm_end.tm_hour = tm_start.tm_hour + 1;
-
- if (tm_end.tm_hour >= 24) {
- tm_end.tm_hour = 24; /* mktime() will bump the day */
- tm_end.tm_min = 0;
- tm_end.tm_sec = 0;
- }
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (&tm_end));
- } else if (GTK_WIDGET (gde) == ee->end_time) {
- tm_start.tm_min = tm_end.tm_min;
- tm_start.tm_sec = tm_end.tm_sec;
-
- tm_start.tm_hour = tm_end.tm_hour - 1;
-
- if (tm_start.tm_hour < 0) {
- tm_start.tm_hour = 0;
- tm_start.tm_min = 0;
- tm_start.tm_min = 0;
- }
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->start_time), mktime (&tm_start));
- }
- }
-
- /* Check whether the event spans the whole day */
-
- ee_check_all_day (ee);
-}
-
-/*
- * Callback: all day event box clicked
- */
-static void
-set_all_day (GtkToggleButton *toggle, EventEditor *ee)
-{
- struct tm tm;
- time_t start_t;
-
- start_t = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- tm = *localtime (&start_t);
- tm.tm_hour = day_begin;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->start_time), mktime (&tm));
-
- if (toggle->active)
- tm.tm_hour = day_end;
- else
- tm.tm_hour++;
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (&tm));
-}
-
-/* Convenience function to create a properly-configured date editor widget */
-GtkWidget *
-date_edit_new (time_t the_time, int show_time)
-{
- return gnome_date_edit_new_flags (the_time,
- ((show_time ? GNOME_DATE_EDIT_SHOW_TIME : 0)
- | (am_pm_flag ? 0 : GNOME_DATE_EDIT_24_HR)
- | (week_starts_on_monday
- ? GNOME_DATE_EDIT_WEEK_STARTS_ON_MONDAY
- : 0)));
-}
-
-static GtkWidget *
-event_editor_setup_time_frame (EventEditor *ee)
-{
- GtkWidget *frame;
- GtkWidget *start_time, *end_time;
- GtkTable *t;
-
- frame = gtk_frame_new (_("Time"));
- t = GTK_TABLE (ee->general_time_table = gtk_table_new (1, 1, 0));
- gtk_container_border_width (GTK_CONTAINER (t), 4);
- gtk_table_set_row_spacings (t, 4);
- gtk_table_set_col_spacings (t, 4);
- gtk_container_add (GTK_CONTAINER (frame), ee->general_time_table);
-
- /* 1. Start time */
- if (ee->ical->dtstart == 0){
- ee->ical->dtstart = time (NULL);
- ee->ical->dtend = time_add_minutes (ee->ical->dtstart, 30);
- }
- ee->start_time = start_time = date_edit_new (ee->ical->dtstart, TRUE);
- gnome_date_edit_set_popup_range ((GnomeDateEdit *) start_time, day_begin, day_end);
- gtk_signal_connect (GTK_OBJECT (start_time), "date_changed",
- GTK_SIGNAL_FUNC (check_dates), ee);
- gtk_signal_connect (GTK_OBJECT (start_time), "time_changed",
- GTK_SIGNAL_FUNC (check_times), ee);
- gtk_table_attach (t, gtk_label_new (_("Start time:")), 1, 2, 1, 2,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_table_attach (t, start_time, 2, 3, 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- /* 2. End time */
- ee->end_time = end_time = date_edit_new (ee->ical->dtend, TRUE);
- gnome_date_edit_set_popup_range ((GnomeDateEdit *) end_time, day_begin, day_end);
- gtk_signal_connect (GTK_OBJECT (end_time), "date_changed",
- GTK_SIGNAL_FUNC (check_dates), ee);
- gtk_signal_connect (GTK_OBJECT (end_time), "time_changed",
- GTK_SIGNAL_FUNC (check_times), ee);
- gtk_table_attach (t, gtk_label_new (_("End time:")), 1, 2, 2, 3,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_table_attach (t, end_time, 2, 3, 2, 3,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- /* 3. All day checkbox */
- ee->general_allday = gtk_check_button_new_with_label (_("All day event"));
- gtk_signal_connect (GTK_OBJECT (ee->general_allday), "toggled",
- GTK_SIGNAL_FUNC (set_all_day), ee);
- gtk_table_attach (t, ee->general_allday, 3, 4, 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 4, 0);
- ee_check_all_day (ee);
-
- return frame;
-}
-
-static GtkWidget *
-timesel_new (void)
-{
- GtkWidget *menu, *option_menu;
- char *items [] = { N_("Minutes"), N_("Hours"), N_("Days") };
- int i;
-
- option_menu = gtk_option_menu_new ();
- menu = gtk_menu_new ();
- for (i = 0; i < 3; i++){
- GtkWidget *item;
-
- item = gtk_menu_item_new_with_label (_(items [i]));
- gtk_menu_append (GTK_MENU (menu), item);
- gtk_widget_show (item);
- }
- gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
- return option_menu;
-}
-
-/*
- * Set the sensitive state depending on whether the alarm enabled flag.
- */
-static void
-ee_alarm_setting (CalendarAlarm *alarm, int sensitive)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_count), sensitive);
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_timesel), sensitive);
-
- if (alarm->type == ALARM_PROGRAM || alarm->type == ALARM_MAIL){
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_entry), sensitive);
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_label), sensitive);
- }
-}
-
-static void
-alarm_toggle (GtkToggleButton *toggle, CalendarAlarm *alarm)
-{
- ee_alarm_setting (alarm, toggle->active);
-}
-
-#define FXS (GTK_FILL | GTK_EXPAND | GTK_SHRINK)
-#define FS (GTK_FILL | GTK_SHRINK)
-
-void
-ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type, int y, gboolean control_sens, GtkSignalFunc dirty_func)
-{
- GtkWidget *entry;
-
- alarm->w_enabled = gtk_check_button_new_with_label (str);
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (alarm->w_enabled),
- alarm->enabled);
- if (control_sens)
- gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled",
- GTK_SIGNAL_FUNC (alarm_toggle), alarm);
- if (dirty_func)
- gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled",
- GTK_SIGNAL_FUNC (dirty_func), NULL);
- gtk_table_attach (table, alarm->w_enabled, 0, 1, y, y+1, FS, FS, 0, 0);
-
- alarm->w_count = make_spin_button (alarm->count, 0, 10000);
- if (dirty_func)
- gtk_signal_connect (GTK_OBJECT (alarm->w_count), "changed",
- GTK_SIGNAL_FUNC (dirty_func), NULL);
- gtk_table_attach (table, alarm->w_count, 1, 2, y, y+1, FS, FS, 0, 0);
-
- alarm->w_timesel = timesel_new ();
- /* is there a "changed" signal which we can connect to? */
- gtk_option_menu_set_history (GTK_OPTION_MENU (alarm->w_timesel), alarm->units);
- gtk_table_attach (table, alarm->w_timesel, 2, 3, y, y+1, FS, FS, 0, 0);
-
- switch (type){
- case ALARM_MAIL:
- alarm->w_label = gtk_label_new (_("Mail to:"));
- gtk_misc_set_alignment (GTK_MISC (alarm->w_label), 1.0, 0.5);
- gtk_table_attach (table, alarm->w_label, 3, 4, y, y+1, FS, FS, 0, 0);
- alarm->w_entry = gtk_entry_new ();
- gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0);
- gtk_entry_set_text (GTK_ENTRY (alarm->w_entry), alarm->data ? alarm->data : "");
- if (dirty_func)
- gtk_signal_connect (GTK_OBJECT (alarm->w_entry),
- "changed",
- GTK_SIGNAL_FUNC (dirty_func),
- NULL);
- break;
-
- case ALARM_PROGRAM:
- alarm->w_label = gtk_label_new (_("Run program:"));
- gtk_misc_set_alignment (GTK_MISC (alarm->w_label), 1.0, 0.5);
- gtk_table_attach (table, alarm->w_label, 3, 4, y, y+1, FS, FS, 0, 0);
- alarm->w_entry = gnome_file_entry_new ("alarm-program", _("Select program to run at alarm time"));
- entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (alarm->w_entry));
- gtk_entry_set_text (GTK_ENTRY (entry), alarm->data ? alarm->data : "");
- gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0);
- if (dirty_func)
- gtk_signal_connect (GTK_OBJECT (entry),
- "changed",
- GTK_SIGNAL_FUNC (dirty_func),
- NULL);
- break;
-
- default:
- break;
- }
-
- if (control_sens)
- ee_alarm_setting (alarm, alarm->enabled);
- else
- ee_alarm_setting (alarm, TRUE);
-}
-
-static GtkWidget *
-ee_alarm_widgets (EventEditor *ee)
-{
- GtkWidget *table, *mailto, *mailte, *l;
-
- l = gtk_frame_new (_("Alarms"));
-
- table = gtk_table_new (1, 1, 0);
- gtk_container_border_width (GTK_CONTAINER (table), 4);
- gtk_table_set_row_spacings (GTK_TABLE (table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (table), 4);
- gtk_container_add (GTK_CONTAINER (l), table);
-
- mailto = gtk_label_new (_("Mail to:"));
- mailte = gtk_entry_new ();
-
- ee_create_ae (GTK_TABLE (table), _("Display"), &ee->ical->dalarm, ALARM_DISPLAY, 1, TRUE, NULL);
- ee_create_ae (GTK_TABLE (table), _("Audio"), &ee->ical->aalarm, ALARM_AUDIO, 2, TRUE, NULL);
- ee_create_ae (GTK_TABLE (table), _("Program"), &ee->ical->palarm, ALARM_PROGRAM, 3, TRUE, NULL);
- ee_create_ae (GTK_TABLE (table), _("Mail"), &ee->ical->malarm, ALARM_MAIL, 4, TRUE, NULL);
-
- return l;
-}
-
-static GtkWidget *
-ee_classification_widgets (EventEditor *ee)
-{
- GtkWidget *rpub, *rpriv, *rconf;
- GtkWidget *frame, *hbox;
-
- frame = gtk_frame_new (_("Classification"));
-
- hbox = gtk_hbox_new (TRUE, 0);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_container_add (GTK_CONTAINER (frame), hbox);
-
- rpub = gtk_radio_button_new_with_label (NULL, _("Public"));
- rpriv = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Private"));
- rconf = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Confidential"));
-
- gtk_box_pack_start (GTK_BOX (hbox), rpub, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), rpriv, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), rconf, FALSE, FALSE, 0);
-
- if (strcmp (ee->ical->class, class_names[0]) == 0)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rpub), TRUE);
- else if (strcmp (ee->ical->class, class_names[1]) == 0)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rpriv), TRUE);
- else if (strcmp (ee->ical->class, class_names[2]) == 0)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rconf), TRUE);
-
- ee->general_radios = rpub;
-
- return frame;
-}
-
-/*
- * Retrieves the information from the CalendarAlarm widgets and stores them
- * on the CalendarAlarm generic values
- */
-void
-ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type)
-{
- GtkWidget *item;
- GtkMenu *menu;
- GList *child;
- int idx;
-
- if (alarm->data){
- g_free (alarm->data);
- alarm->data = 0;
- }
-
- alarm->enabled = GTK_TOGGLE_BUTTON (alarm->w_enabled)->active;
-
- if (!alarm->enabled)
- return;
-
- if (type == ALARM_PROGRAM)
- alarm->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (gnome_file_entry_gtk_entry (alarm->w_entry))));
- if (type == ALARM_MAIL)
- alarm->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (alarm->w_entry)));
-
- /* Find out the index */
- menu = GTK_MENU (GTK_OPTION_MENU (alarm->w_timesel)->menu);
-
- item = gtk_menu_get_active (menu);
-
- for (idx = 0, child = GTK_MENU_SHELL (menu)->children; child->data != item; child = child->next)
- idx++;
-
- alarm->units = idx;
- alarm->count = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (alarm->w_count));
-}
-
-static void
-ee_store_general_values_to_ical (EventEditor *ee)
-{
- GtkRadioButton *radio = GTK_RADIO_BUTTON (ee->general_radios);
- iCalObject *ical = ee->ical;
- GSList *list = radio->group;
- int idx;
- time_t now;
-
- now = time (NULL);
- ical->dtstart = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- ical->dtend = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (ical->summary)
- g_free (ical->summary);
-
- ical->summary = gtk_editable_get_chars (GTK_EDITABLE (ee->general_summary), 0, -1);
-
- ee_store_alarm (&ical->dalarm, ALARM_DISPLAY);
- ee_store_alarm (&ical->aalarm, ALARM_AUDIO);
- ee_store_alarm (&ical->palarm, ALARM_PROGRAM);
- ee_store_alarm (&ical->malarm, ALARM_MAIL);
-
- for (idx = 2; list; list = list->next) {
- if (GTK_TOGGLE_BUTTON (list->data)->active)
- break;
- idx--; /* The group is stored in reverse order of insertion */
- }
-
- g_free (ical->class);
- ical->class = g_strdup (class_names [idx]);
-}
-
-static int
-option_menu_active_number (GtkWidget *omenu)
-{
- GtkWidget *menu;
- GtkWidget *item;
- struct numbered_item *ni;
-
- menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (omenu));
- item = gtk_menu_get_active (GTK_MENU (menu));
-
- ni = gtk_object_get_user_data (GTK_OBJECT (item));
-
- return ni->num;
-}
-
-static int
-ee_store_recur_rule_to_ical (EventEditor *ee)
-{
- iCalObject *ical;
- int i, j;
- GSList *list;
-
- ical = ee->ical;
-
- for (i = 0, list = ee->recur_rr_group; list; i++, list = list->next)
- if (GTK_TOGGLE_BUTTON (list->data)->active)
- break;
-
- i = g_slist_length (ee->recur_rr_group) - i - 1; /* buttons are stored in reverse order of insertion */
-
- /* None selected, no rule to be stored */
- if (i == 0)
- return 0;
-
- if (!ical->recur)
- ical->recur = g_new0 (Recurrence, 1);
-
- switch (i) {
- case 1:
- /* Daily */
- ical->recur->type = RECUR_DAILY;
- ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_day_period));
- break;
-
- case 2:
- /* Weekly */
- ical->recur->type = RECUR_WEEKLY;
- ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_week_period));
- ical->recur->weekday = 0;
-
- for (j = 0; j < 7; j++)
- if (GTK_TOGGLE_BUTTON (ee->recur_rr_week_days[j])->active) {
- if (j == 6)
- ical->recur->weekday |= 1 << 0; /* sunday is at bit 0 */
- else
- ical->recur->weekday |= 1 << (j + 1);
- }
-
- break;
-
- case 3:
- /* Monthly */
-
- if (GTK_WIDGET_SENSITIVE (ee->recur_rr_month_date)) {
- /* by day */
-
- ical->recur->type = RECUR_MONTHLY_BY_DAY;
- ical->recur->u.month_day =
- gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (ee->recur_rr_month_date));
- ical->recur->interval =
- gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (ee->recur_rr_month_period));
- } else {
- /* by position */
-
- ical->recur->type = RECUR_MONTHLY_BY_POS;
-
- ical->recur->u.month_pos =
- option_menu_active_number (ee->recur_rr_month_day);
- ical->recur->weekday =
- option_menu_active_number (ee->recur_rr_month_weekday);
- ical->recur->interval =
- gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (ee->recur_rr_month_period));
- }
-
- break;
-
- case 4:
- /* Yearly */
- ical->recur->type = RECUR_YEARLY_BY_DAY;
- ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_year_period));
- /* FIXME: need to specify anything else? I am assuming the code will look at the dtstart
- * to figure out when to recur. - Federico
- */
- break;
-
- default:
- g_assert_not_reached ();
- }
- return 1;
-}
-
-static void
-ee_store_recur_end_to_ical (EventEditor *ee)
-{
- iCalObject *ical;
- GSList *list;
- int i;
-
- /* Ending date of recurrence */
-
- ical = ee->ical;
-
- for (i = 0, list = ee->recur_ed_group; list; i++, list = list->next)
- if (GTK_TOGGLE_BUTTON (list->data)->active)
- break;
-
- i = g_slist_length (ee->recur_ed_group) - i - 1; /* the list is stored in reverse order of insertion */
-
- switch (i) {
- case 0:
- /* repeat forever */
- ical->recur->_enddate = 0;
- ical->recur->enddate = 0;
- ical->recur->duration = 0;
- break;
-
- case 1:
- /* end date */
- /* Also here, to ensure that the event is used, we add 86400 secs to get
- get next day, in accordance to the RFC */
- ical->recur->_enddate = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->recur_ed_end_on)) + 86400;
- ical->recur->enddate = ical->recur->_enddate;
- ical->recur->duration = 0;
- break;
-
- case 2:
- /* end after n occurrences */
- ical->recur->duration = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_ed_end_after));
- ical_object_compute_end (ical);
- break;
-
- default:
- g_assert_not_reached ();
- break;
- }
-}
-
-static void
-free_exdate (iCalObject *ical)
-{
- GList *list;
-
- if (!ical->exdate)
- return;
-
- for (list = ical->exdate; list; list = list->next)
- g_free (list->data);
-
- g_list_free (ical->exdate);
- ical->exdate = NULL;
-}
-
-static void
-ee_store_recur_exceptions_to_ical (EventEditor *ee)
-{
- iCalObject *ical;
- GtkCList *clist;
- int i;
- time_t *t;
-
- ical = ee->ical;
- clist = GTK_CLIST (ee->recur_ex_clist);
-
- free_exdate (ical);
-
- for (i = 0; i < clist->rows; i++) {
- t = gtk_clist_get_row_data (clist, i);
- ical->exdate = g_list_prepend (ical->exdate, t);
- }
-}
-
-static void
-ee_store_recur_values_to_ical (EventEditor *ee)
-{
- if (ee_store_recur_rule_to_ical (ee)){
- ee_store_recur_exceptions_to_ical (ee);
- ee_store_recur_end_to_ical (ee);
- } else if (ee->ical->recur) {
- g_free (ee->ical->recur);
- ee->ical->recur = NULL;
- if (ee->ical->exdate){
- GList *l = ee->ical->exdate;
-
- for (; l; l = l->next)
- g_free (l->data);
- g_list_free (l);
- }
- }
-}
-
-/*
- * Retrieves all of the information from the different widgets and updates
- * the iCalObject accordingly.
- */
-static void
-ee_store_dlg_values_to_ical (EventEditor *ee)
-{
- time_t now;
-
- ee_store_general_values_to_ical (ee);
- ee_store_recur_values_to_ical (ee);
-
- now = time (NULL);
-
- /* FIXME: This is not entirely correct; we should check if the values actually changed */
- ee->ical->last_mod = now;
-
- if (ee->ical->new)
- ee->ical->created = now;
-}
-
-static void
-ee_ok (GtkWidget *widget, EventEditor *ee)
-{
- ee_store_dlg_values_to_ical (ee);
-
- if (ee->ical->new)
- gnome_calendar_add_object (ee->gnome_cal, ee->ical);
- else
- gnome_calendar_object_changed (ee->gnome_cal, ee->ical, CHANGE_ALL);
-
- save_default_calendar (ee->gnome_cal);
- ee->ical->new = 0;
-}
-
-static void
-ee_cancel (GtkWidget *widget, EventEditor *ee)
-{
- if (ee->ical->new) {
- ical_object_destroy (ee->ical);
- ee->ical = NULL;
- }
-
-}
-
-static void
-ee_create_buttons (EventEditor *ee)
-{
- gnome_dialog_append_buttons(GNOME_DIALOG(ee),
- GNOME_STOCK_BUTTON_OK,
- GNOME_STOCK_BUTTON_CANCEL, NULL);
- gnome_dialog_set_default (GNOME_DIALOG (ee), 0);
- gnome_dialog_button_connect (GNOME_DIALOG (ee), 0, GTK_SIGNAL_FUNC(ee_ok), ee);
- gnome_dialog_button_connect (GNOME_DIALOG (ee), 1, GTK_SIGNAL_FUNC(ee_cancel), ee);
-
- return;
-}
-
-/*
- * Load the contents in a delayed fashion, as the GtkText widget needs it
- */
-static void
-ee_fill_summary (GtkWidget *widget, EventEditor *ee)
-{
- int pos = 0;
-
- gtk_editable_insert_text (GTK_EDITABLE (ee->general_summary), ee->ical->summary,
- strlen (ee->ical->summary), &pos);
- gtk_text_thaw (GTK_TEXT (ee->general_summary));
-}
-
-enum {
- OWNER_LINE,
- DESC_LINE,
- SUMMARY_LINE,
- TIME_LINE,
- ALARM_LINE,
- CLASS_LINE
-};
-
-/* Create/setup the general page */
-static void
-ee_init_general_page (EventEditor *ee)
-{
- GtkWidget *l;
- GtkWidget *hbox;
-
- ee->general_table = gtk_table_new (1, 1, FALSE);
- gtk_container_border_width (GTK_CONTAINER (ee->general_table), 4);
- gtk_table_set_row_spacings (GTK_TABLE (ee->general_table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (ee->general_table), 4);
- gtk_notebook_append_page (GTK_NOTEBOOK (ee->notebook), GTK_WIDGET (ee->general_table),
- gtk_label_new (_("General")));
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_table_attach (GTK_TABLE (ee->general_table), hbox,
- 0, 1, OWNER_LINE, OWNER_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 4);
-
- l = gtk_label_new (_("Owner:"));
- gtk_box_pack_start (GTK_BOX (hbox), l, FALSE, FALSE, 0);
-
- ee->general_owner = gtk_label_new (ee->ical->organizer ? ee->ical->organizer : _("?"));
- gtk_misc_set_alignment (GTK_MISC (ee->general_owner), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (hbox), ee->general_owner, TRUE, TRUE, 4);
-
- l = gtk_label_new (_("Summary:"));
- gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, DESC_LINE, DESC_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- ee->general_summary = gtk_text_new (NULL, NULL);
- gtk_text_freeze (GTK_TEXT (ee->general_summary));
- gtk_signal_connect (GTK_OBJECT (ee->general_summary), "realize",
- GTK_SIGNAL_FUNC (ee_fill_summary), ee);
- gtk_widget_set_usize (ee->general_summary, 0, 60);
- gtk_text_set_editable (GTK_TEXT (ee->general_summary), 1);
- gtk_table_attach (GTK_TABLE (ee->general_table), ee->general_summary,
- 0, 1, SUMMARY_LINE, SUMMARY_LINE+1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- l = ee_alarm_widgets (ee);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, ALARM_LINE, ALARM_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- l = event_editor_setup_time_frame (ee);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, TIME_LINE, TIME_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- l = ee_classification_widgets (ee);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, CLASS_LINE, CLASS_LINE + 1,
- GTK_EXPAND | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-}
-
-static void
-ee_init_summary_page (EventEditor *ee)
-{
-}
-
-struct {
- char *name;
-} recurrence_types [] = {
- { N_("None") },
- { N_("Daily") },
- { N_("Weekly") },
- { N_("Monthly") },
- { N_("Yearly") },
- { 0 }
-};
-
-static void
-recurrence_toggled (GtkRadioButton *radio, EventEditor *ee)
-{
- GSList *list = ee->recur_rr_group;
- int which;
-
- if (!GTK_TOGGLE_BUTTON (radio)->active)
- return;
-
- for (which = 0; list; list = list->next, which++) {
- if (list->data == radio) {
- gtk_notebook_set_page (GTK_NOTEBOOK (ee->recur_rr_notebook), 4 - which);
- return;
- }
- }
-}
-
-static struct numbered_item weekday_positions[] = {
- { N_("1st"), 1 },
- { N_("2nd"), 2 },
- { N_("3rd"), 3 },
- { N_("4th"), 4 },
- { N_("5th"), 5 },
- { 0 }
-};
-
-static struct numbered_item weekday_names[] = {
- { N_("Monday"), 1 },
- { N_("Tuesday"), 2 },
- { N_("Wednesday"), 3 },
- { N_("Thursday"), 4 },
- { N_("Friday"), 5 },
- { N_("Saturday"), 6 },
- { N_("Sunday"), 0 }, /* on the spec, Sunday is zero */
- { 0 }
-};
-
-static GtkWidget *
-make_numbered_menu (struct numbered_item *items, int sel)
-{
- GtkWidget *option_menu, *menu;
- int i;
-
- option_menu = gtk_option_menu_new ();
- menu = gtk_menu_new ();
-
- for (i = 0; items[i].text; i++) {
- GtkWidget *item;
-
- item = gtk_menu_item_new_with_label (_(items[i].text));
- gtk_object_set_user_data (GTK_OBJECT (item), &items[i]);
- gtk_menu_append (GTK_MENU (menu), item);
- gtk_widget_show (item);
- }
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
- gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), sel);
-
- return option_menu;
-}
-
-static void
-month_sensitize (EventEditor *ee, int state)
-{
- gtk_widget_set_sensitive (ee->recur_rr_month_date, state);
- gtk_widget_set_sensitive (ee->recur_rr_month_date_label, state);
-
- gtk_widget_set_sensitive (ee->recur_rr_month_day, !state);
- gtk_widget_set_sensitive (ee->recur_rr_month_weekday, !state);
-}
-
-static void
-recur_month_enable_date (GtkToggleButton *button, EventEditor *ee)
-{
- month_sensitize (ee, button->active);
-}
-
-static void
-desensitize_on_toggle (GtkToggleButton *toggle, gpointer data)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (data), !toggle->active);
-}
-
-static void
-ee_rp_init_rule (EventEditor *ee)
-{
- static char *day_names [] = { N_("Mon"), N_("Tue"), N_("Wed"), N_("Thu"), N_("Fri"), N_("Sat"), N_("Sun") };
- GtkWidget *r, *re, *r1, *f, *vbox, *hbox, *b, *week_hbox, *week_day, *w;
- GtkWidget *none, *daily, *weekly, *monthly, *yearly;
- GtkNotebook *notebook;
- GSList *group;
- int i, page, day_period, week_period, month_period, year_period;
- int week_vector, default_day, def_pos, def_off;
- struct tm tm;
-
- tm = *localtime (&ee->ical->dtstart);
-
- f = gtk_frame_new (_("Recurrence rule"));
-
- hbox = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_container_add (GTK_CONTAINER (f), hbox);
-
- vbox = gtk_vbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
-
- gtk_box_pack_start (GTK_BOX (hbox), gtk_vseparator_new (), FALSE, FALSE, 0);
-
- ee->recur_rr_notebook = gtk_notebook_new ();
- notebook = GTK_NOTEBOOK (ee->recur_rr_notebook);
- gtk_box_pack_start (GTK_BOX (hbox), ee->recur_rr_notebook, TRUE, TRUE, 0);
-
- day_period = 1;
- week_period = 1;
- month_period = 1;
- year_period = 1;
-
- /* Default to today */
-
- week_vector = 1 << tm.tm_wday;
- default_day = tm.tm_mday;
- def_pos = 0;
- def_off = 0;
-
- /* Determine which should be the default selection */
-
- page = 0;
- if (ee->ical->recur) {
- enum RecurType type = ee->ical->recur->type;
- int interval = ee->ical->recur->interval;
-
- switch (type) {
- case RECUR_DAILY:
- page = 1;
- day_period = interval;
- break;
-
- case RECUR_WEEKLY:
- page = 2;
- week_period = interval;
- week_vector = ee->ical->recur->weekday;
- break;
-
- case RECUR_MONTHLY_BY_POS:
- page = 3;
- month_period = interval;
- def_pos = ee->ical->recur->u.month_pos;
- default_day = ee->ical->recur->weekday; /* you can't use u.month_pos and u.month_day-- it's a union... */
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- page = 3;
- month_period = interval;
- default_day = ee->ical->recur->u.month_day;
- break;
-
- case RECUR_YEARLY_BY_MONTH:
- page = 4;
- year_period = interval;
- break;
-
- case RECUR_YEARLY_BY_DAY:
- page = 4;
- year_period = interval;
- break;
- }
- } else
- page = 0;
-
- /* The recurrency selector */
-
- for (i = 0, group = NULL; recurrence_types [i].name; i++) {
- r = gtk_radio_button_new_with_label (group, _(recurrence_types [i].name));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (r));
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r), i == page);
- gtk_signal_connect (GTK_OBJECT (r), "toggled", GTK_SIGNAL_FUNC (recurrence_toggled), ee);
- gtk_box_pack_start (GTK_BOX (vbox), r, FALSE, FALSE, 0);
-
- if (i == 0)
- gtk_signal_connect (GTK_OBJECT (r), "toggled",
- (GtkSignalFunc) desensitize_on_toggle,
- ee->recur_hbox);
- }
-
- ee->recur_rr_group = group;
-
- /* 0. No recurrence */
- none = gtk_label_new ("");
-
- /* 1. The daily recurrence */
-
- daily = gtk_vbox_new (FALSE, 0);
-
- b = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (daily), b, FALSE, FALSE, 0);
-
- ee->recur_rr_day_period = make_spin_button (day_period, 1, 10000);
- /* in some languages "Every" can follow the gender of the word it
- refers to (here "day(s)"). leave the two leadin letter "d_"
- in the translation they are ther on purpose */
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("d_Every") +2), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), ee->recur_rr_day_period, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("day(s)")), FALSE, FALSE, 0);
-
- /* 2. The weekly recurrence */
-
- weekly = gtk_vbox_new (FALSE, 4);
-
- week_hbox = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (weekly), week_hbox, FALSE, FALSE, 0);
-
- /* 2.1 The week period selector */
-
- ee->recur_rr_week_period = make_spin_button (week_period, 1, 10000);
- /* in some languages "Every" can follow the gender of the word it
- refers to (here "week(s)"). leave the two leadin letter "w_"
- in the translation they are ther on purpose */
- gtk_box_pack_start (GTK_BOX (week_hbox), gtk_label_new (_("w_Every") +2), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (week_hbox), ee->recur_rr_week_period, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (week_hbox), gtk_label_new (_("week(s)")), FALSE, FALSE, 0);
-
- /* 2.2 The week day selector */
-
- week_day = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (weekly), week_day, FALSE, FALSE, 0);
-
- for (i = 0; i < 7; i++) {
- ee->recur_rr_week_days [i] = gtk_check_button_new_with_label (_(day_names [i]));
- gtk_box_pack_start (GTK_BOX (week_day), ee->recur_rr_week_days [i], FALSE, FALSE, 0);
-
- if (week_vector & (1 << ((i + 1) % 7))) /* on the spec, Sunday is 0 */
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->recur_rr_week_days [i]), TRUE);
- }
-
- /* 3. The monthly recurrence */
-
- monthly = gtk_table_new (0, 0, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (monthly), 4);
- gtk_table_set_col_spacings (GTK_TABLE (monthly), 4);
-
- re = gtk_radio_button_new_with_label (NULL, _("Recur on the"));
- ee->recur_rr_month_date = make_spin_button (default_day, 1, 31);
- ee->recur_rr_month_date_label = w = gtk_label_new (_("th day of the month"));
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (monthly), re,
- 0, 1, 0, 1, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_date,
- 1, 2, 0, 1, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), w,
- 2, 3, 0, 1, FS, FS, 0, 0);
- gtk_signal_connect (GTK_OBJECT (re), "toggled", GTK_SIGNAL_FUNC (recur_month_enable_date), ee);
-
- r1 = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (re)), _("Recur on the"));
- ee->recur_rr_month_day = make_numbered_menu (weekday_positions, def_pos);
- ee->recur_rr_month_weekday = make_numbered_menu (weekday_names, default_day);
- gtk_table_attach (GTK_TABLE (monthly), r1,
- 0, 1, 1, 2, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_day,
- 1, 2, 1, 2, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_weekday,
- 2, 3, 1, 2, FS, FS, 0, 0);
-
- /* in some languages "Every" can follow the gender of the word it
- refers to (here "month(s)"). leave the two leadin letter "m_"
- in the translation they are ther on purpose */
- gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("m_Every") +2),
- 3, 4, 0, 2, FS, FS, 0, 0);
- ee->recur_rr_month_period = make_spin_button (month_period, 1, 10000);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_period,
- 4, 5, 0, 2, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("month(s)")),
- 5, 6, 0, 2, FS, FS, 0, 0);
-
- if (ee->ical->recur) {
- if (ee->ical->recur->type == RECUR_MONTHLY_BY_POS)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r1), 1);
- } else
- recur_month_enable_date (GTK_TOGGLE_BUTTON (re), ee);
-
- /* 4. The yearly recurrence */
-
- yearly = gtk_vbox_new (FALSE, 0);
-
- b = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (yearly), b, FALSE, FALSE, 0);
-
- ee->recur_rr_year_period = make_spin_button (year_period, 1, 10000);
- /* in some languages "Every" can follow the gender of the word it
- refers to (here "year(s)"). leave the two leadin letter "y_"
- in the translation they are ther on purpose */
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("y_Every") +2), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), ee->recur_rr_year_period, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("year(s)")), FALSE, FALSE, 0);
-
- /* Finish setting this up */
-
- gtk_notebook_append_page (notebook, none, gtk_label_new (""));
- gtk_notebook_append_page (notebook, daily, gtk_label_new (""));
- gtk_notebook_append_page (notebook, weekly, gtk_label_new (""));
- gtk_notebook_append_page (notebook, monthly, gtk_label_new (""));
- gtk_notebook_append_page (notebook, yearly, gtk_label_new (""));
- gtk_notebook_set_show_tabs (notebook, FALSE);
- gtk_notebook_set_show_border (notebook, FALSE);
-
- gtk_notebook_set_page (notebook, page);
-
- /* Attach to the main box */
-
- gtk_box_pack_start (GTK_BOX (ee->recur_vbox), f, FALSE, FALSE, 0);
-}
-
-static void
-sensitize_on_toggle (GtkToggleButton *toggle, gpointer data)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (data), toggle->active);
-}
-
-static void
-ee_rp_init_ending_date (EventEditor *ee)
-{
- GtkWidget *frame;
- GtkWidget *vbox;
- GSList *group;
- GtkWidget *radio0, *radio1, *radio2;
- GtkWidget *hbox;
- GtkWidget *ihbox;
- GtkWidget *widget;
- time_t enddate;
- int repeat;
-
- frame = gtk_frame_new (_("Ending date"));
-
- vbox = gtk_vbox_new (TRUE, 4);
- gtk_container_border_width (GTK_CONTAINER (vbox), 4);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
-
- group = NULL;
-
- /* repeat forever */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- radio0 = gtk_radio_button_new_with_label (group, _("Repeat forever"));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio0));
- gtk_box_pack_start (GTK_BOX (hbox), radio0, FALSE, FALSE, 0);
-
- /* end on date */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- radio1 = gtk_radio_button_new_with_label (group, _("End on"));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio1));
- gtk_box_pack_start (GTK_BOX (hbox), radio1, FALSE, FALSE, 0);
-
- ihbox = gtk_hbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ihbox, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), ihbox, FALSE, FALSE, 0);
-
- if (ee->ical->recur) {
- /* Shorten by one day, as we store end-on date a day ahead */
- enddate = ee->ical->recur->enddate - 86400;
- } else
- enddate = ee->ical->dtend;
-
- ee->recur_ed_end_on = widget = date_edit_new (enddate, FALSE);
- gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
-
- gtk_signal_connect (GTK_OBJECT (radio1), "toggled",
- (GtkSignalFunc) sensitize_on_toggle,
- ihbox);
-
- /* end after n occurrences */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- radio2 = gtk_radio_button_new_with_label (group, _("End after"));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio2));
- gtk_box_pack_start (GTK_BOX (hbox), radio2, FALSE, FALSE, 0);
-
- ihbox = gtk_hbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ihbox, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), ihbox, FALSE, FALSE, 0);
-
- if (ee->ical->recur && ee->ical->recur->duration)
- repeat = ee->ical->recur->duration;
- else
- repeat = 2;
-
- ee->recur_ed_end_after = widget = make_spin_button (repeat, 1, 10000);
- gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
-
- widget = gtk_label_new (_("occurrence(s)"));
- gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
-
- gtk_signal_connect (GTK_OBJECT (radio2), "toggled",
- (GtkSignalFunc) sensitize_on_toggle,
- ihbox);
-
- /* Activate appropriate item */
-
- if (ee->ical->recur) {
- if (ee->ical->recur->_enddate == 0) {
- if (ee->ical->recur->duration == 0)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (radio0), TRUE);
- else {
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (ee->recur_ed_end_after),
- ee->ical->recur->duration);
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (radio2), TRUE);
- }
- } else {
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->recur_ed_end_on), ee->ical->recur->enddate);
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (radio1), TRUE);
- }
- }
-
- /* Done, add to main table */
-
- ee->recur_ed_group = group;
-
- gtk_box_pack_start (GTK_BOX (ee->recur_hbox), frame, FALSE, FALSE, 0);
-}
-
-static char *
-get_exception_string (time_t t)
-{
- static char buf[256];
-
- strftime (buf, sizeof(buf), _("%a %b %d %Y"), localtime (&t));
- return buf;
-}
-
-static void
-append_exception (EventEditor *ee, time_t t)
-{
- time_t *tt;
- char *c[1];
- int i;
-
- c[0] = get_exception_string (t);
-
- tt = g_new (time_t, 1);
- *tt = t;
-
- i = gtk_clist_append (GTK_CLIST (ee->recur_ex_clist), c);
- gtk_clist_set_row_data (GTK_CLIST (ee->recur_ex_clist), i, tt);
- gtk_clist_select_row (GTK_CLIST (ee->recur_ex_clist), i, 0);
-
- gtk_widget_set_sensitive (ee->recur_ex_vbox, TRUE);
-}
-
-static void
-fill_exception_clist (EventEditor *ee)
-{
- GList *list;
-
- for (list = ee->ical->exdate; list; list = list->next)
- append_exception (ee, *((time_t *) list->data));
-}
-
-static void
-add_exception (GtkWidget *widget, EventEditor *ee)
-{
- time_t t;
-
- t = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->recur_ex_date));
- append_exception (ee, t);
-}
-
-static void
-change_exception (GtkWidget *widget, EventEditor *ee)
-{
- GtkCList *clist;
- time_t *t;
- int sel;
-
- clist = GTK_CLIST (ee->recur_ex_clist);
- sel = GPOINTER_TO_INT(clist->selection->data);
-
- t = gtk_clist_get_row_data (clist, sel);
- *t = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->recur_ex_date));
-
- gtk_clist_set_text (clist, sel, 0, get_exception_string (*t));
-}
-
-static void
-delete_exception (GtkWidget *widget, EventEditor *ee)
-{
- GtkCList *clist;
- int sel, length;
-
- clist = GTK_CLIST (ee->recur_ex_clist);
- sel = GPOINTER_TO_INT(clist->selection->data);
-
- g_free (gtk_clist_get_row_data (clist, sel)); /* free the time_t stored there */
-
- gtk_clist_remove (clist, sel);
- length = g_list_length(clist->row_list);
- if (sel >= length)
- sel--;
- gtk_clist_select_row (GTK_CLIST (ee->recur_ex_clist), sel, 0);
-
- if (clist->rows == 0)
- gtk_widget_set_sensitive (ee->recur_ex_vbox, FALSE);
-}
-
-static void
-ee_rp_init_exceptions (EventEditor *ee)
-{
- GtkWidget *frame;
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *ivbox;
- GtkWidget *widget;
- GtkWidget *sw;
-
- frame = gtk_frame_new (_("Exceptions"));
-
- hbox = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_container_add (GTK_CONTAINER (frame), hbox);
-
- vbox = gtk_vbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
-
- ee->recur_ex_date = widget = date_edit_new (time (NULL), FALSE);
- gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
-
- widget = gtk_button_new_with_label (_("Add exception"));
- gtk_signal_connect (GTK_OBJECT (widget), "clicked",
- (GtkSignalFunc) add_exception,
- ee);
- gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
-
- ee->recur_ex_vbox = ivbox = gtk_vbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ivbox, FALSE); /* at first there are no items to change or delete */
- gtk_box_pack_start (GTK_BOX (vbox), ivbox, FALSE, FALSE, 0);
-
- widget = gtk_button_new_with_label (_("Change selected"));
- gtk_signal_connect (GTK_OBJECT (widget), "clicked",
- (GtkSignalFunc) change_exception,
- ee);
- gtk_box_pack_start (GTK_BOX (ivbox), widget, FALSE, FALSE, 0);
-
- widget = gtk_button_new_with_label (_("Delete selected"));
- gtk_signal_connect (GTK_OBJECT (widget), "clicked",
- (GtkSignalFunc) delete_exception,
- ee);
- gtk_box_pack_start (GTK_BOX (ivbox), widget, FALSE, FALSE, 0);
-
- ee->recur_ex_clist = widget = gtk_clist_new (1);
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (sw), widget);
- gtk_clist_set_selection_mode (GTK_CLIST (widget), GTK_SELECTION_BROWSE);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- fill_exception_clist (ee);
- gtk_box_pack_start (GTK_BOX (hbox), sw, TRUE, TRUE, 0);
-
- /* Done, add to main table */
-
- gtk_box_pack_start (GTK_BOX (ee->recur_hbox), frame, TRUE, TRUE, 0);
-}
-
-static void
-ee_init_recurrence_page (EventEditor *ee)
-{
- ee->recur_vbox = gtk_vbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (ee->recur_vbox), 4);
-
- ee->recur_hbox = gtk_hbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ee->recur_hbox, FALSE);
-
- ee->recur_page_label = gtk_label_new (_("Recurrence"));
-
- gtk_notebook_append_page (GTK_NOTEBOOK (ee->notebook), ee->recur_vbox,
- ee->recur_page_label);
-
- ee_rp_init_rule (ee);
-
- /* pack here so that the box gets inserted after the recurrence rule frame */
- gtk_box_pack_start (GTK_BOX (ee->recur_vbox), ee->recur_hbox, FALSE, FALSE, 0);
-
- ee_rp_init_ending_date (ee);
- ee_rp_init_exceptions (ee);
-}
-
-static void
-event_editor_init_widgets (EventEditor *ee)
-{
- ee->notebook = gtk_notebook_new ();
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG(ee)->vbox), ee->notebook, 1, 1, 0);
-
- /* Init the various configuration pages */
- ee_init_general_page (ee);
- ee_init_summary_page (ee);
- ee_init_recurrence_page (ee);
-
- /* Buttons */
- ee_create_buttons(ee);
-
- /* We show all of the contained widgets */
- gtk_widget_show_all (GTK_BIN (ee)->child);
-}
-
-static void
-event_editor_init (EventEditor *ee)
-{
- ee->ical = 0;
- gnome_dialog_set_close (GNOME_DIALOG(ee), TRUE);
-}
-
-static void
-event_editor_destroy (GtkObject *object)
-{
- EventEditor *ee;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_EVENT_EDITOR (object));
-
- ee = EVENT_EDITOR (object);
-
- if (ee->ical)
- ee->ical->user_data = NULL; /* we are no longer editing it */
-}
-
-GtkWidget *
-event_editor_new (GnomeCalendar *gcal, iCalObject *ical)
-{
- GtkWidget *retval;
- EventEditor *ee;
-
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gdk_flush ();
-
- retval = gtk_type_new (event_editor_get_type ());
- ee = EVENT_EDITOR (retval);
-
- if (ical == 0){
- ical = ical_new ("", user_name, "");
- ical->new = 1;
- }
-
- if (ical->new){
- gtk_window_set_title (GTK_WINDOW (ee), _("Create new appointment"));
- } else {
- gtk_window_set_title (GTK_WINDOW (ee), _("Edit appointment"));
- }
-
- ical->user_data = ee; /* so that the world can know we are editing it */
-
- ee->ical = ical;
- ee->gnome_cal = gcal;
- event_editor_init_widgets (ee);
-
- return retval;
-}
-
-void
-event_editor_new_whole_day (GnomeCalendar *owner, time_t day)
-{
- struct tm tm;
- iCalObject *ico;
- GtkWidget *ee;
-
- g_return_if_fail (owner != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (owner));
-
- ico = ical_new ("", user_name, "");
- ico->new = TRUE;
-
- tm = *localtime (&day);
-
- /* Set the start time of the event to the beginning of the day */
-
- tm.tm_hour = day_begin;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- ico->dtstart = mktime (&tm);
-
- /* Set the end time of the event to the end of the day */
-
- tm.tm_hour = day_end;
- ico->dtend = mktime (&tm);
-
- /* Launch the event editor */
-
- ee = event_editor_new (owner, ico);
- gtk_widget_show (ee);
-}
diff --git a/calendar/eventedit.h b/calendar/eventedit.h
deleted file mode 100644
index 4d605892dd..0000000000
--- a/calendar/eventedit.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * EventEditor widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-
-#ifndef EVENT_EDITOR_H
-#define EVENT_EDITOR_H
-
-#include "gnome-cal.h"
-#include <libgnomeui/gnome-dialog.h>
-
-BEGIN_GNOME_DECLS
-
-
-#define EVENT_EDITOR(obj) GTK_CHECK_CAST(obj, event_editor_get_type(), EventEditor)
-#define EVENT_EDITOR_CLASS(class) GTK_CHECK_CAST_CLASS(class, event_editor_get_type(), EventEditorClass)
-#define IS_EVENT_EDITOR(obj) GTK_CHECK_TYPE(obj, event_editor_get_type())
-
-
-typedef struct {
- GnomeDialog dialog;
- GtkWidget *notebook;
-
- GtkWidget *general;
- GtkWidget *general_table;
- GtkWidget *general_time_table;
- GtkWidget *general_allday;
- GtkWidget *general_owner;
- GtkWidget *general_summary;
- GtkWidget *start_time, *end_time;
- GtkWidget *general_radios;
-
- GtkWidget *recur_page_label;
- GtkWidget *recur_vbox;
- GtkWidget *recur_hbox;
-
- GSList *recur_rr_group;
- GtkWidget *recur_rr_notebook;
- GtkWidget *recur_rr_day_period;
- GtkWidget *recur_rr_week_period;
- GtkWidget *recur_rr_week_days [7];
- GtkWidget *recur_rr_month_date;
- GtkWidget *recur_rr_month_date_label;
- GtkWidget *recur_rr_month_day;
- GtkWidget *recur_rr_month_weekday;
- GtkWidget *recur_rr_month_period;
- GtkWidget *recur_rr_year_period;
-
- GSList *recur_ed_group;
- GtkWidget *recur_ed_end_on;
- GtkWidget *recur_ed_end_after;
-
- GtkWidget *recur_ex_date;
- GtkWidget *recur_ex_vbox;
- GtkWidget *recur_ex_clist;
-
- /* The associated ical object */
- iCalObject *ical;
-
- /* The calendar owner of this event */
- GnomeCalendar *gnome_cal;
-} EventEditor;
-
-typedef struct {
- GnomeDialogClass parent_class;
-} EventEditorClass;
-
-
-guint event_editor_get_type (void);
-GtkWidget *event_editor_new (GnomeCalendar *owner, iCalObject *);
-
-/* Convenience function to create and show a new event editor for an event that goes from day_begin
- * to day_end of the specified day.
- */
-void event_editor_new_whole_day (GnomeCalendar *owner, time_t day);
-
-GtkWidget *date_edit_new (time_t the_time, int show_time);
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/evolution-calendar.idl b/calendar/evolution-calendar.idl
deleted file mode 100644
index 6746eb66a1..0000000000
--- a/calendar/evolution-calendar.idl
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Evolution calendar interface
- *
- * Copyright (C) 2000 Eskil Heyn Olsen
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Authors: Eskil Heyn Olsen <deity@eskil.dk>
- * Federico Mena-Quintero <federico@helixcode.com>
- */
-
-#ifndef _EVOLUTION_CALENDAR_IDL_
-#define _EVOLUTION_CALENDAR_IDL_
-
-#include <Bonobo.idl>
-
-module Evolution {
-
-module Calendar {
- /* A calendar object (event/todo/journal/etc), represented as an
- * iCalendar string.
- */
- typedef string CalObj;
-
- /* An unique identifier for a calendar object */
- typedef string CalObjUID;
-
- interface Listener;
-
- /* Calendar client interface */
- interface Cal : Bonobo::Unknown {
- exception NotFound {};
-
- /* A calendar is identified by its URI */
- readonly attribute string uri;
-
- /* Gets an object based on its URI */
- CalObj get_object (in CalObjUID uid)
- raises (NotFound);
- };
-
- /* Listener for changes in a calendar */
- interface Listener : Bonobo::Unknown {
- /* Return status when loading a calendar; we need better error reporting */
- enum LoadStatus {
- SUCCESS,
- ERROR
- };
-
- /* Called from a CalFactory when a calendar is initially loaded
- * or created. The listener must remember the cal object.
- */
- void cal_loaded (in LoadStatus status, in Cal cal);
-
- /* Called from a Calendar when an object is added */
- void obj_added (in CalObjUID uid);
-
- /* Called from a Calendar when an object is removed */
- void obj_removed (in CalObjUID uid);
-
- /* Called from a Calendar when an object is changed */
- void obj_changed (in CalObjUID uid);
- };
-
- /* A calendar factory, can load and create calendars */
- interface CalFactory : Bonobo::Unknown {
- exception NilListener {};
-
- /* Load a calendar from an URI */
- void load (in string uri, in Listener listener)
- raises (NilListener);
-
- /* Create a new calendar at the specified URI */
- void create (in string uri, in Listener listener)
- raises (NilListener);
- };
-};
-
-};
-
-#endif
diff --git a/calendar/getdate.y b/calendar/getdate.y
deleted file mode 100644
index 6df71bddda..0000000000
--- a/calendar/getdate.y
+++ /dev/null
@@ -1,1001 +0,0 @@
-%{
-/*
-** Originally) written by Steven M. Bellovin <smb@research.att.com> while
-** at the University of North Carolina at Chapel Hill. Later tweaked by
-** a couple of people on Usenet. Completely overhauled by Rich $alz
-** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
-** send any email to Rich.
-**
-** This grammar has 10 shift/reduce conflicts.
-**
-** This code is in the public domain and has no copyright.
-*/
-/* SUPPRESS 287 on yaccpar_sccsid *//* Unused static variable */
-/* SUPPRESS 288 on yyerrlab *//* Label unused */
-
-#include <config.h>
-#include <gnome.h>
-
-/* Since the code of getdate.y is not included in the Emacs executable
- itself, there is no need to #define static in this file. Even if
- the code were included in the Emacs executable, it probably
- wouldn't do any harm to #undef it here; this will only cause
- problems if we try to write to a static variable, which I don't
- think this code needs to do. */
-#ifdef emacs
-#undef static
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-
-/* The code at the top of get_date which figures out the offset of the
- current time zone checks various CPP symbols to see if special
- tricks are need, but defaults to using the gettimeofday system call.
- Include <sys/time.h> if that will be used. */
-
-#if defined(vms)
-
-#include <types.h>
-#include <time.h>
-
-#else
-
-#include <sys/types.h>
-
-#ifdef TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#else
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#endif
-
-#ifdef timezone
-#undef timezone /* needed for sgi */
-#endif
-
-#if defined(HAVE_SYS_TIMEB_H)
-#include <sys/timeb.h>
-#else
-/*
-** We use the obsolete `struct timeb' as part of our interface!
-** Since the system doesn't have it, we define it here;
-** our callers must do likewise.
-*/
-struct timeb {
- time_t time; /* Seconds since the epoch */
- unsigned short millitm; /* Field not used */
- short timezone; /* Minutes west of GMT */
- short dstflag; /* Field not used */
-};
-#endif /* defined(HAVE_SYS_TIMEB_H) */
-
-#endif /* defined(vms) */
-
-#if defined (STDC_HEADERS) || defined (USG)
-#include <string.h>
-#endif
-
-/* Some old versions of bison generate parsers that use bcopy.
- That loses on systems that don't provide the function, so we have
- to redefine it here. */
-#if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy)
-#define bcopy(from, to, len) memcpy ((to), (from), (len))
-#endif
-
-#if defined (STDC_HEADERS)
-#include <stdlib.h>
-#endif
-
-/* NOTES on rebuilding getdate.c (particularly for inclusion in CVS
- releases):
-
- We don't want to mess with all the portability hassles of alloca.
- In particular, most (all?) versions of bison will use alloca in
- their parser. If bison works on your system (e.g. it should work
- with gcc), then go ahead and use it, but the more general solution
- is to use byacc instead of bison, which should generate a portable
- parser. I played with adding "#define alloca dont_use_alloca", to
- give an error if the parser generator uses alloca (and thus detect
- unportable getdate.c's), but that seems to cause as many problems
- as it solves. */
-
-extern struct tm *gmtime();
-extern struct tm *localtime();
-
-#define yyparse getdate_yyparse
-#define yylex getdate_yylex
-#define yyerror getdate_yyerror
-
-static int yylex ();
-static int yyerror ();
-
-#define EPOCH 1970
-#define HOUR(x) ((time_t)(x) * 60)
-#define SECSPERDAY (24L * 60L * 60L)
-
-
-/*
-** An entry in the lexical lookup table.
-*/
-typedef struct _TABLE {
- char *name;
- int type;
- time_t value;
-} TABLE;
-
-
-/*
-** Daylight-savings mode: on, off, or not yet known.
-*/
-typedef enum _DSTMODE {
- DSTon, DSToff, DSTmaybe
-} DSTMODE;
-
-/*
-** Meridian: am, pm, or 24-hour style.
-*/
-typedef enum _MERIDIAN {
- MERam, MERpm, MER24
-} MERIDIAN;
-
-
-/*
-** Global variables. We could get rid of most of these by using a good
-** union as the yacc stack. (This routine was originally written before
-** yacc had the %union construct.) Maybe someday; right now we only use
-** the %union very rarely.
-*/
-static char *yyInput;
-static DSTMODE yyDSTmode;
-static time_t yyDayOrdinal;
-static time_t yyDayNumber;
-static int yyHaveDate;
-static int yyHaveDay;
-static int yyHaveRel;
-static int yyHaveTime;
-static int yyHaveZone;
-static time_t yyTimezone;
-static time_t yyDay;
-static time_t yyHour;
-static time_t yyMinutes;
-static time_t yyMonth;
-static time_t yySeconds;
-static time_t yyYear;
-static MERIDIAN yyMeridian;
-static time_t yyRelMonth;
-static time_t yyRelSeconds;
-
-%}
-
-%union {
- time_t Number;
- enum _MERIDIAN Meridian;
-}
-
-%token tAGO tDAY tDAYZONE tID tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT
-%token tSEC_UNIT tSNUMBER tUNUMBER tZONE tDST
-
-%type <Number> tDAY tDAYZONE tMINUTE_UNIT tMONTH tMONTH_UNIT
-%type <Number> tSEC_UNIT tSNUMBER tUNUMBER tZONE
-%type <Meridian> tMERIDIAN o_merid
-
-%%
-
-spec : /* NULL */
- | spec item
- ;
-
-item : time {
- yyHaveTime++;
- }
- | zone {
- yyHaveZone++;
- }
- | date {
- yyHaveDate++;
- }
- | day {
- yyHaveDay++;
- }
- | rel {
- yyHaveRel++;
- }
- | number
- ;
-
-time : tUNUMBER tMERIDIAN {
- yyHour = $1;
- yyMinutes = 0;
- yySeconds = 0;
- yyMeridian = $2;
- }
- | tUNUMBER ':' tUNUMBER o_merid {
- yyHour = $1;
- yyMinutes = $3;
- yySeconds = 0;
- yyMeridian = $4;
- }
- | tUNUMBER ':' tUNUMBER tSNUMBER {
- yyHour = $1;
- yyMinutes = $3;
- yyMeridian = MER24;
- yyDSTmode = DSToff;
- yyTimezone = - ($4 % 100 + ($4 / 100) * 60);
- }
- | tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid {
- yyHour = $1;
- yyMinutes = $3;
- yySeconds = $5;
- yyMeridian = $6;
- }
- | tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER {
- yyHour = $1;
- yyMinutes = $3;
- yySeconds = $5;
- yyMeridian = MER24;
- yyDSTmode = DSToff;
- yyTimezone = - ($6 % 100 + ($6 / 100) * 60);
- }
- ;
-
-zone : tZONE {
- yyTimezone = $1;
- yyDSTmode = DSToff;
- }
- | tDAYZONE {
- yyTimezone = $1;
- yyDSTmode = DSTon;
- }
- |
- tZONE tDST {
- yyTimezone = $1;
- yyDSTmode = DSTon;
- }
- ;
-
-day : tDAY {
- yyDayOrdinal = 1;
- yyDayNumber = $1;
- }
- | tDAY ',' {
- yyDayOrdinal = 1;
- yyDayNumber = $1;
- }
- | tUNUMBER tDAY {
- yyDayOrdinal = $1;
- yyDayNumber = $2;
- }
- ;
-
-date : tUNUMBER '/' tUNUMBER {
- yyMonth = $1;
- yyDay = $3;
- }
- | tUNUMBER '/' tUNUMBER '/' tUNUMBER {
- yyMonth = $1;
- yyDay = $3;
- yyYear = $5;
- }
- | tUNUMBER tSNUMBER tSNUMBER {
- /* ISO 8601 format. yyyy-mm-dd. */
- yyYear = $1;
- yyMonth = -$2;
- yyDay = -$3;
- }
- | tUNUMBER tMONTH tSNUMBER {
- /* e.g. 17-JUN-1992. */
- yyDay = $1;
- yyMonth = $2;
- yyYear = -$3;
- }
- | tMONTH tUNUMBER {
- yyMonth = $1;
- yyDay = $2;
- }
- | tMONTH tUNUMBER ',' tUNUMBER {
- yyMonth = $1;
- yyDay = $2;
- yyYear = $4;
- }
- | tUNUMBER tMONTH {
- yyMonth = $2;
- yyDay = $1;
- }
- | tUNUMBER tMONTH tUNUMBER {
- yyMonth = $2;
- yyDay = $1;
- yyYear = $3;
- }
- ;
-
-rel : relunit tAGO {
- yyRelSeconds = -yyRelSeconds;
- yyRelMonth = -yyRelMonth;
- }
- | relunit
- ;
-
-relunit : tUNUMBER tMINUTE_UNIT {
- yyRelSeconds += $1 * $2 * 60L;
- }
- | tSNUMBER tMINUTE_UNIT {
- yyRelSeconds += $1 * $2 * 60L;
- }
- | tMINUTE_UNIT {
- yyRelSeconds += $1 * 60L;
- }
- | tSNUMBER tSEC_UNIT {
- yyRelSeconds += $1;
- }
- | tUNUMBER tSEC_UNIT {
- yyRelSeconds += $1;
- }
- | tSEC_UNIT {
- yyRelSeconds++;
- }
- | tSNUMBER tMONTH_UNIT {
- yyRelMonth += $1 * $2;
- }
- | tUNUMBER tMONTH_UNIT {
- yyRelMonth += $1 * $2;
- }
- | tMONTH_UNIT {
- yyRelMonth += $1;
- }
- ;
-
-number : tUNUMBER {
- if (yyHaveTime && yyHaveDate && !yyHaveRel)
- yyYear = $1;
- else {
- if($1>10000) {
- yyHaveDate++;
- yyDay= ($1)%100;
- yyMonth= ($1/100)%100;
- yyYear = $1/10000;
- }
- else {
- yyHaveTime++;
- if ($1 < 100) {
- yyHour = $1;
- yyMinutes = 0;
- }
- else {
- yyHour = $1 / 100;
- yyMinutes = $1 % 100;
- }
- yySeconds = 0;
- yyMeridian = MER24;
- }
- }
- }
- ;
-
-o_merid : /* NULL */ {
- $$ = MER24;
- }
- | tMERIDIAN {
- $$ = $1;
- }
- ;
-
-%%
-
-/* Month and day table. */
-static TABLE const MonthDayTable[] = {
- { N_("january"), tMONTH, 1 },
- { N_("february"), tMONTH, 2 },
- { N_("march"), tMONTH, 3 },
- { N_("april"), tMONTH, 4 },
- { N_("may"), tMONTH, 5 },
- { N_("june"), tMONTH, 6 },
- { N_("july"), tMONTH, 7 },
- { N_("august"), tMONTH, 8 },
- { N_("september"), tMONTH, 9 },
- { N_("sept"), tMONTH, 9 },
- { N_("october"), tMONTH, 10 },
- { N_("november"), tMONTH, 11 },
- { N_("december"), tMONTH, 12 },
- { N_("sunday"), tDAY, 0 },
- { N_("monday"), tDAY, 1 },
- { N_("tuesday"), tDAY, 2 },
- { N_("tues"), tDAY, 2 },
- { N_("wednesday"), tDAY, 3 },
- { N_("wednes"), tDAY, 3 },
- { N_("thursday"), tDAY, 4 },
- { N_("thur"), tDAY, 4 },
- { N_("thurs"), tDAY, 4 },
- { N_("friday"), tDAY, 5 },
- { N_("saturday"), tDAY, 6 },
- { NULL }
-};
-
-/* Time units table. */
-static TABLE const UnitsTable[] = {
- { N_("year"), tMONTH_UNIT, 12 },
- { N_("month"), tMONTH_UNIT, 1 },
- { N_("fortnight"), tMINUTE_UNIT, 14 * 24 * 60 },
- { N_("week"), tMINUTE_UNIT, 7 * 24 * 60 },
- { N_("day"), tMINUTE_UNIT, 1 * 24 * 60 },
- { N_("hour"), tMINUTE_UNIT, 60 },
- { N_("minute"), tMINUTE_UNIT, 1 },
- { N_("min"), tMINUTE_UNIT, 1 },
- { N_("second"), tSEC_UNIT, 1 },
- { N_("sec"), tSEC_UNIT, 1 },
- { NULL }
-};
-
-/* Assorted relative-time words. */
-static TABLE const OtherTable[] = {
- { N_("tomorrow"), tMINUTE_UNIT, 1 * 24 * 60 },
- { N_("yesterday"), tMINUTE_UNIT, -1 * 24 * 60 },
- { N_("today"), tMINUTE_UNIT, 0 },
- { N_("now"), tMINUTE_UNIT, 0 },
- { N_("last"), tUNUMBER, -1 },
- { N_("this"), tMINUTE_UNIT, 0 },
- { N_("next"), tUNUMBER, 2 },
- { N_("first"), tUNUMBER, 1 },
-/* { N_("second"), tUNUMBER, 2 }, */
- { N_("third"), tUNUMBER, 3 },
- { N_("fourth"), tUNUMBER, 4 },
- { N_("fifth"), tUNUMBER, 5 },
- { N_("sixth"), tUNUMBER, 6 },
- { N_("seventh"), tUNUMBER, 7 },
- { N_("eighth"), tUNUMBER, 8 },
- { N_("ninth"), tUNUMBER, 9 },
- { N_("tenth"), tUNUMBER, 10 },
- { N_("eleventh"), tUNUMBER, 11 },
- { N_("twelfth"), tUNUMBER, 12 },
- { N_("ago"), tAGO, 1 },
- { NULL }
-};
-
-/* The timezone table. */
-/* Some of these are commented out because a time_t can't store a float. */
-static TABLE const TimezoneTable[] = {
- { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
- { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */
- { "utc", tZONE, HOUR( 0) },
- { "wet", tZONE, HOUR( 0) }, /* Western European */
- { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
- { "wat", tZONE, HOUR( 1) }, /* West Africa */
- { "at", tZONE, HOUR( 2) }, /* Azores */
-#if 0
- /* For completeness. BST is also British Summer, and GST is
- * also Guam Standard. */
- { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
- { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
-#endif
-#if 0
- { "nft", tZONE, HOUR(3.5) }, /* Newfoundland */
- { "nst", tZONE, HOUR(3.5) }, /* Newfoundland Standard */
- { "ndt", tDAYZONE, HOUR(3.5) }, /* Newfoundland Daylight */
-#endif
- { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
- { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
- { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
- { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
- { "cst", tZONE, HOUR( 6) }, /* Central Standard */
- { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
- { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
- { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
- { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
- { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
- { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
- { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
- { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
- { "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */
- { "cat", tZONE, HOUR(10) }, /* Central Alaska */
- { "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */
- { "nt", tZONE, HOUR(11) }, /* Nome */
- { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
- { "cet", tZONE, -HOUR(1) }, /* Central European */
- { "met", tZONE, -HOUR(1) }, /* Middle European */
- { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
- { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
- { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
- { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
- { "fwt", tZONE, -HOUR(1) }, /* French Winter */
- { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
- { "eet", tZONE, -HOUR(2) }, /* Eastern Europe, USSR Zone 1 */
- { "bt", tZONE, -HOUR(3) }, /* Baghdad, USSR Zone 2 */
-#if 0
- { "it", tZONE, -HOUR(3.5) },/* Iran */
-#endif
- { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
- { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
-#if 0
- { "ist", tZONE, -HOUR(5.5) },/* Indian Standard */
-#endif
- { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
-#if 0
- /* For completeness. NST is also Newfoundland Stanard, and SST is
- * also Swedish Summer. */
- { "nst", tZONE, -HOUR(6.5) },/* North Sumatra */
- { "sst", tZONE, -HOUR(7) }, /* South Sumatra, USSR Zone 6 */
-#endif /* 0 */
- { "wast", tZONE, -HOUR(7) }, /* West Australian Standard */
- { "wadt", tDAYZONE, -HOUR(7) }, /* West Australian Daylight */
-#if 0
- { "jt", tZONE, -HOUR(7.5) },/* Java (3pm in Cronusland!) */
-#endif
- { "cct", tZONE, -HOUR(8) }, /* China Coast, USSR Zone 7 */
- { "jst", tZONE, -HOUR(9) }, /* Japan Standard, USSR Zone 8 */
-#if 0
- { "cast", tZONE, -HOUR(9.5) },/* Central Australian Standard */
- { "cadt", tDAYZONE, -HOUR(9.5) },/* Central Australian Daylight */
-#endif
- { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
- { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
- { "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */
- { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
- { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
- { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
- { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
- { NULL }
-};
-
-/* Military timezone table. */
-static TABLE const MilitaryTable[] = {
- { "a", tZONE, HOUR( 1) },
- { "b", tZONE, HOUR( 2) },
- { "c", tZONE, HOUR( 3) },
- { "d", tZONE, HOUR( 4) },
- { "e", tZONE, HOUR( 5) },
- { "f", tZONE, HOUR( 6) },
- { "g", tZONE, HOUR( 7) },
- { "h", tZONE, HOUR( 8) },
- { "i", tZONE, HOUR( 9) },
- { "k", tZONE, HOUR( 10) },
- { "l", tZONE, HOUR( 11) },
- { "m", tZONE, HOUR( 12) },
- { "n", tZONE, HOUR(- 1) },
- { "o", tZONE, HOUR(- 2) },
- { "p", tZONE, HOUR(- 3) },
- { "q", tZONE, HOUR(- 4) },
- { "r", tZONE, HOUR(- 5) },
- { "s", tZONE, HOUR(- 6) },
- { "t", tZONE, HOUR(- 7) },
- { "u", tZONE, HOUR(- 8) },
- { "v", tZONE, HOUR(- 9) },
- { "w", tZONE, HOUR(-10) },
- { "x", tZONE, HOUR(-11) },
- { "y", tZONE, HOUR(-12) },
- { "z", tZONE, HOUR( 0) },
- { NULL }
-};
-
-
-
-
-/* ARGSUSED */
-static int
-yyerror(s)
- char *s;
-{
- return 0;
-}
-
-
-static time_t
-ToSeconds(Hours, Minutes, Seconds, Meridian)
- time_t Hours;
- time_t Minutes;
- time_t Seconds;
- MERIDIAN Meridian;
-{
- if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59)
- return -1;
- switch (Meridian) {
- case MER24:
- if (Hours < 0 || Hours > 23)
- return -1;
- return (Hours * 60L + Minutes) * 60L + Seconds;
- case MERam:
- if (Hours < 1 || Hours > 12)
- return -1;
- return (Hours * 60L + Minutes) * 60L + Seconds;
- case MERpm:
- if (Hours < 1 || Hours > 12)
- return -1;
- return ((Hours + 12) * 60L + Minutes) * 60L + Seconds;
- default:
- abort ();
- }
- /* NOTREACHED */
-}
-
-
-static time_t
-Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode)
- time_t Month;
- time_t Day;
- time_t Year;
- time_t Hours;
- time_t Minutes;
- time_t Seconds;
- MERIDIAN Meridian;
- DSTMODE DSTmode;
-{
- static int DaysInMonth[12] = {
- 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
- };
- time_t tod;
- time_t Julian;
- int i;
-
- if (Year < 0)
- Year = -Year;
- if (Year < 100)
- Year += 1900;
- DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0)
- ? 29 : 28;
- if (Year < EPOCH || Year > 1999
- || Month < 1 || Month > 12
- /* Lint fluff: "conversion from long may lose accuracy" */
- || Day < 1 || Day > DaysInMonth[(int)--Month])
- return -1;
-
- for (Julian = Day - 1, i = 0; i < Month; i++)
- Julian += DaysInMonth[i];
- for (i = EPOCH; i < Year; i++)
- Julian += 365 + (i % 4 == 0);
- Julian *= SECSPERDAY;
- Julian += yyTimezone * 60L;
- if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
- return -1;
- Julian += tod;
- if (DSTmode == DSTon
- || (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst))
- Julian -= 60 * 60;
- return Julian;
-}
-
-
-static time_t
-DSTcorrect(Start, Future)
- time_t Start;
- time_t Future;
-{
- time_t StartDay;
- time_t FutureDay;
-
- StartDay = (localtime(&Start)->tm_hour + 1) % 24;
- FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
- return (Future - Start) + (StartDay - FutureDay) * 60L * 60L;
-}
-
-
-static time_t
-RelativeDate(Start, DayOrdinal, DayNumber)
- time_t Start;
- time_t DayOrdinal;
- time_t DayNumber;
-{
- struct tm *tm;
- time_t now;
-
- now = Start;
- tm = localtime(&now);
- now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7);
- now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1);
- return DSTcorrect(Start, now);
-}
-
-
-static time_t
-RelativeMonth(Start, RelMonth)
- time_t Start;
- time_t RelMonth;
-{
- struct tm *tm;
- time_t Month;
- time_t Year;
-
- if (RelMonth == 0)
- return 0;
- tm = localtime(&Start);
- Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
- Year = Month / 12;
- Month = Month % 12 + 1;
- return DSTcorrect(Start,
- Convert(Month, (time_t)tm->tm_mday, Year,
- (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
- MER24, DSTmaybe));
-}
-
-
-static int
-LookupWord(buff)
- char *buff;
-{
- register char *p;
- register char *q;
- register const TABLE *tp;
- int i;
- int abbrev;
-
- /* Make it lowercase. */
- for (p = buff; *p; p++)
- if (isupper(*p))
- *p = tolower(*p);
-
- if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) {
- yylval.Meridian = MERam;
- return tMERIDIAN;
- }
- if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) {
- yylval.Meridian = MERpm;
- return tMERIDIAN;
- }
-
- /* See if we have an abbreviation for a month. */
- if (strlen(buff) == 3)
- abbrev = 1;
- else if (strlen(buff) == 4 && buff[3] == '.') {
- abbrev = 1;
- buff[3] = '\0';
- }
- else
- abbrev = 0;
-
- for (tp = MonthDayTable; tp->name; tp++) {
- if (abbrev) {
- if (strncmp(buff, tp->name, 3) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- }
- else if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- }
-
- for (tp = TimezoneTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- if (strcmp(buff, "dst") == 0)
- return tDST;
-
- for (tp = UnitsTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- /* Strip off any plural and try the units table again. */
- i = strlen(buff) - 1;
- if (buff[i] == 's') {
- buff[i] = '\0';
- for (tp = UnitsTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- buff[i] = 's'; /* Put back for "this" in OtherTable. */
- }
-
- for (tp = OtherTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- /* Military timezones. */
- if (buff[1] == '\0' && isalpha(*buff)) {
- for (tp = MilitaryTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- }
-
- /* Drop out any periods and try the timezone table again. */
- for (i = 0, p = q = buff; *q; q++)
- if (*q != '.')
- *p++ = *q;
- else
- i++;
- *p = '\0';
- if (i)
- for (tp = TimezoneTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- return tID;
-}
-
-
-static int
-yylex()
-{
- register char c;
- register char *p;
- char buff[20];
- int Count;
- int sign;
-
- for ( ; ; ) {
- while (isspace(*yyInput))
- yyInput++;
-
- if (isdigit(c = *yyInput) || c == '-' || c == '+') {
- if (c == '-' || c == '+') {
- sign = c == '-' ? -1 : 1;
- if (!isdigit(*++yyInput))
- /* skip the '-' sign */
- continue;
- }
- else
- sign = 0;
- for (yylval.Number = 0; isdigit(c = *yyInput++); )
- yylval.Number = 10 * yylval.Number + c - '0';
- yyInput--;
- if (sign < 0)
- yylval.Number = -yylval.Number;
- return sign ? tSNUMBER : tUNUMBER;
- }
- if (isalpha(c)) {
- for (p = buff; isalpha(c = *yyInput++) || c == '.'; )
- if (p < &buff[sizeof buff - 1])
- *p++ = c;
- *p = '\0';
- yyInput--;
- return LookupWord(buff);
- }
- if (c != '(')
- return *yyInput++;
- Count = 0;
- do {
- c = *yyInput++;
- if (c == '\0')
- return c;
- if (c == '(')
- Count++;
- else if (c == ')')
- Count--;
- } while (Count > 0);
- }
-}
-
-#define TM_YEAR_ORIGIN 1900
-
-/* Yield A - B, measured in seconds. */
-static long
-difftm (a, b)
- struct tm *a, *b;
-{
- int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
- int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
- int days = (
- /* difference in day of year */
- a->tm_yday - b->tm_yday
- /* + intervening leap days */
- + ((ay >> 2) - (by >> 2))
- - (ay/100 - by/100)
- + ((ay/100 >> 2) - (by/100 >> 2))
- /* + difference in years * 365 */
- + (long)(ay-by) * 365
- );
- return (60*(60*(24*days + (a->tm_hour - b->tm_hour))
- + (a->tm_min - b->tm_min))
- + (a->tm_sec - b->tm_sec));
-}
-
-time_t
-get_date(p, now)
- char *p;
- struct timeb *now;
-{
- struct tm *tm, gmt;
- struct timeb ftz;
- time_t Start;
- time_t tod;
- time_t nowtime;
-
- yyInput = p;
- if (now == NULL) {
- now = &ftz;
- (void)time (&nowtime);
-
- if (! (tm = gmtime (&nowtime)))
- return -1;
- gmt = *tm; /* Make a copy, in case localtime modifies *tm. */
-
- if (! (tm = localtime (&nowtime)))
- return -1;
-
- ftz.timezone = difftm (&gmt, tm) / 60;
- if(tm->tm_isdst)
- ftz.timezone += 60;
- }
- else
- {
- nowtime = now->time;
- }
-
- tm = localtime(&nowtime);
- yyYear = tm->tm_year;
- yyMonth = tm->tm_mon + 1;
- yyDay = tm->tm_mday;
- yyTimezone = now->timezone;
- yyDSTmode = DSTmaybe;
- yyHour = 0;
- yyMinutes = 0;
- yySeconds = 0;
- yyMeridian = MER24;
- yyRelSeconds = 0;
- yyRelMonth = 0;
- yyHaveDate = 0;
- yyHaveDay = 0;
- yyHaveRel = 0;
- yyHaveTime = 0;
- yyHaveZone = 0;
-
- if (yyparse()
- || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1)
- return -1;
-
- if (yyHaveDate || yyHaveTime || yyHaveDay) {
- Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
- yyMeridian, yyDSTmode);
- if (Start < 0)
- return -1;
- }
- else {
- Start = nowtime;
- if (!yyHaveRel)
- Start -= ((tm->tm_hour * 60L + tm->tm_min) * 60L) + tm->tm_sec;
- }
-
- Start += yyRelSeconds;
- Start += RelativeMonth(Start, yyRelMonth);
-
- if (yyHaveDay && !yyHaveDate) {
- tod = RelativeDate(Start, yyDayOrdinal, yyDayNumber);
- Start += tod;
- }
-
- /* Have to do *something* with a legitimate -1 so it's distinguishable
- * from the error return value. (Alternately could set errno on error.) */
- return Start == -1 ? 0 : Start;
-}
-
-
-#if defined(TEST)
-
-/* ARGSUSED */
-int
-main(ac, av)
- int ac;
- char *av[];
-{
- char buff[128];
- time_t d;
-
- (void)printf("Enter date, or blank line to exit.\n\t> ");
- (void)fflush(stdout);
- while (gets(buff) && buff[0]) {
- d = get_date(buff, (struct timeb *)NULL);
- if (d == -1)
- (void)printf("Bad format - couldn't convert.\n");
- else
- (void)printf("%s", ctime(&d));
- (void)printf("\t> ");
- (void)fflush(stdout);
- }
- exit(0);
- /* NOTREACHED */
-}
-#endif /* defined(TEST) */
diff --git a/calendar/gncal-day-panel.c b/calendar/gncal-day-panel.c
deleted file mode 100644
index f407a497d3..0000000000
--- a/calendar/gncal-day-panel.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/* Day view notebook panel for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#include <config.h>
-#include <gnome.h>
-#include <gtk/gtkhseparator.h>
-#include "gncal-day-panel.h"
-#include "main.h"
-#include "timeutil.h"
-
-
-guint
-gncal_day_panel_get_type (void)
-{
- static guint day_panel_type = 0;
-
- if (!day_panel_type) {
- GtkTypeInfo day_panel_info = {
- "GncalDayPanel",
- sizeof (GncalDayPanel),
- sizeof (GncalDayPanelClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) NULL,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- day_panel_type = gtk_type_unique (gtk_table_get_type (), &day_panel_info);
- }
-
- return day_panel_type;
-}
-
-static void
-day_view_range_activated (GncalFullDay *fullday, GncalDayPanel *dpanel)
-{
- iCalObject *ical;
-
- ical = ical_new ("", user_name, "");
- ical->new = 1;
-
- gncal_full_day_selection_range (fullday, &ical->dtstart, &ical->dtend);
-
- gnome_calendar_add_object (dpanel->calendar, ical);
- save_default_calendar (dpanel->calendar);
- gncal_full_day_focus_child (fullday, ical);
-}
-
-static void
-full_day_size_allocated (GtkWidget *widget, GtkAllocation *allocation, GncalDayPanel *dpanel)
-{
- GtkAdjustment *adj;
- int yoffset;
- gfloat newval;
-
- adj = gtk_scrolled_window_get_vadjustment (dpanel->fullday_sw);
-
- yoffset = gncal_full_day_get_day_start_yoffset (GNCAL_FULL_DAY (widget));
-
- newval = adj->lower + (adj->upper - adj->lower) * (double) yoffset / allocation->height;
- if (newval != adj->value)
- gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");
-}
-
-static void
-calendar_day_selected (GtkCalendar *calendar, GncalDayPanel *dpanel)
-{
- gint y, m, d;
- struct tm tm;
-
- gtk_calendar_get_date (calendar, &y, &m, &d);
-
- tm.tm_year = y - 1900;
- tm.tm_mon = m;
- tm.tm_mday = d;
- tm.tm_hour = 5; /* for daylight savings time fix */
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- gnome_calendar_goto (dpanel->calendar, mktime (&tm));
-}
-
-static void
-retag_calendar (GtkCalendar *calendar, GncalDayPanel *dpanel)
-{
- gnome_calendar_tag_calendar (dpanel->calendar, GTK_CALENDAR (dpanel->gtk_calendar));
-}
-
-GtkWidget *
-gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day)
-{
- GncalDayPanel *dpanel;
- GtkWidget *w;
- GtkWidget *hpane, *vpane;
- gint start_pos = 265;
- struct tm tm;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- dpanel = gtk_type_new (gncal_day_panel_get_type ());
-
- gtk_container_border_width (GTK_CONTAINER (dpanel), 4);
- gtk_table_set_row_spacings (GTK_TABLE (dpanel), 4);
- gtk_table_set_col_spacings (GTK_TABLE (dpanel), 4);
-
- dpanel->calendar = calendar;
-
- /* Date label */
-
- w = gtk_label_new ("");
- dpanel->date_label = GTK_LABEL (w);
- gtk_table_attach (GTK_TABLE (dpanel), w,
- 0, 1, 0, 1,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_widget_show (w);
-
- /* Create horizontal pane */
-
- hpane = gtk_hpaned_new ();
- gtk_table_attach (GTK_TABLE (dpanel), hpane,
- 0, 1, 2, 4,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- /* Full day */
-
- w = gtk_scrolled_window_new (NULL, NULL);
- dpanel->fullday_sw = GTK_SCROLLED_WINDOW (w);
- gtk_scrolled_window_set_policy (dpanel->fullday_sw,
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_paned_pack1 (GTK_PANED (hpane), w, FALSE, TRUE);
- /*gtk_paned_add1 (GTK_PANED (hpane), w);*/
- gtk_widget_show (w);
-
- w = gncal_full_day_new (calendar, time_day_begin (start_of_day), time_day_end (start_of_day));
- dpanel->fullday = GNCAL_FULL_DAY (w);
- gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "range_activated",
- (GtkSignalFunc) day_view_range_activated,
- dpanel);
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (dpanel->fullday_sw), w);
- gtk_widget_show (w);
-
- /* We'll scroll the list to the proper initial position */
-
- gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "size_allocate",
- (GtkSignalFunc) full_day_size_allocated,
- dpanel);
-
- /* Create vertical pane */
-
- vpane = gtk_vpaned_new ();
- gtk_paned_pack2 (GTK_PANED (hpane), GTK_WIDGET (vpane), TRUE, TRUE);
- /*gtk_paned_add2 (GTK_PANED (hpane), GTK_WIDGET (vpane));*/
-
- /* Gtk calendar */
-
- tm = *localtime (&start_of_day);
-
- w = gtk_calendar_new ();
- dpanel->gtk_calendar = GTK_CALENDAR (w);
- gtk_calendar_display_options (dpanel->gtk_calendar,
- (GTK_CALENDAR_SHOW_HEADING
- | GTK_CALENDAR_SHOW_DAY_NAMES
- | (week_starts_on_monday
- ? GTK_CALENDAR_WEEK_START_MONDAY : 0)));
- gtk_calendar_select_month (dpanel->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
- gtk_calendar_select_day (dpanel->gtk_calendar, tm.tm_mday);
- dpanel->day_selected_id = gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar),
- "day_selected_double_click",
- (GtkSignalFunc) calendar_day_selected,
- dpanel);
- gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar), "month_changed",
- GTK_SIGNAL_FUNC (retag_calendar), dpanel);
- gtk_paned_add1 (GTK_PANED (vpane), w);
- gtk_widget_show (w);
-
- /* To-do */
-
- w = gncal_todo_new (calendar);
- dpanel->todo = GNCAL_TODO (w);
- gtk_paned_add2 (GTK_PANED (vpane), w);
- gtk_widget_show (w);
-
- /* Done */
-
- gncal_day_panel_set (dpanel, start_of_day);
-
- gtk_paned_set_position (GTK_PANED (hpane), start_pos);
-
- return GTK_WIDGET (dpanel);
-}
-
-static void
-update (GncalDayPanel *dpanel, int update_fullday, iCalObject *ico, int flags)
-{
- char buf [80];
-
- if (update_fullday){
- gncal_full_day_update (dpanel->fullday, ico, flags);
- retag_calendar (dpanel->gtk_calendar, dpanel);
- }
- gncal_todo_update (dpanel->todo, ico, flags);
-
- strftime (buf, sizeof (buf), _("%a %b %d %Y"), localtime (&dpanel->start_of_day));
- gtk_label_set (GTK_LABEL (dpanel->date_label), buf);
-}
-
-void
-gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags)
-{
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- update (dpanel, TRUE, ico, flags);
-}
-
-void
-gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day)
-{
- char buf[80];
- struct tm tm;
-
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- dpanel->start_of_day = time_day_begin(start_of_day);
- if (dpanel->fullday->lower == dpanel->start_of_day)
- return;
-
- tm = *localtime (&dpanel->start_of_day);
- strftime (buf, sizeof (buf), _("%a %b %d %Y"), &tm);
- gtk_label_set (GTK_LABEL (dpanel->date_label), buf);
-
- gncal_full_day_set_bounds (dpanel->fullday, dpanel->start_of_day, time_day_end (dpanel->start_of_day));
-
- gtk_calendar_select_month (dpanel->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
-
- gtk_signal_handler_block (GTK_OBJECT (dpanel->gtk_calendar), dpanel->day_selected_id);
- gtk_calendar_select_day (dpanel->gtk_calendar, tm.tm_mday);
- gtk_signal_handler_unblock (GTK_OBJECT (dpanel->gtk_calendar), dpanel->day_selected_id);
-
- update (dpanel, FALSE, NULL, 0);
-}
-
-void
-gncal_day_panel_time_format_changed (GncalDayPanel *dpanel)
-{
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- gtk_calendar_display_options (dpanel->gtk_calendar,
- (week_starts_on_monday
- ? (dpanel->gtk_calendar->display_flags
- | GTK_CALENDAR_WEEK_START_MONDAY)
- : (dpanel->gtk_calendar->display_flags
- & ~GTK_CALENDAR_WEEK_START_MONDAY)));
-}
-
-void
-todo_list_properties_changed (GncalDayPanel *dpanel)
-{
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- gncal_todo_update (dpanel->todo, NULL, 0);
-}
-
-
-
diff --git a/calendar/gncal-day-panel.h b/calendar/gncal-day-panel.h
deleted file mode 100644
index 6bf8768d9c..0000000000
--- a/calendar/gncal-day-panel.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Day view notebook panel for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_DAY_PANEL_H
-#define GNCAL_DAY_PANEL_H
-
-#include <gtk/gtklabel.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktable.h>
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-#include "gncal-full-day.h"
-#include "gncal-todo.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_DAY_PANEL(obj) GTK_CHECK_CAST (obj, gncal_day_panel_get_type (), GncalDayPanel)
-#define GNCAL_DAY_PANEL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_day_panel_get_type (), GncalDayPanelClass)
-#define GNCAL_IS_DAY_PANEL(obj) GTK_CHECK_TYPE (obj, gncal_day_panel_get_type ())
-
-
-typedef struct _GncalDayPanel GncalDayPanel;
-typedef struct _GncalDayPanelClass GncalDayPanelClass;
-
-struct _GncalDayPanel {
- GtkTable table;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- time_t start_of_day;
-
- GtkLabel *date_label;
- GncalFullDay *fullday;
- GtkScrolledWindow *fullday_sw;
- GtkCalendar *gtk_calendar;
- GncalTodo *todo;
-
- guint day_selected_id;
-};
-
-struct _GncalDayPanelClass {
- GtkTableClass parent_class;
-};
-
-
-guint gncal_day_panel_get_type (void);
-GtkWidget *gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day);
-
-void gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags);
-void gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day);
-void gncal_day_panel_time_format_changed (GncalDayPanel *dpanel);
-
-void todo_list_properties_changed (GncalDayPanel *dpanel);
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gncal-day-view.c b/calendar/gncal-day-view.c
deleted file mode 100644
index eafd237029..0000000000
--- a/calendar/gncal-day-view.c
+++ /dev/null
@@ -1,396 +0,0 @@
-/* Day view widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <gnome.h>
-#include "gncal-day-view.h"
-#include "timeutil.h"
-#include "view-utils.h"
-#include "main.h"
-#include "eventedit.h"
-#include "popup-menu.h"
-
-
-#define TEXT_BORDER 2
-#define MIN_INFO_WIDTH 50
-
-
-static void gncal_day_view_class_init (GncalDayViewClass *class);
-static void gncal_day_view_init (GncalDayView *dview);
-static void gncal_day_view_destroy (GtkObject *object);
-static void gncal_day_view_realize (GtkWidget *widget);
-static void gncal_day_view_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static gint gncal_day_view_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static gint gncal_day_view_button_press (GtkWidget *widget,
- GdkEventButton *event);
-
-
-static GtkWidgetClass *parent_class;
-
-
-guint
-gncal_day_view_get_type (void)
-{
- static guint day_view_type = 0;
-
- if (!day_view_type) {
- GtkTypeInfo day_view_info = {
- "GncalDayView",
- sizeof (GncalDayView),
- sizeof (GncalDayViewClass),
- (GtkClassInitFunc) gncal_day_view_class_init,
- (GtkObjectInitFunc) gncal_day_view_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- day_view_type = gtk_type_unique (gtk_widget_get_type (), &day_view_info);
- }
-
- return day_view_type;
-}
-
-static void
-gncal_day_view_class_init (GncalDayViewClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gtk_widget_get_type ());
-
- object_class->destroy = gncal_day_view_destroy;
-
- widget_class->realize = gncal_day_view_realize;
- widget_class->size_request = gncal_day_view_size_request;
- widget_class->expose_event = gncal_day_view_expose;
- widget_class->button_press_event = gncal_day_view_button_press;
-}
-
-static void
-gncal_day_view_init (GncalDayView *dview)
-{
- GTK_WIDGET_UNSET_FLAGS (dview, GTK_NO_WINDOW);
-
- dview->calendar = NULL;
-
- dview->lower = 0;
- dview->upper = 0;
-
- dview->shadow_type = GTK_SHADOW_ETCHED_IN;
-}
-
-static void
-gncal_day_view_destroy (GtkObject *object)
-{
- GncalDayView *dview;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (object));
-
- dview = GNCAL_DAY_VIEW (object);
-
- if (dview->day_str)
- g_free (dview->day_str);
- if (dview->events)
- calendar_destroy_event_list (dview->events);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-static int
-new_appointment (GtkWidget *widget, gpointer data)
-{
- GncalDayView *dayview = GNCAL_DAY_VIEW (data);
- iCalObject *ico;
- GtkWidget *ee;
- struct tm tm;
-
- ico = ical_new ("", user_name, "");
- ico->new = 1;
-
- tm = *localtime (&dayview->lower);
- tm.tm_hour = day_begin;
- ico->dtstart = mktime (&tm);
- tm.tm_hour++;
- ico->dtend = mktime (&tm);
- ee = event_editor_new (dayview->calendar, ico);
- gtk_widget_show (ee);
- return 1;
-}
-
-static void
-context_menu (GncalDayView *dayview, GdkEventButton *event)
-{
- static struct menu_item main_items[] = {
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- main_items [0].data = dayview;
- popup_menu (main_items, 1, event);
-}
-
-static gint
-gncal_day_view_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- GncalDayView *dayview;
-
- dayview = GNCAL_DAY_VIEW (widget);
-
- if (event->button == 3)
- context_menu (dayview, event);
-
- if (event->button == 1 && event->type == GDK_2BUTTON_PRESS)
- gnome_calendar_dayjump (dayview->calendar, dayview->lower);
-
- return TRUE;
-}
-
-GtkWidget *
-gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper)
-{
- GncalDayView *dview;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- dview = gtk_type_new (gncal_day_view_get_type ());
-
- dview->calendar = calendar;
- dview->lower = lower;
- dview->upper = upper;
- dview->events = 0;
-
- gncal_day_view_update (dview, NULL, 0);
-
- return GTK_WIDGET (dview);
-}
-
-static void
-gncal_day_view_realize (GtkWidget *widget)
-{
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = (gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- gdk_window_set_background (widget->window, &widget->style->bg[GTK_STATE_PRELIGHT]);
-}
-
-static void
-gncal_day_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- GncalDayView *dview;
- int str_width, width;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (widget));
- g_return_if_fail (requisition != NULL);
-
- dview = GNCAL_DAY_VIEW (widget);
-
- /* border and min width */
-
- str_width = gdk_string_width (widget->style->font, dview->day_str);
-
- width = MAX (MIN_INFO_WIDTH, str_width);
-
- requisition->width = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + width;
- requisition->height = 2 * (widget->style->klass->ythickness + TEXT_BORDER);
-
- /* division line */
-
- requisition->height += 2 * TEXT_BORDER + widget->style->klass->ythickness;
-
- /* title and at least one line of text */
-
- requisition->height += 2 * (widget->style->font->ascent + widget->style->font->descent);
-}
-
-static gint
-gncal_day_view_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- GncalDayView *dview;
- int x1, y1, width, height;
- GdkRectangle rect, dest;
- GdkFont *font;
- int str_width;
- GdkGC *gc;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_DAY_VIEW (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return FALSE;
-
- gc = widget->style->fg_gc [GTK_STATE_NORMAL];
- dview = GNCAL_DAY_VIEW (widget);
-
- x1 = widget->style->klass->xthickness;
- y1 = widget->style->klass->ythickness;
- width = widget->allocation.width - 2 * x1;
- height = widget->allocation.height - 2 * y1;
-
- /* Clear and paint frame shadow */
-
- gdk_window_clear_area (widget->window,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
-
- gtk_draw_shadow (widget->style, widget->window,
- GTK_STATE_NORMAL, dview->shadow_type,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
-
- /* Clear and paint title */
-
- font = widget->style->font;
-
- rect.x = x1;
- rect.y = y1;
- rect.width = width;
- rect.height = 2 * TEXT_BORDER + font->ascent + font->descent;
-
- if (gdk_rectangle_intersect (&rect, &event->area, &dest)) {
- gdk_draw_rectangle (widget->window,
- widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- dest = rect;
-
- dest.x += TEXT_BORDER;
- dest.y += TEXT_BORDER;
- dest.width -= 2 * TEXT_BORDER;
- dest.height -= 2 * TEXT_BORDER;
-
- gdk_gc_set_clip_rectangle (gc, &dest);
-
- str_width = gdk_string_width (font, dview->day_str);
-
- gdk_draw_string (widget->window, font, gc,
- dest.x + (dest.width - str_width) / 2,
- dest.y + font->ascent,
- dview->day_str);
-
- gdk_gc_set_clip_rectangle (gc, NULL);
- }
-
- /* Division line */
-
- gtk_draw_hline (widget->style,
- widget->window,
- GTK_STATE_NORMAL,
- rect.x,
- rect.x + rect.width - 1,
- rect.y + rect.height);
-
- /* Text */
-
- if (dview->events != NULL){
- rect.x = x1 + TEXT_BORDER;
- rect.y = y1 + 3 * TEXT_BORDER +
- font->ascent + font->descent +
- widget->style->klass->ythickness;
- rect.width = width - 2 * TEXT_BORDER;
- rect.height = height - (rect.y - y1) - TEXT_BORDER;
-
- if (gdk_rectangle_intersect (&rect, &event->area, &dest))
- view_utils_draw_events (
- widget, widget->window, gc,
- &rect,
- VIEW_UTILS_DRAW_END | VIEW_UTILS_DRAW_SPLIT,
- dview->events,
- dview->lower,
- dview->upper);
- }
-
- return FALSE;
-}
-
-void
-gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags)
-{
- struct tm tm;
- char buf[256];
-
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
- g_return_if_fail (dview->calendar->cal);
-
- if (dview->day_str)
- g_free (dview->day_str);
-
- tm = *localtime (&dview->lower);
- strftime (buf, sizeof (buf)-1, "%A %d", &tm);
- dview->day_str = g_strdup (buf);
-
- if (dview->events)
- calendar_destroy_event_list (dview->events);
-
- dview->events = calendar_get_events_in_range (dview->calendar->cal,
- dview->lower,
- dview->upper);
-
- gtk_widget_draw (GTK_WIDGET (dview), NULL);
-}
-
-void
-gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper)
-{
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
-
- if ((lower != dview->lower) || (upper != dview->upper)) {
- dview->lower = lower;
- dview->upper = upper;
-
- gncal_day_view_update (dview, NULL, 0);
- }
-}
-
-void
-gncal_day_view_set_shadow (GncalDayView *dview, GtkShadowType shadow_type)
-{
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
-
- if (shadow_type != dview->shadow_type) {
- dview->shadow_type = shadow_type;
-
- gtk_widget_draw (GTK_WIDGET (dview), NULL);
- }
-}
diff --git a/calendar/gncal-day-view.h b/calendar/gncal-day-view.h
deleted file mode 100644
index dae1897fb6..0000000000
--- a/calendar/gncal-day-view.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Day view widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_DAY_VIEW_H
-#define GNCAL_DAY_VIEW_H
-
-
-#include <gtk/gtkwidget.h>
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_DAY_VIEW(obj) GTK_CHECK_CAST (obj, gncal_day_view_get_type (), GncalDayView)
-#define GNCAL_DAY_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_day_view_get_type (), GncalDayViewClass)
-#define GNCAL_IS_DAY_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_day_view_get_type ())
-
-
-typedef struct _GncalDayView GncalDayView;
-typedef struct _GncalDayViewClass GncalDayViewClass;
-
-struct _GncalDayView {
- GtkWidget widget;
-
- GnomeCalendar *calendar;/* the calendar we are associated to */
-
- time_t lower; /* lower and upper times to display */
- time_t upper; /* these include the full day */
-
- char *day_str; /* what day is it? */
- GList *events; /* the events for the this day */
- GtkShadowType shadow_type;
-};
-
-struct _GncalDayViewClass {
- GtkWidgetClass parent_class;
-};
-
-
-guint gncal_day_view_get_type (void);
-GtkWidget *gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper);
-
-void gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags);
-void gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper);
-
-void gncal_day_view_set_shadow (GncalDayView *dview, GtkShadowType shadow_type);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c
deleted file mode 100644
index c07d9a5710..0000000000
--- a/calendar/gncal-full-day.c
+++ /dev/null
@@ -1,2287 +0,0 @@
-/* Full day widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-#include <config.h>
-#include <string.h>
-#include <gdk/gdkkeysyms.h>
-#include <gnome.h>
-#include "eventedit.h"
-#include "gncal-full-day.h"
-#include "view-utils.h"
-#include "layout.h"
-#include "main.h"
-#include "popup-menu.h"
-
-/* Images */
-#include "bell.xpm"
-#include "recur.xpm"
-
-#define TEXT_BORDER 2
-#define HANDLE_SIZE 8
-#define MIN_WIDTH 200
-#define XOR_RECT_WIDTH 2
-#define UNSELECT_TIMEOUT 0 /* ms */
-
-/* Size of the pixmaps */
-#define DECOR_WIDTH 16
-#define DECOR_HEIGHT 16
-
-typedef struct {
- iCalObject *ico;
- GtkWidget *widget;
- GdkWindow *window;
- GdkWindow *decor_window;
- guint focus_out_id;
- int lower_row; /* zero is first displayed row */
- int rows_used;
- int x; /* coords of child's window */
- int y;
- int width;
- int height;
- int decor_width;
- int decor_height;
- int items; /* number of decoration bitmaps */
- time_t start, end;
-} Child;
-
-struct drag_info {
- enum {
- DRAG_NONE,
- DRAG_SELECT, /* selecting a range in the main window */
- DRAG_MOVE, /* moving a child */
- DRAG_SIZE_TOP, /* resizing a child */
- DRAG_SIZE_BOTTOM
- } drag_mode;
-
- Child *child;
- int child_click_y;
- int child_start_row;
- int child_rows_used;
-
- int sel_click_row;
- int sel_start_row;
- int sel_rows_used;
- guint32 click_time;
-};
-
-
-enum {
- RANGE_ACTIVATED,
- LAST_SIGNAL
-};
-
-
-static void gncal_full_day_class_init (GncalFullDayClass *class);
-static void gncal_full_day_init (GncalFullDay *fullday);
-static void gncal_full_day_destroy (GtkObject *object);
-static void gncal_full_day_map (GtkWidget *widget);
-static void gncal_full_day_unmap (GtkWidget *widget);
-static void gncal_full_day_realize (GtkWidget *widget);
-static void gncal_full_day_unrealize (GtkWidget *widget);
-static void gncal_full_day_draw (GtkWidget *widget,
- GdkRectangle *area);
-static void gncal_full_day_draw_focus (GtkWidget *widget);
-static void gncal_full_day_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void gncal_full_day_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gint gncal_full_day_button_press (GtkWidget *widget,
- GdkEventButton *event);
-static gint gncal_full_day_button_release (GtkWidget *widget,
- GdkEventButton *event);
-static gint gncal_full_day_motion (GtkWidget *widget,
- GdkEventMotion *event);
-static gint gncal_full_day_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static gint gncal_full_day_key_press (GtkWidget *widget,
- GdkEventKey *event);
-static gint gncal_full_day_focus_in (GtkWidget *widget,
- GdkEventFocus *event);
-static gint gncal_full_day_focus_out (GtkWidget *widget,
- GdkEventFocus *event);
-static void gncal_full_day_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-
-static void range_activated (GncalFullDay *fullday);
-
-static GtkContainerClass *parent_class;
-
-static int fullday_signals[LAST_SIGNAL] = { 0 };
-
-/* The little images */
-static GdkPixmap *pixmap_bell, *pixmap_recur;
-
-static void
-get_tm_range (GncalFullDay *fullday,
- time_t time_lower, time_t time_upper,
- struct tm *lower, struct tm *upper,
- int *lower_row, int *rows_used)
-{
- struct tm tm_lower, tm_upper;
- int lmin, umin;
- int lrow;
-
- /* Lower */
-
- tm_lower = *localtime (&time_lower);
-
- if ((tm_lower.tm_min % fullday->interval) != 0) {
- tm_lower.tm_min -= tm_lower.tm_min % fullday->interval; /* round down */
- mktime (&tm_lower);
- }
-
- /* Upper */
-
- tm_upper = *localtime (&time_upper);
-
- if ((tm_upper.tm_min % fullday->interval) != 0) {
- tm_upper.tm_min += fullday->interval - (tm_upper.tm_min % fullday->interval); /* round up */
- mktime (&tm_upper);
- }
-
- if (lower)
- *lower = tm_lower;
-
- if (upper)
- *upper = tm_upper;
-
- lmin = 60 * tm_lower.tm_hour + tm_lower.tm_min;
- umin = 60 * tm_upper.tm_hour + tm_upper.tm_min;
-
- if (umin == 0) /* midnight of next day? */
- umin = 60 * 24;
-
- lrow = lmin / fullday->interval;
-
- if (lower_row)
- *lower_row = lrow;
-
- if (rows_used)
- *rows_used = (umin - lmin) / fullday->interval;
-}
-
-static void
-child_map (GncalFullDay *fullday, Child *child)
-{
- gdk_window_show (child->window);
- if (child->decor_width)
- gdk_window_show (child->decor_window);
- gtk_widget_show (child->widget); /* OK, not just a map... */
-}
-
-static void
-child_unmap (GncalFullDay *fullday, Child *child)
-{
- gdk_window_hide (child->window);
- gdk_window_hide (child->decor_window);
- if (GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_unmap (child->widget);
-}
-
-static void
-child_set_text_pos (Child *child)
-{
- GtkAllocation allocation;
- int has_focus;
- int handle_size;
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- handle_size = (child->ico->recur) ? 0 : HANDLE_SIZE;
-
- allocation.x = handle_size;
- allocation.y = has_focus ? handle_size : 0;
- allocation.width = child->width - handle_size - child->decor_width;
- allocation.height = child->height - (has_focus ? (2 * handle_size) : 0);
-
- gtk_widget_size_request (child->widget, NULL);
- gtk_widget_size_allocate (child->widget, &allocation);
-}
-
-static void
-child_realize (GncalFullDay *fullday, Child *child)
-{
- GdkWindowAttr attributes;
- gint attributes_mask;
- GtkWidget *widget;
- GdkColor c;
-
- widget = GTK_WIDGET (fullday);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = child->x;
- attributes.y = child->y;
- attributes.width = child->width - child->decor_width;;
- attributes.height = child->height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.cursor = fullday->up_down_cursor;
- attributes.event_mask = (GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_KEY_PRESS_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR;
- child->window = gdk_window_new (widget->window, &attributes, attributes_mask);
- gdk_window_set_user_data (child->window, widget);
- gtk_style_set_background (widget->style, child->window, GTK_STATE_NORMAL);
- gtk_widget_set_parent_window (child->widget, child->window);
-
- /* Create the decoration window */
- attributes.x = child->x + child->width - child->decor_width;
- attributes.width = child->decor_width ? child->decor_width : 1;
- attributes.height = child->decor_height ? child->decor_height : 1;
- attributes.visual = gdk_imlib_get_visual ();
- attributes.colormap = gdk_imlib_get_colormap ();
- attributes.event_mask = (GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- child->decor_window = gdk_window_new (widget->window, &attributes, attributes_mask);
- gdk_color_white (gdk_imlib_get_colormap (), &c);
- gdk_window_set_background (child->decor_window, &c);
- gdk_window_set_user_data (child->decor_window, widget);
-
- if (!pixmap_bell){
- GdkImlibImage *imlib_bell, *imlib_recur;
- GdkPixmap *mask;
-
- imlib_bell = gdk_imlib_create_image_from_xpm_data (bell_xpm);
- gdk_imlib_render (imlib_bell, DECOR_WIDTH, DECOR_HEIGHT);
- pixmap_bell = gdk_imlib_move_image (imlib_bell);
- mask = gdk_imlib_move_mask (imlib_bell);
- gdk_imlib_destroy_image (imlib_bell);
- fullday->bell_gc = gdk_gc_new (child->decor_window);
- if (mask)
- gdk_gc_set_clip_mask (fullday->bell_gc, mask);
-
- imlib_recur = gdk_imlib_create_image_from_xpm_data (recur_xpm);
- gdk_imlib_render (imlib_recur, DECOR_WIDTH, DECOR_HEIGHT);
- pixmap_recur = gdk_imlib_move_image (imlib_recur);
- mask = gdk_imlib_move_mask (imlib_recur);
- gdk_imlib_destroy_image (imlib_recur);
- fullday->recur_gc = gdk_gc_new (child->decor_window);
- if (mask)
- gdk_gc_set_clip_mask (fullday->recur_gc, mask);
- }
- child_set_text_pos (child);
-}
-
-static void
-child_unrealize (GncalFullDay *fullday, Child *child)
-{
- if (GTK_WIDGET_REALIZED (child->widget))
- gtk_widget_unrealize (child->widget);
-
- gdk_window_set_user_data (child->window, NULL);
- gdk_window_destroy (child->window);
- child->window = NULL;
-}
-
-static void
-child_draw_decor (GncalFullDay *fullday, Child *child)
-{
- iCalObject *ico = child->ico;
- int ry = 0;
-
- if (ico->recur) {
- gdk_gc_set_clip_origin (fullday->recur_gc, 0, ry);
- gdk_draw_pixmap (child->decor_window,
- fullday->recur_gc,
- pixmap_recur,
- 0, 0,
- 0, ry,
- DECOR_WIDTH, DECOR_HEIGHT);
- ry += DECOR_HEIGHT;
- }
-
- if (ico->dalarm.enabled || ico->malarm.enabled || ico->palarm.enabled || ico->aalarm.enabled) {
- gdk_gc_set_clip_origin (fullday->bell_gc, 0, ry);
- gdk_draw_pixmap (child->decor_window,
- fullday->bell_gc,
- pixmap_bell,
- 0, 0,
- 0, ry,
- DECOR_WIDTH, DECOR_HEIGHT);
- ry += DECOR_HEIGHT;
- }
-}
-
-static void
-child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, GdkWindow *window, int draw_child)
-{
- GdkRectangle arect, rect, dest;
- int has_focus;
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- if (!window || (window == child->window)) {
- if (!area) {
- arect.x = 0;
- arect.y = 0;
- arect.width = child->width;
- arect.height = child->height;
-
- area = &arect;
- }
-
- /* Left handle */
-
- rect.x = 0;
- rect.y = has_focus ? HANDLE_SIZE : 0;
- rect.width = HANDLE_SIZE;
- rect.height = has_focus ? (child->height - 2 * HANDLE_SIZE) : child->height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window, &rect, GTK_SHADOW_OUT);
-
- if (has_focus) {
- /* Top handle */
-
- rect.x = 0;
- rect.y = 0;
- rect.width = child->width - child->decor_width;
- rect.height = HANDLE_SIZE;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window,
- &rect, GTK_SHADOW_OUT);
-
- /* Bottom handle */
-
- rect.y = child->height - HANDLE_SIZE;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window,
- &rect, GTK_SHADOW_OUT);
- }
-
- } else if (!window || (window == child->decor_window)) {
- if (!area) {
- arect.x = 0;
- arect.y = 0;
- arect.width = child->decor_width;
- arect.height = child->decor_height;
-
- area = &arect;
- }
-
- child_draw_decor (fullday, child);
- }
-
- if (draw_child)
- gtk_widget_draw (child->widget, NULL);
-}
-
-static void
-child_range_changed (GncalFullDay *fullday, Child *child)
-{
- struct tm start, end;
- int lower_row, rows_used;
- int f_lower_row;
-
- /* Calc display range for event */
-
- get_tm_range (fullday, child->start, child->end, &start, &end, &lower_row, &rows_used);
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, &f_lower_row, NULL);
-
- child->lower_row = lower_row - f_lower_row;
- child->rows_used = rows_used;
-}
-
-static void
-new_appointment (GtkWidget *widget, gpointer data)
-{
- GncalFullDay *fullday;
- GtkWidget *ee;
- iCalObject *ico;
-
- fullday = GNCAL_FULL_DAY (data);
-
- ico = ical_new ("", user_name, "");
- ico->new = 1;
-
- gncal_full_day_selection_range (fullday, &ico->dtstart, &ico->dtend);
- ee = event_editor_new (fullday->calendar, ico);
- gtk_widget_show (ee);
-}
-
-static void
-edit_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GtkWidget *ee;
-
- child = data;
-
- ee = event_editor_new (GNCAL_FULL_DAY (child->widget->parent)->calendar, child->ico);
- gtk_widget_show (ee);
-}
-
-static void
-delete_occurance (GtkWidget *widget, gpointer data)
-{
- Child *child = data;
- iCalObject *ical;
- time_t *t;
- GnomeCalendar *gcal = GNCAL_FULL_DAY (child->widget->parent)->calendar;
-
- child = data;
- ical = child->ico;
- t = g_new(time_t, 1);
- *t = child->start;
- ical->exdate = g_list_prepend(ical->exdate, t);
- gnome_calendar_object_changed (gcal, child->ico, CHANGE_DATES);
- save_default_calendar (gcal);
-
-}
-
-static void
-delete_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- child = data;
-
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- gnome_calendar_remove_object (fullday->calendar, child->ico);
- save_default_calendar (fullday->calendar);
-}
-
-static void
-unrecur_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
- iCalObject *new;
-
- child = data;
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- /* New object */
- new = ical_object_duplicate (child->ico);
- g_free (new->recur);
- new->recur = 0;
- new->dtstart = child->start;
- new->dtend = child->end;
-
- /* Duplicate, and eliminate the recurrency fields */
- ical_object_add_exdate (child->ico, child->start);
- gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_ALL);
-
- gnome_calendar_add_object (fullday->calendar, new);
- save_default_calendar (fullday->calendar);
-}
-
-static void
-child_popup_menu (GncalFullDay *fullday, Child *child, GdkEventButton *event)
-{
- int sensitive, items;
- struct menu_item *context_menu;
-
- static struct menu_item child_items[] = {
- { N_("Edit this appointment..."), (GtkSignalFunc) edit_appointment, NULL, TRUE },
- { N_("Delete this appointment"), (GtkSignalFunc) delete_appointment, NULL, TRUE },
- { NULL, NULL, NULL, TRUE },
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- static struct menu_item recur_child_items[] = {
- { N_("Make this appointment movable"), (GtkSignalFunc) unrecur_appointment, NULL, TRUE },
- { N_("Edit this appointment..."), (GtkSignalFunc) edit_appointment, NULL, TRUE },
- { N_("Delete this occurance"), (GtkSignalFunc) delete_occurance, NULL, TRUE },
- { N_("Delete all occurances"), (GtkSignalFunc) delete_appointment, NULL, TRUE },
- { NULL, NULL, NULL, TRUE },
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- sensitive = (child->ico->user_data == NULL);
-
- if (child->ico->recur){
- items = 6;
- context_menu = &recur_child_items[0];
- context_menu[2].data = child;
- context_menu[3].data = child;
- context_menu[3].sensitive = sensitive;
- context_menu[4].data = fullday;
- context_menu[5].data = fullday;
- } else {
- items = 4;
- context_menu = &child_items[0];
- context_menu[3].data = fullday;
- }
- /* These settings are common for each context sensitive menu */
- context_menu[0].data = child;
- context_menu[1].data = child;
- context_menu[0].sensitive = sensitive;
- context_menu[1].sensitive = sensitive;
- context_menu[2].sensitive = sensitive;
-
- popup_menu (context_menu, items, event);
-}
-
-static void
-child_realized_setup (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- child = data;
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gdk_window_set_cursor (widget->window, fullday->beam_cursor);
-}
-
-static void
-child_set_pos (GncalFullDay *fullday, Child *child, int x, int y, int width, int height)
-{
- const int decor_width = child->decor_width;
-
- child->x = x;
- child->y = y;
- child->width = width;
- child->height = height;
-
- if (!child->window) /* realized? */
- return;
-
- child_set_text_pos (child);
- gdk_window_move_resize (child->window, x, y, width - decor_width, height);
-
- if (decor_width){
- gdk_window_move_resize (child->decor_window, x + width - decor_width, y,
- decor_width, child->decor_height);
- }
-}
-
-static int
-calc_row_height (GncalFullDay *fullday)
-{
- int f_rows;
- GtkWidget *widget;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- widget = GTK_WIDGET (fullday);
-
- return (widget->allocation.height - 2 * widget->style->klass->ythickness) / f_rows;
-}
-
-static void
-child_set_size (Child *child)
-{
- int row_height;
- int x, y, width, height;
- GncalFullDay *fullday;
-
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- row_height = calc_row_height (fullday);
-
- x = child->x;
- y = child->lower_row * row_height + GTK_WIDGET (fullday)->style->klass->ythickness;
- width = child->width;
- height = child->rows_used * row_height;
-
- if (GTK_WIDGET_HAS_FOCUS (child->widget) && !child->ico->recur) {
- y -= HANDLE_SIZE;
- height += 2 * HANDLE_SIZE;
- }
-
- child_set_pos (fullday, child, x, y, width, height);
-}
-
-static gint
-child_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- child_set_size (data);
- return FALSE;
-}
-
-static gint
-child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
- char *text;
-
- child = data;
-
- child_set_size (child);
-
- /* Update summary in calendar object */
-
- text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
- if (child->ico->summary && strcmp (text, child->ico->summary) == 0)
- return FALSE;
-
- if (child->ico->summary)
- g_free (child->ico->summary);
-
- child->ico->summary = text;
-
- /* Notify calendar of change */
-
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_SUMMARY);
- save_default_calendar (fullday->calendar);
-
- return FALSE;
-}
-
-static gint
-child_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data)
-{
- if (event->keyval != GDK_Escape)
- return FALSE;
-
- /* If user pressed Esc, un-focus the child by focusing the fullday widget */
-
- gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
- gtk_widget_grab_focus (widget->parent);
-
- return FALSE;
-}
-
-static gint
-child_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- if (event->button != 3)
- return FALSE;
-
- child = data;
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "button_press_event");
- gtk_widget_grab_focus (widget);
- child_popup_menu (fullday, child, event);
-
- return TRUE;
-}
-
-/*
- * compute the space required to display the decorations
- */
-static void
-child_compute_decor (Child *child)
-{
- iCalObject *ico = child->ico;
- int rows_used;
-
- child->items = 0;
- rows_used = (child->rows_used < 1) ? 1 : child->rows_used;
- if (ico->recur)
- child->items++;
- if (ico->dalarm.enabled || ico->aalarm.enabled || ico->palarm.enabled || ico->malarm.enabled)
- child->items++;
-
- if (child->items > rows_used){
- child->decor_width = DECOR_WIDTH * 2;
- child->decor_height = DECOR_HEIGHT;
- } else {
- child->decor_width = DECOR_WIDTH * (child->items ? 1 : 0);
- child->decor_height = DECOR_HEIGHT * child->items;
- }
-}
-
-static Child *
-child_new (GncalFullDay *fullday, time_t start, time_t end, iCalObject *ico)
-{
- Child *child;
-
- child = g_new (Child, 1);
-
- child->ico = ico;
- child->widget = gtk_text_new (NULL, NULL);
- child->window = NULL;
- child->x = 0;
- child->y = 0;
- child->width = 0;
- child->height = 0;
- child->start = start;
- child->end = end;
- child_range_changed (fullday, child);
- child_compute_decor (child);
-
- if (ico->summary)
- gtk_text_insert (GTK_TEXT (child->widget), NULL, NULL, NULL,
- ico->summary,
- strlen (ico->summary));
-
- /* We set the i-beam cursor of the text widget upon realization */
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "realize",
- (GtkSignalFunc) child_realized_setup,
- child);
-
- gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_in_event",
- (GtkSignalFunc) child_focus_in,
- child);
-
- child->focus_out_id = gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_out_event",
- (GtkSignalFunc) child_focus_out,
- child);
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "key_press_event",
- (GtkSignalFunc) child_key_press,
- child);
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "button_press_event",
- (GtkSignalFunc) child_button_press,
- child);
-
- /* Finish setup */
-
- gtk_text_set_editable (GTK_TEXT (child->widget), TRUE);
- gtk_text_set_word_wrap (GTK_TEXT (child->widget), TRUE);
-
- gtk_widget_set_parent (child->widget, GTK_WIDGET (fullday));
-
- return child;
-}
-
-static void
-squick (GtkWidget *widget, gpointer data)
-{
-}
-
-static void
-child_destroy (GncalFullDay *fullday, Child *child)
-{
- /* Disconnect the focus_out_event signal since we will get such an event
- * from the destroy call.
- */
- gtk_signal_disconnect (GTK_OBJECT (child->widget), child->focus_out_id);
-
- if (GTK_WIDGET_MAPPED (fullday))
- child_unmap (fullday, child);
-
- if (GTK_WIDGET_REALIZED (fullday))
- child_unrealize (fullday, child);
-
- /* Unparent the child widget manually as we don't have a remove method */
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "destroy",
- (GtkSignalFunc) squick,
- NULL);
-
- gtk_widget_unparent (child->widget);
- g_free (child);
-}
-
-static int
-calc_labels_width (GncalFullDay *fullday)
-{
- struct tm cur, upper;
- time_t tim, time_upper;
- int width, max_w;
- char buf[40];
-
- get_tm_range (fullday, fullday->lower, fullday->upper, &cur, &upper, NULL, NULL);
-
- max_w = 0;
-
- tim = mktime (&cur);
- time_upper = mktime (&upper);
-
- while (tim < time_upper) {
- if (am_pm_flag)
- strftime (buf, sizeof (buf), "%I:%M%p", &cur);
- else
- strftime (buf, sizeof (buf), "%H:%M", &cur);
-
-
- width = gdk_string_width (GTK_WIDGET (fullday)->style->font, buf);
-
- if (width > max_w)
- max_w = width;
-
- cur.tm_min += fullday->interval;
- tim = mktime (&cur);
- }
-
- return max_w;
-}
-
-/* Used with layout_events(), takes in a list element and returns the start and end times for the
- * event corresponding to that element.
- */
-static void
-child_layout_query_func (GList *event, time_t *start, time_t *end)
-{
- Child *child;
-
- child = event->data;
-
- *start = child->start;
- *end = child->end;
-}
-
-/* Takes the list of children in the full day view and lays them out nicely without overlapping.
- * Basically it calls the layout_events() function in layout.c and resizes the fullday's children.
- */
-static void
-layout_children (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- GList *children;
- Child *child;
- int num_slots;
- int *allocations;
- int *slots;
- int left_x;
- int usable_pixels, pixels_per_col, extra_pixels;
- int i;
-
- if (!fullday->children)
- return;
-
- layout_events (fullday->children, child_layout_query_func, &num_slots, &allocations, &slots);
-
- /* Set the size and position of each child */
-
- widget = GTK_WIDGET (fullday);
- left_x = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + calc_labels_width (fullday);
-
- usable_pixels = widget->allocation.width - left_x - widget->style->klass->xthickness;
- pixels_per_col = usable_pixels / num_slots;
- extra_pixels = usable_pixels % num_slots;
-
- for (children = fullday->children, i = 0; children; children = children->next, i++) {
- child = children->data;
-
- child->x = left_x + pixels_per_col * allocations[i];
- child->width = pixels_per_col * slots[i];
-
- if ((allocations[i] + slots[i]) == num_slots)
- child->width += extra_pixels;
-
- child_set_size (child);
- }
-
- g_free (allocations);
- g_free (slots);
-}
-
-guint
-gncal_full_day_get_type (void)
-{
- static guint full_day_type = 0;
-
- if (!full_day_type) {
- GtkTypeInfo full_day_info = {
- "GncalFullDay",
- sizeof (GncalFullDay),
- sizeof (GncalFullDayClass),
- (GtkClassInitFunc) gncal_full_day_class_init,
- (GtkObjectInitFunc) gncal_full_day_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- full_day_type = gtk_type_unique (gtk_container_get_type (), &full_day_info);
- }
-
- return full_day_type;
-}
-
-static void
-gncal_full_day_class_init (GncalFullDayClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- container_class = (GtkContainerClass *) class;
-
- parent_class = gtk_type_class (gtk_container_get_type ());
-
- fullday_signals[RANGE_ACTIVATED] =
- gtk_signal_new ("range_activated",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (GncalFullDayClass, range_activated),
- gtk_signal_default_marshaller,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, fullday_signals, LAST_SIGNAL);
-
- object_class->destroy = gncal_full_day_destroy;
-
- widget_class->map = gncal_full_day_map;
- widget_class->unmap = gncal_full_day_unmap;
- widget_class->realize = gncal_full_day_realize;
- widget_class->unrealize = gncal_full_day_unrealize;
- widget_class->draw = gncal_full_day_draw;
- widget_class->draw_focus = gncal_full_day_draw_focus;
- widget_class->size_request = gncal_full_day_size_request;
- widget_class->size_allocate = gncal_full_day_size_allocate;
- widget_class->button_press_event = gncal_full_day_button_press;
- widget_class->button_release_event = gncal_full_day_button_release;
- widget_class->motion_notify_event = gncal_full_day_motion;
- widget_class->expose_event = gncal_full_day_expose;
- widget_class->key_press_event = gncal_full_day_key_press;
- widget_class->focus_in_event = gncal_full_day_focus_in;
- widget_class->focus_out_event = gncal_full_day_focus_out;
-
- container_class->forall = gncal_full_day_forall;
-
- class->range_activated = range_activated;
-}
-
-static void
-gncal_full_day_init (GncalFullDay *fullday)
-{
- GTK_WIDGET_UNSET_FLAGS (fullday, GTK_NO_WINDOW);
- GTK_WIDGET_SET_FLAGS (fullday, GTK_CAN_FOCUS);
-
- fullday->calendar = NULL;
-
- fullday->lower = 0;
- fullday->upper = 0;
- fullday->interval = 30; /* 30 minutes by default */
-
- fullday->children = NULL;
- fullday->drag_info = g_new0 (struct drag_info, 1);
-
- fullday->up_down_cursor = NULL;
- fullday->beam_cursor = NULL;
- fullday->recur_gc = NULL;
- fullday->bell_gc = NULL;
-}
-
-/* Destroys all the children in the full day widget */
-static void
-destroy_children (GncalFullDay *fullday)
-{
- GList *children;
-
- for (children = fullday->children; children; children = children->next)
- child_destroy (fullday, children->data);
-
- g_list_free (fullday->children);
- fullday->children = NULL;
-}
-
-static void
-gncal_full_day_destroy (GtkObject *object)
-{
- GncalFullDay *fullday;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (object));
-
- fullday = GNCAL_FULL_DAY (object);
-
- destroy_children (fullday);
-
- g_free (fullday->drag_info);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-GtkWidget *
-gncal_full_day_new (GnomeCalendar *calendar, time_t lower, time_t upper)
-{
- GncalFullDay *fullday;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- fullday = gtk_type_new (gncal_full_day_get_type ());
-
- fullday->calendar = calendar;
-
- gncal_full_day_set_bounds (fullday, lower, upper);
-
- return GTK_WIDGET (fullday);
-}
-
-static void
-gncal_full_day_map (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- gdk_window_show (widget->window);
-
- for (children = fullday->children; children; children = children->next)
- child_map (fullday, children->data);
-}
-
-static void
-gncal_full_day_unmap (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- gdk_window_hide (widget->window);
-
- for (children = fullday->children; children; children = children->next)
- child_unmap (fullday, children->data);
-}
-
-static void
-gncal_full_day_realize (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GdkWindowAttr attributes;
- gint attributes_mask;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = (gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gdk_window_set_background (widget->window, &widget->style->bg[GTK_STATE_PRELIGHT]);
-
- fullday->up_down_cursor = gdk_cursor_new (GDK_DOUBLE_ARROW);
- fullday->beam_cursor = gdk_cursor_new (GDK_XTERM);
-
- for (children = fullday->children; children; children = children->next)
- child_realize (fullday, children->data);
-
-}
-
-static void
-gncal_full_day_unrealize (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- fullday = GNCAL_FULL_DAY (widget);
-
- for (children = fullday->children; children; children = children->next)
- child_unrealize (fullday, children->data);
-
- gdk_cursor_destroy (fullday->up_down_cursor);
- fullday->up_down_cursor = NULL;
-
- gdk_cursor_destroy (fullday->beam_cursor);
- fullday->beam_cursor = NULL;
-
- if (fullday->bell_gc)
- gdk_gc_destroy (fullday->bell_gc);
- if (fullday->recur_gc)
- gdk_gc_destroy (fullday->recur_gc);
-
- if (pixmap_bell){
- gdk_pixmap_unref (pixmap_bell);
- pixmap_bell = NULL;
- }
-
- if (pixmap_recur){
- gdk_pixmap_unref (pixmap_recur);
- pixmap_recur = NULL;
- }
-
- if (GTK_WIDGET_CLASS (parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
-}
-
-struct paint_info {
- GtkWidget *widget;
- struct drag_info *di;
- GdkRectangle *area;
- int x1, y1, width, height;
- int labels_width;
- int row_height;
- struct tm start_tm;
-};
-
-static void
-paint_row (GncalFullDay *fullday, int row, struct paint_info *p)
-{
- GdkRectangle rect, dest;
- GdkGC *left_gc, *right_gc, *text_gc;
- int begin_row, end_row;
- struct tm tm;
- char buf[40];
-
- begin_row = (day_begin * 60) / fullday->interval;
- end_row = (day_end * 60) / fullday->interval;
-
- /* See which GCs we will use */
-
- if ((p->di->sel_rows_used != 0)
- && (row >= p->di->sel_start_row)
- && (row < (p->di->sel_start_row + p->di->sel_rows_used))) {
- left_gc = p->widget->style->bg_gc[GTK_STATE_SELECTED];
- right_gc = left_gc;
- text_gc = p->widget->style->fg_gc[GTK_STATE_SELECTED];
- } else if ((row < begin_row) || (row >= end_row)) {
- left_gc = p->widget->style->bg_gc[GTK_STATE_NORMAL];
- right_gc = p->widget->style->bg_gc[GTK_STATE_ACTIVE];
- text_gc = p->widget->style->fg_gc[GTK_STATE_NORMAL];
- } else {
- left_gc = p->widget->style->bg_gc[GTK_STATE_NORMAL];
- right_gc = p->widget->style->bg_gc[GTK_STATE_PRELIGHT];
- text_gc = p->widget->style->fg_gc[GTK_STATE_NORMAL];
- }
-
- /* Left background and text */
-
- rect.x = p->x1;
- rect.y = p->y1 + row * p->row_height;
- rect.width = 2 * TEXT_BORDER + p->labels_width;
- rect.height = p->row_height - 1;
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest)) {
- gdk_draw_rectangle (p->widget->window,
- left_gc,
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- tm = p->start_tm;
- tm.tm_min += row * fullday->interval;
- mktime (&tm);
-
- if (am_pm_flag)
- strftime (buf, sizeof (buf), "%I:%M%p", &tm);
- else
- strftime (buf, sizeof (buf), "%H:%M", &tm);
-
- gdk_draw_string (p->widget->window,
- p->widget->style->font,
- text_gc,
- rect.x + TEXT_BORDER,
- rect.y + TEXT_BORDER + p->widget->style->font->ascent,
- buf);
- }
-
- /* Right background */
-
- rect.x += rect.width + p->widget->style->klass->xthickness;
- rect.width = p->width - (rect.x - p->x1);
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest))
- gdk_draw_rectangle (p->widget->window,
- right_gc,
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- /* Horizontal division at bottom of row */
-
- rect.x = p->x1;
- rect.y += rect.height;
- rect.width = p->width;
- rect.height = 1;
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest))
- gdk_draw_line (p->widget->window,
- p->widget->style->black_gc,
- rect.x, rect.y,
- rect.x + rect.width - 1, rect.y);
-}
-
-static void
-paint_back (GncalFullDay *fullday, GdkRectangle *area)
-{
- struct paint_info p;
- int start_row, end_row;
- int i;
- GdkRectangle rect, dest, aarea;
- int f_rows;
- int draw_focus;
-
- p.widget = GTK_WIDGET (fullday);
- p.di = fullday->drag_info;
-
- if (!area) {
- area = &aarea;
-
- area->x = 0;
- area->y = 0;
- area->width = p.widget->allocation.width;
- area->height = p.widget->allocation.height;
- }
- p.area = area;
-
- p.x1 = p.widget->style->klass->xthickness;
- p.y1 = p.widget->style->klass->ythickness;
- p.width = p.widget->allocation.width - 2 * p.x1;
- p.height = p.widget->allocation.height - 2 * p.y1;
-
- p.labels_width = calc_labels_width (fullday);
- p.row_height = calc_row_height (fullday);
- get_tm_range (fullday, fullday->lower, fullday->upper, &p.start_tm, NULL, NULL, &f_rows);
-
- /* Frame shadow */
-
- rect.x = 0;
- rect.y = 0;
- rect.width = p.widget->allocation.width;
- rect.height = p.widget->style->klass->ythickness;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
-
- if (!draw_focus) {
- rect.y = p.widget->allocation.height - rect.height;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (!draw_focus) {
- rect.y = p.widget->style->klass->ythickness;
- rect.width = p.widget->style->klass->xthickness;
- rect.height = p.widget->allocation.height - 2 * rect.y;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (!draw_focus) {
- rect.x = p.widget->allocation.width - rect.width;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (draw_focus)
- gtk_widget_draw_focus (p.widget);
-
- /* Rows */
-
- start_row = (area->y - p.y1) / p.row_height;
- end_row = (area->y + area->height - 1 - p.y1) / p.row_height;
-
- if (end_row >= f_rows)
- end_row = f_rows - 1;
-
- for (i = start_row; i <= end_row; i++)
- paint_row (fullday, i, &p);
-
- /* Slack area at bottom of widget */
-
- rect.x = p.x1;
- rect.y = p.y1 + f_rows * p.row_height;
- rect.width = p.width;
- rect.height = p.height - (rect.y - p.y1);
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- gdk_draw_rectangle (p.widget->window,
- p.widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- /* Vertical division */
-
- rect.x = p.x1 + 2 * TEXT_BORDER + p.labels_width;
- rect.y = p.y1;
- rect.width = p.widget->style->klass->xthickness;
- rect.height = p.height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- gtk_draw_vline (p.widget->style, p.widget->window,
- GTK_STATE_NORMAL,
- rect.y,
- rect.y + rect.height - 1,
- rect.x);
-}
-
-static void
-paint_back_rows (GncalFullDay *fullday, int start_row, int rows_used)
-{
- int row_height;
- int xthickness, ythickness;
- GtkWidget *widget;
- GdkRectangle area;
-
- widget = GTK_WIDGET (fullday);
-
- row_height = calc_row_height (fullday);
-
- xthickness = widget->style->klass->xthickness;
- ythickness = widget->style->klass->ythickness;
-
- area.x = xthickness;
- area.y = ythickness + start_row * row_height;
- area.width = widget->allocation.width - 2 * xthickness;
- area.height = rows_used * row_height;
-
- paint_back (fullday, &area);
-}
-
-static void
-gncal_full_day_draw (GtkWidget *widget, GdkRectangle *area)
-{
- GncalFullDay *fullday;
- GList *children;
- Child *child;
- GdkRectangle rect, dest;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (area != NULL);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- paint_back (fullday, area);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- rect.x = child->x;
- rect.y = child->y;
- rect.width = child->width;
- rect.height = child->height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest)) {
- child_draw (fullday, child, NULL, NULL, TRUE);
- }
- }
-}
-
-static void
-gncal_full_day_draw_focus (GtkWidget *widget)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return;
-
- gtk_draw_shadow (widget->style, widget->window,
- GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
-
- if (GTK_WIDGET_HAS_FOCUS (widget))
- gdk_draw_rectangle (widget->window,
- widget->style->black_gc,
- FALSE,
- 0, 0,
- widget->allocation.width - 1,
- widget->allocation.height - 1);
-}
-
-static void
-gncal_full_day_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- GncalFullDay *fullday;
- int labels_width;
- int rows;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (requisition != NULL);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- /* Border and min width */
-
- labels_width = calc_labels_width (fullday);
-
- requisition->width = 2 * widget->style->klass->xthickness + 4 * TEXT_BORDER + labels_width + MIN_WIDTH;
- requisition->height = 2 * widget->style->klass->ythickness;
-
- /* Rows */
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &rows);
-
- requisition->height += (rows * (2 * TEXT_BORDER + widget->style->font->ascent + widget->style->font->descent)
- + (rows - 1)); /* division lines */
-}
-
-static void
-gncal_full_day_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- GncalFullDay *fullday;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (allocation != NULL);
-
- widget->allocation = *allocation;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- if (GTK_WIDGET_REALIZED (widget))
- gdk_window_move_resize (widget->window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
-
- layout_children (fullday);
-}
-
-static Child *
-find_child_by_window (GncalFullDay *fullday, GdkWindow *window, int *on_text)
-{
- GList *children;
- Child *child;
- GtkWidget *owner;
-
- *on_text = FALSE;
-
- gdk_window_get_user_data (window, (gpointer *) &owner);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->window == window || child->decor_window == window)
- return child;
-
- if (child->widget == owner) {
- *on_text = TRUE;
- return child;
- }
- }
-
- return NULL;
-}
-
-static void
-draw_xor_rect (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- struct drag_info *di;
- int i;
- int row_height;
- int ythickness;
-
- widget = GTK_WIDGET (fullday);
-
- gdk_gc_set_function (widget->style->white_gc, GDK_INVERT);
- gdk_gc_set_subwindow (widget->style->white_gc, GDK_INCLUDE_INFERIORS);
-
- ythickness = widget->style->klass->ythickness;
-
- di = fullday->drag_info;
-
- row_height = calc_row_height (fullday);
-
- for (i = 0; i < XOR_RECT_WIDTH; i++)
- gdk_draw_rectangle (widget->window,
- widget->style->white_gc,
- FALSE,
- di->child->x + i,
- di->child_start_row * row_height + ythickness + i,
- di->child->width - 2 * i - 1,
- di->child_rows_used * row_height - 2 - 2 * i);
-
- gdk_gc_set_function (widget->style->white_gc, GDK_COPY);
- gdk_gc_set_subwindow (widget->style->white_gc, GDK_CLIP_BY_CHILDREN);
-}
-
-static int
-get_row_from_y (GncalFullDay *fullday, int y, int round)
-{
- GtkWidget *widget;
- int row_height;
- int f_rows;
- int ythickness;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- row_height = calc_row_height (fullday);
-
- widget = GTK_WIDGET (fullday);
-
- ythickness = widget->style->klass->ythickness;
-
- y -= ythickness;
-
- if (y < 0)
- y = 0;
- else if (y >= (f_rows * row_height))
- y = f_rows * row_height - 1;
-
- if (round)
- y += row_height / 2;
-
- y /= row_height;
-
- if (y > f_rows)
- y = f_rows; /* note that this is 1 more than the last row's index */
-
- return y;
-}
-
-static int
-button_1 (GncalFullDay *fullday, GdkEventButton *event)
-{
- GtkWidget *widget;
- Child *child;
- int on_text;
- struct drag_info *di;
- gint y;
- int row_height;
- int has_focus;
- int old_start_row, old_rows_used;
- int old_max;
- int paint_start_row, paint_rows_used;
-
- widget = GTK_WIDGET (fullday);
-
- if (event->window == widget->window) {
- /* Clicked on main window */
-
- if (!GTK_WIDGET_HAS_FOCUS (widget))
- gtk_widget_grab_focus (widget);
-
- /* Prepare for drag */
-
- di = fullday->drag_info;
-
- di->drag_mode = DRAG_SELECT;
-
- old_start_row = di->sel_start_row;
- old_rows_used = di->sel_rows_used;
-
- di->sel_click_row = get_row_from_y (fullday, event->y, FALSE);
- di->sel_start_row = di->sel_click_row;
- di->sel_rows_used = 1;
-
- di->click_time = event->time;
-
- gdk_pointer_grab (widget->window, FALSE,
- (GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_BUTTON_RELEASE_MASK),
- NULL,
- fullday->up_down_cursor,
- event->time);
-
- if (old_rows_used == 0) {
- paint_start_row = di->sel_start_row;
- paint_rows_used = di->sel_rows_used;
- } else {
- paint_start_row = MIN (old_start_row, di->sel_start_row);
- old_max = old_start_row + old_rows_used - 1;
- paint_rows_used = MAX (old_max, di->sel_start_row) - paint_start_row + 1;
- }
-
- paint_back_rows (fullday, paint_start_row, paint_rows_used);
-
- return TRUE;
- } else {
- /* Clicked on a child? */
-
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (!child || on_text || child->ico->recur)
- return FALSE;
-
- /* Prepare for drag */
-
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- if (has_focus) {
- if (event->y < HANDLE_SIZE)
- di->drag_mode = DRAG_SIZE_TOP;
- else if (event->y >= (child->height - HANDLE_SIZE))
- di->drag_mode = DRAG_SIZE_BOTTOM;
- else
- di->drag_mode = DRAG_MOVE;
- } else
- di->drag_mode = DRAG_MOVE;
-
- row_height = calc_row_height (fullday);
-
- di->child = child;
-
- di->child_click_y = event->y;
- di->child_start_row = child->lower_row;
- di->child_rows_used = child->rows_used;
-
- gdk_pointer_grab (child->window, FALSE,
- (GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_BUTTON_RELEASE_MASK),
- NULL,
- fullday->up_down_cursor,
- event->time);
-
- draw_xor_rect (fullday);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static int
-button_3 (GncalFullDay *fullday, GdkEventButton *event)
-{
- static struct menu_item main_items[] = {
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- GtkWidget *widget;
- Child *child;
- int on_text;
-
- widget = GTK_WIDGET (fullday);
-
- if (event->window == widget->window) {
- /* Clicked on main window */
-
- if (!GTK_WIDGET_HAS_FOCUS (widget))
- gtk_widget_grab_focus (widget);
-
- main_items[0].data = fullday;
-
- popup_menu (main_items, sizeof (main_items) / sizeof (main_items[0]), event);
-
- return TRUE;
- } else {
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (!child || on_text)
- return FALSE;
-
- child_popup_menu (fullday, child, event);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- GncalFullDay *fullday;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- switch (event->button) {
- case 1:
- return button_1 (fullday, event);
-
- case 3:
- return button_3 (fullday, event);
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-static void
-recompute_motion (GncalFullDay *fullday, int y)
-{
- struct drag_info *di;
- int f_rows;
- int row;
- int has_focus;
-
- di = fullday->drag_info;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- switch (di->drag_mode) {
- case DRAG_SELECT:
- row = get_row_from_y (fullday, y, FALSE);
-
- if (row >= f_rows)
- row = f_rows - 1;
-
- if (row < di->sel_click_row) {
- di->sel_start_row = row;
- di->sel_rows_used = di->sel_click_row - row + 1;
- } else {
- di->sel_start_row = di->sel_click_row;
- di->sel_rows_used = row - di->sel_start_row + 1;
- }
-
- break;
-
- case DRAG_MOVE:
- has_focus = GTK_WIDGET_HAS_FOCUS (di->child->widget);
-
- if (has_focus)
- child_focus_out (di->child->widget, NULL, di->child);
-
- row = get_row_from_y (fullday, y - di->child_click_y + (has_focus ? HANDLE_SIZE : 0), TRUE);
-
- if (row > (f_rows - di->child_rows_used))
- row = f_rows - di->child_rows_used;
-
- di->child_start_row = row;
-
- break;
-
- case DRAG_SIZE_TOP:
- has_focus = GTK_WIDGET_HAS_FOCUS (di->child->widget);
-
- if (has_focus)
- child_focus_out (di->child->widget, NULL, di->child);
-
- row = get_row_from_y (fullday, y + HANDLE_SIZE, TRUE);
-
- if (row > (di->child_start_row + di->child_rows_used - 1))
- row = di->child_start_row + di->child_rows_used - 1;
-
- di->child_rows_used = (di->child_start_row + di->child_rows_used) - row;
- di->child_start_row = row;
-
- break;
-
- case DRAG_SIZE_BOTTOM:
- has_focus = GTK_WIDGET_HAS_FOCUS (di->child->widget);
-
- if (has_focus)
- child_focus_out (di->child->widget, NULL, di->child);
-
- row = get_row_from_y (fullday, y - HANDLE_SIZE, TRUE);
-
- if (row <= di->child_start_row)
- row = di->child_start_row + 1;
- else if (row > f_rows)
- row = f_rows;
-
- di->child_rows_used = row - di->child_start_row;
-
- break;
-
- default:
- g_assert_not_reached ();
- }
-}
-
-static void
-get_time_from_rows (GncalFullDay *fullday, int start_row, int rows_used, time_t *t_lower, time_t *t_upper)
-{
- struct tm tm;
- int row_height;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, NULL);
-
- row_height = calc_row_height (fullday);
-
- tm.tm_min += fullday->interval * start_row;
- *t_lower = mktime (&tm);
-
- tm.tm_min += fullday->interval * rows_used;
- *t_upper = mktime (&tm);
-}
-
-static void
-update_from_drag_info (GncalFullDay *fullday)
-{
- struct drag_info *di;
- GtkWidget *widget;
-
- di = fullday->drag_info;
-
- widget = GTK_WIDGET (fullday);
-
- get_time_from_rows (fullday, di->child_start_row, di->child_rows_used,
- &di->child->ico->dtstart,
- &di->child->ico->dtend);
-
- child_range_changed (fullday, di->child);
-
- /* Notify calendar of change */
-
- gnome_calendar_object_changed (fullday->calendar, di->child->ico, CHANGE_DATES);
- save_default_calendar (fullday->calendar);
-}
-
-static gint
-gncal_full_day_button_release (GtkWidget *widget, GdkEventButton *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- gint y;
- int retval;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- retval = FALSE;
-
- switch (di->drag_mode) {
- case DRAG_NONE:
- break;
-
- case DRAG_SELECT:
- if ((event->time - di->click_time) < UNSELECT_TIMEOUT)
- di->sel_rows_used = 0;
- else
- recompute_motion (fullday, y);
-
- gdk_pointer_ungrab (event->time);
-
- paint_back_rows (fullday, di->sel_start_row, MAX (di->sel_rows_used, 1));
-
- retval = TRUE;
- break;
-
- case DRAG_MOVE:
- case DRAG_SIZE_TOP:
- case DRAG_SIZE_BOTTOM:
- draw_xor_rect (fullday);
- recompute_motion (fullday, y);
- gdk_pointer_ungrab (event->time);
-
- update_from_drag_info (fullday);
-
- di->child_rows_used = 0;
-
- retval = TRUE;
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- di->drag_mode = DRAG_NONE;
- di->child = NULL;
-
- return retval;
-}
-
-static gint
-gncal_full_day_motion (GtkWidget *widget, GdkEventMotion *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- gint y;
- int old_min, old_max;
- int new_min, new_max;
- int new_start_row, new_rows_used;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- switch (di->drag_mode) {
- case DRAG_NONE:
- break;
-
- case DRAG_SELECT:
- old_min = di->sel_start_row;
- old_max = di->sel_start_row + di->sel_rows_used - 1;
-
- recompute_motion (fullday, y);
-
- new_min = di->sel_start_row;
- new_max = di->sel_start_row + di->sel_rows_used - 1;
-
- new_start_row = MIN (old_min, new_min);
- new_rows_used = MAX (old_max, new_max) - new_start_row + 1;
-
- paint_back_rows (fullday, new_start_row, new_rows_used);
-
- return TRUE;
-
- case DRAG_MOVE:
- case DRAG_SIZE_TOP:
- case DRAG_SIZE_BOTTOM:
- draw_xor_rect (fullday);
- recompute_motion (fullday, y);
- draw_xor_rect (fullday);
-
- return TRUE;
-
- default:
- g_assert_not_reached ();
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- GncalFullDay *fullday;
- Child *child;
- int on_text;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return FALSE;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- if (event->window == widget->window)
- paint_back (fullday, &event->area);
- else {
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (child && !on_text)
- child_draw (fullday, child, &event->area, event->window, FALSE);
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_key_press (GtkWidget *widget, GdkEventKey *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- GList *children;
- Child *child;
- gint pos;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- di = fullday->drag_info;
-
- if (di->sel_rows_used == 0)
- return FALSE;
-
- if (event->keyval == GDK_Return) {
- gtk_signal_emit (GTK_OBJECT (fullday), fullday_signals[RANGE_ACTIVATED]);
- return TRUE;
- }
-
- /*
- * If a non-printable key was pressed, bail. Otherwise, begin
- * editing the appointment.
- */
- if ((event->keyval < 0x20) || (event->keyval > 0xFF)
- || (event->length == 0) || (event->state & GDK_CONTROL_MASK)
- || (event->state & GDK_MOD1_MASK))
- return FALSE;
-
- gtk_signal_emit (GTK_OBJECT (fullday),
- fullday_signals[RANGE_ACTIVATED]);
-
- /*
- * Find the new child, which should hopefully be focused, and
- * insert the keypress.
- */
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (GTK_WIDGET_HAS_FOCUS (child->widget)) {
- pos = gtk_text_get_length (GTK_TEXT (child->widget));
-
- gtk_editable_insert_text (GTK_EDITABLE (child->widget),
- event->string,
- event->length,
- &pos);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_focus_in (GtkWidget *widget, GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
- gtk_widget_draw_focus (widget);
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_focus_out (GtkWidget *widget, GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
- gtk_widget_draw_focus (widget);
-
- return FALSE;
-}
-
-static void
-gncal_full_day_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data)
-{
- GncalFullDay *fullday;
- GList *children;
- Child *child;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (container));
- g_return_if_fail (callback != NULL);
-
- fullday = GNCAL_FULL_DAY (container);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- (*callback) (child->widget, callback_data);
- }
-}
-
-static gint
-child_compare (gconstpointer a, gconstpointer b)
-{
- const Child *ca = a;
- const Child *cb = b;
- time_t diff;
-
- diff = ca->start - cb->start;
-
- if (diff == 0)
- diff = cb->end - ca->end;
-
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-static int
-fullday_add_children (iCalObject *obj, time_t start, time_t end, void *c)
-{
- GncalFullDay *fullday = c;
- Child *child;
-
- child = child_new (fullday, start, end, obj);
- fullday->children = g_list_insert_sorted (fullday->children, child, child_compare);
-
- return 1;
-}
-
-void
-gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags)
-{
- GList *children;
- Child *child;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- if (!fullday->calendar->cal)
- return;
-
- /* Try to find child that changed */
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->ico == ico)
- break;
- }
-
- /* If child was found and nothing but the summary changed, we can just paint the child and return */
-
- if (children && !(flags & ~CHANGE_SUMMARY)) {
- child_draw (fullday, child, NULL, NULL, TRUE);
- return;
- }
-
- /* We have to regenerate and layout our list of children */
-
- destroy_children (fullday);
-
- calendar_iterate (fullday->calendar->cal,
- fullday->lower,
- fullday->upper,
- fullday_add_children,
- fullday);
-
- layout_children (fullday);
-
- /* Realize and map children */
-
- for (children = fullday->children; children; children = children->next) {
- if (GTK_WIDGET_REALIZED (fullday))
- child_realize (fullday, children->data);
-
- if (GTK_WIDGET_MAPPED (fullday))
- child_map (fullday, children->data);
- }
-
- gtk_widget_draw (GTK_WIDGET (fullday), NULL);
-}
-
-void
-gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper)
-{
- struct drag_info *di;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- if ((lower != fullday->lower) || (upper != fullday->upper)) {
- fullday->lower = lower;
- fullday->upper = upper;
-
- di = fullday->drag_info;
-
- di->sel_rows_used = 0; /* clear selection */
-
- gncal_full_day_update (fullday, NULL, 0);
- }
-}
-
-int
-gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper)
-{
- struct drag_info *di;
- time_t alower, aupper;
-
- g_return_val_if_fail (fullday != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (fullday), FALSE);
-
- di = fullday->drag_info;
-
- if (di->sel_rows_used == 0){
- time_t now = time (NULL);
- struct tm tm = *localtime (&now);
- struct tm thisd = *localtime (&fullday->lower);
-
- thisd.tm_hour = tm.tm_hour;
- thisd.tm_min = tm.tm_min;
- thisd.tm_sec = 0;
- *lower = mktime (&thisd);
- thisd.tm_hour++;
- *upper = mktime (&thisd);
- return FALSE;
- }
-
- get_time_from_rows (fullday, di->sel_start_row, di->sel_rows_used, &alower, &aupper);
-
- if (lower)
- *lower = alower;
-
- if (upper)
- *upper= aupper;
-
- return TRUE;
-}
-
-void
-gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico)
-{
- GList *children;
- Child *child;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (ico != NULL);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->ico == ico) {
- gtk_widget_grab_focus (child->widget);
- break;
- }
- }
-}
-
-int
-gncal_full_day_get_day_start_yoffset (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- int begin_row;
-
- g_return_val_if_fail (fullday != NULL, 0);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (fullday), 0);
-
- widget = GTK_WIDGET (fullday);
-
- begin_row = (day_begin * 60) / fullday->interval;
-
- return widget->style->klass->ythickness + begin_row * calc_row_height (fullday);
-}
-
-static void
-range_activated (GncalFullDay *fullday)
-{
- struct drag_info *di;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- di = fullday->drag_info;
-
- /* Remove selection; at this point someone should already have added an appointment */
-
- di->sel_rows_used = 0;
-
- paint_back (fullday, NULL);
-}
diff --git a/calendar/gncal-full-day.h b/calendar/gncal-full-day.h
deleted file mode 100644
index 287c5f63f6..0000000000
--- a/calendar/gncal-full-day.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Full day widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_FULL_DAY_H
-#define GNCAL_FULL_DAY_H
-
-
-#include <gtk/gtkcontainer.h>
-#include <libgnome/gnome-defs.h>
-#include "calendar.h"
-#include "gnome-cal.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_FULL_DAY(obj) GTK_CHECK_CAST (obj, gncal_full_day_get_type (), GncalFullDay)
-#define GNCAL_FULL_DAY_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_full_day_get_type (), GncalFullDayClass)
-#define GNCAL_IS_FULL_DAY(obj) GTK_CHECK_TYPE (obj, gncal_full_day_get_type ())
-
-
-typedef struct _GncalFullDay GncalFullDay;
-typedef struct _GncalFullDayClass GncalFullDayClass;
-
-struct _GncalFullDay {
- GtkContainer container;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- time_t lower; /* lower time to display */
- time_t upper; /* upper time to display */
- int interval; /* interval between rows in minutes */
-
- GList *children; /* container children */
- gpointer drag_info; /* internal drag information */
-
- GdkCursor *up_down_cursor; /* for dragging children */
- GdkCursor *beam_cursor; /* for the text widgets */
- GdkGC *recur_gc; /* The gc used to draw the recur image */
- GdkGC *bell_gc; /* The gc used to draw on imlib windows */
-
-};
-
-struct _GncalFullDayClass {
- GtkContainerClass parent_class;
-
- void (* range_activated) (GncalFullDay *fullday);
-};
-
-
-guint gncal_full_day_get_type (void);
-GtkWidget *gncal_full_day_new (GnomeCalendar *calendar, time_t lower, time_t upper);
-
-void gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags);
-void gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper);
-
-/* Returns the selected range in lower and upper. If nothing is
- * selected, return value is FALSE, otherwise it is TRUE.
- * The lower and upper values are always set to proper values, regardless of
- * the selection value
- */
-int gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper);
-
-void gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico);
-
-int gncal_full_day_get_day_start_yoffset (GncalFullDay *fullday);
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gncal-todo.c b/calendar/gncal-todo.c
deleted file mode 100644
index 3be3ac4517..0000000000
--- a/calendar/gncal-todo.c
+++ /dev/null
@@ -1,877 +0,0 @@
-/* To-do widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#include <config.h>
-#include <string.h>
-#include <gnome.h>
-#include "gncal-todo.h"
-#include "main.h"
-#include "popup-menu.h"
-#include "eventedit.h"
-
-int todo_show_due_date = 0;
-int todo_show_priority = 0;
-int todo_show_time_remaining = 0;
-
-int todo_item_dstatus_highlight_overdue = 0;
-int todo_item_dstatus_highlight_due_today = 0;
-int todo_item_dstatus_highlight_not_due_yet = 0;
-
-
-char *todo_overdue_font_text;
-gint todo_current_sort_column = 0;
-gint todo_current_sort_type = GTK_SORT_ASCENDING;
-
-gboolean todo_style_changed =0;
-gboolean todo_list_autoresize = 1;
-gboolean todo_list_redraw_in_progess = 0;
-static void gncal_todo_init (GncalTodo *todo);
-
-
-guint
-gncal_todo_get_type (void)
-{
- static guint todo_type = 0;
-
- if (!todo_type) {
- GtkTypeInfo todo_info = {
- "GncalTodo",
- sizeof (GncalTodo),
- sizeof (GncalTodoClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) gncal_todo_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- todo_type = gtk_type_unique (gtk_vbox_get_type (), &todo_info);
- }
-
- return todo_type;
-}
-
-static void
-ok_button (GtkWidget *widget, GnomeDialog *dialog)
-{
- iCalObject *ico;
- GncalTodo *todo;
- GtkEntry *entry;
- GnomeDateEdit *due_date;
- GtkText *comment;
- GtkSpinButton *priority;
-
- ico = gtk_object_get_user_data (GTK_OBJECT (dialog));
-
- todo = GNCAL_TODO (gtk_object_get_data (GTK_OBJECT (dialog), "gncal_todo"));
- entry = GTK_ENTRY (gtk_object_get_data (GTK_OBJECT (dialog), "summary_entry"));
- due_date = GNOME_DATE_EDIT (gtk_object_get_data(GTK_OBJECT(dialog), "due_date"));
- priority = GTK_SPIN_BUTTON (gtk_object_get_data(GTK_OBJECT(dialog), "priority"));
- comment = GTK_TEXT(gtk_object_get_data (GTK_OBJECT(dialog), "comment"));
- if (ico->summary)
- g_free (ico->summary);
- if (ico->comment)
- g_free (ico->comment);
- ico->dtend = gnome_date_edit_get_date (due_date);
- ico->summary = g_strdup (gtk_entry_get_text (entry));
- ico->priority = gtk_spin_button_get_value_as_int (priority);
- ico->comment = gtk_editable_get_chars( GTK_EDITABLE(comment), 0, -1);
- ico->user_data = NULL;
-
- if (ico->new) {
- gnome_calendar_add_object (todo->calendar, ico);
- ico->new = FALSE;
- } else
- gnome_calendar_object_changed (todo->calendar, ico, CHANGE_ALL); /* ok, summary only... */
-
- save_default_calendar (todo->calendar);
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-
-static void
-cancel_button (GtkWidget *widget, GnomeDialog *dialog)
-{
- iCalObject *ico;
-
- ico = gtk_object_get_user_data (GTK_OBJECT (dialog));
-
- ico->user_data = NULL;
-
- if (ico->new)
- ical_object_destroy (ico);
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
-
-
-}
-
-static gint
-delete_event (GtkWidget *widget, GdkEvent *event, GnomeDialog *dialog)
-{
- cancel_button (NULL, dialog);
- return TRUE;
-}
-
-static void
-simple_todo_editor (GncalTodo *todo, iCalObject *ico)
-{
- GtkWidget *dialog;
- GtkWidget *hbox;
- GtkWidget *due_box;
- GtkWidget *due_label;
- GtkWidget *due_entry;
- GtkWidget *comment_box;
- GtkWidget *comment_label;
- GtkWidget *comment_text;
- GtkWidget *comment_internal_box;
- GtkWidget *comment_sep;
- GtkWidget *w;
- GtkWidget *pri_box;
- GtkWidget *pri_label;
- GtkWidget *pri_spin;
- GtkObject *pri_adj;
-
- GtkWidget *entry;
-
- dialog = gnome_dialog_new (ico->new ? _("Create to-do item") : _("Edit to-do item"),
- GNOME_STOCK_BUTTON_OK,
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
- gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (todo->calendar));
- hbox = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
-
- due_box = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (due_box), 4);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), due_box, FALSE, FALSE, 0);
- gtk_widget_show (due_box);
-
- pri_box = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (pri_box), 4);
- gtk_box_pack_start(GTK_BOX (GNOME_DIALOG (dialog)->vbox), pri_box, FALSE, FALSE, 0);
- gtk_widget_show (pri_box);
-
- comment_box = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (comment_box), 4);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), comment_box, FALSE, FALSE, 0);
- gtk_widget_show (comment_box);
-
- comment_internal_box = gtk_vbox_new(FALSE,2);
- gtk_container_border_width (GTK_CONTAINER (comment_internal_box), 4);
-
- gtk_box_pack_start (GTK_BOX (comment_box), comment_internal_box, TRUE, TRUE, 0);
- gtk_widget_show (comment_internal_box);
-
- w = gtk_label_new (_("Summary:"));
- gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- entry = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY (entry), ico->summary);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- gtk_widget_show (entry);
-
-
- due_label = gtk_label_new (_("Due Date:"));
- gtk_box_pack_start (GTK_BOX (due_box), due_label, FALSE, FALSE, 0);
- gtk_widget_show (due_label);
-
- due_entry = gtk_entry_new ();
- due_entry = date_edit_new (ico->dtend, TRUE);
- gtk_box_pack_start (GTK_BOX (due_box), due_entry, TRUE, TRUE, 0);
- gtk_widget_show (due_entry);
-
- pri_label = gtk_label_new (_("Priority:"));
- gtk_box_pack_start (GTK_BOX (pri_box), pri_label, FALSE, FALSE, 0);
- gtk_widget_show (pri_label);
-
- pri_adj = gtk_adjustment_new (5.0, 1.0, 9.0, 1.0, 3.0, 0.0);
- pri_spin = gtk_spin_button_new (GTK_ADJUSTMENT(pri_adj), 0.0, 0);
- gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (pri_spin), TRUE);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (pri_spin), FALSE);
- gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (pri_spin), FALSE);
- gtk_box_pack_start (GTK_BOX (pri_box), pri_spin, FALSE, FALSE, 0);
- gtk_widget_show (pri_spin);
-
- comment_sep = gtk_hseparator_new ();
- gtk_box_pack_start (GTK_BOX (comment_box), comment_sep, FALSE, FALSE, 0);
- gtk_widget_show(comment_sep);
-
- comment_label = gtk_label_new (_("Item Comments:"));
- gtk_label_set_justify(GTK_LABEL(comment_label), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start (GTK_BOX (comment_internal_box), comment_label, TRUE, TRUE, 0);
- gtk_widget_show (comment_label);
-
-
-
-
- comment_text = gtk_text_new (NULL, NULL);
- gtk_text_set_editable (GTK_TEXT (comment_text), TRUE);
- gtk_text_set_word_wrap( GTK_TEXT(comment_text), TRUE);
- gtk_text_freeze(GTK_TEXT(comment_text));
- if(ico->comment) {
- gtk_text_insert(GTK_TEXT(comment_text), NULL, NULL, NULL, ico->comment, strlen(ico->comment));
- }
- gtk_text_thaw(GTK_TEXT(comment_text));
- gtk_box_pack_start (GTK_BOX (comment_internal_box), comment_text, FALSE, TRUE, 0);
- gtk_widget_show (comment_text);
-
- ico->user_data = dialog;
-
- gtk_object_set_user_data (GTK_OBJECT (dialog), ico);
-
- gtk_object_set_data (GTK_OBJECT (dialog), "gncal_todo", todo);
- gtk_object_set_data (GTK_OBJECT (dialog), "summary_entry", entry);
- gtk_object_set_data (GTK_OBJECT (dialog), "due_date", due_entry);
- gtk_object_set_data (GTK_OBJECT (dialog), "priority", pri_spin);
- gtk_object_set_data (GTK_OBJECT (dialog), "comment", comment_text);
-
- gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0, (GtkSignalFunc) ok_button, dialog);
- gnome_dialog_button_connect (GNOME_DIALOG (dialog), 1, (GtkSignalFunc) cancel_button, dialog);
-
- gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
- (GtkSignalFunc) delete_event,
- dialog);
-
- gnome_dialog_set_default (GNOME_DIALOG (dialog), 0);
- gnome_dialog_editable_enters (GNOME_DIALOG (dialog), GTK_EDITABLE(entry));
-
- gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
- gtk_widget_show (dialog);
- gtk_widget_grab_focus (entry);
-}
-
-static iCalObject *
-get_clist_selected_ico (GtkCList *clist)
-{
- gint sel;
-
- if (!clist->selection)
- return NULL;
-
- sel = GPOINTER_TO_INT(clist->selection->data);
-
- return gtk_clist_get_row_data (clist, sel);
-}
-
-static void
-add_todo (GncalTodo *todo)
-{
- iCalObject *ico;
-
- ico = ical_new ("", user_name, "");
- ico->type = ICAL_TODO;
- ico->new = TRUE;
-
- simple_todo_editor (todo, ico);
-}
-
-static void
-edit_todo (GncalTodo *todo)
-{
- simple_todo_editor (todo, get_clist_selected_ico (todo->clist));
-}
-
-static void
-delete_todo (GncalTodo *todo)
-{
- gnome_calendar_remove_object (todo->calendar, get_clist_selected_ico (todo->clist));
- save_default_calendar (todo->calendar);
-
-}
-
-static void
-add_activated (GtkWidget *widget, GncalTodo *todo)
-{
- GtkWidget *w;
-
- while ((w = gtk_grab_get_current ()) != NULL)
- gtk_grab_remove (w);
-
- add_todo (todo);
-}
-
-static void
-edit_activated (GtkWidget *widget, GncalTodo *todo)
-{
- GtkWidget *w;
-
- while ((w = gtk_grab_get_current ()) != NULL)
- gtk_grab_remove (w);
-
- edit_todo (todo);
-}
-
-static void
-delete_activated (GtkWidget *widget, GncalTodo *todo)
-{
- delete_todo (todo);
-}
-
-
-static void
-clist_row_selected (GtkCList *clist, gint row, gint column, GdkEventButton *event, GncalTodo *todo)
-{
- static struct menu_item items[] = {
- { N_("Add to-do item..."), (GtkSignalFunc) add_activated, NULL, TRUE },
- { N_("Edit this item..."), (GtkSignalFunc) edit_activated, NULL, TRUE },
- { N_("Delete this item"), (GtkSignalFunc) delete_activated, NULL, TRUE }
- };
-
- int i;
-
- gtk_widget_set_sensitive (todo->edit_button, (todo->clist->selection != NULL));
- gtk_widget_set_sensitive (todo->delete_button, (todo->clist->selection != NULL));
-
- if (!event)
- return;
-
- switch (event->button) {
- case 1:
- if (event->type == GDK_2BUTTON_PRESS)
- edit_todo (todo);
- break;
-
- case 3:
- for (i = 0; i < (sizeof (items) / sizeof (items[0])); i++)
- items[i].data = todo;
-
- popup_menu (items, sizeof (items) / sizeof (items[0]), event);
- break;
-
- default:
- break;
- }
-}
-
-/*
- * once we get a call back stating that a column
- * has been resized never ever automatically resize again
- */
-void
-column_resized (GtkWidget *widget, GncalTodo *todo)
-{
- /* disabling autoresize of columns */
- if (todo_list_autoresize && !todo_list_redraw_in_progess){
- todo_list_autoresize = 0;
- }
-}
-
-/*
- * restore the previously set settings for sorting the
- * todo list
- */
-static void
-init_column_sorting (GtkCList *clist)
-{
-
- /* due date isn't shown so we can't sort by it */
- if (todo_current_sort_column == 1 && ! todo_show_due_date)
- todo_current_sort_column = 0;
-
- clist->sort_type = todo_current_sort_type;
- clist->sort_column = todo_current_sort_column;
-
- gtk_clist_set_sort_column (clist, todo_current_sort_column);
- gtk_clist_sort (clist);
-}
-
-static void
-todo_click_column (GtkCList *clist, gint column, gpointer data)
-{
- if (column == clist->sort_column)
- {
- if (clist->sort_type == GTK_SORT_ASCENDING) {
- clist->sort_type = GTK_SORT_DESCENDING;
- todo_current_sort_type = GTK_SORT_DESCENDING;
- } else {
- clist->sort_type = GTK_SORT_ASCENDING;
- todo_current_sort_type = GTK_SORT_ASCENDING;
- }
- }
- else {
- gtk_clist_set_sort_column (clist, column);
- todo_current_sort_column = column;
- }
-
- gtk_clist_sort (clist);
-
- /*
- * save the sorting preferences cause I hate to have the user
- * click twice
- */
-
- gnome_config_set_int("/calendar/Todo/sort_column", todo_current_sort_column);
- gnome_config_set_int("/calendar/Todo/sort_type", todo_current_sort_type);
- gnome_config_sync();
-}
-
-static void
-gncal_todo_init (GncalTodo *todo)
-{
- GtkWidget *w;
- GtkWidget *sw;
- GtkWidget *hbox;
- gchar *titles[4] = {
- N_("Summary"),
- N_("Due Date"),
- N_("Priority"),
- N_("Time Left")
- };
- char *tmp[4];
- tmp[0] = _(titles[0]);
- tmp[1] = _(titles[1]);
- tmp[2] = _(titles[2]);
- tmp[3] = _(titles[3]);
-
- gtk_box_set_spacing (GTK_BOX (todo), 4);
-
- /* Label */
-
- w = gtk_label_new (_("To-do list"));
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (todo), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Clist */
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start (GTK_BOX (todo), sw, TRUE, TRUE, 0);
- gtk_widget_show (sw);
-
-
- w = gtk_clist_new_with_titles(4, tmp);
-
- todo->clist = GTK_CLIST (w);
- gtk_clist_set_selection_mode (todo->clist, GTK_SELECTION_BROWSE);
-
- gtk_signal_connect (GTK_OBJECT (todo->clist), "select_row",
- (GtkSignalFunc) clist_row_selected,
- todo);
- gtk_clist_set_button_actions (todo->clist, 2, GTK_BUTTON_SELECTS);
- gtk_signal_connect (GTK_OBJECT (todo->clist), "resize_column",
- (GtkSignalFunc) column_resized,
- todo);
- gtk_signal_connect (GTK_OBJECT (todo->clist), "click_column",
- (GtkSignalFunc) todo_click_column, NULL);
-
- gtk_container_add (GTK_CONTAINER (sw), w);
- gtk_widget_show (w);
-
- /* Box for buttons */
-
- hbox = gtk_hbox_new (TRUE, 4);
- gtk_box_pack_start (GTK_BOX (todo), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
- /* Add */
-
- w = gtk_button_new_with_label (_("Add..."));
- gtk_signal_connect (GTK_OBJECT (w), "clicked",
- (GtkSignalFunc) add_activated,
- todo);
- gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
- gtk_widget_show (w);
-
- /* Edit */
-
- w = gtk_button_new_with_label (_("Edit..."));
- todo->edit_button = w;
- gtk_widget_set_sensitive (w, FALSE);
- gtk_signal_connect (GTK_OBJECT (w), "clicked",
- (GtkSignalFunc) edit_activated,
- todo);
- gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
- gtk_widget_show (w);
-
- /* Delete */
-
- w = gtk_button_new_with_label (_("Delete"));
- todo->delete_button = w;
- gtk_widget_set_sensitive (w, FALSE);
- gtk_signal_connect (GTK_OBJECT (w), "clicked",
- (GtkSignalFunc) delete_activated,
- todo);
- gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
- gtk_widget_show (w);
-}
-
-GtkWidget *
-gncal_todo_new (GnomeCalendar *calendar)
-{
- GncalTodo *todo;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- todo = gtk_type_new (gncal_todo_get_type ());
-
- todo->calendar = calendar;
-
- gncal_todo_update (todo, NULL, 0);
-
- return GTK_WIDGET (todo);
-}
-
-static char *
-convert_time_t_to_char (time_t t)
-{
- char buf[100];
- struct tm tm;
-
- tm = *localtime (&t);
- strftime(buf, sizeof (buf), "%m/%d/%Y", &tm);
-
- return g_strdup (buf);
-}
-
-enum todo_styles {
- TODO_STYLE_OVERDUE,
- TODO_STYLE_DUE_TODAY,
- TODO_STYLE_NOT_DUE
-};
-
-
-enum todo_status {
- TODO_ITEM_DSTATUS_NOT_DUE_YET,
- TODO_ITEM_DSTATUS_DUE_TODAY,
- TODO_ITEM_DSTATUS_OVERDUE,
- TODO_ITEM_DSTATUS_LAST_DUE_STATUS
-};
-typedef enum todo_status todo_status;
-
-static GtkStyle *
-make_todo_style(GncalTodo *todo, todo_status style_type)
-{
- GtkStyle *style = NULL;
- GdkColor style_color;
- int color_prop = 0;
- switch(style_type) {
- case TODO_ITEM_DSTATUS_NOT_DUE_YET:
- color_prop = COLOR_PROP_TODO_NOT_DUE_YET;
- break;
- case TODO_ITEM_DSTATUS_DUE_TODAY:
- color_prop = COLOR_PROP_TODO_DUE_TODAY;
- break;
- case TODO_ITEM_DSTATUS_OVERDUE:
- color_prop = COLOR_PROP_TODO_OVERDUE;
- break;
- case TODO_ITEM_DSTATUS_LAST_DUE_STATUS:
- }
-
- style_color.red = color_props[color_prop].r;
- style_color.green = color_props[color_prop].g;
- style_color.blue = color_props[color_prop].b;
-
- style = gtk_style_copy (GTK_WIDGET (todo->clist)->style);
- style->base[GTK_STATE_NORMAL] = style_color;
- return style;
-}
-
-
-
-
-static
-todo_status todo_item_due_status(time_t *todo_due_time) {
- struct tm due_tm_time;
- struct tm current_time;
- struct tm *temp_tm;
- time_t current_time_val = time(NULL);
- temp_tm = localtime(todo_due_time);
- /* make a copy so it dosen't get over written */
- memcpy(&due_tm_time, temp_tm, sizeof(struct tm));
-
-
- temp_tm = localtime(&current_time_val);
- memcpy(&current_time, temp_tm, sizeof(struct tm));
-
- if(due_tm_time.tm_mon == current_time.tm_mon &&
- due_tm_time.tm_mday == current_time.tm_mday &&
- due_tm_time.tm_year == current_time.tm_year) {
- return TODO_ITEM_DSTATUS_DUE_TODAY;
- }
-
- if((*todo_due_time) < current_time_val) {
- return TODO_ITEM_DSTATUS_OVERDUE;
- }
-
- return TODO_ITEM_DSTATUS_NOT_DUE_YET;
-}
-
-
-enum todo_remaining_time_form {
- TODO_ITEM_REMAINING_WEEKS,
- TODO_ITEM_REMAINING_DAYS,
- TODO_ITEM_REMAINING_HOURS,
- TODO_ITEM_REMAINING_MINUTES,
- TODO_ITEM_REMAINING_SECONDS
-};
-typedef enum todo_remaining_time_form todo_remaining_time_form;
-
-static void
-insert_in_clist (GncalTodo *todo, iCalObject *ico)
-{
- int i;
- char *text[4];
- char time_remaining_buffer[100];
- time_t time_remain;
- todo_remaining_time_form time_remaining_form;
- int sec_in_week = 3600*7*24;
- int sec_in_day = 3600*24;
- int sec_in_hour = 3600;
- int sec_in_minute = 60;
- int weeks = 0;
- int days = 0;
- int hours = 0;
- int minutes = 0;
- int seconds = 0;
-
-
- /* an array for the styles of items */
- static GtkStyle *dstatus_styles[TODO_ITEM_DSTATUS_LAST_DUE_STATUS];
- /* we want to remake the styles when the status is changed,
- also we need to check for the null value in the pointer so we init them
- at startup */
- if (todo_style_changed || !dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]) {
- g_free(dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]);
- g_free(dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE]);
- g_free(dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY]);
-
- dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET] = make_todo_style(todo, TODO_ITEM_DSTATUS_NOT_DUE_YET);
- dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE] = make_todo_style(todo, TODO_ITEM_DSTATUS_OVERDUE);
- dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY] = make_todo_style(todo, TODO_ITEM_DSTATUS_DUE_TODAY);
-
- todo_style_changed = 0;
- }
-
-
-
-
-
- text[0] = ico->summary;
-
- if(todo_show_time_remaining) {
- memset(time_remaining_buffer, 0, 100);
- /* we need to make a string that represents the amount of time remaining
- before this task is due */
-
- /* for right now all I'll do is up to the hours. */
- time_remain = (ico->dtend - time(NULL));
- if(time_remain < 0) {
- text[3] = "Overdue!";
- }
- else {
-
- /* lets determine a decent denomination to display */
- if(time_remain / (sec_in_week))
- {
- /* we have weeks available */
- time_remaining_form = TODO_ITEM_REMAINING_WEEKS;
- weeks = time_remain / sec_in_week;
- days = (time_remain % (sec_in_week))/sec_in_day;
- }
- else if(time_remain / (sec_in_day))
- {
- /* we have days available */
- time_remaining_form = TODO_ITEM_REMAINING_DAYS;
- days = time_remain / sec_in_day;
- hours = (time_remain % sec_in_day)/sec_in_hour;
- }
- else if(time_remain / (sec_in_hour))
- {
- /* we have hours available */
- time_remaining_form = TODO_ITEM_REMAINING_HOURS;
- hours = time_remain /sec_in_hour;
- minutes = (time_remain % sec_in_hour) / sec_in_minute;
- }
- else if(time_remain / sec_in_minute)
- {
- time_remaining_form = TODO_ITEM_REMAINING_MINUTES;
- minutes = time_remain / sec_in_minute;
- seconds = time_remain % sec_in_minute;
- }
- else
- {
- time_remaining_form = TODO_ITEM_REMAINING_SECONDS;
- seconds = time_remain;
- }
-
- switch(time_remaining_form)
- {
- case TODO_ITEM_REMAINING_WEEKS:
- snprintf(time_remaining_buffer, 100, "%d %s %d %s", weeks,
- (weeks > 1) ? _("Weeks") : _("Week"),
- days, (days > 1) ? _("Days") : _("Day"));
- break;
- case TODO_ITEM_REMAINING_DAYS:
- snprintf(time_remaining_buffer, 100, "%d %s %d %s", days,
- (days > 1) ? _("Days") : _("Day"),
- hours, (hours > 1) ? _("Hours") : _("Hour"));
- break;
- case TODO_ITEM_REMAINING_HOURS:
- snprintf(time_remaining_buffer, 100, "%d %s %d %s", hours,
- (hours > 1) ? _("Hours") : _("Hour"),
- minutes, (minutes > 1) ? _("Minutes") : _("Minute"));
- break;
- case TODO_ITEM_REMAINING_MINUTES:
- snprintf(time_remaining_buffer, 100, "%d %s %d %s", minutes,
- (minutes > 1) ? _("Minutes") : _("Minute"),
- seconds, (seconds > 1) ? _("Seconds") : _("Second"));
- break;
- case TODO_ITEM_REMAINING_SECONDS:
- snprintf(time_remaining_buffer, 100, "%d %s", seconds,
- (seconds > 1) ? _("Seconds") : _("Second"));
- break;
- }
- text[3] = g_strdup(time_remaining_buffer);
- todo->data_ptrs = g_slist_append(todo->data_ptrs, text[3]);
- }
-
- }
- else {
- text[3] = "Loose penguini!";
- }
- /*
- * right now column 0 will be the summary
- * and column 1 will be the due date.
- * WISH: this should be able to be changed on the fly
- */
-
- if(ico->dtend && todo_show_due_date)
- {
- text[1] = convert_time_t_to_char (ico->dtend);
- /* Append the data's pointer so later it can be properly freed */
- todo->data_ptrs = g_slist_append (todo->data_ptrs, text[1]);
- }
- else
- text[1] = NULL;
-
- if(ico->priority && todo_show_priority)
- {
- text[2] = g_strdup_printf ("%d", ico->priority);
- todo->data_ptrs = g_slist_append (todo->data_ptrs, text[2]);
- }
- else
- text[2] = NULL;
-
- i = gtk_clist_append (todo->clist, text);
-
- gtk_clist_set_row_data (todo->clist, i, ico);
-
- /*
- * determine if the task is overdue..
- * if so mark with the apropriate style
- */
-
- switch(todo_item_due_status(&ico->dtend)) {
- case TODO_ITEM_DSTATUS_NOT_DUE_YET:
- if(todo_item_dstatus_highlight_not_due_yet)
- {
- gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]);
- }
- break;
- case TODO_ITEM_DSTATUS_DUE_TODAY:
- if(todo_item_dstatus_highlight_due_today)
- {
- gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY]);
- }
- break;
- case TODO_ITEM_DSTATUS_OVERDUE:
- if(todo_item_dstatus_highlight_overdue)
- {
- gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE]);
- }
- break;
- case TODO_ITEM_DSTATUS_LAST_DUE_STATUS:
- }
-
- /* keep the list in order */
- gtk_clist_sort (todo->clist);
-}
-
-void
-gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags)
-{
- GList *list;
- GSList *current_list;
-
- g_return_if_fail (todo != NULL);
- g_return_if_fail (GNCAL_IS_TODO (todo));
-
- /*
- * shut down the resize handler cause we are playing with the list.
- * In otherwords turn off the event handler
- */
- todo_list_redraw_in_progess =1;
-
- /* freeze the list */
- gtk_clist_freeze (todo->clist);
- init_column_sorting (todo->clist);
-
- /*
- * before here we have to free some of the memory that
- * stores the due date, or else we have a memory leak.
- * luckily all of the pointers are stored in todo->data_ptrs;
- */
-
- /* check on the columns that we should display */
- /* check for due date */
-
- if(todo_show_due_date) {
- gtk_clist_set_column_visibility (todo->clist, 1, 1);
- }
- else {
- gtk_clist_set_column_visibility (todo->clist, 1, 0);
- }
-
- if(todo_show_time_remaining) {
- gtk_clist_set_column_visibility (todo->clist, 3, 1);
- }
- else {
- gtk_clist_set_column_visibility (todo->clist, 3, 0);
- }
-
-
- if(todo_show_priority)
- gtk_clist_set_column_visibility (todo->clist, 2, 1);
- else
- gtk_clist_set_column_visibility (todo->clist, 2, 0);
-
- /* free the memory locations that were used in the previous display */
- for (current_list = todo->data_ptrs; current_list != NULL; current_list = g_slist_next(current_list)){
- g_free(current_list->data);
- }
-
- /* free the list and clear out the pointer */
- g_slist_free(todo->data_ptrs);
- todo->data_ptrs = NULL;
-
- gtk_clist_clear (todo->clist);
-
- for (list = todo->calendar->cal->todo; list; list = list->next)
- insert_in_clist (todo, list->data);
-
- /* if we are autoresizing then do it now */
- if(todo_list_autoresize && todo->clist->rows != 0)
- gtk_clist_columns_autosize (todo->clist);
-
- gtk_clist_thaw (todo->clist);
-
- gtk_widget_set_sensitive (todo->edit_button, (todo->clist->selection != NULL));
- gtk_widget_set_sensitive (todo->delete_button, (todo->clist->selection != NULL));
- todo_list_redraw_in_progess = 0;
-}
-
-
-
-
-
-
-
-
diff --git a/calendar/gncal-todo.h b/calendar/gncal-todo.h
deleted file mode 100644
index 51cfadea3f..0000000000
--- a/calendar/gncal-todo.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* To-do widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_TODO_H
-#define GNCAL_TODO_H
-
-#include <gtk/gtkclist.h>
-#include <gtk/gtkvbox.h>
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_TODO(obj) GTK_CHECK_CAST (obj, gncal_todo_get_type (), GncalTodo)
-#define GNCAL_TODO_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_todo_get_type (), GncalTodoClass)
-#define GNCAL_IS_TODO(obj) GTK_CHECK_TYPE (obj, gncal_todo_get_type ())
-
-
-typedef struct _GncalTodo GncalTodo;
-typedef struct _GncalTodoClass GncalTodoClass;
-
-struct _GncalTodo {
- GtkVBox vbox;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- GtkCList *clist;
-
- GtkWidget *edit_button;
- GtkWidget *delete_button;
- GSList *data_ptrs;
-
-
-};
-
-struct _GncalTodoClass {
- GtkVBoxClass parent_class;
-};
-
-
-guint gncal_todo_get_type (void);
-GtkWidget *gncal_todo_new (GnomeCalendar *calendar);
-
-void gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gncal-week-view.c b/calendar/gncal-week-view.c
deleted file mode 100644
index 888c656ff4..0000000000
--- a/calendar/gncal-week-view.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <config.h>
-#include <gnome.h>
-#include <string.h>
-#include <gtk/gtk.h>
-#include "gncal-week-view.h"
-#include "main.h"
-#include "timeutil.h"
-
-static void gncal_week_view_init (GncalWeekView *wview);
-
-
-guint
-gncal_week_view_get_type (void)
-{
- static guint week_view_type = 0;
-
- if (!week_view_type) {
- GtkTypeInfo week_view_info = {
- "GncalWeekView",
- sizeof (GncalWeekView),
- sizeof (GncalWeekViewClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) gncal_week_view_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- week_view_type = gtk_type_unique (gtk_vbox_get_type (), &week_view_info);
- }
-
- return week_view_type;
-}
-
-static void
-gncal_week_view_init (GncalWeekView *wview)
-{
- int i;
-
- wview->calendar = NULL;
- memset (&wview->start_of_week, 0, sizeof (wview->start_of_week));
-
- for (i = 0; i < 7; i++)
- wview->days[i] = NULL;
-
- wview->gtk_calendar = NULL;
-}
-
-static void
-jump_to_day (GtkCalendar *cal, GncalWeekView *wview, int day)
-{
- struct tm tm;
- time_t t;
- static int inside;
-
- if (inside)
- return;
- inside = 1;
- tm.tm_mday = day;
- tm.tm_mon = cal->month;
- tm.tm_year = cal->year - 1900;
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_isdst = -1;
- t = mktime (&tm);
-
- gncal_week_view_set (wview, t);
- inside = 0;
-}
-
-static void
-jump_to_day_click (GtkCalendar *cal, GncalWeekView *wview)
-{
- jump_to_day (cal, wview, cal->selected_day);
-}
-
-static void
-sync_week (GtkCalendar *cal, GncalWeekView *wview)
-{
- jump_to_day (cal, wview, wview->start_of_week.tm_mday + 7);
- gnome_calendar_tag_calendar (wview->calendar, wview->gtk_calendar);
-}
-
-static void
-double_click_on_weekday (GtkWidget *widget, GdkEvent *e, GncalWeekView *wview)
-{
-}
-
-GtkWidget *
-gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week)
-{
- GncalWeekView *wview;
- GtkWidget *table;
- int i;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- wview = gtk_type_new (gncal_week_view_get_type ());
-
- table = gtk_table_new (0, 0, 0);
- gtk_table_set_homogeneous (GTK_TABLE (table), TRUE);
- wview->label = gtk_label_new ("");
- gtk_box_pack_start (GTK_BOX (wview), wview->label, 0, 0, 0);
- gtk_box_pack_start (GTK_BOX (wview), table, 1, 1, 0);
- wview->calendar = calendar;
- for (i = 0; i < 7; i++) {
- wview->days[i] = GNCAL_DAY_VIEW (gncal_day_view_new (calendar, 0, 0));
- gtk_signal_connect (GTK_OBJECT (wview->days [i]), "button_press_event",
- GTK_SIGNAL_FUNC(double_click_on_weekday), wview);
-
- if (i < 5)
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->days[i]),
- i, i + 1,
- 0, 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
- else
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->days[i]),
- i - 2, i - 1,
- 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- gtk_widget_show (GTK_WIDGET (wview->days[i]));
- }
-
- wview->gtk_calendar = GTK_CALENDAR (gtk_calendar_new ());
-
- gtk_signal_connect (GTK_OBJECT (wview->gtk_calendar), "day_selected_double_click",
- GTK_SIGNAL_FUNC(jump_to_day_click), wview);
- gtk_signal_connect (GTK_OBJECT (wview->gtk_calendar), "month_changed",
- GTK_SIGNAL_FUNC(sync_week), wview);
-
- gtk_calendar_display_options (wview->gtk_calendar,
- (GTK_CALENDAR_SHOW_HEADING
- | GTK_CALENDAR_SHOW_DAY_NAMES
- | (week_starts_on_monday
- ? GTK_CALENDAR_WEEK_START_MONDAY : 0)));
-
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->gtk_calendar),
- 0, 3,
- 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 4, 4);
- gtk_widget_show (GTK_WIDGET (wview->gtk_calendar));
-
- gncal_week_view_set (wview, start_of_week);
-
- return GTK_WIDGET (wview);
-}
-
-static void
-update (GncalWeekView *wview, int update_days, iCalObject *object, int flags)
-{
- int i;
-
- if (update_days)
- for (i = 0; i < 7; i++)
- gncal_day_view_update (wview->days[i], object, flags);
-
- /* FIXME: update extra widgets */
-}
-
-void
-gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags)
-{
- g_return_if_fail (wview != NULL);
- g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
-
- update (wview, TRUE, ico, flags);
-}
-
-void
-gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
-{
- struct tm tm;
- time_t day_start, day_end, week_start, week_end;
- int i;
-
- g_return_if_fail (wview != NULL);
- g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
-
- tm = *localtime (&start_of_week);
-
- /* back up to start of week (Monday) */
-
- tm.tm_mday -= (tm.tm_wday == 0) ? 6 : (tm.tm_wday - 1);
-
- /* Start of day */
-
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- day_start = week_start = mktime (&tm);
-
- /* Calendar */
-
- gtk_calendar_select_month (wview->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
-
- /* Day views */
-
- for (i = 0; i < 7; i++) { /* rest of days */
- tm.tm_mday++;
- day_end = mktime (&tm);
-
- gncal_day_view_set_bounds (wview->days[i], day_start, day_end - 1);
-
- day_start = day_end;
- }
-
- update (wview, FALSE, NULL, 0);
-
- /* The label */
- {
- char buf [3][100];
-
- week_end = time_add_day (week_start, 6);
-
- strftime (buf[0], sizeof (buf[0]), _("%a %b %d %Y"),
- localtime(&week_start));
-
- strftime (buf[1], sizeof (buf[1]), _("%a %b %d %Y"),
- localtime(&week_end));
-
- g_snprintf(buf[2], sizeof(buf[2]), "%s - %s", buf[0], buf[1]);
- gtk_label_set (GTK_LABEL (wview->label), buf[2]);
-
- }
-}
-
-void
-gncal_week_view_time_format_changed (GncalWeekView *wview)
-{
- g_return_if_fail (wview != NULL);
- g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
-
- gtk_calendar_display_options (wview->gtk_calendar,
- (week_starts_on_monday
- ? (wview->gtk_calendar->display_flags
- | GTK_CALENDAR_WEEK_START_MONDAY)
- : (wview->gtk_calendar->display_flags
- & ~GTK_CALENDAR_WEEK_START_MONDAY)));
-}
diff --git a/calendar/gncal-week-view.h b/calendar/gncal-week-view.h
deleted file mode 100644
index ab06161844..0000000000
--- a/calendar/gncal-week-view.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef WEEK_VIEW_H
-#define WEEK_VIEW_H
-
-
-#include <gtk/gtkvbox.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkvbox.h>
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-#include "gncal-day-view.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_WEEK_VIEW(obj) GTK_CHECK_CAST (obj, gncal_week_view_get_type (), GncalWeekView)
-#define GNCAL_WEEK_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_week_view_get_type (), GncalWeekViewClass)
-#define GNCAL_IS_WEEK_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_week_view_get_type ())
-
-
-typedef struct _GncalWeekView GncalWeekView;
-typedef struct _GncalWeekViewClass GncalWeekViewClass;
-
-struct _GncalWeekView {
- GtkVBox box;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- struct tm start_of_week;
-
- GncalDayView *days[7]; /* the day view widgets */
- GtkCalendar *gtk_calendar; /* At least for now; see the FIXME comments in the .c file */
- GtkWidget *label;
-};
-
-struct _GncalWeekViewClass {
- GtkVBoxClass parent_class;
-};
-
-
-guint gncal_week_view_get_type (void);
-GtkWidget *gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week);
-
-void gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags);
-void gncal_week_view_set (GncalWeekView *wview, time_t start_of_week);
-void gncal_week_view_time_format_changed (GncalWeekView *wview);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gncal.desktop b/calendar/gncal.desktop
deleted file mode 100644
index 9ee2a2db9b..0000000000
--- a/calendar/gncal.desktop
+++ /dev/null
@@ -1,37 +0,0 @@
-[Desktop Entry]
-Name=Calendar
-Name[da]=Kalender
-Name[de]=Kalender
-Name[el]=Çìåñïëüãéï
-Name[es]=Calendario
-Name[et]=Kalender
-Name[fi]=Kalenteri
-Name[fr]=Calendrier
-Name[gl]=Axenda
-Name[ja]=¥«¥ì¥ó¥À¡¼
-Name[ko]=´Þ·Â
-Name[no]=Kalender
-Name[pt]=Agenda
-Name[pt_BR]=Calendário
-Name[ru]=ëÁÌÅÎÄÁÒØ
-Name[sv]=Kalender
-Comment=Calendar application
-Comment[da]=Gnome Kalender
-Comment[de]=Gnome Kalender
-Comment[el]=Çìåñïëüãéï ôïõ Gnome
-Comment[es]=Calendario de Gnome
-Comment[et]=GNOME kalender
-Comment[fi]=GNOME-kalenteri
-Comment[fr]=Calendrier GNOME
-Comment[gl]=Axenda de GNOME
-Comment[ja]=GNOME¥«¥ì¥ó¥À¡¼
-Comment[ko]=±×³ð ´Þ·Â
-Comment[no]=Gnome Kalender
-Comment[pt]=Agenda Gnome
-Comment[pt_BR]=Calendário GNOME
-Comment[ru]=ëÁÌÅÎÄÁÒØ Gnome
-Comment[sv]=Gnome-kalender
-Exec=gnomecal
-Icon=gnome-calendar.png
-Terminal=0
-Type=Application
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
deleted file mode 100644
index 387d46a31c..0000000000
--- a/calendar/gnome-cal.c
+++ /dev/null
@@ -1,613 +0,0 @@
-/*
- * GnomeCalendar widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-#include <config.h>
-#include <gnome.h>
-#include <unistd.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include "calendar.h"
-#include "gnome-cal.h"
-#include "gncal-day-panel.h"
-#include "gncal-week-view.h"
-#include "month-view.h"
-#include "year-view.h"
-#include "timeutil.h"
-#include "main.h"
-#include "corba-cal.h"
-
-GnomeApp *parent_class;
-
-guint
-gnome_calendar_get_type (void)
-{
- static guint gnome_calendar_type = 0;
- if(!gnome_calendar_type) {
- GtkTypeInfo gnome_calendar_info = {
- "GnomeCalendar",
- sizeof(GnomeCalendar),
- sizeof(GnomeCalendarClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) NULL,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL,
- };
- gnome_calendar_type = gtk_type_unique(gnome_app_get_type(), &gnome_calendar_info);
- parent_class = gtk_type_class (gnome_app_get_type());
- }
- return gnome_calendar_type;
-}
-
-static void
-setup_widgets (GnomeCalendar *gcal)
-{
- time_t now;
-
- now = time (NULL);
-
- gcal->notebook = gtk_notebook_new ();
- gcal->day_view = gncal_day_panel_new (gcal, now);
- gcal->week_view = gncal_week_view_new (gcal, now);
- gcal->month_view = month_view_new (gcal, now);
- gcal->year_view = year_view_new (gcal, now);
-
- gcal->year_view_sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gcal->year_view_sw),
- GTK_POLICY_NEVER,
- GTK_POLICY_AUTOMATIC);
- gtk_container_add (GTK_CONTAINER (gcal->year_view_sw), gcal->year_view);
- GTK_LAYOUT (gcal->year_view)->vadjustment->step_increment = 10.0;
- gtk_adjustment_changed (GTK_ADJUSTMENT (GTK_LAYOUT (gcal->year_view)->vadjustment));
-
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view, gtk_label_new (_("Day View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->week_view, gtk_label_new (_("Week View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->month_view, gtk_label_new (_("Month View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->year_view_sw, gtk_label_new (_("Year View")));
-
- gtk_widget_show_all (gcal->notebook);
-
- gnome_app_set_contents (GNOME_APP (gcal), gcal->notebook);
-}
-
-static GtkWidget *
-get_current_page (GnomeCalendar *gcal)
-{
- return GTK_NOTEBOOK (gcal->notebook)->cur_page->child;
-}
-
-char *
-gnome_calendar_get_current_view_name (GnomeCalendar *gcal)
-{
- GtkWidget *page;
-
- g_return_val_if_fail (gcal != NULL, "dayview");
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), "dayview");
-
- page = get_current_page (gcal);
-
- if (page == gcal->day_view)
- return "dayview";
- else if (page == gcal->week_view)
- return "weekview";
- else if (page == gcal->month_view)
- return "monthview";
- else if (page == gcal->year_view_sw)
- return "yearview";
- else
- return "dayview";
-}
-
-void
-gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
-{
- GtkWidget *current;
-
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (new_time != -1);
-
- current = get_current_page (gcal);
- new_time = time_day_begin (new_time);
-
- if (current == gcal->day_view)
- gncal_day_panel_set (GNCAL_DAY_PANEL (gcal->day_view), new_time);
- else if (current == gcal->week_view)
- gncal_week_view_set (GNCAL_WEEK_VIEW (gcal->week_view), new_time);
- else if (current == gcal->month_view)
- month_view_set (MONTH_VIEW (gcal->month_view), new_time);
- else if (current == gcal->year_view_sw)
- year_view_set (YEAR_VIEW (gcal->year_view), new_time);
- else {
- g_warning ("My penguin is gone!");
- g_assert_not_reached ();
- }
-
- gcal->current_display = new_time;
-}
-
-static void
-gnome_calendar_direction (GnomeCalendar *gcal, int direction)
-{
- GtkWidget *cp = get_current_page (gcal);
- time_t new_time;
-
- if (cp == gcal->day_view)
- new_time = time_add_day (time_day_begin (gcal->current_display), 1 * direction);
- else if (cp == gcal->week_view)
- new_time = time_add_week (time_week_begin (gcal->current_display), 1 * direction);
- else if (cp == gcal->month_view)
- new_time = time_add_month (time_month_begin (gcal->current_display), 1 * direction);
- else if (cp == gcal->year_view_sw)
- new_time = time_add_year (time_year_begin (gcal->current_display), 1 * direction);
- else {
- g_warning ("Weee! Where did the penguin go?");
- g_assert_not_reached ();
- new_time = 0;
- }
-
- gnome_calendar_goto (gcal, new_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);
-}
-
-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);
-}
-
-void
-gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- gtk_notebook_set_page (GTK_NOTEBOOK (gcal->notebook), 0);
- gnome_calendar_goto (gcal, time);
-}
-
-void
-gnome_calendar_goto_today (GnomeCalendar *gcal)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- gnome_calendar_goto (gcal, time (NULL));
-}
-
-void
-gnome_calendar_set_view (GnomeCalendar *gcal, char *page_name)
-{
- int page = 0;
-
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (page_name != NULL);
-
-
- if (strcmp (page_name, "dayview") == 0)
- page = 0;
- else if (strcmp (page_name, "weekview") == 0)
- page = 1;
- else if (strcmp (page_name, "monthview") == 0)
- page = 2;
- else if (strcmp (page_name, "yearview") == 0)
- page = 3;
- gtk_notebook_set_page (GTK_NOTEBOOK (gcal->notebook), page);
-}
-
-GtkWidget *
-gnome_calendar_new (char *title)
-{
- GtkWidget *retval;
- GnomeCalendar *gcal;
- GnomeApp *app;
-
- retval = gtk_type_new (gnome_calendar_get_type ());
- app = GNOME_APP (retval);
- gcal = GNOME_CALENDAR (retval);
-
- app->name = g_strdup ("calendar");
- app->prefix = g_strconcat ("/", app->name, "/", NULL);
-
- gtk_window_set_title(GTK_WINDOW(retval), title);
-
- gcal->current_display = time_day_begin (time (NULL));
- gcal->cal = calendar_new (title,CALENDAR_INIT_ALARMS);
- setup_widgets (gcal);
- gnome_calendar_create_corba_server (gcal);
-
- return retval;
-}
-
-static void
-gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags)
-{
- gncal_day_panel_update (GNCAL_DAY_PANEL (cal->day_view), object, flags);
- gncal_week_view_update (GNCAL_WEEK_VIEW (cal->week_view), object, flags);
- month_view_update (MONTH_VIEW (cal->month_view), object, flags);
- year_view_update (YEAR_VIEW (cal->year_view), object, flags);
-}
-
-int
-gnome_calendar_load (GnomeCalendar *gcal, char *file)
-{
- char *r;
-
- g_return_val_if_fail (gcal != NULL, 0);
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), 0);
- g_return_val_if_fail (file != NULL, 0);
-
- if ((r = calendar_load (gcal->cal, file)) != NULL){
- printf ("Error loading calendar: %s\n", r);
- return 0;
- }
- gnome_calendar_update_all (gcal, NULL, 0);
- return 1;
-}
-
-void
-gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (obj != NULL);
-
- calendar_add_object (gcal->cal, obj);
- gnome_calendar_update_all (gcal, obj, CHANGE_NEW);
-}
-
-void
-gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (obj != NULL);
-
- calendar_remove_object (gcal->cal, obj);
- gnome_calendar_update_all (gcal, obj, CHANGE_ALL);
-}
-
-void
-gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (obj != NULL);
-
- gcal->cal->modified = TRUE;
-
- gnome_calendar_update_all (gcal, obj, flags);
- calendar_object_changed (gcal->cal, obj, flags);
-}
-
-static int
-max_open_files (void)
-{
- static int files;
-
- if (files)
- return files;
-
- files = sysconf (_SC_OPEN_MAX);
- if (files != -1)
- return files;
-#ifdef OPEN_MAX
- return files = OPEN_MAX;
-#else
- return files = 256;
-#endif
-}
-
-static void
-execute (char *command, int close_standard)
-{
- struct sigaction ignore, save_intr, save_quit;
- int status = 0, i;
- pid_t pid;
-
- ignore.sa_handler = SIG_IGN;
- sigemptyset (&ignore.sa_mask);
- ignore.sa_flags = 0;
-
- sigaction (SIGINT, &ignore, &save_intr);
- sigaction (SIGQUIT, &ignore, &save_quit);
-
- if ((pid = fork ()) < 0){
- fprintf (stderr, "\n\nfork () = -1\n");
- return;
- }
- if (pid == 0){
- pid = fork ();
- if (pid == 0){
- const int top = max_open_files ();
- sigaction (SIGINT, &save_intr, NULL);
- sigaction (SIGQUIT, &save_quit, NULL);
-
- for (i = (close_standard ? 0 : 3); i < top; i++)
- close (i);
-
- /* FIXME: As an excercise to the reader, copy the
- * code from mc to setup shell properly instead of
- * /bin/sh. Yes, this comment is larger than a cut and paste.
- */
- execl ("/bin/sh", "/bin/sh", "-c", command, (char *) 0);
-
- _exit (127);
- } else {
- _exit (127);
- }
- }
- wait (&status);
- sigaction (SIGINT, &save_intr, NULL);
- sigaction (SIGQUIT, &save_quit, NULL);
-}
-
-void
-mail_notify (char *mail_address, char *text, time_t app_time)
-{
- pid_t pid;
- int p [2];
- char *command;
-
- pipe (p);
- pid = fork ();
- if (pid == 0){
- int dev_null;
-
- dev_null = open ("/dev/null", O_RDWR);
- dup2 (p [0], 0);
- dup2 (dev_null, 1);
- dup2 (dev_null, 2);
- execl ("/usr/lib/sendmail", "/usr/lib/sendmail",
- mail_address, NULL);
- _exit (127);
- }
- command = g_strconcat ("To: ", mail_address, "\n",
- "Subject: ", _("Reminder of your appointment at "),
- ctime (&app_time), "\n\n", text, "\n", NULL);
- write (p [1], command, strlen (command));
- close (p [1]);
- close (p [0]);
- g_free (command);
-}
-
-static void
-stop_beeping (GtkObject* object, gpointer data)
-{
- guint timer_tag, beep_tag;
- timer_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "timer_tag"));
- beep_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "beep_tag"));
-
- if (beep_tag > 0) {
- gtk_timeout_remove (beep_tag);
- gtk_object_set_data (object, "beep_tag", GINT_TO_POINTER (0));
- }
- if (timer_tag > 0) {
- gtk_timeout_remove (timer_tag);
- gtk_object_set_data (object, "timer_tag", GINT_TO_POINTER (0));
- }
-}
-
-static gint
-start_beeping (gpointer data)
-{
- gdk_beep ();
-
- return TRUE;
-}
-
-static gint
-timeout_beep (gpointer data)
-{
- stop_beeping (data, NULL);
- return FALSE;
-}
-
-void
-calendar_notify (time_t activation_time, CalendarAlarm *which, void *data)
-{
- iCalObject *ico = data;
- guint beep_tag, timer_tag;
- int ret;
- gchar* snooze_button = (enable_snooze ? _("Snooze") : NULL);
- time_t now, diff;
-
- if (&ico->aalarm == which){
- time_t app = ico->aalarm.trigger + ico->aalarm.offset;
- GtkWidget *w;
- char *msg;
-
- msg = g_strconcat (_("Reminder of your appointment at "),
- ctime (&app), "`",
- ico->summary, "'", NULL);
-
- /* Idea: we need Snooze option :-) */
- w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, _("Ok"), snooze_button, NULL);
- beep_tag = gtk_timeout_add (1000, start_beeping, NULL);
- if (enable_aalarm_timeout)
- timer_tag = gtk_timeout_add (audio_alarm_timeout*1000,
- timeout_beep, w);
- else
- timer_tag = 0;
- gtk_object_set_data (GTK_OBJECT (w), "timer_tag",
- GINT_TO_POINTER (timer_tag));
- gtk_object_set_data (GTK_OBJECT (w), "beep_tag",
- GINT_TO_POINTER (beep_tag));
- gtk_widget_ref (w);
- ret = gnome_dialog_run (GNOME_DIALOG (w));
- switch (ret) {
- case 1:
- stop_beeping (GTK_OBJECT (w), NULL);
- now = time (NULL);
- diff = now - which->trigger;
- which->trigger = which->trigger + diff + snooze_secs;
- which->offset = which->offset - diff - snooze_secs;
- alarm_add (which, &calendar_notify, data);
- break;
- default:
- stop_beeping (GTK_OBJECT (w), NULL);
- break;
- }
-
- gtk_widget_unref (w);
- return;
- }
-
- if (&ico->palarm == which){
- execute (ico->palarm.data, 0);
- return;
- }
-
- if (&ico->malarm == which){
- time_t app = ico->malarm.trigger + ico->malarm.offset;
-
- mail_notify (ico->malarm.data, ico->summary, app);
- return;
- }
-
- if (&ico->dalarm == which){
- time_t app = ico->dalarm.trigger + ico->dalarm.offset;
- GtkWidget *w;
- char *msg;
-
- if (beep_on_display)
- gdk_beep ();
- msg = g_strconcat (_("Reminder of your appointment at "),
- ctime (&app), "`",
- ico->summary, "'", NULL);
- w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO,
- _("Ok"), snooze_button, NULL);
- ret = gnome_dialog_run (GNOME_DIALOG (w));
- switch (ret) {
- case 1:
- now = time (NULL);
- diff = now - which->trigger;
- which->trigger = which->trigger + diff + snooze_secs;
- which->offset = which->offset - diff - snooze_secs;
- alarm_add (which, &calendar_notify, data);
- break;
- default:
- break;
- }
-
- return;
- }
-}
-
-/*
- * called from the calendar_iterate routine to mark the days of a GtkCalendar
- */
-static int
-mark_gtk_calendar_day (iCalObject *obj, time_t start, time_t end, void *c)
-{
- GtkCalendar *gtk_cal = c;
- struct tm tm_s;
- time_t t, day_end;
-
- tm_s = *localtime (&start);
- day_end = time_day_end (end);
-
- for (t = start; t <= day_end; t += 60*60*24){
- time_t new = mktime (&tm_s);
- struct tm tm_day;
-
- tm_day = *localtime (&new);
- gtk_calendar_mark_day (gtk_cal, tm_day.tm_mday);
- tm_s.tm_mday++;
- }
- return TRUE;
-}
-
-/*
- * Tags the dates with appointments in a GtkCalendar based on the
- * GnomeCalendar contents
- */
-void
-gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal)
-{
- time_t month_begin, month_end;
- struct tm tm;
-
- g_return_if_fail (cal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (cal));
- g_return_if_fail (gtk_cal != NULL);
- g_return_if_fail (GTK_IS_CALENDAR (gtk_cal));
-
- /* compute month_begin */
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_mday = 1; /* setting this to zero is a no-no; it will set mktime back to the end of the
- previous month, which may be 28,29,30; this may chop some days from the calendar */
- tm.tm_mon = gtk_cal->month;
- tm.tm_year = gtk_cal->year - 1900;
- tm.tm_isdst= -1;
-
- month_begin = mktime (&tm);
- tm.tm_mon++;
- month_end = mktime (&tm);
-
- gtk_calendar_freeze (gtk_cal);
- gtk_calendar_clear_marks (gtk_cal);
- calendar_iterate (cal->cal, month_begin, month_end, mark_gtk_calendar_day, gtk_cal);
- gtk_calendar_thaw (gtk_cal);
-}
-
-void
-gnome_calendar_time_format_changed (GnomeCalendar *gcal)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- /* FIXME: the queue resizes will do until we rewrite those views... */
-
- gncal_day_panel_time_format_changed (GNCAL_DAY_PANEL (gcal->day_view));
- gtk_widget_queue_resize (gcal->day_view);
- gncal_week_view_time_format_changed (GNCAL_WEEK_VIEW (gcal->week_view));
- gtk_widget_queue_resize (gcal->week_view);
- month_view_time_format_changed (MONTH_VIEW (gcal->month_view));
- year_view_time_format_changed (YEAR_VIEW (gcal->year_view));
-}
-
-void
-gnome_calendar_colors_changed (GnomeCalendar *gcal)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- /* FIXME: add day and week view when they are done */
-
- month_view_colors_changed (MONTH_VIEW (gcal->month_view));
- year_view_colors_changed (YEAR_VIEW (gcal->year_view));
- todo_style_changed = 1;
- todo_list_properties_changed (GNCAL_DAY_PANEL (gcal->day_view));
-}
-
-void
-gnome_calendar_todo_properties_changed (GnomeCalendar *gcal)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- /* FIXME: add day and week view when they are done */
-
- todo_style_changed = 1;
- todo_list_properties_changed (GNCAL_DAY_PANEL (gcal->day_view));
-}
-
-
diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h
deleted file mode 100644
index da53f29882..0000000000
--- a/calendar/gnome-cal.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * GnomeCalendar widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-
-#ifndef GNOME_CALENDAR_APP_H
-#define GNOME_CALENDAR_APP_H
-
-#include <gnome.h>
-
-#include "calendar.h"
-
-BEGIN_GNOME_DECLS
-
-#define GNOME_CALENDAR(obj) GTK_CHECK_CAST(obj, gnome_calendar_get_type(), GnomeCalendar)
-#define GNOME_CALENDAR_CLASS(class) GTK_CHECK_CAST_CLASS(class, gnome_calendar_get_type(), GnomeCalendarClass)
-#define GNOME_IS_CALENDAR(obj) GTK_CHECK_TYPE(obj, gnome_calendar_get_type())
-
-typedef struct {
- GnomeApp gnome_app;
- Calendar *cal;
- time_t current_display;
-
- GtkWidget *notebook;
- GtkWidget *day_view;
- GtkWidget *week_view;
- GtkWidget *month_view;
- GtkWidget *year_view;
- GtkWidget *year_view_sw;
- void *event_editor;
-} GnomeCalendar;
-
-typedef struct {
- GnomeAppClass parent_class;
-} GnomeCalendarClass;
-
-guint gnome_calendar_get_type (void);
-GtkWidget *gnome_calendar_new (char *title);
-int gnome_calendar_load (GnomeCalendar *gcal,
- char *file);
-void gnome_calendar_add_object (GnomeCalendar *gcal,
- iCalObject *obj);
-void gnome_calendar_remove_object (GnomeCalendar *gcal,
- iCalObject *obj);
-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,
- time_t time);
-/* Jumps to the current day */
-void gnome_calendar_goto_today (GnomeCalendar *gcal);
-void gnome_calendar_tag_calendar (GnomeCalendar *cal,
- GtkCalendar *gtk_cal);
-char *gnome_calendar_get_current_view_name (GnomeCalendar *gcal);
-void gnome_calendar_set_view (GnomeCalendar *gcal,
- char *page_name);
-
-/* Flags is a bitmask of CalObjectChange values */
-void gnome_calendar_object_changed (GnomeCalendar *gcal,
- iCalObject *obj,
- int flags);
-
-GnomeCalendar *gnome_calendar_locate (const char *pathname);
-
-/* Notifies the calendar that the time format has changed and it must update all its views */
-void gnome_calendar_time_format_changed (GnomeCalendar *gcal);
-
-/* Notifies the calendar that the todo list properties have changed and its time to update the views */
-void
-gnome_calendar_colors_changed (GnomeCalendar *gcal);
-
-/* Notifies the calendar that the todo list properties have changed and its time to update the views */
-void
-gnome_calendar_todo_properties_changed (GnomeCalendar *gcal);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gnome-cal.html b/calendar/gnome-cal.html
deleted file mode 100644
index 5a7d0a537f..0000000000
--- a/calendar/gnome-cal.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<!-- Some simple instructions on how to use the help browser -->
-<BODY>
-<!-- <TITLE>GNOME Calendar Documentation</TITLE> -->
-<H2> GNOME Calendar Documentation </H2>
-<p>
-The GNOME calendar program is the calendaring program of the GNOME
-system. It uses the vCalendar standard for transfering calendar
-information (and is also the on-disk format used).
-
-<p>
-
-<a name="cmdline">
-<h2>Command line options</h2>
-
-Several options are available on the command line, they are:
-<ul>
- <li><tt>--events</tt> Displays the events for the date
- specified (or today, if no date is specified).
-
- <li><tt>--from DATE</tt> Define the beginning of the range for
- the event display, or the startup day on the calenday views.
- By default, the event will span the whole day specified in
- DATE.
-
- <li><tt>--to DATE</tt> Define the range end for the event
- display. If this is not specified, it will default to the end
- of the day specified by the <tt>--from</tt> option.
-
- <li><tt>--file FILE</tt> Set the calendar to the FILE
- specified on the command line.
-
- <li><tt>--todo</tt> Dumps the to-do values to standard output.
-</ul>
-
-<p>
-
-DATE is interpreted as being in the local time- zone, unless a
-specific timezone is specified. Examples of valid date specifications
-include: "1 month ago", "2 hours ago", "400000 seconds ago", "last
-year", "last Monday", "yesterday", "a fortnight ago", "3/31/92
-10:00:07 PST", "January 23, 1987 10:05pm", "22:00 GMT".
-
-</BODY>
-
diff --git a/calendar/gnome-calendar-conduit.png b/calendar/gnome-calendar-conduit.png
deleted file mode 100644
index e867ba90b2..0000000000
--- a/calendar/gnome-calendar-conduit.png
+++ /dev/null
Binary files differ
diff --git a/calendar/gnome-month-item.c b/calendar/gnome-month-item.c
deleted file mode 100644
index 58e393e4ee..0000000000
--- a/calendar/gnome-month-item.c
+++ /dev/null
@@ -1,1246 +0,0 @@
-/* General-purpose monthly calendar canvas item for GNOME
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include <math.h>
-#include <time.h>
-#include <gnome.h>
-#include "gnome-month-item.h"
-
-
-#define DEFAULT_FONT "-*-helvetica-medium-r-normal--10-*-*-*-p-*-*-*"
-
-
-/* Number of days in a month, for normal and leap years */
-static const int days_in_month[2][12] = {
- { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
- { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
-};
-
-/* The weird month of September 1752, where 3 Sep through 13 Sep were eliminated due to the
- * Gregorian reformation.
- */
-static const int sept_1752[42] = {
- 0, 0, 1, 2, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30,
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0
-};
-
-#define REFORMATION_DAY 639787 /* First day of the reformation, counted from 1 Jan 1 */
-#define MISSING_DAYS 11 /* They corrected out 11 days */
-#define THURSDAY 4 /* First day of reformation */
-#define SATURDAY 6 /* Offset value; 1 Jan 1 was a Saturday */
-#define SEPT_1752_START 2 /* Start day within month */
-#define SEPT_1752_END 20 /* End day within month */
-
-
-enum {
- ARG_0,
- ARG_YEAR,
- ARG_MONTH,
- ARG_X,
- ARG_Y,
- ARG_WIDTH,
- ARG_HEIGHT,
- ARG_ANCHOR,
- ARG_HEAD_PADDING,
- ARG_DAY_PADDING,
- ARG_DAY_NAMES,
- ARG_HEADING_HEIGHT,
- ARG_HEADING_ANCHOR,
- ARG_DAY_ANCHOR,
- ARG_START_ON_MONDAY,
- ARG_HEAD_FONT,
- ARG_HEAD_FONTSET,
- ARG_HEAD_FONT_GDK,
- ARG_DAY_FONT,
- ARG_DAY_FONTSET,
- ARG_DAY_FONT_GDK,
- ARG_HEAD_COLOR,
- ARG_HEAD_COLOR_GDK,
- ARG_OUTLINE_COLOR,
- ARG_OUTLINE_COLOR_GDK,
- ARG_DAY_BOX_COLOR,
- ARG_DAY_BOX_COLOR_GDK,
- ARG_DAY_COLOR,
- ARG_DAY_COLOR_GDK
-};
-
-
-static void gnome_month_item_class_init (GnomeMonthItemClass *class);
-static void gnome_month_item_init (GnomeMonthItem *mitem);
-static void gnome_month_item_destroy (GtkObject *object);
-static void gnome_month_item_set_arg (GtkObject *object,
- GtkArg *arg,
- guint arg_id);
-static void gnome_month_item_get_arg (GtkObject *object,
- GtkArg *arg,
- guint arg_id);
-
-
-
-static GnomeCanvasGroupClass *parent_class;
-
-
-GtkType
-gnome_month_item_get_type (void)
-{
- static GtkType month_item_type = 0;
-
- if (!month_item_type) {
- GtkTypeInfo month_item_info = {
- "GnomeMonthItem",
- sizeof (GnomeMonthItem),
- sizeof (GnomeMonthItemClass),
- (GtkClassInitFunc) gnome_month_item_class_init,
- (GtkObjectInitFunc) gnome_month_item_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- month_item_type = gtk_type_unique (gnome_canvas_group_get_type (), &month_item_info);
- }
-
- return month_item_type;
-}
-
-static void
-gnome_month_item_class_init (GnomeMonthItemClass *class)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass *) class;
- item_class = (GnomeCanvasItemClass *) class;
-
- parent_class = gtk_type_class (gnome_canvas_group_get_type ());
-
- gtk_object_add_arg_type ("GnomeMonthItem::year", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_YEAR);
- gtk_object_add_arg_type ("GnomeMonthItem::month", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_MONTH);
- gtk_object_add_arg_type ("GnomeMonthItem::x", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_X);
- gtk_object_add_arg_type ("GnomeMonthItem::y", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_Y);
- gtk_object_add_arg_type ("GnomeMonthItem::width", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_WIDTH);
- gtk_object_add_arg_type ("GnomeMonthItem::height", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_HEIGHT);
- gtk_object_add_arg_type ("GnomeMonthItem::anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_ANCHOR);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_padding", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_HEAD_PADDING);
- gtk_object_add_arg_type ("GnomeMonthItem::day_padding", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_DAY_PADDING);
- gtk_object_add_arg_type ("GnomeMonthItem::day_names", GTK_TYPE_POINTER, GTK_ARG_WRITABLE, ARG_DAY_NAMES);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_height", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_HEADING_HEIGHT);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_HEADING_ANCHOR);
- gtk_object_add_arg_type ("GnomeMonthItem::day_anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_DAY_ANCHOR);
- gtk_object_add_arg_type ("GnomeMonthItem::start_on_monday", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_START_ON_MONDAY);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_font", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_HEAD_FONT);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_fontset", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_HEAD_FONTSET);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_font_gdk", GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_HEAD_FONT_GDK);
- gtk_object_add_arg_type ("GnomeMonthItem::day_font", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_FONT);
- gtk_object_add_arg_type ("GnomeMonthItem::day_fontset", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_FONTSET);
- gtk_object_add_arg_type ("GnomeMonthItem::day_font_gdk", GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_DAY_FONT_GDK);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_HEAD_COLOR);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_HEAD_COLOR_GDK);
- gtk_object_add_arg_type ("GnomeMonthItem::outline_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_OUTLINE_COLOR);
- gtk_object_add_arg_type ("GnomeMonthItem::outline_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_OUTLINE_COLOR_GDK);
- gtk_object_add_arg_type ("GnomeMonthItem::day_box_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_BOX_COLOR);
- gtk_object_add_arg_type ("GnomeMonthItem::day_box_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_DAY_BOX_COLOR_GDK);
- gtk_object_add_arg_type ("GnomeMonthItem::day_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_COLOR);
- gtk_object_add_arg_type ("GnomeMonthItem::day_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_DAY_COLOR_GDK);
-
- object_class->destroy = gnome_month_item_destroy;
- object_class->set_arg = gnome_month_item_set_arg;
- object_class->get_arg = gnome_month_item_get_arg;
-}
-
-/* Calculates the minimum heading height based on the heading font size and padding. It also
- * calculates the minimum width of the month item based on the width of the headings.
- */
-static void
-check_heading_sizes (GnomeMonthItem *mitem)
-{
- double m_height;
- double m_width;
- int width;
- int max_width;
- int i;
-
- /* Calculate minimum height */
-
- m_height = mitem->head_font->ascent + mitem->head_font->descent + 2 * mitem->head_padding;
-
- if (mitem->head_height < m_height)
- mitem->head_height = m_height;
-
- /* Go through each heading and remember the widest one */
-
- max_width = 0;
-
- for (i = 0; i < 7; i++) {
- width = gdk_string_width (mitem->head_font, mitem->day_names[i]);
- if (max_width < width)
- max_width = width;
- }
-
- m_width = 7 * (max_width + 2 * mitem->head_padding);
-
- if (mitem->width < m_width)
- mitem->width = m_width;
-}
-
-/* Calculates the minimum width and height of the month item based on the day font size and padding.
- * Assumes that the minimum heading height has already been computed.
- */
-static void
-check_day_sizes (GnomeMonthItem *mitem)
-{
- double m_height;
- double m_width;
- int width;
- int max_width;
- char buf[100];
- int i;
-
- /* Calculate minimum height */
-
- m_height = mitem->head_height + 6 * (mitem->day_font->ascent + mitem->day_font->descent + 2 * mitem->day_padding);
-
- if (mitem->height < m_height)
- mitem->height = m_height;
-
- /* Calculate minimum width */
-
- max_width = 0;
-
- for (i = 1; i < 32; i++) {
- sprintf (buf, "%d", i);
- width = gdk_string_width (mitem->day_font, buf);
- if (max_width < width)
- max_width = width;
- }
-
- m_width = 7 * (max_width + 2 * mitem->day_padding);
-
- if (mitem->width < m_width)
- mitem->width = m_width;
-}
-
-/* Calculates the minimum size of the month item based on the font sizes and paddings. If the
- * current size of the month item is smaller than the required minimum size, this function will
- * change the size to the appropriate values.
- */
-static void
-check_sizes (GnomeMonthItem *mitem)
-{
- check_heading_sizes (mitem);
- check_day_sizes (mitem);
-}
-
-/* Recalculates the position of the toplevel calendar group based on the logical position and anchor */
-static void
-reanchor (GnomeMonthItem *mitem)
-{
- double x, y;
-
- x = mitem->x;
- y = mitem->y;
-
- switch (mitem->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- x -= mitem->width / 2;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- x -= mitem->width;
- break;
- }
-
- switch (mitem->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- y -= mitem->height / 2;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- y -= mitem->height;
- break;
- }
-
- /* Explicitly use the canvas group class prefix since the month item class has x and y
- * arguments as well.
- */
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "GnomeCanvasGroup::x", x,
- "GnomeCanvasGroup::y", y,
- NULL);
-}
-
-/* Takes an anchor specification and the corners of a rectangle, and returns an anchored point with
- * respect to that rectangle.
- */
-static void
-get_label_anchor (GtkAnchorType anchor, double x1, double y1, double x2, double y2, double *x, double *y)
-{
- switch (anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- *x = x1;
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- *x = (x1 + x2) / 2.0;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- *x = x2;
- break;
- }
-
- switch (anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- *y = y1;
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- *y = (y1 + y2) / 2.0;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- *y = y2;
- break;
- }
-}
-
-/* Resets the position of the day name headings in the calendar */
-static void
-reshape_headings (GnomeMonthItem *mitem)
-{
- double width;
- int i;
- double x, y;
-
- width = mitem->width / 7;
-
- for (i = 0; i < 7; i++) {
- /* Group */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i],
- "x", width * i,
- "y", 0.0,
- NULL);
-
- /* Box */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i],
- "x1", 0.0,
- "y1", 0.0,
- "x2", width,
- "y2", mitem->head_height,
- NULL);
-
- /* Label */
- get_label_anchor (mitem->head_anchor,
- mitem->head_padding,
- mitem->head_padding,
- width - mitem->head_padding,
- mitem->head_height - mitem->head_padding,
- &x, &y);
-
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i],
- "x", x,
- "y", y,
- "anchor", mitem->head_anchor,
- NULL);
- }
-}
-
-/* Resets the position of the days in the calendar */
-static void
-reshape_days (GnomeMonthItem *mitem)
-{
- double width, height;
- double x, y;
- int row, col;
- int i;
-
- width = mitem->width / 7;
- height = (mitem->height - mitem->head_height) / 6;
-
- i = 0;
-
- for (row = 0; row < 6; row++)
- for (col = 0; col < 7; col++) {
- /* Group */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i],
- "x", width * col,
- "y", mitem->head_height + height * row,
- NULL);
-
- /* Box */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i],
- "x1", 0.0,
- "y1", 0.0,
- "x2", width,
- "y2", height,
- NULL);
-
- /* Label */
- get_label_anchor (mitem->day_anchor,
- mitem->day_padding,
- mitem->day_padding,
- width - mitem->day_padding,
- height - mitem->day_padding,
- &x, &y);
-
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "x", x,
- "y", y,
- "anchor", mitem->day_anchor,
- NULL);
-
- i++;
- }
-}
-
-/* Changes the positions and resizes the items in the calendar to match the new size of the
- * calendar.
- */
-static void
-reshape (GnomeMonthItem *mitem)
-{
- check_sizes (mitem);
- reanchor (mitem);
- reshape_headings (mitem);
- reshape_days (mitem);
-}
-
-/* Sets the font for all the day headings */
-static void
-set_head_font (GnomeMonthItem *mitem)
-{
- int i;
-
- for (i = 0; i < 7; i++)
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i],
- "font_gdk", mitem->head_font,
- NULL);
-}
-
-/* Sets the color for all the headings */
-static void
-set_head_color (GnomeMonthItem *mitem)
-{
- int i;
- GdkColor outline;
- GdkColor head;
-
- outline.pixel = mitem->outline_pixel;
- head.pixel = mitem->head_pixel;
-
- for (i = 0; i < 7; i++) {
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i],
- "fill_color_gdk", &outline,
- NULL);
-
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i],
- "fill_color_gdk", &head,
- NULL);
- }
-}
-
-/* Creates the items for the day name headings */
-static void
-create_headings (GnomeMonthItem *mitem)
-{
- int i;
-
- /* Just create the items; they will be positioned and configured by a call to reshape() */
-
- for (i = 0; i < 7; i++) {
- /* Group */
- mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem),
- gnome_canvas_group_get_type (),
- NULL);
-
- /* Box */
- mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i]),
- gnome_canvas_rect_get_type (),
- NULL);
-
- /* Label */
- mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i]),
- gnome_canvas_text_get_type (),
- NULL);
- }
-
- set_head_font (mitem);
- set_head_color (mitem);
-}
-
-/* Returns the number of leap years since year 1 up to (but not including) the specified year */
-static int
-leap_years_up_to (int year)
-{
- return (year / 4 /* trivial leapness */
- - ((year > 1700) ? (year / 100 - 17) : 0) /* minus centuries since 1700 */
- + ((year > 1600) ? ((year - 1600) / 400) : 0)); /* plus centuries since 1700 divisible by 400 */
-}
-
-/* Returns whether the specified year is a leap year */
-static int
-is_leap_year (int year)
-{
- if (year <= 1752)
- return !(year % 4);
- else
- return (!(year % 4) && (year % 100)) || !(year % 400);
-}
-
-/* Returns the 1-based day number within the year of the specified date */
-static int
-day_in_year (int day, int month, int year)
-{
- int is_leap, i;
-
- is_leap = is_leap_year (year);
-
- for (i = 0; i < month; i++)
- day += days_in_month [is_leap][i];
-
- return day;
-}
-
-/* Returns the day of the week (zero-based, zero is Sunday) for the specified date. For the days
- * that were removed on the Gregorian reformation, it returns Thursday.
- */
-static int
-day_in_week (int day, int month, int year)
-{
- int n;
-
- n = (year - 1) * 365 + leap_years_up_to (year - 1) + day_in_year (day, month, year);
-
- if (n < REFORMATION_DAY)
- return (n - 1 + SATURDAY) % 7;
-
- if (n >= (REFORMATION_DAY + MISSING_DAYS))
- return (n - 1 + SATURDAY - MISSING_DAYS) % 7;
-
- return THURSDAY;
-}
-
-/* Fills the 42-element days array with the day numbers for the specified month. Slots outside the
- * bounds of the month are filled with zeros. The starting and ending indexes of the days are
- * returned in the start and end arguments.
- */
-static void
-build_month (int month, int year, int start_on_monday, int *days, int *start, int *end)
-{
- int i;
- int d_month, d_week;
-
- /* Note that months are zero-based, so September is month 8 */
-
- if ((year == 1752) && (month == 8)) {
- memcpy (days, sept_1752, 42 * sizeof (int));
-
- if (start)
- *start = SEPT_1752_START;
-
- if (end)
- *end = SEPT_1752_END;
-
- return;
- }
-
- for (i = 0; i < 42; i++)
- days[i] = 0;
-
- d_month = days_in_month[is_leap_year (year)][month];
- d_week = day_in_week (1, month, year);
-
- if (start_on_monday)
- d_week = (d_week + 6) % 7;
-
- for (i = 0; i < d_month; i++)
- days[d_week + i] = i + 1;
-
- if (start)
- *start = d_week;
-
- if (end)
- *end = d_week + d_month - 1;
-}
-
-/* Set the day numbers in the monthly calendar */
-static void
-set_days (GnomeMonthItem *mitem)
-{
- int i;
- int start, end;
- char buf[100];
-
- build_month (mitem->month, mitem->year, mitem->start_on_monday, mitem->day_numbers, &start, &end);
-
- /* Clear days before start of month */
-
- for (i = 0; i < start; i++)
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "text", NULL,
- NULL);
-
- /* Set days of month */
-
- for (; start <= end; start++, i++) {
- sprintf (buf, "%d", mitem->day_numbers[start]);
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "text", buf,
- NULL);
- }
-
- /* Clear days after end of month */
-
- for (; i < 42; i++)
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "text", NULL,
- NULL);
-}
-
-/* Sets the font for all the day numbers */
-static void
-set_day_font (GnomeMonthItem *mitem)
-{
- int i;
-
- for (i = 0; i < 42; i++)
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "font_gdk", mitem->day_font,
- NULL);
-}
-
-/* Sets the color for all the day items */
-static void
-set_day_color (GnomeMonthItem *mitem)
-{
- int i;
- GdkColor outline;
- GdkColor day_box;
- GdkColor day;
-
- outline.pixel = mitem->outline_pixel;
- day_box.pixel = mitem->day_box_pixel;
- day.pixel = mitem->day_pixel;
-
- for (i = 0; i < 42; i++) {
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i],
- "outline_color_gdk", &outline,
- "fill_color_gdk", &day_box,
- NULL);
-
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "fill_color_gdk", &day,
- NULL);
- }
-}
-
-/* Creates the items for the days */
-static void
-create_days (GnomeMonthItem *mitem)
-{
- int i;
-
- /* Just create the items; they will be positioned and configured by a call to reshape() */
-
- for (i = 0; i < 42; i++) {
- /* Group */
- mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem),
- gnome_canvas_group_get_type (),
- NULL);
-
- /* Box */
- mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i]),
- gnome_canvas_rect_get_type (),
- NULL);
-
- /* Label */
- mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i]),
- gnome_canvas_text_get_type (),
- NULL);
- }
-
- set_day_font (mitem);
- set_day_color (mitem);
- set_days (mitem);
-}
-
-/* Resets the text of the day name headings */
-static void
-set_day_names (GnomeMonthItem *mitem)
-{
- int i;
-
- for (i = 0; i < 7; i++)
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i],
- "text", mitem->day_names[mitem->start_on_monday ? ((i + 1) % 7) : i],
- NULL);
-}
-
-/* Creates all the canvas items that make up the calendar */
-static void
-create_items (GnomeMonthItem *mitem)
-{
- mitem->items = g_new (GnomeCanvasItem *, GNOME_MONTH_ITEM_LAST);
-
- create_headings (mitem);
- create_days (mitem);
-
- /* Initialize by default to three-letter day names */
-
- mitem->day_names[0] = g_strdup (_("Sun"));
- mitem->day_names[1] = g_strdup (_("Mon"));
- mitem->day_names[2] = g_strdup (_("Tue"));
- mitem->day_names[3] = g_strdup (_("Wed"));
- mitem->day_names[4] = g_strdup (_("Thu"));
- mitem->day_names[5] = g_strdup (_("Fri"));
- mitem->day_names[6] = g_strdup (_("Sat"));
-
- set_day_names (mitem);
- reshape (mitem);
-}
-
-static void
-gnome_month_item_init (GnomeMonthItem *mitem)
-{
- time_t t;
- struct tm tm;
-
- /* Initialize to the current month by default */
-
- t = time (NULL);
- tm = *localtime (&t);
-
- mitem->year = tm.tm_year + 1900;
- mitem->month = tm.tm_mon;
-
- mitem->x = 0.0;
- mitem->y = 0.0;
- mitem->width = 150.0; /* not unreasonable defaults, I hope */
- mitem->height = 100.0;
- mitem->anchor = GTK_ANCHOR_NW;
- mitem->head_padding = 0.0;
- mitem->day_padding = 2.0;
- mitem->head_height = 14.0;
- mitem->head_anchor = GTK_ANCHOR_CENTER;
- mitem->day_anchor = GTK_ANCHOR_CENTER;
-
- /* Load the default fonts */
-
- mitem->head_font = gdk_font_load (DEFAULT_FONT);
- if (!mitem->head_font) {
- mitem->head_font = gdk_font_load ("fixed");
- g_assert (mitem->head_font != NULL);
- }
-
- mitem->day_font = gdk_font_load (DEFAULT_FONT);
- if (!mitem->day_font) {
- mitem->day_font = gdk_font_load ("fixed");
- g_assert (mitem->day_font != NULL);
- }
-}
-
-GnomeCanvasItem *
-gnome_month_item_new (GnomeCanvasGroup *parent)
-{
- GnomeMonthItem *mitem;
-
- g_return_val_if_fail (parent != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CANVAS_GROUP (parent), NULL);
-
- mitem = GNOME_MONTH_ITEM (gnome_canvas_item_new (parent,
- gnome_month_item_get_type (),
- NULL));
-
- gnome_month_item_construct (mitem);
-
- return GNOME_CANVAS_ITEM (mitem);
-}
-
-void
-gnome_month_item_construct (GnomeMonthItem *mitem)
-{
- GdkColor color;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
-
- gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, "#d6d6d6d6d6d6", &color);
- mitem->head_pixel = color.pixel;
- mitem->day_box_pixel = color.pixel;
-
- gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, "black", &color);
- mitem->outline_pixel = color.pixel;
- mitem->day_pixel = color.pixel;
-
- create_items (mitem);
-}
-
-static void
-free_day_names (GnomeMonthItem *mitem)
-{
- int i;
-
- if (mitem->day_names[0])
- for (i = 0; i < 7; i++)
- g_free (mitem->day_names[i]);
-}
-
-static void
-gnome_month_item_destroy (GtkObject *object)
-{
- GnomeMonthItem *mitem;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (object));
-
- mitem = GNOME_MONTH_ITEM (object);
-
- free_day_names (mitem);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-/* Sets the color of the specified pixel value to that of the specified argument, which must be in
- * GdkColor format if format is TRUE, otherwise it must be in string format.
- */
-static void
-set_color_arg (GnomeMonthItem *mitem, gulong *pixel, GtkArg *arg, int gdk_format, int set_head, int set_day)
-{
- GdkColor color;
-
- if (gdk_format)
- *pixel = ((GdkColor *) GTK_VALUE_BOXED (*arg))->pixel;
- else {
- if (gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, GTK_VALUE_STRING (*arg), &color))
- *pixel = color.pixel;
- else
- *pixel = 0;
- }
-
- if (set_head)
- set_head_color (mitem);
-
- if (set_day)
- set_day_color (mitem);
-}
-
-static void
-gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- GnomeMonthItem *mitem;
- char **day_names;
- int i;
-
- mitem = GNOME_MONTH_ITEM (object);
-
- switch (arg_id) {
- case ARG_YEAR:
- mitem->year = GTK_VALUE_UINT (*arg);
- set_days (mitem);
- break;
-
- case ARG_MONTH:
- mitem->month = GTK_VALUE_UINT (*arg);
- set_days (mitem);
- break;
-
- case ARG_X:
- mitem->x = GTK_VALUE_DOUBLE (*arg);
- reanchor (mitem);
- break;
-
- case ARG_Y:
- mitem->y = GTK_VALUE_DOUBLE (*arg);
- reanchor (mitem);
- break;
-
- case ARG_WIDTH:
- mitem->width = fabs (GTK_VALUE_DOUBLE (*arg));
- reshape (mitem);
- break;
-
- case ARG_HEIGHT:
- mitem->height = fabs (GTK_VALUE_DOUBLE (*arg));
- reshape (mitem);
- break;
-
- case ARG_ANCHOR:
- mitem->anchor = GTK_VALUE_ENUM (*arg);
- reanchor (mitem);
- break;
-
- case ARG_HEAD_PADDING:
- mitem->head_padding = fabs (GTK_VALUE_DOUBLE (*arg));
- reshape (mitem);
- break;
-
- case ARG_DAY_PADDING:
- mitem->day_padding = fabs (GTK_VALUE_DOUBLE (*arg));
- reshape (mitem);
- break;
-
- case ARG_DAY_NAMES:
- day_names = GTK_VALUE_POINTER (*arg);
-
- /* First, check that none of the names is null */
-
- for (i = 0; i < 7; i++)
- if (!day_names[i]) {
- g_warning ("Day number %d was NULL; day names cannot be NULL!", i);
- return;
- }
-
- /* Set the new names */
-
- free_day_names (mitem);
- for (i = 0; i < 7; i++)
- mitem->day_names[i] = g_strdup (day_names[i]);
-
- set_day_names (mitem);
- reshape (mitem);
- break;
-
- case ARG_HEADING_HEIGHT:
- mitem->head_height = fabs (GTK_VALUE_DOUBLE (*arg));
- reshape (mitem);
- break;
-
- case ARG_HEADING_ANCHOR:
- mitem->head_anchor = GTK_VALUE_ENUM (*arg);
- reshape (mitem);
- break;
-
- case ARG_DAY_ANCHOR:
- mitem->day_anchor = GTK_VALUE_ENUM (*arg);
- reshape (mitem);
- break;
-
- case ARG_START_ON_MONDAY:
- mitem->start_on_monday = GTK_VALUE_BOOL (*arg);
- set_day_names (mitem);
- set_days (mitem);
- break;
-
- case ARG_HEAD_FONT:
- gdk_font_unref (mitem->head_font);
-
- mitem->head_font = gdk_font_load (GTK_VALUE_STRING (*arg));
- if (!mitem->head_font) {
- mitem->head_font = gdk_font_load ("fixed");
- g_assert (mitem->head_font != NULL);
- }
-
- set_head_font (mitem);
- reshape (mitem);
- break;
-
- case ARG_HEAD_FONTSET:
- gdk_font_unref (mitem->head_font);
-
- mitem->head_font = gdk_fontset_load (GTK_VALUE_STRING (*arg));
- if (!mitem->head_font) {
- mitem->head_font =
- gdk_fontset_load ("-*-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-*");
- g_assert (mitem->head_font != NULL);
- }
-
- set_head_font (mitem);
- reshape (mitem);
- break;
-
- case ARG_HEAD_FONT_GDK:
- gdk_font_unref (mitem->head_font);
-
- mitem->head_font = GTK_VALUE_BOXED (*arg);
- gdk_font_ref (mitem->head_font);
- set_head_font (mitem);
- reshape (mitem);
- break;
-
- case ARG_DAY_FONT:
- gdk_font_unref (mitem->day_font);
-
- mitem->day_font = gdk_font_load (GTK_VALUE_STRING (*arg));
- if (!mitem->day_font) {
- mitem->day_font = gdk_font_load ("fixed");
- g_assert (mitem->day_font != NULL);
- }
-
- set_day_font (mitem);
- reshape (mitem);
- break;
-
- case ARG_DAY_FONTSET:
- gdk_font_unref (mitem->day_font);
-
- mitem->day_font = gdk_fontset_load (GTK_VALUE_STRING (*arg));
- if (!mitem->day_font) {
- mitem->day_font =
- gdk_fontset_load ("-*-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-*");
- g_assert (mitem->day_font != NULL);
- }
-
- set_day_font (mitem);
- reshape (mitem);
- break;
-
- case ARG_DAY_FONT_GDK:
- gdk_font_unref (mitem->day_font);
-
- mitem->day_font = GTK_VALUE_BOXED (*arg);
- gdk_font_ref (mitem->day_font);
- set_day_font (mitem);
- reshape (mitem);
- break;
-
- case ARG_HEAD_COLOR:
- set_color_arg (mitem, &mitem->head_pixel, arg, FALSE, TRUE, FALSE);
- break;
-
- case ARG_HEAD_COLOR_GDK:
- set_color_arg (mitem, &mitem->head_pixel, arg, TRUE, TRUE, FALSE);
- break;
-
- case ARG_OUTLINE_COLOR:
- set_color_arg (mitem, &mitem->outline_pixel, arg, FALSE, TRUE, TRUE);
- break;
-
- case ARG_OUTLINE_COLOR_GDK:
- set_color_arg (mitem, &mitem->outline_pixel, arg, TRUE, TRUE, TRUE);
- break;
-
- case ARG_DAY_BOX_COLOR:
- set_color_arg (mitem, &mitem->day_box_pixel, arg, FALSE, FALSE, TRUE);
- break;
-
- case ARG_DAY_BOX_COLOR_GDK:
- set_color_arg (mitem, &mitem->day_box_pixel, arg, TRUE, FALSE, TRUE);
- break;
-
- case ARG_DAY_COLOR:
- set_color_arg (mitem, &mitem->day_pixel, arg, FALSE, FALSE, TRUE);
- break;
-
- case ARG_DAY_COLOR_GDK:
- set_color_arg (mitem, &mitem->day_pixel, arg, TRUE, FALSE, TRUE);
- break;
-
- default:
- break;
- }
-}
-
-/* Allocates a GdkColor structure filled with the specified pixel, and puts it into the specified
- * arg for returning it in the get_arg method.
- */
-static void
-get_color_arg (GnomeMonthItem *mitem, gulong pixel, GtkArg *arg)
-{
- GdkColor *color;
-
- color = g_new (GdkColor, 1);
- color->pixel = pixel;
- gdk_color_context_query_color (GNOME_CANVAS_ITEM (mitem)->canvas->cc, color);
- GTK_VALUE_BOXED (*arg) = color;
-}
-
-static void
-gnome_month_item_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- GnomeMonthItem *mitem;
-
- mitem = GNOME_MONTH_ITEM (object);
-
- switch (arg_id) {
- case ARG_YEAR:
- GTK_VALUE_UINT (*arg) = mitem->year;
- break;
-
- case ARG_MONTH:
- GTK_VALUE_UINT (*arg) = mitem->month;
- break;
-
- case ARG_X:
- GTK_VALUE_DOUBLE (*arg) = mitem->x;
- break;
-
- case ARG_Y:
- GTK_VALUE_DOUBLE (*arg) = mitem->y;
- break;
-
- case ARG_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = mitem->width;
- break;
-
- case ARG_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = mitem->height;
- break;
-
- case ARG_ANCHOR:
- GTK_VALUE_ENUM (*arg) = mitem->anchor;
- break;
-
- case ARG_HEAD_PADDING:
- GTK_VALUE_DOUBLE (*arg) = mitem->head_padding;
- break;
-
- case ARG_DAY_PADDING:
- GTK_VALUE_DOUBLE (*arg) = mitem->day_padding;
- break;
-
- case ARG_HEADING_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = mitem->head_height;
- break;
-
- case ARG_HEADING_ANCHOR:
- GTK_VALUE_ENUM (*arg) = mitem->head_anchor;
- break;
-
- case ARG_DAY_ANCHOR:
- GTK_VALUE_ENUM (*arg) = mitem->day_anchor;
- break;
-
- case ARG_START_ON_MONDAY:
- GTK_VALUE_BOOL (*arg) = mitem->start_on_monday;
- break;
-
- case ARG_HEAD_FONT_GDK:
- GTK_VALUE_BOXED (*arg) = mitem->head_font;
- break;
-
- case ARG_DAY_FONT_GDK:
- GTK_VALUE_BOXED (*arg) = mitem->day_font;
- break;
-
- case ARG_HEAD_COLOR_GDK:
- get_color_arg (mitem, mitem->head_pixel, arg);
- break;
-
- case ARG_OUTLINE_COLOR_GDK:
- get_color_arg (mitem, mitem->outline_pixel, arg);
- break;
-
- case ARG_DAY_BOX_COLOR_GDK:
- get_color_arg (mitem, mitem->day_box_pixel, arg);
- break;
-
- case ARG_DAY_COLOR_GDK:
- get_color_arg (mitem, mitem->day_pixel, arg);
- break;
-
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-GnomeCanvasItem *
-gnome_month_item_num2child (GnomeMonthItem *mitem, int child_num)
-{
- g_return_val_if_fail (mitem != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), NULL);
-
- return mitem->items[child_num];
-}
-
-int
-gnome_month_item_child2num (GnomeMonthItem *mitem, GnomeCanvasItem *child)
-{
- int i;
-
- g_return_val_if_fail (mitem != NULL, -1);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), -1);
- g_return_val_if_fail (child != NULL, -1);
- g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (child), -1);
-
- for (i = 0; i < GNOME_MONTH_ITEM_LAST; i++)
- if (mitem->items[i] == child)
- return i;
-
- return -1;
-}
-
-int
-gnome_month_item_num2day (GnomeMonthItem *mitem, int child_num)
-{
- g_return_val_if_fail (mitem != NULL, 0);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), 0);
-
- if ((child_num >= GNOME_MONTH_ITEM_DAY_GROUP) && (child_num < GNOME_MONTH_ITEM_LAST)) {
- child_num = (child_num - GNOME_MONTH_ITEM_DAY_GROUP) % 42;
- return mitem->day_numbers[child_num];
- } else
- return 0;
-}
-
-int
-gnome_month_item_day2index (GnomeMonthItem *mitem, int day_num)
-{
- int i;
-
- g_return_val_if_fail (mitem != NULL, -1);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), -1);
- g_return_val_if_fail (day_num >= 1, -1);
-
- /* Find first day of month */
-
- for (i = 0; mitem->day_numbers[i] == 0; i++)
- ;
-
- /* Find the specified day */
-
- for (; (mitem->day_numbers[i] != 0) && (i < 42); i++)
- if (mitem->day_numbers[i] == day_num)
- return i;
-
- /* Bail out */
-
- return -1;
-}
diff --git a/calendar/gnome-month-item.h b/calendar/gnome-month-item.h
deleted file mode 100644
index 0ec4fd484c..0000000000
--- a/calendar/gnome-month-item.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/* General-purpose monthly calendar canvas item for GNOME
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef GNOME_MONTH_ITEM_H
-#define GNOME_MONTH_ITEM_H
-
-#include <libgnome/gnome-defs.h>
-#include <gtk/gtkpacker.h> /* why the hell is GtkAnchorType here and not in gtkenums.h? */
-#include <libgnomeui/gnome-canvas.h>
-
-
-BEGIN_GNOME_DECLS
-
-
-/* These values are used to identify the canvas items that make up a complete GnomeMonthItem, which
- * is made up of the following "pieces":
- *
- * Headings line:
- * - 7 GnomeCanvasGroups:
- * Each group contains one box (GnomeCanvasRectangle) and one label
- * (GnomeCanvasText)
- *
- * Day slots:
- * - 42 GnomeCanvasGroups:
- * Each group contains one box (GnomeCanvasRectangle) and one label
- * (GnomeCanvasText)
- *
- * The headings are organized from left to right. The day slots are organized as a table in
- * row-major order.
- *
- * If you want to access the individual items of the GnomeMonthItem, you can use these numbers with
- * the gnome_month_item_num2child() function. If you want to convert a number into the
- * corresponding GnomeCanvasItem, you can use the gnome_month_item_child2num() function.
- */
-typedef enum {
- GNOME_MONTH_ITEM_HEAD_GROUP = 0, /* 7 groups for headings */
- GNOME_MONTH_ITEM_HEAD_BOX = 7, /* 7 boxes for headings */
- GNOME_MONTH_ITEM_HEAD_LABEL = 14, /* 7 labels for headings */
- GNOME_MONTH_ITEM_DAY_GROUP = 21, /* 42 groups for days */
- GNOME_MONTH_ITEM_DAY_BOX = 63, /* 42 boxes for days */
- GNOME_MONTH_ITEM_DAY_LABEL = 105, /* 42 labels for days */
- GNOME_MONTH_ITEM_LAST = 147 /* total number of items */
-} GnomeMonthItemChild;
-
-/* The MonthItem canvas item defines a simple monthly calendar. It is made out of a number of
- * canvas items, which can be accessed using the functions provided. The monthly calendar is
- * anchored with respect to a point. The following arguments are available:
- *
- * name type read/write description
- * ------------------------------------------------------------------------------------------
- * year uint RW Full year (1-9999)
- * month uint RW Number of month (0-11)
- * x double RW X position of anchor point
- * y double RW Y position of anchor point
- * width double RW Width of calendar in canvas units
- * height double RW Height of calendar in canvas units
- * anchor GtkAnchorType RW Anchor side for calendar
- * heading_padding double RW Padding inside heading boxes
- * day_padding double RW Padding inside day boxes
- * day_names char ** W Array of strings corresponding to the day names (sun-sat)
- * heading_height double RW Height of headings bar in canvas units
- * heading_anchor GtkAnchorType RW Anchor side for headings inside heading boxes
- * day_anchor GtkAnchorType RW Anchor side for day numbers inside day boxes
- * start_on_monday boolean RW Specifies whether the week starts on Monday or Sunday
- * heading_font string W X logical font descriptor for the headings
- * heading_fontset string W X logical fontset descriptor for the headings
- * heading_font_gdk GdkFont * RW Pointer to GdkFont for the headings
- * day_font string W X logical font descriptor for the day numbers
- * day_fontset string W X logical fontset descriptor for the day numbers
- * day_font_gdk GdkFont * RW Pointer to GdkFont for the day numbers
- * heading_color string W X color specification for heading labels
- * heading_color_gdk GdkColor * RW Pointer to an allocated GdkColor for heading labels
- * outline_color string W X color specification for outline (lines and fill of heading boxes)
- * outline_color_gdk GdkColor * RW Pointer to an allocated GdkColor for outline
- * day_box_color string W X color specification for day boxes
- * day_box_color_gdk GdkColor * RW Pointer to an allocated GdkColor for day boxes
- * day_color string W X color specification for day number labels
- * day_color_gdk GdkColor * RW Pointer to an allocated GdkColor for day number labels
- */
-
-#define GNOME_TYPE_MONTH_ITEM (gnome_month_item_get_type ())
-#define GNOME_MONTH_ITEM(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_MONTH_ITEM, GnomeMonthItem))
-#define GNOME_MONTH_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GNOME_TYPE_MONTH_ITEM, GnomeMonthItemClass))
-#define GNOME_IS_MONTH_ITEM(obj) (GTK_CHECK_TYPE ((obj), GNOME_TYPE_MONTH_ITEM))
-#define GNOME_IS_MONTH_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_MONTH_ITEM))
-
-
-typedef struct _GnomeMonthItem GnomeMonthItem;
-typedef struct _GnomeMonthItemClass GnomeMonthItemClass;
-
-struct _GnomeMonthItem {
- GnomeCanvasGroup group;
-
- int year; /* Year to show (full, no two-digit crap) */
- int month; /* Month to show (0-11) */
-
- double x, y; /* Position at anchor */
- double width, height; /* Size of calendar */
- GtkAnchorType anchor; /* Anchor side for calendar */
-
- double head_padding; /* Padding to use between heading lines and text */
- double day_padding; /* Padding to use between day number lines and text */
-
- char *day_names[7]; /* Names to use for the day labels, starting from Sunday */
-
- double head_height; /* Height of the headings row */
- GtkAnchorType head_anchor; /* Anchor side for the heading labels */
- GtkAnchorType day_anchor; /* Anchor side for the day number labels */
-
- GnomeCanvasItem **items; /* All the items that make up the calendar */
- int day_numbers[42]; /* The numbers of the days, as they are shown in the display */
-
- GdkFont *head_font; /* Font for the headings */
- GdkFont *day_font; /* Font for the day numbers */
-
- gulong head_pixel; /* Color for heading labels */
- gulong outline_pixel; /* Color for the outline (lines and heading boxes) */
- gulong day_box_pixel; /* Color for the day boxes */
- gulong day_pixel; /* Color for day number labels */
-
- int start_on_monday : 1; /* Start the week on Monday? If false, then start from Sunday */
-};
-
-struct _GnomeMonthItemClass {
- GnomeCanvasGroupClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType gnome_month_item_get_type (void);
-
-/* Creates a new month item with the specified group as parent */
-GnomeCanvasItem *gnome_month_item_new (GnomeCanvasGroup *parent);
-
-/* Constructor function useful for derived classes */
-void gnome_month_item_construct (GnomeMonthItem *mitem);
-
-/* Returns the child item defined by the child number (as specified on the GnomeMonthItemChild
- * enumeration above).
- */
-GnomeCanvasItem *gnome_month_item_num2child (GnomeMonthItem *mitem, int child_num);
-
-/* Returns the number of the specified child item, as defined on the GnomeMonthItemChild enumeration
- * above. If the specified object is not found, it returns -1.
- */
-int gnome_month_item_child2num (GnomeMonthItem *mitem, GnomeCanvasItem *child);
-
-/* Returns the number of the day relevant to the specified child item. Day numbers are 1-based. If
- * the specified child is outside the range of displayed days, then it returns 0.
- */
-int gnome_month_item_num2day (GnomeMonthItem *mitem, int child_num);
-
-/* Returns the index (0-41) of the specified date within the table of days. If the day number is
- * invalid for the current monthly calendar, then -1 is returned.
- */
-int gnome_month_item_day2index (GnomeMonthItem *mitem, int day_num);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gnomecal.gnorba b/calendar/gnomecal.gnorba
deleted file mode 100644
index 74df8ecf04..0000000000
--- a/calendar/gnomecal.gnorba
+++ /dev/null
@@ -1,11 +0,0 @@
-[IDL:GNOME:Calendar:Repository:1.0]
-type=factory
-repo_id=IDL:Gnome/Calendar/Repository:1.0
-description=Calendar Repository
-location_info=IDL:GNOME:Calendar:RepositoryLocator:1.0
-
-[IDL:GNOME:Calendar:RepositoryLocator:1.0]
-type=exe
-repo_id=IDL:GNOME/GenericFactory:1.0
-description=Calendar Server
-location_info=gnomecal
diff --git a/calendar/goto.c b/calendar/goto.c
deleted file mode 100644
index 41609da678..0000000000
--- a/calendar/goto.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/* Go to date dialog for gnomecal
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include <gnome.h>
-#include "gnome-cal.h"
-#include "gnome-month-item.h"
-#include "main.h"
-#include "mark.h"
-#include "timeutil.h"
-
-
-static GtkWidget *goto_win; /* The goto dialog window */
-static GnomeMonthItem *month_item; /* The month item in the dialog */
-static GnomeCalendar *gnome_calendar; /* The gnome calendar the dialog refers to */
-static int current_index; /* The index of the day marked as current, or -1 if none */
-
-
-/* Updates the specified month item by marking it appropriately from the calendar the dialog refers
- * to. Also marks the current day if appropriate.
- */
-static void
-update (void)
-{
- GnomeCanvasItem *item;
- time_t t;
- struct tm tm;
-
- unmark_month_item (month_item);
- mark_month_item (month_item, gnome_calendar->cal);
-
- if (current_index != -1) {
- item = gnome_month_item_num2child (month_item,
- GNOME_MONTH_ITEM_DAY_LABEL + current_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
- "fontset", NORMAL_DAY_FONTSET,
- NULL);
- current_index = -1;
- }
-
- t = time (NULL);
- tm = *localtime (&t);
-
- if (((tm.tm_year + 1900) == month_item->year) && (tm.tm_mon == month_item->month)) {
- current_index = gnome_month_item_day2index (month_item, tm.tm_mday);
- g_assert (current_index != -1);
-
- item = gnome_month_item_num2child (month_item,
- GNOME_MONTH_ITEM_DAY_LABEL + current_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
- "fontset", CURRENT_DAY_FONTSET,
- NULL);
- }
-}
-
-/* Callback used when the year adjustment is changed */
-static void
-year_changed (GtkAdjustment *adj, gpointer data)
-{
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
- "year", (int) adj->value,
- NULL);
- update ();
-}
-
-/* Creates the year control with its adjustment */
-static GtkWidget *
-create_year (int year)
-{
- GtkWidget *hbox;
- GtkAdjustment *adj;
- GtkWidget *w;
-
- hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
-
- w = gtk_label_new (_("Year:"));
- gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- adj = GTK_ADJUSTMENT (gtk_adjustment_new (year, 1900, 9999, 1, 10, 10));
- gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
- (GtkSignalFunc) year_changed,
- NULL);
-
- w = gtk_spin_button_new (adj, 1.0, 0);
- gtk_widget_set_usize (w, 60, 0);
- gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- return hbox;
-}
-
-/* Callback used when a month button is toggled */
-static void
-month_toggled (GtkToggleButton *toggle, gpointer data)
-{
- if (!toggle->active)
- return;
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
- "month", GPOINTER_TO_INT (data),
- NULL);
- update ();
-}
-
-/* Creates the months control */
-static GtkWidget *
-create_months (int month)
-{
- GtkWidget *table;
- GtkWidget *w;
- GSList *group;
- int i, row, col;
- struct tm tm;
- char buf[100];
-
- tm = *localtime (&gnome_calendar->current_display);
-
- table = gtk_table_new (2, 6, TRUE);
-
- group = NULL;
-
- for (i = 0; i < 12; i++) {
- row = i / 6;
- col = i % 6;
-
- tm.tm_mon = i;
- strftime (buf, 100, "%b", &tm);
-
- w = gtk_radio_button_new (group);
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (w));
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (w), FALSE);
-
- gtk_container_add (GTK_CONTAINER (w), gtk_label_new (buf));
-
- if (i == month)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (w), TRUE);
-
- gtk_signal_connect (GTK_OBJECT (w), "toggled",
- (GtkSignalFunc) month_toggled,
- GINT_TO_POINTER (i));
- gtk_table_attach (GTK_TABLE (table), w,
- col, col + 1,
- row, row + 1,
- GTK_EXPAND | GTK_FILL,
- GTK_EXPAND | GTK_FILL,
- 0, 0);
- gtk_widget_show_all (w);
- }
-
- return table;
-}
-
-/* Sets the scrolling region of the canvas to the allocation size */
-static void
-set_scroll_region (GtkWidget *widget, GtkAllocation *allocation)
-{
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
- "width", (double) (allocation->width - 1),
- "height", (double) (allocation->height - 1),
- NULL);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (widget),
- 0, 0,
- allocation->width, allocation->height);
-}
-
-/* Event handler for day groups in the month item. A button press makes the calendar jump to the
- * selected day and destroys the Go-to dialog box.
- */
-static gint
-day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- int child_num, day;
-
- child_num = gnome_month_item_child2num (month_item, item);
- day = gnome_month_item_num2day (month_item, child_num);
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if ((event->button.button == 1) && (day != 0)) {
- gnome_calendar_goto (gnome_calendar,
- time_from_day (month_item->year, month_item->month, day));
- gtk_widget_destroy (goto_win);
- }
- break;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-/* Creates the canvas with the month item for selecting days */
-static GtkWidget *
-create_days (int day, int month, int year)
-{
- GtkWidget *canvas;
- int i;
- GnomeCanvasItem *day_group;
-
- canvas = gnome_canvas_new ();
- gtk_widget_set_usize (canvas, 150, 120);
-
- month_item = GNOME_MONTH_ITEM (gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (canvas))));
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
- "month", month,
- "year", year,
- "start_on_monday", week_starts_on_monday,
- NULL);
- colorify_month_item (month_item, default_color_func, NULL);
- month_item_prepare_prelight (month_item, default_color_func, NULL);
- update ();
-
- /* Connect to size_allocate so that we can change the size of the month item and the
- * scrolling region appropriately.
- */
-
- gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate",
- (GtkSignalFunc) set_scroll_region,
- NULL);
-
- /* Bind the day groups to our event handler */
-
- for (i = 0; i < 42; i++) {
- day_group = gnome_month_item_num2child (month_item, i + GNOME_MONTH_ITEM_DAY_GROUP);
- gtk_signal_connect (GTK_OBJECT (day_group), "event",
- (GtkSignalFunc) day_event,
- NULL);
- }
-
- return canvas;
-}
-
-static void
-goto_today (GtkWidget *widget, gpointer data)
-{
- gnome_calendar_goto_today (gnome_calendar);
- gtk_widget_destroy (goto_win);
-}
-
-/* Creates a "goto date" dialog and runs it */
-void
-goto_dialog (GnomeCalendar *gcal)
-{
- GtkWidget *vbox;
- GtkWidget *hbox;
- GtkWidget *w;
- GtkWidget *days;
- struct tm tm;
-
- gnome_calendar = gcal;
- current_index = -1;
-
- tm = *localtime (&gnome_calendar->current_display);
-
- goto_win = gnome_dialog_new (_("Go to date"),
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
- gnome_dialog_set_parent (GNOME_DIALOG (goto_win), GTK_WINDOW (gcal));
-
- vbox = GNOME_DIALOG (goto_win)->vbox;
-
- /* Instructions */
-
- w = gtk_label_new (_("Please select the date you want to go to.\n"
- "When you click on a day, you will be taken\n"
- "to that date."));
- gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT);
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Create month item before creating the year controls, since the latter ones need the
- * month_item to be created.
- */
-
- days = create_days (tm.tm_mday, tm.tm_mon, tm.tm_year + 1900);
-
- /* Year */
-
- w = create_year (tm.tm_year + 1900);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Month */
-
- w = create_months (tm.tm_mon);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Days (canvas with month item) */
-
- gtk_box_pack_start (GTK_BOX (vbox), days, TRUE, TRUE, 0);
- gtk_widget_show (days);
-
- /* Today button */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
- w = gtk_button_new_with_label (_("Go to today"));
- gtk_signal_connect (GTK_OBJECT (w), "clicked",
- (GtkSignalFunc) goto_today,
- NULL);
- gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Run! */
-
- gtk_window_set_modal (GTK_WINDOW (goto_win), TRUE);
- gnome_dialog_set_close (GNOME_DIALOG (goto_win), TRUE);
- gnome_dialog_set_parent (GNOME_DIALOG (goto_win), GTK_WINDOW (gnome_calendar));
- gtk_widget_show (goto_win);
-}
diff --git a/calendar/gui/GnomeCal.idl b/calendar/gui/GnomeCal.idl
deleted file mode 100644
index 1e426fae36..0000000000
--- a/calendar/gui/GnomeCal.idl
+++ /dev/null
@@ -1,125 +0,0 @@
-#include <Bonobo.idl>
-
-module GNOME {
-
- module Calendar {
-
- interface Repository {
-
- exception NotFound {};
- typedef sequence<string> String_Sequence;
-
- /*
- * get_object:
- * @uid: Unique Identifier for the object
- *
- * Returns a vCalendar object for the object
- * that matches the UID @uid.
- */
- string get_object (in string uid)
- raises (NotFound);
-
- /*
- * get_objects_by_id_list:
- * @uid_list: a sequence of Unique Identifiers
- *
- * Returns a vCalendar object for the objects
- * that matches the given UID list @uid_list;
- * NotFound is raised if any of the given UIDs
- * were not found.
- */
- string get_objects_by_id_list (in String_Sequence uid)
- raises (NotFound);
-
- /*
- * get_object_by_pilot_id:
- * @pilot_id: the pilot id
- *
- * Returns the object that has the @pilot_id
- * identifier.
- */
- string get_object_by_pilot_id (in long pilot_id)
- raises (NotFound);
-
- /*
- * get_id_from_pilot_id:
- * @pilot_id: the pilot id
- *
- * Returns the object id that matches the @pilot_id
- * identifier.
- */
- string get_id_from_pilot_id (in long pilot_id)
- raises (NotFound);
-
- /*
- * delete_object:
- * @uid: Unique Identifier for the object
- */
- void delete_object (in string uid)
- raises (NotFound);
-
- /*
- * update_object:
- * @uid: uid of object to update
- * @object: vcard object to update
- */
- void update_object (in string uid, in string object);
-
- /*
- * update_pilot_id:
- * @uid: Unique identifier for the event we want to update
- * @pilot_id: new ID assigned by the pilot
- * @pilot_status: Status to flag the event with
- */
- void update_pilot_id (in string uid, in long pilot_id, in long pilot_status)
- raises (NotFound);
-
- /*
- * get_objects:
- *
- * Danger Will Robinson : This can result in a
- * huge string, namely the size of all your entries.
- * Returns a vCalendar with all the objects
- */
- string get_objects ();
-
- /*
- * get_object_id_list
- *
- * Returns a sequence of the UID's of the entries
- */
- String_Sequence get_object_id_list();
-
- /*
- * get_updated_objects:
- *
- * Returns a vCalendar with all the objects that have been
- * modified since the last Pilot Sync
- */
- string get_updated_objects ();
-
- /*
- * Returns the number of objects of a specific type in the calendar
- * repository.
- */
-
- enum RecordStatus {
- ANY, /* This means all records */
- NEW,
- MODIFIED,
- DELETED
- };
-
- long get_number_of_objects(in RecordStatus record_status);
-
- /*
- * done:
- *
- * Informs the calendar that we are done using it,
- * gets a chance to destroy windows and save information.
- */
- void done ();
- };
- };
-};
-
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
deleted file mode 100644
index 408f80dd76..0000000000
--- a/calendar/gui/Makefile.am
+++ /dev/null
@@ -1,271 +0,0 @@
-SUBDIRS = doc
-
-idldir = $(datadir)/idl
-idl_DATA = \
- GnomeCal.idl \
- evolution-calendar.idl
-
-gnorbadir = $(sysconfdir)/CORBA/servers
-gnorba_DATA = \
- gnomecal.gnorba \
- tlacuache.gnorba
-
-help_base = $(datadir)/gnome/help/cal
-
-if HAVE_GNOME_PILOT
-extra_pilot_bins = \
- calendar-conduit-control-applet \
- calendar-pilot-sync
-endif
-
-bin_PROGRAMS = gnomecal tlacuache $(extra_pilot_bins)
-
-INCLUDES = \
- -I$(includedir) \
- $(GNOME_INCLUDEDIR) \
- $(GNOME_CONDUIT_INCLUDEDIR) \
- $(PISOCK_INCLUDEDIR) \
- -DGNOMELOCALEDIR=\""$(datadir)/locale"\"
-
-GNOMECAL_CORBA_GENERATED = \
- GnomeCal.h \
- GnomeCal.c \
- GnomeCal-common.c \
- GnomeCal-skels.c \
- GnomeCal-stubs.c
-
-$(GNOMECAL_CORBA_GENERATED): GnomeCal.idl
- orbit-idl $(srcdir)/GnomeCal.idl
-
-corba-cal.c \
-corba-cal.h \
-corba-cal-factory.c \
-corba-cal-factory.h: GnomeCal.h
-
-GNOME_CALENDAR_CORBA_GENERATED = \
- evolution-calendar.h \
- evolution-calendar-common.c \
- evolution-calendar-skels.c \
- evolution-calendar-stubs.c
-
-$(GNOME_CALENDAR_CORBA_GENERATED): evolution-calendar.idl
- orbit-idl -I`$(GNOME_CONFIG) --datadir`/idl $(srcdir)/evolution-calendar.idl
-
-gnomecal_SOURCES = \
- $(GNOME_CALENDAR_CORBA_GENERATED) \
- GnomeCal-common.c \
- GnomeCal-skels.c \
- GnomeCal.h \
- alarm.c \
- alarm.h \
- cal-client.c \
- cal-client.h \
- cal-listener.c \
- cal-listener.h \
- calendar.c \
- calendar.h \
- calendar-conduit.h \
- calobj.c \
- calobj.h \
- eventedit.c \
- eventedit.h \
- corba-cal.c \
- corba-cal.h \
- corba-cal-factory.c \
- corba-cal-factory.h \
- getdate.y \
- gncal-day-panel.c \
- gncal-day-panel.h \
- gncal-day-view.c \
- gncal-day-view.h \
- gncal-full-day.c \
- gncal-full-day.h \
- gncal-week-view.c \
- gncal-week-view.h \
- gncal-todo.c \
- gncal-todo.h \
- gnome-month-item.c \
- gnome-month-item.h \
- gnome-cal.c \
- gnome-cal.h \
- html-month.c \
- goto.c \
- layout.c \
- layout.h \
- main.c \
- main.h \
- mark.c \
- mark.h \
- month-view.c \
- month-view.h \
- popup-menu.c \
- popup-menu.h \
- prop.c \
- quick-view.c \
- quick-view.h \
- timeutil.c \
- timeutil.h \
- todo-conduit.h \
- view-utils.h \
- view-utils.c \
- year-view.c \
- year-view.h
-
-calendar_pilot_sync_SOURCES = \
- GnomeCal-common.c \
- GnomeCal-stubs.c \
- alarm.c \
- calendar-pilot-sync.c \
- calobj.c \
- calobj.h \
- calendar.c \
- calendar.h \
- timeutil.c \
- timeutil.h
-
-tlacuache_SOURCES = \
- $(GNOME_CALENDAR_CORBA_GENERATED) \
- alarm.c \
- alarm.h \
- cal.c \
- cal.h \
- cal-backend.c \
- cal-backend.h \
- cal-common.h \
- cal-factory.c \
- cal-factory.h \
- calobj.c \
- calobj.h \
- job.c \
- job.h \
- timeutil.c \
- timeutil.h \
- tlacuache.c
-
-LINK_FLAGS = \
- $(BONOBO_VFS_GNOME_LIBS) \
- $(INTLLIBS) \
- ../libversit/libversit.la
-
-tlacuache_INCLUDES = \
- $(INCLUDES) \
- -DG_LOG_DOMAIN=\"tlacuache\"
-
-tlacuache_LDADD = \
- $(BONOBO_VFS_GNOME_LIBS) \
- ../libversit/libversit.la
-
-calendar_pilot_sync_LDADD = \
- $(PISOCK_LIBDIR) $(PISOCK_LIBS) \
- $(LINK_FLAGS)
-
-if HAVE_GNOME_PILOT
-#calendar_conduit
-calendar_conduitsdir=$(libdir)/gnome-pilot/conduits
-
-calendar_conduits_LTLIBRARIES = libcalendar_conduit.la
-endif
-
-libcalendar_conduit_la_SOURCES = \
- GnomeCal-common.c \
- GnomeCal-stubs.c \
- calendar-conduit.c \
- calobj.c \
- alarm.c \
- calendar.c \
- timeutil.c
-
-calendar-conduit.c: my_gnomecal_idl
-
-libcalendar_conduit_la_LDFLAGS = \
- -rpath $(libdir)
-
-libcalendar_conduit_la_LIBADD = \
- ../libversit/libversit.la \
- $(PISOCK_LIBDIR) $(PISOCK_LIBS) \
- $(GNOME_LIBDIR) \
- $(GNOME_LIBS)
-
-calendar_conduit_control_applet_SOURCES = \
- calendar-conduit-control-applet.c
-
-calendar_conduit_control_applet_LDADD = \
- $(CAPPLET_LIBS) \
- $(GNOME_LIBDIR) \
- $(GNOME_CAPPLET_LIBS) \
- $(PISOCK_LIBDIR) $(PISOCK_LIBS) \
- $(GNOMEUI_LIBS) \
- $(GNOME_PILOT_LIBS) \
- $(INTLLIBS)
-
-#todo_conduit
-#todo_conduitsdir=$(libdir)/gnome-pilot/conduits
-
-#todo_conduits_LTLIBRARIES = libtodo_conduit.la
-
-#libtodo_conduit_la_LDFLAGS = \
-# -rpath $(libdir)
-
-#libtodo_conduit_la_LIBADD = \
-# $(GNOME_LIBDIR) \
-# $(GNOME_LIBS)
-
-#libtodo_conduit_la_SOURCES = \
-# todo-conduit.c
-
-#todo-conduit.c: GnomeCal.h
-
-#todo_conduit_control_applet_SOURCES = \
-# todo-conduit-control-applet.c
-
-#todo_conduit_control_applet_LDADD = \
-# $(CAPPLET_LIBS) \
-# $(GNOME_LIBDIR) \
-# $(GNOME_CAPPLET_LIBS) \
-# $(PISOCK_LIBDIR) $(PISOCK_LIBS) \
-# $(GNOMEUI_LIBS) \
-# $(GNOME_PILOT_LIBS) \
-# $(INTLLIBS)
-
-gnomecal_INCLUDES = \
- $(INCLUDES) \
- -DG_LOG_DOMAIN=\"gnomecal\"
-
-gnomecal_LDADD = $(LINK_FLAGS)
-
-if HAVE_GNOME_PILOT
-ccenterdir = $(datadir)/control-center
-Rootdir = $(ccenterdir)
-PalmPilotdir = $(ccenterdir)/Peripherals/PalmPilot
-Conduitsdir = $(PalmPilotdir)/Conduits
-
-Conduits_DATA = \
- calendar-conduit-control-applet.desktop
-# todo-conduit-control-applet.desktop
-
-Conduits_seconddir = $(datadir)/gnome/apps/Settings/Peripherals/PalmPilot/Conduits/
-Conduits_second_DATA = $(Conduits_DATA)
-endif
-
-EXTRA_DIST = \
- gncal.desktop \
- calendar-conduit-control-applet.desktop \
- bell.xpm \
- recur.xpm \
- $(idl_DATA) \
- $(gnorba_DATA) \
- gnome-calendar-conduit.png
-
-# todo-conduit-control-applet.desktop \
-
-
-appicondir = $(datadir)/pixmaps
-appicon_DATA = gnome-calendar-conduit.png
-
-Productivitydir = $(datadir)/gnome/apps/Applications
-
-Productivity_DATA = gncal.desktop
-
-install-data-local:
- $(mkinstalldirs) $(DESTDIR)$(help_base)/C
- $(mkinstalldirs) $(Conduitsdir)
diff --git a/calendar/gui/alarm-notify/alarm.c b/calendar/gui/alarm-notify/alarm.c
deleted file mode 100644
index cf1cd8fb60..0000000000
--- a/calendar/gui/alarm-notify/alarm.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Alarm handling for the GNOME Calendar.
- *
- * (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-#include <config.h>
-#include <time.h>
-#include <gnome.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/time.h>
-#include "calobj.h"
-#include "alarm.h"
-
-/* The pipes used to notify about an alarm */
-int alarm_pipes [2];
-
-/* The list of pending alarms */
-static GList *alarms;
-
-static void *head_alarm;
-
-typedef struct {
- time_t activation_time;
- AlarmFunction fn;
- void *closure;
- CalendarAlarm *alarm;
-} AlarmRecord;
-
-enum DebugAction {
- ALARM_ACTIVATED,
- ALARM_ADDED,
- ALARM_NOT_ADDED
-};
-
-void debug_alarm (AlarmRecord* ar, enum DebugAction action);
-void calendar_notify (time_t time, CalendarAlarm *which, void *data);
-extern int debug_alarms;
-
-/*
- * SIGALRM handler. Notifies the callback about the alarm
- */
-static void
-alarm_activate ()
-{
- char c = 0;
-
- write (alarm_pipes [1], &c, 1);
-}
-
-/*
- * SIGUSR1 handler. Toggles debugging output
- */
-static void
-toggle_debugging ()
-{
- debug_alarms = !debug_alarms;
-}
-
-static void
-alarm_ready (void *closure, int fd, GdkInputCondition cond)
-{
- AlarmRecord *ar = head_alarm;
- time_t now = time (NULL);
- char c;
-
- if (read (alarm_pipes [0], &c, 1) != 1)
- return;
-
- if (ar == NULL){
- g_warning ("Empty events. This should not happen\n");
- return;
- }
-
- while (head_alarm){
- if (debug_alarms)
- debug_alarm (ar, ALARM_ACTIVATED);
- (*ar->fn)(ar->activation_time, ar->alarm, ar->closure);
- alarms = g_list_remove (alarms, head_alarm);
-
- /* Schedule next alarm */
- if (alarms){
- AlarmRecord *next;
-
- head_alarm = alarms->data;
- next = head_alarm;
-
- if (next->activation_time > now){
- struct itimerval itimer;
-
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_sec = next->activation_time - now;
- itimer.it_value.tv_usec = 0;
- setitimer (ITIMER_REAL, &itimer, NULL);
- break;
- } else {
- g_free (ar);
- ar = next;
- }
- } else
- head_alarm = NULL;
- }
- g_free (ar);
-}
-
-static int
-alarm_compare_by_time (gconstpointer a, gconstpointer b)
-{
- const AlarmRecord *ara = a;
- const AlarmRecord *arb = b;
- time_t diff;
-
- diff = ara->activation_time - arb->activation_time;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-/**
- * alarm_add:
- *
- * Tries to schedule @alarm.
- *
- * Returns TRUE if the alarm was scheduled.
- */
-gboolean
-alarm_add (CalendarAlarm *alarm, AlarmFunction fn, void *closure)
-{
- time_t now = time (NULL);
- AlarmRecord *ar;
- time_t alarm_time = alarm->trigger;
-
- ar = g_new0 (AlarmRecord, 1);
- ar->activation_time = alarm_time;
- ar->fn = fn;
- ar->closure = closure;
- ar->alarm = alarm;
-
- /* If it already expired, do not add it */
- if (alarm_time < now) {
- if (debug_alarms)
- debug_alarm (ar, ALARM_NOT_ADDED);
- return FALSE;
- }
-
- alarms = g_list_insert_sorted (alarms, ar, alarm_compare_by_time);
-
- /* If first alarm is not the previous first alarm, reschedule SIGALRM */
- if (head_alarm != alarms->data){
- struct itimerval itimer;
- int v;
-
- /* Set the timer to disable upon activation */
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_sec = alarm_time - now;
- itimer.it_value.tv_usec = 0;
- v = setitimer (ITIMER_REAL, &itimer, NULL);
- head_alarm = alarms->data;
- }
- if (debug_alarms)
- debug_alarm (ar, ALARM_ADDED);
- return TRUE;
-}
-
-int
-alarm_kill (void *closure_key)
-{
- GList *p;
-
- for (p = alarms; p; p = p->next){
- AlarmRecord *ar = p->data;
-
- if (ar->closure == closure_key){
- alarms = g_list_remove (alarms, p->data);
- if (alarms)
- head_alarm = alarms->data;
- else
- head_alarm = NULL;
- return 1;
- }
- }
- return 0;
-}
-
-void
-alarm_init (void)
-{
- struct sigaction sa;
- struct sigaction debug_sa;
- int flags = 0;
-
- pipe (alarm_pipes);
-
- /* set non blocking mode */
- fcntl (alarm_pipes [0], F_GETFL, &flags);
- fcntl (alarm_pipes [0], F_SETFL, flags | O_NONBLOCK);
- gdk_input_add (alarm_pipes [0], GDK_INPUT_READ, alarm_ready, 0);
-
- /* Setup the signal handler */
- sa.sa_handler = alarm_activate;
- sigemptyset (&sa.sa_mask);
- sa.sa_flags = SA_RESTART;
- sigaction (SIGALRM, &sa, NULL);
-
- /* Setup a signal handler to toggle debugging */
- debug_sa.sa_handler = toggle_debugging;
- sigemptyset (&debug_sa.sa_mask);
- debug_sa.sa_flags = SA_RESTART;
- sigaction (SIGUSR1, &debug_sa, NULL);
-}
-
-void
-debug_alarm (AlarmRecord* ar, enum DebugAction action)
-{
- time_t now = time (NULL);
- iCalObject *ico = ar->closure;
- printf ("%s", ctime(&now));
- switch (action) {
- case ALARM_ADDED:
- printf ("Added alarm for %s", ctime(&ar->activation_time));
- break;
- case ALARM_NOT_ADDED:
- printf ("Alarm not added for %s", ctime(&ar->activation_time));
- break;
- case ALARM_ACTIVATED:
- printf ("Activated alarm\n");
- break;
- }
-
- if (ar->fn!=&calendar_notify) return;
- printf ("--- Summary: %s\n", ico->summary);
- switch (ar->alarm->type) {
- case ALARM_MAIL:
- printf ("--- Type: Mail\n");
- break;
- case ALARM_PROGRAM:
- printf ("--- Type: Program\n");
- break;
- case ALARM_DISPLAY:
- printf ("--- Type: Display\n");
- break;
- case ALARM_AUDIO:
- printf ("--- Type: Audio\n");
- break;
- }
-}
-
-
diff --git a/calendar/gui/alarm-notify/alarm.h b/calendar/gui/alarm-notify/alarm.h
deleted file mode 100644
index 81710bda5e..0000000000
--- a/calendar/gui/alarm-notify/alarm.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef ALARM_H
-#define ALARM_H
-
-#include <time.h>
-
-typedef void (*AlarmFunction)(time_t time, CalendarAlarm *which, void *closuse);
-
-void alarm_init (void);
-gboolean alarm_add (CalendarAlarm *alarm, AlarmFunction fn, void *closure);
-int alarm_kill (void *closure);
-
-#endif
diff --git a/calendar/gui/alarm.c b/calendar/gui/alarm.c
deleted file mode 100644
index cf1cd8fb60..0000000000
--- a/calendar/gui/alarm.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Alarm handling for the GNOME Calendar.
- *
- * (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-#include <config.h>
-#include <time.h>
-#include <gnome.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/time.h>
-#include "calobj.h"
-#include "alarm.h"
-
-/* The pipes used to notify about an alarm */
-int alarm_pipes [2];
-
-/* The list of pending alarms */
-static GList *alarms;
-
-static void *head_alarm;
-
-typedef struct {
- time_t activation_time;
- AlarmFunction fn;
- void *closure;
- CalendarAlarm *alarm;
-} AlarmRecord;
-
-enum DebugAction {
- ALARM_ACTIVATED,
- ALARM_ADDED,
- ALARM_NOT_ADDED
-};
-
-void debug_alarm (AlarmRecord* ar, enum DebugAction action);
-void calendar_notify (time_t time, CalendarAlarm *which, void *data);
-extern int debug_alarms;
-
-/*
- * SIGALRM handler. Notifies the callback about the alarm
- */
-static void
-alarm_activate ()
-{
- char c = 0;
-
- write (alarm_pipes [1], &c, 1);
-}
-
-/*
- * SIGUSR1 handler. Toggles debugging output
- */
-static void
-toggle_debugging ()
-{
- debug_alarms = !debug_alarms;
-}
-
-static void
-alarm_ready (void *closure, int fd, GdkInputCondition cond)
-{
- AlarmRecord *ar = head_alarm;
- time_t now = time (NULL);
- char c;
-
- if (read (alarm_pipes [0], &c, 1) != 1)
- return;
-
- if (ar == NULL){
- g_warning ("Empty events. This should not happen\n");
- return;
- }
-
- while (head_alarm){
- if (debug_alarms)
- debug_alarm (ar, ALARM_ACTIVATED);
- (*ar->fn)(ar->activation_time, ar->alarm, ar->closure);
- alarms = g_list_remove (alarms, head_alarm);
-
- /* Schedule next alarm */
- if (alarms){
- AlarmRecord *next;
-
- head_alarm = alarms->data;
- next = head_alarm;
-
- if (next->activation_time > now){
- struct itimerval itimer;
-
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_sec = next->activation_time - now;
- itimer.it_value.tv_usec = 0;
- setitimer (ITIMER_REAL, &itimer, NULL);
- break;
- } else {
- g_free (ar);
- ar = next;
- }
- } else
- head_alarm = NULL;
- }
- g_free (ar);
-}
-
-static int
-alarm_compare_by_time (gconstpointer a, gconstpointer b)
-{
- const AlarmRecord *ara = a;
- const AlarmRecord *arb = b;
- time_t diff;
-
- diff = ara->activation_time - arb->activation_time;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-/**
- * alarm_add:
- *
- * Tries to schedule @alarm.
- *
- * Returns TRUE if the alarm was scheduled.
- */
-gboolean
-alarm_add (CalendarAlarm *alarm, AlarmFunction fn, void *closure)
-{
- time_t now = time (NULL);
- AlarmRecord *ar;
- time_t alarm_time = alarm->trigger;
-
- ar = g_new0 (AlarmRecord, 1);
- ar->activation_time = alarm_time;
- ar->fn = fn;
- ar->closure = closure;
- ar->alarm = alarm;
-
- /* If it already expired, do not add it */
- if (alarm_time < now) {
- if (debug_alarms)
- debug_alarm (ar, ALARM_NOT_ADDED);
- return FALSE;
- }
-
- alarms = g_list_insert_sorted (alarms, ar, alarm_compare_by_time);
-
- /* If first alarm is not the previous first alarm, reschedule SIGALRM */
- if (head_alarm != alarms->data){
- struct itimerval itimer;
- int v;
-
- /* Set the timer to disable upon activation */
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_sec = alarm_time - now;
- itimer.it_value.tv_usec = 0;
- v = setitimer (ITIMER_REAL, &itimer, NULL);
- head_alarm = alarms->data;
- }
- if (debug_alarms)
- debug_alarm (ar, ALARM_ADDED);
- return TRUE;
-}
-
-int
-alarm_kill (void *closure_key)
-{
- GList *p;
-
- for (p = alarms; p; p = p->next){
- AlarmRecord *ar = p->data;
-
- if (ar->closure == closure_key){
- alarms = g_list_remove (alarms, p->data);
- if (alarms)
- head_alarm = alarms->data;
- else
- head_alarm = NULL;
- return 1;
- }
- }
- return 0;
-}
-
-void
-alarm_init (void)
-{
- struct sigaction sa;
- struct sigaction debug_sa;
- int flags = 0;
-
- pipe (alarm_pipes);
-
- /* set non blocking mode */
- fcntl (alarm_pipes [0], F_GETFL, &flags);
- fcntl (alarm_pipes [0], F_SETFL, flags | O_NONBLOCK);
- gdk_input_add (alarm_pipes [0], GDK_INPUT_READ, alarm_ready, 0);
-
- /* Setup the signal handler */
- sa.sa_handler = alarm_activate;
- sigemptyset (&sa.sa_mask);
- sa.sa_flags = SA_RESTART;
- sigaction (SIGALRM, &sa, NULL);
-
- /* Setup a signal handler to toggle debugging */
- debug_sa.sa_handler = toggle_debugging;
- sigemptyset (&debug_sa.sa_mask);
- debug_sa.sa_flags = SA_RESTART;
- sigaction (SIGUSR1, &debug_sa, NULL);
-}
-
-void
-debug_alarm (AlarmRecord* ar, enum DebugAction action)
-{
- time_t now = time (NULL);
- iCalObject *ico = ar->closure;
- printf ("%s", ctime(&now));
- switch (action) {
- case ALARM_ADDED:
- printf ("Added alarm for %s", ctime(&ar->activation_time));
- break;
- case ALARM_NOT_ADDED:
- printf ("Alarm not added for %s", ctime(&ar->activation_time));
- break;
- case ALARM_ACTIVATED:
- printf ("Activated alarm\n");
- break;
- }
-
- if (ar->fn!=&calendar_notify) return;
- printf ("--- Summary: %s\n", ico->summary);
- switch (ar->alarm->type) {
- case ALARM_MAIL:
- printf ("--- Type: Mail\n");
- break;
- case ALARM_PROGRAM:
- printf ("--- Type: Program\n");
- break;
- case ALARM_DISPLAY:
- printf ("--- Type: Display\n");
- break;
- case ALARM_AUDIO:
- printf ("--- Type: Audio\n");
- break;
- }
-}
-
-
diff --git a/calendar/gui/alarm.h b/calendar/gui/alarm.h
deleted file mode 100644
index 81710bda5e..0000000000
--- a/calendar/gui/alarm.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef ALARM_H
-#define ALARM_H
-
-#include <time.h>
-
-typedef void (*AlarmFunction)(time_t time, CalendarAlarm *which, void *closuse);
-
-void alarm_init (void);
-gboolean alarm_add (CalendarAlarm *alarm, AlarmFunction fn, void *closure);
-int alarm_kill (void *closure);
-
-#endif
diff --git a/calendar/gui/bell.xpm b/calendar/gui/bell.xpm
deleted file mode 100644
index b1ab537a17..0000000000
--- a/calendar/gui/bell.xpm
+++ /dev/null
@@ -1,83 +0,0 @@
-/* XPM */
-static char * bell_xpm[] = {
-"16 16 64 1",
-" c None",
-". c #000000",
-"+ c #E3BB43",
-"@ c #E6C049",
-"# c #EED275",
-"$ c #F4E193",
-"% c #F4DF8C",
-"& c #EAC95C",
-"* c #EFD57A",
-"= c #FAEFBB",
-"- c #FDF6D3",
-"; c #FDF5C6",
-"> c #F4E18F",
-", c #E4BD43",
-"' c #F6E295",
-") c #FEF9D8",
-"! c #FFFFFF",
-"~ c #FFFADA",
-"{ c #FCEEAA",
-"] c #EBCA5A",
-"^ c #E9C550",
-"/ c #FAEA9C",
-"( c #FEF7CB",
-"_ c #FFF8CC",
-": c #FDF1A8",
-"< c #EED060",
-"[ c #D39D12",
-"} c #F2D55D",
-"| c #FCEC91",
-"1 c #FFF4AE",
-"2 c #FFF5B6",
-"3 c #FEEF97",
-"4 c #F3D65E",
-"5 c #D5A216",
-"6 c #FAE05C",
-"7 c #FFED7C",
-"8 c #FFEF8C",
-"9 c #FFF092",
-"0 c #FDEB7A",
-"a c #F4D750",
-"b c #D8A717",
-"c c #EAC01D",
-"d c #F6D83E",
-"e c #FAE255",
-"f c #FAE362",
-"g c #F9E161",
-"h c #F6DE5B",
-"i c #F1D145",
-"j c #E6BE28",
-"k c #D09B09",
-"l c #B67E00",
-"m c #CE9100",
-"n c #D69F04",
-"o c #E0B011",
-"p c #E6BA1D",
-"q c #E3B721",
-"r c #E0B21E",
-"s c #DCAB16",
-"t c #D7A20D",
-"u c #CC9303",
-"v c #BE8400",
-"w c #AC7500",
-"x c #A06B00",
-"y c #FFDD00",
-" ",
-" .. ",
-" .+@. ",
-" .#$%&. ",
-" .*=-;>,. ",
-" .')!~{]. ",
-" .^/(~_:<[. ",
-" .}|121345. ",
-" .678980ab. ",
-" .cdefghijkl. ",
-" .mnopqrstuvwx. ",
-" .............. ",
-" .8y. ",
-" .. ",
-" ",
-" "};
diff --git a/calendar/gui/cal_struct.h b/calendar/gui/cal_struct.h
deleted file mode 100644
index 411036c7aa..0000000000
--- a/calendar/gui/cal_struct.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#define MAX_SZ 30
-
-enum RepeatType {
- Single,
- Days,
- Months,
- WeekDays,
- MonthDays
-};
-
-
-struct actionitem {
- char date[MAX_SZ];
- int time; /* Minutes past midnight */
-};
-
-struct event {
- struct actionitem start;
- struct actionitem end;
-
- enum RepeatType repeat;
- int repeatcount;
- char description[MAX_SZ];
- char subtype[MAX_SZ];
- GList *properties;
-};
-
diff --git a/calendar/gui/calendar-conduit-control-applet.c b/calendar/gui/calendar-conduit-control-applet.c
deleted file mode 100644
index 2d6fb60ef5..0000000000
--- a/calendar/gui/calendar-conduit-control-applet.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/* Control applet ("capplet") for the gnome-pilot calendar conduit, */
-/* based on */
-/* gpilotd control applet ('capplet') for use with the GNOME control center */
-/* $Id$ */
-
-#include <pwd.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <gnome.h>
-#include <ctype.h>
-
-#include <config.h>
-#include <capplet-widget.h>
-
-#include <gpilotd/gpilotd-conduit-mgmt.h>
-#include <gpilotd/gpilotd-app.h>
-#include <gpilotd/gpilotd-app-dummy-callbacks.h>
-
-#include "calendar-conduit.h"
-
-/* tell changes callbacks to ignore changes or not */
-static gboolean ignore_changes=FALSE;
-
-/* capplet widget */
-static GtkWidget *capplet=NULL;
-
-/* host/device/pilot configuration windows */
-GtkWidget *cfgOptionsWindow=NULL;
-GtkWidget *cfgStateWindow=NULL;
-GtkWidget *dialogWindow=NULL;
-
-GnomePilotConduitMgmt *conduit;
-
-static void doTrySettings(GtkWidget *widget, gpointer);
-static void doRevertSettings(GtkWidget *widget, gpointer);
-static void doSaveSettings(GtkWidget *widget, gpointer);
-
-static void readStateCfg(GtkWidget *w,GCalConduitCfg *cfg);
-static void setStateCfg(GtkWidget *w,GCalConduitCfg *cfg);
-void about_cb (GtkWidget *, gpointer);
-GCalConduitCfg *origState = NULL;
-GCalConduitCfg *curState = NULL;
-
-gint pilotId;
-CORBA_Environment ev;
-
-/* This array must be in the same order as enumerations
- in GnomePilotConduitSyncType as they are used as index.
- Custom type implies Disabled state.
-*/
-static gchar* sync_options[] ={ N_("Disabled"),
- N_("Synchronize"),
- N_("Copy From Pilot"),
- N_("Copy To Pilot"),
- N_("Merge From Pilot"),
- N_("Merge To Pilot")};
-#define SYNC_OPTIONS_COUNT 6
-
-static void
-setSettings(GCalConduitCfg* conduitCfg)
-{
- if(conduitCfg->sync_type!=GnomePilotConduitSyncTypeCustom)
- gpilotd_conduit_mgmt_enable_with_first_sync(conduit,pilotId,
- conduitCfg->sync_type,
- conduitCfg->sync_type,
- TRUE);
- else
- gpilotd_conduit_mgmt_disable(conduit,pilotId);
-
- gcalconduit_save_configuration(conduitCfg);
-}
-
-static void
-doTrySettings(GtkWidget *widget, gpointer whatever)
-{
- readStateCfg(cfgStateWindow,curState);
- setSettings(curState);
-}
-
-static void
-doSaveSettings(GtkWidget *widget, gpointer whatever)
-{
- doTrySettings(widget,whatever);
-}
-
-static void
-doCancelSettings(GtkWidget *widget, gpointer whatever)
-{
- setSettings(origState);
-}
-
-static void
-doRevertSettings(GtkWidget *widget, gpointer whatever)
-{
- gcalconduit_destroy_configuration(&curState);
- curState = gcalconduit_dupe_configuration(origState);
- setStateCfg(cfgStateWindow,curState);
- setSettings(curState);
-}
-
-static void
-insert_dir_callback (GtkEditable *editable, const gchar *text,
- gint len, gint *position, void *data)
-{
- gint i;
- gchar *curname;
-
- curname = gtk_entry_get_text(GTK_ENTRY(editable));
- if (*curname == '\0' && len > 0) {
- if (isspace(text[0])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text");
- return;
- }
- } else {
- for (i=0; i<len; i++) {
- if (isspace(text[i])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable),
- "insert_text");
- return;
- }
- }
- }
-}
-static void
-insert_dir_callback2(GtkEditable *editable, const gchar *text,
- gint length, gint *position,
- void *data)
-{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-static void
-clist_changed(GtkWidget *widget, gpointer data)
-{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-void about_cb (GtkWidget *widget, gpointer data) {
- GtkWidget *about;
- const gchar *authors[] = {_("Eskil Heyn Olsen <deity@eskil.dk>"),NULL};
-
- about = gnome_about_new(_("GnomeCalendar Conduit"), VERSION,
- _("(C) 1998"),
- authors,
- _("Configuration utility for the calendar conduit.\n"),
- _("gnome-calendar-conduit.png"));
- gtk_widget_show (about);
-
- return;
-}
-
-static void toggled_cb(GtkWidget *widget, gpointer data) {
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-/* called by the sync_type GtkOptionMenu */
-static void
-sync_action_selection(GtkMenuShell *widget, gpointer unused)
-{
- if (!ignore_changes) {
- capplet_widget_state_changed(CAPPLET_WIDGET (capplet), TRUE);
- }
-}
-
-/* called by the sync_type GtkOptionMenu */
-static void
-activate_sync_type(GtkMenuItem *widget, gpointer data)
-{
- curState->sync_type = GPOINTER_TO_INT(data);
- if(!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-static GtkWidget
-*createStateCfgWindow(void)
-{
- GtkWidget *vbox, *table;
- GtkWidget *label;
- GtkWidget *optionMenu,*menuItem;
- GtkMenu *menu;
- gint i;
-
- vbox = gtk_vbox_new(FALSE, GNOME_PAD);
-
- table = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD);
-
- label = gtk_label_new(_("Synchronize Action"));
- gtk_box_pack_start(GTK_BOX(table), label, FALSE, FALSE, GNOME_PAD);
-
- optionMenu=gtk_option_menu_new();
- gtk_object_set_data(GTK_OBJECT(vbox), "conduit_state", optionMenu);
- menu = GTK_MENU(gtk_menu_new());
-
- for (i=0; i<SYNC_OPTIONS_COUNT;i++) {
- sync_options[i]=_(sync_options[i]);
- menuItem = gtk_menu_item_new_with_label(sync_options[i]);
- gtk_widget_show(menuItem);
- gtk_signal_connect(GTK_OBJECT(menuItem),"activate",
- GTK_SIGNAL_FUNC(activate_sync_type),
- GINT_TO_POINTER(i));
- gtk_menu_append(menu,menuItem);
- }
-
- gtk_option_menu_set_menu(GTK_OPTION_MENU(optionMenu),GTK_WIDGET(menu));
- gtk_signal_connect(GTK_OBJECT(menu), "selection-done",
- GTK_SIGNAL_FUNC(sync_action_selection),
- NULL);
-
- gtk_box_pack_start(GTK_BOX(table), optionMenu, FALSE, FALSE, 0);
-
- return vbox;
-}
-
-static void
-setStateCfg(GtkWidget *widget,GCalConduitCfg *cfg)
-{
- GtkOptionMenu *optionMenu;
- GtkMenu *menu;
-
- optionMenu = gtk_object_get_data(GTK_OBJECT(widget), "conduit_state");
- g_assert(optionMenu!=NULL);
- menu = GTK_MENU(gtk_option_menu_get_menu(optionMenu));
-
-
- ignore_changes = TRUE;
- /* Here were are relying on the items in menu being the same
- order as in GnomePilotConduitSyncType. */
- gtk_option_menu_set_history(optionMenu,(int)cfg->sync_type);
- ignore_changes = FALSE;
-}
-
-
-static void
-readStateCfg(GtkWidget *w,GCalConduitCfg *cfg)
-{
-/*
- GtkWidget *button;
-
- button = gtk_object_get_data(GTK_OBJECT(w), "conduit_on_off");
-
- g_assert(button!=NULL);
-
- activated = GTK_TOGGLE_BUTTON(button)->active;
-*/
-}
-
-static void
-pilot_capplet_setup(void)
-{
- GtkWidget *frame, *table;
-
- capplet = capplet_widget_new();
-
- table = gtk_table_new(1, 2, FALSE);
- gtk_container_border_width(GTK_CONTAINER(table), GNOME_PAD);
- gtk_container_add(GTK_CONTAINER(capplet), table);
-
- frame = gtk_frame_new(_("Conduit state"));
- gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL);
- gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1);
- cfgStateWindow = createStateCfgWindow();
- gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow);
-
- gtk_signal_connect(GTK_OBJECT(capplet), "try",
- GTK_SIGNAL_FUNC(doTrySettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "revert",
- GTK_SIGNAL_FUNC(doRevertSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "ok",
- GTK_SIGNAL_FUNC(doSaveSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "cancel",
- GTK_SIGNAL_FUNC(doCancelSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "help",
- GTK_SIGNAL_FUNC(about_cb), NULL);
-
-
- setStateCfg(cfgStateWindow,curState);
-
- gtk_widget_show_all(capplet);
-}
-
-static void
-run_error_dialog(gchar *mesg,...) {
- char tmp[80];
- va_list ap;
-
- va_start(ap,mesg);
- vsnprintf(tmp,79,mesg,ap);
- dialogWindow = gnome_message_box_new(mesg,GNOME_MESSAGE_BOX_ERROR,GNOME_STOCK_BUTTON_OK,NULL);
- gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow));
- va_end(ap);
-}
-
-gint get_pilot_id_from_gpilotd() {
- gint *pilots;
- int i;
-
- i=0;
- gpilotd_get_pilot_ids(&pilots);
- if(pilots) {
- while(pilots[i]!=-1) { g_message("pilot %d = \"%d\"",i,pilots[i]); i++; }
- if(i==0) {
- run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
- return -1;
- } else {
- if(i==1)
- return pilots[0];
- else {
- g_message("too many pilots...");
- return pilots[0];
- }
- }
- } else {
- run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
- return -1;
- }
-}
-
-int
-main( int argc, char *argv[] )
-{
- /* we're a capplet */
- gnome_capplet_init ("calendar conduit control applet", NULL, argc, argv,
- NULL,
- 0, NULL);
-
- /* get pilot name from gpilotd */
- /* 1. initialize the gpilotd connection */
- if (gpilotd_init(&argc,argv)!=0) {
- run_error_dialog(_("Cannot initialze the GnomePilot Daemon"));
- g_error(_("Cannot initialze the GnomePilot Daemon"));
- return -1;
- }
-
- /* 2 connect to gpilotd */
- if (gpilotd_connect()!=0) {
- run_error_dialog(_("Cannot connect to the GnomePilot Daemon"));
- g_error(_("Cannot connect to the GnomePilot Daemon"));
- return -1;
- }
-
- pilotId = get_pilot_id_from_gpilotd();
- if(!pilotId) return -1;
-
- /* put all code to set things up in here */
- conduit = gpilotd_conduit_mgmt_new("calendar_conduit",pilotId);
- gcalconduit_load_configuration(&origState,pilotId);
- gpilotd_conduit_mgmt_get_sync_type(conduit,pilotId,&origState->sync_type);
-
- curState = gcalconduit_dupe_configuration(origState);
-
- pilot_capplet_setup();
-
-
- /* done setting up, now run main loop */
- capplet_gtk_main();
- return 0;
-}
diff --git a/calendar/gui/calendar-conduit-control-applet.desktop b/calendar/gui/calendar-conduit-control-applet.desktop
deleted file mode 100644
index 43c429ef97..0000000000
--- a/calendar/gui/calendar-conduit-control-applet.desktop
+++ /dev/null
@@ -1,7 +0,0 @@
-[Desktop Entry]
-Name=GnomeCalendar
-Comment=Configure the GnomeCal conduit
-Exec=calendar-conduit-control-applet --cap-id=1
-Terminal=0
-Type=Application
-Icon=gnome-calendar-conduit.png
diff --git a/calendar/gui/calendar-conduit.c b/calendar/gui/calendar-conduit.c
deleted file mode 100644
index 9c758b3263..0000000000
--- a/calendar/gui/calendar-conduit.c
+++ /dev/null
@@ -1,1416 +0,0 @@
-/* $Id$ */
-
-#include <glib.h>
-#include <gnome.h>
-
-#include <pi-source.h>
-#include <pi-socket.h>
-#include <pi-file.h>
-#include <pi-dlp.h>
-#include <pi-version.h>
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <utime.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <signal.h>
-#include <errno.h>
-
-#include <libgnorba/gnorba.h>
-#include <libgnorba/gnome-factory.h>
-
-#include <gpilotd/gnome-pilot-conduit.h>
-#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
-
-#include "GnomeCal.h"
-#include "calobj.h"
-#include "calendar.h"
-#include "timeutil.h"
-
-#include "calendar-conduit.h"
-
-int debug_alarms = 0; /* needed to satisfy some other part of gncal */
-/* Default values for alarms */ /* needed to satisfy some other part of gncal */
-CalendarAlarm alarm_defaults[4] = {
- { ALARM_MAIL, 0, 15, ALARM_MINUTES },
- { ALARM_PROGRAM, 0, 15, ALARM_MINUTES },
- { ALARM_DISPLAY, 0, 15, ALARM_MINUTES },
- { ALARM_AUDIO, 0, 15, ALARM_MINUTES }
-};
-
-GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
-void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
-void local_record_from_icalobject(GCalLocalRecord *local,iCalObject *obj);
-
-#define CONDUIT_VERSION "0.8.11"
-#ifdef G_LOG_DOMAIN
-#undef G_LOG_DOMAIN
-#endif
-#define G_LOG_DOMAIN "gcalconduit"
-
-#define DEBUG_CALCONDUIT
-#undef DEBUG_CALCONDUIT
-
-#ifdef DEBUG_CALCONDUIT
-#define show_exception(e) g_warning ("Exception: %s\n", CORBA_exception_id (e))
-#define LOG(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e)
-#else
-#define show_exception(e)
-#define LOG(e...)
-#endif
-
-#define WARN(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING, e)
-#define INFO(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, e)
-
-#define catch_ret_val(_env,ret) \
- if (_env._major != CORBA_NO_EXCEPTION) { \
- g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE,"%s:%d: Caught exception",__FILE__,__LINE__); \
- g_warning ("Exception: %s\n", CORBA_exception_id (&(_env))); \
- CORBA_exception_free(&(_env)); \
- return ret; \
- }
-
-static int
-start_calendar_server (GnomePilotConduitStandardAbs *conduit,
- GCalConduitContext *ctxt)
-{
-
- g_return_val_if_fail(conduit!=NULL,-2);
- g_return_val_if_fail(ctxt!=NULL,-2);
-
- ctxt->calendar = goad_server_activate_with_id (NULL,
- "IDL:GNOME:Calendar:Repository:1.0",
- 0, NULL);
- if (ctxt->calendar == CORBA_OBJECT_NIL) {
- g_warning ("Can not communicate with GnomeCalendar server");
- return -1;
- }
-
- if (ctxt->ev._major != CORBA_NO_EXCEPTION){
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- }
- return 0;
-}
-
-
-/* Just a stub to link with */
-void
-calendar_notify (time_t time, CalendarAlarm *which, void *data)
-{
-}
-
-static GSList *
-get_calendar_objects(GnomePilotConduitStandardAbs *conduit,
- gboolean *status,
- GCalConduitContext *ctxt)
-{
- GSList *result;
- GNOME_Calendar_Repository_String_Sequence *uids;
-
- g_return_val_if_fail(conduit!=NULL,NULL);
- g_return_val_if_fail(ctxt!=NULL,NULL);
-
- result = NULL;
- uids = GNOME_Calendar_Repository_get_object_id_list (ctxt->calendar, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- if(status!=NULL) (*status) = FALSE;
- return NULL;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- if(status!=NULL) (*status) = FALSE;
- return NULL;
- }
-
- if(status!=NULL) (*status) = TRUE;
- if(uids->_length>0) {
- int i;
- for(i=0;i<uids->_length;i++) {
- result = g_slist_prepend(result,g_strdup(uids->_buffer[i]));
- }
- } else {
- INFO ("No entries found");
- }
-
- CORBA_free(uids);
-
- return result;
-}
-
-static void
-local_record_from_ical_uid(GCalLocalRecord *local,
- char *uid,
- GCalConduitContext *ctxt)
-{
- iCalObject *obj;
- char *vcalendar_string;
-
- g_assert(local!=NULL);
-
- vcalendar_string = GNOME_Calendar_Repository_get_object(ctxt->calendar, uid, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- }
- g_return_if_fail(vcalendar_string!=NULL);
-
- obj = ical_object_new_from_string (vcalendar_string);
-
- local_record_from_icalobject(local,obj);
-
- return;
-}
-
-
-/*
- * converts a iCalObject to a GCalLocalRecord
- */
-
-void
-local_record_from_icalobject(GCalLocalRecord *local,
- iCalObject *obj)
-{
- g_return_if_fail(local!=NULL);
- g_return_if_fail(obj!=NULL);
-
- local->ical = obj;
- local->local.ID = local->ical->pilot_id;
-
-/*
- LOG ("local->Id = %ld [%s], status = %d",
- local->local.ID,obj->summary,local->ical->pilot_status);
-*/
- switch(local->ical->pilot_status) {
- case ICAL_PILOT_SYNC_NONE:
- local->local.attr = GnomePilotRecordNothing;
- break;
- case ICAL_PILOT_SYNC_MOD:
- local->local.attr = GnomePilotRecordModified;
- break;
- case ICAL_PILOT_SYNC_DEL:
- local->local.attr = GnomePilotRecordDeleted;
- break;
- }
-
- /* Records without a pilot_id are new */
- if(local->local.ID == 0)
- local->local.attr = GnomePilotRecordNew;
-
- local->local.secret = 0;
- if(obj->class!=NULL)
- if(strcmp(obj->class,"PRIVATE")==0)
- local->local.secret = 1;
-
- local->local.archived = 0;
-}
-
-/*
- * Given a PilotRecord, find the matching record in
- * the calendar repository. If no match, return NULL
- */
-static GCalLocalRecord *
-find_record_in_repository(GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- char *vcal_string;
- GCalLocalRecord *loc;
-
- g_return_val_if_fail(conduit!=NULL,NULL);
- g_return_val_if_fail(remote!=NULL,NULL);
-
- LOG ("requesting %ld", remote->ID);
-
- vcal_string =
- GNOME_Calendar_Repository_get_object_by_pilot_id (ctxt->calendar, remote->ID, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return NULL;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return NULL;
- } else {
- LOG ("Found");
- loc = g_new0(GCalLocalRecord,1);
- /* memory allocated in new_from_string is freed in free_match */
- local_record_from_icalobject(loc,
- ical_object_new_from_string (vcal_string));
- /* g_free(vcal_string); FIXME: this coredumps, but won't it leak without ? */
- return loc;
- }
-
- return NULL;
-}
-
-/*
- * updates an given iCalObject in the repository
- */
-static void
-update_calendar_entry_in_repository(GnomePilotConduitStandardAbs *conduit,
- iCalObject *obj,
- GCalConduitContext *ctxt)
-{
- char *str;
-
- g_return_if_fail(conduit!=NULL);
- g_return_if_fail(obj!=NULL);
-
- str = calendar_string_from_object (obj);
-
- GNOME_Calendar_Repository_update_object (ctxt->calendar, obj->uid, str, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return;
- }
-
- free (str);
-}
-
-static iCalObject *
-ical_from_remote_record(GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- iCalObject *in_obj)
-{
- iCalObject *obj;
- int i;
- struct Appointment a;
- time_t now;
-
- now = time (NULL);
-
- g_return_val_if_fail(remote!=NULL,NULL);
- memset(&a,0,sizeof(struct Appointment));
- unpack_Appointment(&a,remote->record,remote->length);
-
- if (in_obj == NULL)
- obj = ical_new (a.note ? a.note : "",
- g_get_user_name (),
- a.description ? a.description : "");
- else
- obj = in_obj;
-
- if (a.note) {
- g_free(obj->comment);
- obj->comment = g_strdup(a.note);
- }
- if (a.description) {
- g_free(obj->summary);
- obj->summary = g_strdup(a.description);
- }
-
- obj->created = now;
- obj->last_mod = now;
- obj->priority = 0;
- obj->transp = 0;
- obj->related = NULL;
- obj->pilot_id = remote->ID;
- obj->pilot_status = ICAL_PILOT_SYNC_NONE;
-
- /*
- * Begin and end
- */
-
- if (a.event)
- {
- /* turn day-long events into a full day's appointment
- FIXME: get settings from gnomecal */
- a.begin.tm_sec = 0;
- a.begin.tm_min = 0;
- a.begin.tm_hour = 0;
-
- a.end.tm_sec = 0;
- a.end.tm_min =59;
- a.end.tm_hour = 23;
- }
-
- obj->dtstart = mktime (&a.begin);
- obj->dtend = mktime (&a.end);
-
- /* Special case: daily repetitions are converted to a multi-day event */
- /* This sucketh, a pilot event scheduled for dailyRepeat, freq 1, end on
- whatever is cleary converted wrong
- if (a.repeatType == repeatDaily){
- time_t newt = time_add_day (obj->dtend, a.repeatFrequency);
-
- obj->dtend = newt;
- }
- */
-
- /*
- * Alarm
- */
- if (a.alarm){
- obj->aalarm.type = ALARM_AUDIO;
- obj->aalarm.enabled = 1;
- obj->aalarm.count = a.advance;
-
- switch (a.advanceUnits){
- case advMinutes:
- obj->aalarm.units = ALARM_MINUTES;
- break;
-
- case advHours:
- obj->aalarm.units = ALARM_HOURS;
- break;
-
- case advDays:
- obj->aalarm.units = ALARM_DAYS;
- break;
- default:
- }
- }
-
- /*
- * Recurrence
- */
- if (a.repeatFrequency){
- obj->recur = g_new0 (Recurrence, 1);
-
- switch (a.repeatType){
- case repeatDaily:
- /*
- * In the Pilot daily repetitions are actually
- * multi-day events
- */
- obj->recur->type = RECUR_DAILY;
- break;
-
- case repeatMonthlyByDate:
- obj->recur->type = RECUR_MONTHLY_BY_DAY;
- obj->recur->u.month_day = a.repeatFrequency;
- break;
-
- case repeatWeekly:
- {
- int wd;
-
- obj->recur->type = RECUR_WEEKLY;
- for (wd = 0; wd < 7; wd++)
- if (a.repeatDays [wd])
- obj->recur->weekday |= 1 << wd;
-
- if (obj->recur->weekday == 0){
- struct tm tm = *localtime (&obj->dtstart);
-
- obj->recur->weekday = 1 << tm.tm_wday;
- }
- break;
- }
-
- case repeatMonthlyByDay:
- obj->recur->type = RECUR_MONTHLY_BY_POS;
- obj->recur->u.month_pos = a.repeatFrequency;
- obj->recur->weekday = (a.repeatDay / 7);
- break;
-
- case repeatYearly:
- obj->recur->type = RECUR_YEARLY_BY_DAY;
- break;
-
- default:
- g_assert_not_reached();
- }
-
- if (a.repeatForever)
- obj->recur->duration = 0;
- else
- obj->recur->_enddate = mktime (&a.repeatEnd);
-
- obj->recur->interval = a.repeatFrequency;
- }
-
- /*
- * Load exception dates
- */
- obj->exdate = NULL;
- for (i = 0; i < a.exceptions; i++){
- time_t *t = g_new (time_t, 1);
-
- *t = mktime (&(a.exception [i]));
- obj->exdate = g_list_prepend (obj->exdate, t);
- }
-
- g_free (obj->class);
-
- if (remote->attr & dlpRecAttrSecret)
- obj->class = g_strdup ("PRIVATE");
- else
- obj->class = g_strdup ("PUBLIC");
-
-
- free_Appointment(&a);
-
- return obj;
-}
-
-/* Code blatantly stolen from
- * calendar-pilot-sync.c:
- *
- * (C) 1999 International GNOME Support
- *
- * Author:
- * Miguel de Icaza (miguel@gnome-support.com)
- *
- */
-static gint
-update_record (GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- char *vcal_string;
- iCalObject *obj;
- struct Appointment a;
-
- g_return_val_if_fail(remote!=NULL,-1);
-
- memset(&a,0,sizeof(struct Appointment));
- unpack_Appointment(&a,remote->record,remote->length);
-
- obj = ical_new (a.note ? a.note : "",
- g_get_user_name (),
- a.description ? a.description : "");
-
- LOG ("requesting %ld [%s]", remote->ID, a.description);
- vcal_string = GNOME_Calendar_Repository_get_object_by_pilot_id (ctxt->calendar, remote->ID, &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- LOG ("Object did not exist, creating a new one");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- ical_from_remote_record(conduit,remote,obj);
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- ical_object_destroy (obj);
- free_Appointment(&a);
- return -1;
- } else {
- LOG ("Found");
- ical_object_destroy (obj);
- obj = ical_object_new_from_string (vcal_string);
- ical_from_remote_record(conduit,remote,obj);
- CORBA_free(vcal_string);
- }
-
- /* update record on server */
-
- update_calendar_entry_in_repository(conduit,obj,ctxt);
-
- /*
- * Shutdown
- */
- ical_object_destroy (obj);
- free_Appointment(&a);
-
- return 0;
-}
-
-static void
-check_for_slow_setting(GnomePilotConduit *c,
- GCalConduitContext *ctxt)
-{
- CORBA_long entry_number;
- entry_number =
- GNOME_Calendar_Repository_get_number_of_objects(ctxt->calendar,
- GNOME_Calendar_Repository_ANY,
- &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- } else {
- LOG (_("Calendar holds %d entries"),entry_number);
- /* If the local base is empty, do a slow sync */
- if ( entry_number <= 0) {
- gnome_pilot_conduit_standard_set_slow(GNOME_PILOT_CONDUIT_STANDARD(c));
- }
- }
-}
-
-static gint
-pre_sync(GnomePilotConduit *c,
- GnomePilotDBInfo *dbi,
- GCalConduitContext *ctxt)
-{
- int l;
- gint num_records;
- unsigned char *buf;
-
- g_message ("GnomeCal Conduit v.%s",CONDUIT_VERSION);
-
- ctxt->calendar = CORBA_OBJECT_NIL;
-
- if (start_calendar_server(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),ctxt) != 0) {
- WARN(_("Could not start gnomecal server"));
- gnome_pilot_conduit_error(GNOME_PILOT_CONDUIT(c),
- _("Could not start gnomecal server"));
- return -1;
- }
-
- /* Set the counters for the progress bar crap */
- num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_ANY, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
- num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_MODIFIED, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_updated_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
- num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_NEW, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_new_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
- num_records = GNOME_Calendar_Repository_get_number_of_objects (ctxt->calendar, GNOME_Calendar_Repository_DELETED, &(ctxt->ev));
- catch_ret_val(ctxt->ev,-1);
- gnome_pilot_conduit_standard_abs_set_num_deleted_local_records(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),
- num_records);
-
- gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi);
-
- /* load_records(c); */
-
- buf = (unsigned char*)g_malloc(0xffff);
- if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff)) < 0) {
- WARN(_("Could not read pilot's DateBook application block"));
- WARN("dlp_ReadAppBlock(...) = %d",l);
- gnome_pilot_conduit_error(GNOME_PILOT_CONDUIT(c),
- _("Could not read pilot's DateBook application block"));
- return -1;
- }
- unpack_AppointmentAppInfo(&(ctxt->ai),buf,l);
- g_free(buf);
-
- check_for_slow_setting(c,ctxt);
-
- return 0;
-}
-
-/**
- * Find (if possible) the local record which matches
- * the given PilotRecord.
- * if successfull, return non-zero and set *local to
- * a non-null value (the located local record),
- * otherwise return 0 and set *local = NULL;
- */
-
-static gint
-match_record (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord **local,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- LOG ("in match_record");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
-
- *local = find_record_in_repository(conduit,remote,ctxt);
-
- if (*local==NULL) return -1;
- return 0;
-}
-
-/**
- * Free the data allocated by a previous match_record call.
- * If successfull, return non-zero and ser *local=NULL, otherwise
- * return 0.
- */
-static gint
-free_match (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord **local,
- GCalConduitContext *ctxt)
-{
- LOG ("entering free_match");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(*local!=NULL,-1);
-
- ical_object_destroy (GCAL_LOCALRECORD(*local)->ical);
- g_free(*local);
-
- *local = NULL;
- return 0;
-}
-
-/*
- Move to archive and set status to Nothing
- */
-static gint
-archive_local (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- GCalConduitContext *ctxt)
-{
- LOG ("entering archive_local");
-
- g_return_val_if_fail(local!=NULL,-1);
-
- return -1;
-}
-
-/*
- Store in archive and set status to Nothing
- */
-static gint
-archive_remote (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- LOG ("entering archive_remote");
-
- g_return_val_if_fail(remote!=NULL,-1);
- g_return_val_if_fail(local!=NULL,-1);
-
- return -1;
-}
-
-/*
- Store and set status to Nothing
- */
-static gint
-store_remote (GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- LOG ("entering store_remote");
-
- g_return_val_if_fail(remote!=NULL,-1);
- remote->attr = GnomePilotRecordNothing;
-
- return update_record(conduit,remote,ctxt);
-}
-
-static gint
-clear_status_archive_local (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- GCalConduitContext *ctxt)
-{
- LOG ("entering clear_status_archive_local");
-
- g_return_val_if_fail(local!=NULL,-1);
-
- return -1;
-}
-
-static gint
-iterate (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord **local,
- GCalConduitContext *ctxt)
-{
- static GSList *events,*iterator;
- static int hest;
-
- g_return_val_if_fail(local!=NULL,-1);
-
- if(*local==NULL) {
- LOG ("beginning iteration");
-
- events = get_calendar_objects(conduit,NULL,ctxt);
- hest = 0;
-
- if(events!=NULL) {
- LOG ("iterating over %d records",g_slist_length(events));
- *local = g_new0(GCalLocalRecord,1);
-
- local_record_from_ical_uid(*local,(gchar*)events->data,ctxt);
- iterator = events;
- } else {
- LOG ("no events");
- (*local) = NULL;
- }
- } else {
- /*LOG ("continuing iteration");*/
- hest++;
- if(g_slist_next(iterator)==NULL) {
- GSList *l;
-
- LOG ("ending");
- /** free stuff allocated for iteration */
- g_free((*local));
-
- LOG ("iterated over %d records",hest);
- for(l=events;l;l=l->next)
- g_free(l->data);
-
- g_slist_free(events);
-
- /* ends iteration */
- (*local) = NULL;
- return 0;
- } else {
- iterator = g_slist_next(iterator);
- local_record_from_ical_uid(*local,(gchar*)(iterator->data),ctxt);
- }
- }
- return 1;
-}
-
-static gint
-iterate_specific (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord **local,
- gint flag,
- gint archived,
- GCalConduitContext *ctxt)
-{
-#ifdef DEBUG_CALCONDUIT
- {
- gchar *tmp;
- switch (flag) {
- case GnomePilotRecordNothing: tmp = g_strdup("RecordNothing"); break;
- case GnomePilotRecordModified: tmp = g_strdup("RecordModified"); break;
- case GnomePilotRecordNew: tmp = g_strdup("RecordNew"); break;
- default: tmp = g_strdup_printf("0x%x",flag); break;
- }
- LOG ("entering iterate_specific(flag = %s)",tmp);
- g_free(tmp);
- }
-#endif
- g_return_val_if_fail(local!=NULL,-1);
-
- /* iterate until a record meets the criteria */
- while(gnome_pilot_conduit_standard_abs_iterate(conduit,(LocalRecord**)local)) {
- if((*local)==NULL) break;
- if(archived && ((*local)->local.archived==archived)) break;
- if(((*local)->local.attr == flag)) break;
- }
-
- return (*local)==NULL?0:1;
-}
-
-static gint
-purge (GnomePilotConduitStandardAbs *conduit,
- GCalConduitContext *ctxt)
-{
- LOG ("entering purge");
-
-
- /* HEST, gem posterne her */
-
- return -1;
-}
-
-static gint
-set_status (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- gint status,
- GCalConduitContext *ctxt)
-{
- LOG ("entering set_status(status=%d)",status);
-
- g_return_val_if_fail(local!=NULL,-1);
-
- g_assert(local->ical!=NULL);
-
- local->local.attr = status;
- switch(status) {
- case GnomePilotRecordPending:
- case GnomePilotRecordNothing:
- local->ical->pilot_status = ICAL_PILOT_SYNC_NONE;
- break;
- case GnomePilotRecordDeleted:
- break;
- case GnomePilotRecordNew:
- case GnomePilotRecordModified:
- local->ical->pilot_status = ICAL_PILOT_SYNC_MOD;
- break;
- }
-
- if ( status == GnomePilotRecordDeleted) {
- GNOME_Calendar_Repository_delete_object(ctxt->calendar,local->ical->uid,&(ctxt->ev));
- } else {
- GNOME_Calendar_Repository_update_pilot_id(ctxt->calendar,
- local->ical->uid,
- local->local.ID,
- local->ical->pilot_status,
- &(ctxt->ev));
- }
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- LOG ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- }
- return 0;
-}
-
-static gint
-set_archived (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- gint archived,
- GCalConduitContext *ctxt)
-{
- LOG ("entering set_archived");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_assert(local->ical!=NULL);
-
- local->local.archived = archived;
- update_calendar_entry_in_repository(conduit,local->ical,ctxt);
- /* FIXME: This should move the entry into a speciel
- calendar file, eg. Archive, or (by config option), simply
- delete it */
- return 0;
-}
-
-static gint
-set_pilot_id (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- guint32 ID,
- GCalConduitContext *ctxt)
-{
- LOG ("entering set_pilot_id(id=%d)",ID);
-
- g_return_val_if_fail(local!=NULL,-1);
- g_assert(local->ical!=NULL);
-
- local->local.ID = ID;
- local->ical->pilot_id = ID;
- GNOME_Calendar_Repository_update_pilot_id(ctxt->calendar,
- local->ical->uid,
- local->local.ID,
- local->ical->pilot_status,
- &(ctxt->ev));
-
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- LOG ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- return -1;
- }
- return 0;
-}
-
-static gint
-transmit (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord **remote,
- GCalConduitContext *ctxt)
-{
- PilotRecord *p;
- int daycount;
-
- LOG ("entering transmit");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
- g_assert(local->ical!=NULL);
-
- p = g_new0(PilotRecord,1);
-
- p->ID = local->local.ID;
- p->attr = local->local.attr;
- p->archived = local->local.archived;
- p->secret = local->local.secret;
-
- local->a = g_new0(struct Appointment,1);
-
- local->a->event = 0; /* if no start time, leave at 1 */
- local->a->begin = *localtime(&local->ical->dtstart);
- local->a->end = *localtime(&local->ical->dtend);
-
- /* set the Audio Alarm parameters */
- if(local->ical->aalarm.enabled) {
- local->a->alarm = 1;
- local->a->advance = local->ical->aalarm.count;
- switch(local->ical->aalarm.units) {
- case ALARM_MINUTES:
- local->a->advanceUnits = advMinutes;
- break;
- case ALARM_HOURS:
- local->a->advanceUnits = advHours;
- break;
- case ALARM_DAYS:
- local->a->advanceUnits = advDays;
- break;
- }
- } else {
- local->a->alarm = 0;
- local->a->advance = 0;
- local->a->advanceUnits = advMinutes;
- }
-
- /* set the recurrence parameters */
- if (local->ical->recur != NULL) {
- switch (local->ical->recur->type) {
- case RECUR_DAILY:
- local->a->repeatType = repeatDaily;
- break;
- case RECUR_WEEKLY:
- local->a->repeatType = repeatWeekly;
- break;
- case RECUR_MONTHLY_BY_POS:
- local->a->repeatType = repeatMonthlyByDate;
- break;
- case RECUR_MONTHLY_BY_DAY:
- local->a->repeatType = repeatMonthlyByDay;
- break;
- case RECUR_YEARLY_BY_MONTH:
- local->a->repeatType = repeatYearly;
- break;
- case RECUR_YEARLY_BY_DAY:
- local->a->repeatType = repeatYearly;
- break;
- }
- if (local->ical->recur->duration == 0) {
- local->a->repeatForever = 1;
- } else {
- local->a->repeatForever = 0;
- local->a->repeatEnd = *localtime(&local->ical->recur->_enddate);
- }
- local->a->repeatFrequency = local->ical->recur->interval;
-
-
- for ( daycount=0; daycount<7; daycount++ ) {
- if (local->ical->recur->weekday & (1 << daycount))
- local->a->repeatDays[daycount] = 1;
- }
- } else {
- local->a->repeatType = repeatNone;
- local->a->repeatForever = 0;
- local->a->repeatEnd = local->a->end;
- local->a->repeatFrequency = 0;
- local->a->repeatDay = dom1stSun;
- local->a->repeatDays[0] = 0;
- local->a->repeatDays[1] = 0;
- local->a->repeatDays[2] = 0;
- local->a->repeatDays[3] = 0;
- local->a->repeatDays[4] = 0;
- local->a->repeatDays[5] = 0;
- local->a->repeatDays[6] = 0;
- local->a->repeatWeekstart = 0;
- local->a->exceptions = 0;
- local->a->exception = NULL;
- }
-
- /* STOP: don't replace these with g_strdup, since free_Appointment
- uses free to deallocte */
- local->a->note =
- local->ical->comment==NULL?NULL:strdup(local->ical->comment);
- local->a->description =
- local->ical->summary==NULL?NULL:strdup(local->ical->summary);
-
- /* Generate pilot record structure */
- p->record = g_new0(char,0xffff);
- p->length = pack_Appointment(local->a,p->record,0xffff);
-
-#if 0
- /* This is some debug code that hexdumps the calendar entry...
- You won't need this. */
- {
- int x,y;
- g_message("calconduit: new item from %s to %s",asctime(&(local->a->begin)),asctime(&(local->a->end)));
-
- g_message("local->a->note = %s",local->a->note);
- g_message("local->a->description = %s",local->a->description);
- g_message("sizeof(p->record) = %d, length is %d",sizeof(p->record),p->length);
- for(x=0;x<p->length;x+=32) {
- for(y=x;y<x+32;y++)
- if(p->record[y]<33 || p->record[y]>128)
- printf("%02X",p->record[y]);
- else
- printf(" %c",p->record[y]);
- printf("\n");
- }
- }
-#endif
-
- *remote = p;
-
- return 0;
-}
-
-static gint
-free_transmit (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord **remote,
- GCalConduitContext *ctxt)
-{
- LOG ("entering free_transmit");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
-
- free_Appointment(local->a);
- g_free((*remote)->record);
- *remote = NULL;
- return 0;
-}
-
-static gint
-compare (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- /* used by the quick compare */
- PilotRecord *remoteOfLocal;
- int err;
- int retval;
-
- /* used by the tedious compare */
- struct Appointment a;
- int daycount;
-
- g_message ("entering compare");
-
- g_return_val_if_fail (local!=NULL,-1);
- g_return_val_if_fail (remote!=NULL,-1);
-#if 1
- err = transmit(conduit,local,&remoteOfLocal,ctxt);
- if (err != 0) return err;
-
- retval = 0;
- if (remote->length == remoteOfLocal->length) {
- if (memcmp(remoteOfLocal->record,remote->record,remote->length)!=0) {
- g_message("compare failed on contents");
- retval = 1;
- }
- } else {
- g_message("compare failed on length");
- retval = 1;
- }
-
- free_transmit(conduit,local,&remoteOfLocal,ctxt);
- return retval;
-
-#else
- /** FIXME: All the { LOG("yadayada"); return 1; } bloat is for debug purposes.
- Once this is known to work, compact to return 1;'s */
-
- /* Check record attributes */
- if (local->local.ID != remote->ID) {
- LOG("failed local->local.ID == remote->ID");
- return 1;
- }
- if (local->local.attr != remote->attr) {
- LOG("failed local->local.attr == remote->attr");
- return 1;
- }
- if (local->local.archived != remote->archived) {
- LOG("failed local->local.archived == remote->archived");
- return 1;
- }
- if (local->local.secret != remote->secret) {
- LOG("failed local->local.secret == remote->secret");
- return 1;
- }
-
- unpack_Appointment(&a,remote->record,remote->length);
-
- /* Check records begin/end time */
- if (a.event==0) {
-/* FIXME
- if (a.begin != *localtime(&local->ical->dtstart)) {
- LOG("a.begin == *localtime(&local->ical->dtstart)");
- return 1;
- }
- if (a.end != *localtime(&local->ical->dtend)) {
- LOG("a.end == *localtime(&local->ical->dtend)");
- return 1;
- }
-*/
- } else {
- LOG("failed local->a.event != 0, unsupported by gnomecal");
- return 1;
- }
-
- /* Check records alarm settings */
- if(a.alarm == 1) {
- if (local->ical->aalarm.enabled == 1) {
- if (a.advance != local->ical->aalarm.count) {
- LOG("failed a.advance == local->ical->aalarm.count");
- return 1;
- }
- switch(local->ical->aalarm.units) {
- case ALARM_MINUTES:
- if (a.advanceUnits != advMinutes) {
- LOG("failed local->ical->aalarm.units == a.advanceUnits");
- return 1;
- }
- break;
- case ALARM_HOURS:
- if (a.advanceUnits != advHours) {
- LOG("failed local->ical->aalarm.units == a.advanceUnits");
- return 1;
- }
- break;
- case ALARM_DAYS:
- if (a.advanceUnits != advDays) {
- LOG("failed local->ical->aalarm.units == a.advanceUnits");
- return 1;
- }
- break;
- }
- } else {
- LOG("failed a.alarm == 1 && local->ical->aalarm.enabled == 1");
- return 1;
- }
- } else if (local->ical->aalarm.enabled == 1) {
- LOG("failed a.alarm != 1 && local->ical->aalarm.enabled != 1");
- return 1;
- }
-
- /* Check records recurrence settings */
- /* If this code is broken, a more or less safe although not efficient
- approach is (other the fixing the bug), if either has recurrence,
- return 1, thus failing the comparision */
- if (local->ical->recur != NULL) {
- if (a.repeatType == repeatNone) {
- LOG("failed: local->ical->recur != NULL && a.repeatType != repeatNone");
- return 1;
- }
- switch (local->ical->recur->type) {
- case RECUR_DAILY:
- if (a.repeatType != repeatDaily) {
- LOG("failed a.repeatType == repeatDaily");
- return 1; }
- break;
- case RECUR_WEEKLY:
- if (a.repeatType != repeatWeekly) {
- LOG("failed a.repeatType == repeatWeekly");
- return 1; }
- break;
- case RECUR_MONTHLY_BY_POS:
- if (a.repeatType != repeatMonthlyByDate) {
- LOG("failed a.repeatType == repeatMonthlyByDate");
- return 1; }
- break;
- case RECUR_MONTHLY_BY_DAY:
- if (a.repeatType != repeatMonthlyByDay) {
- LOG("failed a.repeatType == repeatMonthlyByDay");
- return 1; }
- break;
- case RECUR_YEARLY_BY_MONTH:
- if (a.repeatType != repeatYearly) {
- LOG("failed a.repeatType == repeatYearly");
- return 1; }
- break;
- case RECUR_YEARLY_BY_DAY:
- if (a.repeatType != repeatYearly) {
- LOG("failed a.repeatType == repeatYearly");
- return 1; }
- break;
- }
- if (local->ical->recur->duration == 0) {
- if(a.repeatForever != 1) {
- LOG("failed local->ical->recur->duration == 0 && a.repeatForever == 1");
- return 1;
- }
- } else {
- if(a.repeatForever != 0) {
- LOG("failed local->ical->recur->duration != 0 && ! a.repeatForever == 0");
- return 1;
- }
-/* FIXME
- if(a.repeatEnd != *localtime(&local->ical->recur->_enddate)) {
- LOG("failed a.repeatEnd == *localtime(&local->ical->recur->_enddate)");
- return 1;
- }
-*/
- }
- if (a.repeatFrequency != local->ical->recur->interval) {
- LOG("failed a.repeatFrequency == local->ical->recur->interval");
- return 1;
- }
- for (daycount = 0; daycount<7; daycount++) {
- if(local->ical->recur->weekday & (1<<daycount)) {
- if (a.repeatDays[daycount]!=1) {
- LOG("failed local->ical->recur->weekday & (1<<daycount) && a.repeatDays[daycount]==1");
- return 1;
- }
- } else {
- if (a.repeatDays[daycount]!=0) {
- LOG("failed local->ical->recur->weekday &! (1<<daycount) && a.repeatDays[daycount]==0");
- return 1;
- }
- }
- }
- } else if (a.repeatType != repeatNone ) {
- LOG("failed: local->ical->recur == NULL && a.repeatType == repeatNone");
- return 1;
- }
-
- /* check the note and description */
- if(a.note!=NULL) {
- if(local->ical->comment==NULL) {
- LOG("failed a.note != NULL && local->ical->coment != NULL");
- return 1;
- }
- if(strcmp(local->ical->comment,a.note)!=0) {
- LOG("failed strcmp(local->ical->comment,a.note)==0");
- return 1;
- }
- } if(local->ical->comment!=NULL) {
- LOG("failed a.note == NULL && local->ical->coment == NULL");
- return 1;
- }
- if(a.description!=NULL) {
- if(local->ical->summary==NULL) {
- LOG("failed a.description != NULL && local->ical->coment != NULL");
- return 1;
- }
- if(strcmp(local->ical->summary,a.description)!=0) {
- LOG("failed strcmp(local->ical->summary,a.description)==0");
- return 1;
- }
- } if(local->ical->summary!=NULL) {
- LOG("failed a.description == NULL && local->ical->coment == NULL");
- return 1;
- }
-#endif
- return 0;
-}
-
-static gint
-compare_backup (GnomePilotConduitStandardAbs *conduit,
- GCalLocalRecord *local,
- PilotRecord *remote,
- GCalConduitContext *ctxt)
-{
- LOG ("entering compare_backup");
-
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(remote!=NULL,-1);
-
- return -1;
-}
-
-static gint
-delete_all (GnomePilotConduitStandardAbs *conduit,
- GCalConduitContext *ctxt)
-{
- GSList *events,*it;
- gboolean error;
-
- events = get_calendar_objects(conduit,&error,ctxt);
-
- if (error == FALSE) return -1;
- for (it=events;it;it = g_slist_next(it)) {
- GNOME_Calendar_Repository_delete_object(ctxt->calendar,
- it->data,
- &(ctxt->ev));
- if (ctxt->ev._major == CORBA_USER_EXCEPTION){
- INFO ("Object did not exist");
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
- WARN (_("Error while communicating with calendar server"));
- show_exception(&(ctxt->ev));
- CORBA_exception_free(&(ctxt->ev));
- /* destroy loop, free data */
- for (it=events;it;it = g_slist_next(it)) g_free(it->data);
- g_slist_free(events);
- return -1;
- }
- g_free(it->data);
- }
- g_slist_free(events);
- return -1;
-}
-
-GnomePilotConduit *
-conduit_get_gpilot_conduit (guint32 pilotId)
-{
- GtkObject *retval;
- GCalConduitCfg *cfg;
- GCalConduitContext *ctxt;
-
-
- retval = gnome_pilot_conduit_standard_abs_new ("DatebookDB", 0x64617465);
- g_assert (retval != NULL);
- gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"GnomeCalConduit");
-
- gcalconduit_load_configuration(&cfg,pilotId);
- gtk_object_set_data(retval,"gcalconduit_cfg",cfg);
-
- gcalconduit_new_context(&ctxt,cfg);
- gtk_object_set_data(GTK_OBJECT(retval),"gcalconduit_context",ctxt);
-
- gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, ctxt);
- gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt);
- gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, ctxt);
- gtk_signal_connect (retval, "archive_remote", (GtkSignalFunc) archive_remote, ctxt);
- gtk_signal_connect (retval, "store_remote", (GtkSignalFunc) store_remote, ctxt);
- gtk_signal_connect (retval, "clear_status_archive_local", (GtkSignalFunc) clear_status_archive_local, ctxt);
- gtk_signal_connect (retval, "iterate", (GtkSignalFunc) iterate, ctxt);
- gtk_signal_connect (retval, "iterate_specific", (GtkSignalFunc) iterate_specific, ctxt);
- gtk_signal_connect (retval, "purge", (GtkSignalFunc) purge, ctxt);
- gtk_signal_connect (retval, "set_status", (GtkSignalFunc) set_status, ctxt);
- gtk_signal_connect (retval, "set_archived", (GtkSignalFunc) set_archived, ctxt);
- gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, ctxt);
- gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, ctxt);
- gtk_signal_connect (retval, "compare_backup", (GtkSignalFunc) compare_backup, ctxt);
- gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, ctxt);
- gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, ctxt);
- gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, ctxt);
- gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, ctxt);
-
- return GNOME_PILOT_CONDUIT (retval);
-}
-
-void
-conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
-{
- GCalConduitCfg *cc;
- GCalConduitContext *ctxt;
-
- cc = GET_GCALCONFIG(conduit);
- ctxt = GET_GCALCONTEXT(conduit);
-
- if(ctxt->calendar!=CORBA_OBJECT_NIL)
- GNOME_Calendar_Repository_done (ctxt->calendar, &(ctxt->ev));
-
- gcalconduit_destroy_configuration(&cc);
-
- gcalconduit_destroy_context(&ctxt);
-
- gtk_object_destroy (GTK_OBJECT (conduit));
-
-}
-
-
diff --git a/calendar/gui/calendar-conduit.h b/calendar/gui/calendar-conduit.h
deleted file mode 100644
index 711609e96a..0000000000
--- a/calendar/gui/calendar-conduit.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* $Id$ */
-
-#ifndef __CALENDAR_CONDUIT_H__
-#define __CALENDAR_CONDUIT_H__
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <pi-datebook.h>
-#include <gnome.h>
-
-#include "GnomeCal.h"
-#include "calobj.h"
-#include "calendar.h"
-#include "timeutil.h"
-
-#include <gpilotd/gnome-pilot-conduit.h>
-#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
-
-/* This is the local record structure for the GnomeCal conduit. */
-typedef struct _GCalLocalRecord GCalLocalRecord;
-struct _GCalLocalRecord {
- /* The stuff from gnome-pilot-conduit-standard-abs.h
- Must be first in the structure, or instances of this
- structure cannot be used by gnome-pilot-conduit-standard-abs.
- */
- LocalRecord local;
- /* The corresponding iCal object, as found by GnomeCal. */
- iCalObject *ical;
- /* pilot-link appointment structure, used for implementing Transmit. */
- struct Appointment *a;
-};
-#define GCAL_LOCALRECORD(s) ((GCalLocalRecord*)(s))
-
-/* This is the configuration of the GnomeCal conduit. */
-typedef struct _GCalConduitCfg GCalConduitCfg;
-struct _GCalConduitCfg {
- gboolean open_secret;
- guint32 pilotId;
- GnomePilotConduitSyncType sync_type; /* only used by capplet */
-};
-#define GET_GCALCONFIG(c) ((GCalConduitCfg*)gtk_object_get_data(GTK_OBJECT(c),"gcalconduit_cfg"))
-
-/* This is the context for all the GnomeCal conduit methods. */
-typedef struct _GCalConduitContext GCalConduitContext;
-struct _GCalConduitContext {
- struct AppointmentAppInfo ai;
- GCalConduitCfg *cfg;
- GNOME_Calendar_Repository calendar;
- CORBA_Environment ev;
- CORBA_ORB orb;
-};
-#define GET_GCALCONTEXT(c) ((GCalConduitContext*)gtk_object_get_data(GTK_OBJECT(c),"gcalconduit_context"))
-
-/* Given a GCalConduitCfg*, allocates the structure and
- loads the configuration data for the given pilot. */
-static void
-gcalconduit_load_configuration(GCalConduitCfg **c,
- guint32 pilotId)
-{
- gchar prefix[256];
- g_snprintf(prefix,255,"/gnome-pilot.d/calendard-conduit/Pilot_%u/",pilotId);
-
- *c = g_new0(GCalConduitCfg,1);
- g_assert(*c != NULL);
- gnome_config_push_prefix(prefix);
- (*c)->open_secret = gnome_config_get_bool("open_secret=FALSE");
- (*c)->sync_type = GnomePilotConduitSyncTypeCustom; /* set in capplets main */
- gnome_config_pop_prefix();
-
- (*c)->pilotId = pilotId;
-}
-
-/* Saves the configuration data. */
-static void
-gcalconduit_save_configuration(GCalConduitCfg *c)
-{
- gchar prefix[256];
-
- g_snprintf(prefix,255,"/gnome-pilot.d/calendar-conduit/Pilot_%u/",c->pilotId);
-
- gnome_config_push_prefix(prefix);
- gnome_config_set_bool("open_secret",c->open_secret);
- gnome_config_pop_prefix();
-
- gnome_config_sync();
- gnome_config_drop_all();
-}
-
-/* Creates a duplicate of the configuration data */
-static GCalConduitCfg*
-gcalconduit_dupe_configuration(GCalConduitCfg *c) {
- GCalConduitCfg *retval;
- g_return_val_if_fail(c!=NULL,NULL);
- retval = g_new0(GCalConduitCfg,1);
- retval->sync_type = c->sync_type;
- retval->open_secret = c->open_secret;
- retval->pilotId = c->pilotId;
- return retval;
-}
-
-/* Destroys any data allocated by gcalconduit_load_configuration
- and deallocates the given configuration. */
-static void
-gcalconduit_destroy_configuration(GCalConduitCfg **c)
-{
- g_return_if_fail(c!=NULL);
- g_return_if_fail(*c!=NULL);
- g_free(*c);
- *c = NULL;
-}
-
-/* Given a GCalConduitContxt*, allocates the structure */
-static void
-gcalconduit_new_context(GCalConduitContext **ctxt,
- GCalConduitCfg *c)
-{
- *ctxt = g_new0(GCalConduitContext,1);
- g_assert(ctxt!=NULL);
- (*ctxt)->cfg = c;
- CORBA_exception_init (&((*ctxt)->ev));
-}
-
-/* Destroys any data allocated by gcalconduit_new_context
- and deallocates its data. */
-static void
-gcalconduit_destroy_context(GCalConduitContext **ctxt)
-{
- g_return_if_fail(ctxt!=NULL);
- g_return_if_fail(*ctxt!=NULL);
-/*
- if ((*ctxt)->cfg!=NULL)
- gcalconduit_destroy_configuration(&((*ctxt)->cfg));
-*/
- g_free(*ctxt);
- *ctxt = NULL;
-}
-#endif __CALENDAR_CONDUIT_H__
diff --git a/calendar/gui/calendar-pilot-sync.c b/calendar/gui/calendar-pilot-sync.c
deleted file mode 100644
index 5039bb37b7..0000000000
--- a/calendar/gui/calendar-pilot-sync.c
+++ /dev/null
@@ -1,658 +0,0 @@
-/*
- * calendar-pilot-sync.c:
- *
- * (C) 1999 International GNOME Support
- *
- * Author:
- * Miguel de Icaza (miguel@gnome-support.com)
- *
- */
-#include <config.h>
-#include <gnome.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <libgnorba/gnome-factory.h>
-#include <libgnorba/gnorba.h>
-#include "calobj.h"
-#include "calendar.h"
-#include "timeutil.h"
-#include "GnomeCal.h"
-#include "pi-source.h"
-#include "pi-socket.h"
-#include "pi-datebook.h"
-#include "pi-dlp.h"
-
-/* the CORBA ORB */
-CORBA_ORB orb;
-
-/* The default port to communicate with */
-char *pilot_port = "/dev/pilot";
-
-CORBA_Environment ev;
-
-/* Our pi-socket address where we connect to */
-struct pi_sockaddr addr;
-
-/* The Pilot DB identifier for DateBook */
-int db;
-
-/* If true, enable debug output for alarms */
-int debug_alarms = 0;
-
-/* True if you want to dump the flags bits from the records */
-int debug_attrs = 0;
-
-/* Default values for alarms */
-CalendarAlarm alarm_defaults[4] = {
- { ALARM_MAIL, 0, 15, ALARM_MINUTES },
- { ALARM_PROGRAM, 0, 15, ALARM_MINUTES },
- { ALARM_DISPLAY, 0, 15, ALARM_MINUTES },
- { ALARM_AUDIO, 0, 15, ALARM_MINUTES }
-};
-
-int only_desktop_to_pilot = 0;
-
-int only_pilot_to_desktop = 0;
-
-const struct poptOption calendar_sync_options [] = {
- { "pilot", 0, POPT_ARG_STRING, &pilot_port, 0,
- N_("Specifies the port on which the Pilot is"), N_("PORT") },
- { "debug-attrs", 0, POPT_ARG_NONE, &debug_attrs, 0,
- N_("If you want to debug the attributes on records"), NULL },
- { "only-desktop", 0, POPT_ARG_NONE, &only_desktop_to_pilot, 0,
- N_("Only syncs from desktop to pilot"), NULL },
- { "only-pilot", 0, POPT_ARG_INT, &only_pilot_to_desktop, 0,
- N_("Only syncs from pilot to desktop"), NULL },
- { NULL, '\0', 0, NULL, 0 }
-};
-
-static void
-conduit_free_Appointment (struct Appointment *a)
-{
- /* free_Appointment is brain-dead with respect to guarding against
- double-frees */
-
- free_Appointment (a);
- a->exception = 0;
- a->description = 0;
- a->note = 0;
-}
-
-static int
-setup_connection (void)
-{
- int socket;
- int ret, news;
-
- if (!(socket = pi_socket(PI_AF_SLP, PI_SOCK_STREAM, PI_PF_PADP)))
- g_error (_("Can not create Pilot socket\n"));
-
- addr.pi_family = PI_AF_SLP;
- strncpy ((void *) &addr.pi_device, pilot_port, sizeof (addr.pi_device));
-
- ret = pi_bind (socket, (struct sockaddr *)&addr, sizeof (addr));
- if (ret == -1)
- g_error (_("Can not bind to device %s\n"), pilot_port);
-
- if (pi_listen (socket, 1) == -1)
- g_error (_("Failed to get a connection from the Pilot device"));
-
- if ((news = pi_accept (socket, 0, 0)) == -1)
- g_error (_("pi_accept failed"));
-
- return news;
-}
-
-static GNOME_Calendar_Repository
-locate_calendar_server (void)
-{
- GNOME_Calendar_Repository repo;
-
- repo = goad_server_activate_with_id (
- NULL, "IDL:GNOME:Calendar:Repository:1.0",
- 0, NULL);
-
- if (repo == CORBA_OBJECT_NIL)
- g_error ("Can not communicate with GnomeCalendar server");
-
- if (ev._major != CORBA_NO_EXCEPTION){
- printf ("Exception: %s\n", CORBA_exception_id (&ev));
- abort ();
- }
-
- return repo;
-}
-
-static void
-delete_record (GNOME_Calendar_Repository repo, int id)
-{
- char *uid;
-
- uid = GNOME_Calendar_Repository_get_id_from_pilot_id (repo, id, &ev);
-
- /* The record was already deleted */
- if (ev._major != CORBA_NO_EXCEPTION)
- return;
-
- GNOME_Calendar_Repository_delete_object (repo, uid, &ev);
- CORBA_free (uid);
-}
-
-static void
-update_record (GNOME_Calendar_Repository repo, int id, struct Appointment *a, int attr)
-{
- char *vcal_string;
- iCalObject *obj;
- int i;
- char *str;
-
- obj = ical_new (a->note ? a->note : "",
- g_get_user_name (),
- a->description ? a->description : "");
-
- printf ("requesting %d [%s]\n", id, a->description);
- vcal_string = GNOME_Calendar_Repository_get_object_by_pilot_id (repo, id, &ev);
-
- if (ev._major == CORBA_USER_EXCEPTION){
- time_t now = time (NULL);
-
- obj->created = now;
- obj->last_mod = now;
- obj->priority = 0;
- obj->transp = 0;
- obj->related = NULL;
- obj->pilot_id = id;
- obj->pilot_status = ICAL_PILOT_SYNC_NONE;
- printf (_("\tObject did not exist, creating a new one\n"));
- } else {
- printf ("\tFound\n");
- obj = ical_object_new_from_string (vcal_string);
- }
-
- if (obj->pilot_status == ICAL_PILOT_SYNC_MOD){
- printf (_("\tObject has been modified on desktop and on the pilot, desktop takes precedence\n"));
- ical_object_destroy (obj);
- return;
- }
-
- /*
- * Begin and end
- */
-
- if (a->event)
- {
- /* turn day-long events into a full day's appointment */
- a->begin.tm_sec = 0;
- a->begin.tm_min = 0;
- a->begin.tm_hour = 6;
-
- a->end.tm_sec = 0;
- a->end.tm_min = 0;
- a->end.tm_hour = 10;
- }
-
- obj->dtstart = mktime (&a->begin);
- obj->dtend = mktime (&a->end);
-
- /* Special case: daily repetitions are converted to a multi-day event */
- if (a->repeatType == repeatDaily){
- time_t newt = time_add_day (obj->dtend, a->repeatFrequency);
-
- obj->dtend = newt;
- }
-
- /*
- * Alarm
- */
- if (a->alarm){
- obj->aalarm.type = ALARM_AUDIO;
- obj->aalarm.enabled = 1;
- obj->aalarm.count = a->advance;
-
- switch (a->advanceUnits){
- case advMinutes:
- obj->aalarm.units = ALARM_MINUTES;
- break;
-
- case advHours:
- obj->aalarm.units = ALARM_HOURS;
- break;
-
- case advDays:
- obj->aalarm.units = ALARM_DAYS;
- break;
- default:
- }
- }
-
- /*
- * Recurrence
- */
- if (a->repeatFrequency && a->repeatType != repeatDaily){
- obj->recur = g_new0 (Recurrence, 1);
-
- switch (a->repeatType){
- case repeatDaily:
- /*
- * In the Pilot daily repetitions are actually
- * multi-day events
- */
- g_warning ("Should not have got here");
- break;
-
- case repeatMonthlyByDate:
- obj->recur->type = RECUR_MONTHLY_BY_DAY;
- obj->recur->u.month_day = a->repeatFrequency;
- break;
-
- case repeatWeekly:
- {
- int wd;
-
- obj->recur->type = RECUR_WEEKLY;
- for (wd = 0; wd < 7; wd++)
- if (a->repeatDays [wd])
- obj->recur->weekday |= 1 << wd;
-
- if (obj->recur->weekday == 0){
- struct tm tm = *localtime (&obj->dtstart);
-
- obj->recur->weekday = 1 << tm.tm_wday;
- }
- break;
- }
-
- case repeatMonthlyByDay:
- obj->recur->type = RECUR_MONTHLY_BY_POS;
- obj->recur->u.month_pos = a->repeatFrequency;
- obj->recur->weekday = (a->repeatDay / 7);
- break;
-
- case repeatYearly:
- obj->recur->type = RECUR_YEARLY_BY_DAY;
- break;
-
- default:
- g_warning ("Unhandled repeate case");
- }
-
- if (a->repeatForever)
- obj->recur->duration = 0;
- else
- obj->recur->_enddate = mktime (&a->repeatEnd);
- }
-
- /*
- * Load exception dates
- */
- obj->exdate = NULL;
- for (i = 0; i < a->exceptions; i++){
- time_t *t = g_new (time_t, 1);
-
- *t = mktime (&(a->exception [i]));
- obj->exdate = g_list_prepend (obj->exdate, t);
- }
-
- g_free (obj->class);
-
- if (attr & dlpRecAttrSecret)
- obj->class = g_strdup ("PRIVATE");
- else
- obj->class = g_strdup ("PUBLIC");
-
- /*
- * Now, convert the in memory iCalObject to a full vCalendar we can send
- */
- str = calendar_string_from_object (obj);
-
- GNOME_Calendar_Repository_update_object (repo, obj->uid, str, &ev);
-
- free (str);
-
- /*
- * Shutdown
- */
- ical_object_destroy (obj);
-}
-
-/*
- * Sets the alarm for Appointment based on @alarm
- */
-static int
-try_alarm (CalendarAlarm *alarm, struct Appointment *a)
-{
- if (!alarm->enabled)
- return 0;
-
- a->advance = alarm->count;
- switch (alarm->type){
- case ALARM_DAYS:
- a->advanceUnits = advDays;
- break;
-
- case ALARM_HOURS:
- a->advanceUnits = advHours;
- break;
-
- case ALARM_MINUTES:
- a->advanceUnits = advMinutes;
- break;
-
- default:
- return 0;
- }
- a->alarm = 1;
- return 1;
-}
-
-static void
-sync_object_to_pilot (GNOME_Calendar_Repository repo, iCalObject *obj, int pilot_fd)
-{
- char buffer [65536];
- struct Appointment *a;
- int wd, i, idx, attr, cat, rec_len;
- recordid_t new_id;
- GList *l;
-
- a = g_new0 (struct Appointment, 1);
-
- attr = 0;
- cat = 0;
- idx = 0;
-
- if (obj->pilot_id){
- rec_len = dlp_ReadRecordById (pilot_fd, db, obj->pilot_id,
- buffer, &idx, &rec_len, &attr, &cat);
-
- if (rec_len > 0)
- unpack_Appointment (a, buffer, rec_len);
- } else {
- attr = 0;
- cat = 0;
- }
-
- /* a contains the appointment either cleared or with the data from the Pilot */
- a->begin = *localtime (&obj->dtstart);
- a->end = *localtime (&obj->dtend);
-
- /* FIXME: add support for timeless */
- a->event = 0;
-
- /* Alarms, try the various ones. Probably we should only do Audio?
- * Otherwise going gnomecal->pilot->gnomecal would get the gnomecal
- * with *possibly* an alarm that was not originally defined.
- */
- a->alarm = 0;
- if (try_alarm (&obj->aalarm, a) == 0)
- if (try_alarm (&obj->dalarm, a) == 0)
- try_alarm (&obj->palarm, a);
-
- /* Recurrence */
- if (obj->recur){
- a->repeatFrequency = obj->recur->interval;
-
- switch (obj->recur->type){
- case RECUR_MONTHLY_BY_POS:
- a->repeatType = repeatMonthlyByDay;
- a->repeatFrequency = obj->recur->u.month_pos;
- a->repeatDay = obj->recur->weekday * 7;
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- a->repeatType = repeatMonthlyByDate;
- a->repeatFrequency = obj->recur->u.month_day;
- break;
-
- case RECUR_YEARLY_BY_DAY:
- a->repeatType = repeatYearly;
- break;
-
- case RECUR_WEEKLY:
- for (wd = 0; wd < 7; wd++)
- if (obj->recur->weekday & (1 << wd))
- a->repeatDays [wd] = 1;
- a->repeatType = repeatWeekly;
- break;
- case RECUR_DAILY:
-
- default:
- a->repeatType = repeatNone;
- break;
- }
- if (obj->recur->enddate == 0){
- a->repeatForever = 1;
- } else
- a->repeatEnd = *localtime (&obj->recur->enddate);
- }
-
- /*
- * Pilot uses a repeat-daily for a multi-day event, adjust for that case
- */
- if ((a->end.tm_mday != a->begin.tm_mday) ||
- (a->end.tm_mon != a->begin.tm_mon) ||
- (a->end.tm_year != a->begin.tm_year)){
- a->event = 1;
- a->begin.tm_sec = 0;
- a->begin.tm_min = 0;
- a->begin.tm_hour = 0;
-
- a->end.tm_sec = 0;
- a->end.tm_min = 0;
- a->end.tm_hour = 0;
-
- a->repeatEnd = a->end;
- a->repeatForever = 0;
- a->repeatFrequency = 1;
- a->repeatType = repeatDaily;
- }
-
- /*
- * Exceptions
- */
- a->exceptions = g_list_length (obj->exdate);
- a->exception = (struct tm *) malloc (sizeof (struct tm) * a->exceptions);
- for (i = 0, l = obj->exdate; l; l = l->next, i++){
- time_t *exdate = l->data;
-
- a->exception [i] = *localtime (exdate);
- }
-
- /*
- * Description and note.
- *
- * We use strdup to be correct. free_Appointment assumes we used
- * malloc.
- */
- if (obj->comment)
- a->note = strdup (obj->comment);
- else
- a->note = 0;
-
- if (obj->summary)
- a->description = strdup (obj->summary);
- else
- a->description = strdup (_("No description"));
-
- if (strcmp (obj->class, "PUBLIC") != 0)
- attr |= dlpRecAttrSecret;
- else
- attr &= ~dlpRecAttrSecret;
-
- /*
- * Send the appointment to the pilot
- */
- rec_len = pack_Appointment (a, buffer, sizeof (buffer));
- attr &= ~dlpRecAttrDirty;
-
- dlp_WriteRecord (
- pilot_fd, db, 0,
- obj->pilot_id, 0, buffer, rec_len, &new_id);
-
- GNOME_Calendar_Repository_update_pilot_id (repo, obj->uid, new_id, ICAL_PILOT_SYNC_NONE, &ev);
-
- conduit_free_Appointment (a);
- g_free (a);
-}
-
-static void
-sync_cal_to_pilot (GNOME_Calendar_Repository repo, Calendar *cal, int pilot_fd)
-{
- GList *l;
- int c = g_list_length (cal->events);
- int i;
-
- printf ("\n");
- for (i = 0, l = cal->events; l; l = l->next, i++){
- iCalObject *obj = l->data;
-
- printf ("Syncing desktop to pilot: %d/%d\r", i + 1, c);
- fflush (stdout);
- if (obj->pilot_status != ICAL_PILOT_SYNC_MOD){
- g_warning ("Strange, we were supposed to get only a dirty object");
- continue;
- }
-
- sync_object_to_pilot (repo, obj, pilot_fd);
- }
- printf ("\n");
-}
-
-static void
-dump_attr (int flags)
-{
- if (flags & dlpRecAttrDeleted)
- fprintf(stderr, " Deleted");
- if (flags & dlpRecAttrDirty)
- fprintf(stderr, " Dirty");
- if (flags & dlpRecAttrBusy)
- fprintf(stderr, " Busy");
- if (flags & dlpRecAttrSecret)
- fprintf(stderr, " Secret");
- if (flags & dlpRecAttrArchived)
- fprintf(stderr, " Archive");
- fprintf (stderr, "\n");
-}
-
-static void
-sync_pilot (GNOME_Calendar_Repository repo, int pilot_fd)
-{
- struct PilotUser user_info;
- int record;
- unsigned char buffer [65536];
- Calendar *dirty_cal;
- char *vcalendar_string;
- char *error;
-
- printf (_("Syncing with the pilot..."));
- dlp_ReadUserInfo (pilot_fd, &user_info);
-
- /* This informs the user of the progress on the Pilot */
- dlp_OpenConduit (pilot_fd);
-
- if (dlp_OpenDB (pilot_fd, 0, 0x80 | 0x40, "DatebookDB", &db) < 0){
- g_warning (_("Could not open DatebookDB on the Pilot"));
- dlp_AddSyncLogEntry (pilot_fd, _("Unable to open DatebookDB"));
- pi_close (pilot_fd);
- exit (1);
- }
-
- /*
- * 1. Pull all the records from the Pilot, and make any updates
- * required on the desktop side
- */
- if (!only_desktop_to_pilot){
- for (record = 0;; record++){
- struct Appointment a;
- int rec_len, attr, size;
- recordid_t id;
-
- rec_len = dlp_ReadRecordByIndex (
- pilot_fd, db,
- record, buffer, &id, &size, &attr, 0);
-
- if (rec_len < 0)
- break;
-
- printf ("processing record %d\n", record);
- unpack_Appointment (&a, buffer, rec_len);
-
- if (debug_attrs)
- dump_attr (attr);
-
- /* If the object was deleted, remove it from the database */
- if (attr & dlpRecAttrDeleted){
- printf ("Deleting id %ld\n", id);
- delete_record (repo, id);
- conduit_free_Appointment (&a);
- dlp_DeleteRecord (pilot_fd, db, 0, id);
- continue;
- }
-
- if (attr & dlpRecAttrArchived)
- continue;
-
- printf ("updating record\n");
- update_record (repo, id, &a, attr);
-
- conduit_free_Appointment (&a);
- }
- }
-
- /*
- * 2. Pull all the records from the Calendar, and move any new items
- * to the pilot
- */
- if (!only_pilot_to_desktop){
- vcalendar_string = GNOME_Calendar_Repository_get_updated_objects (repo, &ev);
- dirty_cal = calendar_new ("Temporal",CALENDAR_INIT_NIL);
- error = calendar_load_from_memory (dirty_cal, vcalendar_string);
- if (!error)
- sync_cal_to_pilot (repo, dirty_cal, pilot_fd);
- calendar_destroy (dirty_cal);
- }
-
-
- dlp_CloseDB (pilot_fd, db);
- dlp_AddSyncLogEntry (pilot_fd, _("Synced DateBook from Pilot to GnomeCal"));
- pi_close (pilot_fd);
-}
-
-int
-main (int argc, char *argv [])
-{
- int link;
- GNOME_Calendar_Repository repository;
-
- CORBA_exception_init (&ev);
- orb = gnome_CORBA_init_with_popt_table (
- "calendar-pilot-sync", VERSION, &argc, argv,
- calendar_sync_options, 0, NULL, 0, &ev);
-
- printf ("Please, press HotSync button on the palm...");
- fflush (stdout);
- link = setup_connection ();
- printf ("Connected\n");
-
- printf ("Launching GnomeCal...");
- fflush (stdout);
- repository = locate_calendar_server ();
- printf ("Done\n");
-
- printf ("<Syncing>\n");
- sync_pilot (repository, link);
- printf ("</Syncing>\n");
-
- GNOME_Calendar_Repository_done (repository, &ev);
-
- CORBA_exception_free (&ev);
-
- return 0;
-}
-
-/* Just a stub to link with */
-void
-calendar_notify (time_t time, CalendarAlarm *which, void *data)
-{
-}
-
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
deleted file mode 100644
index db31ba016b..0000000000
--- a/calendar/gui/calendar.c
+++ /dev/null
@@ -1,646 +0,0 @@
-/*
- * Calendar manager object
- *
- * This keeps track of a given calendar. Eventually this will abtract everything
- * related to getting calendars/saving calendars locally or to a remote Calendar Service
- *
- * Copyright (C) 1998, 1999 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org)
- *
- */
-
-#include <gnome.h>
-#include <stdio.h>
-#include <config.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include "calendar.h"
-#include "alarm.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
-
-#ifdef HAVE_TZNAME
-extern char *tzname[2];
-#endif
-
-/* Our day range */
-time_t calendar_day_begin, calendar_day_end;
-
-static void calendar_init_alarms (Calendar *cal);
-static void calendar_set_day (void);
-
-Calendar *
-calendar_new (char *title,CalendarNewOptions options)
-{
- Calendar *cal;
-
- cal = g_new0 (Calendar, 1);
-
- cal->title = g_strdup (title);
-
- if ((calendar_day_begin == 0) || (calendar_day_end == 0))
- calendar_set_day ();
-
- cal->event_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
- if (options & CALENDAR_INIT_ALARMS) {
- calendar_init_alarms (cal);
- }
-
- return cal;
-}
-
-static void
-try_add (iCalObject *ico, CalendarAlarm *alarm, time_t start, time_t end)
-{
- alarm->trigger = start-alarm->offset;
-
- if (alarm->trigger < calendar_day_begin)
- return;
- if (alarm->trigger > calendar_day_end)
- return;
- alarm_add (alarm, &calendar_notify, ico);
-}
-
-static int
-add_object_alarms (iCalObject *obj, time_t start, time_t end, void *closure)
-{
- if (obj->aalarm.enabled)
- try_add (obj, &obj->aalarm, start, end);
- if (obj->dalarm.enabled)
- try_add (obj, &obj->dalarm, start, end);
- if (obj->palarm.enabled)
- try_add (obj,&obj->palarm, start, end);
- if (obj->malarm.enabled)
- try_add (obj, &obj->malarm, start, end);
-
- return TRUE;
-}
-
-#define max(a,b) ((a > b) ? a : b)
-
-static void
-ical_object_try_alarms (iCalObject *obj)
-{
- int ao, po, od, mo;
- int max_o;
-
- ao = alarm_compute_offset (&obj->aalarm);
- po = alarm_compute_offset (&obj->palarm);
- od = alarm_compute_offset (&obj->dalarm);
- mo = alarm_compute_offset (&obj->malarm);
-
- max_o = max (ao, max (po, max (od, mo)));
- if (max_o == -1)
- return;
-
- ical_object_generate_events (obj, calendar_day_begin, calendar_day_end + max_o, add_object_alarms, obj);
-}
-
-void
-calendar_add_object (Calendar *cal, iCalObject *obj)
-{
- g_return_if_fail (cal != NULL);
- g_return_if_fail (obj != NULL);
- g_return_if_fail (obj->uid != NULL);
-
- obj->new = 0;
- switch (obj->type){
- case ICAL_EVENT:
- g_hash_table_insert (cal->event_hash, obj->uid, obj);
- cal->events = g_list_prepend (cal->events, obj);
- ical_object_try_alarms (obj);
-#ifdef DEBUGGING_MAIL_ALARM
- obj->malarm.trigger = 0;
- calendar_notify (0, obj);
-#endif
- break;
-
- case ICAL_TODO:
- cal->todo = g_list_prepend (cal->todo, obj);
- break;
-
- case ICAL_JOURNAL:
- cal->journal = g_list_prepend (cal->journal, obj);
- break;
- default:
- g_assert_not_reached ();
- }
-
- if (!obj->uid){
- char buffer [80];
-
- snprintf (buffer, sizeof (buffer), "GnomeCalendar-%ld\n", time (NULL));
- obj->uid = g_strdup (buffer);
- }
-
- cal->modified = TRUE;
-
- obj->last_mod = time (NULL);
-}
-
-void
-calendar_remove_object (Calendar *cal, iCalObject *obj)
-{
- switch (obj->type){
- case ICAL_EVENT:
- cal->events = g_list_remove (cal->events, obj);
- g_hash_table_remove (cal->event_hash, obj->uid);
- break;
-
- case ICAL_TODO:
- cal->todo = g_list_remove (cal->todo, obj);
- break;
-
- case ICAL_JOURNAL:
- cal->journal = g_list_remove (cal->journal, obj);
- break;
- default:
- g_assert_not_reached ();
- }
-
- cal->modified = TRUE;
-}
-
-void
-calendar_destroy (Calendar *cal)
-{
- g_list_foreach (cal->events, (GFunc) ical_object_destroy, NULL);
- g_list_free (cal->events);
-
- g_list_foreach (cal->todo, (GFunc) ical_object_destroy, NULL);
- g_list_free (cal->todo);
-
- g_list_foreach (cal->journal, (GFunc) ical_object_destroy, NULL);
- g_list_free (cal->journal);
-
- g_hash_table_destroy (cal->event_hash);
-
- if (cal->title)
- g_free (cal->title);
- if (cal->filename)
- g_free (cal->filename);
-
- g_free (cal);
-}
-
-void
-calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure)
-{
- for (; objects; objects = objects->next){
- iCalObject *object = objects->data;
-
- ical_object_generate_events (object, start, end, cb, closure);
- }
-}
-
-void
-calendar_iterate (Calendar *cal, time_t start, time_t end, calendarfn cb, void *closure)
-{
- calendar_iterate_on_objects (cal->events, start, end, cb, closure);
-}
-
-GList *
-calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func)
-{
- GList *new_events = 0;
-
- for (; objects; objects = objects->next){
- iCalObject *object = objects->data;
-
- if ((start <= object->dtstart) && (object->dtend <= end)){
- if (sort_func)
- new_events = g_list_insert_sorted (new_events, object, sort_func);
- else
- new_events = g_list_prepend (new_events, object);
- }
- }
-
- /* Put the list in increasing order if no sort function was specified */
-
- if (!sort_func)
- new_events = g_list_reverse (new_events);
-
- return new_events;
-}
-
-GList *
-calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func)
-{
- return calendar_get_objects_in_range (cal->todo, start, end, sort_func);
-}
-
-GList *
-calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func)
-{
- return calendar_get_objects_in_range (cal->journal, start, end, sort_func);
-}
-
-gint
-calendar_compare_by_dtstart (gpointer a, gpointer b)
-{
- iCalObject *obj1, *obj2;
- time_t diff;
-
- obj1 = a;
- obj2 = b;
-
- diff = obj1->dtstart - obj2->dtstart;
-
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-#define str_val(obj) (char *) vObjectUStringZValue (obj)
-
-/* Loads our calendar contents from a vObject */
-void
-calendar_load_from_vobject (Calendar *cal, VObject *vcal)
-{
- VObjectIterator i;
-
- initPropIterator (&i, vcal);
-
- while (moreIteration (&i)){
- VObject *this = nextVObject (&i);
- iCalObject *ical;
- const char *object_name = vObjectName (this);
-
- if (strcmp (object_name, VCDCreatedProp) == 0){
- cal->created = time_from_isodate (str_val (this));
- continue;
- }
-
- if (strcmp (object_name, VCLocationProp) == 0)
- continue; /* FIXME: imlement */
-
- if (strcmp (object_name, VCProdIdProp) == 0)
- continue; /* FIXME: implement */
-
- if (strcmp (object_name, VCVersionProp) == 0)
- continue; /* FIXME: implement */
-
- if (strcmp (object_name, VCTimeZoneProp) == 0)
- continue; /* FIXME: implement */
-
- ical = ical_object_create_from_vobject (this, object_name);
-
- if (ical)
- calendar_add_object (cal, ical);
- }
-}
-
-static void
-calendar_set_day (void)
-{
- time_t calendar_today;
-
- calendar_today = time (NULL);
- calendar_day_begin = time_day_begin (calendar_today);
- calendar_day_end = time_day_end (calendar_today);
-}
-
-/* Loads a calendar from a file */
-char *
-calendar_load (Calendar *cal, char *fname)
-{
- VObject *vcal;
- struct stat s;
-
- if (cal->filename){
- g_warning ("Calendar load called again\n");
- return "Internal error";
- }
-
- cal->filename = g_strdup (fname);
- vcal = Parse_MIME_FromFileName (fname);
- if (!vcal)
- return "Could not load the calendar";
-
- stat (fname, &s);
- cal->file_time = s.st_mtime;
-
- calendar_set_day ();
-
- calendar_load_from_vobject (cal, vcal);
- cleanVObject (vcal);
- cleanStrTbl ();
- return NULL;
-}
-
-/*
- * calendar_load_from_memory:
- * @cal: calendar on which we load the information
- * @buffer: A buffer that contains a vCalendar file
- *
- * Loads the information from the vCalendar information in @buffer
- * into the Calendar
- */
-char *
-calendar_load_from_memory (Calendar *cal, const char *buffer)
-{
- VObject *vcal;
-
- g_return_val_if_fail (buffer != NULL, NULL);
-
- cal->filename = g_strdup ("memory-based-calendar");
- vcal = Parse_MIME (buffer, strlen (buffer));
- if (!vcal)
- return "Could not load the calendar";
-
- cal->file_time = time (NULL);
- calendar_load_from_vobject (cal, vcal);
- cleanVObject (vcal);
- cleanStrTbl ();
-
- return NULL;
-}
-
-static VObject *
-vcalendar_create_from_calendar (Calendar *cal)
-{
- VObject *vcal;
- GList *l;
- time_t now = time (NULL);
- struct tm tm;
-
- /* WE call localtime for the side effect of setting tzname */
- tm = *localtime (&now);
-
- vcal = newVObject (VCCalProp);
- addPropValue (vcal, VCProdIdProp, "-//GNOME//NONSGML GnomeCalendar//EN");
-#if defined(HAVE_TM_ZONE)
- addPropValue (vcal, VCTimeZoneProp, tm.tm_zone);
-#elif defined(HAVE_TZNAME)
- addPropValue (vcal, VCTimeZoneProp, tzname[0]);
-#endif
- addPropValue (vcal, VCVersionProp, VERSION);
- cal->temp = vcal;
-
- /* Events */
-
- for (l = cal->events; l; l = l->next) {
- VObject *obj;
-
- obj = ical_object_to_vobject ((iCalObject *) l->data);
- addVObjectProp (vcal, obj);
- }
-
- /* To-do entries */
-
- for (l = cal->todo; l; l = l->next) {
- VObject *obj;
-
- obj = ical_object_to_vobject ((iCalObject *) l->data);
- addVObjectProp (vcal, obj);
- }
-
- return vcal;
-}
-
-void
-calendar_save (Calendar *cal, char *fname)
-{
- VObject *vcal;
- FILE *fp;
- GtkWidget *dlg;
- struct stat s;
- int status;
-
- if (fname == NULL)
- fname = cal->filename;
-
- vcal = vcalendar_create_from_calendar (cal);
- if (g_file_exists (fname)){
- char *backup_name = g_strconcat (fname, "~", NULL);
-
- if (g_file_exists (backup_name)){
- unlink (backup_name);
- }
- rename (fname, backup_name);
- g_free (backup_name);
- }
-
- fp = fopen(fname,"w");
- if (fp) {
- writeVObject(fp, vcal);
- fclose(fp);
- if (strcmp(cal->filename, fname)) {
- if (cal->filename)
- g_free (cal->filename);
- cal->filename = g_strdup (fname);
- }
- status = stat (fname, &s);
- cal->file_time = s.st_mtime;
- } else {
- dlg = gnome_message_box_new(_("Failed to save calendar!"),
- GNOME_MESSAGE_BOX_ERROR, "Ok", NULL);
- gtk_widget_show(dlg);
- }
-
- cleanVObject (vcal);
- cleanStrTbl ();
-}
-
-char *
-calendar_get_as_vcal_string (Calendar *cal)
-{
- VObject *vcal;
- char *result;
-
- g_return_val_if_fail (cal != NULL, NULL);
-
- vcal = vcalendar_create_from_calendar (cal);
- result = writeMemVObject (NULL, 0, vcal);
-
- cleanVObject (vcal);
- cleanStrTbl ();
-
- return result;
-}
-
-static gint
-calendar_object_compare_by_start (gconstpointer a, gconstpointer b)
-{
- const CalendarObject *ca = a;
- const CalendarObject *cb = b;
- time_t diff;
-
- diff = ca->ev_start - cb->ev_start;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-static int
-assemble_event_list (iCalObject *obj, time_t start, time_t end, void *c)
-{
- CalendarObject *co;
- GList **l = c;
-
- co = g_new (CalendarObject, 1);
-
- co->ev_start = start;
- co->ev_end = end;
- co->ico = obj;
- *l = g_list_insert_sorted (*l, co, calendar_object_compare_by_start);
-
- return 1;
-}
-
-void
-calendar_destroy_event_list (GList *l)
-{
- GList *p;
-
- for (p = l; p; p = p->next)
- g_free (p->data);
- g_list_free (l);
-}
-
-GList *
-calendar_get_events_in_range (Calendar *cal, time_t start, time_t end)
-{
- GList *l = 0;
-
- calendar_iterate (cal, start, end, assemble_event_list, &l);
- return l;
-}
-
-void
-calendar_object_changed (Calendar *cal, iCalObject *obj, int flags)
-{
- obj->last_mod = time (NULL);
- obj->pilot_status = ICAL_PILOT_SYNC_MOD;
-
- if (!(flags & CHANGE_DATES))
- return;
-
- /* Remove any alarms on the alarm list for this object */
- while (alarm_kill (obj))
- ;
-
- ical_object_try_alarms (obj);
-}
-
-static void
-calendar_day_change (time_t time, CalendarAlarm *which, void *closure)
-{
- GList *events;
- Calendar *cal = closure;
-
- calendar_set_day ();
- calendar_init_alarms (cal);
-
- for (events = cal->events; events; events = events->next){
- iCalObject *obj = events->data;
-
- ical_object_try_alarms (obj);
- }
-}
-
-static void
-calendar_init_alarms (Calendar *cal)
-{
- CalendarAlarm day_change_alarm;
-
- day_change_alarm.trigger = calendar_day_end;
- alarm_add (&day_change_alarm, calendar_day_change, cal);
-}
-
-static iCalObject *
-calendar_object_find_in_list (Calendar *cal, GList *list, const char *uid)
-{
- GList *l;
-
- for (l = list; l; l = l->next){
- iCalObject *obj = l->data;
-
- if (strcmp (obj->uid, uid) == 0)
- return obj;
- }
-
- return NULL;
-}
-
-iCalObject *
-calendar_object_find_event (Calendar *cal, const char *uid)
-{
- g_return_val_if_fail (cal != NULL, NULL);
- g_return_val_if_fail (uid != NULL, NULL);
-
- return g_hash_table_lookup (cal->event_hash, uid);
-}
-
-iCalObject *
-calendar_object_find_todo (Calendar *cal, const char *uid)
-{
- g_return_val_if_fail (cal != NULL, NULL);
- g_return_val_if_fail (uid != NULL, NULL);
-
- return calendar_object_find_in_list (cal, cal->todo, uid);
-}
-
-iCalObject *
-calendar_object_find (Calendar *cal, const char *uid)
-{
- iCalObject *obj;
-
- g_return_val_if_fail (cal != NULL, NULL);
- g_return_val_if_fail (uid != NULL, NULL);
-
- obj = calendar_object_find_in_list (cal, cal->todo, uid);
-
- if (obj == NULL)
- obj = calendar_object_find_in_list (cal, cal->events, uid);
-
- return obj;
-}
-
-iCalObject *
-calendar_object_find_by_pilot (Calendar *cal, int pilot_id)
-{
- GList *l;
-
- g_return_val_if_fail (cal != NULL, NULL);
-
- for (l = cal->events; l; l = l->next){
- iCalObject *obj = l->data;
-
- if (obj->pilot_id == pilot_id)
- return obj;
- }
-
- for (l = cal->todo; l; l = l->next){
- iCalObject *obj = l->data;
-
- if (obj->pilot_id == pilot_id)
- return obj;
- }
-
- return NULL;
-}
-
-/*
- * calendar_string_from_object:
- *
- * Returns the iCalObject @object armored around a vCalendar
- * object as a string.
- */
-char *
-calendar_string_from_object (iCalObject *object)
-{
- Calendar *cal;
- char *str;
-
- g_return_val_if_fail (object != NULL, NULL);
-
- cal = calendar_new ("Temporal",CALENDAR_INIT_NIL);
- calendar_add_object (cal, object);
- str = calendar_get_as_vcal_string (cal);
- calendar_remove_object (cal, object);
-
- calendar_destroy (cal);
-
- return str;
-}
diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h
deleted file mode 100644
index 858f0151ca..0000000000
--- a/calendar/gui/calendar.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef CALENDAR_H
-#define CALENDAR_H
-
-#include "calobj.h"
-
-BEGIN_GNOME_DECLS
-
-typedef struct {
- /* This calendar's title */
- char *title;
-
- /* backing store for this calendar object */
- char *filename;
-
- /* The list of events; todo's and journal entries */
- GList *events;
- GList *todo;
- GList *journal;
-
- GHashTable *event_hash;
-
- /* Time at which the calendar was created */
- time_t created;
-
- /* Timestamp in the filename */
- time_t file_time;
-
- /* If the calendar was last modified */
- int modified;
- void *temp;
-
- void *corba_server;
-} Calendar;
-
-/* This is only used by the calendar_get_events_in_range routine to get
- * a list of objects that recur on a specific date
- */
-typedef struct {
- time_t ev_start;
- time_t ev_end;
- iCalObject *ico;
-} CalendarObject;
-
-typedef enum {
- CALENDAR_INIT_NIL = 0,
- CALENDAR_INIT_ALARMS = 1 << 0
-} CalendarNewOptions;
-
-Calendar *calendar_new (char *title,CalendarNewOptions options);
-char *calendar_get_as_vcal_string (Calendar *cal);
-char *calendar_string_from_object (iCalObject *object);
-
-char *calendar_load (Calendar *cal, char *fname);
-char *calendar_load_from_memory (Calendar *cal, const char *buffer);
-void calendar_load_from_vobject (Calendar *cal, VObject *vcal);
-void calendar_save (Calendar *cal, char *fname);
-void calendar_add_object (Calendar *cal, iCalObject *obj);
-void calendar_remove_object (Calendar *cal, iCalObject *obj);
-void calendar_destroy (Calendar *cal);
-GList *calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func);
-GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
-GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
-gint calendar_compare_by_dtstart (gpointer a, gpointer b);
-
-void calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure);
-void calendar_iterate (Calendar *cal, time_t start, time_t end, calendarfn cb, void *closure);
-
-/* Returns a list of CalendarObject structures. These represent the events in the calendar that are
- * in the specified range.
- */
-GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end);
-
-/* Destroy list returned by calendar_get_events_in_range() with this function */
-void calendar_destroy_event_list (GList *l);
-
-/* Informs the calendar that obj information has changed */
-void calendar_object_changed (Calendar *cal, iCalObject *obj, int flags);
-
-void calendar_notify (time_t time, CalendarAlarm *which, void *data);
-
-iCalObject *calendar_object_find_event (Calendar *cal, const char *uid);
-iCalObject *calendar_object_find_todo (Calendar *cal, const char *uid);
-iCalObject *calendar_object_find (Calendar *cal, const char *uid);
-iCalObject *calendar_object_find_by_pilot (Calendar *cal, int pilot_id);
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/corba-cal-factory.c b/calendar/gui/corba-cal-factory.c
deleted file mode 100644
index a86af3c238..0000000000
--- a/calendar/gui/corba-cal-factory.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * corba-cal-factory.c: Service that provides access to the calendar repositories.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- */
-
-#include <config.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include "gnome-cal.h"
-#include "main.h"
-#include "alarm.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
-#include <libgnorba/gnorba.h>
-#include <bonobo.h>
-#include "GnomeCal.h"
-#include "corba-cal-factory.h"
-#include "corba-cal.h"
-
-CORBA_ORB orb;
-PortableServer_POA poa;
-PortableServer_POAManager poa_manager;
-
-static POA_Bonobo_GenericFactory__epv calendar_epv;
-static POA_Bonobo_GenericFactory__vepv calendar_vepv;
-
-/*
- * Servant and Object Factory
- */
-static POA_Bonobo_GenericFactory calendar_servant;
-static Bonobo_GenericFactory calendar_factory;
-
-static CORBA_boolean
-calendar_supports (PortableServer_Servant servant,
- CORBA_char * obj_goad_id,
- CORBA_Environment * ev)
-{
- if (strcmp (obj_goad_id, "IDL:GNOME:Calendar:Repository:1.0") == 0)
- return CORBA_TRUE;
- else
- return CORBA_FALSE;
-}
-
-static CORBA_Object
-calendar_create_object (PortableServer_Servant servant,
- CORBA_char *goad_id,
- const GNOME_stringlist *params,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal;
- struct stat s;
- char *name;
-
- if (params->_length == 1)
- name = params->_buffer [0];
- else
- name = NULL;
-
- if (strcmp (goad_id, "IDL:GNOME:Calendar:Repository:1.0") != 0){
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_Bonobo_GenericFactory_CannotActivate,
- NULL);
- return CORBA_OBJECT_NIL;
- }
-
- gcal = gnome_calendar_locate (name);
- if (gcal != NULL)
- return CORBA_Object_duplicate (gcal->cal->corba_server, ev);
-
- if (stat (name, &s) != 0){
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_Bonobo_GenericFactory_CannotActivate,
- NULL);
- return CORBA_OBJECT_NIL;
- }
-
- gcal = new_calendar ("", name, NULL, NULL, FALSE);
-
- return CORBA_Object_duplicate (gcal->cal->corba_server, ev);
-}
-
-void
-init_corba_server (void)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- poa_manager = PortableServer_POA__get_the_POAManager (poa, &ev);
- if (ev._major != CORBA_NO_EXCEPTION){
- g_warning ("Can not get the POA manager");
- CORBA_exception_free (&ev);
- return;
- }
-
- PortableServer_POAManager_activate (poa_manager, &ev);
-
- /* First create the locator for the repositories as a factory object */
- calendar_vepv.Bonobo_GenericFactory_epv = &calendar_epv;
- calendar_epv.supports = calendar_supports;
- calendar_epv.create_object = calendar_create_object;
-
- calendar_servant.vepv = &calendar_vepv;
- POA_Bonobo_GenericFactory__init ((PortableServer_Servant) &calendar_servant, &ev);
- CORBA_free (PortableServer_POA_activate_object (
- poa, (PortableServer_Servant)&calendar_servant, &ev));
-
- calendar_factory = PortableServer_POA_servant_to_reference (
- poa, (PortableServer_Servant) &calendar_servant, &ev);
-
- goad_server_register (
- CORBA_OBJECT_NIL, calendar_factory,
- "IDL:GNOME:Calendar:RepositoryLocator:1.0", "object", &ev);
- CORBA_exception_free (&ev);
-}
-
-void
-unregister_calendar_services (void)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
- goad_server_unregister (
- CORBA_OBJECT_NIL,
- "IDL:GNOME:Calendar:RepositoryLocator:1.0", "object", &ev);
- CORBA_exception_free (&ev);
-}
diff --git a/calendar/gui/corba-cal-factory.h b/calendar/gui/corba-cal-factory.h
deleted file mode 100644
index 5d3bcb3140..0000000000
--- a/calendar/gui/corba-cal-factory.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _CORBA_CAL_FACTORY_H_
-#define _CORBA_CAL_FACTORY_H_
-
-/* The CORBA globals */
-CORBA_ORB orb;
-PortableServer_POA poa;
-
-void corba_server_init (void);
-void unregister_calendar_services (void);
-
-#endif /* _CORBA_CAL_FACTORY_H_ */
diff --git a/calendar/gui/corba-cal.c b/calendar/gui/corba-cal.c
deleted file mode 100644
index 74afc0e76a..0000000000
--- a/calendar/gui/corba-cal.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * corba-cal.c: Service that provides access to the calendar repository
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- */
-
-#include <config.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include "calendar.h"
-#include "gnome-cal.h"
-#include "alarm.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
-#include <libgnorba/gnome-factory.h>
-#include "GnomeCal.h"
-#include "corba-cal-factory.h"
-#include "corba-cal.h"
-
-typedef struct {
- POA_GNOME_Calendar_Repository servant;
- GnomeCalendar *calendar;
-} CalendarServant;
-
-/*
- * Vectors
- */
-static POA_GNOME_Calendar_Repository__epv calendar_repository_epv;
-static POA_GNOME_Calendar_Repository__vepv calendar_repository_vepv;
-
-/*
- * Servant and Object Factory
- */
-static POA_GNOME_Calendar_Repository calendar_repository_servant;
-
-static inline GnomeCalendar *
-gnomecal_from_servant (PortableServer_Servant servant)
-{
- CalendarServant *cs = (CalendarServant *) servant;
-
- return cs->calendar;
-}
-
-static CORBA_char *
-cal_repo_get_object (PortableServer_Servant servant,
- const CORBA_char *uid,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- iCalObject *obj;
- char *buffer;
- CORBA_char *ret;
-
- obj = calendar_object_find_event (gcal->cal, uid);
- if (obj == NULL){
- GNOME_Calendar_Repository_NotFound *exn;
-
- exn = GNOME_Calendar_Repository_NotFound__alloc();
- CORBA_exception_set (
- ev,
- CORBA_USER_EXCEPTION,
- ex_GNOME_Calendar_Repository_NotFound,
- exn);
- return NULL;
- }
-
- buffer = calendar_string_from_object (obj);
- ret = CORBA_string_dup (buffer);
- free (buffer);
-
- return ret;
-}
-
-static CORBA_char *
-cal_repo_get_object_by_pilot_id (PortableServer_Servant servant,
- CORBA_long pilot_id,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- iCalObject *obj;
- char *buffer;
- CORBA_char *ret;
-
- obj = calendar_object_find_by_pilot (gcal->cal, pilot_id);
- if (obj == NULL){
- GNOME_Calendar_Repository_NotFound *exn;
-
- exn = GNOME_Calendar_Repository_NotFound__alloc();
- CORBA_exception_set (ev,
- CORBA_USER_EXCEPTION,
- ex_GNOME_Calendar_Repository_NotFound, exn);
- return NULL;
- }
-
- buffer = calendar_string_from_object (obj);
- ret = CORBA_string_dup (buffer);
- free (buffer);
-
- return ret;
-
-}
-
-static CORBA_char *
-cal_repo_get_id_from_pilot_id (PortableServer_Servant servant,
- CORBA_long pilot_id,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- iCalObject *obj;
-
- obj = calendar_object_find_by_pilot (gcal->cal, pilot_id);
- if (obj == NULL){
- GNOME_Calendar_Repository_NotFound *exn;
-
- exn = GNOME_Calendar_Repository_NotFound__alloc();
- CORBA_exception_set (ev,
- CORBA_USER_EXCEPTION,
- ex_GNOME_Calendar_Repository_NotFound, exn);
- return NULL;
- }
-
- return CORBA_string_dup (obj->uid);
-}
-
-static void
-cal_repo_delete_object (PortableServer_Servant servant,
- const CORBA_char *uid,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- iCalObject *obj;
-
- obj = calendar_object_find_event (gcal->cal, uid);
- if (obj == NULL){
- GNOME_Calendar_Repository_NotFound *exn;
-
- exn = GNOME_Calendar_Repository_NotFound__alloc();
- CORBA_exception_set (ev,
- CORBA_USER_EXCEPTION,
- ex_GNOME_Calendar_Repository_NotFound, exn);
- return;
- }
-
- gnome_calendar_remove_object (gcal, obj);
-}
-
-static void
-cal_repo_update_object (PortableServer_Servant servant,
- const CORBA_char *uid,
- const CORBA_char *vcalendar_object,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- iCalObject *obj;
- iCalObject *new_object;
-
- new_object = ical_object_new_from_string (vcalendar_object);
-
- obj = calendar_object_find_event (gcal->cal, uid);
- if (obj != NULL){
- calendar_remove_object (gcal->cal, obj);
- }
-
- calendar_add_object (gcal->cal, new_object);
-}
-
-static void
-cal_repo_update_pilot_id (PortableServer_Servant servant,
- const CORBA_char *uid,
- const CORBA_long pilot_id,
- const CORBA_long pilot_status,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- iCalObject *obj;
-
- obj = calendar_object_find_event (gcal->cal, uid);
- if (obj == NULL){
- GNOME_Calendar_Repository_NotFound *exn;
-
- exn = GNOME_Calendar_Repository_NotFound__alloc();
- CORBA_exception_set (
- ev,
- CORBA_USER_EXCEPTION,
- ex_GNOME_Calendar_Repository_NotFound,
- exn);
- return;
- }
-
- obj->pilot_id = pilot_id;
- obj->pilot_status = pilot_status;
-}
-
-static CORBA_char *
-cal_repo_get_objects (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- char *str;
- CORBA_char *res;
-
- str = calendar_get_as_vcal_string (gcal->cal);
- g_message("length of result is %d",strlen(str));
- res = CORBA_string_dup (str);
- free(str); /* ...get_as_vcal calls writeMemVObject, which uses realloc to
- allocate this string */
-
- return res;
-}
-
-static CORBA_long
-cal_repo_get_number_of_objects (PortableServer_Servant servant,
- GNOME_Calendar_Repository_RecordStatus record_status,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- CORBA_long res;
- GList *l;
- iCalPilotState real_record_status;
-
- if (record_status == GNOME_Calendar_Repository_ANY) {
- return g_list_length(gcal->cal->events);
- }
-
- switch (record_status) {
- case GNOME_Calendar_Repository_NEW:
- real_record_status = ICAL_PILOT_SYNC_MOD;
- break;
- case GNOME_Calendar_Repository_MODIFIED:
- real_record_status = ICAL_PILOT_SYNC_MOD;
- break;
- case GNOME_Calendar_Repository_DELETED:
- real_record_status = ICAL_PILOT_SYNC_DEL;
- break;
- }
-
- res = 0;
-
- for (l = gcal->cal->events; l; l = l->next){
- iCalObject *obj = l->data;
-
- if (obj->pilot_status == real_record_status)
- res ++;
- }
-
- return res;
-}
-
-static GNOME_Calendar_Repository_String_Sequence*
-cal_repo_get_object_id_list(PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- GList *l;
- GNOME_Calendar_Repository_String_Sequence *result;
- int counter;
-
- result = GNOME_Calendar_Repository_String_Sequence__alloc();
- result->_length = g_list_length(gcal->cal->events);
- result->_buffer = CORBA_sequence_CORBA_string_allocbuf(result->_length);
-
- counter = 0;
- for (l = gcal->cal->events ; l; l = l->next){
- iCalObject *obj = l->data;
- result->_buffer[counter] = CORBA_string_dup(obj->uid);
- counter++;
- }
-
- return result;
-}
-
-static CORBA_char *
-cal_repo_get_updated_objects (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
- Calendar *dirty_cal;
- GList *l;
- CORBA_char *res;
- char *str;
-
- dirty_cal = calendar_new ("Temporal",CALENDAR_INIT_NIL);
-
- for (l = gcal->cal->events; l; l = l->next){
- iCalObject *obj = l->data;
-
- if (obj->pilot_status != ICAL_PILOT_SYNC_MOD)
- continue;
-
- obj = ical_object_duplicate (l->data);
-
- calendar_add_object (dirty_cal, obj);
- }
- str = calendar_get_as_vcal_string (dirty_cal);
- res = CORBA_string_dup (str);
- g_free (str);
- calendar_destroy (dirty_cal);
-
- return res;
-}
-
-static void
-cal_repo_done (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
-
- calendar_save (gcal->cal, NULL);
-}
-
-static void
-init_calendar_repo_class (void)
-{
- calendar_repository_epv.get_object = cal_repo_get_object;
- calendar_repository_epv.get_object_by_pilot_id = cal_repo_get_object_by_pilot_id;
- calendar_repository_epv.get_id_from_pilot_id = cal_repo_get_id_from_pilot_id;
- calendar_repository_epv.delete_object = cal_repo_delete_object;
- calendar_repository_epv.update_object = cal_repo_update_object;
- calendar_repository_epv.get_objects = cal_repo_get_objects;
- calendar_repository_epv.get_number_of_objects = cal_repo_get_number_of_objects;
- calendar_repository_epv.get_updated_objects = cal_repo_get_updated_objects;
- calendar_repository_epv.update_pilot_id = cal_repo_update_pilot_id;
- calendar_repository_epv.get_object_id_list = cal_repo_get_object_id_list;
-
- calendar_repository_epv.done = cal_repo_done;
-
- calendar_repository_vepv.GNOME_Calendar_Repository_epv =
- &calendar_repository_epv;
-
- calendar_repository_servant.vepv = &calendar_repository_vepv;
-}
-
-/*
- * Initializes the CORBA parts of the @calendar object
- */
-void
-gnome_calendar_create_corba_server (GnomeCalendar *calendar)
-{
- static gboolean class_inited = FALSE;
- CalendarServant *calendar_servant;
- CORBA_Environment ev;
-
- if (!class_inited){
- init_calendar_repo_class ();
- class_inited = TRUE;
- }
-
- calendar_servant = g_new0 (CalendarServant, 1);
- calendar_servant->servant.vepv = &calendar_repository_vepv;
- calendar_servant->calendar = calendar;
-
- CORBA_exception_init (&ev);
- POA_GNOME_Calendar_Repository__init ((PortableServer_Servant) calendar_servant, &ev);
- CORBA_free (
- PortableServer_POA_activate_object (poa, calendar_servant, &ev));
- calendar->cal->corba_server = PortableServer_POA_servant_to_reference (
- poa, calendar_servant, &ev);
- CORBA_exception_free (&ev);
-}
diff --git a/calendar/gui/corba-cal.h b/calendar/gui/corba-cal.h
deleted file mode 100644
index 47caacba70..0000000000
--- a/calendar/gui/corba-cal.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _CORBA_CAL_H_
-#define _CORBA_CAL_H_
-
-void gnome_calendar_create_corba_server (GnomeCalendar *calendar);
-
-#endif /* _CORBA_CAL_H_ */
diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c
deleted file mode 100644
index 31fbf11225..0000000000
--- a/calendar/gui/eventedit.c
+++ /dev/null
@@ -1,1583 +0,0 @@
-/*
- * EventEditor widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors: Miguel de Icaza (miguel@kernel.org)
- * Federico Mena (quartic@gimp.org)
- */
-#include <config.h>
-#include <gnome.h>
-#include <string.h>
-#include "calendar.h"
-#include "eventedit.h"
-#include "main.h"
-#include "timeutil.h"
-
-
-static void event_editor_class_init (EventEditorClass *class);
-static void event_editor_init (EventEditor *ee);
-static void event_editor_destroy (GtkObject *object);
-
-GtkWidget* make_spin_button (int val, int low, int high);
-void ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type,
- int y, gboolean control_sens, GtkSignalFunc dirty_func);
-void ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type);
-
-/* Note: do not i18n these strings, they are part of the vCalendar protocol */
-static char *class_names [] = { "PUBLIC", "PRIVATE", "CONFIDENTIAL" };
-
-static GnomeDialogClass *parent_class;
-
-struct numbered_item {
- char *text;
- int num;
-};
-
-
-guint
-event_editor_get_type (void)
-{
- static guint event_editor_type = 0;
-
- if(!event_editor_type) {
- GtkTypeInfo event_editor_info = {
- "EventEditor",
- sizeof(EventEditor),
- sizeof(EventEditorClass),
- (GtkClassInitFunc) event_editor_class_init,
- (GtkObjectInitFunc) event_editor_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL,
- };
- event_editor_type = gtk_type_unique (gnome_dialog_get_type (), &event_editor_info);
- }
- return event_editor_type;
-}
-
-static void
-event_editor_class_init (EventEditorClass *class)
-{
- GtkObjectClass *object_class;
-
- parent_class = gtk_type_class (gnome_dialog_get_type ());
- object_class = (GtkObjectClass*) class;
- object_class->destroy = event_editor_destroy;
-}
-
-GtkWidget *
-make_spin_button (int val, int low, int high)
-{
- GtkAdjustment *adj;
- GtkWidget *spin;
-
- adj = GTK_ADJUSTMENT (gtk_adjustment_new (val, low, high, 1, 10, 10));
- spin = gtk_spin_button_new (adj, 0.5, 0);
- gtk_widget_set_usize (spin, 60, 0);
-
- return spin;
-}
-
-/*
- * Checks if the day range occupies all the day, and if so, check the
- * box accordingly
- */
-static void
-ee_check_all_day (EventEditor *ee)
-{
- time_t ev_start, ev_end;
-
- ev_start = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- ev_end = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (get_time_t_hour (ev_start) <= day_begin && get_time_t_hour (ev_end) >= day_end)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->general_allday), 1);
- else
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->general_allday), 0);
-}
-
-/*
- * Callback: checks that the dates are start < end
- */
-static void
-check_dates (GnomeDateEdit *gde, EventEditor *ee)
-{
- time_t start, end;
- struct tm tm_start, tm_end;
-
- start = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- end = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (start > end) {
- tm_start = *localtime (&start);
- tm_end = *localtime (&end);
-
- if (GTK_WIDGET (gde) == ee->start_time) {
- tm_end.tm_year = tm_start.tm_year;
- tm_end.tm_mon = tm_start.tm_mon;
- tm_end.tm_mday = tm_start.tm_mday;
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (&tm_end));
- } else if (GTK_WIDGET (gde) == ee->end_time) {
- tm_start.tm_year = tm_end.tm_year;
- tm_start.tm_mon = tm_end.tm_mon;
- tm_start.tm_mday = tm_end.tm_mday;
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->start_time), mktime (&tm_start));
- }
- }
-}
-
-/*
- * Callback: checks that start_time < end_time and whether the
- * selected hour range spans all of the day
- */
-static void
-check_times (GnomeDateEdit *gde, EventEditor *ee)
-{
- time_t start, end;
- struct tm tm_start, tm_end;
-
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gdk_flush ();
-
- start = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- end = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (start >= end) {
- tm_start = *localtime (&start);
- tm_end = *localtime (&end);
-
- if (GTK_WIDGET (gde) == ee->start_time) {
- tm_end.tm_min = tm_start.tm_min;
- tm_end.tm_sec = tm_start.tm_sec;
-
- tm_end.tm_hour = tm_start.tm_hour + 1;
-
- if (tm_end.tm_hour >= 24) {
- tm_end.tm_hour = 24; /* mktime() will bump the day */
- tm_end.tm_min = 0;
- tm_end.tm_sec = 0;
- }
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (&tm_end));
- } else if (GTK_WIDGET (gde) == ee->end_time) {
- tm_start.tm_min = tm_end.tm_min;
- tm_start.tm_sec = tm_end.tm_sec;
-
- tm_start.tm_hour = tm_end.tm_hour - 1;
-
- if (tm_start.tm_hour < 0) {
- tm_start.tm_hour = 0;
- tm_start.tm_min = 0;
- tm_start.tm_min = 0;
- }
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->start_time), mktime (&tm_start));
- }
- }
-
- /* Check whether the event spans the whole day */
-
- ee_check_all_day (ee);
-}
-
-/*
- * Callback: all day event box clicked
- */
-static void
-set_all_day (GtkToggleButton *toggle, EventEditor *ee)
-{
- struct tm tm;
- time_t start_t;
-
- start_t = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- tm = *localtime (&start_t);
- tm.tm_hour = day_begin;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->start_time), mktime (&tm));
-
- if (toggle->active)
- tm.tm_hour = day_end;
- else
- tm.tm_hour++;
-
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->end_time), mktime (&tm));
-}
-
-/* Convenience function to create a properly-configured date editor widget */
-GtkWidget *
-date_edit_new (time_t the_time, int show_time)
-{
- return gnome_date_edit_new_flags (the_time,
- ((show_time ? GNOME_DATE_EDIT_SHOW_TIME : 0)
- | (am_pm_flag ? 0 : GNOME_DATE_EDIT_24_HR)
- | (week_starts_on_monday
- ? GNOME_DATE_EDIT_WEEK_STARTS_ON_MONDAY
- : 0)));
-}
-
-static GtkWidget *
-event_editor_setup_time_frame (EventEditor *ee)
-{
- GtkWidget *frame;
- GtkWidget *start_time, *end_time;
- GtkTable *t;
-
- frame = gtk_frame_new (_("Time"));
- t = GTK_TABLE (ee->general_time_table = gtk_table_new (1, 1, 0));
- gtk_container_border_width (GTK_CONTAINER (t), 4);
- gtk_table_set_row_spacings (t, 4);
- gtk_table_set_col_spacings (t, 4);
- gtk_container_add (GTK_CONTAINER (frame), ee->general_time_table);
-
- /* 1. Start time */
- if (ee->ical->dtstart == 0){
- ee->ical->dtstart = time (NULL);
- ee->ical->dtend = time_add_minutes (ee->ical->dtstart, 30);
- }
- ee->start_time = start_time = date_edit_new (ee->ical->dtstart, TRUE);
- gnome_date_edit_set_popup_range ((GnomeDateEdit *) start_time, day_begin, day_end);
- gtk_signal_connect (GTK_OBJECT (start_time), "date_changed",
- GTK_SIGNAL_FUNC (check_dates), ee);
- gtk_signal_connect (GTK_OBJECT (start_time), "time_changed",
- GTK_SIGNAL_FUNC (check_times), ee);
- gtk_table_attach (t, gtk_label_new (_("Start time:")), 1, 2, 1, 2,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_table_attach (t, start_time, 2, 3, 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- /* 2. End time */
- ee->end_time = end_time = date_edit_new (ee->ical->dtend, TRUE);
- gnome_date_edit_set_popup_range ((GnomeDateEdit *) end_time, day_begin, day_end);
- gtk_signal_connect (GTK_OBJECT (end_time), "date_changed",
- GTK_SIGNAL_FUNC (check_dates), ee);
- gtk_signal_connect (GTK_OBJECT (end_time), "time_changed",
- GTK_SIGNAL_FUNC (check_times), ee);
- gtk_table_attach (t, gtk_label_new (_("End time:")), 1, 2, 2, 3,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_table_attach (t, end_time, 2, 3, 2, 3,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- /* 3. All day checkbox */
- ee->general_allday = gtk_check_button_new_with_label (_("All day event"));
- gtk_signal_connect (GTK_OBJECT (ee->general_allday), "toggled",
- GTK_SIGNAL_FUNC (set_all_day), ee);
- gtk_table_attach (t, ee->general_allday, 3, 4, 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 4, 0);
- ee_check_all_day (ee);
-
- return frame;
-}
-
-static GtkWidget *
-timesel_new (void)
-{
- GtkWidget *menu, *option_menu;
- char *items [] = { N_("Minutes"), N_("Hours"), N_("Days") };
- int i;
-
- option_menu = gtk_option_menu_new ();
- menu = gtk_menu_new ();
- for (i = 0; i < 3; i++){
- GtkWidget *item;
-
- item = gtk_menu_item_new_with_label (_(items [i]));
- gtk_menu_append (GTK_MENU (menu), item);
- gtk_widget_show (item);
- }
- gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
- return option_menu;
-}
-
-/*
- * Set the sensitive state depending on whether the alarm enabled flag.
- */
-static void
-ee_alarm_setting (CalendarAlarm *alarm, int sensitive)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_count), sensitive);
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_timesel), sensitive);
-
- if (alarm->type == ALARM_PROGRAM || alarm->type == ALARM_MAIL){
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_entry), sensitive);
- gtk_widget_set_sensitive (GTK_WIDGET (alarm->w_label), sensitive);
- }
-}
-
-static void
-alarm_toggle (GtkToggleButton *toggle, CalendarAlarm *alarm)
-{
- ee_alarm_setting (alarm, toggle->active);
-}
-
-#define FXS (GTK_FILL | GTK_EXPAND | GTK_SHRINK)
-#define FS (GTK_FILL | GTK_SHRINK)
-
-void
-ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type, int y, gboolean control_sens, GtkSignalFunc dirty_func)
-{
- GtkWidget *entry;
-
- alarm->w_enabled = gtk_check_button_new_with_label (str);
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (alarm->w_enabled),
- alarm->enabled);
- if (control_sens)
- gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled",
- GTK_SIGNAL_FUNC (alarm_toggle), alarm);
- if (dirty_func)
- gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled",
- GTK_SIGNAL_FUNC (dirty_func), NULL);
- gtk_table_attach (table, alarm->w_enabled, 0, 1, y, y+1, FS, FS, 0, 0);
-
- alarm->w_count = make_spin_button (alarm->count, 0, 10000);
- if (dirty_func)
- gtk_signal_connect (GTK_OBJECT (alarm->w_count), "changed",
- GTK_SIGNAL_FUNC (dirty_func), NULL);
- gtk_table_attach (table, alarm->w_count, 1, 2, y, y+1, FS, FS, 0, 0);
-
- alarm->w_timesel = timesel_new ();
- /* is there a "changed" signal which we can connect to? */
- gtk_option_menu_set_history (GTK_OPTION_MENU (alarm->w_timesel), alarm->units);
- gtk_table_attach (table, alarm->w_timesel, 2, 3, y, y+1, FS, FS, 0, 0);
-
- switch (type){
- case ALARM_MAIL:
- alarm->w_label = gtk_label_new (_("Mail to:"));
- gtk_misc_set_alignment (GTK_MISC (alarm->w_label), 1.0, 0.5);
- gtk_table_attach (table, alarm->w_label, 3, 4, y, y+1, FS, FS, 0, 0);
- alarm->w_entry = gtk_entry_new ();
- gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0);
- gtk_entry_set_text (GTK_ENTRY (alarm->w_entry), alarm->data ? alarm->data : "");
- if (dirty_func)
- gtk_signal_connect (GTK_OBJECT (alarm->w_entry),
- "changed",
- GTK_SIGNAL_FUNC (dirty_func),
- NULL);
- break;
-
- case ALARM_PROGRAM:
- alarm->w_label = gtk_label_new (_("Run program:"));
- gtk_misc_set_alignment (GTK_MISC (alarm->w_label), 1.0, 0.5);
- gtk_table_attach (table, alarm->w_label, 3, 4, y, y+1, FS, FS, 0, 0);
- alarm->w_entry = gnome_file_entry_new ("alarm-program", _("Select program to run at alarm time"));
- entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (alarm->w_entry));
- gtk_entry_set_text (GTK_ENTRY (entry), alarm->data ? alarm->data : "");
- gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0);
- if (dirty_func)
- gtk_signal_connect (GTK_OBJECT (entry),
- "changed",
- GTK_SIGNAL_FUNC (dirty_func),
- NULL);
- break;
-
- default:
- break;
- }
-
- if (control_sens)
- ee_alarm_setting (alarm, alarm->enabled);
- else
- ee_alarm_setting (alarm, TRUE);
-}
-
-static GtkWidget *
-ee_alarm_widgets (EventEditor *ee)
-{
- GtkWidget *table, *mailto, *mailte, *l;
-
- l = gtk_frame_new (_("Alarms"));
-
- table = gtk_table_new (1, 1, 0);
- gtk_container_border_width (GTK_CONTAINER (table), 4);
- gtk_table_set_row_spacings (GTK_TABLE (table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (table), 4);
- gtk_container_add (GTK_CONTAINER (l), table);
-
- mailto = gtk_label_new (_("Mail to:"));
- mailte = gtk_entry_new ();
-
- ee_create_ae (GTK_TABLE (table), _("Display"), &ee->ical->dalarm, ALARM_DISPLAY, 1, TRUE, NULL);
- ee_create_ae (GTK_TABLE (table), _("Audio"), &ee->ical->aalarm, ALARM_AUDIO, 2, TRUE, NULL);
- ee_create_ae (GTK_TABLE (table), _("Program"), &ee->ical->palarm, ALARM_PROGRAM, 3, TRUE, NULL);
- ee_create_ae (GTK_TABLE (table), _("Mail"), &ee->ical->malarm, ALARM_MAIL, 4, TRUE, NULL);
-
- return l;
-}
-
-static GtkWidget *
-ee_classification_widgets (EventEditor *ee)
-{
- GtkWidget *rpub, *rpriv, *rconf;
- GtkWidget *frame, *hbox;
-
- frame = gtk_frame_new (_("Classification"));
-
- hbox = gtk_hbox_new (TRUE, 0);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_container_add (GTK_CONTAINER (frame), hbox);
-
- rpub = gtk_radio_button_new_with_label (NULL, _("Public"));
- rpriv = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Private"));
- rconf = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Confidential"));
-
- gtk_box_pack_start (GTK_BOX (hbox), rpub, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), rpriv, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), rconf, FALSE, FALSE, 0);
-
- if (strcmp (ee->ical->class, class_names[0]) == 0)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rpub), TRUE);
- else if (strcmp (ee->ical->class, class_names[1]) == 0)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rpriv), TRUE);
- else if (strcmp (ee->ical->class, class_names[2]) == 0)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rconf), TRUE);
-
- ee->general_radios = rpub;
-
- return frame;
-}
-
-/*
- * Retrieves the information from the CalendarAlarm widgets and stores them
- * on the CalendarAlarm generic values
- */
-void
-ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type)
-{
- GtkWidget *item;
- GtkMenu *menu;
- GList *child;
- int idx;
-
- if (alarm->data){
- g_free (alarm->data);
- alarm->data = 0;
- }
-
- alarm->enabled = GTK_TOGGLE_BUTTON (alarm->w_enabled)->active;
-
- if (!alarm->enabled)
- return;
-
- if (type == ALARM_PROGRAM)
- alarm->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (gnome_file_entry_gtk_entry (alarm->w_entry))));
- if (type == ALARM_MAIL)
- alarm->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (alarm->w_entry)));
-
- /* Find out the index */
- menu = GTK_MENU (GTK_OPTION_MENU (alarm->w_timesel)->menu);
-
- item = gtk_menu_get_active (menu);
-
- for (idx = 0, child = GTK_MENU_SHELL (menu)->children; child->data != item; child = child->next)
- idx++;
-
- alarm->units = idx;
- alarm->count = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (alarm->w_count));
-}
-
-static void
-ee_store_general_values_to_ical (EventEditor *ee)
-{
- GtkRadioButton *radio = GTK_RADIO_BUTTON (ee->general_radios);
- iCalObject *ical = ee->ical;
- GSList *list = radio->group;
- int idx;
- time_t now;
-
- now = time (NULL);
- ical->dtstart = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->start_time));
- ical->dtend = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->end_time));
-
- if (ical->summary)
- g_free (ical->summary);
-
- ical->summary = gtk_editable_get_chars (GTK_EDITABLE (ee->general_summary), 0, -1);
-
- ee_store_alarm (&ical->dalarm, ALARM_DISPLAY);
- ee_store_alarm (&ical->aalarm, ALARM_AUDIO);
- ee_store_alarm (&ical->palarm, ALARM_PROGRAM);
- ee_store_alarm (&ical->malarm, ALARM_MAIL);
-
- for (idx = 2; list; list = list->next) {
- if (GTK_TOGGLE_BUTTON (list->data)->active)
- break;
- idx--; /* The group is stored in reverse order of insertion */
- }
-
- g_free (ical->class);
- ical->class = g_strdup (class_names [idx]);
-}
-
-static int
-option_menu_active_number (GtkWidget *omenu)
-{
- GtkWidget *menu;
- GtkWidget *item;
- struct numbered_item *ni;
-
- menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (omenu));
- item = gtk_menu_get_active (GTK_MENU (menu));
-
- ni = gtk_object_get_user_data (GTK_OBJECT (item));
-
- return ni->num;
-}
-
-static int
-ee_store_recur_rule_to_ical (EventEditor *ee)
-{
- iCalObject *ical;
- int i, j;
- GSList *list;
-
- ical = ee->ical;
-
- for (i = 0, list = ee->recur_rr_group; list; i++, list = list->next)
- if (GTK_TOGGLE_BUTTON (list->data)->active)
- break;
-
- i = g_slist_length (ee->recur_rr_group) - i - 1; /* buttons are stored in reverse order of insertion */
-
- /* None selected, no rule to be stored */
- if (i == 0)
- return 0;
-
- if (!ical->recur)
- ical->recur = g_new0 (Recurrence, 1);
-
- switch (i) {
- case 1:
- /* Daily */
- ical->recur->type = RECUR_DAILY;
- ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_day_period));
- break;
-
- case 2:
- /* Weekly */
- ical->recur->type = RECUR_WEEKLY;
- ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_week_period));
- ical->recur->weekday = 0;
-
- for (j = 0; j < 7; j++)
- if (GTK_TOGGLE_BUTTON (ee->recur_rr_week_days[j])->active) {
- if (j == 6)
- ical->recur->weekday |= 1 << 0; /* sunday is at bit 0 */
- else
- ical->recur->weekday |= 1 << (j + 1);
- }
-
- break;
-
- case 3:
- /* Monthly */
-
- if (GTK_WIDGET_SENSITIVE (ee->recur_rr_month_date)) {
- /* by day */
-
- ical->recur->type = RECUR_MONTHLY_BY_DAY;
- ical->recur->u.month_day =
- gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (ee->recur_rr_month_date));
- ical->recur->interval =
- gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (ee->recur_rr_month_period));
- } else {
- /* by position */
-
- ical->recur->type = RECUR_MONTHLY_BY_POS;
-
- ical->recur->u.month_pos =
- option_menu_active_number (ee->recur_rr_month_day);
- ical->recur->weekday =
- option_menu_active_number (ee->recur_rr_month_weekday);
- ical->recur->interval =
- gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (ee->recur_rr_month_period));
- }
-
- break;
-
- case 4:
- /* Yearly */
- ical->recur->type = RECUR_YEARLY_BY_DAY;
- ical->recur->interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_rr_year_period));
- /* FIXME: need to specify anything else? I am assuming the code will look at the dtstart
- * to figure out when to recur. - Federico
- */
- break;
-
- default:
- g_assert_not_reached ();
- }
- return 1;
-}
-
-static void
-ee_store_recur_end_to_ical (EventEditor *ee)
-{
- iCalObject *ical;
- GSList *list;
- int i;
-
- /* Ending date of recurrence */
-
- ical = ee->ical;
-
- for (i = 0, list = ee->recur_ed_group; list; i++, list = list->next)
- if (GTK_TOGGLE_BUTTON (list->data)->active)
- break;
-
- i = g_slist_length (ee->recur_ed_group) - i - 1; /* the list is stored in reverse order of insertion */
-
- switch (i) {
- case 0:
- /* repeat forever */
- ical->recur->_enddate = 0;
- ical->recur->enddate = 0;
- ical->recur->duration = 0;
- break;
-
- case 1:
- /* end date */
- /* Also here, to ensure that the event is used, we add 86400 secs to get
- get next day, in accordance to the RFC */
- ical->recur->_enddate = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->recur_ed_end_on)) + 86400;
- ical->recur->enddate = ical->recur->_enddate;
- ical->recur->duration = 0;
- break;
-
- case 2:
- /* end after n occurrences */
- ical->recur->duration = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ee->recur_ed_end_after));
- ical_object_compute_end (ical);
- break;
-
- default:
- g_assert_not_reached ();
- break;
- }
-}
-
-static void
-free_exdate (iCalObject *ical)
-{
- GList *list;
-
- if (!ical->exdate)
- return;
-
- for (list = ical->exdate; list; list = list->next)
- g_free (list->data);
-
- g_list_free (ical->exdate);
- ical->exdate = NULL;
-}
-
-static void
-ee_store_recur_exceptions_to_ical (EventEditor *ee)
-{
- iCalObject *ical;
- GtkCList *clist;
- int i;
- time_t *t;
-
- ical = ee->ical;
- clist = GTK_CLIST (ee->recur_ex_clist);
-
- free_exdate (ical);
-
- for (i = 0; i < clist->rows; i++) {
- t = gtk_clist_get_row_data (clist, i);
- ical->exdate = g_list_prepend (ical->exdate, t);
- }
-}
-
-static void
-ee_store_recur_values_to_ical (EventEditor *ee)
-{
- if (ee_store_recur_rule_to_ical (ee)){
- ee_store_recur_exceptions_to_ical (ee);
- ee_store_recur_end_to_ical (ee);
- } else if (ee->ical->recur) {
- g_free (ee->ical->recur);
- ee->ical->recur = NULL;
- if (ee->ical->exdate){
- GList *l = ee->ical->exdate;
-
- for (; l; l = l->next)
- g_free (l->data);
- g_list_free (l);
- }
- }
-}
-
-/*
- * Retrieves all of the information from the different widgets and updates
- * the iCalObject accordingly.
- */
-static void
-ee_store_dlg_values_to_ical (EventEditor *ee)
-{
- time_t now;
-
- ee_store_general_values_to_ical (ee);
- ee_store_recur_values_to_ical (ee);
-
- now = time (NULL);
-
- /* FIXME: This is not entirely correct; we should check if the values actually changed */
- ee->ical->last_mod = now;
-
- if (ee->ical->new)
- ee->ical->created = now;
-}
-
-static void
-ee_ok (GtkWidget *widget, EventEditor *ee)
-{
- ee_store_dlg_values_to_ical (ee);
-
- if (ee->ical->new)
- gnome_calendar_add_object (ee->gnome_cal, ee->ical);
- else
- gnome_calendar_object_changed (ee->gnome_cal, ee->ical, CHANGE_ALL);
-
- save_default_calendar (ee->gnome_cal);
- ee->ical->new = 0;
-}
-
-static void
-ee_cancel (GtkWidget *widget, EventEditor *ee)
-{
- if (ee->ical->new) {
- ical_object_destroy (ee->ical);
- ee->ical = NULL;
- }
-
-}
-
-static void
-ee_create_buttons (EventEditor *ee)
-{
- gnome_dialog_append_buttons(GNOME_DIALOG(ee),
- GNOME_STOCK_BUTTON_OK,
- GNOME_STOCK_BUTTON_CANCEL, NULL);
- gnome_dialog_set_default (GNOME_DIALOG (ee), 0);
- gnome_dialog_button_connect (GNOME_DIALOG (ee), 0, GTK_SIGNAL_FUNC(ee_ok), ee);
- gnome_dialog_button_connect (GNOME_DIALOG (ee), 1, GTK_SIGNAL_FUNC(ee_cancel), ee);
-
- return;
-}
-
-/*
- * Load the contents in a delayed fashion, as the GtkText widget needs it
- */
-static void
-ee_fill_summary (GtkWidget *widget, EventEditor *ee)
-{
- int pos = 0;
-
- gtk_editable_insert_text (GTK_EDITABLE (ee->general_summary), ee->ical->summary,
- strlen (ee->ical->summary), &pos);
- gtk_text_thaw (GTK_TEXT (ee->general_summary));
-}
-
-enum {
- OWNER_LINE,
- DESC_LINE,
- SUMMARY_LINE,
- TIME_LINE,
- ALARM_LINE,
- CLASS_LINE
-};
-
-/* Create/setup the general page */
-static void
-ee_init_general_page (EventEditor *ee)
-{
- GtkWidget *l;
- GtkWidget *hbox;
-
- ee->general_table = gtk_table_new (1, 1, FALSE);
- gtk_container_border_width (GTK_CONTAINER (ee->general_table), 4);
- gtk_table_set_row_spacings (GTK_TABLE (ee->general_table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (ee->general_table), 4);
- gtk_notebook_append_page (GTK_NOTEBOOK (ee->notebook), GTK_WIDGET (ee->general_table),
- gtk_label_new (_("General")));
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_table_attach (GTK_TABLE (ee->general_table), hbox,
- 0, 1, OWNER_LINE, OWNER_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 4);
-
- l = gtk_label_new (_("Owner:"));
- gtk_box_pack_start (GTK_BOX (hbox), l, FALSE, FALSE, 0);
-
- ee->general_owner = gtk_label_new (ee->ical->organizer ? ee->ical->organizer : _("?"));
- gtk_misc_set_alignment (GTK_MISC (ee->general_owner), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (hbox), ee->general_owner, TRUE, TRUE, 4);
-
- l = gtk_label_new (_("Summary:"));
- gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, DESC_LINE, DESC_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- ee->general_summary = gtk_text_new (NULL, NULL);
- gtk_text_freeze (GTK_TEXT (ee->general_summary));
- gtk_signal_connect (GTK_OBJECT (ee->general_summary), "realize",
- GTK_SIGNAL_FUNC (ee_fill_summary), ee);
- gtk_widget_set_usize (ee->general_summary, 0, 60);
- gtk_text_set_editable (GTK_TEXT (ee->general_summary), 1);
- gtk_table_attach (GTK_TABLE (ee->general_table), ee->general_summary,
- 0, 1, SUMMARY_LINE, SUMMARY_LINE+1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- l = ee_alarm_widgets (ee);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, ALARM_LINE, ALARM_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- l = event_editor_setup_time_frame (ee);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, TIME_LINE, TIME_LINE + 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- l = ee_classification_widgets (ee);
- gtk_table_attach (GTK_TABLE (ee->general_table), l,
- 0, 1, CLASS_LINE, CLASS_LINE + 1,
- GTK_EXPAND | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-}
-
-static void
-ee_init_summary_page (EventEditor *ee)
-{
-}
-
-struct {
- char *name;
-} recurrence_types [] = {
- { N_("None") },
- { N_("Daily") },
- { N_("Weekly") },
- { N_("Monthly") },
- { N_("Yearly") },
- { 0 }
-};
-
-static void
-recurrence_toggled (GtkRadioButton *radio, EventEditor *ee)
-{
- GSList *list = ee->recur_rr_group;
- int which;
-
- if (!GTK_TOGGLE_BUTTON (radio)->active)
- return;
-
- for (which = 0; list; list = list->next, which++) {
- if (list->data == radio) {
- gtk_notebook_set_page (GTK_NOTEBOOK (ee->recur_rr_notebook), 4 - which);
- return;
- }
- }
-}
-
-static struct numbered_item weekday_positions[] = {
- { N_("1st"), 1 },
- { N_("2nd"), 2 },
- { N_("3rd"), 3 },
- { N_("4th"), 4 },
- { N_("5th"), 5 },
- { 0 }
-};
-
-static struct numbered_item weekday_names[] = {
- { N_("Monday"), 1 },
- { N_("Tuesday"), 2 },
- { N_("Wednesday"), 3 },
- { N_("Thursday"), 4 },
- { N_("Friday"), 5 },
- { N_("Saturday"), 6 },
- { N_("Sunday"), 0 }, /* on the spec, Sunday is zero */
- { 0 }
-};
-
-static GtkWidget *
-make_numbered_menu (struct numbered_item *items, int sel)
-{
- GtkWidget *option_menu, *menu;
- int i;
-
- option_menu = gtk_option_menu_new ();
- menu = gtk_menu_new ();
-
- for (i = 0; items[i].text; i++) {
- GtkWidget *item;
-
- item = gtk_menu_item_new_with_label (_(items[i].text));
- gtk_object_set_user_data (GTK_OBJECT (item), &items[i]);
- gtk_menu_append (GTK_MENU (menu), item);
- gtk_widget_show (item);
- }
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
- gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), sel);
-
- return option_menu;
-}
-
-static void
-month_sensitize (EventEditor *ee, int state)
-{
- gtk_widget_set_sensitive (ee->recur_rr_month_date, state);
- gtk_widget_set_sensitive (ee->recur_rr_month_date_label, state);
-
- gtk_widget_set_sensitive (ee->recur_rr_month_day, !state);
- gtk_widget_set_sensitive (ee->recur_rr_month_weekday, !state);
-}
-
-static void
-recur_month_enable_date (GtkToggleButton *button, EventEditor *ee)
-{
- month_sensitize (ee, button->active);
-}
-
-static void
-desensitize_on_toggle (GtkToggleButton *toggle, gpointer data)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (data), !toggle->active);
-}
-
-static void
-ee_rp_init_rule (EventEditor *ee)
-{
- static char *day_names [] = { N_("Mon"), N_("Tue"), N_("Wed"), N_("Thu"), N_("Fri"), N_("Sat"), N_("Sun") };
- GtkWidget *r, *re, *r1, *f, *vbox, *hbox, *b, *week_hbox, *week_day, *w;
- GtkWidget *none, *daily, *weekly, *monthly, *yearly;
- GtkNotebook *notebook;
- GSList *group;
- int i, page, day_period, week_period, month_period, year_period;
- int week_vector, default_day, def_pos, def_off;
- struct tm tm;
-
- tm = *localtime (&ee->ical->dtstart);
-
- f = gtk_frame_new (_("Recurrence rule"));
-
- hbox = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_container_add (GTK_CONTAINER (f), hbox);
-
- vbox = gtk_vbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
-
- gtk_box_pack_start (GTK_BOX (hbox), gtk_vseparator_new (), FALSE, FALSE, 0);
-
- ee->recur_rr_notebook = gtk_notebook_new ();
- notebook = GTK_NOTEBOOK (ee->recur_rr_notebook);
- gtk_box_pack_start (GTK_BOX (hbox), ee->recur_rr_notebook, TRUE, TRUE, 0);
-
- day_period = 1;
- week_period = 1;
- month_period = 1;
- year_period = 1;
-
- /* Default to today */
-
- week_vector = 1 << tm.tm_wday;
- default_day = tm.tm_mday;
- def_pos = 0;
- def_off = 0;
-
- /* Determine which should be the default selection */
-
- page = 0;
- if (ee->ical->recur) {
- enum RecurType type = ee->ical->recur->type;
- int interval = ee->ical->recur->interval;
-
- switch (type) {
- case RECUR_DAILY:
- page = 1;
- day_period = interval;
- break;
-
- case RECUR_WEEKLY:
- page = 2;
- week_period = interval;
- week_vector = ee->ical->recur->weekday;
- break;
-
- case RECUR_MONTHLY_BY_POS:
- page = 3;
- month_period = interval;
- def_pos = ee->ical->recur->u.month_pos;
- default_day = ee->ical->recur->weekday; /* you can't use u.month_pos and u.month_day-- it's a union... */
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- page = 3;
- month_period = interval;
- default_day = ee->ical->recur->u.month_day;
- break;
-
- case RECUR_YEARLY_BY_MONTH:
- page = 4;
- year_period = interval;
- break;
-
- case RECUR_YEARLY_BY_DAY:
- page = 4;
- year_period = interval;
- break;
- }
- } else
- page = 0;
-
- /* The recurrency selector */
-
- for (i = 0, group = NULL; recurrence_types [i].name; i++) {
- r = gtk_radio_button_new_with_label (group, _(recurrence_types [i].name));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (r));
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r), i == page);
- gtk_signal_connect (GTK_OBJECT (r), "toggled", GTK_SIGNAL_FUNC (recurrence_toggled), ee);
- gtk_box_pack_start (GTK_BOX (vbox), r, FALSE, FALSE, 0);
-
- if (i == 0)
- gtk_signal_connect (GTK_OBJECT (r), "toggled",
- (GtkSignalFunc) desensitize_on_toggle,
- ee->recur_hbox);
- }
-
- ee->recur_rr_group = group;
-
- /* 0. No recurrence */
- none = gtk_label_new ("");
-
- /* 1. The daily recurrence */
-
- daily = gtk_vbox_new (FALSE, 0);
-
- b = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (daily), b, FALSE, FALSE, 0);
-
- ee->recur_rr_day_period = make_spin_button (day_period, 1, 10000);
- /* in some languages "Every" can follow the gender of the word it
- refers to (here "day(s)"). leave the two leadin letter "d_"
- in the translation they are ther on purpose */
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("d_Every") +2), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), ee->recur_rr_day_period, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("day(s)")), FALSE, FALSE, 0);
-
- /* 2. The weekly recurrence */
-
- weekly = gtk_vbox_new (FALSE, 4);
-
- week_hbox = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (weekly), week_hbox, FALSE, FALSE, 0);
-
- /* 2.1 The week period selector */
-
- ee->recur_rr_week_period = make_spin_button (week_period, 1, 10000);
- /* in some languages "Every" can follow the gender of the word it
- refers to (here "week(s)"). leave the two leadin letter "w_"
- in the translation they are ther on purpose */
- gtk_box_pack_start (GTK_BOX (week_hbox), gtk_label_new (_("w_Every") +2), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (week_hbox), ee->recur_rr_week_period, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (week_hbox), gtk_label_new (_("week(s)")), FALSE, FALSE, 0);
-
- /* 2.2 The week day selector */
-
- week_day = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (weekly), week_day, FALSE, FALSE, 0);
-
- for (i = 0; i < 7; i++) {
- ee->recur_rr_week_days [i] = gtk_check_button_new_with_label (_(day_names [i]));
- gtk_box_pack_start (GTK_BOX (week_day), ee->recur_rr_week_days [i], FALSE, FALSE, 0);
-
- if (week_vector & (1 << ((i + 1) % 7))) /* on the spec, Sunday is 0 */
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->recur_rr_week_days [i]), TRUE);
- }
-
- /* 3. The monthly recurrence */
-
- monthly = gtk_table_new (0, 0, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (monthly), 4);
- gtk_table_set_col_spacings (GTK_TABLE (monthly), 4);
-
- re = gtk_radio_button_new_with_label (NULL, _("Recur on the"));
- ee->recur_rr_month_date = make_spin_button (default_day, 1, 31);
- ee->recur_rr_month_date_label = w = gtk_label_new (_("th day of the month"));
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (monthly), re,
- 0, 1, 0, 1, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_date,
- 1, 2, 0, 1, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), w,
- 2, 3, 0, 1, FS, FS, 0, 0);
- gtk_signal_connect (GTK_OBJECT (re), "toggled", GTK_SIGNAL_FUNC (recur_month_enable_date), ee);
-
- r1 = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (re)), _("Recur on the"));
- ee->recur_rr_month_day = make_numbered_menu (weekday_positions, def_pos);
- ee->recur_rr_month_weekday = make_numbered_menu (weekday_names, default_day);
- gtk_table_attach (GTK_TABLE (monthly), r1,
- 0, 1, 1, 2, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_day,
- 1, 2, 1, 2, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_weekday,
- 2, 3, 1, 2, FS, FS, 0, 0);
-
- /* in some languages "Every" can follow the gender of the word it
- refers to (here "month(s)"). leave the two leadin letter "m_"
- in the translation they are ther on purpose */
- gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("m_Every") +2),
- 3, 4, 0, 2, FS, FS, 0, 0);
- ee->recur_rr_month_period = make_spin_button (month_period, 1, 10000);
- gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_period,
- 4, 5, 0, 2, FS, FS, 0, 0);
- gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("month(s)")),
- 5, 6, 0, 2, FS, FS, 0, 0);
-
- if (ee->ical->recur) {
- if (ee->ical->recur->type == RECUR_MONTHLY_BY_POS)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r1), 1);
- } else
- recur_month_enable_date (GTK_TOGGLE_BUTTON (re), ee);
-
- /* 4. The yearly recurrence */
-
- yearly = gtk_vbox_new (FALSE, 0);
-
- b = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (yearly), b, FALSE, FALSE, 0);
-
- ee->recur_rr_year_period = make_spin_button (year_period, 1, 10000);
- /* in some languages "Every" can follow the gender of the word it
- refers to (here "year(s)"). leave the two leadin letter "y_"
- in the translation they are ther on purpose */
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("y_Every") +2), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), ee->recur_rr_year_period, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (b), gtk_label_new (_("year(s)")), FALSE, FALSE, 0);
-
- /* Finish setting this up */
-
- gtk_notebook_append_page (notebook, none, gtk_label_new (""));
- gtk_notebook_append_page (notebook, daily, gtk_label_new (""));
- gtk_notebook_append_page (notebook, weekly, gtk_label_new (""));
- gtk_notebook_append_page (notebook, monthly, gtk_label_new (""));
- gtk_notebook_append_page (notebook, yearly, gtk_label_new (""));
- gtk_notebook_set_show_tabs (notebook, FALSE);
- gtk_notebook_set_show_border (notebook, FALSE);
-
- gtk_notebook_set_page (notebook, page);
-
- /* Attach to the main box */
-
- gtk_box_pack_start (GTK_BOX (ee->recur_vbox), f, FALSE, FALSE, 0);
-}
-
-static void
-sensitize_on_toggle (GtkToggleButton *toggle, gpointer data)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (data), toggle->active);
-}
-
-static void
-ee_rp_init_ending_date (EventEditor *ee)
-{
- GtkWidget *frame;
- GtkWidget *vbox;
- GSList *group;
- GtkWidget *radio0, *radio1, *radio2;
- GtkWidget *hbox;
- GtkWidget *ihbox;
- GtkWidget *widget;
- time_t enddate;
- int repeat;
-
- frame = gtk_frame_new (_("Ending date"));
-
- vbox = gtk_vbox_new (TRUE, 4);
- gtk_container_border_width (GTK_CONTAINER (vbox), 4);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
-
- group = NULL;
-
- /* repeat forever */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- radio0 = gtk_radio_button_new_with_label (group, _("Repeat forever"));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio0));
- gtk_box_pack_start (GTK_BOX (hbox), radio0, FALSE, FALSE, 0);
-
- /* end on date */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- radio1 = gtk_radio_button_new_with_label (group, _("End on"));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio1));
- gtk_box_pack_start (GTK_BOX (hbox), radio1, FALSE, FALSE, 0);
-
- ihbox = gtk_hbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ihbox, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), ihbox, FALSE, FALSE, 0);
-
- if (ee->ical->recur) {
- /* Shorten by one day, as we store end-on date a day ahead */
- enddate = ee->ical->recur->enddate - 86400;
- } else
- enddate = ee->ical->dtend;
-
- ee->recur_ed_end_on = widget = date_edit_new (enddate, FALSE);
- gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
-
- gtk_signal_connect (GTK_OBJECT (radio1), "toggled",
- (GtkSignalFunc) sensitize_on_toggle,
- ihbox);
-
- /* end after n occurrences */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- radio2 = gtk_radio_button_new_with_label (group, _("End after"));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio2));
- gtk_box_pack_start (GTK_BOX (hbox), radio2, FALSE, FALSE, 0);
-
- ihbox = gtk_hbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ihbox, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), ihbox, FALSE, FALSE, 0);
-
- if (ee->ical->recur && ee->ical->recur->duration)
- repeat = ee->ical->recur->duration;
- else
- repeat = 2;
-
- ee->recur_ed_end_after = widget = make_spin_button (repeat, 1, 10000);
- gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
-
- widget = gtk_label_new (_("occurrence(s)"));
- gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0);
-
- gtk_signal_connect (GTK_OBJECT (radio2), "toggled",
- (GtkSignalFunc) sensitize_on_toggle,
- ihbox);
-
- /* Activate appropriate item */
-
- if (ee->ical->recur) {
- if (ee->ical->recur->_enddate == 0) {
- if (ee->ical->recur->duration == 0)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (radio0), TRUE);
- else {
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (ee->recur_ed_end_after),
- ee->ical->recur->duration);
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (radio2), TRUE);
- }
- } else {
- gnome_date_edit_set_time (GNOME_DATE_EDIT (ee->recur_ed_end_on), ee->ical->recur->enddate);
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (radio1), TRUE);
- }
- }
-
- /* Done, add to main table */
-
- ee->recur_ed_group = group;
-
- gtk_box_pack_start (GTK_BOX (ee->recur_hbox), frame, FALSE, FALSE, 0);
-}
-
-static char *
-get_exception_string (time_t t)
-{
- static char buf[256];
-
- strftime (buf, sizeof(buf), _("%a %b %d %Y"), localtime (&t));
- return buf;
-}
-
-static void
-append_exception (EventEditor *ee, time_t t)
-{
- time_t *tt;
- char *c[1];
- int i;
-
- c[0] = get_exception_string (t);
-
- tt = g_new (time_t, 1);
- *tt = t;
-
- i = gtk_clist_append (GTK_CLIST (ee->recur_ex_clist), c);
- gtk_clist_set_row_data (GTK_CLIST (ee->recur_ex_clist), i, tt);
- gtk_clist_select_row (GTK_CLIST (ee->recur_ex_clist), i, 0);
-
- gtk_widget_set_sensitive (ee->recur_ex_vbox, TRUE);
-}
-
-static void
-fill_exception_clist (EventEditor *ee)
-{
- GList *list;
-
- for (list = ee->ical->exdate; list; list = list->next)
- append_exception (ee, *((time_t *) list->data));
-}
-
-static void
-add_exception (GtkWidget *widget, EventEditor *ee)
-{
- time_t t;
-
- t = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->recur_ex_date));
- append_exception (ee, t);
-}
-
-static void
-change_exception (GtkWidget *widget, EventEditor *ee)
-{
- GtkCList *clist;
- time_t *t;
- int sel;
-
- clist = GTK_CLIST (ee->recur_ex_clist);
- sel = GPOINTER_TO_INT(clist->selection->data);
-
- t = gtk_clist_get_row_data (clist, sel);
- *t = gnome_date_edit_get_date (GNOME_DATE_EDIT (ee->recur_ex_date));
-
- gtk_clist_set_text (clist, sel, 0, get_exception_string (*t));
-}
-
-static void
-delete_exception (GtkWidget *widget, EventEditor *ee)
-{
- GtkCList *clist;
- int sel, length;
-
- clist = GTK_CLIST (ee->recur_ex_clist);
- sel = GPOINTER_TO_INT(clist->selection->data);
-
- g_free (gtk_clist_get_row_data (clist, sel)); /* free the time_t stored there */
-
- gtk_clist_remove (clist, sel);
- length = g_list_length(clist->row_list);
- if (sel >= length)
- sel--;
- gtk_clist_select_row (GTK_CLIST (ee->recur_ex_clist), sel, 0);
-
- if (clist->rows == 0)
- gtk_widget_set_sensitive (ee->recur_ex_vbox, FALSE);
-}
-
-static void
-ee_rp_init_exceptions (EventEditor *ee)
-{
- GtkWidget *frame;
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *ivbox;
- GtkWidget *widget;
- GtkWidget *sw;
-
- frame = gtk_frame_new (_("Exceptions"));
-
- hbox = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_container_add (GTK_CONTAINER (frame), hbox);
-
- vbox = gtk_vbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
-
- ee->recur_ex_date = widget = date_edit_new (time (NULL), FALSE);
- gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
-
- widget = gtk_button_new_with_label (_("Add exception"));
- gtk_signal_connect (GTK_OBJECT (widget), "clicked",
- (GtkSignalFunc) add_exception,
- ee);
- gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
-
- ee->recur_ex_vbox = ivbox = gtk_vbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ivbox, FALSE); /* at first there are no items to change or delete */
- gtk_box_pack_start (GTK_BOX (vbox), ivbox, FALSE, FALSE, 0);
-
- widget = gtk_button_new_with_label (_("Change selected"));
- gtk_signal_connect (GTK_OBJECT (widget), "clicked",
- (GtkSignalFunc) change_exception,
- ee);
- gtk_box_pack_start (GTK_BOX (ivbox), widget, FALSE, FALSE, 0);
-
- widget = gtk_button_new_with_label (_("Delete selected"));
- gtk_signal_connect (GTK_OBJECT (widget), "clicked",
- (GtkSignalFunc) delete_exception,
- ee);
- gtk_box_pack_start (GTK_BOX (ivbox), widget, FALSE, FALSE, 0);
-
- ee->recur_ex_clist = widget = gtk_clist_new (1);
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (sw), widget);
- gtk_clist_set_selection_mode (GTK_CLIST (widget), GTK_SELECTION_BROWSE);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- fill_exception_clist (ee);
- gtk_box_pack_start (GTK_BOX (hbox), sw, TRUE, TRUE, 0);
-
- /* Done, add to main table */
-
- gtk_box_pack_start (GTK_BOX (ee->recur_hbox), frame, TRUE, TRUE, 0);
-}
-
-static void
-ee_init_recurrence_page (EventEditor *ee)
-{
- ee->recur_vbox = gtk_vbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (ee->recur_vbox), 4);
-
- ee->recur_hbox = gtk_hbox_new (FALSE, 4);
- gtk_widget_set_sensitive (ee->recur_hbox, FALSE);
-
- ee->recur_page_label = gtk_label_new (_("Recurrence"));
-
- gtk_notebook_append_page (GTK_NOTEBOOK (ee->notebook), ee->recur_vbox,
- ee->recur_page_label);
-
- ee_rp_init_rule (ee);
-
- /* pack here so that the box gets inserted after the recurrence rule frame */
- gtk_box_pack_start (GTK_BOX (ee->recur_vbox), ee->recur_hbox, FALSE, FALSE, 0);
-
- ee_rp_init_ending_date (ee);
- ee_rp_init_exceptions (ee);
-}
-
-static void
-event_editor_init_widgets (EventEditor *ee)
-{
- ee->notebook = gtk_notebook_new ();
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG(ee)->vbox), ee->notebook, 1, 1, 0);
-
- /* Init the various configuration pages */
- ee_init_general_page (ee);
- ee_init_summary_page (ee);
- ee_init_recurrence_page (ee);
-
- /* Buttons */
- ee_create_buttons(ee);
-
- /* We show all of the contained widgets */
- gtk_widget_show_all (GTK_BIN (ee)->child);
-}
-
-static void
-event_editor_init (EventEditor *ee)
-{
- ee->ical = 0;
- gnome_dialog_set_close (GNOME_DIALOG(ee), TRUE);
-}
-
-static void
-event_editor_destroy (GtkObject *object)
-{
- EventEditor *ee;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_EVENT_EDITOR (object));
-
- ee = EVENT_EDITOR (object);
-
- if (ee->ical)
- ee->ical->user_data = NULL; /* we are no longer editing it */
-}
-
-GtkWidget *
-event_editor_new (GnomeCalendar *gcal, iCalObject *ical)
-{
- GtkWidget *retval;
- EventEditor *ee;
-
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gdk_flush ();
-
- retval = gtk_type_new (event_editor_get_type ());
- ee = EVENT_EDITOR (retval);
-
- if (ical == 0){
- ical = ical_new ("", user_name, "");
- ical->new = 1;
- }
-
- if (ical->new){
- gtk_window_set_title (GTK_WINDOW (ee), _("Create new appointment"));
- } else {
- gtk_window_set_title (GTK_WINDOW (ee), _("Edit appointment"));
- }
-
- ical->user_data = ee; /* so that the world can know we are editing it */
-
- ee->ical = ical;
- ee->gnome_cal = gcal;
- event_editor_init_widgets (ee);
-
- return retval;
-}
-
-void
-event_editor_new_whole_day (GnomeCalendar *owner, time_t day)
-{
- struct tm tm;
- iCalObject *ico;
- GtkWidget *ee;
-
- g_return_if_fail (owner != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (owner));
-
- ico = ical_new ("", user_name, "");
- ico->new = TRUE;
-
- tm = *localtime (&day);
-
- /* Set the start time of the event to the beginning of the day */
-
- tm.tm_hour = day_begin;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- ico->dtstart = mktime (&tm);
-
- /* Set the end time of the event to the end of the day */
-
- tm.tm_hour = day_end;
- ico->dtend = mktime (&tm);
-
- /* Launch the event editor */
-
- ee = event_editor_new (owner, ico);
- gtk_widget_show (ee);
-}
diff --git a/calendar/gui/eventedit.h b/calendar/gui/eventedit.h
deleted file mode 100644
index 4d605892dd..0000000000
--- a/calendar/gui/eventedit.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * EventEditor widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-
-#ifndef EVENT_EDITOR_H
-#define EVENT_EDITOR_H
-
-#include "gnome-cal.h"
-#include <libgnomeui/gnome-dialog.h>
-
-BEGIN_GNOME_DECLS
-
-
-#define EVENT_EDITOR(obj) GTK_CHECK_CAST(obj, event_editor_get_type(), EventEditor)
-#define EVENT_EDITOR_CLASS(class) GTK_CHECK_CAST_CLASS(class, event_editor_get_type(), EventEditorClass)
-#define IS_EVENT_EDITOR(obj) GTK_CHECK_TYPE(obj, event_editor_get_type())
-
-
-typedef struct {
- GnomeDialog dialog;
- GtkWidget *notebook;
-
- GtkWidget *general;
- GtkWidget *general_table;
- GtkWidget *general_time_table;
- GtkWidget *general_allday;
- GtkWidget *general_owner;
- GtkWidget *general_summary;
- GtkWidget *start_time, *end_time;
- GtkWidget *general_radios;
-
- GtkWidget *recur_page_label;
- GtkWidget *recur_vbox;
- GtkWidget *recur_hbox;
-
- GSList *recur_rr_group;
- GtkWidget *recur_rr_notebook;
- GtkWidget *recur_rr_day_period;
- GtkWidget *recur_rr_week_period;
- GtkWidget *recur_rr_week_days [7];
- GtkWidget *recur_rr_month_date;
- GtkWidget *recur_rr_month_date_label;
- GtkWidget *recur_rr_month_day;
- GtkWidget *recur_rr_month_weekday;
- GtkWidget *recur_rr_month_period;
- GtkWidget *recur_rr_year_period;
-
- GSList *recur_ed_group;
- GtkWidget *recur_ed_end_on;
- GtkWidget *recur_ed_end_after;
-
- GtkWidget *recur_ex_date;
- GtkWidget *recur_ex_vbox;
- GtkWidget *recur_ex_clist;
-
- /* The associated ical object */
- iCalObject *ical;
-
- /* The calendar owner of this event */
- GnomeCalendar *gnome_cal;
-} EventEditor;
-
-typedef struct {
- GnomeDialogClass parent_class;
-} EventEditorClass;
-
-
-guint event_editor_get_type (void);
-GtkWidget *event_editor_new (GnomeCalendar *owner, iCalObject *);
-
-/* Convenience function to create and show a new event editor for an event that goes from day_begin
- * to day_end of the specified day.
- */
-void event_editor_new_whole_day (GnomeCalendar *owner, time_t day);
-
-GtkWidget *date_edit_new (time_t the_time, int show_time);
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/getdate.y b/calendar/gui/getdate.y
deleted file mode 100644
index 6df71bddda..0000000000
--- a/calendar/gui/getdate.y
+++ /dev/null
@@ -1,1001 +0,0 @@
-%{
-/*
-** Originally) written by Steven M. Bellovin <smb@research.att.com> while
-** at the University of North Carolina at Chapel Hill. Later tweaked by
-** a couple of people on Usenet. Completely overhauled by Rich $alz
-** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
-** send any email to Rich.
-**
-** This grammar has 10 shift/reduce conflicts.
-**
-** This code is in the public domain and has no copyright.
-*/
-/* SUPPRESS 287 on yaccpar_sccsid *//* Unused static variable */
-/* SUPPRESS 288 on yyerrlab *//* Label unused */
-
-#include <config.h>
-#include <gnome.h>
-
-/* Since the code of getdate.y is not included in the Emacs executable
- itself, there is no need to #define static in this file. Even if
- the code were included in the Emacs executable, it probably
- wouldn't do any harm to #undef it here; this will only cause
- problems if we try to write to a static variable, which I don't
- think this code needs to do. */
-#ifdef emacs
-#undef static
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-
-/* The code at the top of get_date which figures out the offset of the
- current time zone checks various CPP symbols to see if special
- tricks are need, but defaults to using the gettimeofday system call.
- Include <sys/time.h> if that will be used. */
-
-#if defined(vms)
-
-#include <types.h>
-#include <time.h>
-
-#else
-
-#include <sys/types.h>
-
-#ifdef TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#else
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#endif
-
-#ifdef timezone
-#undef timezone /* needed for sgi */
-#endif
-
-#if defined(HAVE_SYS_TIMEB_H)
-#include <sys/timeb.h>
-#else
-/*
-** We use the obsolete `struct timeb' as part of our interface!
-** Since the system doesn't have it, we define it here;
-** our callers must do likewise.
-*/
-struct timeb {
- time_t time; /* Seconds since the epoch */
- unsigned short millitm; /* Field not used */
- short timezone; /* Minutes west of GMT */
- short dstflag; /* Field not used */
-};
-#endif /* defined(HAVE_SYS_TIMEB_H) */
-
-#endif /* defined(vms) */
-
-#if defined (STDC_HEADERS) || defined (USG)
-#include <string.h>
-#endif
-
-/* Some old versions of bison generate parsers that use bcopy.
- That loses on systems that don't provide the function, so we have
- to redefine it here. */
-#if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy)
-#define bcopy(from, to, len) memcpy ((to), (from), (len))
-#endif
-
-#if defined (STDC_HEADERS)
-#include <stdlib.h>
-#endif
-
-/* NOTES on rebuilding getdate.c (particularly for inclusion in CVS
- releases):
-
- We don't want to mess with all the portability hassles of alloca.
- In particular, most (all?) versions of bison will use alloca in
- their parser. If bison works on your system (e.g. it should work
- with gcc), then go ahead and use it, but the more general solution
- is to use byacc instead of bison, which should generate a portable
- parser. I played with adding "#define alloca dont_use_alloca", to
- give an error if the parser generator uses alloca (and thus detect
- unportable getdate.c's), but that seems to cause as many problems
- as it solves. */
-
-extern struct tm *gmtime();
-extern struct tm *localtime();
-
-#define yyparse getdate_yyparse
-#define yylex getdate_yylex
-#define yyerror getdate_yyerror
-
-static int yylex ();
-static int yyerror ();
-
-#define EPOCH 1970
-#define HOUR(x) ((time_t)(x) * 60)
-#define SECSPERDAY (24L * 60L * 60L)
-
-
-/*
-** An entry in the lexical lookup table.
-*/
-typedef struct _TABLE {
- char *name;
- int type;
- time_t value;
-} TABLE;
-
-
-/*
-** Daylight-savings mode: on, off, or not yet known.
-*/
-typedef enum _DSTMODE {
- DSTon, DSToff, DSTmaybe
-} DSTMODE;
-
-/*
-** Meridian: am, pm, or 24-hour style.
-*/
-typedef enum _MERIDIAN {
- MERam, MERpm, MER24
-} MERIDIAN;
-
-
-/*
-** Global variables. We could get rid of most of these by using a good
-** union as the yacc stack. (This routine was originally written before
-** yacc had the %union construct.) Maybe someday; right now we only use
-** the %union very rarely.
-*/
-static char *yyInput;
-static DSTMODE yyDSTmode;
-static time_t yyDayOrdinal;
-static time_t yyDayNumber;
-static int yyHaveDate;
-static int yyHaveDay;
-static int yyHaveRel;
-static int yyHaveTime;
-static int yyHaveZone;
-static time_t yyTimezone;
-static time_t yyDay;
-static time_t yyHour;
-static time_t yyMinutes;
-static time_t yyMonth;
-static time_t yySeconds;
-static time_t yyYear;
-static MERIDIAN yyMeridian;
-static time_t yyRelMonth;
-static time_t yyRelSeconds;
-
-%}
-
-%union {
- time_t Number;
- enum _MERIDIAN Meridian;
-}
-
-%token tAGO tDAY tDAYZONE tID tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT
-%token tSEC_UNIT tSNUMBER tUNUMBER tZONE tDST
-
-%type <Number> tDAY tDAYZONE tMINUTE_UNIT tMONTH tMONTH_UNIT
-%type <Number> tSEC_UNIT tSNUMBER tUNUMBER tZONE
-%type <Meridian> tMERIDIAN o_merid
-
-%%
-
-spec : /* NULL */
- | spec item
- ;
-
-item : time {
- yyHaveTime++;
- }
- | zone {
- yyHaveZone++;
- }
- | date {
- yyHaveDate++;
- }
- | day {
- yyHaveDay++;
- }
- | rel {
- yyHaveRel++;
- }
- | number
- ;
-
-time : tUNUMBER tMERIDIAN {
- yyHour = $1;
- yyMinutes = 0;
- yySeconds = 0;
- yyMeridian = $2;
- }
- | tUNUMBER ':' tUNUMBER o_merid {
- yyHour = $1;
- yyMinutes = $3;
- yySeconds = 0;
- yyMeridian = $4;
- }
- | tUNUMBER ':' tUNUMBER tSNUMBER {
- yyHour = $1;
- yyMinutes = $3;
- yyMeridian = MER24;
- yyDSTmode = DSToff;
- yyTimezone = - ($4 % 100 + ($4 / 100) * 60);
- }
- | tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid {
- yyHour = $1;
- yyMinutes = $3;
- yySeconds = $5;
- yyMeridian = $6;
- }
- | tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER {
- yyHour = $1;
- yyMinutes = $3;
- yySeconds = $5;
- yyMeridian = MER24;
- yyDSTmode = DSToff;
- yyTimezone = - ($6 % 100 + ($6 / 100) * 60);
- }
- ;
-
-zone : tZONE {
- yyTimezone = $1;
- yyDSTmode = DSToff;
- }
- | tDAYZONE {
- yyTimezone = $1;
- yyDSTmode = DSTon;
- }
- |
- tZONE tDST {
- yyTimezone = $1;
- yyDSTmode = DSTon;
- }
- ;
-
-day : tDAY {
- yyDayOrdinal = 1;
- yyDayNumber = $1;
- }
- | tDAY ',' {
- yyDayOrdinal = 1;
- yyDayNumber = $1;
- }
- | tUNUMBER tDAY {
- yyDayOrdinal = $1;
- yyDayNumber = $2;
- }
- ;
-
-date : tUNUMBER '/' tUNUMBER {
- yyMonth = $1;
- yyDay = $3;
- }
- | tUNUMBER '/' tUNUMBER '/' tUNUMBER {
- yyMonth = $1;
- yyDay = $3;
- yyYear = $5;
- }
- | tUNUMBER tSNUMBER tSNUMBER {
- /* ISO 8601 format. yyyy-mm-dd. */
- yyYear = $1;
- yyMonth = -$2;
- yyDay = -$3;
- }
- | tUNUMBER tMONTH tSNUMBER {
- /* e.g. 17-JUN-1992. */
- yyDay = $1;
- yyMonth = $2;
- yyYear = -$3;
- }
- | tMONTH tUNUMBER {
- yyMonth = $1;
- yyDay = $2;
- }
- | tMONTH tUNUMBER ',' tUNUMBER {
- yyMonth = $1;
- yyDay = $2;
- yyYear = $4;
- }
- | tUNUMBER tMONTH {
- yyMonth = $2;
- yyDay = $1;
- }
- | tUNUMBER tMONTH tUNUMBER {
- yyMonth = $2;
- yyDay = $1;
- yyYear = $3;
- }
- ;
-
-rel : relunit tAGO {
- yyRelSeconds = -yyRelSeconds;
- yyRelMonth = -yyRelMonth;
- }
- | relunit
- ;
-
-relunit : tUNUMBER tMINUTE_UNIT {
- yyRelSeconds += $1 * $2 * 60L;
- }
- | tSNUMBER tMINUTE_UNIT {
- yyRelSeconds += $1 * $2 * 60L;
- }
- | tMINUTE_UNIT {
- yyRelSeconds += $1 * 60L;
- }
- | tSNUMBER tSEC_UNIT {
- yyRelSeconds += $1;
- }
- | tUNUMBER tSEC_UNIT {
- yyRelSeconds += $1;
- }
- | tSEC_UNIT {
- yyRelSeconds++;
- }
- | tSNUMBER tMONTH_UNIT {
- yyRelMonth += $1 * $2;
- }
- | tUNUMBER tMONTH_UNIT {
- yyRelMonth += $1 * $2;
- }
- | tMONTH_UNIT {
- yyRelMonth += $1;
- }
- ;
-
-number : tUNUMBER {
- if (yyHaveTime && yyHaveDate && !yyHaveRel)
- yyYear = $1;
- else {
- if($1>10000) {
- yyHaveDate++;
- yyDay= ($1)%100;
- yyMonth= ($1/100)%100;
- yyYear = $1/10000;
- }
- else {
- yyHaveTime++;
- if ($1 < 100) {
- yyHour = $1;
- yyMinutes = 0;
- }
- else {
- yyHour = $1 / 100;
- yyMinutes = $1 % 100;
- }
- yySeconds = 0;
- yyMeridian = MER24;
- }
- }
- }
- ;
-
-o_merid : /* NULL */ {
- $$ = MER24;
- }
- | tMERIDIAN {
- $$ = $1;
- }
- ;
-
-%%
-
-/* Month and day table. */
-static TABLE const MonthDayTable[] = {
- { N_("january"), tMONTH, 1 },
- { N_("february"), tMONTH, 2 },
- { N_("march"), tMONTH, 3 },
- { N_("april"), tMONTH, 4 },
- { N_("may"), tMONTH, 5 },
- { N_("june"), tMONTH, 6 },
- { N_("july"), tMONTH, 7 },
- { N_("august"), tMONTH, 8 },
- { N_("september"), tMONTH, 9 },
- { N_("sept"), tMONTH, 9 },
- { N_("october"), tMONTH, 10 },
- { N_("november"), tMONTH, 11 },
- { N_("december"), tMONTH, 12 },
- { N_("sunday"), tDAY, 0 },
- { N_("monday"), tDAY, 1 },
- { N_("tuesday"), tDAY, 2 },
- { N_("tues"), tDAY, 2 },
- { N_("wednesday"), tDAY, 3 },
- { N_("wednes"), tDAY, 3 },
- { N_("thursday"), tDAY, 4 },
- { N_("thur"), tDAY, 4 },
- { N_("thurs"), tDAY, 4 },
- { N_("friday"), tDAY, 5 },
- { N_("saturday"), tDAY, 6 },
- { NULL }
-};
-
-/* Time units table. */
-static TABLE const UnitsTable[] = {
- { N_("year"), tMONTH_UNIT, 12 },
- { N_("month"), tMONTH_UNIT, 1 },
- { N_("fortnight"), tMINUTE_UNIT, 14 * 24 * 60 },
- { N_("week"), tMINUTE_UNIT, 7 * 24 * 60 },
- { N_("day"), tMINUTE_UNIT, 1 * 24 * 60 },
- { N_("hour"), tMINUTE_UNIT, 60 },
- { N_("minute"), tMINUTE_UNIT, 1 },
- { N_("min"), tMINUTE_UNIT, 1 },
- { N_("second"), tSEC_UNIT, 1 },
- { N_("sec"), tSEC_UNIT, 1 },
- { NULL }
-};
-
-/* Assorted relative-time words. */
-static TABLE const OtherTable[] = {
- { N_("tomorrow"), tMINUTE_UNIT, 1 * 24 * 60 },
- { N_("yesterday"), tMINUTE_UNIT, -1 * 24 * 60 },
- { N_("today"), tMINUTE_UNIT, 0 },
- { N_("now"), tMINUTE_UNIT, 0 },
- { N_("last"), tUNUMBER, -1 },
- { N_("this"), tMINUTE_UNIT, 0 },
- { N_("next"), tUNUMBER, 2 },
- { N_("first"), tUNUMBER, 1 },
-/* { N_("second"), tUNUMBER, 2 }, */
- { N_("third"), tUNUMBER, 3 },
- { N_("fourth"), tUNUMBER, 4 },
- { N_("fifth"), tUNUMBER, 5 },
- { N_("sixth"), tUNUMBER, 6 },
- { N_("seventh"), tUNUMBER, 7 },
- { N_("eighth"), tUNUMBER, 8 },
- { N_("ninth"), tUNUMBER, 9 },
- { N_("tenth"), tUNUMBER, 10 },
- { N_("eleventh"), tUNUMBER, 11 },
- { N_("twelfth"), tUNUMBER, 12 },
- { N_("ago"), tAGO, 1 },
- { NULL }
-};
-
-/* The timezone table. */
-/* Some of these are commented out because a time_t can't store a float. */
-static TABLE const TimezoneTable[] = {
- { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
- { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */
- { "utc", tZONE, HOUR( 0) },
- { "wet", tZONE, HOUR( 0) }, /* Western European */
- { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
- { "wat", tZONE, HOUR( 1) }, /* West Africa */
- { "at", tZONE, HOUR( 2) }, /* Azores */
-#if 0
- /* For completeness. BST is also British Summer, and GST is
- * also Guam Standard. */
- { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
- { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
-#endif
-#if 0
- { "nft", tZONE, HOUR(3.5) }, /* Newfoundland */
- { "nst", tZONE, HOUR(3.5) }, /* Newfoundland Standard */
- { "ndt", tDAYZONE, HOUR(3.5) }, /* Newfoundland Daylight */
-#endif
- { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
- { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
- { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
- { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
- { "cst", tZONE, HOUR( 6) }, /* Central Standard */
- { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
- { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
- { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
- { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
- { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
- { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
- { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
- { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
- { "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */
- { "cat", tZONE, HOUR(10) }, /* Central Alaska */
- { "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */
- { "nt", tZONE, HOUR(11) }, /* Nome */
- { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
- { "cet", tZONE, -HOUR(1) }, /* Central European */
- { "met", tZONE, -HOUR(1) }, /* Middle European */
- { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
- { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
- { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
- { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
- { "fwt", tZONE, -HOUR(1) }, /* French Winter */
- { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
- { "eet", tZONE, -HOUR(2) }, /* Eastern Europe, USSR Zone 1 */
- { "bt", tZONE, -HOUR(3) }, /* Baghdad, USSR Zone 2 */
-#if 0
- { "it", tZONE, -HOUR(3.5) },/* Iran */
-#endif
- { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
- { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
-#if 0
- { "ist", tZONE, -HOUR(5.5) },/* Indian Standard */
-#endif
- { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
-#if 0
- /* For completeness. NST is also Newfoundland Stanard, and SST is
- * also Swedish Summer. */
- { "nst", tZONE, -HOUR(6.5) },/* North Sumatra */
- { "sst", tZONE, -HOUR(7) }, /* South Sumatra, USSR Zone 6 */
-#endif /* 0 */
- { "wast", tZONE, -HOUR(7) }, /* West Australian Standard */
- { "wadt", tDAYZONE, -HOUR(7) }, /* West Australian Daylight */
-#if 0
- { "jt", tZONE, -HOUR(7.5) },/* Java (3pm in Cronusland!) */
-#endif
- { "cct", tZONE, -HOUR(8) }, /* China Coast, USSR Zone 7 */
- { "jst", tZONE, -HOUR(9) }, /* Japan Standard, USSR Zone 8 */
-#if 0
- { "cast", tZONE, -HOUR(9.5) },/* Central Australian Standard */
- { "cadt", tDAYZONE, -HOUR(9.5) },/* Central Australian Daylight */
-#endif
- { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
- { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
- { "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */
- { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
- { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
- { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
- { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
- { NULL }
-};
-
-/* Military timezone table. */
-static TABLE const MilitaryTable[] = {
- { "a", tZONE, HOUR( 1) },
- { "b", tZONE, HOUR( 2) },
- { "c", tZONE, HOUR( 3) },
- { "d", tZONE, HOUR( 4) },
- { "e", tZONE, HOUR( 5) },
- { "f", tZONE, HOUR( 6) },
- { "g", tZONE, HOUR( 7) },
- { "h", tZONE, HOUR( 8) },
- { "i", tZONE, HOUR( 9) },
- { "k", tZONE, HOUR( 10) },
- { "l", tZONE, HOUR( 11) },
- { "m", tZONE, HOUR( 12) },
- { "n", tZONE, HOUR(- 1) },
- { "o", tZONE, HOUR(- 2) },
- { "p", tZONE, HOUR(- 3) },
- { "q", tZONE, HOUR(- 4) },
- { "r", tZONE, HOUR(- 5) },
- { "s", tZONE, HOUR(- 6) },
- { "t", tZONE, HOUR(- 7) },
- { "u", tZONE, HOUR(- 8) },
- { "v", tZONE, HOUR(- 9) },
- { "w", tZONE, HOUR(-10) },
- { "x", tZONE, HOUR(-11) },
- { "y", tZONE, HOUR(-12) },
- { "z", tZONE, HOUR( 0) },
- { NULL }
-};
-
-
-
-
-/* ARGSUSED */
-static int
-yyerror(s)
- char *s;
-{
- return 0;
-}
-
-
-static time_t
-ToSeconds(Hours, Minutes, Seconds, Meridian)
- time_t Hours;
- time_t Minutes;
- time_t Seconds;
- MERIDIAN Meridian;
-{
- if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59)
- return -1;
- switch (Meridian) {
- case MER24:
- if (Hours < 0 || Hours > 23)
- return -1;
- return (Hours * 60L + Minutes) * 60L + Seconds;
- case MERam:
- if (Hours < 1 || Hours > 12)
- return -1;
- return (Hours * 60L + Minutes) * 60L + Seconds;
- case MERpm:
- if (Hours < 1 || Hours > 12)
- return -1;
- return ((Hours + 12) * 60L + Minutes) * 60L + Seconds;
- default:
- abort ();
- }
- /* NOTREACHED */
-}
-
-
-static time_t
-Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode)
- time_t Month;
- time_t Day;
- time_t Year;
- time_t Hours;
- time_t Minutes;
- time_t Seconds;
- MERIDIAN Meridian;
- DSTMODE DSTmode;
-{
- static int DaysInMonth[12] = {
- 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
- };
- time_t tod;
- time_t Julian;
- int i;
-
- if (Year < 0)
- Year = -Year;
- if (Year < 100)
- Year += 1900;
- DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0)
- ? 29 : 28;
- if (Year < EPOCH || Year > 1999
- || Month < 1 || Month > 12
- /* Lint fluff: "conversion from long may lose accuracy" */
- || Day < 1 || Day > DaysInMonth[(int)--Month])
- return -1;
-
- for (Julian = Day - 1, i = 0; i < Month; i++)
- Julian += DaysInMonth[i];
- for (i = EPOCH; i < Year; i++)
- Julian += 365 + (i % 4 == 0);
- Julian *= SECSPERDAY;
- Julian += yyTimezone * 60L;
- if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
- return -1;
- Julian += tod;
- if (DSTmode == DSTon
- || (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst))
- Julian -= 60 * 60;
- return Julian;
-}
-
-
-static time_t
-DSTcorrect(Start, Future)
- time_t Start;
- time_t Future;
-{
- time_t StartDay;
- time_t FutureDay;
-
- StartDay = (localtime(&Start)->tm_hour + 1) % 24;
- FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
- return (Future - Start) + (StartDay - FutureDay) * 60L * 60L;
-}
-
-
-static time_t
-RelativeDate(Start, DayOrdinal, DayNumber)
- time_t Start;
- time_t DayOrdinal;
- time_t DayNumber;
-{
- struct tm *tm;
- time_t now;
-
- now = Start;
- tm = localtime(&now);
- now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7);
- now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1);
- return DSTcorrect(Start, now);
-}
-
-
-static time_t
-RelativeMonth(Start, RelMonth)
- time_t Start;
- time_t RelMonth;
-{
- struct tm *tm;
- time_t Month;
- time_t Year;
-
- if (RelMonth == 0)
- return 0;
- tm = localtime(&Start);
- Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
- Year = Month / 12;
- Month = Month % 12 + 1;
- return DSTcorrect(Start,
- Convert(Month, (time_t)tm->tm_mday, Year,
- (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
- MER24, DSTmaybe));
-}
-
-
-static int
-LookupWord(buff)
- char *buff;
-{
- register char *p;
- register char *q;
- register const TABLE *tp;
- int i;
- int abbrev;
-
- /* Make it lowercase. */
- for (p = buff; *p; p++)
- if (isupper(*p))
- *p = tolower(*p);
-
- if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) {
- yylval.Meridian = MERam;
- return tMERIDIAN;
- }
- if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) {
- yylval.Meridian = MERpm;
- return tMERIDIAN;
- }
-
- /* See if we have an abbreviation for a month. */
- if (strlen(buff) == 3)
- abbrev = 1;
- else if (strlen(buff) == 4 && buff[3] == '.') {
- abbrev = 1;
- buff[3] = '\0';
- }
- else
- abbrev = 0;
-
- for (tp = MonthDayTable; tp->name; tp++) {
- if (abbrev) {
- if (strncmp(buff, tp->name, 3) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- }
- else if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- }
-
- for (tp = TimezoneTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- if (strcmp(buff, "dst") == 0)
- return tDST;
-
- for (tp = UnitsTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- /* Strip off any plural and try the units table again. */
- i = strlen(buff) - 1;
- if (buff[i] == 's') {
- buff[i] = '\0';
- for (tp = UnitsTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- buff[i] = 's'; /* Put back for "this" in OtherTable. */
- }
-
- for (tp = OtherTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- /* Military timezones. */
- if (buff[1] == '\0' && isalpha(*buff)) {
- for (tp = MilitaryTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- }
-
- /* Drop out any periods and try the timezone table again. */
- for (i = 0, p = q = buff; *q; q++)
- if (*q != '.')
- *p++ = *q;
- else
- i++;
- *p = '\0';
- if (i)
- for (tp = TimezoneTable; tp->name; tp++)
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
-
- return tID;
-}
-
-
-static int
-yylex()
-{
- register char c;
- register char *p;
- char buff[20];
- int Count;
- int sign;
-
- for ( ; ; ) {
- while (isspace(*yyInput))
- yyInput++;
-
- if (isdigit(c = *yyInput) || c == '-' || c == '+') {
- if (c == '-' || c == '+') {
- sign = c == '-' ? -1 : 1;
- if (!isdigit(*++yyInput))
- /* skip the '-' sign */
- continue;
- }
- else
- sign = 0;
- for (yylval.Number = 0; isdigit(c = *yyInput++); )
- yylval.Number = 10 * yylval.Number + c - '0';
- yyInput--;
- if (sign < 0)
- yylval.Number = -yylval.Number;
- return sign ? tSNUMBER : tUNUMBER;
- }
- if (isalpha(c)) {
- for (p = buff; isalpha(c = *yyInput++) || c == '.'; )
- if (p < &buff[sizeof buff - 1])
- *p++ = c;
- *p = '\0';
- yyInput--;
- return LookupWord(buff);
- }
- if (c != '(')
- return *yyInput++;
- Count = 0;
- do {
- c = *yyInput++;
- if (c == '\0')
- return c;
- if (c == '(')
- Count++;
- else if (c == ')')
- Count--;
- } while (Count > 0);
- }
-}
-
-#define TM_YEAR_ORIGIN 1900
-
-/* Yield A - B, measured in seconds. */
-static long
-difftm (a, b)
- struct tm *a, *b;
-{
- int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
- int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
- int days = (
- /* difference in day of year */
- a->tm_yday - b->tm_yday
- /* + intervening leap days */
- + ((ay >> 2) - (by >> 2))
- - (ay/100 - by/100)
- + ((ay/100 >> 2) - (by/100 >> 2))
- /* + difference in years * 365 */
- + (long)(ay-by) * 365
- );
- return (60*(60*(24*days + (a->tm_hour - b->tm_hour))
- + (a->tm_min - b->tm_min))
- + (a->tm_sec - b->tm_sec));
-}
-
-time_t
-get_date(p, now)
- char *p;
- struct timeb *now;
-{
- struct tm *tm, gmt;
- struct timeb ftz;
- time_t Start;
- time_t tod;
- time_t nowtime;
-
- yyInput = p;
- if (now == NULL) {
- now = &ftz;
- (void)time (&nowtime);
-
- if (! (tm = gmtime (&nowtime)))
- return -1;
- gmt = *tm; /* Make a copy, in case localtime modifies *tm. */
-
- if (! (tm = localtime (&nowtime)))
- return -1;
-
- ftz.timezone = difftm (&gmt, tm) / 60;
- if(tm->tm_isdst)
- ftz.timezone += 60;
- }
- else
- {
- nowtime = now->time;
- }
-
- tm = localtime(&nowtime);
- yyYear = tm->tm_year;
- yyMonth = tm->tm_mon + 1;
- yyDay = tm->tm_mday;
- yyTimezone = now->timezone;
- yyDSTmode = DSTmaybe;
- yyHour = 0;
- yyMinutes = 0;
- yySeconds = 0;
- yyMeridian = MER24;
- yyRelSeconds = 0;
- yyRelMonth = 0;
- yyHaveDate = 0;
- yyHaveDay = 0;
- yyHaveRel = 0;
- yyHaveTime = 0;
- yyHaveZone = 0;
-
- if (yyparse()
- || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1)
- return -1;
-
- if (yyHaveDate || yyHaveTime || yyHaveDay) {
- Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
- yyMeridian, yyDSTmode);
- if (Start < 0)
- return -1;
- }
- else {
- Start = nowtime;
- if (!yyHaveRel)
- Start -= ((tm->tm_hour * 60L + tm->tm_min) * 60L) + tm->tm_sec;
- }
-
- Start += yyRelSeconds;
- Start += RelativeMonth(Start, yyRelMonth);
-
- if (yyHaveDay && !yyHaveDate) {
- tod = RelativeDate(Start, yyDayOrdinal, yyDayNumber);
- Start += tod;
- }
-
- /* Have to do *something* with a legitimate -1 so it's distinguishable
- * from the error return value. (Alternately could set errno on error.) */
- return Start == -1 ? 0 : Start;
-}
-
-
-#if defined(TEST)
-
-/* ARGSUSED */
-int
-main(ac, av)
- int ac;
- char *av[];
-{
- char buff[128];
- time_t d;
-
- (void)printf("Enter date, or blank line to exit.\n\t> ");
- (void)fflush(stdout);
- while (gets(buff) && buff[0]) {
- d = get_date(buff, (struct timeb *)NULL);
- if (d == -1)
- (void)printf("Bad format - couldn't convert.\n");
- else
- (void)printf("%s", ctime(&d));
- (void)printf("\t> ");
- (void)fflush(stdout);
- }
- exit(0);
- /* NOTREACHED */
-}
-#endif /* defined(TEST) */
diff --git a/calendar/gui/gncal-day-panel.c b/calendar/gui/gncal-day-panel.c
deleted file mode 100644
index f407a497d3..0000000000
--- a/calendar/gui/gncal-day-panel.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/* Day view notebook panel for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#include <config.h>
-#include <gnome.h>
-#include <gtk/gtkhseparator.h>
-#include "gncal-day-panel.h"
-#include "main.h"
-#include "timeutil.h"
-
-
-guint
-gncal_day_panel_get_type (void)
-{
- static guint day_panel_type = 0;
-
- if (!day_panel_type) {
- GtkTypeInfo day_panel_info = {
- "GncalDayPanel",
- sizeof (GncalDayPanel),
- sizeof (GncalDayPanelClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) NULL,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- day_panel_type = gtk_type_unique (gtk_table_get_type (), &day_panel_info);
- }
-
- return day_panel_type;
-}
-
-static void
-day_view_range_activated (GncalFullDay *fullday, GncalDayPanel *dpanel)
-{
- iCalObject *ical;
-
- ical = ical_new ("", user_name, "");
- ical->new = 1;
-
- gncal_full_day_selection_range (fullday, &ical->dtstart, &ical->dtend);
-
- gnome_calendar_add_object (dpanel->calendar, ical);
- save_default_calendar (dpanel->calendar);
- gncal_full_day_focus_child (fullday, ical);
-}
-
-static void
-full_day_size_allocated (GtkWidget *widget, GtkAllocation *allocation, GncalDayPanel *dpanel)
-{
- GtkAdjustment *adj;
- int yoffset;
- gfloat newval;
-
- adj = gtk_scrolled_window_get_vadjustment (dpanel->fullday_sw);
-
- yoffset = gncal_full_day_get_day_start_yoffset (GNCAL_FULL_DAY (widget));
-
- newval = adj->lower + (adj->upper - adj->lower) * (double) yoffset / allocation->height;
- if (newval != adj->value)
- gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");
-}
-
-static void
-calendar_day_selected (GtkCalendar *calendar, GncalDayPanel *dpanel)
-{
- gint y, m, d;
- struct tm tm;
-
- gtk_calendar_get_date (calendar, &y, &m, &d);
-
- tm.tm_year = y - 1900;
- tm.tm_mon = m;
- tm.tm_mday = d;
- tm.tm_hour = 5; /* for daylight savings time fix */
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- gnome_calendar_goto (dpanel->calendar, mktime (&tm));
-}
-
-static void
-retag_calendar (GtkCalendar *calendar, GncalDayPanel *dpanel)
-{
- gnome_calendar_tag_calendar (dpanel->calendar, GTK_CALENDAR (dpanel->gtk_calendar));
-}
-
-GtkWidget *
-gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day)
-{
- GncalDayPanel *dpanel;
- GtkWidget *w;
- GtkWidget *hpane, *vpane;
- gint start_pos = 265;
- struct tm tm;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- dpanel = gtk_type_new (gncal_day_panel_get_type ());
-
- gtk_container_border_width (GTK_CONTAINER (dpanel), 4);
- gtk_table_set_row_spacings (GTK_TABLE (dpanel), 4);
- gtk_table_set_col_spacings (GTK_TABLE (dpanel), 4);
-
- dpanel->calendar = calendar;
-
- /* Date label */
-
- w = gtk_label_new ("");
- dpanel->date_label = GTK_LABEL (w);
- gtk_table_attach (GTK_TABLE (dpanel), w,
- 0, 1, 0, 1,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_widget_show (w);
-
- /* Create horizontal pane */
-
- hpane = gtk_hpaned_new ();
- gtk_table_attach (GTK_TABLE (dpanel), hpane,
- 0, 1, 2, 4,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- /* Full day */
-
- w = gtk_scrolled_window_new (NULL, NULL);
- dpanel->fullday_sw = GTK_SCROLLED_WINDOW (w);
- gtk_scrolled_window_set_policy (dpanel->fullday_sw,
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_paned_pack1 (GTK_PANED (hpane), w, FALSE, TRUE);
- /*gtk_paned_add1 (GTK_PANED (hpane), w);*/
- gtk_widget_show (w);
-
- w = gncal_full_day_new (calendar, time_day_begin (start_of_day), time_day_end (start_of_day));
- dpanel->fullday = GNCAL_FULL_DAY (w);
- gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "range_activated",
- (GtkSignalFunc) day_view_range_activated,
- dpanel);
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (dpanel->fullday_sw), w);
- gtk_widget_show (w);
-
- /* We'll scroll the list to the proper initial position */
-
- gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "size_allocate",
- (GtkSignalFunc) full_day_size_allocated,
- dpanel);
-
- /* Create vertical pane */
-
- vpane = gtk_vpaned_new ();
- gtk_paned_pack2 (GTK_PANED (hpane), GTK_WIDGET (vpane), TRUE, TRUE);
- /*gtk_paned_add2 (GTK_PANED (hpane), GTK_WIDGET (vpane));*/
-
- /* Gtk calendar */
-
- tm = *localtime (&start_of_day);
-
- w = gtk_calendar_new ();
- dpanel->gtk_calendar = GTK_CALENDAR (w);
- gtk_calendar_display_options (dpanel->gtk_calendar,
- (GTK_CALENDAR_SHOW_HEADING
- | GTK_CALENDAR_SHOW_DAY_NAMES
- | (week_starts_on_monday
- ? GTK_CALENDAR_WEEK_START_MONDAY : 0)));
- gtk_calendar_select_month (dpanel->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
- gtk_calendar_select_day (dpanel->gtk_calendar, tm.tm_mday);
- dpanel->day_selected_id = gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar),
- "day_selected_double_click",
- (GtkSignalFunc) calendar_day_selected,
- dpanel);
- gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar), "month_changed",
- GTK_SIGNAL_FUNC (retag_calendar), dpanel);
- gtk_paned_add1 (GTK_PANED (vpane), w);
- gtk_widget_show (w);
-
- /* To-do */
-
- w = gncal_todo_new (calendar);
- dpanel->todo = GNCAL_TODO (w);
- gtk_paned_add2 (GTK_PANED (vpane), w);
- gtk_widget_show (w);
-
- /* Done */
-
- gncal_day_panel_set (dpanel, start_of_day);
-
- gtk_paned_set_position (GTK_PANED (hpane), start_pos);
-
- return GTK_WIDGET (dpanel);
-}
-
-static void
-update (GncalDayPanel *dpanel, int update_fullday, iCalObject *ico, int flags)
-{
- char buf [80];
-
- if (update_fullday){
- gncal_full_day_update (dpanel->fullday, ico, flags);
- retag_calendar (dpanel->gtk_calendar, dpanel);
- }
- gncal_todo_update (dpanel->todo, ico, flags);
-
- strftime (buf, sizeof (buf), _("%a %b %d %Y"), localtime (&dpanel->start_of_day));
- gtk_label_set (GTK_LABEL (dpanel->date_label), buf);
-}
-
-void
-gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags)
-{
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- update (dpanel, TRUE, ico, flags);
-}
-
-void
-gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day)
-{
- char buf[80];
- struct tm tm;
-
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- dpanel->start_of_day = time_day_begin(start_of_day);
- if (dpanel->fullday->lower == dpanel->start_of_day)
- return;
-
- tm = *localtime (&dpanel->start_of_day);
- strftime (buf, sizeof (buf), _("%a %b %d %Y"), &tm);
- gtk_label_set (GTK_LABEL (dpanel->date_label), buf);
-
- gncal_full_day_set_bounds (dpanel->fullday, dpanel->start_of_day, time_day_end (dpanel->start_of_day));
-
- gtk_calendar_select_month (dpanel->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
-
- gtk_signal_handler_block (GTK_OBJECT (dpanel->gtk_calendar), dpanel->day_selected_id);
- gtk_calendar_select_day (dpanel->gtk_calendar, tm.tm_mday);
- gtk_signal_handler_unblock (GTK_OBJECT (dpanel->gtk_calendar), dpanel->day_selected_id);
-
- update (dpanel, FALSE, NULL, 0);
-}
-
-void
-gncal_day_panel_time_format_changed (GncalDayPanel *dpanel)
-{
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- gtk_calendar_display_options (dpanel->gtk_calendar,
- (week_starts_on_monday
- ? (dpanel->gtk_calendar->display_flags
- | GTK_CALENDAR_WEEK_START_MONDAY)
- : (dpanel->gtk_calendar->display_flags
- & ~GTK_CALENDAR_WEEK_START_MONDAY)));
-}
-
-void
-todo_list_properties_changed (GncalDayPanel *dpanel)
-{
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- gncal_todo_update (dpanel->todo, NULL, 0);
-}
-
-
-
diff --git a/calendar/gui/gncal-day-panel.h b/calendar/gui/gncal-day-panel.h
deleted file mode 100644
index 6bf8768d9c..0000000000
--- a/calendar/gui/gncal-day-panel.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Day view notebook panel for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_DAY_PANEL_H
-#define GNCAL_DAY_PANEL_H
-
-#include <gtk/gtklabel.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktable.h>
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-#include "gncal-full-day.h"
-#include "gncal-todo.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_DAY_PANEL(obj) GTK_CHECK_CAST (obj, gncal_day_panel_get_type (), GncalDayPanel)
-#define GNCAL_DAY_PANEL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_day_panel_get_type (), GncalDayPanelClass)
-#define GNCAL_IS_DAY_PANEL(obj) GTK_CHECK_TYPE (obj, gncal_day_panel_get_type ())
-
-
-typedef struct _GncalDayPanel GncalDayPanel;
-typedef struct _GncalDayPanelClass GncalDayPanelClass;
-
-struct _GncalDayPanel {
- GtkTable table;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- time_t start_of_day;
-
- GtkLabel *date_label;
- GncalFullDay *fullday;
- GtkScrolledWindow *fullday_sw;
- GtkCalendar *gtk_calendar;
- GncalTodo *todo;
-
- guint day_selected_id;
-};
-
-struct _GncalDayPanelClass {
- GtkTableClass parent_class;
-};
-
-
-guint gncal_day_panel_get_type (void);
-GtkWidget *gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day);
-
-void gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags);
-void gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day);
-void gncal_day_panel_time_format_changed (GncalDayPanel *dpanel);
-
-void todo_list_properties_changed (GncalDayPanel *dpanel);
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gncal-day-view.c b/calendar/gui/gncal-day-view.c
deleted file mode 100644
index eafd237029..0000000000
--- a/calendar/gui/gncal-day-view.c
+++ /dev/null
@@ -1,396 +0,0 @@
-/* Day view widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <gnome.h>
-#include "gncal-day-view.h"
-#include "timeutil.h"
-#include "view-utils.h"
-#include "main.h"
-#include "eventedit.h"
-#include "popup-menu.h"
-
-
-#define TEXT_BORDER 2
-#define MIN_INFO_WIDTH 50
-
-
-static void gncal_day_view_class_init (GncalDayViewClass *class);
-static void gncal_day_view_init (GncalDayView *dview);
-static void gncal_day_view_destroy (GtkObject *object);
-static void gncal_day_view_realize (GtkWidget *widget);
-static void gncal_day_view_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static gint gncal_day_view_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static gint gncal_day_view_button_press (GtkWidget *widget,
- GdkEventButton *event);
-
-
-static GtkWidgetClass *parent_class;
-
-
-guint
-gncal_day_view_get_type (void)
-{
- static guint day_view_type = 0;
-
- if (!day_view_type) {
- GtkTypeInfo day_view_info = {
- "GncalDayView",
- sizeof (GncalDayView),
- sizeof (GncalDayViewClass),
- (GtkClassInitFunc) gncal_day_view_class_init,
- (GtkObjectInitFunc) gncal_day_view_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- day_view_type = gtk_type_unique (gtk_widget_get_type (), &day_view_info);
- }
-
- return day_view_type;
-}
-
-static void
-gncal_day_view_class_init (GncalDayViewClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gtk_widget_get_type ());
-
- object_class->destroy = gncal_day_view_destroy;
-
- widget_class->realize = gncal_day_view_realize;
- widget_class->size_request = gncal_day_view_size_request;
- widget_class->expose_event = gncal_day_view_expose;
- widget_class->button_press_event = gncal_day_view_button_press;
-}
-
-static void
-gncal_day_view_init (GncalDayView *dview)
-{
- GTK_WIDGET_UNSET_FLAGS (dview, GTK_NO_WINDOW);
-
- dview->calendar = NULL;
-
- dview->lower = 0;
- dview->upper = 0;
-
- dview->shadow_type = GTK_SHADOW_ETCHED_IN;
-}
-
-static void
-gncal_day_view_destroy (GtkObject *object)
-{
- GncalDayView *dview;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (object));
-
- dview = GNCAL_DAY_VIEW (object);
-
- if (dview->day_str)
- g_free (dview->day_str);
- if (dview->events)
- calendar_destroy_event_list (dview->events);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-static int
-new_appointment (GtkWidget *widget, gpointer data)
-{
- GncalDayView *dayview = GNCAL_DAY_VIEW (data);
- iCalObject *ico;
- GtkWidget *ee;
- struct tm tm;
-
- ico = ical_new ("", user_name, "");
- ico->new = 1;
-
- tm = *localtime (&dayview->lower);
- tm.tm_hour = day_begin;
- ico->dtstart = mktime (&tm);
- tm.tm_hour++;
- ico->dtend = mktime (&tm);
- ee = event_editor_new (dayview->calendar, ico);
- gtk_widget_show (ee);
- return 1;
-}
-
-static void
-context_menu (GncalDayView *dayview, GdkEventButton *event)
-{
- static struct menu_item main_items[] = {
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- main_items [0].data = dayview;
- popup_menu (main_items, 1, event);
-}
-
-static gint
-gncal_day_view_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- GncalDayView *dayview;
-
- dayview = GNCAL_DAY_VIEW (widget);
-
- if (event->button == 3)
- context_menu (dayview, event);
-
- if (event->button == 1 && event->type == GDK_2BUTTON_PRESS)
- gnome_calendar_dayjump (dayview->calendar, dayview->lower);
-
- return TRUE;
-}
-
-GtkWidget *
-gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper)
-{
- GncalDayView *dview;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- dview = gtk_type_new (gncal_day_view_get_type ());
-
- dview->calendar = calendar;
- dview->lower = lower;
- dview->upper = upper;
- dview->events = 0;
-
- gncal_day_view_update (dview, NULL, 0);
-
- return GTK_WIDGET (dview);
-}
-
-static void
-gncal_day_view_realize (GtkWidget *widget)
-{
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = (gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- gdk_window_set_background (widget->window, &widget->style->bg[GTK_STATE_PRELIGHT]);
-}
-
-static void
-gncal_day_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- GncalDayView *dview;
- int str_width, width;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (widget));
- g_return_if_fail (requisition != NULL);
-
- dview = GNCAL_DAY_VIEW (widget);
-
- /* border and min width */
-
- str_width = gdk_string_width (widget->style->font, dview->day_str);
-
- width = MAX (MIN_INFO_WIDTH, str_width);
-
- requisition->width = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + width;
- requisition->height = 2 * (widget->style->klass->ythickness + TEXT_BORDER);
-
- /* division line */
-
- requisition->height += 2 * TEXT_BORDER + widget->style->klass->ythickness;
-
- /* title and at least one line of text */
-
- requisition->height += 2 * (widget->style->font->ascent + widget->style->font->descent);
-}
-
-static gint
-gncal_day_view_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- GncalDayView *dview;
- int x1, y1, width, height;
- GdkRectangle rect, dest;
- GdkFont *font;
- int str_width;
- GdkGC *gc;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_DAY_VIEW (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return FALSE;
-
- gc = widget->style->fg_gc [GTK_STATE_NORMAL];
- dview = GNCAL_DAY_VIEW (widget);
-
- x1 = widget->style->klass->xthickness;
- y1 = widget->style->klass->ythickness;
- width = widget->allocation.width - 2 * x1;
- height = widget->allocation.height - 2 * y1;
-
- /* Clear and paint frame shadow */
-
- gdk_window_clear_area (widget->window,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
-
- gtk_draw_shadow (widget->style, widget->window,
- GTK_STATE_NORMAL, dview->shadow_type,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
-
- /* Clear and paint title */
-
- font = widget->style->font;
-
- rect.x = x1;
- rect.y = y1;
- rect.width = width;
- rect.height = 2 * TEXT_BORDER + font->ascent + font->descent;
-
- if (gdk_rectangle_intersect (&rect, &event->area, &dest)) {
- gdk_draw_rectangle (widget->window,
- widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- dest = rect;
-
- dest.x += TEXT_BORDER;
- dest.y += TEXT_BORDER;
- dest.width -= 2 * TEXT_BORDER;
- dest.height -= 2 * TEXT_BORDER;
-
- gdk_gc_set_clip_rectangle (gc, &dest);
-
- str_width = gdk_string_width (font, dview->day_str);
-
- gdk_draw_string (widget->window, font, gc,
- dest.x + (dest.width - str_width) / 2,
- dest.y + font->ascent,
- dview->day_str);
-
- gdk_gc_set_clip_rectangle (gc, NULL);
- }
-
- /* Division line */
-
- gtk_draw_hline (widget->style,
- widget->window,
- GTK_STATE_NORMAL,
- rect.x,
- rect.x + rect.width - 1,
- rect.y + rect.height);
-
- /* Text */
-
- if (dview->events != NULL){
- rect.x = x1 + TEXT_BORDER;
- rect.y = y1 + 3 * TEXT_BORDER +
- font->ascent + font->descent +
- widget->style->klass->ythickness;
- rect.width = width - 2 * TEXT_BORDER;
- rect.height = height - (rect.y - y1) - TEXT_BORDER;
-
- if (gdk_rectangle_intersect (&rect, &event->area, &dest))
- view_utils_draw_events (
- widget, widget->window, gc,
- &rect,
- VIEW_UTILS_DRAW_END | VIEW_UTILS_DRAW_SPLIT,
- dview->events,
- dview->lower,
- dview->upper);
- }
-
- return FALSE;
-}
-
-void
-gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags)
-{
- struct tm tm;
- char buf[256];
-
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
- g_return_if_fail (dview->calendar->cal);
-
- if (dview->day_str)
- g_free (dview->day_str);
-
- tm = *localtime (&dview->lower);
- strftime (buf, sizeof (buf)-1, "%A %d", &tm);
- dview->day_str = g_strdup (buf);
-
- if (dview->events)
- calendar_destroy_event_list (dview->events);
-
- dview->events = calendar_get_events_in_range (dview->calendar->cal,
- dview->lower,
- dview->upper);
-
- gtk_widget_draw (GTK_WIDGET (dview), NULL);
-}
-
-void
-gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper)
-{
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
-
- if ((lower != dview->lower) || (upper != dview->upper)) {
- dview->lower = lower;
- dview->upper = upper;
-
- gncal_day_view_update (dview, NULL, 0);
- }
-}
-
-void
-gncal_day_view_set_shadow (GncalDayView *dview, GtkShadowType shadow_type)
-{
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
-
- if (shadow_type != dview->shadow_type) {
- dview->shadow_type = shadow_type;
-
- gtk_widget_draw (GTK_WIDGET (dview), NULL);
- }
-}
diff --git a/calendar/gui/gncal-day-view.h b/calendar/gui/gncal-day-view.h
deleted file mode 100644
index dae1897fb6..0000000000
--- a/calendar/gui/gncal-day-view.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Day view widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_DAY_VIEW_H
-#define GNCAL_DAY_VIEW_H
-
-
-#include <gtk/gtkwidget.h>
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_DAY_VIEW(obj) GTK_CHECK_CAST (obj, gncal_day_view_get_type (), GncalDayView)
-#define GNCAL_DAY_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_day_view_get_type (), GncalDayViewClass)
-#define GNCAL_IS_DAY_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_day_view_get_type ())
-
-
-typedef struct _GncalDayView GncalDayView;
-typedef struct _GncalDayViewClass GncalDayViewClass;
-
-struct _GncalDayView {
- GtkWidget widget;
-
- GnomeCalendar *calendar;/* the calendar we are associated to */
-
- time_t lower; /* lower and upper times to display */
- time_t upper; /* these include the full day */
-
- char *day_str; /* what day is it? */
- GList *events; /* the events for the this day */
- GtkShadowType shadow_type;
-};
-
-struct _GncalDayViewClass {
- GtkWidgetClass parent_class;
-};
-
-
-guint gncal_day_view_get_type (void);
-GtkWidget *gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper);
-
-void gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags);
-void gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper);
-
-void gncal_day_view_set_shadow (GncalDayView *dview, GtkShadowType shadow_type);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c
deleted file mode 100644
index c07d9a5710..0000000000
--- a/calendar/gui/gncal-full-day.c
+++ /dev/null
@@ -1,2287 +0,0 @@
-/* Full day widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-#include <config.h>
-#include <string.h>
-#include <gdk/gdkkeysyms.h>
-#include <gnome.h>
-#include "eventedit.h"
-#include "gncal-full-day.h"
-#include "view-utils.h"
-#include "layout.h"
-#include "main.h"
-#include "popup-menu.h"
-
-/* Images */
-#include "bell.xpm"
-#include "recur.xpm"
-
-#define TEXT_BORDER 2
-#define HANDLE_SIZE 8
-#define MIN_WIDTH 200
-#define XOR_RECT_WIDTH 2
-#define UNSELECT_TIMEOUT 0 /* ms */
-
-/* Size of the pixmaps */
-#define DECOR_WIDTH 16
-#define DECOR_HEIGHT 16
-
-typedef struct {
- iCalObject *ico;
- GtkWidget *widget;
- GdkWindow *window;
- GdkWindow *decor_window;
- guint focus_out_id;
- int lower_row; /* zero is first displayed row */
- int rows_used;
- int x; /* coords of child's window */
- int y;
- int width;
- int height;
- int decor_width;
- int decor_height;
- int items; /* number of decoration bitmaps */
- time_t start, end;
-} Child;
-
-struct drag_info {
- enum {
- DRAG_NONE,
- DRAG_SELECT, /* selecting a range in the main window */
- DRAG_MOVE, /* moving a child */
- DRAG_SIZE_TOP, /* resizing a child */
- DRAG_SIZE_BOTTOM
- } drag_mode;
-
- Child *child;
- int child_click_y;
- int child_start_row;
- int child_rows_used;
-
- int sel_click_row;
- int sel_start_row;
- int sel_rows_used;
- guint32 click_time;
-};
-
-
-enum {
- RANGE_ACTIVATED,
- LAST_SIGNAL
-};
-
-
-static void gncal_full_day_class_init (GncalFullDayClass *class);
-static void gncal_full_day_init (GncalFullDay *fullday);
-static void gncal_full_day_destroy (GtkObject *object);
-static void gncal_full_day_map (GtkWidget *widget);
-static void gncal_full_day_unmap (GtkWidget *widget);
-static void gncal_full_day_realize (GtkWidget *widget);
-static void gncal_full_day_unrealize (GtkWidget *widget);
-static void gncal_full_day_draw (GtkWidget *widget,
- GdkRectangle *area);
-static void gncal_full_day_draw_focus (GtkWidget *widget);
-static void gncal_full_day_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void gncal_full_day_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gint gncal_full_day_button_press (GtkWidget *widget,
- GdkEventButton *event);
-static gint gncal_full_day_button_release (GtkWidget *widget,
- GdkEventButton *event);
-static gint gncal_full_day_motion (GtkWidget *widget,
- GdkEventMotion *event);
-static gint gncal_full_day_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static gint gncal_full_day_key_press (GtkWidget *widget,
- GdkEventKey *event);
-static gint gncal_full_day_focus_in (GtkWidget *widget,
- GdkEventFocus *event);
-static gint gncal_full_day_focus_out (GtkWidget *widget,
- GdkEventFocus *event);
-static void gncal_full_day_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-
-static void range_activated (GncalFullDay *fullday);
-
-static GtkContainerClass *parent_class;
-
-static int fullday_signals[LAST_SIGNAL] = { 0 };
-
-/* The little images */
-static GdkPixmap *pixmap_bell, *pixmap_recur;
-
-static void
-get_tm_range (GncalFullDay *fullday,
- time_t time_lower, time_t time_upper,
- struct tm *lower, struct tm *upper,
- int *lower_row, int *rows_used)
-{
- struct tm tm_lower, tm_upper;
- int lmin, umin;
- int lrow;
-
- /* Lower */
-
- tm_lower = *localtime (&time_lower);
-
- if ((tm_lower.tm_min % fullday->interval) != 0) {
- tm_lower.tm_min -= tm_lower.tm_min % fullday->interval; /* round down */
- mktime (&tm_lower);
- }
-
- /* Upper */
-
- tm_upper = *localtime (&time_upper);
-
- if ((tm_upper.tm_min % fullday->interval) != 0) {
- tm_upper.tm_min += fullday->interval - (tm_upper.tm_min % fullday->interval); /* round up */
- mktime (&tm_upper);
- }
-
- if (lower)
- *lower = tm_lower;
-
- if (upper)
- *upper = tm_upper;
-
- lmin = 60 * tm_lower.tm_hour + tm_lower.tm_min;
- umin = 60 * tm_upper.tm_hour + tm_upper.tm_min;
-
- if (umin == 0) /* midnight of next day? */
- umin = 60 * 24;
-
- lrow = lmin / fullday->interval;
-
- if (lower_row)
- *lower_row = lrow;
-
- if (rows_used)
- *rows_used = (umin - lmin) / fullday->interval;
-}
-
-static void
-child_map (GncalFullDay *fullday, Child *child)
-{
- gdk_window_show (child->window);
- if (child->decor_width)
- gdk_window_show (child->decor_window);
- gtk_widget_show (child->widget); /* OK, not just a map... */
-}
-
-static void
-child_unmap (GncalFullDay *fullday, Child *child)
-{
- gdk_window_hide (child->window);
- gdk_window_hide (child->decor_window);
- if (GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_unmap (child->widget);
-}
-
-static void
-child_set_text_pos (Child *child)
-{
- GtkAllocation allocation;
- int has_focus;
- int handle_size;
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- handle_size = (child->ico->recur) ? 0 : HANDLE_SIZE;
-
- allocation.x = handle_size;
- allocation.y = has_focus ? handle_size : 0;
- allocation.width = child->width - handle_size - child->decor_width;
- allocation.height = child->height - (has_focus ? (2 * handle_size) : 0);
-
- gtk_widget_size_request (child->widget, NULL);
- gtk_widget_size_allocate (child->widget, &allocation);
-}
-
-static void
-child_realize (GncalFullDay *fullday, Child *child)
-{
- GdkWindowAttr attributes;
- gint attributes_mask;
- GtkWidget *widget;
- GdkColor c;
-
- widget = GTK_WIDGET (fullday);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = child->x;
- attributes.y = child->y;
- attributes.width = child->width - child->decor_width;;
- attributes.height = child->height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.cursor = fullday->up_down_cursor;
- attributes.event_mask = (GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_KEY_PRESS_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR;
- child->window = gdk_window_new (widget->window, &attributes, attributes_mask);
- gdk_window_set_user_data (child->window, widget);
- gtk_style_set_background (widget->style, child->window, GTK_STATE_NORMAL);
- gtk_widget_set_parent_window (child->widget, child->window);
-
- /* Create the decoration window */
- attributes.x = child->x + child->width - child->decor_width;
- attributes.width = child->decor_width ? child->decor_width : 1;
- attributes.height = child->decor_height ? child->decor_height : 1;
- attributes.visual = gdk_imlib_get_visual ();
- attributes.colormap = gdk_imlib_get_colormap ();
- attributes.event_mask = (GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- child->decor_window = gdk_window_new (widget->window, &attributes, attributes_mask);
- gdk_color_white (gdk_imlib_get_colormap (), &c);
- gdk_window_set_background (child->decor_window, &c);
- gdk_window_set_user_data (child->decor_window, widget);
-
- if (!pixmap_bell){
- GdkImlibImage *imlib_bell, *imlib_recur;
- GdkPixmap *mask;
-
- imlib_bell = gdk_imlib_create_image_from_xpm_data (bell_xpm);
- gdk_imlib_render (imlib_bell, DECOR_WIDTH, DECOR_HEIGHT);
- pixmap_bell = gdk_imlib_move_image (imlib_bell);
- mask = gdk_imlib_move_mask (imlib_bell);
- gdk_imlib_destroy_image (imlib_bell);
- fullday->bell_gc = gdk_gc_new (child->decor_window);
- if (mask)
- gdk_gc_set_clip_mask (fullday->bell_gc, mask);
-
- imlib_recur = gdk_imlib_create_image_from_xpm_data (recur_xpm);
- gdk_imlib_render (imlib_recur, DECOR_WIDTH, DECOR_HEIGHT);
- pixmap_recur = gdk_imlib_move_image (imlib_recur);
- mask = gdk_imlib_move_mask (imlib_recur);
- gdk_imlib_destroy_image (imlib_recur);
- fullday->recur_gc = gdk_gc_new (child->decor_window);
- if (mask)
- gdk_gc_set_clip_mask (fullday->recur_gc, mask);
- }
- child_set_text_pos (child);
-}
-
-static void
-child_unrealize (GncalFullDay *fullday, Child *child)
-{
- if (GTK_WIDGET_REALIZED (child->widget))
- gtk_widget_unrealize (child->widget);
-
- gdk_window_set_user_data (child->window, NULL);
- gdk_window_destroy (child->window);
- child->window = NULL;
-}
-
-static void
-child_draw_decor (GncalFullDay *fullday, Child *child)
-{
- iCalObject *ico = child->ico;
- int ry = 0;
-
- if (ico->recur) {
- gdk_gc_set_clip_origin (fullday->recur_gc, 0, ry);
- gdk_draw_pixmap (child->decor_window,
- fullday->recur_gc,
- pixmap_recur,
- 0, 0,
- 0, ry,
- DECOR_WIDTH, DECOR_HEIGHT);
- ry += DECOR_HEIGHT;
- }
-
- if (ico->dalarm.enabled || ico->malarm.enabled || ico->palarm.enabled || ico->aalarm.enabled) {
- gdk_gc_set_clip_origin (fullday->bell_gc, 0, ry);
- gdk_draw_pixmap (child->decor_window,
- fullday->bell_gc,
- pixmap_bell,
- 0, 0,
- 0, ry,
- DECOR_WIDTH, DECOR_HEIGHT);
- ry += DECOR_HEIGHT;
- }
-}
-
-static void
-child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, GdkWindow *window, int draw_child)
-{
- GdkRectangle arect, rect, dest;
- int has_focus;
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- if (!window || (window == child->window)) {
- if (!area) {
- arect.x = 0;
- arect.y = 0;
- arect.width = child->width;
- arect.height = child->height;
-
- area = &arect;
- }
-
- /* Left handle */
-
- rect.x = 0;
- rect.y = has_focus ? HANDLE_SIZE : 0;
- rect.width = HANDLE_SIZE;
- rect.height = has_focus ? (child->height - 2 * HANDLE_SIZE) : child->height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window, &rect, GTK_SHADOW_OUT);
-
- if (has_focus) {
- /* Top handle */
-
- rect.x = 0;
- rect.y = 0;
- rect.width = child->width - child->decor_width;
- rect.height = HANDLE_SIZE;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window,
- &rect, GTK_SHADOW_OUT);
-
- /* Bottom handle */
-
- rect.y = child->height - HANDLE_SIZE;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window,
- &rect, GTK_SHADOW_OUT);
- }
-
- } else if (!window || (window == child->decor_window)) {
- if (!area) {
- arect.x = 0;
- arect.y = 0;
- arect.width = child->decor_width;
- arect.height = child->decor_height;
-
- area = &arect;
- }
-
- child_draw_decor (fullday, child);
- }
-
- if (draw_child)
- gtk_widget_draw (child->widget, NULL);
-}
-
-static void
-child_range_changed (GncalFullDay *fullday, Child *child)
-{
- struct tm start, end;
- int lower_row, rows_used;
- int f_lower_row;
-
- /* Calc display range for event */
-
- get_tm_range (fullday, child->start, child->end, &start, &end, &lower_row, &rows_used);
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, &f_lower_row, NULL);
-
- child->lower_row = lower_row - f_lower_row;
- child->rows_used = rows_used;
-}
-
-static void
-new_appointment (GtkWidget *widget, gpointer data)
-{
- GncalFullDay *fullday;
- GtkWidget *ee;
- iCalObject *ico;
-
- fullday = GNCAL_FULL_DAY (data);
-
- ico = ical_new ("", user_name, "");
- ico->new = 1;
-
- gncal_full_day_selection_range (fullday, &ico->dtstart, &ico->dtend);
- ee = event_editor_new (fullday->calendar, ico);
- gtk_widget_show (ee);
-}
-
-static void
-edit_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GtkWidget *ee;
-
- child = data;
-
- ee = event_editor_new (GNCAL_FULL_DAY (child->widget->parent)->calendar, child->ico);
- gtk_widget_show (ee);
-}
-
-static void
-delete_occurance (GtkWidget *widget, gpointer data)
-{
- Child *child = data;
- iCalObject *ical;
- time_t *t;
- GnomeCalendar *gcal = GNCAL_FULL_DAY (child->widget->parent)->calendar;
-
- child = data;
- ical = child->ico;
- t = g_new(time_t, 1);
- *t = child->start;
- ical->exdate = g_list_prepend(ical->exdate, t);
- gnome_calendar_object_changed (gcal, child->ico, CHANGE_DATES);
- save_default_calendar (gcal);
-
-}
-
-static void
-delete_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- child = data;
-
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- gnome_calendar_remove_object (fullday->calendar, child->ico);
- save_default_calendar (fullday->calendar);
-}
-
-static void
-unrecur_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
- iCalObject *new;
-
- child = data;
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- /* New object */
- new = ical_object_duplicate (child->ico);
- g_free (new->recur);
- new->recur = 0;
- new->dtstart = child->start;
- new->dtend = child->end;
-
- /* Duplicate, and eliminate the recurrency fields */
- ical_object_add_exdate (child->ico, child->start);
- gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_ALL);
-
- gnome_calendar_add_object (fullday->calendar, new);
- save_default_calendar (fullday->calendar);
-}
-
-static void
-child_popup_menu (GncalFullDay *fullday, Child *child, GdkEventButton *event)
-{
- int sensitive, items;
- struct menu_item *context_menu;
-
- static struct menu_item child_items[] = {
- { N_("Edit this appointment..."), (GtkSignalFunc) edit_appointment, NULL, TRUE },
- { N_("Delete this appointment"), (GtkSignalFunc) delete_appointment, NULL, TRUE },
- { NULL, NULL, NULL, TRUE },
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- static struct menu_item recur_child_items[] = {
- { N_("Make this appointment movable"), (GtkSignalFunc) unrecur_appointment, NULL, TRUE },
- { N_("Edit this appointment..."), (GtkSignalFunc) edit_appointment, NULL, TRUE },
- { N_("Delete this occurance"), (GtkSignalFunc) delete_occurance, NULL, TRUE },
- { N_("Delete all occurances"), (GtkSignalFunc) delete_appointment, NULL, TRUE },
- { NULL, NULL, NULL, TRUE },
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- sensitive = (child->ico->user_data == NULL);
-
- if (child->ico->recur){
- items = 6;
- context_menu = &recur_child_items[0];
- context_menu[2].data = child;
- context_menu[3].data = child;
- context_menu[3].sensitive = sensitive;
- context_menu[4].data = fullday;
- context_menu[5].data = fullday;
- } else {
- items = 4;
- context_menu = &child_items[0];
- context_menu[3].data = fullday;
- }
- /* These settings are common for each context sensitive menu */
- context_menu[0].data = child;
- context_menu[1].data = child;
- context_menu[0].sensitive = sensitive;
- context_menu[1].sensitive = sensitive;
- context_menu[2].sensitive = sensitive;
-
- popup_menu (context_menu, items, event);
-}
-
-static void
-child_realized_setup (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- child = data;
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gdk_window_set_cursor (widget->window, fullday->beam_cursor);
-}
-
-static void
-child_set_pos (GncalFullDay *fullday, Child *child, int x, int y, int width, int height)
-{
- const int decor_width = child->decor_width;
-
- child->x = x;
- child->y = y;
- child->width = width;
- child->height = height;
-
- if (!child->window) /* realized? */
- return;
-
- child_set_text_pos (child);
- gdk_window_move_resize (child->window, x, y, width - decor_width, height);
-
- if (decor_width){
- gdk_window_move_resize (child->decor_window, x + width - decor_width, y,
- decor_width, child->decor_height);
- }
-}
-
-static int
-calc_row_height (GncalFullDay *fullday)
-{
- int f_rows;
- GtkWidget *widget;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- widget = GTK_WIDGET (fullday);
-
- return (widget->allocation.height - 2 * widget->style->klass->ythickness) / f_rows;
-}
-
-static void
-child_set_size (Child *child)
-{
- int row_height;
- int x, y, width, height;
- GncalFullDay *fullday;
-
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- row_height = calc_row_height (fullday);
-
- x = child->x;
- y = child->lower_row * row_height + GTK_WIDGET (fullday)->style->klass->ythickness;
- width = child->width;
- height = child->rows_used * row_height;
-
- if (GTK_WIDGET_HAS_FOCUS (child->widget) && !child->ico->recur) {
- y -= HANDLE_SIZE;
- height += 2 * HANDLE_SIZE;
- }
-
- child_set_pos (fullday, child, x, y, width, height);
-}
-
-static gint
-child_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- child_set_size (data);
- return FALSE;
-}
-
-static gint
-child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
- char *text;
-
- child = data;
-
- child_set_size (child);
-
- /* Update summary in calendar object */
-
- text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
- if (child->ico->summary && strcmp (text, child->ico->summary) == 0)
- return FALSE;
-
- if (child->ico->summary)
- g_free (child->ico->summary);
-
- child->ico->summary = text;
-
- /* Notify calendar of change */
-
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_SUMMARY);
- save_default_calendar (fullday->calendar);
-
- return FALSE;
-}
-
-static gint
-child_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data)
-{
- if (event->keyval != GDK_Escape)
- return FALSE;
-
- /* If user pressed Esc, un-focus the child by focusing the fullday widget */
-
- gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
- gtk_widget_grab_focus (widget->parent);
-
- return FALSE;
-}
-
-static gint
-child_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- if (event->button != 3)
- return FALSE;
-
- child = data;
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "button_press_event");
- gtk_widget_grab_focus (widget);
- child_popup_menu (fullday, child, event);
-
- return TRUE;
-}
-
-/*
- * compute the space required to display the decorations
- */
-static void
-child_compute_decor (Child *child)
-{
- iCalObject *ico = child->ico;
- int rows_used;
-
- child->items = 0;
- rows_used = (child->rows_used < 1) ? 1 : child->rows_used;
- if (ico->recur)
- child->items++;
- if (ico->dalarm.enabled || ico->aalarm.enabled || ico->palarm.enabled || ico->malarm.enabled)
- child->items++;
-
- if (child->items > rows_used){
- child->decor_width = DECOR_WIDTH * 2;
- child->decor_height = DECOR_HEIGHT;
- } else {
- child->decor_width = DECOR_WIDTH * (child->items ? 1 : 0);
- child->decor_height = DECOR_HEIGHT * child->items;
- }
-}
-
-static Child *
-child_new (GncalFullDay *fullday, time_t start, time_t end, iCalObject *ico)
-{
- Child *child;
-
- child = g_new (Child, 1);
-
- child->ico = ico;
- child->widget = gtk_text_new (NULL, NULL);
- child->window = NULL;
- child->x = 0;
- child->y = 0;
- child->width = 0;
- child->height = 0;
- child->start = start;
- child->end = end;
- child_range_changed (fullday, child);
- child_compute_decor (child);
-
- if (ico->summary)
- gtk_text_insert (GTK_TEXT (child->widget), NULL, NULL, NULL,
- ico->summary,
- strlen (ico->summary));
-
- /* We set the i-beam cursor of the text widget upon realization */
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "realize",
- (GtkSignalFunc) child_realized_setup,
- child);
-
- gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_in_event",
- (GtkSignalFunc) child_focus_in,
- child);
-
- child->focus_out_id = gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_out_event",
- (GtkSignalFunc) child_focus_out,
- child);
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "key_press_event",
- (GtkSignalFunc) child_key_press,
- child);
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "button_press_event",
- (GtkSignalFunc) child_button_press,
- child);
-
- /* Finish setup */
-
- gtk_text_set_editable (GTK_TEXT (child->widget), TRUE);
- gtk_text_set_word_wrap (GTK_TEXT (child->widget), TRUE);
-
- gtk_widget_set_parent (child->widget, GTK_WIDGET (fullday));
-
- return child;
-}
-
-static void
-squick (GtkWidget *widget, gpointer data)
-{
-}
-
-static void
-child_destroy (GncalFullDay *fullday, Child *child)
-{
- /* Disconnect the focus_out_event signal since we will get such an event
- * from the destroy call.
- */
- gtk_signal_disconnect (GTK_OBJECT (child->widget), child->focus_out_id);
-
- if (GTK_WIDGET_MAPPED (fullday))
- child_unmap (fullday, child);
-
- if (GTK_WIDGET_REALIZED (fullday))
- child_unrealize (fullday, child);
-
- /* Unparent the child widget manually as we don't have a remove method */
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "destroy",
- (GtkSignalFunc) squick,
- NULL);
-
- gtk_widget_unparent (child->widget);
- g_free (child);
-}
-
-static int
-calc_labels_width (GncalFullDay *fullday)
-{
- struct tm cur, upper;
- time_t tim, time_upper;
- int width, max_w;
- char buf[40];
-
- get_tm_range (fullday, fullday->lower, fullday->upper, &cur, &upper, NULL, NULL);
-
- max_w = 0;
-
- tim = mktime (&cur);
- time_upper = mktime (&upper);
-
- while (tim < time_upper) {
- if (am_pm_flag)
- strftime (buf, sizeof (buf), "%I:%M%p", &cur);
- else
- strftime (buf, sizeof (buf), "%H:%M", &cur);
-
-
- width = gdk_string_width (GTK_WIDGET (fullday)->style->font, buf);
-
- if (width > max_w)
- max_w = width;
-
- cur.tm_min += fullday->interval;
- tim = mktime (&cur);
- }
-
- return max_w;
-}
-
-/* Used with layout_events(), takes in a list element and returns the start and end times for the
- * event corresponding to that element.
- */
-static void
-child_layout_query_func (GList *event, time_t *start, time_t *end)
-{
- Child *child;
-
- child = event->data;
-
- *start = child->start;
- *end = child->end;
-}
-
-/* Takes the list of children in the full day view and lays them out nicely without overlapping.
- * Basically it calls the layout_events() function in layout.c and resizes the fullday's children.
- */
-static void
-layout_children (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- GList *children;
- Child *child;
- int num_slots;
- int *allocations;
- int *slots;
- int left_x;
- int usable_pixels, pixels_per_col, extra_pixels;
- int i;
-
- if (!fullday->children)
- return;
-
- layout_events (fullday->children, child_layout_query_func, &num_slots, &allocations, &slots);
-
- /* Set the size and position of each child */
-
- widget = GTK_WIDGET (fullday);
- left_x = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + calc_labels_width (fullday);
-
- usable_pixels = widget->allocation.width - left_x - widget->style->klass->xthickness;
- pixels_per_col = usable_pixels / num_slots;
- extra_pixels = usable_pixels % num_slots;
-
- for (children = fullday->children, i = 0; children; children = children->next, i++) {
- child = children->data;
-
- child->x = left_x + pixels_per_col * allocations[i];
- child->width = pixels_per_col * slots[i];
-
- if ((allocations[i] + slots[i]) == num_slots)
- child->width += extra_pixels;
-
- child_set_size (child);
- }
-
- g_free (allocations);
- g_free (slots);
-}
-
-guint
-gncal_full_day_get_type (void)
-{
- static guint full_day_type = 0;
-
- if (!full_day_type) {
- GtkTypeInfo full_day_info = {
- "GncalFullDay",
- sizeof (GncalFullDay),
- sizeof (GncalFullDayClass),
- (GtkClassInitFunc) gncal_full_day_class_init,
- (GtkObjectInitFunc) gncal_full_day_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- full_day_type = gtk_type_unique (gtk_container_get_type (), &full_day_info);
- }
-
- return full_day_type;
-}
-
-static void
-gncal_full_day_class_init (GncalFullDayClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- container_class = (GtkContainerClass *) class;
-
- parent_class = gtk_type_class (gtk_container_get_type ());
-
- fullday_signals[RANGE_ACTIVATED] =
- gtk_signal_new ("range_activated",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (GncalFullDayClass, range_activated),
- gtk_signal_default_marshaller,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, fullday_signals, LAST_SIGNAL);
-
- object_class->destroy = gncal_full_day_destroy;
-
- widget_class->map = gncal_full_day_map;
- widget_class->unmap = gncal_full_day_unmap;
- widget_class->realize = gncal_full_day_realize;
- widget_class->unrealize = gncal_full_day_unrealize;
- widget_class->draw = gncal_full_day_draw;
- widget_class->draw_focus = gncal_full_day_draw_focus;
- widget_class->size_request = gncal_full_day_size_request;
- widget_class->size_allocate = gncal_full_day_size_allocate;
- widget_class->button_press_event = gncal_full_day_button_press;
- widget_class->button_release_event = gncal_full_day_button_release;
- widget_class->motion_notify_event = gncal_full_day_motion;
- widget_class->expose_event = gncal_full_day_expose;
- widget_class->key_press_event = gncal_full_day_key_press;
- widget_class->focus_in_event = gncal_full_day_focus_in;
- widget_class->focus_out_event = gncal_full_day_focus_out;
-
- container_class->forall = gncal_full_day_forall;
-
- class->range_activated = range_activated;
-}
-
-static void
-gncal_full_day_init (GncalFullDay *fullday)
-{
- GTK_WIDGET_UNSET_FLAGS (fullday, GTK_NO_WINDOW);
- GTK_WIDGET_SET_FLAGS (fullday, GTK_CAN_FOCUS);
-
- fullday->calendar = NULL;
-
- fullday->lower = 0;
- fullday->upper = 0;
- fullday->interval = 30; /* 30 minutes by default */
-
- fullday->children = NULL;
- fullday->drag_info = g_new0 (struct drag_info, 1);
-
- fullday->up_down_cursor = NULL;
- fullday->beam_cursor = NULL;
- fullday->recur_gc = NULL;
- fullday->bell_gc = NULL;
-}
-
-/* Destroys all the children in the full day widget */
-static void
-destroy_children (GncalFullDay *fullday)
-{
- GList *children;
-
- for (children = fullday->children; children; children = children->next)
- child_destroy (fullday, children->data);
-
- g_list_free (fullday->children);
- fullday->children = NULL;
-}
-
-static void
-gncal_full_day_destroy (GtkObject *object)
-{
- GncalFullDay *fullday;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (object));
-
- fullday = GNCAL_FULL_DAY (object);
-
- destroy_children (fullday);
-
- g_free (fullday->drag_info);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-GtkWidget *
-gncal_full_day_new (GnomeCalendar *calendar, time_t lower, time_t upper)
-{
- GncalFullDay *fullday;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- fullday = gtk_type_new (gncal_full_day_get_type ());
-
- fullday->calendar = calendar;
-
- gncal_full_day_set_bounds (fullday, lower, upper);
-
- return GTK_WIDGET (fullday);
-}
-
-static void
-gncal_full_day_map (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- gdk_window_show (widget->window);
-
- for (children = fullday->children; children; children = children->next)
- child_map (fullday, children->data);
-}
-
-static void
-gncal_full_day_unmap (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- gdk_window_hide (widget->window);
-
- for (children = fullday->children; children; children = children->next)
- child_unmap (fullday, children->data);
-}
-
-static void
-gncal_full_day_realize (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GdkWindowAttr attributes;
- gint attributes_mask;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = (gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gdk_window_set_background (widget->window, &widget->style->bg[GTK_STATE_PRELIGHT]);
-
- fullday->up_down_cursor = gdk_cursor_new (GDK_DOUBLE_ARROW);
- fullday->beam_cursor = gdk_cursor_new (GDK_XTERM);
-
- for (children = fullday->children; children; children = children->next)
- child_realize (fullday, children->data);
-
-}
-
-static void
-gncal_full_day_unrealize (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- fullday = GNCAL_FULL_DAY (widget);
-
- for (children = fullday->children; children; children = children->next)
- child_unrealize (fullday, children->data);
-
- gdk_cursor_destroy (fullday->up_down_cursor);
- fullday->up_down_cursor = NULL;
-
- gdk_cursor_destroy (fullday->beam_cursor);
- fullday->beam_cursor = NULL;
-
- if (fullday->bell_gc)
- gdk_gc_destroy (fullday->bell_gc);
- if (fullday->recur_gc)
- gdk_gc_destroy (fullday->recur_gc);
-
- if (pixmap_bell){
- gdk_pixmap_unref (pixmap_bell);
- pixmap_bell = NULL;
- }
-
- if (pixmap_recur){
- gdk_pixmap_unref (pixmap_recur);
- pixmap_recur = NULL;
- }
-
- if (GTK_WIDGET_CLASS (parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
-}
-
-struct paint_info {
- GtkWidget *widget;
- struct drag_info *di;
- GdkRectangle *area;
- int x1, y1, width, height;
- int labels_width;
- int row_height;
- struct tm start_tm;
-};
-
-static void
-paint_row (GncalFullDay *fullday, int row, struct paint_info *p)
-{
- GdkRectangle rect, dest;
- GdkGC *left_gc, *right_gc, *text_gc;
- int begin_row, end_row;
- struct tm tm;
- char buf[40];
-
- begin_row = (day_begin * 60) / fullday->interval;
- end_row = (day_end * 60) / fullday->interval;
-
- /* See which GCs we will use */
-
- if ((p->di->sel_rows_used != 0)
- && (row >= p->di->sel_start_row)
- && (row < (p->di->sel_start_row + p->di->sel_rows_used))) {
- left_gc = p->widget->style->bg_gc[GTK_STATE_SELECTED];
- right_gc = left_gc;
- text_gc = p->widget->style->fg_gc[GTK_STATE_SELECTED];
- } else if ((row < begin_row) || (row >= end_row)) {
- left_gc = p->widget->style->bg_gc[GTK_STATE_NORMAL];
- right_gc = p->widget->style->bg_gc[GTK_STATE_ACTIVE];
- text_gc = p->widget->style->fg_gc[GTK_STATE_NORMAL];
- } else {
- left_gc = p->widget->style->bg_gc[GTK_STATE_NORMAL];
- right_gc = p->widget->style->bg_gc[GTK_STATE_PRELIGHT];
- text_gc = p->widget->style->fg_gc[GTK_STATE_NORMAL];
- }
-
- /* Left background and text */
-
- rect.x = p->x1;
- rect.y = p->y1 + row * p->row_height;
- rect.width = 2 * TEXT_BORDER + p->labels_width;
- rect.height = p->row_height - 1;
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest)) {
- gdk_draw_rectangle (p->widget->window,
- left_gc,
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- tm = p->start_tm;
- tm.tm_min += row * fullday->interval;
- mktime (&tm);
-
- if (am_pm_flag)
- strftime (buf, sizeof (buf), "%I:%M%p", &tm);
- else
- strftime (buf, sizeof (buf), "%H:%M", &tm);
-
- gdk_draw_string (p->widget->window,
- p->widget->style->font,
- text_gc,
- rect.x + TEXT_BORDER,
- rect.y + TEXT_BORDER + p->widget->style->font->ascent,
- buf);
- }
-
- /* Right background */
-
- rect.x += rect.width + p->widget->style->klass->xthickness;
- rect.width = p->width - (rect.x - p->x1);
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest))
- gdk_draw_rectangle (p->widget->window,
- right_gc,
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- /* Horizontal division at bottom of row */
-
- rect.x = p->x1;
- rect.y += rect.height;
- rect.width = p->width;
- rect.height = 1;
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest))
- gdk_draw_line (p->widget->window,
- p->widget->style->black_gc,
- rect.x, rect.y,
- rect.x + rect.width - 1, rect.y);
-}
-
-static void
-paint_back (GncalFullDay *fullday, GdkRectangle *area)
-{
- struct paint_info p;
- int start_row, end_row;
- int i;
- GdkRectangle rect, dest, aarea;
- int f_rows;
- int draw_focus;
-
- p.widget = GTK_WIDGET (fullday);
- p.di = fullday->drag_info;
-
- if (!area) {
- area = &aarea;
-
- area->x = 0;
- area->y = 0;
- area->width = p.widget->allocation.width;
- area->height = p.widget->allocation.height;
- }
- p.area = area;
-
- p.x1 = p.widget->style->klass->xthickness;
- p.y1 = p.widget->style->klass->ythickness;
- p.width = p.widget->allocation.width - 2 * p.x1;
- p.height = p.widget->allocation.height - 2 * p.y1;
-
- p.labels_width = calc_labels_width (fullday);
- p.row_height = calc_row_height (fullday);
- get_tm_range (fullday, fullday->lower, fullday->upper, &p.start_tm, NULL, NULL, &f_rows);
-
- /* Frame shadow */
-
- rect.x = 0;
- rect.y = 0;
- rect.width = p.widget->allocation.width;
- rect.height = p.widget->style->klass->ythickness;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
-
- if (!draw_focus) {
- rect.y = p.widget->allocation.height - rect.height;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (!draw_focus) {
- rect.y = p.widget->style->klass->ythickness;
- rect.width = p.widget->style->klass->xthickness;
- rect.height = p.widget->allocation.height - 2 * rect.y;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (!draw_focus) {
- rect.x = p.widget->allocation.width - rect.width;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (draw_focus)
- gtk_widget_draw_focus (p.widget);
-
- /* Rows */
-
- start_row = (area->y - p.y1) / p.row_height;
- end_row = (area->y + area->height - 1 - p.y1) / p.row_height;
-
- if (end_row >= f_rows)
- end_row = f_rows - 1;
-
- for (i = start_row; i <= end_row; i++)
- paint_row (fullday, i, &p);
-
- /* Slack area at bottom of widget */
-
- rect.x = p.x1;
- rect.y = p.y1 + f_rows * p.row_height;
- rect.width = p.width;
- rect.height = p.height - (rect.y - p.y1);
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- gdk_draw_rectangle (p.widget->window,
- p.widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- /* Vertical division */
-
- rect.x = p.x1 + 2 * TEXT_BORDER + p.labels_width;
- rect.y = p.y1;
- rect.width = p.widget->style->klass->xthickness;
- rect.height = p.height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- gtk_draw_vline (p.widget->style, p.widget->window,
- GTK_STATE_NORMAL,
- rect.y,
- rect.y + rect.height - 1,
- rect.x);
-}
-
-static void
-paint_back_rows (GncalFullDay *fullday, int start_row, int rows_used)
-{
- int row_height;
- int xthickness, ythickness;
- GtkWidget *widget;
- GdkRectangle area;
-
- widget = GTK_WIDGET (fullday);
-
- row_height = calc_row_height (fullday);
-
- xthickness = widget->style->klass->xthickness;
- ythickness = widget->style->klass->ythickness;
-
- area.x = xthickness;
- area.y = ythickness + start_row * row_height;
- area.width = widget->allocation.width - 2 * xthickness;
- area.height = rows_used * row_height;
-
- paint_back (fullday, &area);
-}
-
-static void
-gncal_full_day_draw (GtkWidget *widget, GdkRectangle *area)
-{
- GncalFullDay *fullday;
- GList *children;
- Child *child;
- GdkRectangle rect, dest;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (area != NULL);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- paint_back (fullday, area);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- rect.x = child->x;
- rect.y = child->y;
- rect.width = child->width;
- rect.height = child->height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest)) {
- child_draw (fullday, child, NULL, NULL, TRUE);
- }
- }
-}
-
-static void
-gncal_full_day_draw_focus (GtkWidget *widget)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return;
-
- gtk_draw_shadow (widget->style, widget->window,
- GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
-
- if (GTK_WIDGET_HAS_FOCUS (widget))
- gdk_draw_rectangle (widget->window,
- widget->style->black_gc,
- FALSE,
- 0, 0,
- widget->allocation.width - 1,
- widget->allocation.height - 1);
-}
-
-static void
-gncal_full_day_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- GncalFullDay *fullday;
- int labels_width;
- int rows;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (requisition != NULL);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- /* Border and min width */
-
- labels_width = calc_labels_width (fullday);
-
- requisition->width = 2 * widget->style->klass->xthickness + 4 * TEXT_BORDER + labels_width + MIN_WIDTH;
- requisition->height = 2 * widget->style->klass->ythickness;
-
- /* Rows */
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &rows);
-
- requisition->height += (rows * (2 * TEXT_BORDER + widget->style->font->ascent + widget->style->font->descent)
- + (rows - 1)); /* division lines */
-}
-
-static void
-gncal_full_day_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- GncalFullDay *fullday;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (allocation != NULL);
-
- widget->allocation = *allocation;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- if (GTK_WIDGET_REALIZED (widget))
- gdk_window_move_resize (widget->window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
-
- layout_children (fullday);
-}
-
-static Child *
-find_child_by_window (GncalFullDay *fullday, GdkWindow *window, int *on_text)
-{
- GList *children;
- Child *child;
- GtkWidget *owner;
-
- *on_text = FALSE;
-
- gdk_window_get_user_data (window, (gpointer *) &owner);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->window == window || child->decor_window == window)
- return child;
-
- if (child->widget == owner) {
- *on_text = TRUE;
- return child;
- }
- }
-
- return NULL;
-}
-
-static void
-draw_xor_rect (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- struct drag_info *di;
- int i;
- int row_height;
- int ythickness;
-
- widget = GTK_WIDGET (fullday);
-
- gdk_gc_set_function (widget->style->white_gc, GDK_INVERT);
- gdk_gc_set_subwindow (widget->style->white_gc, GDK_INCLUDE_INFERIORS);
-
- ythickness = widget->style->klass->ythickness;
-
- di = fullday->drag_info;
-
- row_height = calc_row_height (fullday);
-
- for (i = 0; i < XOR_RECT_WIDTH; i++)
- gdk_draw_rectangle (widget->window,
- widget->style->white_gc,
- FALSE,
- di->child->x + i,
- di->child_start_row * row_height + ythickness + i,
- di->child->width - 2 * i - 1,
- di->child_rows_used * row_height - 2 - 2 * i);
-
- gdk_gc_set_function (widget->style->white_gc, GDK_COPY);
- gdk_gc_set_subwindow (widget->style->white_gc, GDK_CLIP_BY_CHILDREN);
-}
-
-static int
-get_row_from_y (GncalFullDay *fullday, int y, int round)
-{
- GtkWidget *widget;
- int row_height;
- int f_rows;
- int ythickness;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- row_height = calc_row_height (fullday);
-
- widget = GTK_WIDGET (fullday);
-
- ythickness = widget->style->klass->ythickness;
-
- y -= ythickness;
-
- if (y < 0)
- y = 0;
- else if (y >= (f_rows * row_height))
- y = f_rows * row_height - 1;
-
- if (round)
- y += row_height / 2;
-
- y /= row_height;
-
- if (y > f_rows)
- y = f_rows; /* note that this is 1 more than the last row's index */
-
- return y;
-}
-
-static int
-button_1 (GncalFullDay *fullday, GdkEventButton *event)
-{
- GtkWidget *widget;
- Child *child;
- int on_text;
- struct drag_info *di;
- gint y;
- int row_height;
- int has_focus;
- int old_start_row, old_rows_used;
- int old_max;
- int paint_start_row, paint_rows_used;
-
- widget = GTK_WIDGET (fullday);
-
- if (event->window == widget->window) {
- /* Clicked on main window */
-
- if (!GTK_WIDGET_HAS_FOCUS (widget))
- gtk_widget_grab_focus (widget);
-
- /* Prepare for drag */
-
- di = fullday->drag_info;
-
- di->drag_mode = DRAG_SELECT;
-
- old_start_row = di->sel_start_row;
- old_rows_used = di->sel_rows_used;
-
- di->sel_click_row = get_row_from_y (fullday, event->y, FALSE);
- di->sel_start_row = di->sel_click_row;
- di->sel_rows_used = 1;
-
- di->click_time = event->time;
-
- gdk_pointer_grab (widget->window, FALSE,
- (GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_BUTTON_RELEASE_MASK),
- NULL,
- fullday->up_down_cursor,
- event->time);
-
- if (old_rows_used == 0) {
- paint_start_row = di->sel_start_row;
- paint_rows_used = di->sel_rows_used;
- } else {
- paint_start_row = MIN (old_start_row, di->sel_start_row);
- old_max = old_start_row + old_rows_used - 1;
- paint_rows_used = MAX (old_max, di->sel_start_row) - paint_start_row + 1;
- }
-
- paint_back_rows (fullday, paint_start_row, paint_rows_used);
-
- return TRUE;
- } else {
- /* Clicked on a child? */
-
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (!child || on_text || child->ico->recur)
- return FALSE;
-
- /* Prepare for drag */
-
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- if (has_focus) {
- if (event->y < HANDLE_SIZE)
- di->drag_mode = DRAG_SIZE_TOP;
- else if (event->y >= (child->height - HANDLE_SIZE))
- di->drag_mode = DRAG_SIZE_BOTTOM;
- else
- di->drag_mode = DRAG_MOVE;
- } else
- di->drag_mode = DRAG_MOVE;
-
- row_height = calc_row_height (fullday);
-
- di->child = child;
-
- di->child_click_y = event->y;
- di->child_start_row = child->lower_row;
- di->child_rows_used = child->rows_used;
-
- gdk_pointer_grab (child->window, FALSE,
- (GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_BUTTON_RELEASE_MASK),
- NULL,
- fullday->up_down_cursor,
- event->time);
-
- draw_xor_rect (fullday);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static int
-button_3 (GncalFullDay *fullday, GdkEventButton *event)
-{
- static struct menu_item main_items[] = {
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- GtkWidget *widget;
- Child *child;
- int on_text;
-
- widget = GTK_WIDGET (fullday);
-
- if (event->window == widget->window) {
- /* Clicked on main window */
-
- if (!GTK_WIDGET_HAS_FOCUS (widget))
- gtk_widget_grab_focus (widget);
-
- main_items[0].data = fullday;
-
- popup_menu (main_items, sizeof (main_items) / sizeof (main_items[0]), event);
-
- return TRUE;
- } else {
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (!child || on_text)
- return FALSE;
-
- child_popup_menu (fullday, child, event);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- GncalFullDay *fullday;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- switch (event->button) {
- case 1:
- return button_1 (fullday, event);
-
- case 3:
- return button_3 (fullday, event);
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-static void
-recompute_motion (GncalFullDay *fullday, int y)
-{
- struct drag_info *di;
- int f_rows;
- int row;
- int has_focus;
-
- di = fullday->drag_info;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- switch (di->drag_mode) {
- case DRAG_SELECT:
- row = get_row_from_y (fullday, y, FALSE);
-
- if (row >= f_rows)
- row = f_rows - 1;
-
- if (row < di->sel_click_row) {
- di->sel_start_row = row;
- di->sel_rows_used = di->sel_click_row - row + 1;
- } else {
- di->sel_start_row = di->sel_click_row;
- di->sel_rows_used = row - di->sel_start_row + 1;
- }
-
- break;
-
- case DRAG_MOVE:
- has_focus = GTK_WIDGET_HAS_FOCUS (di->child->widget);
-
- if (has_focus)
- child_focus_out (di->child->widget, NULL, di->child);
-
- row = get_row_from_y (fullday, y - di->child_click_y + (has_focus ? HANDLE_SIZE : 0), TRUE);
-
- if (row > (f_rows - di->child_rows_used))
- row = f_rows - di->child_rows_used;
-
- di->child_start_row = row;
-
- break;
-
- case DRAG_SIZE_TOP:
- has_focus = GTK_WIDGET_HAS_FOCUS (di->child->widget);
-
- if (has_focus)
- child_focus_out (di->child->widget, NULL, di->child);
-
- row = get_row_from_y (fullday, y + HANDLE_SIZE, TRUE);
-
- if (row > (di->child_start_row + di->child_rows_used - 1))
- row = di->child_start_row + di->child_rows_used - 1;
-
- di->child_rows_used = (di->child_start_row + di->child_rows_used) - row;
- di->child_start_row = row;
-
- break;
-
- case DRAG_SIZE_BOTTOM:
- has_focus = GTK_WIDGET_HAS_FOCUS (di->child->widget);
-
- if (has_focus)
- child_focus_out (di->child->widget, NULL, di->child);
-
- row = get_row_from_y (fullday, y - HANDLE_SIZE, TRUE);
-
- if (row <= di->child_start_row)
- row = di->child_start_row + 1;
- else if (row > f_rows)
- row = f_rows;
-
- di->child_rows_used = row - di->child_start_row;
-
- break;
-
- default:
- g_assert_not_reached ();
- }
-}
-
-static void
-get_time_from_rows (GncalFullDay *fullday, int start_row, int rows_used, time_t *t_lower, time_t *t_upper)
-{
- struct tm tm;
- int row_height;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, NULL);
-
- row_height = calc_row_height (fullday);
-
- tm.tm_min += fullday->interval * start_row;
- *t_lower = mktime (&tm);
-
- tm.tm_min += fullday->interval * rows_used;
- *t_upper = mktime (&tm);
-}
-
-static void
-update_from_drag_info (GncalFullDay *fullday)
-{
- struct drag_info *di;
- GtkWidget *widget;
-
- di = fullday->drag_info;
-
- widget = GTK_WIDGET (fullday);
-
- get_time_from_rows (fullday, di->child_start_row, di->child_rows_used,
- &di->child->ico->dtstart,
- &di->child->ico->dtend);
-
- child_range_changed (fullday, di->child);
-
- /* Notify calendar of change */
-
- gnome_calendar_object_changed (fullday->calendar, di->child->ico, CHANGE_DATES);
- save_default_calendar (fullday->calendar);
-}
-
-static gint
-gncal_full_day_button_release (GtkWidget *widget, GdkEventButton *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- gint y;
- int retval;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- retval = FALSE;
-
- switch (di->drag_mode) {
- case DRAG_NONE:
- break;
-
- case DRAG_SELECT:
- if ((event->time - di->click_time) < UNSELECT_TIMEOUT)
- di->sel_rows_used = 0;
- else
- recompute_motion (fullday, y);
-
- gdk_pointer_ungrab (event->time);
-
- paint_back_rows (fullday, di->sel_start_row, MAX (di->sel_rows_used, 1));
-
- retval = TRUE;
- break;
-
- case DRAG_MOVE:
- case DRAG_SIZE_TOP:
- case DRAG_SIZE_BOTTOM:
- draw_xor_rect (fullday);
- recompute_motion (fullday, y);
- gdk_pointer_ungrab (event->time);
-
- update_from_drag_info (fullday);
-
- di->child_rows_used = 0;
-
- retval = TRUE;
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- di->drag_mode = DRAG_NONE;
- di->child = NULL;
-
- return retval;
-}
-
-static gint
-gncal_full_day_motion (GtkWidget *widget, GdkEventMotion *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- gint y;
- int old_min, old_max;
- int new_min, new_max;
- int new_start_row, new_rows_used;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- switch (di->drag_mode) {
- case DRAG_NONE:
- break;
-
- case DRAG_SELECT:
- old_min = di->sel_start_row;
- old_max = di->sel_start_row + di->sel_rows_used - 1;
-
- recompute_motion (fullday, y);
-
- new_min = di->sel_start_row;
- new_max = di->sel_start_row + di->sel_rows_used - 1;
-
- new_start_row = MIN (old_min, new_min);
- new_rows_used = MAX (old_max, new_max) - new_start_row + 1;
-
- paint_back_rows (fullday, new_start_row, new_rows_used);
-
- return TRUE;
-
- case DRAG_MOVE:
- case DRAG_SIZE_TOP:
- case DRAG_SIZE_BOTTOM:
- draw_xor_rect (fullday);
- recompute_motion (fullday, y);
- draw_xor_rect (fullday);
-
- return TRUE;
-
- default:
- g_assert_not_reached ();
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- GncalFullDay *fullday;
- Child *child;
- int on_text;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return FALSE;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- if (event->window == widget->window)
- paint_back (fullday, &event->area);
- else {
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (child && !on_text)
- child_draw (fullday, child, &event->area, event->window, FALSE);
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_key_press (GtkWidget *widget, GdkEventKey *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- GList *children;
- Child *child;
- gint pos;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- di = fullday->drag_info;
-
- if (di->sel_rows_used == 0)
- return FALSE;
-
- if (event->keyval == GDK_Return) {
- gtk_signal_emit (GTK_OBJECT (fullday), fullday_signals[RANGE_ACTIVATED]);
- return TRUE;
- }
-
- /*
- * If a non-printable key was pressed, bail. Otherwise, begin
- * editing the appointment.
- */
- if ((event->keyval < 0x20) || (event->keyval > 0xFF)
- || (event->length == 0) || (event->state & GDK_CONTROL_MASK)
- || (event->state & GDK_MOD1_MASK))
- return FALSE;
-
- gtk_signal_emit (GTK_OBJECT (fullday),
- fullday_signals[RANGE_ACTIVATED]);
-
- /*
- * Find the new child, which should hopefully be focused, and
- * insert the keypress.
- */
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (GTK_WIDGET_HAS_FOCUS (child->widget)) {
- pos = gtk_text_get_length (GTK_TEXT (child->widget));
-
- gtk_editable_insert_text (GTK_EDITABLE (child->widget),
- event->string,
- event->length,
- &pos);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_focus_in (GtkWidget *widget, GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
- gtk_widget_draw_focus (widget);
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_focus_out (GtkWidget *widget, GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
- gtk_widget_draw_focus (widget);
-
- return FALSE;
-}
-
-static void
-gncal_full_day_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data)
-{
- GncalFullDay *fullday;
- GList *children;
- Child *child;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (container));
- g_return_if_fail (callback != NULL);
-
- fullday = GNCAL_FULL_DAY (container);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- (*callback) (child->widget, callback_data);
- }
-}
-
-static gint
-child_compare (gconstpointer a, gconstpointer b)
-{
- const Child *ca = a;
- const Child *cb = b;
- time_t diff;
-
- diff = ca->start - cb->start;
-
- if (diff == 0)
- diff = cb->end - ca->end;
-
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-static int
-fullday_add_children (iCalObject *obj, time_t start, time_t end, void *c)
-{
- GncalFullDay *fullday = c;
- Child *child;
-
- child = child_new (fullday, start, end, obj);
- fullday->children = g_list_insert_sorted (fullday->children, child, child_compare);
-
- return 1;
-}
-
-void
-gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags)
-{
- GList *children;
- Child *child;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- if (!fullday->calendar->cal)
- return;
-
- /* Try to find child that changed */
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->ico == ico)
- break;
- }
-
- /* If child was found and nothing but the summary changed, we can just paint the child and return */
-
- if (children && !(flags & ~CHANGE_SUMMARY)) {
- child_draw (fullday, child, NULL, NULL, TRUE);
- return;
- }
-
- /* We have to regenerate and layout our list of children */
-
- destroy_children (fullday);
-
- calendar_iterate (fullday->calendar->cal,
- fullday->lower,
- fullday->upper,
- fullday_add_children,
- fullday);
-
- layout_children (fullday);
-
- /* Realize and map children */
-
- for (children = fullday->children; children; children = children->next) {
- if (GTK_WIDGET_REALIZED (fullday))
- child_realize (fullday, children->data);
-
- if (GTK_WIDGET_MAPPED (fullday))
- child_map (fullday, children->data);
- }
-
- gtk_widget_draw (GTK_WIDGET (fullday), NULL);
-}
-
-void
-gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper)
-{
- struct drag_info *di;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- if ((lower != fullday->lower) || (upper != fullday->upper)) {
- fullday->lower = lower;
- fullday->upper = upper;
-
- di = fullday->drag_info;
-
- di->sel_rows_used = 0; /* clear selection */
-
- gncal_full_day_update (fullday, NULL, 0);
- }
-}
-
-int
-gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper)
-{
- struct drag_info *di;
- time_t alower, aupper;
-
- g_return_val_if_fail (fullday != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (fullday), FALSE);
-
- di = fullday->drag_info;
-
- if (di->sel_rows_used == 0){
- time_t now = time (NULL);
- struct tm tm = *localtime (&now);
- struct tm thisd = *localtime (&fullday->lower);
-
- thisd.tm_hour = tm.tm_hour;
- thisd.tm_min = tm.tm_min;
- thisd.tm_sec = 0;
- *lower = mktime (&thisd);
- thisd.tm_hour++;
- *upper = mktime (&thisd);
- return FALSE;
- }
-
- get_time_from_rows (fullday, di->sel_start_row, di->sel_rows_used, &alower, &aupper);
-
- if (lower)
- *lower = alower;
-
- if (upper)
- *upper= aupper;
-
- return TRUE;
-}
-
-void
-gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico)
-{
- GList *children;
- Child *child;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (ico != NULL);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->ico == ico) {
- gtk_widget_grab_focus (child->widget);
- break;
- }
- }
-}
-
-int
-gncal_full_day_get_day_start_yoffset (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- int begin_row;
-
- g_return_val_if_fail (fullday != NULL, 0);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (fullday), 0);
-
- widget = GTK_WIDGET (fullday);
-
- begin_row = (day_begin * 60) / fullday->interval;
-
- return widget->style->klass->ythickness + begin_row * calc_row_height (fullday);
-}
-
-static void
-range_activated (GncalFullDay *fullday)
-{
- struct drag_info *di;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- di = fullday->drag_info;
-
- /* Remove selection; at this point someone should already have added an appointment */
-
- di->sel_rows_used = 0;
-
- paint_back (fullday, NULL);
-}
diff --git a/calendar/gui/gncal-full-day.h b/calendar/gui/gncal-full-day.h
deleted file mode 100644
index 287c5f63f6..0000000000
--- a/calendar/gui/gncal-full-day.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Full day widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_FULL_DAY_H
-#define GNCAL_FULL_DAY_H
-
-
-#include <gtk/gtkcontainer.h>
-#include <libgnome/gnome-defs.h>
-#include "calendar.h"
-#include "gnome-cal.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_FULL_DAY(obj) GTK_CHECK_CAST (obj, gncal_full_day_get_type (), GncalFullDay)
-#define GNCAL_FULL_DAY_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_full_day_get_type (), GncalFullDayClass)
-#define GNCAL_IS_FULL_DAY(obj) GTK_CHECK_TYPE (obj, gncal_full_day_get_type ())
-
-
-typedef struct _GncalFullDay GncalFullDay;
-typedef struct _GncalFullDayClass GncalFullDayClass;
-
-struct _GncalFullDay {
- GtkContainer container;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- time_t lower; /* lower time to display */
- time_t upper; /* upper time to display */
- int interval; /* interval between rows in minutes */
-
- GList *children; /* container children */
- gpointer drag_info; /* internal drag information */
-
- GdkCursor *up_down_cursor; /* for dragging children */
- GdkCursor *beam_cursor; /* for the text widgets */
- GdkGC *recur_gc; /* The gc used to draw the recur image */
- GdkGC *bell_gc; /* The gc used to draw on imlib windows */
-
-};
-
-struct _GncalFullDayClass {
- GtkContainerClass parent_class;
-
- void (* range_activated) (GncalFullDay *fullday);
-};
-
-
-guint gncal_full_day_get_type (void);
-GtkWidget *gncal_full_day_new (GnomeCalendar *calendar, time_t lower, time_t upper);
-
-void gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags);
-void gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper);
-
-/* Returns the selected range in lower and upper. If nothing is
- * selected, return value is FALSE, otherwise it is TRUE.
- * The lower and upper values are always set to proper values, regardless of
- * the selection value
- */
-int gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper);
-
-void gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico);
-
-int gncal_full_day_get_day_start_yoffset (GncalFullDay *fullday);
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gncal-todo.c b/calendar/gui/gncal-todo.c
deleted file mode 100644
index 3be3ac4517..0000000000
--- a/calendar/gui/gncal-todo.c
+++ /dev/null
@@ -1,877 +0,0 @@
-/* To-do widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#include <config.h>
-#include <string.h>
-#include <gnome.h>
-#include "gncal-todo.h"
-#include "main.h"
-#include "popup-menu.h"
-#include "eventedit.h"
-
-int todo_show_due_date = 0;
-int todo_show_priority = 0;
-int todo_show_time_remaining = 0;
-
-int todo_item_dstatus_highlight_overdue = 0;
-int todo_item_dstatus_highlight_due_today = 0;
-int todo_item_dstatus_highlight_not_due_yet = 0;
-
-
-char *todo_overdue_font_text;
-gint todo_current_sort_column = 0;
-gint todo_current_sort_type = GTK_SORT_ASCENDING;
-
-gboolean todo_style_changed =0;
-gboolean todo_list_autoresize = 1;
-gboolean todo_list_redraw_in_progess = 0;
-static void gncal_todo_init (GncalTodo *todo);
-
-
-guint
-gncal_todo_get_type (void)
-{
- static guint todo_type = 0;
-
- if (!todo_type) {
- GtkTypeInfo todo_info = {
- "GncalTodo",
- sizeof (GncalTodo),
- sizeof (GncalTodoClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) gncal_todo_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- todo_type = gtk_type_unique (gtk_vbox_get_type (), &todo_info);
- }
-
- return todo_type;
-}
-
-static void
-ok_button (GtkWidget *widget, GnomeDialog *dialog)
-{
- iCalObject *ico;
- GncalTodo *todo;
- GtkEntry *entry;
- GnomeDateEdit *due_date;
- GtkText *comment;
- GtkSpinButton *priority;
-
- ico = gtk_object_get_user_data (GTK_OBJECT (dialog));
-
- todo = GNCAL_TODO (gtk_object_get_data (GTK_OBJECT (dialog), "gncal_todo"));
- entry = GTK_ENTRY (gtk_object_get_data (GTK_OBJECT (dialog), "summary_entry"));
- due_date = GNOME_DATE_EDIT (gtk_object_get_data(GTK_OBJECT(dialog), "due_date"));
- priority = GTK_SPIN_BUTTON (gtk_object_get_data(GTK_OBJECT(dialog), "priority"));
- comment = GTK_TEXT(gtk_object_get_data (GTK_OBJECT(dialog), "comment"));
- if (ico->summary)
- g_free (ico->summary);
- if (ico->comment)
- g_free (ico->comment);
- ico->dtend = gnome_date_edit_get_date (due_date);
- ico->summary = g_strdup (gtk_entry_get_text (entry));
- ico->priority = gtk_spin_button_get_value_as_int (priority);
- ico->comment = gtk_editable_get_chars( GTK_EDITABLE(comment), 0, -1);
- ico->user_data = NULL;
-
- if (ico->new) {
- gnome_calendar_add_object (todo->calendar, ico);
- ico->new = FALSE;
- } else
- gnome_calendar_object_changed (todo->calendar, ico, CHANGE_ALL); /* ok, summary only... */
-
- save_default_calendar (todo->calendar);
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-
-static void
-cancel_button (GtkWidget *widget, GnomeDialog *dialog)
-{
- iCalObject *ico;
-
- ico = gtk_object_get_user_data (GTK_OBJECT (dialog));
-
- ico->user_data = NULL;
-
- if (ico->new)
- ical_object_destroy (ico);
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
-
-
-}
-
-static gint
-delete_event (GtkWidget *widget, GdkEvent *event, GnomeDialog *dialog)
-{
- cancel_button (NULL, dialog);
- return TRUE;
-}
-
-static void
-simple_todo_editor (GncalTodo *todo, iCalObject *ico)
-{
- GtkWidget *dialog;
- GtkWidget *hbox;
- GtkWidget *due_box;
- GtkWidget *due_label;
- GtkWidget *due_entry;
- GtkWidget *comment_box;
- GtkWidget *comment_label;
- GtkWidget *comment_text;
- GtkWidget *comment_internal_box;
- GtkWidget *comment_sep;
- GtkWidget *w;
- GtkWidget *pri_box;
- GtkWidget *pri_label;
- GtkWidget *pri_spin;
- GtkObject *pri_adj;
-
- GtkWidget *entry;
-
- dialog = gnome_dialog_new (ico->new ? _("Create to-do item") : _("Edit to-do item"),
- GNOME_STOCK_BUTTON_OK,
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
- gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (todo->calendar));
- hbox = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (hbox), 4);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
-
- due_box = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (due_box), 4);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), due_box, FALSE, FALSE, 0);
- gtk_widget_show (due_box);
-
- pri_box = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (pri_box), 4);
- gtk_box_pack_start(GTK_BOX (GNOME_DIALOG (dialog)->vbox), pri_box, FALSE, FALSE, 0);
- gtk_widget_show (pri_box);
-
- comment_box = gtk_hbox_new (FALSE, 4);
- gtk_container_border_width (GTK_CONTAINER (comment_box), 4);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), comment_box, FALSE, FALSE, 0);
- gtk_widget_show (comment_box);
-
- comment_internal_box = gtk_vbox_new(FALSE,2);
- gtk_container_border_width (GTK_CONTAINER (comment_internal_box), 4);
-
- gtk_box_pack_start (GTK_BOX (comment_box), comment_internal_box, TRUE, TRUE, 0);
- gtk_widget_show (comment_internal_box);
-
- w = gtk_label_new (_("Summary:"));
- gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- entry = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY (entry), ico->summary);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- gtk_widget_show (entry);
-
-
- due_label = gtk_label_new (_("Due Date:"));
- gtk_box_pack_start (GTK_BOX (due_box), due_label, FALSE, FALSE, 0);
- gtk_widget_show (due_label);
-
- due_entry = gtk_entry_new ();
- due_entry = date_edit_new (ico->dtend, TRUE);
- gtk_box_pack_start (GTK_BOX (due_box), due_entry, TRUE, TRUE, 0);
- gtk_widget_show (due_entry);
-
- pri_label = gtk_label_new (_("Priority:"));
- gtk_box_pack_start (GTK_BOX (pri_box), pri_label, FALSE, FALSE, 0);
- gtk_widget_show (pri_label);
-
- pri_adj = gtk_adjustment_new (5.0, 1.0, 9.0, 1.0, 3.0, 0.0);
- pri_spin = gtk_spin_button_new (GTK_ADJUSTMENT(pri_adj), 0.0, 0);
- gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (pri_spin), TRUE);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (pri_spin), FALSE);
- gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (pri_spin), FALSE);
- gtk_box_pack_start (GTK_BOX (pri_box), pri_spin, FALSE, FALSE, 0);
- gtk_widget_show (pri_spin);
-
- comment_sep = gtk_hseparator_new ();
- gtk_box_pack_start (GTK_BOX (comment_box), comment_sep, FALSE, FALSE, 0);
- gtk_widget_show(comment_sep);
-
- comment_label = gtk_label_new (_("Item Comments:"));
- gtk_label_set_justify(GTK_LABEL(comment_label), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start (GTK_BOX (comment_internal_box), comment_label, TRUE, TRUE, 0);
- gtk_widget_show (comment_label);
-
-
-
-
- comment_text = gtk_text_new (NULL, NULL);
- gtk_text_set_editable (GTK_TEXT (comment_text), TRUE);
- gtk_text_set_word_wrap( GTK_TEXT(comment_text), TRUE);
- gtk_text_freeze(GTK_TEXT(comment_text));
- if(ico->comment) {
- gtk_text_insert(GTK_TEXT(comment_text), NULL, NULL, NULL, ico->comment, strlen(ico->comment));
- }
- gtk_text_thaw(GTK_TEXT(comment_text));
- gtk_box_pack_start (GTK_BOX (comment_internal_box), comment_text, FALSE, TRUE, 0);
- gtk_widget_show (comment_text);
-
- ico->user_data = dialog;
-
- gtk_object_set_user_data (GTK_OBJECT (dialog), ico);
-
- gtk_object_set_data (GTK_OBJECT (dialog), "gncal_todo", todo);
- gtk_object_set_data (GTK_OBJECT (dialog), "summary_entry", entry);
- gtk_object_set_data (GTK_OBJECT (dialog), "due_date", due_entry);
- gtk_object_set_data (GTK_OBJECT (dialog), "priority", pri_spin);
- gtk_object_set_data (GTK_OBJECT (dialog), "comment", comment_text);
-
- gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0, (GtkSignalFunc) ok_button, dialog);
- gnome_dialog_button_connect (GNOME_DIALOG (dialog), 1, (GtkSignalFunc) cancel_button, dialog);
-
- gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
- (GtkSignalFunc) delete_event,
- dialog);
-
- gnome_dialog_set_default (GNOME_DIALOG (dialog), 0);
- gnome_dialog_editable_enters (GNOME_DIALOG (dialog), GTK_EDITABLE(entry));
-
- gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
- gtk_widget_show (dialog);
- gtk_widget_grab_focus (entry);
-}
-
-static iCalObject *
-get_clist_selected_ico (GtkCList *clist)
-{
- gint sel;
-
- if (!clist->selection)
- return NULL;
-
- sel = GPOINTER_TO_INT(clist->selection->data);
-
- return gtk_clist_get_row_data (clist, sel);
-}
-
-static void
-add_todo (GncalTodo *todo)
-{
- iCalObject *ico;
-
- ico = ical_new ("", user_name, "");
- ico->type = ICAL_TODO;
- ico->new = TRUE;
-
- simple_todo_editor (todo, ico);
-}
-
-static void
-edit_todo (GncalTodo *todo)
-{
- simple_todo_editor (todo, get_clist_selected_ico (todo->clist));
-}
-
-static void
-delete_todo (GncalTodo *todo)
-{
- gnome_calendar_remove_object (todo->calendar, get_clist_selected_ico (todo->clist));
- save_default_calendar (todo->calendar);
-
-}
-
-static void
-add_activated (GtkWidget *widget, GncalTodo *todo)
-{
- GtkWidget *w;
-
- while ((w = gtk_grab_get_current ()) != NULL)
- gtk_grab_remove (w);
-
- add_todo (todo);
-}
-
-static void
-edit_activated (GtkWidget *widget, GncalTodo *todo)
-{
- GtkWidget *w;
-
- while ((w = gtk_grab_get_current ()) != NULL)
- gtk_grab_remove (w);
-
- edit_todo (todo);
-}
-
-static void
-delete_activated (GtkWidget *widget, GncalTodo *todo)
-{
- delete_todo (todo);
-}
-
-
-static void
-clist_row_selected (GtkCList *clist, gint row, gint column, GdkEventButton *event, GncalTodo *todo)
-{
- static struct menu_item items[] = {
- { N_("Add to-do item..."), (GtkSignalFunc) add_activated, NULL, TRUE },
- { N_("Edit this item..."), (GtkSignalFunc) edit_activated, NULL, TRUE },
- { N_("Delete this item"), (GtkSignalFunc) delete_activated, NULL, TRUE }
- };
-
- int i;
-
- gtk_widget_set_sensitive (todo->edit_button, (todo->clist->selection != NULL));
- gtk_widget_set_sensitive (todo->delete_button, (todo->clist->selection != NULL));
-
- if (!event)
- return;
-
- switch (event->button) {
- case 1:
- if (event->type == GDK_2BUTTON_PRESS)
- edit_todo (todo);
- break;
-
- case 3:
- for (i = 0; i < (sizeof (items) / sizeof (items[0])); i++)
- items[i].data = todo;
-
- popup_menu (items, sizeof (items) / sizeof (items[0]), event);
- break;
-
- default:
- break;
- }
-}
-
-/*
- * once we get a call back stating that a column
- * has been resized never ever automatically resize again
- */
-void
-column_resized (GtkWidget *widget, GncalTodo *todo)
-{
- /* disabling autoresize of columns */
- if (todo_list_autoresize && !todo_list_redraw_in_progess){
- todo_list_autoresize = 0;
- }
-}
-
-/*
- * restore the previously set settings for sorting the
- * todo list
- */
-static void
-init_column_sorting (GtkCList *clist)
-{
-
- /* due date isn't shown so we can't sort by it */
- if (todo_current_sort_column == 1 && ! todo_show_due_date)
- todo_current_sort_column = 0;
-
- clist->sort_type = todo_current_sort_type;
- clist->sort_column = todo_current_sort_column;
-
- gtk_clist_set_sort_column (clist, todo_current_sort_column);
- gtk_clist_sort (clist);
-}
-
-static void
-todo_click_column (GtkCList *clist, gint column, gpointer data)
-{
- if (column == clist->sort_column)
- {
- if (clist->sort_type == GTK_SORT_ASCENDING) {
- clist->sort_type = GTK_SORT_DESCENDING;
- todo_current_sort_type = GTK_SORT_DESCENDING;
- } else {
- clist->sort_type = GTK_SORT_ASCENDING;
- todo_current_sort_type = GTK_SORT_ASCENDING;
- }
- }
- else {
- gtk_clist_set_sort_column (clist, column);
- todo_current_sort_column = column;
- }
-
- gtk_clist_sort (clist);
-
- /*
- * save the sorting preferences cause I hate to have the user
- * click twice
- */
-
- gnome_config_set_int("/calendar/Todo/sort_column", todo_current_sort_column);
- gnome_config_set_int("/calendar/Todo/sort_type", todo_current_sort_type);
- gnome_config_sync();
-}
-
-static void
-gncal_todo_init (GncalTodo *todo)
-{
- GtkWidget *w;
- GtkWidget *sw;
- GtkWidget *hbox;
- gchar *titles[4] = {
- N_("Summary"),
- N_("Due Date"),
- N_("Priority"),
- N_("Time Left")
- };
- char *tmp[4];
- tmp[0] = _(titles[0]);
- tmp[1] = _(titles[1]);
- tmp[2] = _(titles[2]);
- tmp[3] = _(titles[3]);
-
- gtk_box_set_spacing (GTK_BOX (todo), 4);
-
- /* Label */
-
- w = gtk_label_new (_("To-do list"));
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (todo), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Clist */
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start (GTK_BOX (todo), sw, TRUE, TRUE, 0);
- gtk_widget_show (sw);
-
-
- w = gtk_clist_new_with_titles(4, tmp);
-
- todo->clist = GTK_CLIST (w);
- gtk_clist_set_selection_mode (todo->clist, GTK_SELECTION_BROWSE);
-
- gtk_signal_connect (GTK_OBJECT (todo->clist), "select_row",
- (GtkSignalFunc) clist_row_selected,
- todo);
- gtk_clist_set_button_actions (todo->clist, 2, GTK_BUTTON_SELECTS);
- gtk_signal_connect (GTK_OBJECT (todo->clist), "resize_column",
- (GtkSignalFunc) column_resized,
- todo);
- gtk_signal_connect (GTK_OBJECT (todo->clist), "click_column",
- (GtkSignalFunc) todo_click_column, NULL);
-
- gtk_container_add (GTK_CONTAINER (sw), w);
- gtk_widget_show (w);
-
- /* Box for buttons */
-
- hbox = gtk_hbox_new (TRUE, 4);
- gtk_box_pack_start (GTK_BOX (todo), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
- /* Add */
-
- w = gtk_button_new_with_label (_("Add..."));
- gtk_signal_connect (GTK_OBJECT (w), "clicked",
- (GtkSignalFunc) add_activated,
- todo);
- gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
- gtk_widget_show (w);
-
- /* Edit */
-
- w = gtk_button_new_with_label (_("Edit..."));
- todo->edit_button = w;
- gtk_widget_set_sensitive (w, FALSE);
- gtk_signal_connect (GTK_OBJECT (w), "clicked",
- (GtkSignalFunc) edit_activated,
- todo);
- gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
- gtk_widget_show (w);
-
- /* Delete */
-
- w = gtk_button_new_with_label (_("Delete"));
- todo->delete_button = w;
- gtk_widget_set_sensitive (w, FALSE);
- gtk_signal_connect (GTK_OBJECT (w), "clicked",
- (GtkSignalFunc) delete_activated,
- todo);
- gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
- gtk_widget_show (w);
-}
-
-GtkWidget *
-gncal_todo_new (GnomeCalendar *calendar)
-{
- GncalTodo *todo;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- todo = gtk_type_new (gncal_todo_get_type ());
-
- todo->calendar = calendar;
-
- gncal_todo_update (todo, NULL, 0);
-
- return GTK_WIDGET (todo);
-}
-
-static char *
-convert_time_t_to_char (time_t t)
-{
- char buf[100];
- struct tm tm;
-
- tm = *localtime (&t);
- strftime(buf, sizeof (buf), "%m/%d/%Y", &tm);
-
- return g_strdup (buf);
-}
-
-enum todo_styles {
- TODO_STYLE_OVERDUE,
- TODO_STYLE_DUE_TODAY,
- TODO_STYLE_NOT_DUE
-};
-
-
-enum todo_status {
- TODO_ITEM_DSTATUS_NOT_DUE_YET,
- TODO_ITEM_DSTATUS_DUE_TODAY,
- TODO_ITEM_DSTATUS_OVERDUE,
- TODO_ITEM_DSTATUS_LAST_DUE_STATUS
-};
-typedef enum todo_status todo_status;
-
-static GtkStyle *
-make_todo_style(GncalTodo *todo, todo_status style_type)
-{
- GtkStyle *style = NULL;
- GdkColor style_color;
- int color_prop = 0;
- switch(style_type) {
- case TODO_ITEM_DSTATUS_NOT_DUE_YET:
- color_prop = COLOR_PROP_TODO_NOT_DUE_YET;
- break;
- case TODO_ITEM_DSTATUS_DUE_TODAY:
- color_prop = COLOR_PROP_TODO_DUE_TODAY;
- break;
- case TODO_ITEM_DSTATUS_OVERDUE:
- color_prop = COLOR_PROP_TODO_OVERDUE;
- break;
- case TODO_ITEM_DSTATUS_LAST_DUE_STATUS:
- }
-
- style_color.red = color_props[color_prop].r;
- style_color.green = color_props[color_prop].g;
- style_color.blue = color_props[color_prop].b;
-
- style = gtk_style_copy (GTK_WIDGET (todo->clist)->style);
- style->base[GTK_STATE_NORMAL] = style_color;
- return style;
-}
-
-
-
-
-static
-todo_status todo_item_due_status(time_t *todo_due_time) {
- struct tm due_tm_time;
- struct tm current_time;
- struct tm *temp_tm;
- time_t current_time_val = time(NULL);
- temp_tm = localtime(todo_due_time);
- /* make a copy so it dosen't get over written */
- memcpy(&due_tm_time, temp_tm, sizeof(struct tm));
-
-
- temp_tm = localtime(&current_time_val);
- memcpy(&current_time, temp_tm, sizeof(struct tm));
-
- if(due_tm_time.tm_mon == current_time.tm_mon &&
- due_tm_time.tm_mday == current_time.tm_mday &&
- due_tm_time.tm_year == current_time.tm_year) {
- return TODO_ITEM_DSTATUS_DUE_TODAY;
- }
-
- if((*todo_due_time) < current_time_val) {
- return TODO_ITEM_DSTATUS_OVERDUE;
- }
-
- return TODO_ITEM_DSTATUS_NOT_DUE_YET;
-}
-
-
-enum todo_remaining_time_form {
- TODO_ITEM_REMAINING_WEEKS,
- TODO_ITEM_REMAINING_DAYS,
- TODO_ITEM_REMAINING_HOURS,
- TODO_ITEM_REMAINING_MINUTES,
- TODO_ITEM_REMAINING_SECONDS
-};
-typedef enum todo_remaining_time_form todo_remaining_time_form;
-
-static void
-insert_in_clist (GncalTodo *todo, iCalObject *ico)
-{
- int i;
- char *text[4];
- char time_remaining_buffer[100];
- time_t time_remain;
- todo_remaining_time_form time_remaining_form;
- int sec_in_week = 3600*7*24;
- int sec_in_day = 3600*24;
- int sec_in_hour = 3600;
- int sec_in_minute = 60;
- int weeks = 0;
- int days = 0;
- int hours = 0;
- int minutes = 0;
- int seconds = 0;
-
-
- /* an array for the styles of items */
- static GtkStyle *dstatus_styles[TODO_ITEM_DSTATUS_LAST_DUE_STATUS];
- /* we want to remake the styles when the status is changed,
- also we need to check for the null value in the pointer so we init them
- at startup */
- if (todo_style_changed || !dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]) {
- g_free(dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]);
- g_free(dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE]);
- g_free(dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY]);
-
- dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET] = make_todo_style(todo, TODO_ITEM_DSTATUS_NOT_DUE_YET);
- dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE] = make_todo_style(todo, TODO_ITEM_DSTATUS_OVERDUE);
- dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY] = make_todo_style(todo, TODO_ITEM_DSTATUS_DUE_TODAY);
-
- todo_style_changed = 0;
- }
-
-
-
-
-
- text[0] = ico->summary;
-
- if(todo_show_time_remaining) {
- memset(time_remaining_buffer, 0, 100);
- /* we need to make a string that represents the amount of time remaining
- before this task is due */
-
- /* for right now all I'll do is up to the hours. */
- time_remain = (ico->dtend - time(NULL));
- if(time_remain < 0) {
- text[3] = "Overdue!";
- }
- else {
-
- /* lets determine a decent denomination to display */
- if(time_remain / (sec_in_week))
- {
- /* we have weeks available */
- time_remaining_form = TODO_ITEM_REMAINING_WEEKS;
- weeks = time_remain / sec_in_week;
- days = (time_remain % (sec_in_week))/sec_in_day;
- }
- else if(time_remain / (sec_in_day))
- {
- /* we have days available */
- time_remaining_form = TODO_ITEM_REMAINING_DAYS;
- days = time_remain / sec_in_day;
- hours = (time_remain % sec_in_day)/sec_in_hour;
- }
- else if(time_remain / (sec_in_hour))
- {
- /* we have hours available */
- time_remaining_form = TODO_ITEM_REMAINING_HOURS;
- hours = time_remain /sec_in_hour;
- minutes = (time_remain % sec_in_hour) / sec_in_minute;
- }
- else if(time_remain / sec_in_minute)
- {
- time_remaining_form = TODO_ITEM_REMAINING_MINUTES;
- minutes = time_remain / sec_in_minute;
- seconds = time_remain % sec_in_minute;
- }
- else
- {
- time_remaining_form = TODO_ITEM_REMAINING_SECONDS;
- seconds = time_remain;
- }
-
- switch(time_remaining_form)
- {
- case TODO_ITEM_REMAINING_WEEKS:
- snprintf(time_remaining_buffer, 100, "%d %s %d %s", weeks,
- (weeks > 1) ? _("Weeks") : _("Week"),
- days, (days > 1) ? _("Days") : _("Day"));
- break;
- case TODO_ITEM_REMAINING_DAYS:
- snprintf(time_remaining_buffer, 100, "%d %s %d %s", days,
- (days > 1) ? _("Days") : _("Day"),
- hours, (hours > 1) ? _("Hours") : _("Hour"));
- break;
- case TODO_ITEM_REMAINING_HOURS:
- snprintf(time_remaining_buffer, 100, "%d %s %d %s", hours,
- (hours > 1) ? _("Hours") : _("Hour"),
- minutes, (minutes > 1) ? _("Minutes") : _("Minute"));
- break;
- case TODO_ITEM_REMAINING_MINUTES:
- snprintf(time_remaining_buffer, 100, "%d %s %d %s", minutes,
- (minutes > 1) ? _("Minutes") : _("Minute"),
- seconds, (seconds > 1) ? _("Seconds") : _("Second"));
- break;
- case TODO_ITEM_REMAINING_SECONDS:
- snprintf(time_remaining_buffer, 100, "%d %s", seconds,
- (seconds > 1) ? _("Seconds") : _("Second"));
- break;
- }
- text[3] = g_strdup(time_remaining_buffer);
- todo->data_ptrs = g_slist_append(todo->data_ptrs, text[3]);
- }
-
- }
- else {
- text[3] = "Loose penguini!";
- }
- /*
- * right now column 0 will be the summary
- * and column 1 will be the due date.
- * WISH: this should be able to be changed on the fly
- */
-
- if(ico->dtend && todo_show_due_date)
- {
- text[1] = convert_time_t_to_char (ico->dtend);
- /* Append the data's pointer so later it can be properly freed */
- todo->data_ptrs = g_slist_append (todo->data_ptrs, text[1]);
- }
- else
- text[1] = NULL;
-
- if(ico->priority && todo_show_priority)
- {
- text[2] = g_strdup_printf ("%d", ico->priority);
- todo->data_ptrs = g_slist_append (todo->data_ptrs, text[2]);
- }
- else
- text[2] = NULL;
-
- i = gtk_clist_append (todo->clist, text);
-
- gtk_clist_set_row_data (todo->clist, i, ico);
-
- /*
- * determine if the task is overdue..
- * if so mark with the apropriate style
- */
-
- switch(todo_item_due_status(&ico->dtend)) {
- case TODO_ITEM_DSTATUS_NOT_DUE_YET:
- if(todo_item_dstatus_highlight_not_due_yet)
- {
- gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]);
- }
- break;
- case TODO_ITEM_DSTATUS_DUE_TODAY:
- if(todo_item_dstatus_highlight_due_today)
- {
- gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY]);
- }
- break;
- case TODO_ITEM_DSTATUS_OVERDUE:
- if(todo_item_dstatus_highlight_overdue)
- {
- gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE]);
- }
- break;
- case TODO_ITEM_DSTATUS_LAST_DUE_STATUS:
- }
-
- /* keep the list in order */
- gtk_clist_sort (todo->clist);
-}
-
-void
-gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags)
-{
- GList *list;
- GSList *current_list;
-
- g_return_if_fail (todo != NULL);
- g_return_if_fail (GNCAL_IS_TODO (todo));
-
- /*
- * shut down the resize handler cause we are playing with the list.
- * In otherwords turn off the event handler
- */
- todo_list_redraw_in_progess =1;
-
- /* freeze the list */
- gtk_clist_freeze (todo->clist);
- init_column_sorting (todo->clist);
-
- /*
- * before here we have to free some of the memory that
- * stores the due date, or else we have a memory leak.
- * luckily all of the pointers are stored in todo->data_ptrs;
- */
-
- /* check on the columns that we should display */
- /* check for due date */
-
- if(todo_show_due_date) {
- gtk_clist_set_column_visibility (todo->clist, 1, 1);
- }
- else {
- gtk_clist_set_column_visibility (todo->clist, 1, 0);
- }
-
- if(todo_show_time_remaining) {
- gtk_clist_set_column_visibility (todo->clist, 3, 1);
- }
- else {
- gtk_clist_set_column_visibility (todo->clist, 3, 0);
- }
-
-
- if(todo_show_priority)
- gtk_clist_set_column_visibility (todo->clist, 2, 1);
- else
- gtk_clist_set_column_visibility (todo->clist, 2, 0);
-
- /* free the memory locations that were used in the previous display */
- for (current_list = todo->data_ptrs; current_list != NULL; current_list = g_slist_next(current_list)){
- g_free(current_list->data);
- }
-
- /* free the list and clear out the pointer */
- g_slist_free(todo->data_ptrs);
- todo->data_ptrs = NULL;
-
- gtk_clist_clear (todo->clist);
-
- for (list = todo->calendar->cal->todo; list; list = list->next)
- insert_in_clist (todo, list->data);
-
- /* if we are autoresizing then do it now */
- if(todo_list_autoresize && todo->clist->rows != 0)
- gtk_clist_columns_autosize (todo->clist);
-
- gtk_clist_thaw (todo->clist);
-
- gtk_widget_set_sensitive (todo->edit_button, (todo->clist->selection != NULL));
- gtk_widget_set_sensitive (todo->delete_button, (todo->clist->selection != NULL));
- todo_list_redraw_in_progess = 0;
-}
-
-
-
-
-
-
-
-
diff --git a/calendar/gui/gncal-todo.h b/calendar/gui/gncal-todo.h
deleted file mode 100644
index 51cfadea3f..0000000000
--- a/calendar/gui/gncal-todo.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* To-do widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_TODO_H
-#define GNCAL_TODO_H
-
-#include <gtk/gtkclist.h>
-#include <gtk/gtkvbox.h>
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_TODO(obj) GTK_CHECK_CAST (obj, gncal_todo_get_type (), GncalTodo)
-#define GNCAL_TODO_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_todo_get_type (), GncalTodoClass)
-#define GNCAL_IS_TODO(obj) GTK_CHECK_TYPE (obj, gncal_todo_get_type ())
-
-
-typedef struct _GncalTodo GncalTodo;
-typedef struct _GncalTodoClass GncalTodoClass;
-
-struct _GncalTodo {
- GtkVBox vbox;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- GtkCList *clist;
-
- GtkWidget *edit_button;
- GtkWidget *delete_button;
- GSList *data_ptrs;
-
-
-};
-
-struct _GncalTodoClass {
- GtkVBoxClass parent_class;
-};
-
-
-guint gncal_todo_get_type (void);
-GtkWidget *gncal_todo_new (GnomeCalendar *calendar);
-
-void gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gncal-week-view.c b/calendar/gui/gncal-week-view.c
deleted file mode 100644
index 888c656ff4..0000000000
--- a/calendar/gui/gncal-week-view.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <config.h>
-#include <gnome.h>
-#include <string.h>
-#include <gtk/gtk.h>
-#include "gncal-week-view.h"
-#include "main.h"
-#include "timeutil.h"
-
-static void gncal_week_view_init (GncalWeekView *wview);
-
-
-guint
-gncal_week_view_get_type (void)
-{
- static guint week_view_type = 0;
-
- if (!week_view_type) {
- GtkTypeInfo week_view_info = {
- "GncalWeekView",
- sizeof (GncalWeekView),
- sizeof (GncalWeekViewClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) gncal_week_view_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- week_view_type = gtk_type_unique (gtk_vbox_get_type (), &week_view_info);
- }
-
- return week_view_type;
-}
-
-static void
-gncal_week_view_init (GncalWeekView *wview)
-{
- int i;
-
- wview->calendar = NULL;
- memset (&wview->start_of_week, 0, sizeof (wview->start_of_week));
-
- for (i = 0; i < 7; i++)
- wview->days[i] = NULL;
-
- wview->gtk_calendar = NULL;
-}
-
-static void
-jump_to_day (GtkCalendar *cal, GncalWeekView *wview, int day)
-{
- struct tm tm;
- time_t t;
- static int inside;
-
- if (inside)
- return;
- inside = 1;
- tm.tm_mday = day;
- tm.tm_mon = cal->month;
- tm.tm_year = cal->year - 1900;
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_isdst = -1;
- t = mktime (&tm);
-
- gncal_week_view_set (wview, t);
- inside = 0;
-}
-
-static void
-jump_to_day_click (GtkCalendar *cal, GncalWeekView *wview)
-{
- jump_to_day (cal, wview, cal->selected_day);
-}
-
-static void
-sync_week (GtkCalendar *cal, GncalWeekView *wview)
-{
- jump_to_day (cal, wview, wview->start_of_week.tm_mday + 7);
- gnome_calendar_tag_calendar (wview->calendar, wview->gtk_calendar);
-}
-
-static void
-double_click_on_weekday (GtkWidget *widget, GdkEvent *e, GncalWeekView *wview)
-{
-}
-
-GtkWidget *
-gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week)
-{
- GncalWeekView *wview;
- GtkWidget *table;
- int i;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- wview = gtk_type_new (gncal_week_view_get_type ());
-
- table = gtk_table_new (0, 0, 0);
- gtk_table_set_homogeneous (GTK_TABLE (table), TRUE);
- wview->label = gtk_label_new ("");
- gtk_box_pack_start (GTK_BOX (wview), wview->label, 0, 0, 0);
- gtk_box_pack_start (GTK_BOX (wview), table, 1, 1, 0);
- wview->calendar = calendar;
- for (i = 0; i < 7; i++) {
- wview->days[i] = GNCAL_DAY_VIEW (gncal_day_view_new (calendar, 0, 0));
- gtk_signal_connect (GTK_OBJECT (wview->days [i]), "button_press_event",
- GTK_SIGNAL_FUNC(double_click_on_weekday), wview);
-
- if (i < 5)
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->days[i]),
- i, i + 1,
- 0, 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
- else
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->days[i]),
- i - 2, i - 1,
- 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- gtk_widget_show (GTK_WIDGET (wview->days[i]));
- }
-
- wview->gtk_calendar = GTK_CALENDAR (gtk_calendar_new ());
-
- gtk_signal_connect (GTK_OBJECT (wview->gtk_calendar), "day_selected_double_click",
- GTK_SIGNAL_FUNC(jump_to_day_click), wview);
- gtk_signal_connect (GTK_OBJECT (wview->gtk_calendar), "month_changed",
- GTK_SIGNAL_FUNC(sync_week), wview);
-
- gtk_calendar_display_options (wview->gtk_calendar,
- (GTK_CALENDAR_SHOW_HEADING
- | GTK_CALENDAR_SHOW_DAY_NAMES
- | (week_starts_on_monday
- ? GTK_CALENDAR_WEEK_START_MONDAY : 0)));
-
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->gtk_calendar),
- 0, 3,
- 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 4, 4);
- gtk_widget_show (GTK_WIDGET (wview->gtk_calendar));
-
- gncal_week_view_set (wview, start_of_week);
-
- return GTK_WIDGET (wview);
-}
-
-static void
-update (GncalWeekView *wview, int update_days, iCalObject *object, int flags)
-{
- int i;
-
- if (update_days)
- for (i = 0; i < 7; i++)
- gncal_day_view_update (wview->days[i], object, flags);
-
- /* FIXME: update extra widgets */
-}
-
-void
-gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags)
-{
- g_return_if_fail (wview != NULL);
- g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
-
- update (wview, TRUE, ico, flags);
-}
-
-void
-gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
-{
- struct tm tm;
- time_t day_start, day_end, week_start, week_end;
- int i;
-
- g_return_if_fail (wview != NULL);
- g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
-
- tm = *localtime (&start_of_week);
-
- /* back up to start of week (Monday) */
-
- tm.tm_mday -= (tm.tm_wday == 0) ? 6 : (tm.tm_wday - 1);
-
- /* Start of day */
-
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- day_start = week_start = mktime (&tm);
-
- /* Calendar */
-
- gtk_calendar_select_month (wview->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
-
- /* Day views */
-
- for (i = 0; i < 7; i++) { /* rest of days */
- tm.tm_mday++;
- day_end = mktime (&tm);
-
- gncal_day_view_set_bounds (wview->days[i], day_start, day_end - 1);
-
- day_start = day_end;
- }
-
- update (wview, FALSE, NULL, 0);
-
- /* The label */
- {
- char buf [3][100];
-
- week_end = time_add_day (week_start, 6);
-
- strftime (buf[0], sizeof (buf[0]), _("%a %b %d %Y"),
- localtime(&week_start));
-
- strftime (buf[1], sizeof (buf[1]), _("%a %b %d %Y"),
- localtime(&week_end));
-
- g_snprintf(buf[2], sizeof(buf[2]), "%s - %s", buf[0], buf[1]);
- gtk_label_set (GTK_LABEL (wview->label), buf[2]);
-
- }
-}
-
-void
-gncal_week_view_time_format_changed (GncalWeekView *wview)
-{
- g_return_if_fail (wview != NULL);
- g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
-
- gtk_calendar_display_options (wview->gtk_calendar,
- (week_starts_on_monday
- ? (wview->gtk_calendar->display_flags
- | GTK_CALENDAR_WEEK_START_MONDAY)
- : (wview->gtk_calendar->display_flags
- & ~GTK_CALENDAR_WEEK_START_MONDAY)));
-}
diff --git a/calendar/gui/gncal-week-view.h b/calendar/gui/gncal-week-view.h
deleted file mode 100644
index ab06161844..0000000000
--- a/calendar/gui/gncal-week-view.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef WEEK_VIEW_H
-#define WEEK_VIEW_H
-
-
-#include <gtk/gtkvbox.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkvbox.h>
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-#include "gncal-day-view.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_WEEK_VIEW(obj) GTK_CHECK_CAST (obj, gncal_week_view_get_type (), GncalWeekView)
-#define GNCAL_WEEK_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_week_view_get_type (), GncalWeekViewClass)
-#define GNCAL_IS_WEEK_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_week_view_get_type ())
-
-
-typedef struct _GncalWeekView GncalWeekView;
-typedef struct _GncalWeekViewClass GncalWeekViewClass;
-
-struct _GncalWeekView {
- GtkVBox box;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- struct tm start_of_week;
-
- GncalDayView *days[7]; /* the day view widgets */
- GtkCalendar *gtk_calendar; /* At least for now; see the FIXME comments in the .c file */
- GtkWidget *label;
-};
-
-struct _GncalWeekViewClass {
- GtkVBoxClass parent_class;
-};
-
-
-guint gncal_week_view_get_type (void);
-GtkWidget *gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week);
-
-void gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags);
-void gncal_week_view_set (GncalWeekView *wview, time_t start_of_week);
-void gncal_week_view_time_format_changed (GncalWeekView *wview);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gncal.desktop b/calendar/gui/gncal.desktop
deleted file mode 100644
index 9ee2a2db9b..0000000000
--- a/calendar/gui/gncal.desktop
+++ /dev/null
@@ -1,37 +0,0 @@
-[Desktop Entry]
-Name=Calendar
-Name[da]=Kalender
-Name[de]=Kalender
-Name[el]=Çìåñïëüãéï
-Name[es]=Calendario
-Name[et]=Kalender
-Name[fi]=Kalenteri
-Name[fr]=Calendrier
-Name[gl]=Axenda
-Name[ja]=¥«¥ì¥ó¥À¡¼
-Name[ko]=´Þ·Â
-Name[no]=Kalender
-Name[pt]=Agenda
-Name[pt_BR]=Calendário
-Name[ru]=ëÁÌÅÎÄÁÒØ
-Name[sv]=Kalender
-Comment=Calendar application
-Comment[da]=Gnome Kalender
-Comment[de]=Gnome Kalender
-Comment[el]=Çìåñïëüãéï ôïõ Gnome
-Comment[es]=Calendario de Gnome
-Comment[et]=GNOME kalender
-Comment[fi]=GNOME-kalenteri
-Comment[fr]=Calendrier GNOME
-Comment[gl]=Axenda de GNOME
-Comment[ja]=GNOME¥«¥ì¥ó¥À¡¼
-Comment[ko]=±×³ð ´Þ·Â
-Comment[no]=Gnome Kalender
-Comment[pt]=Agenda Gnome
-Comment[pt_BR]=Calendário GNOME
-Comment[ru]=ëÁÌÅÎÄÁÒØ Gnome
-Comment[sv]=Gnome-kalender
-Exec=gnomecal
-Icon=gnome-calendar.png
-Terminal=0
-Type=Application
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
deleted file mode 100644
index 387d46a31c..0000000000
--- a/calendar/gui/gnome-cal.c
+++ /dev/null
@@ -1,613 +0,0 @@
-/*
- * GnomeCalendar widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-#include <config.h>
-#include <gnome.h>
-#include <unistd.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include "calendar.h"
-#include "gnome-cal.h"
-#include "gncal-day-panel.h"
-#include "gncal-week-view.h"
-#include "month-view.h"
-#include "year-view.h"
-#include "timeutil.h"
-#include "main.h"
-#include "corba-cal.h"
-
-GnomeApp *parent_class;
-
-guint
-gnome_calendar_get_type (void)
-{
- static guint gnome_calendar_type = 0;
- if(!gnome_calendar_type) {
- GtkTypeInfo gnome_calendar_info = {
- "GnomeCalendar",
- sizeof(GnomeCalendar),
- sizeof(GnomeCalendarClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) NULL,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL,
- };
- gnome_calendar_type = gtk_type_unique(gnome_app_get_type(), &gnome_calendar_info);
- parent_class = gtk_type_class (gnome_app_get_type());
- }
- return gnome_calendar_type;
-}
-
-static void
-setup_widgets (GnomeCalendar *gcal)
-{
- time_t now;
-
- now = time (NULL);
-
- gcal->notebook = gtk_notebook_new ();
- gcal->day_view = gncal_day_panel_new (gcal, now);
- gcal->week_view = gncal_week_view_new (gcal, now);
- gcal->month_view = month_view_new (gcal, now);
- gcal->year_view = year_view_new (gcal, now);
-
- gcal->year_view_sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gcal->year_view_sw),
- GTK_POLICY_NEVER,
- GTK_POLICY_AUTOMATIC);
- gtk_container_add (GTK_CONTAINER (gcal->year_view_sw), gcal->year_view);
- GTK_LAYOUT (gcal->year_view)->vadjustment->step_increment = 10.0;
- gtk_adjustment_changed (GTK_ADJUSTMENT (GTK_LAYOUT (gcal->year_view)->vadjustment));
-
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view, gtk_label_new (_("Day View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->week_view, gtk_label_new (_("Week View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->month_view, gtk_label_new (_("Month View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->year_view_sw, gtk_label_new (_("Year View")));
-
- gtk_widget_show_all (gcal->notebook);
-
- gnome_app_set_contents (GNOME_APP (gcal), gcal->notebook);
-}
-
-static GtkWidget *
-get_current_page (GnomeCalendar *gcal)
-{
- return GTK_NOTEBOOK (gcal->notebook)->cur_page->child;
-}
-
-char *
-gnome_calendar_get_current_view_name (GnomeCalendar *gcal)
-{
- GtkWidget *page;
-
- g_return_val_if_fail (gcal != NULL, "dayview");
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), "dayview");
-
- page = get_current_page (gcal);
-
- if (page == gcal->day_view)
- return "dayview";
- else if (page == gcal->week_view)
- return "weekview";
- else if (page == gcal->month_view)
- return "monthview";
- else if (page == gcal->year_view_sw)
- return "yearview";
- else
- return "dayview";
-}
-
-void
-gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
-{
- GtkWidget *current;
-
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (new_time != -1);
-
- current = get_current_page (gcal);
- new_time = time_day_begin (new_time);
-
- if (current == gcal->day_view)
- gncal_day_panel_set (GNCAL_DAY_PANEL (gcal->day_view), new_time);
- else if (current == gcal->week_view)
- gncal_week_view_set (GNCAL_WEEK_VIEW (gcal->week_view), new_time);
- else if (current == gcal->month_view)
- month_view_set (MONTH_VIEW (gcal->month_view), new_time);
- else if (current == gcal->year_view_sw)
- year_view_set (YEAR_VIEW (gcal->year_view), new_time);
- else {
- g_warning ("My penguin is gone!");
- g_assert_not_reached ();
- }
-
- gcal->current_display = new_time;
-}
-
-static void
-gnome_calendar_direction (GnomeCalendar *gcal, int direction)
-{
- GtkWidget *cp = get_current_page (gcal);
- time_t new_time;
-
- if (cp == gcal->day_view)
- new_time = time_add_day (time_day_begin (gcal->current_display), 1 * direction);
- else if (cp == gcal->week_view)
- new_time = time_add_week (time_week_begin (gcal->current_display), 1 * direction);
- else if (cp == gcal->month_view)
- new_time = time_add_month (time_month_begin (gcal->current_display), 1 * direction);
- else if (cp == gcal->year_view_sw)
- new_time = time_add_year (time_year_begin (gcal->current_display), 1 * direction);
- else {
- g_warning ("Weee! Where did the penguin go?");
- g_assert_not_reached ();
- new_time = 0;
- }
-
- gnome_calendar_goto (gcal, new_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);
-}
-
-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);
-}
-
-void
-gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- gtk_notebook_set_page (GTK_NOTEBOOK (gcal->notebook), 0);
- gnome_calendar_goto (gcal, time);
-}
-
-void
-gnome_calendar_goto_today (GnomeCalendar *gcal)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- gnome_calendar_goto (gcal, time (NULL));
-}
-
-void
-gnome_calendar_set_view (GnomeCalendar *gcal, char *page_name)
-{
- int page = 0;
-
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (page_name != NULL);
-
-
- if (strcmp (page_name, "dayview") == 0)
- page = 0;
- else if (strcmp (page_name, "weekview") == 0)
- page = 1;
- else if (strcmp (page_name, "monthview") == 0)
- page = 2;
- else if (strcmp (page_name, "yearview") == 0)
- page = 3;
- gtk_notebook_set_page (GTK_NOTEBOOK (gcal->notebook), page);
-}
-
-GtkWidget *
-gnome_calendar_new (char *title)
-{
- GtkWidget *retval;
- GnomeCalendar *gcal;
- GnomeApp *app;
-
- retval = gtk_type_new (gnome_calendar_get_type ());
- app = GNOME_APP (retval);
- gcal = GNOME_CALENDAR (retval);
-
- app->name = g_strdup ("calendar");
- app->prefix = g_strconcat ("/", app->name, "/", NULL);
-
- gtk_window_set_title(GTK_WINDOW(retval), title);
-
- gcal->current_display = time_day_begin (time (NULL));
- gcal->cal = calendar_new (title,CALENDAR_INIT_ALARMS);
- setup_widgets (gcal);
- gnome_calendar_create_corba_server (gcal);
-
- return retval;
-}
-
-static void
-gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags)
-{
- gncal_day_panel_update (GNCAL_DAY_PANEL (cal->day_view), object, flags);
- gncal_week_view_update (GNCAL_WEEK_VIEW (cal->week_view), object, flags);
- month_view_update (MONTH_VIEW (cal->month_view), object, flags);
- year_view_update (YEAR_VIEW (cal->year_view), object, flags);
-}
-
-int
-gnome_calendar_load (GnomeCalendar *gcal, char *file)
-{
- char *r;
-
- g_return_val_if_fail (gcal != NULL, 0);
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), 0);
- g_return_val_if_fail (file != NULL, 0);
-
- if ((r = calendar_load (gcal->cal, file)) != NULL){
- printf ("Error loading calendar: %s\n", r);
- return 0;
- }
- gnome_calendar_update_all (gcal, NULL, 0);
- return 1;
-}
-
-void
-gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (obj != NULL);
-
- calendar_add_object (gcal->cal, obj);
- gnome_calendar_update_all (gcal, obj, CHANGE_NEW);
-}
-
-void
-gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (obj != NULL);
-
- calendar_remove_object (gcal->cal, obj);
- gnome_calendar_update_all (gcal, obj, CHANGE_ALL);
-}
-
-void
-gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (obj != NULL);
-
- gcal->cal->modified = TRUE;
-
- gnome_calendar_update_all (gcal, obj, flags);
- calendar_object_changed (gcal->cal, obj, flags);
-}
-
-static int
-max_open_files (void)
-{
- static int files;
-
- if (files)
- return files;
-
- files = sysconf (_SC_OPEN_MAX);
- if (files != -1)
- return files;
-#ifdef OPEN_MAX
- return files = OPEN_MAX;
-#else
- return files = 256;
-#endif
-}
-
-static void
-execute (char *command, int close_standard)
-{
- struct sigaction ignore, save_intr, save_quit;
- int status = 0, i;
- pid_t pid;
-
- ignore.sa_handler = SIG_IGN;
- sigemptyset (&ignore.sa_mask);
- ignore.sa_flags = 0;
-
- sigaction (SIGINT, &ignore, &save_intr);
- sigaction (SIGQUIT, &ignore, &save_quit);
-
- if ((pid = fork ()) < 0){
- fprintf (stderr, "\n\nfork () = -1\n");
- return;
- }
- if (pid == 0){
- pid = fork ();
- if (pid == 0){
- const int top = max_open_files ();
- sigaction (SIGINT, &save_intr, NULL);
- sigaction (SIGQUIT, &save_quit, NULL);
-
- for (i = (close_standard ? 0 : 3); i < top; i++)
- close (i);
-
- /* FIXME: As an excercise to the reader, copy the
- * code from mc to setup shell properly instead of
- * /bin/sh. Yes, this comment is larger than a cut and paste.
- */
- execl ("/bin/sh", "/bin/sh", "-c", command, (char *) 0);
-
- _exit (127);
- } else {
- _exit (127);
- }
- }
- wait (&status);
- sigaction (SIGINT, &save_intr, NULL);
- sigaction (SIGQUIT, &save_quit, NULL);
-}
-
-void
-mail_notify (char *mail_address, char *text, time_t app_time)
-{
- pid_t pid;
- int p [2];
- char *command;
-
- pipe (p);
- pid = fork ();
- if (pid == 0){
- int dev_null;
-
- dev_null = open ("/dev/null", O_RDWR);
- dup2 (p [0], 0);
- dup2 (dev_null, 1);
- dup2 (dev_null, 2);
- execl ("/usr/lib/sendmail", "/usr/lib/sendmail",
- mail_address, NULL);
- _exit (127);
- }
- command = g_strconcat ("To: ", mail_address, "\n",
- "Subject: ", _("Reminder of your appointment at "),
- ctime (&app_time), "\n\n", text, "\n", NULL);
- write (p [1], command, strlen (command));
- close (p [1]);
- close (p [0]);
- g_free (command);
-}
-
-static void
-stop_beeping (GtkObject* object, gpointer data)
-{
- guint timer_tag, beep_tag;
- timer_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "timer_tag"));
- beep_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "beep_tag"));
-
- if (beep_tag > 0) {
- gtk_timeout_remove (beep_tag);
- gtk_object_set_data (object, "beep_tag", GINT_TO_POINTER (0));
- }
- if (timer_tag > 0) {
- gtk_timeout_remove (timer_tag);
- gtk_object_set_data (object, "timer_tag", GINT_TO_POINTER (0));
- }
-}
-
-static gint
-start_beeping (gpointer data)
-{
- gdk_beep ();
-
- return TRUE;
-}
-
-static gint
-timeout_beep (gpointer data)
-{
- stop_beeping (data, NULL);
- return FALSE;
-}
-
-void
-calendar_notify (time_t activation_time, CalendarAlarm *which, void *data)
-{
- iCalObject *ico = data;
- guint beep_tag, timer_tag;
- int ret;
- gchar* snooze_button = (enable_snooze ? _("Snooze") : NULL);
- time_t now, diff;
-
- if (&ico->aalarm == which){
- time_t app = ico->aalarm.trigger + ico->aalarm.offset;
- GtkWidget *w;
- char *msg;
-
- msg = g_strconcat (_("Reminder of your appointment at "),
- ctime (&app), "`",
- ico->summary, "'", NULL);
-
- /* Idea: we need Snooze option :-) */
- w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, _("Ok"), snooze_button, NULL);
- beep_tag = gtk_timeout_add (1000, start_beeping, NULL);
- if (enable_aalarm_timeout)
- timer_tag = gtk_timeout_add (audio_alarm_timeout*1000,
- timeout_beep, w);
- else
- timer_tag = 0;
- gtk_object_set_data (GTK_OBJECT (w), "timer_tag",
- GINT_TO_POINTER (timer_tag));
- gtk_object_set_data (GTK_OBJECT (w), "beep_tag",
- GINT_TO_POINTER (beep_tag));
- gtk_widget_ref (w);
- ret = gnome_dialog_run (GNOME_DIALOG (w));
- switch (ret) {
- case 1:
- stop_beeping (GTK_OBJECT (w), NULL);
- now = time (NULL);
- diff = now - which->trigger;
- which->trigger = which->trigger + diff + snooze_secs;
- which->offset = which->offset - diff - snooze_secs;
- alarm_add (which, &calendar_notify, data);
- break;
- default:
- stop_beeping (GTK_OBJECT (w), NULL);
- break;
- }
-
- gtk_widget_unref (w);
- return;
- }
-
- if (&ico->palarm == which){
- execute (ico->palarm.data, 0);
- return;
- }
-
- if (&ico->malarm == which){
- time_t app = ico->malarm.trigger + ico->malarm.offset;
-
- mail_notify (ico->malarm.data, ico->summary, app);
- return;
- }
-
- if (&ico->dalarm == which){
- time_t app = ico->dalarm.trigger + ico->dalarm.offset;
- GtkWidget *w;
- char *msg;
-
- if (beep_on_display)
- gdk_beep ();
- msg = g_strconcat (_("Reminder of your appointment at "),
- ctime (&app), "`",
- ico->summary, "'", NULL);
- w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO,
- _("Ok"), snooze_button, NULL);
- ret = gnome_dialog_run (GNOME_DIALOG (w));
- switch (ret) {
- case 1:
- now = time (NULL);
- diff = now - which->trigger;
- which->trigger = which->trigger + diff + snooze_secs;
- which->offset = which->offset - diff - snooze_secs;
- alarm_add (which, &calendar_notify, data);
- break;
- default:
- break;
- }
-
- return;
- }
-}
-
-/*
- * called from the calendar_iterate routine to mark the days of a GtkCalendar
- */
-static int
-mark_gtk_calendar_day (iCalObject *obj, time_t start, time_t end, void *c)
-{
- GtkCalendar *gtk_cal = c;
- struct tm tm_s;
- time_t t, day_end;
-
- tm_s = *localtime (&start);
- day_end = time_day_end (end);
-
- for (t = start; t <= day_end; t += 60*60*24){
- time_t new = mktime (&tm_s);
- struct tm tm_day;
-
- tm_day = *localtime (&new);
- gtk_calendar_mark_day (gtk_cal, tm_day.tm_mday);
- tm_s.tm_mday++;
- }
- return TRUE;
-}
-
-/*
- * Tags the dates with appointments in a GtkCalendar based on the
- * GnomeCalendar contents
- */
-void
-gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal)
-{
- time_t month_begin, month_end;
- struct tm tm;
-
- g_return_if_fail (cal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (cal));
- g_return_if_fail (gtk_cal != NULL);
- g_return_if_fail (GTK_IS_CALENDAR (gtk_cal));
-
- /* compute month_begin */
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_mday = 1; /* setting this to zero is a no-no; it will set mktime back to the end of the
- previous month, which may be 28,29,30; this may chop some days from the calendar */
- tm.tm_mon = gtk_cal->month;
- tm.tm_year = gtk_cal->year - 1900;
- tm.tm_isdst= -1;
-
- month_begin = mktime (&tm);
- tm.tm_mon++;
- month_end = mktime (&tm);
-
- gtk_calendar_freeze (gtk_cal);
- gtk_calendar_clear_marks (gtk_cal);
- calendar_iterate (cal->cal, month_begin, month_end, mark_gtk_calendar_day, gtk_cal);
- gtk_calendar_thaw (gtk_cal);
-}
-
-void
-gnome_calendar_time_format_changed (GnomeCalendar *gcal)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- /* FIXME: the queue resizes will do until we rewrite those views... */
-
- gncal_day_panel_time_format_changed (GNCAL_DAY_PANEL (gcal->day_view));
- gtk_widget_queue_resize (gcal->day_view);
- gncal_week_view_time_format_changed (GNCAL_WEEK_VIEW (gcal->week_view));
- gtk_widget_queue_resize (gcal->week_view);
- month_view_time_format_changed (MONTH_VIEW (gcal->month_view));
- year_view_time_format_changed (YEAR_VIEW (gcal->year_view));
-}
-
-void
-gnome_calendar_colors_changed (GnomeCalendar *gcal)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- /* FIXME: add day and week view when they are done */
-
- month_view_colors_changed (MONTH_VIEW (gcal->month_view));
- year_view_colors_changed (YEAR_VIEW (gcal->year_view));
- todo_style_changed = 1;
- todo_list_properties_changed (GNCAL_DAY_PANEL (gcal->day_view));
-}
-
-void
-gnome_calendar_todo_properties_changed (GnomeCalendar *gcal)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- /* FIXME: add day and week view when they are done */
-
- todo_style_changed = 1;
- todo_list_properties_changed (GNCAL_DAY_PANEL (gcal->day_view));
-}
-
-
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
deleted file mode 100644
index da53f29882..0000000000
--- a/calendar/gui/gnome-cal.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * GnomeCalendar widget
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-
-#ifndef GNOME_CALENDAR_APP_H
-#define GNOME_CALENDAR_APP_H
-
-#include <gnome.h>
-
-#include "calendar.h"
-
-BEGIN_GNOME_DECLS
-
-#define GNOME_CALENDAR(obj) GTK_CHECK_CAST(obj, gnome_calendar_get_type(), GnomeCalendar)
-#define GNOME_CALENDAR_CLASS(class) GTK_CHECK_CAST_CLASS(class, gnome_calendar_get_type(), GnomeCalendarClass)
-#define GNOME_IS_CALENDAR(obj) GTK_CHECK_TYPE(obj, gnome_calendar_get_type())
-
-typedef struct {
- GnomeApp gnome_app;
- Calendar *cal;
- time_t current_display;
-
- GtkWidget *notebook;
- GtkWidget *day_view;
- GtkWidget *week_view;
- GtkWidget *month_view;
- GtkWidget *year_view;
- GtkWidget *year_view_sw;
- void *event_editor;
-} GnomeCalendar;
-
-typedef struct {
- GnomeAppClass parent_class;
-} GnomeCalendarClass;
-
-guint gnome_calendar_get_type (void);
-GtkWidget *gnome_calendar_new (char *title);
-int gnome_calendar_load (GnomeCalendar *gcal,
- char *file);
-void gnome_calendar_add_object (GnomeCalendar *gcal,
- iCalObject *obj);
-void gnome_calendar_remove_object (GnomeCalendar *gcal,
- iCalObject *obj);
-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,
- time_t time);
-/* Jumps to the current day */
-void gnome_calendar_goto_today (GnomeCalendar *gcal);
-void gnome_calendar_tag_calendar (GnomeCalendar *cal,
- GtkCalendar *gtk_cal);
-char *gnome_calendar_get_current_view_name (GnomeCalendar *gcal);
-void gnome_calendar_set_view (GnomeCalendar *gcal,
- char *page_name);
-
-/* Flags is a bitmask of CalObjectChange values */
-void gnome_calendar_object_changed (GnomeCalendar *gcal,
- iCalObject *obj,
- int flags);
-
-GnomeCalendar *gnome_calendar_locate (const char *pathname);
-
-/* Notifies the calendar that the time format has changed and it must update all its views */
-void gnome_calendar_time_format_changed (GnomeCalendar *gcal);
-
-/* Notifies the calendar that the todo list properties have changed and its time to update the views */
-void
-gnome_calendar_colors_changed (GnomeCalendar *gcal);
-
-/* Notifies the calendar that the todo list properties have changed and its time to update the views */
-void
-gnome_calendar_todo_properties_changed (GnomeCalendar *gcal);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gnome-cal.html b/calendar/gui/gnome-cal.html
deleted file mode 100644
index 5a7d0a537f..0000000000
--- a/calendar/gui/gnome-cal.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<!-- Some simple instructions on how to use the help browser -->
-<BODY>
-<!-- <TITLE>GNOME Calendar Documentation</TITLE> -->
-<H2> GNOME Calendar Documentation </H2>
-<p>
-The GNOME calendar program is the calendaring program of the GNOME
-system. It uses the vCalendar standard for transfering calendar
-information (and is also the on-disk format used).
-
-<p>
-
-<a name="cmdline">
-<h2>Command line options</h2>
-
-Several options are available on the command line, they are:
-<ul>
- <li><tt>--events</tt> Displays the events for the date
- specified (or today, if no date is specified).
-
- <li><tt>--from DATE</tt> Define the beginning of the range for
- the event display, or the startup day on the calenday views.
- By default, the event will span the whole day specified in
- DATE.
-
- <li><tt>--to DATE</tt> Define the range end for the event
- display. If this is not specified, it will default to the end
- of the day specified by the <tt>--from</tt> option.
-
- <li><tt>--file FILE</tt> Set the calendar to the FILE
- specified on the command line.
-
- <li><tt>--todo</tt> Dumps the to-do values to standard output.
-</ul>
-
-<p>
-
-DATE is interpreted as being in the local time- zone, unless a
-specific timezone is specified. Examples of valid date specifications
-include: "1 month ago", "2 hours ago", "400000 seconds ago", "last
-year", "last Monday", "yesterday", "a fortnight ago", "3/31/92
-10:00:07 PST", "January 23, 1987 10:05pm", "22:00 GMT".
-
-</BODY>
-
diff --git a/calendar/gui/gnome-calendar-conduit.png b/calendar/gui/gnome-calendar-conduit.png
deleted file mode 100644
index e867ba90b2..0000000000
--- a/calendar/gui/gnome-calendar-conduit.png
+++ /dev/null
Binary files differ
diff --git a/calendar/gui/gnome-month-item.c b/calendar/gui/gnome-month-item.c
deleted file mode 100644
index 58e393e4ee..0000000000
--- a/calendar/gui/gnome-month-item.c
+++ /dev/null
@@ -1,1246 +0,0 @@
-/* General-purpose monthly calendar canvas item for GNOME
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include <math.h>
-#include <time.h>
-#include <gnome.h>
-#include "gnome-month-item.h"
-
-
-#define DEFAULT_FONT "-*-helvetica-medium-r-normal--10-*-*-*-p-*-*-*"
-
-
-/* Number of days in a month, for normal and leap years */
-static const int days_in_month[2][12] = {
- { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
- { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
-};
-
-/* The weird month of September 1752, where 3 Sep through 13 Sep were eliminated due to the
- * Gregorian reformation.
- */
-static const int sept_1752[42] = {
- 0, 0, 1, 2, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30,
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0
-};
-
-#define REFORMATION_DAY 639787 /* First day of the reformation, counted from 1 Jan 1 */
-#define MISSING_DAYS 11 /* They corrected out 11 days */
-#define THURSDAY 4 /* First day of reformation */
-#define SATURDAY 6 /* Offset value; 1 Jan 1 was a Saturday */
-#define SEPT_1752_START 2 /* Start day within month */
-#define SEPT_1752_END 20 /* End day within month */
-
-
-enum {
- ARG_0,
- ARG_YEAR,
- ARG_MONTH,
- ARG_X,
- ARG_Y,
- ARG_WIDTH,
- ARG_HEIGHT,
- ARG_ANCHOR,
- ARG_HEAD_PADDING,
- ARG_DAY_PADDING,
- ARG_DAY_NAMES,
- ARG_HEADING_HEIGHT,
- ARG_HEADING_ANCHOR,
- ARG_DAY_ANCHOR,
- ARG_START_ON_MONDAY,
- ARG_HEAD_FONT,
- ARG_HEAD_FONTSET,
- ARG_HEAD_FONT_GDK,
- ARG_DAY_FONT,
- ARG_DAY_FONTSET,
- ARG_DAY_FONT_GDK,
- ARG_HEAD_COLOR,
- ARG_HEAD_COLOR_GDK,
- ARG_OUTLINE_COLOR,
- ARG_OUTLINE_COLOR_GDK,
- ARG_DAY_BOX_COLOR,
- ARG_DAY_BOX_COLOR_GDK,
- ARG_DAY_COLOR,
- ARG_DAY_COLOR_GDK
-};
-
-
-static void gnome_month_item_class_init (GnomeMonthItemClass *class);
-static void gnome_month_item_init (GnomeMonthItem *mitem);
-static void gnome_month_item_destroy (GtkObject *object);
-static void gnome_month_item_set_arg (GtkObject *object,
- GtkArg *arg,
- guint arg_id);
-static void gnome_month_item_get_arg (GtkObject *object,
- GtkArg *arg,
- guint arg_id);
-
-
-
-static GnomeCanvasGroupClass *parent_class;
-
-
-GtkType
-gnome_month_item_get_type (void)
-{
- static GtkType month_item_type = 0;
-
- if (!month_item_type) {
- GtkTypeInfo month_item_info = {
- "GnomeMonthItem",
- sizeof (GnomeMonthItem),
- sizeof (GnomeMonthItemClass),
- (GtkClassInitFunc) gnome_month_item_class_init,
- (GtkObjectInitFunc) gnome_month_item_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- month_item_type = gtk_type_unique (gnome_canvas_group_get_type (), &month_item_info);
- }
-
- return month_item_type;
-}
-
-static void
-gnome_month_item_class_init (GnomeMonthItemClass *class)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass *) class;
- item_class = (GnomeCanvasItemClass *) class;
-
- parent_class = gtk_type_class (gnome_canvas_group_get_type ());
-
- gtk_object_add_arg_type ("GnomeMonthItem::year", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_YEAR);
- gtk_object_add_arg_type ("GnomeMonthItem::month", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_MONTH);
- gtk_object_add_arg_type ("GnomeMonthItem::x", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_X);
- gtk_object_add_arg_type ("GnomeMonthItem::y", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_Y);
- gtk_object_add_arg_type ("GnomeMonthItem::width", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_WIDTH);
- gtk_object_add_arg_type ("GnomeMonthItem::height", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_HEIGHT);
- gtk_object_add_arg_type ("GnomeMonthItem::anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_ANCHOR);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_padding", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_HEAD_PADDING);
- gtk_object_add_arg_type ("GnomeMonthItem::day_padding", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_DAY_PADDING);
- gtk_object_add_arg_type ("GnomeMonthItem::day_names", GTK_TYPE_POINTER, GTK_ARG_WRITABLE, ARG_DAY_NAMES);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_height", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_HEADING_HEIGHT);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_HEADING_ANCHOR);
- gtk_object_add_arg_type ("GnomeMonthItem::day_anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_DAY_ANCHOR);
- gtk_object_add_arg_type ("GnomeMonthItem::start_on_monday", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_START_ON_MONDAY);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_font", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_HEAD_FONT);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_fontset", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_HEAD_FONTSET);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_font_gdk", GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_HEAD_FONT_GDK);
- gtk_object_add_arg_type ("GnomeMonthItem::day_font", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_FONT);
- gtk_object_add_arg_type ("GnomeMonthItem::day_fontset", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_FONTSET);
- gtk_object_add_arg_type ("GnomeMonthItem::day_font_gdk", GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_DAY_FONT_GDK);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_HEAD_COLOR);
- gtk_object_add_arg_type ("GnomeMonthItem::heading_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_HEAD_COLOR_GDK);
- gtk_object_add_arg_type ("GnomeMonthItem::outline_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_OUTLINE_COLOR);
- gtk_object_add_arg_type ("GnomeMonthItem::outline_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_OUTLINE_COLOR_GDK);
- gtk_object_add_arg_type ("GnomeMonthItem::day_box_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_BOX_COLOR);
- gtk_object_add_arg_type ("GnomeMonthItem::day_box_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_DAY_BOX_COLOR_GDK);
- gtk_object_add_arg_type ("GnomeMonthItem::day_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_COLOR);
- gtk_object_add_arg_type ("GnomeMonthItem::day_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_DAY_COLOR_GDK);
-
- object_class->destroy = gnome_month_item_destroy;
- object_class->set_arg = gnome_month_item_set_arg;
- object_class->get_arg = gnome_month_item_get_arg;
-}
-
-/* Calculates the minimum heading height based on the heading font size and padding. It also
- * calculates the minimum width of the month item based on the width of the headings.
- */
-static void
-check_heading_sizes (GnomeMonthItem *mitem)
-{
- double m_height;
- double m_width;
- int width;
- int max_width;
- int i;
-
- /* Calculate minimum height */
-
- m_height = mitem->head_font->ascent + mitem->head_font->descent + 2 * mitem->head_padding;
-
- if (mitem->head_height < m_height)
- mitem->head_height = m_height;
-
- /* Go through each heading and remember the widest one */
-
- max_width = 0;
-
- for (i = 0; i < 7; i++) {
- width = gdk_string_width (mitem->head_font, mitem->day_names[i]);
- if (max_width < width)
- max_width = width;
- }
-
- m_width = 7 * (max_width + 2 * mitem->head_padding);
-
- if (mitem->width < m_width)
- mitem->width = m_width;
-}
-
-/* Calculates the minimum width and height of the month item based on the day font size and padding.
- * Assumes that the minimum heading height has already been computed.
- */
-static void
-check_day_sizes (GnomeMonthItem *mitem)
-{
- double m_height;
- double m_width;
- int width;
- int max_width;
- char buf[100];
- int i;
-
- /* Calculate minimum height */
-
- m_height = mitem->head_height + 6 * (mitem->day_font->ascent + mitem->day_font->descent + 2 * mitem->day_padding);
-
- if (mitem->height < m_height)
- mitem->height = m_height;
-
- /* Calculate minimum width */
-
- max_width = 0;
-
- for (i = 1; i < 32; i++) {
- sprintf (buf, "%d", i);
- width = gdk_string_width (mitem->day_font, buf);
- if (max_width < width)
- max_width = width;
- }
-
- m_width = 7 * (max_width + 2 * mitem->day_padding);
-
- if (mitem->width < m_width)
- mitem->width = m_width;
-}
-
-/* Calculates the minimum size of the month item based on the font sizes and paddings. If the
- * current size of the month item is smaller than the required minimum size, this function will
- * change the size to the appropriate values.
- */
-static void
-check_sizes (GnomeMonthItem *mitem)
-{
- check_heading_sizes (mitem);
- check_day_sizes (mitem);
-}
-
-/* Recalculates the position of the toplevel calendar group based on the logical position and anchor */
-static void
-reanchor (GnomeMonthItem *mitem)
-{
- double x, y;
-
- x = mitem->x;
- y = mitem->y;
-
- switch (mitem->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- x -= mitem->width / 2;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- x -= mitem->width;
- break;
- }
-
- switch (mitem->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- y -= mitem->height / 2;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- y -= mitem->height;
- break;
- }
-
- /* Explicitly use the canvas group class prefix since the month item class has x and y
- * arguments as well.
- */
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "GnomeCanvasGroup::x", x,
- "GnomeCanvasGroup::y", y,
- NULL);
-}
-
-/* Takes an anchor specification and the corners of a rectangle, and returns an anchored point with
- * respect to that rectangle.
- */
-static void
-get_label_anchor (GtkAnchorType anchor, double x1, double y1, double x2, double y2, double *x, double *y)
-{
- switch (anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- *x = x1;
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- *x = (x1 + x2) / 2.0;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- *x = x2;
- break;
- }
-
- switch (anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- *y = y1;
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- *y = (y1 + y2) / 2.0;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- *y = y2;
- break;
- }
-}
-
-/* Resets the position of the day name headings in the calendar */
-static void
-reshape_headings (GnomeMonthItem *mitem)
-{
- double width;
- int i;
- double x, y;
-
- width = mitem->width / 7;
-
- for (i = 0; i < 7; i++) {
- /* Group */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i],
- "x", width * i,
- "y", 0.0,
- NULL);
-
- /* Box */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i],
- "x1", 0.0,
- "y1", 0.0,
- "x2", width,
- "y2", mitem->head_height,
- NULL);
-
- /* Label */
- get_label_anchor (mitem->head_anchor,
- mitem->head_padding,
- mitem->head_padding,
- width - mitem->head_padding,
- mitem->head_height - mitem->head_padding,
- &x, &y);
-
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i],
- "x", x,
- "y", y,
- "anchor", mitem->head_anchor,
- NULL);
- }
-}
-
-/* Resets the position of the days in the calendar */
-static void
-reshape_days (GnomeMonthItem *mitem)
-{
- double width, height;
- double x, y;
- int row, col;
- int i;
-
- width = mitem->width / 7;
- height = (mitem->height - mitem->head_height) / 6;
-
- i = 0;
-
- for (row = 0; row < 6; row++)
- for (col = 0; col < 7; col++) {
- /* Group */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i],
- "x", width * col,
- "y", mitem->head_height + height * row,
- NULL);
-
- /* Box */
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i],
- "x1", 0.0,
- "y1", 0.0,
- "x2", width,
- "y2", height,
- NULL);
-
- /* Label */
- get_label_anchor (mitem->day_anchor,
- mitem->day_padding,
- mitem->day_padding,
- width - mitem->day_padding,
- height - mitem->day_padding,
- &x, &y);
-
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "x", x,
- "y", y,
- "anchor", mitem->day_anchor,
- NULL);
-
- i++;
- }
-}
-
-/* Changes the positions and resizes the items in the calendar to match the new size of the
- * calendar.
- */
-static void
-reshape (GnomeMonthItem *mitem)
-{
- check_sizes (mitem);
- reanchor (mitem);
- reshape_headings (mitem);
- reshape_days (mitem);
-}
-
-/* Sets the font for all the day headings */
-static void
-set_head_font (GnomeMonthItem *mitem)
-{
- int i;
-
- for (i = 0; i < 7; i++)
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i],
- "font_gdk", mitem->head_font,
- NULL);
-}
-
-/* Sets the color for all the headings */
-static void
-set_head_color (GnomeMonthItem *mitem)
-{
- int i;
- GdkColor outline;
- GdkColor head;
-
- outline.pixel = mitem->outline_pixel;
- head.pixel = mitem->head_pixel;
-
- for (i = 0; i < 7; i++) {
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i],
- "fill_color_gdk", &outline,
- NULL);
-
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i],
- "fill_color_gdk", &head,
- NULL);
- }
-}
-
-/* Creates the items for the day name headings */
-static void
-create_headings (GnomeMonthItem *mitem)
-{
- int i;
-
- /* Just create the items; they will be positioned and configured by a call to reshape() */
-
- for (i = 0; i < 7; i++) {
- /* Group */
- mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem),
- gnome_canvas_group_get_type (),
- NULL);
-
- /* Box */
- mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i]),
- gnome_canvas_rect_get_type (),
- NULL);
-
- /* Label */
- mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i]),
- gnome_canvas_text_get_type (),
- NULL);
- }
-
- set_head_font (mitem);
- set_head_color (mitem);
-}
-
-/* Returns the number of leap years since year 1 up to (but not including) the specified year */
-static int
-leap_years_up_to (int year)
-{
- return (year / 4 /* trivial leapness */
- - ((year > 1700) ? (year / 100 - 17) : 0) /* minus centuries since 1700 */
- + ((year > 1600) ? ((year - 1600) / 400) : 0)); /* plus centuries since 1700 divisible by 400 */
-}
-
-/* Returns whether the specified year is a leap year */
-static int
-is_leap_year (int year)
-{
- if (year <= 1752)
- return !(year % 4);
- else
- return (!(year % 4) && (year % 100)) || !(year % 400);
-}
-
-/* Returns the 1-based day number within the year of the specified date */
-static int
-day_in_year (int day, int month, int year)
-{
- int is_leap, i;
-
- is_leap = is_leap_year (year);
-
- for (i = 0; i < month; i++)
- day += days_in_month [is_leap][i];
-
- return day;
-}
-
-/* Returns the day of the week (zero-based, zero is Sunday) for the specified date. For the days
- * that were removed on the Gregorian reformation, it returns Thursday.
- */
-static int
-day_in_week (int day, int month, int year)
-{
- int n;
-
- n = (year - 1) * 365 + leap_years_up_to (year - 1) + day_in_year (day, month, year);
-
- if (n < REFORMATION_DAY)
- return (n - 1 + SATURDAY) % 7;
-
- if (n >= (REFORMATION_DAY + MISSING_DAYS))
- return (n - 1 + SATURDAY - MISSING_DAYS) % 7;
-
- return THURSDAY;
-}
-
-/* Fills the 42-element days array with the day numbers for the specified month. Slots outside the
- * bounds of the month are filled with zeros. The starting and ending indexes of the days are
- * returned in the start and end arguments.
- */
-static void
-build_month (int month, int year, int start_on_monday, int *days, int *start, int *end)
-{
- int i;
- int d_month, d_week;
-
- /* Note that months are zero-based, so September is month 8 */
-
- if ((year == 1752) && (month == 8)) {
- memcpy (days, sept_1752, 42 * sizeof (int));
-
- if (start)
- *start = SEPT_1752_START;
-
- if (end)
- *end = SEPT_1752_END;
-
- return;
- }
-
- for (i = 0; i < 42; i++)
- days[i] = 0;
-
- d_month = days_in_month[is_leap_year (year)][month];
- d_week = day_in_week (1, month, year);
-
- if (start_on_monday)
- d_week = (d_week + 6) % 7;
-
- for (i = 0; i < d_month; i++)
- days[d_week + i] = i + 1;
-
- if (start)
- *start = d_week;
-
- if (end)
- *end = d_week + d_month - 1;
-}
-
-/* Set the day numbers in the monthly calendar */
-static void
-set_days (GnomeMonthItem *mitem)
-{
- int i;
- int start, end;
- char buf[100];
-
- build_month (mitem->month, mitem->year, mitem->start_on_monday, mitem->day_numbers, &start, &end);
-
- /* Clear days before start of month */
-
- for (i = 0; i < start; i++)
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "text", NULL,
- NULL);
-
- /* Set days of month */
-
- for (; start <= end; start++, i++) {
- sprintf (buf, "%d", mitem->day_numbers[start]);
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "text", buf,
- NULL);
- }
-
- /* Clear days after end of month */
-
- for (; i < 42; i++)
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "text", NULL,
- NULL);
-}
-
-/* Sets the font for all the day numbers */
-static void
-set_day_font (GnomeMonthItem *mitem)
-{
- int i;
-
- for (i = 0; i < 42; i++)
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "font_gdk", mitem->day_font,
- NULL);
-}
-
-/* Sets the color for all the day items */
-static void
-set_day_color (GnomeMonthItem *mitem)
-{
- int i;
- GdkColor outline;
- GdkColor day_box;
- GdkColor day;
-
- outline.pixel = mitem->outline_pixel;
- day_box.pixel = mitem->day_box_pixel;
- day.pixel = mitem->day_pixel;
-
- for (i = 0; i < 42; i++) {
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i],
- "outline_color_gdk", &outline,
- "fill_color_gdk", &day_box,
- NULL);
-
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i],
- "fill_color_gdk", &day,
- NULL);
- }
-}
-
-/* Creates the items for the days */
-static void
-create_days (GnomeMonthItem *mitem)
-{
- int i;
-
- /* Just create the items; they will be positioned and configured by a call to reshape() */
-
- for (i = 0; i < 42; i++) {
- /* Group */
- mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem),
- gnome_canvas_group_get_type (),
- NULL);
-
- /* Box */
- mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i]),
- gnome_canvas_rect_get_type (),
- NULL);
-
- /* Label */
- mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i] =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i]),
- gnome_canvas_text_get_type (),
- NULL);
- }
-
- set_day_font (mitem);
- set_day_color (mitem);
- set_days (mitem);
-}
-
-/* Resets the text of the day name headings */
-static void
-set_day_names (GnomeMonthItem *mitem)
-{
- int i;
-
- for (i = 0; i < 7; i++)
- gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i],
- "text", mitem->day_names[mitem->start_on_monday ? ((i + 1) % 7) : i],
- NULL);
-}
-
-/* Creates all the canvas items that make up the calendar */
-static void
-create_items (GnomeMonthItem *mitem)
-{
- mitem->items = g_new (GnomeCanvasItem *, GNOME_MONTH_ITEM_LAST);
-
- create_headings (mitem);
- create_days (mitem);
-
- /* Initialize by default to three-letter day names */
-
- mitem->day_names[0] = g_strdup (_("Sun"));
- mitem->day_names[1] = g_strdup (_("Mon"));
- mitem->day_names[2] = g_strdup (_("Tue"));
- mitem->day_names[3] = g_strdup (_("Wed"));
- mitem->day_names[4] = g_strdup (_("Thu"));
- mitem->day_names[5] = g_strdup (_("Fri"));
- mitem->day_names[6] = g_strdup (_("Sat"));
-
- set_day_names (mitem);
- reshape (mitem);
-}
-
-static void
-gnome_month_item_init (GnomeMonthItem *mitem)
-{
- time_t t;
- struct tm tm;
-
- /* Initialize to the current month by default */
-
- t = time (NULL);
- tm = *localtime (&t);
-
- mitem->year = tm.tm_year + 1900;
- mitem->month = tm.tm_mon;
-
- mitem->x = 0.0;
- mitem->y = 0.0;
- mitem->width = 150.0; /* not unreasonable defaults, I hope */
- mitem->height = 100.0;
- mitem->anchor = GTK_ANCHOR_NW;
- mitem->head_padding = 0.0;
- mitem->day_padding = 2.0;
- mitem->head_height = 14.0;
- mitem->head_anchor = GTK_ANCHOR_CENTER;
- mitem->day_anchor = GTK_ANCHOR_CENTER;
-
- /* Load the default fonts */
-
- mitem->head_font = gdk_font_load (DEFAULT_FONT);
- if (!mitem->head_font) {
- mitem->head_font = gdk_font_load ("fixed");
- g_assert (mitem->head_font != NULL);
- }
-
- mitem->day_font = gdk_font_load (DEFAULT_FONT);
- if (!mitem->day_font) {
- mitem->day_font = gdk_font_load ("fixed");
- g_assert (mitem->day_font != NULL);
- }
-}
-
-GnomeCanvasItem *
-gnome_month_item_new (GnomeCanvasGroup *parent)
-{
- GnomeMonthItem *mitem;
-
- g_return_val_if_fail (parent != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CANVAS_GROUP (parent), NULL);
-
- mitem = GNOME_MONTH_ITEM (gnome_canvas_item_new (parent,
- gnome_month_item_get_type (),
- NULL));
-
- gnome_month_item_construct (mitem);
-
- return GNOME_CANVAS_ITEM (mitem);
-}
-
-void
-gnome_month_item_construct (GnomeMonthItem *mitem)
-{
- GdkColor color;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
-
- gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, "#d6d6d6d6d6d6", &color);
- mitem->head_pixel = color.pixel;
- mitem->day_box_pixel = color.pixel;
-
- gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, "black", &color);
- mitem->outline_pixel = color.pixel;
- mitem->day_pixel = color.pixel;
-
- create_items (mitem);
-}
-
-static void
-free_day_names (GnomeMonthItem *mitem)
-{
- int i;
-
- if (mitem->day_names[0])
- for (i = 0; i < 7; i++)
- g_free (mitem->day_names[i]);
-}
-
-static void
-gnome_month_item_destroy (GtkObject *object)
-{
- GnomeMonthItem *mitem;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (object));
-
- mitem = GNOME_MONTH_ITEM (object);
-
- free_day_names (mitem);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-/* Sets the color of the specified pixel value to that of the specified argument, which must be in
- * GdkColor format if format is TRUE, otherwise it must be in string format.
- */
-static void
-set_color_arg (GnomeMonthItem *mitem, gulong *pixel, GtkArg *arg, int gdk_format, int set_head, int set_day)
-{
- GdkColor color;
-
- if (gdk_format)
- *pixel = ((GdkColor *) GTK_VALUE_BOXED (*arg))->pixel;
- else {
- if (gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, GTK_VALUE_STRING (*arg), &color))
- *pixel = color.pixel;
- else
- *pixel = 0;
- }
-
- if (set_head)
- set_head_color (mitem);
-
- if (set_day)
- set_day_color (mitem);
-}
-
-static void
-gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- GnomeMonthItem *mitem;
- char **day_names;
- int i;
-
- mitem = GNOME_MONTH_ITEM (object);
-
- switch (arg_id) {
- case ARG_YEAR:
- mitem->year = GTK_VALUE_UINT (*arg);
- set_days (mitem);
- break;
-
- case ARG_MONTH:
- mitem->month = GTK_VALUE_UINT (*arg);
- set_days (mitem);
- break;
-
- case ARG_X:
- mitem->x = GTK_VALUE_DOUBLE (*arg);
- reanchor (mitem);
- break;
-
- case ARG_Y:
- mitem->y = GTK_VALUE_DOUBLE (*arg);
- reanchor (mitem);
- break;
-
- case ARG_WIDTH:
- mitem->width = fabs (GTK_VALUE_DOUBLE (*arg));
- reshape (mitem);
- break;
-
- case ARG_HEIGHT:
- mitem->height = fabs (GTK_VALUE_DOUBLE (*arg));
- reshape (mitem);
- break;
-
- case ARG_ANCHOR:
- mitem->anchor = GTK_VALUE_ENUM (*arg);
- reanchor (mitem);
- break;
-
- case ARG_HEAD_PADDING:
- mitem->head_padding = fabs (GTK_VALUE_DOUBLE (*arg));
- reshape (mitem);
- break;
-
- case ARG_DAY_PADDING:
- mitem->day_padding = fabs (GTK_VALUE_DOUBLE (*arg));
- reshape (mitem);
- break;
-
- case ARG_DAY_NAMES:
- day_names = GTK_VALUE_POINTER (*arg);
-
- /* First, check that none of the names is null */
-
- for (i = 0; i < 7; i++)
- if (!day_names[i]) {
- g_warning ("Day number %d was NULL; day names cannot be NULL!", i);
- return;
- }
-
- /* Set the new names */
-
- free_day_names (mitem);
- for (i = 0; i < 7; i++)
- mitem->day_names[i] = g_strdup (day_names[i]);
-
- set_day_names (mitem);
- reshape (mitem);
- break;
-
- case ARG_HEADING_HEIGHT:
- mitem->head_height = fabs (GTK_VALUE_DOUBLE (*arg));
- reshape (mitem);
- break;
-
- case ARG_HEADING_ANCHOR:
- mitem->head_anchor = GTK_VALUE_ENUM (*arg);
- reshape (mitem);
- break;
-
- case ARG_DAY_ANCHOR:
- mitem->day_anchor = GTK_VALUE_ENUM (*arg);
- reshape (mitem);
- break;
-
- case ARG_START_ON_MONDAY:
- mitem->start_on_monday = GTK_VALUE_BOOL (*arg);
- set_day_names (mitem);
- set_days (mitem);
- break;
-
- case ARG_HEAD_FONT:
- gdk_font_unref (mitem->head_font);
-
- mitem->head_font = gdk_font_load (GTK_VALUE_STRING (*arg));
- if (!mitem->head_font) {
- mitem->head_font = gdk_font_load ("fixed");
- g_assert (mitem->head_font != NULL);
- }
-
- set_head_font (mitem);
- reshape (mitem);
- break;
-
- case ARG_HEAD_FONTSET:
- gdk_font_unref (mitem->head_font);
-
- mitem->head_font = gdk_fontset_load (GTK_VALUE_STRING (*arg));
- if (!mitem->head_font) {
- mitem->head_font =
- gdk_fontset_load ("-*-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-*");
- g_assert (mitem->head_font != NULL);
- }
-
- set_head_font (mitem);
- reshape (mitem);
- break;
-
- case ARG_HEAD_FONT_GDK:
- gdk_font_unref (mitem->head_font);
-
- mitem->head_font = GTK_VALUE_BOXED (*arg);
- gdk_font_ref (mitem->head_font);
- set_head_font (mitem);
- reshape (mitem);
- break;
-
- case ARG_DAY_FONT:
- gdk_font_unref (mitem->day_font);
-
- mitem->day_font = gdk_font_load (GTK_VALUE_STRING (*arg));
- if (!mitem->day_font) {
- mitem->day_font = gdk_font_load ("fixed");
- g_assert (mitem->day_font != NULL);
- }
-
- set_day_font (mitem);
- reshape (mitem);
- break;
-
- case ARG_DAY_FONTSET:
- gdk_font_unref (mitem->day_font);
-
- mitem->day_font = gdk_fontset_load (GTK_VALUE_STRING (*arg));
- if (!mitem->day_font) {
- mitem->day_font =
- gdk_fontset_load ("-*-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-*");
- g_assert (mitem->day_font != NULL);
- }
-
- set_day_font (mitem);
- reshape (mitem);
- break;
-
- case ARG_DAY_FONT_GDK:
- gdk_font_unref (mitem->day_font);
-
- mitem->day_font = GTK_VALUE_BOXED (*arg);
- gdk_font_ref (mitem->day_font);
- set_day_font (mitem);
- reshape (mitem);
- break;
-
- case ARG_HEAD_COLOR:
- set_color_arg (mitem, &mitem->head_pixel, arg, FALSE, TRUE, FALSE);
- break;
-
- case ARG_HEAD_COLOR_GDK:
- set_color_arg (mitem, &mitem->head_pixel, arg, TRUE, TRUE, FALSE);
- break;
-
- case ARG_OUTLINE_COLOR:
- set_color_arg (mitem, &mitem->outline_pixel, arg, FALSE, TRUE, TRUE);
- break;
-
- case ARG_OUTLINE_COLOR_GDK:
- set_color_arg (mitem, &mitem->outline_pixel, arg, TRUE, TRUE, TRUE);
- break;
-
- case ARG_DAY_BOX_COLOR:
- set_color_arg (mitem, &mitem->day_box_pixel, arg, FALSE, FALSE, TRUE);
- break;
-
- case ARG_DAY_BOX_COLOR_GDK:
- set_color_arg (mitem, &mitem->day_box_pixel, arg, TRUE, FALSE, TRUE);
- break;
-
- case ARG_DAY_COLOR:
- set_color_arg (mitem, &mitem->day_pixel, arg, FALSE, FALSE, TRUE);
- break;
-
- case ARG_DAY_COLOR_GDK:
- set_color_arg (mitem, &mitem->day_pixel, arg, TRUE, FALSE, TRUE);
- break;
-
- default:
- break;
- }
-}
-
-/* Allocates a GdkColor structure filled with the specified pixel, and puts it into the specified
- * arg for returning it in the get_arg method.
- */
-static void
-get_color_arg (GnomeMonthItem *mitem, gulong pixel, GtkArg *arg)
-{
- GdkColor *color;
-
- color = g_new (GdkColor, 1);
- color->pixel = pixel;
- gdk_color_context_query_color (GNOME_CANVAS_ITEM (mitem)->canvas->cc, color);
- GTK_VALUE_BOXED (*arg) = color;
-}
-
-static void
-gnome_month_item_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- GnomeMonthItem *mitem;
-
- mitem = GNOME_MONTH_ITEM (object);
-
- switch (arg_id) {
- case ARG_YEAR:
- GTK_VALUE_UINT (*arg) = mitem->year;
- break;
-
- case ARG_MONTH:
- GTK_VALUE_UINT (*arg) = mitem->month;
- break;
-
- case ARG_X:
- GTK_VALUE_DOUBLE (*arg) = mitem->x;
- break;
-
- case ARG_Y:
- GTK_VALUE_DOUBLE (*arg) = mitem->y;
- break;
-
- case ARG_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = mitem->width;
- break;
-
- case ARG_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = mitem->height;
- break;
-
- case ARG_ANCHOR:
- GTK_VALUE_ENUM (*arg) = mitem->anchor;
- break;
-
- case ARG_HEAD_PADDING:
- GTK_VALUE_DOUBLE (*arg) = mitem->head_padding;
- break;
-
- case ARG_DAY_PADDING:
- GTK_VALUE_DOUBLE (*arg) = mitem->day_padding;
- break;
-
- case ARG_HEADING_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = mitem->head_height;
- break;
-
- case ARG_HEADING_ANCHOR:
- GTK_VALUE_ENUM (*arg) = mitem->head_anchor;
- break;
-
- case ARG_DAY_ANCHOR:
- GTK_VALUE_ENUM (*arg) = mitem->day_anchor;
- break;
-
- case ARG_START_ON_MONDAY:
- GTK_VALUE_BOOL (*arg) = mitem->start_on_monday;
- break;
-
- case ARG_HEAD_FONT_GDK:
- GTK_VALUE_BOXED (*arg) = mitem->head_font;
- break;
-
- case ARG_DAY_FONT_GDK:
- GTK_VALUE_BOXED (*arg) = mitem->day_font;
- break;
-
- case ARG_HEAD_COLOR_GDK:
- get_color_arg (mitem, mitem->head_pixel, arg);
- break;
-
- case ARG_OUTLINE_COLOR_GDK:
- get_color_arg (mitem, mitem->outline_pixel, arg);
- break;
-
- case ARG_DAY_BOX_COLOR_GDK:
- get_color_arg (mitem, mitem->day_box_pixel, arg);
- break;
-
- case ARG_DAY_COLOR_GDK:
- get_color_arg (mitem, mitem->day_pixel, arg);
- break;
-
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-GnomeCanvasItem *
-gnome_month_item_num2child (GnomeMonthItem *mitem, int child_num)
-{
- g_return_val_if_fail (mitem != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), NULL);
-
- return mitem->items[child_num];
-}
-
-int
-gnome_month_item_child2num (GnomeMonthItem *mitem, GnomeCanvasItem *child)
-{
- int i;
-
- g_return_val_if_fail (mitem != NULL, -1);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), -1);
- g_return_val_if_fail (child != NULL, -1);
- g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (child), -1);
-
- for (i = 0; i < GNOME_MONTH_ITEM_LAST; i++)
- if (mitem->items[i] == child)
- return i;
-
- return -1;
-}
-
-int
-gnome_month_item_num2day (GnomeMonthItem *mitem, int child_num)
-{
- g_return_val_if_fail (mitem != NULL, 0);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), 0);
-
- if ((child_num >= GNOME_MONTH_ITEM_DAY_GROUP) && (child_num < GNOME_MONTH_ITEM_LAST)) {
- child_num = (child_num - GNOME_MONTH_ITEM_DAY_GROUP) % 42;
- return mitem->day_numbers[child_num];
- } else
- return 0;
-}
-
-int
-gnome_month_item_day2index (GnomeMonthItem *mitem, int day_num)
-{
- int i;
-
- g_return_val_if_fail (mitem != NULL, -1);
- g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), -1);
- g_return_val_if_fail (day_num >= 1, -1);
-
- /* Find first day of month */
-
- for (i = 0; mitem->day_numbers[i] == 0; i++)
- ;
-
- /* Find the specified day */
-
- for (; (mitem->day_numbers[i] != 0) && (i < 42); i++)
- if (mitem->day_numbers[i] == day_num)
- return i;
-
- /* Bail out */
-
- return -1;
-}
diff --git a/calendar/gui/gnome-month-item.h b/calendar/gui/gnome-month-item.h
deleted file mode 100644
index 0ec4fd484c..0000000000
--- a/calendar/gui/gnome-month-item.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/* General-purpose monthly calendar canvas item for GNOME
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef GNOME_MONTH_ITEM_H
-#define GNOME_MONTH_ITEM_H
-
-#include <libgnome/gnome-defs.h>
-#include <gtk/gtkpacker.h> /* why the hell is GtkAnchorType here and not in gtkenums.h? */
-#include <libgnomeui/gnome-canvas.h>
-
-
-BEGIN_GNOME_DECLS
-
-
-/* These values are used to identify the canvas items that make up a complete GnomeMonthItem, which
- * is made up of the following "pieces":
- *
- * Headings line:
- * - 7 GnomeCanvasGroups:
- * Each group contains one box (GnomeCanvasRectangle) and one label
- * (GnomeCanvasText)
- *
- * Day slots:
- * - 42 GnomeCanvasGroups:
- * Each group contains one box (GnomeCanvasRectangle) and one label
- * (GnomeCanvasText)
- *
- * The headings are organized from left to right. The day slots are organized as a table in
- * row-major order.
- *
- * If you want to access the individual items of the GnomeMonthItem, you can use these numbers with
- * the gnome_month_item_num2child() function. If you want to convert a number into the
- * corresponding GnomeCanvasItem, you can use the gnome_month_item_child2num() function.
- */
-typedef enum {
- GNOME_MONTH_ITEM_HEAD_GROUP = 0, /* 7 groups for headings */
- GNOME_MONTH_ITEM_HEAD_BOX = 7, /* 7 boxes for headings */
- GNOME_MONTH_ITEM_HEAD_LABEL = 14, /* 7 labels for headings */
- GNOME_MONTH_ITEM_DAY_GROUP = 21, /* 42 groups for days */
- GNOME_MONTH_ITEM_DAY_BOX = 63, /* 42 boxes for days */
- GNOME_MONTH_ITEM_DAY_LABEL = 105, /* 42 labels for days */
- GNOME_MONTH_ITEM_LAST = 147 /* total number of items */
-} GnomeMonthItemChild;
-
-/* The MonthItem canvas item defines a simple monthly calendar. It is made out of a number of
- * canvas items, which can be accessed using the functions provided. The monthly calendar is
- * anchored with respect to a point. The following arguments are available:
- *
- * name type read/write description
- * ------------------------------------------------------------------------------------------
- * year uint RW Full year (1-9999)
- * month uint RW Number of month (0-11)
- * x double RW X position of anchor point
- * y double RW Y position of anchor point
- * width double RW Width of calendar in canvas units
- * height double RW Height of calendar in canvas units
- * anchor GtkAnchorType RW Anchor side for calendar
- * heading_padding double RW Padding inside heading boxes
- * day_padding double RW Padding inside day boxes
- * day_names char ** W Array of strings corresponding to the day names (sun-sat)
- * heading_height double RW Height of headings bar in canvas units
- * heading_anchor GtkAnchorType RW Anchor side for headings inside heading boxes
- * day_anchor GtkAnchorType RW Anchor side for day numbers inside day boxes
- * start_on_monday boolean RW Specifies whether the week starts on Monday or Sunday
- * heading_font string W X logical font descriptor for the headings
- * heading_fontset string W X logical fontset descriptor for the headings
- * heading_font_gdk GdkFont * RW Pointer to GdkFont for the headings
- * day_font string W X logical font descriptor for the day numbers
- * day_fontset string W X logical fontset descriptor for the day numbers
- * day_font_gdk GdkFont * RW Pointer to GdkFont for the day numbers
- * heading_color string W X color specification for heading labels
- * heading_color_gdk GdkColor * RW Pointer to an allocated GdkColor for heading labels
- * outline_color string W X color specification for outline (lines and fill of heading boxes)
- * outline_color_gdk GdkColor * RW Pointer to an allocated GdkColor for outline
- * day_box_color string W X color specification for day boxes
- * day_box_color_gdk GdkColor * RW Pointer to an allocated GdkColor for day boxes
- * day_color string W X color specification for day number labels
- * day_color_gdk GdkColor * RW Pointer to an allocated GdkColor for day number labels
- */
-
-#define GNOME_TYPE_MONTH_ITEM (gnome_month_item_get_type ())
-#define GNOME_MONTH_ITEM(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_MONTH_ITEM, GnomeMonthItem))
-#define GNOME_MONTH_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GNOME_TYPE_MONTH_ITEM, GnomeMonthItemClass))
-#define GNOME_IS_MONTH_ITEM(obj) (GTK_CHECK_TYPE ((obj), GNOME_TYPE_MONTH_ITEM))
-#define GNOME_IS_MONTH_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_MONTH_ITEM))
-
-
-typedef struct _GnomeMonthItem GnomeMonthItem;
-typedef struct _GnomeMonthItemClass GnomeMonthItemClass;
-
-struct _GnomeMonthItem {
- GnomeCanvasGroup group;
-
- int year; /* Year to show (full, no two-digit crap) */
- int month; /* Month to show (0-11) */
-
- double x, y; /* Position at anchor */
- double width, height; /* Size of calendar */
- GtkAnchorType anchor; /* Anchor side for calendar */
-
- double head_padding; /* Padding to use between heading lines and text */
- double day_padding; /* Padding to use between day number lines and text */
-
- char *day_names[7]; /* Names to use for the day labels, starting from Sunday */
-
- double head_height; /* Height of the headings row */
- GtkAnchorType head_anchor; /* Anchor side for the heading labels */
- GtkAnchorType day_anchor; /* Anchor side for the day number labels */
-
- GnomeCanvasItem **items; /* All the items that make up the calendar */
- int day_numbers[42]; /* The numbers of the days, as they are shown in the display */
-
- GdkFont *head_font; /* Font for the headings */
- GdkFont *day_font; /* Font for the day numbers */
-
- gulong head_pixel; /* Color for heading labels */
- gulong outline_pixel; /* Color for the outline (lines and heading boxes) */
- gulong day_box_pixel; /* Color for the day boxes */
- gulong day_pixel; /* Color for day number labels */
-
- int start_on_monday : 1; /* Start the week on Monday? If false, then start from Sunday */
-};
-
-struct _GnomeMonthItemClass {
- GnomeCanvasGroupClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType gnome_month_item_get_type (void);
-
-/* Creates a new month item with the specified group as parent */
-GnomeCanvasItem *gnome_month_item_new (GnomeCanvasGroup *parent);
-
-/* Constructor function useful for derived classes */
-void gnome_month_item_construct (GnomeMonthItem *mitem);
-
-/* Returns the child item defined by the child number (as specified on the GnomeMonthItemChild
- * enumeration above).
- */
-GnomeCanvasItem *gnome_month_item_num2child (GnomeMonthItem *mitem, int child_num);
-
-/* Returns the number of the specified child item, as defined on the GnomeMonthItemChild enumeration
- * above. If the specified object is not found, it returns -1.
- */
-int gnome_month_item_child2num (GnomeMonthItem *mitem, GnomeCanvasItem *child);
-
-/* Returns the number of the day relevant to the specified child item. Day numbers are 1-based. If
- * the specified child is outside the range of displayed days, then it returns 0.
- */
-int gnome_month_item_num2day (GnomeMonthItem *mitem, int child_num);
-
-/* Returns the index (0-41) of the specified date within the table of days. If the day number is
- * invalid for the current monthly calendar, then -1 is returned.
- */
-int gnome_month_item_day2index (GnomeMonthItem *mitem, int day_num);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gnomecal.gnorba b/calendar/gui/gnomecal.gnorba
deleted file mode 100644
index 74df8ecf04..0000000000
--- a/calendar/gui/gnomecal.gnorba
+++ /dev/null
@@ -1,11 +0,0 @@
-[IDL:GNOME:Calendar:Repository:1.0]
-type=factory
-repo_id=IDL:Gnome/Calendar/Repository:1.0
-description=Calendar Repository
-location_info=IDL:GNOME:Calendar:RepositoryLocator:1.0
-
-[IDL:GNOME:Calendar:RepositoryLocator:1.0]
-type=exe
-repo_id=IDL:GNOME/GenericFactory:1.0
-description=Calendar Server
-location_info=gnomecal
diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c
deleted file mode 100644
index 41609da678..0000000000
--- a/calendar/gui/goto.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/* Go to date dialog for gnomecal
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include <gnome.h>
-#include "gnome-cal.h"
-#include "gnome-month-item.h"
-#include "main.h"
-#include "mark.h"
-#include "timeutil.h"
-
-
-static GtkWidget *goto_win; /* The goto dialog window */
-static GnomeMonthItem *month_item; /* The month item in the dialog */
-static GnomeCalendar *gnome_calendar; /* The gnome calendar the dialog refers to */
-static int current_index; /* The index of the day marked as current, or -1 if none */
-
-
-/* Updates the specified month item by marking it appropriately from the calendar the dialog refers
- * to. Also marks the current day if appropriate.
- */
-static void
-update (void)
-{
- GnomeCanvasItem *item;
- time_t t;
- struct tm tm;
-
- unmark_month_item (month_item);
- mark_month_item (month_item, gnome_calendar->cal);
-
- if (current_index != -1) {
- item = gnome_month_item_num2child (month_item,
- GNOME_MONTH_ITEM_DAY_LABEL + current_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
- "fontset", NORMAL_DAY_FONTSET,
- NULL);
- current_index = -1;
- }
-
- t = time (NULL);
- tm = *localtime (&t);
-
- if (((tm.tm_year + 1900) == month_item->year) && (tm.tm_mon == month_item->month)) {
- current_index = gnome_month_item_day2index (month_item, tm.tm_mday);
- g_assert (current_index != -1);
-
- item = gnome_month_item_num2child (month_item,
- GNOME_MONTH_ITEM_DAY_LABEL + current_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
- "fontset", CURRENT_DAY_FONTSET,
- NULL);
- }
-}
-
-/* Callback used when the year adjustment is changed */
-static void
-year_changed (GtkAdjustment *adj, gpointer data)
-{
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
- "year", (int) adj->value,
- NULL);
- update ();
-}
-
-/* Creates the year control with its adjustment */
-static GtkWidget *
-create_year (int year)
-{
- GtkWidget *hbox;
- GtkAdjustment *adj;
- GtkWidget *w;
-
- hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
-
- w = gtk_label_new (_("Year:"));
- gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- adj = GTK_ADJUSTMENT (gtk_adjustment_new (year, 1900, 9999, 1, 10, 10));
- gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
- (GtkSignalFunc) year_changed,
- NULL);
-
- w = gtk_spin_button_new (adj, 1.0, 0);
- gtk_widget_set_usize (w, 60, 0);
- gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- return hbox;
-}
-
-/* Callback used when a month button is toggled */
-static void
-month_toggled (GtkToggleButton *toggle, gpointer data)
-{
- if (!toggle->active)
- return;
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
- "month", GPOINTER_TO_INT (data),
- NULL);
- update ();
-}
-
-/* Creates the months control */
-static GtkWidget *
-create_months (int month)
-{
- GtkWidget *table;
- GtkWidget *w;
- GSList *group;
- int i, row, col;
- struct tm tm;
- char buf[100];
-
- tm = *localtime (&gnome_calendar->current_display);
-
- table = gtk_table_new (2, 6, TRUE);
-
- group = NULL;
-
- for (i = 0; i < 12; i++) {
- row = i / 6;
- col = i % 6;
-
- tm.tm_mon = i;
- strftime (buf, 100, "%b", &tm);
-
- w = gtk_radio_button_new (group);
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (w));
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (w), FALSE);
-
- gtk_container_add (GTK_CONTAINER (w), gtk_label_new (buf));
-
- if (i == month)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (w), TRUE);
-
- gtk_signal_connect (GTK_OBJECT (w), "toggled",
- (GtkSignalFunc) month_toggled,
- GINT_TO_POINTER (i));
- gtk_table_attach (GTK_TABLE (table), w,
- col, col + 1,
- row, row + 1,
- GTK_EXPAND | GTK_FILL,
- GTK_EXPAND | GTK_FILL,
- 0, 0);
- gtk_widget_show_all (w);
- }
-
- return table;
-}
-
-/* Sets the scrolling region of the canvas to the allocation size */
-static void
-set_scroll_region (GtkWidget *widget, GtkAllocation *allocation)
-{
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
- "width", (double) (allocation->width - 1),
- "height", (double) (allocation->height - 1),
- NULL);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (widget),
- 0, 0,
- allocation->width, allocation->height);
-}
-
-/* Event handler for day groups in the month item. A button press makes the calendar jump to the
- * selected day and destroys the Go-to dialog box.
- */
-static gint
-day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- int child_num, day;
-
- child_num = gnome_month_item_child2num (month_item, item);
- day = gnome_month_item_num2day (month_item, child_num);
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if ((event->button.button == 1) && (day != 0)) {
- gnome_calendar_goto (gnome_calendar,
- time_from_day (month_item->year, month_item->month, day));
- gtk_widget_destroy (goto_win);
- }
- break;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-/* Creates the canvas with the month item for selecting days */
-static GtkWidget *
-create_days (int day, int month, int year)
-{
- GtkWidget *canvas;
- int i;
- GnomeCanvasItem *day_group;
-
- canvas = gnome_canvas_new ();
- gtk_widget_set_usize (canvas, 150, 120);
-
- month_item = GNOME_MONTH_ITEM (gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (canvas))));
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
- "month", month,
- "year", year,
- "start_on_monday", week_starts_on_monday,
- NULL);
- colorify_month_item (month_item, default_color_func, NULL);
- month_item_prepare_prelight (month_item, default_color_func, NULL);
- update ();
-
- /* Connect to size_allocate so that we can change the size of the month item and the
- * scrolling region appropriately.
- */
-
- gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate",
- (GtkSignalFunc) set_scroll_region,
- NULL);
-
- /* Bind the day groups to our event handler */
-
- for (i = 0; i < 42; i++) {
- day_group = gnome_month_item_num2child (month_item, i + GNOME_MONTH_ITEM_DAY_GROUP);
- gtk_signal_connect (GTK_OBJECT (day_group), "event",
- (GtkSignalFunc) day_event,
- NULL);
- }
-
- return canvas;
-}
-
-static void
-goto_today (GtkWidget *widget, gpointer data)
-{
- gnome_calendar_goto_today (gnome_calendar);
- gtk_widget_destroy (goto_win);
-}
-
-/* Creates a "goto date" dialog and runs it */
-void
-goto_dialog (GnomeCalendar *gcal)
-{
- GtkWidget *vbox;
- GtkWidget *hbox;
- GtkWidget *w;
- GtkWidget *days;
- struct tm tm;
-
- gnome_calendar = gcal;
- current_index = -1;
-
- tm = *localtime (&gnome_calendar->current_display);
-
- goto_win = gnome_dialog_new (_("Go to date"),
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
- gnome_dialog_set_parent (GNOME_DIALOG (goto_win), GTK_WINDOW (gcal));
-
- vbox = GNOME_DIALOG (goto_win)->vbox;
-
- /* Instructions */
-
- w = gtk_label_new (_("Please select the date you want to go to.\n"
- "When you click on a day, you will be taken\n"
- "to that date."));
- gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT);
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Create month item before creating the year controls, since the latter ones need the
- * month_item to be created.
- */
-
- days = create_days (tm.tm_mday, tm.tm_mon, tm.tm_year + 1900);
-
- /* Year */
-
- w = create_year (tm.tm_year + 1900);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Month */
-
- w = create_months (tm.tm_mon);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Days (canvas with month item) */
-
- gtk_box_pack_start (GTK_BOX (vbox), days, TRUE, TRUE, 0);
- gtk_widget_show (days);
-
- /* Today button */
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
- w = gtk_button_new_with_label (_("Go to today"));
- gtk_signal_connect (GTK_OBJECT (w), "clicked",
- (GtkSignalFunc) goto_today,
- NULL);
- gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
- gtk_widget_show (w);
-
- /* Run! */
-
- gtk_window_set_modal (GTK_WINDOW (goto_win), TRUE);
- gnome_dialog_set_close (GNOME_DIALOG (goto_win), TRUE);
- gnome_dialog_set_parent (GNOME_DIALOG (goto_win), GTK_WINDOW (gnome_calendar));
- gtk_widget_show (goto_win);
-}
diff --git a/calendar/gui/icalendar-types b/calendar/gui/icalendar-types
deleted file mode 100644
index e11f4c1789..0000000000
--- a/calendar/gui/icalendar-types
+++ /dev/null
@@ -1,39 +0,0 @@
-evento todo journal fbrequest fbreply busytime timezone
- attach attach attach
- attendee attendee attendee attendee attendee attendee
- categories categories categories
- class class class
- comment comment comment comment comment comment comment
- completed
- contact contact contact
- created created created created
- description description description
- dtstamp dtstamp
- dtend/duration due->dtend dtend [duration] dtend dtend
- dtstart dtstart dtstart dtstart dtstart dtstart dtstart
- exdate exdate exdate
- exrule exrule exrule
- geo geo
- last-mod last-mod last-mod last-mod last-mod
- location location
- organizer organizer organizer
- percent
- priority priority
- rstatus rstatus rstatus rstatus
- related related related
- resources resources
- rdate rdate rdate [rdate/rrule]
- rrule rrule rrule
- dtstamp dtstamp dtstamp dtstamp
- seq seq seq seq seq
- status status
- summary summary summary
- transp
- uid uid uid uid uid
- url url url url url
- recurid recurid recurid
- freebusy freebusy
- tzname
- tzoffset-to
- tzoffset-from
-
diff --git a/calendar/gui/layout.c b/calendar/gui/layout.c
deleted file mode 100644
index 1367ae3f8f..0000000000
--- a/calendar/gui/layout.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/* Event layout engine for Gnomecal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Miguel de Icaza <miguel@nuclecu.unam.mx>
- * Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include <stdlib.h>
-#include "layout.h"
-
-
-/* This structure is used to pass around layout information among the internal layout functions */
-struct layout_info {
- GList *events; /* List of events from client */
- int num_events; /* The number of events (length of the list) */
- LayoutQueryTimeFunc func; /* Function to convert a list item to a start/end time pair */
- int num_rows; /* Size of the time partition */
- time_t *partition; /* The time partition containing start and end time values */
- int *array; /* Working array of free and allocated time slots */
- int *allocations; /* Returned array of slot allocations */
- int *slots; /* Returned array of slots used */
- int num_slots; /* Number of slots used */
-};
-
-
-/* This defines the maximum number of events to overlap per row. More than that number of events
- * will not be displayed. This is not ideal, so sue me.
- */
-#define MAX_EVENTS_PER_ROW 32
-
-
-/* Compares two time_t values, used for qsort() */
-static int
-compare_time_t (const void *a, const void *b)
-{
- time_t ta, tb;
-
- ta = *((time_t *) a);
- tb = *((time_t *) b);
-
- if (ta < tb)
- return -1;
- else if (ta > tb)
- return 1;
- else
- return 0;
-}
-
-/* Builds a partition of the time range occupied by the events in the list. It returns an array
- * with the times that define the partition and the number of items in the partition.
- */
-static void
-build_partition (struct layout_info *li)
-{
- time_t *rows, *p, *q;
- GList *list;
- int i, unique_vals;
-
- /* This is the maximum number of rows we would need */
-
- li->num_rows = li->num_events * 2;
-
- /* Fill the rows with the times */
-
- rows = g_new (time_t, li->num_rows);
-
- for (list = li->events, p = rows; list; list = list->next) {
- (* li->func) (list, &p[0], &p[1]);
- p += 2;
- }
-
- /* Do a sort | uniq on the array */
-
- qsort (rows, li->num_rows, sizeof (time_t), compare_time_t);
-
- p = rows;
- q = rows + 1;
- unique_vals = 1;
-
- for (i = 1; i < li->num_rows; i++, q++)
- if (*q != *p) {
- unique_vals++;
- p++;
- *p = *q;
- }
-
- /* Return the number of unique values in the partition and the partition array itself */
-
- li->num_rows = unique_vals;
- li->partition = rows;
-}
-
-/* Returns the index of the element in the partition that corresponds to the specified time */
-int
-find_index (struct layout_info *li, time_t t)
-{
- int i;
-
- for (i = 0; ; i++)
- if (li->partition[i] == t)
- return i;
-
- g_assert_not_reached ();
-}
-
-#define xy(li, x, y) li->array[(y * MAX_EVENTS_PER_ROW) + (x)]
-
-/* Checks that all the cells in the slot array at the specified slot column are free to use by an
- * event that has the specified range.
- */
-static int
-range_is_empty (struct layout_info *li, int slot, time_t start, time_t end)
-{
- int i;
-
- for (i = find_index (li, start); li->partition[i] < end; i++)
- if (xy (li, slot, i) != -1)
- return FALSE;
-
- return TRUE;
-}
-
-/* Allocates a time in the slot array for the specified event's index */
-static void
-range_allocate (struct layout_info *li, int slot, time_t start, time_t end, int ev_num)
-{
- int i;
-
- for (i = find_index (li, start); li->partition[i] < end; i++)
- xy (li, slot, i) = ev_num;
-}
-
-/* Performs the initial allocation of slots for events. Each event gets one column; they will be
- * expanded in a later stage. Returns the number of columns used.
- */
-static void
-initial_allocate (struct layout_info *li)
-{
- GList *events;
- int i;
- int slot;
- int num_slots;
- time_t start, end;
-
- num_slots = 0;
-
- for (i = 0, events = li->events; events; events = events->next, i++) {
- (* li->func) (events, &start, &end);
-
- /* Start with no allocation, no columns */
-
- li->allocations[i] = -1;
- li->slots[i] = 0;
-
- /* Find a free column for the event */
-
- for (slot = 0; slot < MAX_EVENTS_PER_ROW; slot++)
- if (range_is_empty (li, slot, start, end)) {
- range_allocate (li, slot, start, end, i);
-
- li->allocations[i] = slot;
- li->slots[i] = 1;
-
- if ((slot + 1) > num_slots)
- num_slots = slot + 1;
-
- break;
- }
- }
-
- li->num_slots = num_slots;
-}
-
-/* Returns the maximum number of columns that an event can expanded by in the slot array */
-static int
-columns_to_expand (struct layout_info *li, int ev_num, time_t start, time_t end)
-{
- int cols;
- int slot;
- int i_start;
- int i;
-
- cols = 0;
-
- i_start = find_index (li, start);
-
- for (slot = li->allocations[ev_num] + 1; slot < li->num_slots; slot++) {
- for (i = i_start; li->partition[i] < end; i++)
- if (xy (li, slot, i) != -1)
- return cols;
-
- cols++;
- }
-
- return cols;
-}
-
-/* Expands an event by the specified number of columns */
-static void
-do_expansion (struct layout_info *li, int ev_num, time_t start, time_t end, int num_cols)
-{
- int i, j;
- int slot;
-
- for (i = find_index (li, start); li->partition[i] < end; i++) {
- slot = li->allocations[ev_num] + 1;
-
- for (j = 0; j < num_cols; j++)
- xy (li, slot + j, i) = ev_num;
- }
-}
-
-/* Expands the events in the slot array to occupy as many columns as possible. This is the second
- * pass of the layout algorithm.
- */
-static void
-expand_events (struct layout_info *li)
-{
- GList *events;
- time_t start, end;
- int i;
- int cols;
-
- for (i = 0, events = li->events; events; events = events->next, i++) {
- (* li->func) (events, &start, &end);
-
- cols = columns_to_expand (li, i, start, end);
-
- if (cols == 0)
- continue; /* We can't expand this event */
-
- do_expansion (li, i, start, end, cols);
-
- li->slots[i] += cols;
- }
-}
-
-void
-layout_events (GList *events, LayoutQueryTimeFunc func, int *num_slots, int **allocations, int **slots)
-{
- struct layout_info li;
- int i;
-
- g_return_if_fail (num_slots != NULL);
- g_return_if_fail (allocations != NULL);
- g_return_if_fail (slots != NULL);
-
- if (!events) {
- *num_slots = 0;
- *allocations = NULL;
- *slots = NULL;
-
- return;
- }
-
- li.events = events;
- li.num_events = g_list_length (events);
- li.func = func;
-
- /* Build the partition of the time range, and then build the array of slots */
-
- build_partition (&li);
-
- li.array = g_new (int, li.num_rows * MAX_EVENTS_PER_ROW);
- for (i = 0; i < (li.num_rows * MAX_EVENTS_PER_ROW); i++)
- li.array[i] = -1; /* This is our 'empty' value */
-
- /* Build the arrays for allocations and columns used */
-
- li.allocations = g_new (int, li.num_events);
- li.slots = g_new (int, li.num_events);
-
- /* Perform initial allocation and then expand the events to as many slots as they can occupy */
-
- initial_allocate (&li);
- expand_events (&li);
-
- /* Clean up and return values */
-
- g_free (li.array);
-
- *num_slots = li.num_slots;
- *allocations = li.allocations;
- *slots = li.slots;
-}
diff --git a/calendar/gui/layout.h b/calendar/gui/layout.h
deleted file mode 100644
index 734b720b8b..0000000000
--- a/calendar/gui/layout.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Event layout engine for Gnomecal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Miguel de Icaza <miguel@nuclecu.unam.mx>
- * Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef LAYOUT_H
-#define LAYOUT_H
-
-#include <glib.h>
-#include <time.h>
-
-
-/* Functions of this type must translate the list item into two time_t values for the start and end
- * of an event.
- */
-typedef void (* LayoutQueryTimeFunc) (GList *event, time_t *start, time_t *end);
-
-
-/* This is the main layout function for overlapping events. You pass in a list of (presumably)
- * events and a function that should take a list element and return the start and end times for the
- * event corresponding to that list element.
- *
- * It returns the number of slots ("columns") that you need to take into account when actually
- * painting the events, the array of the first slot index that each event occupies, and the array of
- * number of slots that each event occupies. You have to free both arrays.
- *
- * You will get somewhat better-looking results if the list of events is sorted by using the start
- * time as the primary sort key and the end time as the secondary sort key -- so that "longer"
- * events go first in the list.
- */
-void layout_events (GList *events, LayoutQueryTimeFunc func, int *num_slots, int **allocations, int **slots);
-
-
-#endif
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
deleted file mode 100644
index 9dead6b92e..0000000000
--- a/calendar/gui/main.c
+++ /dev/null
@@ -1,1059 +0,0 @@
-/*
- * Main file for the GNOME Calendar program
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@kernel.org)
- * Federico Mena (federico@nuclecu.unam.mx)
- */
-
-#include <config.h>
-#include <gnome.h>
-#include <libgnorba/gnorba.h>
-#include <pwd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include "calendar.h"
-#include "alarm.h"
-#include "eventedit.h"
-#include "gnome-cal.h"
-#include "main.h"
-#include "timeutil.h"
-#include "corba-cal-factory.h"
-
-#define COOKIE_USER_HOME_DIR ((char *) -1)
-
-
-/* The username, used to set the `owner' field of the event */
-char *user_name;
-
-/* The full user name from the Gecos field */
-char *full_name;
-
-/* The user's default calendar file */
-char *user_calendar_file;
-
-/* a gnome-config string prefix that can be used to access the calendar config info */
-char *calendar_settings;
-
-/* Day begin, day end parameters */
-int day_begin, day_end;
-
-/* Whether weeks starts on Sunday or Monday */
-int week_starts_on_monday;
-
-/* If true, do not show our top level window */
-int startup_hidden = 0;
-
-/* If true, enable debug output for alarms */
-int debug_alarms = 0;
-
-/* The array of color properties -- keep in sync with the enumeration defined in main.h. The color
- * values specified here are the defaults for the program.
- */
-struct color_prop color_props[] = {
- { 0x3e72, 0x35ec, 0x8ba2, N_("Outline:"), "/calendar/Colors/outline" },
- { 0xffff, 0xffff, 0xffff, N_("Headings:"), "/calendar/Colors/headings" },
- { 0xf26c, 0xecec, 0xbbe7, N_("Empty days:"), "/calendar/Colors/empty_bg" },
- { 0xfc1e, 0xf87f, 0x5f80, N_("Appointments:"), "/calendar/Colors/mark_bg" },
- { 0xd364, 0xc6b7, 0x7969, N_("Highlighted day:"), "/calendar/Colors/prelight_bg" },
- { 0x01f0, 0x01f0, 0x01f0, N_("Day numbers:"), "/calendar/Colors/day_fg" },
- { 0x0000, 0x0000, 0xffff, N_("Current day's number:"), "/calendar/Colors/current_fg" },
- { 0xbbbb, 0xbbbb, 0x0000, N_("To-Do item that is not yet due:"), "/calendar/Colors/todo_not_yet" },
- { 0xdddd, 0xbbbb, 0x0000, N_("To-Do item that is due today:"), "/calendar/Colors/todo_today" },
- { 0xbbbb, 0xdddd, 0x0000, N_("To-Do item that is overdue:"), "/calendar/Colors/todo_overdue" }
-};
-
-/* Number of active calendars */
-int active_calendars = 0;
-
-/* A list of all of the calendars started */
-GList *all_calendars = NULL;
-
-/* For dumping part of a calendar */
-static time_t from_t, to_t;
-
-/* File to load instead of the user default's file */
-static char *load_file;
-
-/* If set, show events for the specified date and quit */
-static int show_events;
-
-/* If set, show todo items quit */
-static int show_todo;
-
-/* If set, beep on display alarms */
-gboolean beep_on_display = 0;
-
-/* If true, timeout the beeper on audio alarms */
-
-gboolean enable_aalarm_timeout = 0;
-guint audio_alarm_timeout = 0;
-const guint MAX_AALARM_TIMEOUT = 3600;
-const guint MAX_SNOOZE_SECS = 3600;
-gboolean enable_snooze = 0;
-guint snooze_secs = 60;
-
-/* Default values for alarms */
-CalendarAlarm alarm_defaults[4] = {
- { ALARM_MAIL, 0, 15, ALARM_MINUTES },
- { ALARM_PROGRAM, 0, 15, ALARM_MINUTES },
- { ALARM_DISPLAY, 0, 15, ALARM_MINUTES },
- { ALARM_AUDIO, 0, 15, ALARM_MINUTES }
-};
-
-static void
-init_username (void)
-{
- user_name = g_strdup(g_get_user_name());
- full_name = g_strdup(g_get_real_name());
-}
-
-static int
-range_check_hour (int hour)
-{
- if (hour < 0)
- hour = 0;
- else if (hour >= 24)
- hour = 23;
-
- return hour;
-}
-
-static void
-init_default_alarms (void)
-{
- int i;
- gboolean def;
-
- alarm_defaults [ALARM_DISPLAY].type = ALARM_DISPLAY;
- alarm_defaults [ALARM_AUDIO].type = ALARM_AUDIO;
- alarm_defaults [ALARM_PROGRAM].type = ALARM_PROGRAM;
- alarm_defaults [ALARM_MAIL].type = ALARM_MAIL;
-
- for (i = 0; i < 4; i++) {
- switch (alarm_defaults [i].type) {
- case ALARM_DISPLAY:
- gnome_config_push_prefix ("/calendar/alarms/def_disp_");
- break;
- case ALARM_AUDIO:
- gnome_config_push_prefix ("/calendar/alarms/def_audio_");
- break;
- case ALARM_PROGRAM:
- gnome_config_push_prefix ("/calendar/alarms/def_prog_");
- break;
- case ALARM_MAIL:
- gnome_config_push_prefix ("/calendar/alarms/def_mail_");
- break;
- }
-
- alarm_defaults[i].enabled = gnome_config_get_int ("enabled=0");
- if (alarm_defaults[i].type != ALARM_MAIL) {
- alarm_defaults[i].count = gnome_config_get_int ("count=15");
- alarm_defaults[i].units = gnome_config_get_int ("units=0");
- } else {
- alarm_defaults[i].count = gnome_config_get_int ("count=1");
- alarm_defaults[i].count = gnome_config_get_int ("count=2");
- }
-
- alarm_defaults[i].data = gnome_config_get_string_with_default ("data=",
- &def);
- if (def)
- alarm_defaults[i].data = NULL;
-
- gnome_config_pop_prefix ();
- }
-}
-
-
-/*
- * Initializes the calendar internal variables, loads defaults
- */
-static void
-init_calendar (void)
-{
- int i;
- char *cspec, *color;
- char *str;
-
- init_username ();
- user_calendar_file = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/user-cal.vcf");
-
- gnome_config_push_prefix (calendar_settings);
-
- /* Read calendar settings */
-
- day_begin = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day start=8"));
- day_end = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day end=17"));
- am_pm_flag = gnome_config_get_bool ("/calendar/Calendar/AM PM flag=0");
- week_starts_on_monday = gnome_config_get_bool ("/calendar/Calendar/Week starts on Monday=0");
-
- if (day_end < day_begin){
- day_begin = 8;
- day_end = 17;
- }
-
- /* Read color settings */
-
- for (i = 0; i < COLOR_PROP_LAST; i++) {
- cspec = build_color_spec (color_props[i].r, color_props[i].g, color_props[i].b);
- str = g_strconcat (color_props[i].key, "=", cspec, NULL);
-
- color = gnome_config_get_string (str);
- parse_color_spec (color, &color_props[i].r, &color_props[i].g, &color_props[i].b);
-
- g_free (str);
- g_free (color);
- }
-
- /* read todolist settings */
-
- todo_show_time_remaining = gnome_config_get_bool("/calendar/Todo/show_time_remain");
- todo_show_due_date = gnome_config_get_bool("/calendar/Todo/show_due_date");
-
- todo_item_dstatus_highlight_overdue = gnome_config_get_bool("/calendar/Todo/highlight_overdue");
-
- todo_item_dstatus_highlight_due_today = gnome_config_get_bool("/calendar/Todo/highlight_due_today");
-
- todo_item_dstatus_highlight_not_due_yet = gnome_config_get_bool("/calendar/Todo/highlight_not_due_yet");
-
- todo_current_sort_column = gnome_config_get_int("/calendar/Todo/sort_column");
-
- todo_current_sort_type = gnome_config_get_int("/calendar/Todo/sort_type");
-
- todo_show_priority = gnome_config_get_bool("/calendar/Todo/show_priority");
-
- /* read alarm settings */
- beep_on_display = gnome_config_get_bool ("/calendar/alarms/beep_on_display=FALSE");
- enable_aalarm_timeout = gnome_config_get_bool ("/calendar/alarms/enable_audio_timeout=FALSE");
- audio_alarm_timeout = gnome_config_get_int ("/calendar/alarms/audio_alarm_timeout=60");
- if (audio_alarm_timeout < 1)
- audio_alarm_timeout = 1;
- if (audio_alarm_timeout > MAX_AALARM_TIMEOUT)
- audio_alarm_timeout = MAX_AALARM_TIMEOUT;
- enable_snooze = gnome_config_get_bool ("/calendar/alarms/enable_snooze=FALSE");
- snooze_secs = gnome_config_get_int ("/calendar/alarms/snooze_secs=300");
- if (snooze_secs < 1)
- snooze_secs = 1;
- if (snooze_secs > MAX_SNOOZE_SECS)
- snooze_secs = MAX_SNOOZE_SECS;
-
- init_default_alarms ();
-
-
- /* Done */
-
- gnome_config_pop_prefix ();
-}
-
-
-
-static void save_calendar_cmd (GtkWidget *widget, void *data);
-
-static void
-about_calendar_cmd (GtkWidget *widget, void *data)
-{
- GtkWidget *about;
- const gchar *authors[] = {
- "Miguel de Icaza (miguel@kernel.org)",
- "Federico Mena (federico@gimp.org)",
- "Arturo Espinosa (arturo@nuclecu.unam.mx)",
- "Russell Steinthal (rms39@columbia.edu)",
- NULL
- };
-
- about = gnome_about_new (_("Gnome Calendar"), VERSION,
- "(C) 1998 the Free Software Foundation",
- authors,
- _("The GNOME personal calendar and schedule manager."),
- NULL);
- gtk_window_set_modal (GTK_WINDOW (about), TRUE);
- gnome_dialog_set_close (GNOME_DIALOG (about), TRUE);
- gtk_widget_show (about);
-}
-
-static void
-display_objedit (GtkWidget *widget, GnomeCalendar *gcal)
-{
- GtkWidget *ee;
- iCalObject *ico;
-
- /* Default to the day the user is looking at */
- ico = ical_new ("", user_name, "");
- ico->new = 1;
- ico->dtstart = time_add_minutes (gcal->current_display, day_begin * 60);
- ico->dtend = time_add_minutes (ico->dtstart, day_begin * 60 + 30 );
-
- ee = event_editor_new (gcal, ico);
- gtk_widget_show (ee);
-}
-
-static void
-display_objedit_today (GtkWidget *widget, GnomeCalendar *gcal)
-{
- GtkWidget *ee;
-
- ee = event_editor_new (gcal, NULL);
- gtk_widget_show (ee);
-}
-
-GnomeCalendar *
-gnome_calendar_locate (const char *pathname)
-{
- GList *l;
-
- if (pathname == NULL || pathname [0] == 0)
- pathname = user_calendar_file;
-
- for (l = all_calendars; l; l = l->next){
- GnomeCalendar *gcal = l->data;
-
- if (strcmp (gcal->cal->filename, pathname) == 0){
- return gcal;
- }
- }
- return NULL;
-}
-
-static void
-close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
-{
- all_calendars = g_list_remove (all_calendars, gcal);
-
- if (gcal->cal->modified){
- if (!gcal->cal->filename)
- save_calendar_cmd (widget, gcal);
- else
- calendar_save (gcal->cal, gcal->cal->filename);
- }
-
- gtk_widget_destroy (GTK_WIDGET (gcal));
- active_calendars--;
-
- if (active_calendars == 0){
- unregister_calendar_services ();
- gtk_main_quit ();
- }
-}
-
-void
-time_format_changed (void)
-{
- GList *l;
-
- for (l = all_calendars; l; l = l->next)
- gnome_calendar_time_format_changed (GNOME_CALENDAR (l->data));
-}
-
-void
-colors_changed (void)
-{
- GList *l;
-
- for (l = all_calendars; l; l = l->next)
- gnome_calendar_colors_changed (GNOME_CALENDAR (l->data));
-}
-
-void
-todo_properties_changed(void)
-{
- GList *l;
-
- for (l = all_calendars; l; l = l->next)
- gnome_calendar_todo_properties_changed (GNOME_CALENDAR (l->data));
-}
-
-
-
-static void
-quit_cmd (void)
-{
- while (all_calendars){
- GnomeCalendar *cal = GNOME_CALENDAR (all_calendars->data);
-
- close_cmd (GTK_WIDGET (cal), cal);
- }
-}
-
-/* Sets a clock cursor for the specified calendar window */
-static void
-set_clock_cursor (GnomeCalendar *gcal)
-{
- GdkCursor *cursor;
-
- cursor = gdk_cursor_new (GDK_WATCH);
- gdk_window_set_cursor (GTK_WIDGET (gcal)->window, cursor);
- gdk_cursor_destroy (cursor);
- gdk_flush ();
-}
-
-/* Resets the normal cursor for the specified calendar window */
-static void
-set_normal_cursor (GnomeCalendar *gcal)
-{
- gdk_window_set_cursor (GTK_WIDGET (gcal)->window, NULL);
- gdk_flush ();
-}
-
-static void
-previous_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- set_clock_cursor (gcal);
- gnome_calendar_previous (gcal);
- set_normal_cursor (gcal);
-}
-
-static void
-next_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- set_clock_cursor (gcal);
- gnome_calendar_next (gcal);
- set_normal_cursor (gcal);
-}
-
-static void
-today_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- set_clock_cursor (gcal);
- gnome_calendar_goto_today (gcal);
- set_normal_cursor (gcal);
-}
-
-static void
-goto_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- goto_dialog (gcal);
-}
-
-static void
-new_calendar_cmd (GtkWidget *widget, void *data)
-{
- new_calendar (full_name, NULL, NULL, NULL, FALSE);
-}
-
-static void
-open_ok (GtkWidget *widget, GtkFileSelection *fs)
-{
- GtkWidget *error_dialog;
- int ret;
- if(!g_file_exists (gtk_file_selection_get_filename (fs))) {
- error_dialog = gnome_message_box_new (
- _("File not found"),
- GNOME_MESSAGE_BOX_ERROR,
- GNOME_STOCK_BUTTON_OK,
- NULL);
-
- gnome_dialog_set_parent (GNOME_DIALOG (error_dialog), GTK_WINDOW (fs));
- ret = gnome_dialog_run (GNOME_DIALOG (error_dialog));
- } else {
- /* FIXME: find out who owns this calendar and use that name */
- new_calendar ("Somebody", gtk_file_selection_get_filename (fs), NULL, NULL, FALSE);
- gtk_widget_destroy (GTK_WIDGET (fs));
- }
-}
-
-static void
-open_calendar_cmd (GtkWidget *widget, void *data)
-{
- GtkFileSelection *fs;
-
- fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Open calendar")));
-
- gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked",
- (GtkSignalFunc) open_ok,
- fs);
- gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked",
- (GtkSignalFunc) gtk_widget_destroy,
- GTK_OBJECT (fs));
-
- gtk_widget_show (GTK_WIDGET (fs));
- gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me */
-}
-
-static void
-save_ok (GtkWidget *widget, GtkFileSelection *fs)
-{
- GnomeCalendar *gcal;
- gchar *fname;
-
- gcal = GNOME_CALENDAR (gtk_object_get_user_data (GTK_OBJECT (fs)));
- gtk_window_set_wmclass (GTK_WINDOW (gcal), "gnomecal", "gnomecal");
-
- fname = g_strdup (gtk_file_selection_get_filename (fs));
- calendar_save (gcal->cal, fname);
- g_free(fname);
- gtk_main_quit ();
-}
-
-static gint
-close_save (GtkWidget *w)
-{
- gtk_main_quit ();
- return TRUE;
-}
-
-static void
-save_as_calendar_cmd (GtkWidget *widget, void *data)
-{
- GtkFileSelection *fs;
-
- fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Save calendar")));
- gtk_object_set_user_data (GTK_OBJECT (fs), data);
-
- gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked",
- (GtkSignalFunc) save_ok,
- fs);
- gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked",
- (GtkSignalFunc) close_save,
- GTK_OBJECT (fs));
- gtk_signal_connect_object (GTK_OBJECT (fs), "delete_event",
- GTK_SIGNAL_FUNC (close_save),
- GTK_OBJECT (fs));
- gtk_widget_show (GTK_WIDGET (fs));
- gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me even more */
- gtk_main ();
- gtk_widget_destroy (GTK_WIDGET (fs));
-}
-
-static void
-properties_cmd (GtkWidget *widget, GtkWidget *gcal)
-{
- properties (gcal);
-}
-
-static void
-save_calendar_cmd (GtkWidget *widget, void *data)
-{
- GnomeCalendar *gcal = data;
-
- if (gcal->cal->filename){
- struct stat s;
-
- if (stat (gcal->cal->filename, &s) == -1){
- if (errno == ENOENT)
- calendar_save (gcal->cal, gcal->cal->filename);
-
- return;
- }
-
- if (s.st_mtime != gcal->cal->file_time){
- GtkWidget *box;
- char *str;
- int b;
-
- str = g_strdup_printf (
- _("File %s has changed since it was loaded\nContinue?"),
- gcal->cal->filename);
- box = gnome_message_box_new (str, GNOME_MESSAGE_BOX_INFO,
- GNOME_STOCK_BUTTON_YES,
- GNOME_STOCK_BUTTON_NO,
- NULL);
- g_free (str);
- gnome_dialog_set_default (GNOME_DIALOG (box), 1);
- b = gnome_dialog_run (GNOME_DIALOG (box));
-
- if (b != 0)
- return;
- }
-
- calendar_save (gcal->cal, gcal->cal->filename);
- } else
- save_as_calendar_cmd (widget, data);
-}
-
-/*
- * Saves @gcal if it is the default calendar
- */
-void
-save_default_calendar (GnomeCalendar *gcal)
-{
- if (!gcal->cal->filename)
- return;
-
- save_calendar_cmd (NULL, gcal);
-}
-
-#if 0
-static void
-make_html_cmd (GtkWidget *widget, GtkWidget *gcal)
-{
- make_month_html (gcal, "output.html");
-}
-#endif
-
-static GnomeUIInfo gnome_cal_file_menu [] = {
- GNOMEUIINFO_MENU_NEW_ITEM(N_("_New calendar"),
- N_("Create a new calendar"),
- new_calendar_cmd, NULL),
-
- GNOMEUIINFO_MENU_OPEN_ITEM(open_calendar_cmd, NULL),
-
- GNOMEUIINFO_MENU_SAVE_ITEM(save_calendar_cmd, NULL),
-
- GNOMEUIINFO_MENU_SAVE_AS_ITEM(save_as_calendar_cmd, NULL),
-
- GNOMEUIINFO_SEPARATOR,
-
-#if 0
- GNOMEUIINFO_ITEM(N_("Create HTML for this month"),
- N_("Creates an HTML version of this month's appointments"),
- make_html_cmd, NULL);
-#endif
- GNOMEUIINFO_SEPARATOR,
-
- GNOMEUIINFO_MENU_CLOSE_ITEM(close_cmd, NULL),
-
- GNOMEUIINFO_MENU_EXIT_ITEM(quit_cmd, NULL),
-
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_edit_menu [] = {
- { GNOME_APP_UI_ITEM, N_("_New appointment..."),
- N_("Create a new appointment"), display_objedit, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_NEW, 0, 0, NULL },
- { GNOME_APP_UI_ITEM, N_("New appointment for _today..."),
- N_("Create a new appointment for today"),
- display_objedit_today, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_NEW, 0, 0, NULL },
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_help_menu [] = {
- GNOMEUIINFO_HELP ("gnomecal"),
-
- GNOMEUIINFO_MENU_ABOUT_ITEM(about_calendar_cmd, NULL),
-
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_settings_menu [] = {
- GNOMEUIINFO_MENU_PREFERENCES_ITEM(properties_cmd, NULL),
-
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_menu [] = {
- GNOMEUIINFO_MENU_FILE_TREE(gnome_cal_file_menu),
- GNOMEUIINFO_MENU_EDIT_TREE(gnome_cal_edit_menu),
- GNOMEUIINFO_MENU_SETTINGS_TREE(gnome_cal_settings_menu),
- GNOMEUIINFO_MENU_HELP_TREE(gnome_cal_help_menu),
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_toolbar [] = {
- GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new appointment"), display_objedit, GNOME_STOCK_PIXMAP_NEW),
-
- GNOMEUIINFO_SEPARATOR,
-
- GNOMEUIINFO_ITEM_STOCK (N_("Prev"), N_("Go back in time"), previous_clicked, GNOME_STOCK_PIXMAP_BACK),
- GNOMEUIINFO_ITEM_STOCK (N_("Today"), N_("Go to present time"), today_clicked, GNOME_STOCK_PIXMAP_HOME),
- GNOMEUIINFO_ITEM_STOCK (N_("Next"), N_("Go forward in time"), next_clicked, GNOME_STOCK_PIXMAP_FORWARD),
-
- GNOMEUIINFO_SEPARATOR,
-
- GNOMEUIINFO_ITEM_STOCK (N_("Go to"), N_("Go to a specific date"), goto_clicked, GNOME_STOCK_PIXMAP_JUMP_TO),
-
- GNOMEUIINFO_END
-};
-
-static void
-setup_menu (GtkWidget *gcal)
-{
- gnome_app_create_menus_with_data (GNOME_APP (gcal), gnome_cal_menu, gcal);
- gnome_app_create_toolbar_with_data (GNOME_APP (gcal), gnome_toolbar, gcal);
- gnome_app_install_menu_hints(GNOME_APP(gcal), gnome_cal_menu);
-}
-
-static void
-setup_appbar (GtkWidget *gcal)
-{
- GtkWidget *appbar;
-
- appbar = gnome_appbar_new (FALSE, TRUE, GNOME_PREFERENCES_USER);
- gnome_app_set_statusbar (GNOME_APP (gcal), GTK_WIDGET (appbar));
-}
-
-static gint
-calendar_close_event (GtkWidget *widget, GdkEvent *event, GnomeCalendar *gcal)
-{
- close_cmd (widget, gcal);
- return TRUE;
-}
-
-GnomeCalendar *
-new_calendar (char *full_name, char *calendar_file, char *geometry, char *page, gboolean hidden)
-{
- GtkWidget *toplevel;
- char title[128];
- int xpos, ypos, width, height;
-
- /* i18n: This "%s%s" indicates possession. Languages where the order is
- * the inverse should translate it to "%2$s%1$s".
- */
- g_snprintf(title, 128, _("%s%s"), full_name, _("'s calendar"));
-
- toplevel = gnome_calendar_new (title);
-
- if (gnome_parse_geometry (geometry, &xpos, &ypos, &width, &height)){
- if (xpos != -1)
- gtk_widget_set_uposition (toplevel, xpos, ypos);
-#if 0
- if (width != -1)
- gtk_widget_set_usize (toplevel, width, 600);
-#endif
- }
-#if 0
- gtk_widget_set_usize (toplevel, width, 600);
-#endif
-
- setup_appbar (toplevel);
- setup_menu (toplevel);
-
-
- if (page)
- gnome_calendar_set_view (GNOME_CALENDAR (toplevel), page);
-
- if (calendar_file && g_file_exists (calendar_file))
- gnome_calendar_load (GNOME_CALENDAR (toplevel), calendar_file);
- else
- GNOME_CALENDAR (toplevel)->cal->filename = g_strdup (calendar_file);
-
- gtk_signal_connect (GTK_OBJECT (toplevel), "delete_event",
- GTK_SIGNAL_FUNC(calendar_close_event), toplevel);
-
- active_calendars++;
- all_calendars = g_list_prepend (all_calendars, toplevel);
-
- if (hidden){
- GnomeWinState state;
-
- /* Realize the toplevel window to prevent a segfault */
- gtk_widget_realize (toplevel);
- state = gnome_win_hints_get_state (toplevel);
-
- state |= WIN_STATE_MINIMIZED;
- gnome_win_hints_set_state (toplevel, state);
- }
-
- gtk_widget_show (toplevel);
-
- return GNOME_CALENDAR (toplevel);
-}
-
-static void
-process_dates (void)
-{
- if (!from_t)
- from_t = time_day_begin (time (NULL));
-
- if (!to_t || to_t < from_t)
- to_t = time_add_day (from_t, 1);
-}
-
-enum {
- GEOMETRY_KEY = -1,
- USERFILE_KEY = -2,
- VIEW_KEY = -3,
- HIDDEN_KEY = -4,
- TODO_KEY = -5,
- DEBUG_KEY = -6
-};
-
-/* Lists used to startup various GnomeCalendars */
-static GList *start_calendars;
-static GList *start_geometries;
-static GList *start_views;
-
-static int
-same_day (struct tm *a, struct tm *b)
-{
- return (a->tm_mday == b->tm_mday &&
- a->tm_mon == b->tm_mon &&
- a->tm_year == b->tm_year);
-}
-
-static void
-dump_events (void)
-{
- Calendar *cal;
- GList *l;
- char *s;
- time_t now = time (NULL);
- struct tm today = *localtime (&now);
-
- process_dates ();
- init_calendar ();
-
- cal = calendar_new (full_name, CALENDAR_INIT_ALARMS);
- s = calendar_load (cal, load_file ? load_file : user_calendar_file);
- if (s){
- printf ("error: %s\n", s);
- exit (1);
- }
- l = calendar_get_events_in_range (cal, from_t, to_t);
- for (; l; l = l->next){
- char start [80], end [80];
- CalendarObject *co = l->data;
- struct tm ts, te;
- char *format;
-
- ts = *localtime (&co->ev_start);
- te = *localtime (&co->ev_end);
-
- if (same_day (&today, &ts))
- format = N_("%H:%M");
- else
- format = N_("%A %b %d, %H:%M");
- strftime (start, sizeof (start), _(format), &ts);
-
- if (!same_day (&ts, &te))
- format = N_("%A %b %d, %H:%M");
- strftime (end, sizeof (start), _(format), &te);
-
- printf ("%s -- %s\n", start, end);
- printf (" %s\n", co->ico->summary);
- }
- calendar_destroy_event_list (l);
- calendar_destroy (cal);
- exit (0);
-}
-
-static void
-dump_todo (void)
-{
- Calendar *cal;
- GList *l;
- char *s;
-
- process_dates ();
- init_calendar ();
-
- cal = calendar_new (full_name, CALENDAR_INIT_ALARMS);
- s = calendar_load (cal, load_file ? load_file : user_calendar_file);
- if (s){
- printf ("error: %s\n", s);
- exit (1);
- }
- for (l = cal->todo; l; l = l->next){
- iCalObject *object = l->data;
-
- if (object->type != ICAL_TODO)
- continue;
-
- printf ("[%s]: %s\n", object->organizer, object->summary);
- }
- calendar_destroy (cal);
- exit (0);
-}
-
-extern time_t get_date ();
-
-static void
-parse_an_arg (poptContext ctx,
- enum poptCallbackReason reason,
- const struct poptOption *opt,
- char *arg, void *data)
-{
- switch (opt->val){
- case 'f':
- from_t = get_date (arg, NULL);
- break;
-
- case 't':
- to_t = get_date (arg, NULL);
- break;
-
- case GEOMETRY_KEY:
- start_geometries = g_list_append (start_geometries, arg);
- break;
-
- case USERFILE_KEY:
- /* This is a special key that tells the program to load
- * the user's calendar file. This allows session management
- * to work even if the User's home directory changes location
- * (ie, on a networked setup).
- */
- arg = COOKIE_USER_HOME_DIR;
- /* fall through */
- break;
-
- case VIEW_KEY:
- start_views = g_list_append (start_views, arg);
- break;
-
- case 'F':
- start_calendars = g_list_append (start_calendars, arg);
- break;
-
- case TODO_KEY:
- show_todo = 1;
- break;
-
- case 'e':
- show_events = 1;
- break;
-
- case HIDDEN_KEY:
- startup_hidden = 1;
- break;
-
- case DEBUG_KEY:
- if (!g_strcasecmp (arg, "alarms"))
- debug_alarms = 1;
- break;
-
- default:
- }
-}
-
-static const struct poptOption options [] = {
- { NULL, '\0', POPT_ARG_CALLBACK, parse_an_arg, 0, NULL, NULL },
- { "events", 'e', POPT_ARG_NONE, NULL, 'e', N_("Show events and quit"),
- NULL },
- { "todo", 0, POPT_ARG_NONE, NULL, TODO_KEY, N_("Show TO-DO items and quit"),
- NULL },
- { "from", 'f', POPT_ARG_STRING, NULL, 'f', N_("Specifies start date [for --events]"), N_("DATE") },
- { "file", 'F', POPT_ARG_STRING, NULL, 'F', N_("File to load calendar from"), N_("FILE") },
- { "userfile", '\0', POPT_ARG_NONE, NULL, USERFILE_KEY, N_("Load the user calendar"), NULL },
- { "geometry", '\0', POPT_ARG_STRING, NULL, GEOMETRY_KEY, N_("Geometry for starting up"), N_("GEOMETRY") },
- { "view", '\0', POPT_ARG_STRING, NULL, VIEW_KEY, N_("The startup view mode (dayview, weekview, monthview, yearview)"), N_("VIEW") },
- { "to", 't', POPT_ARG_STRING, NULL, 't', N_("Specifies ending date [for --events]"), N_("DATE") },
- { "hidden", 0, POPT_ARG_NONE, NULL, HIDDEN_KEY, N_("If used, starts in iconic mode"), NULL },
- { "debug", 'd', POPT_ARG_STRING, NULL, DEBUG_KEY, N_("Enable debugging output of TYPE (alarms)"), N_("TYPE") },
- { NULL, '\0', 0, NULL, 0}
-};
-
-static void
-session_die (void)
-{
- quit_cmd ();
-}
-
-/*
- * Save the session callback
- */
-static int
-session_save_state (GnomeClient *client, gint phase, GnomeRestartStyle save_style, gint shutdown,
- GnomeInteractStyle interact_style, gint fast, gpointer client_data)
-{
- char *sess_id;
- char **argv = (char **) g_malloc (sizeof (char *) * ((active_calendars * 6) + 3));
- GList *l, *free_list = 0;
- int i;
-
- sess_id = gnome_client_get_id (client);
-
- argv [0] = client_data;
- for (i = 1, l = all_calendars; l; l = l->next){
- GnomeCalendar *gcal = GNOME_CALENDAR (l->data);
- char *geometry;
-
- geometry = gnome_geometry_string (GTK_WIDGET (gcal)->window);
-
- if (strcmp (gcal->cal->filename, user_calendar_file) == 0)
- argv [i++] = "--userfile";
- else {
- argv [i++] = "--file";
- argv [i++] = gcal->cal->filename;
- }
- argv [i++] = "--geometry";
- argv [i++] = geometry;
- argv [i++] = "--view";
- argv [i++] = gnome_calendar_get_current_view_name (gcal);
- free_list = g_list_append (free_list, geometry);
- calendar_save (gcal->cal, gcal->cal->filename);
- }
- argv [i] = NULL;
- gnome_client_set_clone_command (client, i, argv);
- gnome_client_set_restart_command (client, i, argv);
-
- for (l = free_list; l; l = l->next)
- g_free (l->data);
- g_list_free (free_list);
-
- return 1;
-}
-
-int
-main(int argc, char *argv[])
-{
- GnomeClient *client;
- CORBA_Environment ev;
-
- bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);
-
- CORBA_exception_init (&ev);
-
- gnome_CORBA_init_with_popt_table (
- "calendar", VERSION, &argc, argv,
- options, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev);
-
- orb = gnome_CORBA_ORB ();
- poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev);
- if (ev._major == CORBA_NO_EXCEPTION){
- init_corba_server ();
- }
-
- if (show_events)
- dump_events ();
- if (show_todo)
- dump_todo ();
-
- client = gnome_master_client ();
- if (client){
- gtk_signal_connect (GTK_OBJECT (client), "save_yourself",
- GTK_SIGNAL_FUNC (session_save_state), argv [0]);
- gtk_signal_connect (GTK_OBJECT (client), "die",
- GTK_SIGNAL_FUNC (session_die), NULL);
- }
-
- process_dates ();
- alarm_init ();
- init_calendar ();
-
- /*
- * Load all of the calendars specifies in the command line with
- * the geometry specificied -if any-
- */
- if (start_calendars){
- GList *p, *g, *v;
- char *title;
-
- p = start_calendars;
- g = start_geometries;
- v = start_views;
- while (p){
- char *file = p->data;
- char *geometry = g ? g->data : NULL;
- char *page_name = v ? v->data : NULL;
-
- if (file == COOKIE_USER_HOME_DIR)
- file = user_calendar_file;
-
- if (strcmp (file, user_calendar_file) == 0)
- title = full_name;
- else
- title = file;
- new_calendar (title, file, geometry, page_name, startup_hidden);
-
- p = p->next;
- if (g)
- g = g->next;
- if (v)
- v = v->next;
- }
- g_list_free (p);
- } else {
- char *geometry = start_geometries ? start_geometries->data : NULL;
- char *page_name = start_views ? start_views->data : NULL;
-
- new_calendar (full_name, user_calendar_file, geometry, page_name, startup_hidden);
- }
- gtk_main ();
- return 0;
-}
diff --git a/calendar/gui/main.h b/calendar/gui/main.h
deleted file mode 100644
index 2785e1d2d1..0000000000
--- a/calendar/gui/main.h
+++ /dev/null
@@ -1,101 +0,0 @@
-#ifndef MAIN_H
-#define MAIN_H
-
-/* Calendar preferences */
-
-extern int day_begin, day_end;
-extern char *user_name;
-extern int am_pm_flag;
-extern int week_starts_on_monday;
-
-
-/* This enum and the following array define the color preferences */
-
-typedef enum {
- COLOR_PROP_OUTLINE_COLOR, /* Color of calendar outline */
- COLOR_PROP_HEADING_COLOR, /* Color for headings */
- COLOR_PROP_EMPTY_DAY_BG, /* Background color for empty days */
- COLOR_PROP_MARK_DAY_BG, /* Background color for days with appointments */
- COLOR_PROP_PRELIGHT_DAY_BG, /* Background color for prelighted day */
- COLOR_PROP_DAY_FG, /* Color for day numbers */
- COLOR_PROP_CURRENT_DAY_FG, /* Color for current day's number */
- COLOR_PROP_TODO_NOT_DUE_YET, /* Color for Todo items not yet due */
- COLOR_PROP_TODO_DUE_TODAY, /* Color for Todo items due today */
- COLOR_PROP_TODO_OVERDUE, /* Color for Todo items that are overdue */
- COLOR_PROP_LAST /* Number of color properties */
-} ColorProp;
-
-struct color_prop {
- int r; /* Values are in [0, 65535] */
- int g;
- int b;
- char *label; /* Label for properties dialog */
- char *key; /* Key for gnome_config */
-};
-
-extern struct color_prop color_props[];
-
-
-/* todo preferences */
-extern int todo_show_due_date;
-
-extern int todo_item_dstatus_highlight_overdue;
-extern int todo_item_dstatus_highlight_due_today;
-extern int todo_item_dstatus_highlight_not_due_yet;
-
-extern int todo_show_time_remaining;
-extern int todo_show_priority;
-extern char *todo_overdue_font_text;
-extern gboolean todo_style_changed;
-extern gint todo_current_sort_column;
-extern gint todo_current_sort_type;
-
-/* alarm stuff */
-extern CalendarAlarm alarm_defaults[4];
-extern gboolean beep_on_display;
-extern gboolean enable_aalarm_timeout;
-extern guint audio_alarm_timeout;
-extern const guint MAX_AALARM_TIMEOUT;
-extern gboolean enable_snooze;
-extern guint snooze_secs;
-extern const guint MAX_SNOOZE_SECS;
-
-/* Creates and runs the preferences dialog box */
-void properties (GtkWidget *toplevel);
-
-/* Asks for all the time-related displays to be updated when the user changes the time format
- * preferences.
- */
-void time_format_changed (void);
-
-/* Asks for all the month items' colors to be reset */
-void colors_changed (void);
-
-/* Asks for all todo lists to reflect the accurate properties */
-void todo_properties_changed(void);
-
-/* Creates and runs the Go-to date dialog */
-void goto_dialog (GnomeCalendar *gcal);
-
-/* Returns a pointer to a statically-allocated string with a representation of the specified color.
- * Values must be in [0, 65535].
- */
-char *build_color_spec (int r, int g, int b);
-
-/* Parses a color specification of the form "#%04x%04x%04x" and returns the color components. */
-void parse_color_spec (char *spec, int *r, int *g, int *b);
-
-/* Calls build_color_spec() for the color in the specified property number */
-char *color_spec_from_prop (ColorProp propnum);
-
-void save_default_calendar (GnomeCalendar *gcal);
-
-GnomeCalendar *new_calendar (char *full_name, char *calendar_file,
- char *geometry, char *page, gboolean hidden);
-
-#endif
-
-
-
-
-
diff --git a/calendar/gui/mark.c b/calendar/gui/mark.c
deleted file mode 100644
index 2de8e2b880..0000000000
--- a/calendar/gui/mark.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/* Functions to mark calendars
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include "gnome-cal.h"
-#include "main.h"
-#include "mark.h"
-#include "timeutil.h"
-
-
-/* Frees the specified data when an object is destroyed */
-static void
-free_data (GtkObject *object, gpointer data)
-{
- g_free (data);
-}
-
-/* If the array of "marked" attributes for the days in a a month item has not been created yet, this
- * function creates the array and clears it. Otherwise, it just returns the existing array.
- */
-static char *
-get_attributes (GnomeMonthItem *mitem)
-{
- char *attrs;
-
- attrs = gtk_object_get_data (GTK_OBJECT (mitem), "day_mark_attributes");
-
- if (!attrs) {
- attrs = g_new0 (char, 42);
- gtk_object_set_data (GTK_OBJECT (mitem), "day_mark_attributes", attrs);
- gtk_signal_connect (GTK_OBJECT (mitem), "destroy",
- (GtkSignalFunc) free_data,
- attrs);
- }
-
- return attrs;
-}
-
-void
-colorify_month_item (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data)
-{
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
- g_return_if_fail (func != NULL);
-
- unmark_month_item (mitem);
-
- /* We have to do this in several calls to gnome_canvas_item_set(), as color_spec_from_prop()
- * returns a pointer to a static string -- and we need several values.
- */
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "heading_color", (* func) (COLOR_PROP_HEADING_COLOR, func_data),
- NULL);
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "outline_color", (* func) (COLOR_PROP_OUTLINE_COLOR, func_data),
- NULL);
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "day_box_color", (* func) (COLOR_PROP_EMPTY_DAY_BG, func_data),
- NULL);
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "day_color", (* func) (COLOR_PROP_DAY_FG, func_data),
- NULL);
-}
-
-/* In the month item, marks all the days that are touched by the specified time span. Assumes that
- * the time span is completely contained within the month. The array of day attributes is modified
- * accordingly.
- */
-static void
-mark_event_in_month (GnomeMonthItem *mitem, time_t start, time_t end)
-{
- struct tm tm;
- int day_index;
-
- tm = *localtime (&start);
-
- for (; start <= end; start += 60 * 60 * 24) {
- mktime (&tm); /* normalize the time */
-
- /* Figure out the day index that corresponds to this time */
-
- day_index = gnome_month_item_day2index (mitem, tm.tm_mday);
- g_assert (day_index >= 0);
-
- /* Mark the day box */
-
- mark_month_item_index (mitem, day_index, default_color_func, NULL);
-
- /* Next day */
-
- tm.tm_mday++;
- }
-}
-
-void
-mark_month_item (GnomeMonthItem *mitem, Calendar *cal)
-{
- time_t month_begin, month_end;
- GList *list, *l;
- CalendarObject *co;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
- g_return_if_fail (cal != NULL);
-
- month_begin = time_month_begin (time_from_day (mitem->year, mitem->month, 1));
- month_end = time_month_end (month_begin);
-
- list = calendar_get_events_in_range (cal, month_begin, month_end);
-
- for (l = list; l; l = l->next) {
- co = l->data;
-
- /* We clip the event's start and end times to the month's limits */
-
- mark_event_in_month (mitem, MAX (co->ev_start, month_begin), MIN (co->ev_end, month_end));
- }
-
- calendar_destroy_event_list (list);
-}
-
-void
-mark_month_item_index (GnomeMonthItem *mitem, int index, GetColorFunc func, gpointer func_data)
-{
- char *attrs;
- GnomeCanvasItem *item;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
- g_return_if_fail ((index >= 0) && (index < 42));
- g_return_if_fail (func != NULL);
-
- attrs = get_attributes (mitem);
-
- attrs[index] = TRUE;
-
- item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + index);
- gnome_canvas_item_set (item,
- "fill_color", (* func) (COLOR_PROP_MARK_DAY_BG, func_data),
- NULL);
-}
-
-void
-unmark_month_item (GnomeMonthItem *mitem)
-{
- int i;
- char *attrs;
- GnomeCanvasItem *item;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
-
- attrs = get_attributes (mitem);
-
- /* Find marked days and unmark them by turning off their marked attribute flag and changing
- * the color.
- */
-
- for (i = 0; i < 42; i++)
- if (attrs[i]) {
- attrs[i] = FALSE;
-
- item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + i);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_EMPTY_DAY_BG),
- NULL);
- }
-}
-
-/* Handles EnterNotify and LeaveNotify events from the month item's day groups, and performs
- * appropriate prelighting.
- */
-static gint
-day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- GnomeMonthItem *mitem;
- GnomeCanvasItem *box;
- int child_num, day;
- GetColorFunc func;
- gpointer func_data;
- char *color;
- char *attrs;
-
- /* We only accept enters and leaves */
-
- if (!((event->type == GDK_ENTER_NOTIFY) || (event->type == GDK_LEAVE_NOTIFY)))
- return FALSE;
-
- /* Get index information */
-
- mitem = GNOME_MONTH_ITEM (data);
- child_num = gnome_month_item_child2num (mitem, item);
- day = gnome_month_item_num2day (mitem, child_num);
-
- if (day == 0)
- return FALSE; /* it was a day outside the month's range */
-
- child_num -= GNOME_MONTH_ITEM_DAY_GROUP;
- box = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + child_num);
-
- /* Get colors */
-
- func = gtk_object_get_data (GTK_OBJECT (mitem), "prelight_color_func");
- func_data = gtk_object_get_data (GTK_OBJECT (mitem), "prelight_color_data");
-
- /* Now actually set the proper color in the item */
-
- switch (event->type) {
- case GDK_ENTER_NOTIFY:
- color = (* func) (COLOR_PROP_PRELIGHT_DAY_BG, func_data);
- gnome_canvas_item_set (box,
- "fill_color", color,
- NULL);
- break;
-
- case GDK_LEAVE_NOTIFY:
- attrs = get_attributes (mitem);
- color = (* func) (attrs[child_num] ? COLOR_PROP_MARK_DAY_BG : COLOR_PROP_EMPTY_DAY_BG,
- func_data);
- gnome_canvas_item_set (box,
- "fill_color", color,
- NULL);
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- return TRUE;
-}
-
-void
-month_item_prepare_prelight (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data)
-{
- GnomeCanvasItem *day_group;
- int i;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
- g_return_if_fail (func != NULL);
-
- /* Store the function in the object data */
-
- gtk_object_set_data (GTK_OBJECT (mitem), "prelight_color_func", func);
- gtk_object_set_data (GTK_OBJECT (mitem), "prelight_color_data", func_data);
-
- /* Connect the appropriate signals to perform prelighting */
-
- for (i = 0; i < 42; i++) {
- day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (mitem), GNOME_MONTH_ITEM_DAY_GROUP + i);
- gtk_signal_connect (GTK_OBJECT (day_group), "event",
- (GtkSignalFunc) day_event,
- mitem);
- }
-}
-
-char *
-default_color_func (ColorProp propnum, gpointer data)
-{
- return color_spec_from_prop (propnum);
-}
diff --git a/calendar/gui/mark.h b/calendar/gui/mark.h
deleted file mode 100644
index cf8f7c1496..0000000000
--- a/calendar/gui/mark.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Functions to mark calendars
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef MARK_H
-#define MARK_H
-
-#include "calendar.h"
-#include "gnome-month-item.h"
-
-
-/* These are the fonts used for the montly calendars */
-
-#define HEADING_FONTSET "-adobe-helvetica-medium-r-*-*-14-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-medium-r-*-*-14-*-*-*-*-*-ksc5601.1987-0,*"
-#define TITLE_FONTSET "-adobe-helvetica-bold-r-normal--12-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-14-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--12-*-*-*-*-*-ksc5601.1987-0,*"
-#define DAY_HEADING_FONTSET "-adobe-helvetica-medium-r-normal--10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*"
-#define NORMAL_DAY_FONTSET "-adobe-helvetica-medium-r-normal--10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*"
-#define CURRENT_DAY_FONTSET "-adobe-helvetica-bold-r-normal--12-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-14-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--12-*-*-*-*-*-ksc5601.1987-0,*"
-#define BIG_DAY_HEADING_FONTSET "-adobe-helvetica-bold-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-bold-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*"
-#define BIG_NORMAL_DAY_FONTSET "-adobe-helvetica-medium-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*"
-#define BIG_CURRENT_DAY_FONTSET "-adobe-helvetica-bold-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-bold-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*"
-#define EVENT_FONTSET "-adobe-helvetica-medium-r-*-*-10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*"
-
-
-/* Functions of this type are used by the marking functions to fetch color specifications. Such
- * a function must return a color spec based on the property passed to it.
- */
-typedef char * (* GetColorFunc) (ColorProp propnum, gpointer data);
-
-
-/* Sets the user-configured colors and font for a month item. It also tags the days as unmarked. */
-void colorify_month_item (GnomeMonthItem *month, GetColorFunc func, gpointer func_data);
-
-/* Takes a monthly calendar item and marks the days that have events scheduled for them in the
- * specified calendar. It also highlights the current day.
- */
-void mark_month_item (GnomeMonthItem *mitem, Calendar *cal);
-
-/* Marks a day specified by index, not by day number */
-void mark_month_item_index (GnomeMonthItem *mitem, int index, GetColorFunc func, gpointer func_data);
-
-/* Unmarks all the days in the specified month item */
-void unmark_month_item (GnomeMonthItem *mitem);
-
-/* Prepares a monthly calendar item to prelight when the mouse goes over the days. */
-
-void month_item_prepare_prelight (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data);
-
-/* This is the default prelight function you can use for most puposes. You can use NULL as the
- * func_data.
- */
-char *default_color_func (ColorProp prop_num, gpointer data);
-
-
-#endif
diff --git a/calendar/gui/month-view.c b/calendar/gui/month-view.c
deleted file mode 100644
index 5df7b7a23d..0000000000
--- a/calendar/gui/month-view.c
+++ /dev/null
@@ -1,798 +0,0 @@
-/* Month view display for gncal
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include <gnome.h>
-#include <libgnomeui/gnome-canvas-text.h>
-#include "eventedit.h"
-#include "layout.h"
-#include "month-view.h"
-#include "main.h"
-#include "mark.h"
-#include "quick-view.h"
-#include "timeutil.h"
-
-
-/* Spacing between title and calendar */
-#define SPACING 4
-
-/* Padding between day borders and event text */
-#define EVENT_PADDING 3
-
-
-static void month_view_class_init (MonthViewClass *class);
-static void month_view_init (MonthView *mv);
-static void month_view_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void month_view_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-
-
-static GnomeCanvasClass *parent_class;
-
-
-GtkType
-month_view_get_type (void)
-{
- static GtkType month_view_type = 0;
-
- if (!month_view_type) {
- GtkTypeInfo month_view_info = {
- "MonthView",
- sizeof (MonthView),
- sizeof (MonthViewClass),
- (GtkClassInitFunc) month_view_class_init,
- (GtkObjectInitFunc) month_view_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- month_view_type = gtk_type_unique (gnome_canvas_get_type (), &month_view_info);
- }
-
- return month_view_type;
-}
-
-static void
-month_view_class_init (MonthViewClass *class)
-{
- GtkWidgetClass *widget_class;
-
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gnome_canvas_get_type ());
-
- widget_class->size_request = month_view_size_request;
- widget_class->size_allocate = month_view_size_allocate;
-}
-
-/* Creates the quick view when a day is clicked in the month view */
-static void
-do_quick_view_popup (MonthView *mv, GdkEventButton *event, int day)
-{
- time_t day_begin_time, day_end_time;
- GList *list;
- GtkWidget *qv;
- char date_str[256];
-
- day_begin_time = time_from_day (mv->year, mv->month, day);
- day_end_time = time_day_end (day_begin_time);
-
- list = calendar_get_events_in_range (mv->calendar->cal, day_begin_time, day_end_time);
-
- strftime (date_str, sizeof (date_str), _("%a %b %d %Y"), localtime (&day_begin_time));
- qv = quick_view_new (mv->calendar, date_str, list);
-
- quick_view_do_popup (QUICK_VIEW (qv), event);
-
- gtk_widget_destroy (qv);
- calendar_destroy_event_list (list);
-}
-
-/* Callback used to destroy the popup menu when the month view is destroyed */
-static void
-destroy_menu (GtkWidget *widget, gpointer data)
-{
- gtk_widget_destroy (GTK_WIDGET (data));
-}
-
-/* Creates a new appointment in the current day */
-static void
-new_appointment (GtkWidget *widget, gpointer data)
-{
- MonthView *mv;
- time_t *t;
-
- mv = MONTH_VIEW (data);
- t = gtk_object_get_data (GTK_OBJECT (widget), "time_data");
-
- event_editor_new_whole_day (mv->calendar, *t);
-}
-
-/* Convenience functions to jump to a view and set the time */
-static void
-do_jump (GtkWidget *widget, gpointer data, char *view_name)
-{
- MonthView *mv;
- time_t *t;
-
- mv = MONTH_VIEW (data);
-
- /* Get the time data from the menu item */
-
- t = gtk_object_get_data (GTK_OBJECT (widget), "time_data");
-
- /* Set the view and time */
-
- gnome_calendar_set_view (mv->calendar, view_name);
- gnome_calendar_goto (mv->calendar, *t);
-}
-
-/* The following three callbacks set the view in the calendar and change the time */
-
-static void
-jump_to_day (GtkWidget *widget, gpointer data)
-{
- do_jump (widget, data, "dayview");
-}
-
-static void
-jump_to_week (GtkWidget *widget, gpointer data)
-{
- do_jump (widget, data, "weekview");
-}
-
-static void
-jump_to_year (GtkWidget *widget, gpointer data)
-{
- do_jump (widget, data, "yearview");
-}
-
-static GnomeUIInfo mv_popup_menu[] = {
- GNOMEUIINFO_ITEM_STOCK (N_("_New appointment in this day..."), NULL, new_appointment, GNOME_STOCK_MENU_NEW),
-
- GNOMEUIINFO_SEPARATOR,
-
- GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _day"), NULL, jump_to_day, GNOME_STOCK_MENU_JUMP_TO),
- GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _week"), NULL, jump_to_week, GNOME_STOCK_MENU_JUMP_TO),
- GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _year"), NULL, jump_to_year, GNOME_STOCK_MENU_JUMP_TO),
- GNOMEUIINFO_END
-};
-
-/* Creates the popup menu for the month view if it does not yet exist, and attaches it to the month
- * view object so that it can be destroyed when appropriate.
- */
-static GtkWidget *
-get_popup_menu (MonthView *mv)
-{
- GtkWidget *menu;
-
- menu = gtk_object_get_data (GTK_OBJECT (mv), "popup_menu");
-
- if (!menu) {
- menu = gnome_popup_menu_new (mv_popup_menu);
- gtk_object_set_data (GTK_OBJECT (mv), "popup_menu", menu);
- gtk_signal_connect (GTK_OBJECT (mv), "destroy",
- (GtkSignalFunc) destroy_menu,
- menu);
- }
-
- return menu;
-}
-
-/* Pops up the menu for the month view. */
-static void
-do_popup_menu (MonthView *mv, GdkEventButton *event, int day)
-{
- GtkWidget *menu;
- static time_t t;
-
- menu = get_popup_menu (mv);
-
- /* Enable or disable items as appropriate */
-
- gtk_widget_set_sensitive (mv_popup_menu[0].widget, day != 0);
- gtk_widget_set_sensitive (mv_popup_menu[2].widget, day != 0);
- gtk_widget_set_sensitive (mv_popup_menu[3].widget, day != 0);
-
- if (day == 0)
- day = 1;
-
- /* Store the time for the menu item callbacks to use */
-
- t = time_from_day (mv->year, mv->month, day);
-
- gtk_object_set_data (GTK_OBJECT (mv_popup_menu[0].widget), "time_data", &t);
- gtk_object_set_data (GTK_OBJECT (mv_popup_menu[2].widget), "time_data", &t);
- gtk_object_set_data (GTK_OBJECT (mv_popup_menu[3].widget), "time_data", &t);
- gtk_object_set_data (GTK_OBJECT (mv_popup_menu[4].widget), "time_data", &t);
-
- gnome_popup_menu_do_popup (menu, NULL, NULL, event, mv);
-}
-
-/* Event handler for day groups. When mouse button 1 is pressed, it will pop up a quick view with
- * the events in that day. When mouse button 3 is pressed, it will pop up a menu.
- */
-static gint
-day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- MonthView *mv;
- int child_num;
- int day;
-
- mv = MONTH_VIEW (data);
-
- child_num = gnome_month_item_child2num (GNOME_MONTH_ITEM (mv->mitem), item);
- day = gnome_month_item_num2day (GNOME_MONTH_ITEM (mv->mitem), child_num);
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if ((event->button.button == 1) && (day != 0)) {
- do_quick_view_popup (mv, (GdkEventButton *) event, day);
- return TRUE;
- } else if (event->button.button == 3) {
- do_popup_menu (mv, (GdkEventButton *) event, day);
- return TRUE;
- }
-
- break;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-/* Returns the index of the specified arrow in the array of arrows */
-static int
-get_arrow_index (MonthView *mv, GnomeCanvasItem *arrow)
-{
- int i;
-
- for (i = 0; i < 42; i++)
- if (mv->up[i] == arrow)
- return i;
- else if (mv->down[i] == arrow)
- return i + 42;
-
- g_warning ("Eeeek, arrow %p not found in month view %p", arrow, mv);
- return -1;
-}
-
-/* Checks whether arrows need to be displayed at the specified day index or not */
-static void
-check_arrow_visibility (MonthView *mv, int day_index)
-{
- GtkArg args[3];
- double text_height;
- double clip_height;
- double y_offset;
-
- args[0].name = "text_height";
- args[1].name = "clip_height";
- args[2].name = "y_offset";
- gtk_object_getv (GTK_OBJECT (mv->text[day_index]), 3, args);
-
- text_height = GTK_VALUE_DOUBLE (args[0]);
- clip_height = GTK_VALUE_DOUBLE (args[1]);
- y_offset = GTK_VALUE_DOUBLE (args[2]);
-
- /* Check up arrow */
-
- if (y_offset < 0.0)
- gnome_canvas_item_show (mv->up[day_index]);
- else
- gnome_canvas_item_hide (mv->up[day_index]);
-
- if (y_offset > (clip_height - text_height))
- gnome_canvas_item_show (mv->down[day_index]);
- else
- gnome_canvas_item_hide (mv->down[day_index]);
-}
-
-/* Finds which arrow was clicked and scrolls the corresponding text item in the month view */
-static void
-do_arrow_click (MonthView *mv, GnomeCanvasItem *arrow)
-{
- int arrow_index;
- int day_index;
- int up;
- GtkArg args[4];
- double text_height, clip_height;
- double y_offset;
- GdkFont *font;
-
- arrow_index = get_arrow_index (mv, arrow);
- up = (arrow_index < 42);
- day_index = up ? arrow_index : (arrow_index - 42);
-
- /* See how much we can scroll */
-
- args[0].name = "text_height";
- args[1].name = "clip_height";
- args[2].name = "y_offset";
- args[3].name = "font_gdk";
- gtk_object_getv (GTK_OBJECT (mv->text[day_index]), 4, args);
-
- text_height = GTK_VALUE_DOUBLE (args[0]);
- clip_height = GTK_VALUE_DOUBLE (args[1]);
- y_offset = GTK_VALUE_DOUBLE (args[2]);
- font = GTK_VALUE_BOXED (args[3]);
-
- if (up)
- y_offset += font->ascent + font->descent;
- else
- y_offset -= font->ascent + font->descent;
-
- if (y_offset > 0.0)
- y_offset = 0.0;
- else if (y_offset < (clip_height - text_height))
- y_offset = clip_height - text_height;
-
- /* Scroll */
-
- gnome_canvas_item_set (mv->text[day_index],
- "y_offset", y_offset,
- NULL);
-
- check_arrow_visibility (mv, day_index);
-}
-
-/* Event handler for the scroll arrows in the month view */
-static gint
-arrow_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- MonthView *mv;
-
- mv = MONTH_VIEW (data);
-
- switch (event->type) {
- case GDK_ENTER_NOTIFY:
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_PRELIGHT_DAY_BG),
- NULL);
- return TRUE;
-
- case GDK_LEAVE_NOTIFY:
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
- NULL);
- return TRUE;
-
- case GDK_BUTTON_PRESS:
- if (event->button.button != 1)
- break;
-
- do_arrow_click (mv, item);
- return TRUE;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-/* Creates a new arrow out of the specified points and connects the proper signals to it */
-static GnomeCanvasItem *
-new_arrow (MonthView *mv, GnomeCanvasGroup *group, GnomeCanvasPoints *points)
-{
- GnomeCanvasItem *item;
- char *color_spec;
-
- color_spec = color_spec_from_prop (COLOR_PROP_DAY_FG);
-
- item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
- gnome_canvas_polygon_get_type (),
- "points", points,
- "fill_color", color_spec,
- "outline_color", color_spec,
- NULL);
-
- gtk_signal_connect (GTK_OBJECT (item), "event",
- (GtkSignalFunc) arrow_event,
- mv);
-
- return item;
-}
-
-static void
-month_view_init (MonthView *mv)
-{
- int i;
- GnomeCanvasItem *day_group;
- GnomeCanvasPoints *points;
-
- /* Title */
-
- mv->title = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (mv)),
- gnome_canvas_text_get_type (),
- "anchor", GTK_ANCHOR_N,
- "fontset", HEADING_FONTSET,
- "fill_color", "black",
- NULL);
-
- /* Month item */
-
- mv->mitem = gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (mv)));
- gnome_canvas_item_set (mv->mitem,
- "x", 0.0,
- "anchor", GTK_ANCHOR_NW,
- "day_anchor", GTK_ANCHOR_NE,
- "start_on_monday", week_starts_on_monday,
- "heading_padding", 2.0,
- "heading_fontset", BIG_DAY_HEADING_FONTSET,
- "day_fontset", BIG_NORMAL_DAY_FONTSET,
- NULL);
-
- /* Arrows and text items. The arrows start hidden by default; they will be shown as
- * appropriate by the item adjustment code. Also, connect to the event signal of the
- * day groups so that we can pop up the quick view when appropriate.
- */
-
- points = gnome_canvas_points_new (3);
-
- for (i = 0; i < 42; i++) {
- day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem),
- i + GNOME_MONTH_ITEM_DAY_GROUP);
- gtk_signal_connect (GTK_OBJECT (day_group), "event",
- (GtkSignalFunc) day_event,
- mv);
-
- /* Up arrow */
-
- points->coords[0] = 3;
- points->coords[1] = 10;
- points->coords[2] = 11;
- points->coords[3] = 10;
- points->coords[4] = 7;
- points->coords[5] = 3;
-
- mv->up[i] = new_arrow (mv, GNOME_CANVAS_GROUP (day_group), points);
-
- /* Down arrow */
-
- points->coords[0] = 13;
- points->coords[1] = 3;
- points->coords[2] = 17;
- points->coords[3] = 10;
- points->coords[4] = 21;
- points->coords[5] = 3;
-
- mv->down[i] = new_arrow (mv, GNOME_CANVAS_GROUP (day_group), points);
-
- /* Text item */
-
- mv->text[i] = gnome_canvas_item_new (GNOME_CANVAS_GROUP (day_group),
- gnome_canvas_text_get_type (),
- "fontset", EVENT_FONTSET,
- "anchor", GTK_ANCHOR_NW,
- "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
- "clip", TRUE,
- NULL);
- }
- gnome_canvas_points_free (points);
-
- mv->old_current_index = -1;
-}
-
-GtkWidget *
-month_view_new (GnomeCalendar *calendar, time_t month)
-{
- MonthView *mv;
-
- g_return_val_if_fail (calendar != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CALENDAR (calendar), NULL);
-
- mv = gtk_type_new (month_view_get_type ());
- mv->calendar = calendar;
-
- month_view_colors_changed (mv);
- month_view_set (mv, month);
- return GTK_WIDGET (mv);
-}
-
-static void
-month_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (IS_MONTH_VIEW (widget));
- g_return_if_fail (requisition != NULL);
-
- if (GTK_WIDGET_CLASS (parent_class)->size_request)
- (* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition);
-
- requisition->width = 200;
- requisition->height = 150;
-}
-
-/* Adjusts the text items for events in the month view to the appropriate size. It also makes the
- * corresponding arrows visible or invisible, as appropriate.
- */
-static void
-adjust_children (MonthView *mv)
-{
- int i;
- GnomeCanvasItem *item;
- double x1, y1, x2, y2;
- GtkArg arg;
-
- for (i = 0; i < 42; i++) {
- /* Get dimensions of the day group */
-
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem), i + GNOME_MONTH_ITEM_DAY_GROUP);
- gnome_canvas_item_get_bounds (item, &x1, &y1, &x2, &y2);
-
- /* Normalize and add paddings */
-
- x2 -= x1 + EVENT_PADDING;
- x1 = EVENT_PADDING;
- y2 -= y1 + EVENT_PADDING;
- y1 = EVENT_PADDING;
-
- /* Add height of day label to y1 */
-
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem), i + GNOME_MONTH_ITEM_DAY_LABEL);
-
- arg.name = "text_height";
- gtk_object_getv (GTK_OBJECT (item), 1, &arg);
- y1 += GTK_VALUE_DOUBLE (arg);
-
- /* Set the position and clip size */
-
- gnome_canvas_item_set (mv->text[i],
- "x", x1,
- "y", y1,
- "clip_width", x2 - x1,
- "clip_height", y2 - y1,
- "x_offset", 0.0,
- "y_offset", 0.0,
- NULL);
-
- /* See what visibility state the arrows should be set to */
-
- check_arrow_visibility (mv, i);
- }
-}
-
-static void
-month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- MonthView *mv;
- GdkFont *font;
- GtkArg arg;
- int y;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (IS_MONTH_VIEW (widget));
- g_return_if_fail (allocation != NULL);
-
- mv = MONTH_VIEW (widget);
-
- if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
- (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (mv), 0, 0, allocation->width, allocation->height);
-
- /* Adjust items to new size */
-
- arg.name = "font_gdk";
- gtk_object_getv (GTK_OBJECT (mv->title), 1, &arg);
- font = GTK_VALUE_BOXED (arg);
-
- gnome_canvas_item_set (mv->title,
- "x", (double) allocation->width / 2.0,
- "y", (double) SPACING,
- NULL);
-
- y = font->ascent + font->descent + 2 * SPACING;
- gnome_canvas_item_set (mv->mitem,
- "y", (double) y,
- "width", (double) (allocation->width - 1),
- "height", (double) (allocation->height - y - 1),
- NULL);
-
- /* Adjust children */
-
- adjust_children (mv);
-}
-
-/* This defines the environment for the calendar iterator function that is used to populate the
- * month view with events.
- */
-struct iter_info {
- MonthView *mv; /* The month view we are creating children for */
- int first_day_index; /* Index of the first day of the month within the month item */
- time_t month_begin, month_end; /* Beginning and end of month */
- GString **strings; /* Array of strings to populate */
-};
-
-/* This is the calendar iterator function used to populate the string array with event information.
- * For each event, it iterates through all the days that the event touches and appends the proper
- * information to the string array in the iter_info structure.
- */
-static int
-add_event (iCalObject *ico, time_t start, time_t end, void *data)
-{
- struct iter_info *ii;
- struct tm tm;
- time_t t;
- time_t day_begin_time, day_end_time;
-
- ii = data;
-
- /* Get the first day of the event */
-
- t = MAX (start, ii->month_begin);
- day_begin_time = time_day_begin (t);
- day_end_time = time_day_end (day_begin_time);
-
- /* Loop until the event ends or the month ends. For each day touched, append the proper
- * information to the corresponding string.
- */
-
- do {
- tm = *localtime (&day_begin_time);
- g_string_sprintfa (ii->strings[ii->first_day_index + tm.tm_mday - 1], "%s\n", ico->summary);
-
- /* Next day */
-
- day_begin_time = time_add_day (day_begin_time, 1);
- day_end_time = time_day_end (day_begin_time);
- } while ((end > day_begin_time) && (day_begin_time < ii->month_end));
-
- return TRUE; /* this means we are not finished yet with event generation */
-}
-
-void
-month_view_update (MonthView *mv, iCalObject *object, int flags)
-{
- struct iter_info ii;
- GString *strings[42];
- int i;
- time_t t;
-
- g_return_if_fail (mv != NULL);
- g_return_if_fail (IS_MONTH_VIEW (mv));
-
- ii.mv = mv;
-
- /* Create an array of empty GStrings */
-
- ii.strings = strings;
-
- for (i = 0; i < 42; i++)
- strings[i] = g_string_new (NULL);
-
- ii.first_day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (mv->mitem), 1);
- g_assert (ii.first_day_index != -1);
-
- /* Populate the array of strings with events */
-
- t = time_from_day (mv->year, mv->month, 1);
- ii.month_begin = time_month_begin (t);
- ii.month_end = time_month_end (t);
-
- calendar_iterate (mv->calendar->cal, ii.month_begin, ii.month_end, add_event, &ii);
-
- for (i = 0; i < 42; i++) {
- /* Delete the last character if it is a newline */
-
- if (strings[i]->str && strings[i]->len && (strings[i]->str[strings[i]->len - 1] == '\n'))
- g_string_truncate (strings[i], strings[i]->len - 1);
-
- gnome_canvas_item_set (mv->text[i],
- "text", strings[i]->str,
- NULL);
- g_string_free (strings[i], TRUE);
- }
-
- /* Adjust children for scrolling */
-
- adjust_children (mv);
-}
-
-/* Unmarks the old day that was marked as current and marks the current day if appropriate */
-static void
-mark_current_day (MonthView *mv)
-{
- time_t t;
- struct tm tm;
- GnomeCanvasItem *item;
-
- /* Unmark the old day */
-
- if (mv->old_current_index != -1) {
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem),
- GNOME_MONTH_ITEM_DAY_LABEL + mv->old_current_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
- "fontset", BIG_NORMAL_DAY_FONTSET,
- NULL);
-
- mv->old_current_index = -1;
- }
-
- /* Mark the new day */
-
- t = time (NULL);
- tm = *localtime (&t);
-
- if (((tm.tm_year + 1900) == mv->year) && (tm.tm_mon == mv->month)) {
- mv->old_current_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (mv->mitem), tm.tm_mday);
- g_assert (mv->old_current_index != -1);
-
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem),
- GNOME_MONTH_ITEM_DAY_LABEL + mv->old_current_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
- "fontset", BIG_CURRENT_DAY_FONTSET,
- NULL);
- }
-}
-
-void
-month_view_set (MonthView *mv, time_t month)
-{
- struct tm tm;
- char buf[100];
-
- g_return_if_fail (mv != NULL);
- g_return_if_fail (IS_MONTH_VIEW (mv));
-
- /* Title */
-
- tm = *localtime (&month);
-
- mv->year = tm.tm_year + 1900;
- mv->month = tm.tm_mon;
-
- strftime (buf, 100, _("%B %Y"), &tm);
-
- gnome_canvas_item_set (mv->title,
- "text", buf,
- NULL);
-
- /* Month item */
-
- gnome_canvas_item_set (mv->mitem,
- "year", mv->year,
- "month", mv->month,
- NULL);
-
- /* Update events */
-
- month_view_update (mv, NULL, 0);
- mark_current_day (mv);
-}
-
-void
-month_view_time_format_changed (MonthView *mv)
-{
- g_return_if_fail (mv != NULL);
- g_return_if_fail (IS_MONTH_VIEW (mv));
-
- gnome_canvas_item_set (mv->mitem,
- "start_on_monday", week_starts_on_monday,
- NULL);
-
- month_view_set (mv, time_month_begin (time_from_day (mv->year, mv->month, 1)));
-}
-
-void
-month_view_colors_changed (MonthView *mv)
-{
- g_return_if_fail (mv != NULL);
- g_return_if_fail (IS_MONTH_VIEW (mv));
-
- colorify_month_item (GNOME_MONTH_ITEM (mv->mitem), default_color_func, NULL);
- mark_current_day (mv);
-
- /* FIXME: set children to the marked color */
-}
diff --git a/calendar/gui/month-view.h b/calendar/gui/month-view.h
deleted file mode 100644
index 6e49c2f931..0000000000
--- a/calendar/gui/month-view.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Month view display for gncal
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef MONTH_VIEW_H
-#define MONTH_VIEW_H
-
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-#include "gnome-month-item.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define TYPE_MONTH_VIEW (month_view_get_type ())
-#define MONTH_VIEW(obj) (GTK_CHECK_CAST ((obj), TYPE_MONTH_VIEW, MonthView))
-#define MONTH_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_MONTH_VIEW, MonthViewClass))
-#define IS_MONTH_VIEW(obj) (GTK_CHECK_TYPE ((obj), TYPE_MONTH_VIEW))
-#define IS_MONTH_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_MONTH_VIEW))
-
-
-typedef struct _MonthView MonthView;
-typedef struct _MonthViewClass MonthViewClass;
-
-struct _MonthView {
- GnomeCanvas canvas;
-
- GnomeCalendar *calendar; /* The calendar we are associated to */
-
- int year; /* The year of the month we are displaying */
- int month; /* The month we are displaying */
- int old_current_index; /* The index of the day marked as current, or -1 if none */
-
- GnomeCanvasItem *up[42]; /* Arrows to go up in the days */
- GnomeCanvasItem *down[42]; /* Arrows to go down in the days */
- GnomeCanvasItem *text[42]; /* Text items for the events */
-
- GnomeCanvasItem *title; /* The title heading with the month/year */
- GnomeCanvasItem *mitem; /* The canvas month item used by this month view */
-};
-
-struct _MonthViewClass {
- GnomeCanvasClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType month_view_get_type (void);
-
-/* Creates a new month view widget associated to the specified calendar */
-GtkWidget *month_view_new (GnomeCalendar *calendar, time_t month);
-
-/* Notifies the month view that a calendar object has changed */
-void month_view_update (MonthView *mv, iCalObject *ico, int flags);
-
-/* Notifies the month view about a change of date */
-void month_view_set (MonthView *mv, time_t month);
-
-/* Notifies the month view that the time format has changed */
-void month_view_time_format_changed (MonthView *mv);
-
-/* Notifies the month view that the colors have changed */
-void month_view_colors_changed (MonthView *mv);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/popup-menu.c b/calendar/gui/popup-menu.c
deleted file mode 100644
index 3686183146..0000000000
--- a/calendar/gui/popup-menu.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Popup menu utilities for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#include <config.h>
-#include <gnome.h>
-#include "popup-menu.h"
-
-
-void
-popup_menu (struct menu_item *items, int nitems, GdkEventButton *event)
-{
- GtkWidget *menu;
- GtkWidget *item;
- int i;
-
- menu = gtk_menu_new (); /* FIXME: this baby is never freed */
-
- for (i = 0; i < nitems; i++) {
- if (items[i].text) {
- item = gtk_menu_item_new_with_label (_(items[i].text));
- gtk_signal_connect (GTK_OBJECT (item), "activate",
- items[i].callback,
- items[i].data);
- gtk_widget_set_sensitive (item, items[i].sensitive);
- } else
- item = gtk_menu_item_new ();
-
- gtk_widget_show (item);
- gtk_menu_append (GTK_MENU (menu), item);
- }
-
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
-}
diff --git a/calendar/gui/popup-menu.h b/calendar/gui/popup-menu.h
deleted file mode 100644
index a4590dbb98..0000000000
--- a/calendar/gui/popup-menu.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Popup menu utilities for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef POPUP_MENU_H
-#define POPUP_MENU_H
-
-#include <gdk/gdktypes.h>
-#include <gtk/gtksignal.h>
-
-
-struct menu_item {
- char *text;
- GtkSignalFunc callback;
- gpointer data;
- int sensitive;
-};
-
-void popup_menu (struct menu_item *items, int nitems, GdkEventButton *event);
-
-
-#endif
diff --git a/calendar/gui/prop.c b/calendar/gui/prop.c
deleted file mode 100644
index 8e91f4d730..0000000000
--- a/calendar/gui/prop.c
+++ /dev/null
@@ -1,927 +0,0 @@
-/* Calendar properties dialog box
- *
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors: Miguel de Icaza <miguel@kernel.org>
- * Federico Mena <federico@nuclecu.unam.mx>
- */
-#include <config.h>
-#ifdef HAVE_LANGINGO_H
-#include <langinfo.h>
-#else
-#include <locale.h>
-#endif
-#include <gnome.h>
-#include "gnome-cal.h"
-#include "gnome-month-item.h"
-#include "main.h"
-#include "mark.h"
-
-/* These specify the page numbers in the preferences notebook */
-enum {
- PROP_TIME_DISPLAY,
- PROP_COLORS,
- PROP_TODO,
- PROP_ALARMS
-};
-
-static GtkWidget *prop_win; /* The preferences dialog */
-
-/* Widgets for the time display page */
-
-static GtkWidget *time_format_12; /* Radio button for 12-hour format */
-static GtkWidget *time_format_24; /* Radio button for 24-hour format */
-static GtkWidget *start_on_sunday; /* Check button for weeks starting on Sunday */
-static GtkWidget *start_on_monday; /* Check button for weeks starting on Monday */
-static GtkWidget *start_omenu; /* Option menu for start of day */
-static GtkWidget *end_omenu; /* Option menu for end of day */
-static GtkWidget *start_items[24]; /* Menu items for start of day menu */
-static GtkWidget *end_items[24]; /* Menu items for end of day menu */
-
-/* Widgets for the colors page */
-
-static GtkWidget *color_pickers[COLOR_PROP_LAST];
-static GnomeCanvasItem *month_item;
-
-/* Widgets for the todo page */
-static GtkWidget *due_date_show_button;
-
-static GtkWidget *todo_item_time_remaining_show_button;
-
-static GtkWidget *todo_item_highlight_overdue;
-static GtkWidget *todo_item_highlight_not_due_yet;
-static GtkWidget *todo_item_highlight_due_today;
-
-static GtkWidget *priority_show_button;
-
-/* Widgets for the alarm page */
-static GtkWidget *enable_display_beep;
-static GtkWidget *to_cb;
-static GtkWidget *to_spin;
-static GtkWidget *snooze_cb;
-static GtkWidget *snooze_spin;
-
-/* prototypes */
-static void prop_apply_alarms (void);
-static void create_alarm_page (void);
-static void to_cb_changed (GtkWidget* object, gpointer data);
-static void snooze_cb_changed (GtkWidget* object, gpointer data);
-
-GtkWidget* make_spin_button (int val, int low, int high);
-void ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm,
- enum AlarmType type, int y, gboolean sens,
- GtkSignalFunc dirty_func);
-void ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type);
-
-/* Callback used when the property box is closed -- just sets the prop_win variable to null. */
-static int
-prop_cancel (void)
-{
- prop_win = NULL;
- return FALSE;
-}
-
-/* Returns the index of the active item in a menu */
-static int
-get_active_index (GtkWidget *menu)
-{
- GtkWidget *active;
-
- active = gtk_menu_get_active (GTK_MENU (menu));
- return GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (active)));
-}
-
-/* Applies the settings in the time display page */
-static void
-prop_apply_time_display (void)
-{
- /* Day begin/end */
-
- day_begin = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (start_omenu)));
- day_end = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (end_omenu)));
- gnome_config_set_int ("/calendar/Calendar/Day start", day_begin);
- gnome_config_set_int ("/calendar/Calendar/Day end", day_end);
-
- /* Time format */
-
- am_pm_flag = GTK_TOGGLE_BUTTON (time_format_12)->active;
- gnome_config_set_bool ("/calendar/Calendar/AM PM flag", am_pm_flag);
-
- /* Week start */
-
- week_starts_on_monday = GTK_TOGGLE_BUTTON (start_on_monday)->active;
- gnome_config_set_bool ("/calendar/Calendar/Week starts on Monday", week_starts_on_monday);
-
- gnome_config_sync ();
- time_format_changed ();
-}
-
-/* Applies the settings in the colors page */
-static void
-prop_apply_colors (void)
-{
- int i;
- char *cspec;
- gushort r, g, b;
-
- for (i = 0; i < COLOR_PROP_LAST; i++) {
- gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[i]), &r, &g, &b, NULL);
- color_props[i].r = r;
- color_props[i].g = g;
- color_props[i].b = b;
-
- cspec = build_color_spec (color_props[i].r, color_props[i].g, color_props[i].b);
- gnome_config_set_string (color_props[i].key, cspec);
- }
-
- gnome_config_sync ();
- colors_changed ();
-}
-/* Applies the settings in the todo page (FIX THIS IF ITS NOT WRITTEN) */
-static void
-prop_apply_todo(void)
-{
- todo_show_due_date = GTK_TOGGLE_BUTTON (due_date_show_button)->active;
-
- todo_item_dstatus_highlight_overdue = GTK_TOGGLE_BUTTON(todo_item_highlight_overdue)->active;
- todo_item_dstatus_highlight_not_due_yet = GTK_TOGGLE_BUTTON(todo_item_highlight_not_due_yet)->active;
- todo_item_dstatus_highlight_due_today = GTK_TOGGLE_BUTTON(todo_item_highlight_due_today)->active;
-
- todo_show_priority = GTK_TOGGLE_BUTTON (priority_show_button)->active;
-
- todo_show_time_remaining = GTK_TOGGLE_BUTTON (todo_item_time_remaining_show_button)->active;
-
- /* storing the values */
-
- gnome_config_set_bool("/calendar/Todo/show_time_remain", todo_show_time_remaining);
- gnome_config_set_bool("/calendar/Todo/highlight_overdue", todo_item_dstatus_highlight_overdue);
-
- gnome_config_set_bool("/calendar/Todo/highlight_due_today", todo_item_dstatus_highlight_due_today);
-
- gnome_config_set_bool("/calendar/Todo/highlight_not_due_yet", todo_item_dstatus_highlight_not_due_yet);
- gnome_config_set_bool("/calendar/Todo/show_due_date", todo_show_due_date);
- gnome_config_set_bool("/calendar/Todo/show_priority", todo_show_priority);
- /* need to sync our config changes. */
- gnome_config_sync ();
-
- /* apply the current changes */
- todo_properties_changed();
-}
-
-
-/* Callback used when the Apply button is clicked. */
-static void
-prop_apply (GtkWidget *w, int page)
-{
- switch (page) {
- case PROP_TIME_DISPLAY:
- prop_apply_time_display ();
- break;
-
- case PROP_COLORS:
- prop_apply_colors ();
- break;
-
- case PROP_TODO:
- prop_apply_todo ();
- break;
-
- case PROP_ALARMS:
- prop_apply_alarms ();
- break;
-
- case -1:
- break;
-
- default:
- g_warning ("We have a loose penguin!");
- g_assert_not_reached ();
- }
-}
-
-/* Notifies the property box that the data has changed */
-static void
-prop_changed (void)
-{
- gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
-}
-
-/* Builds and returns a two-element radio button group surrounded by a frame. The radio buttons are
- * stored in the specified variables, and the first radio button's state is set according to the
- * specified flag value. The buttons are connected to the prop_changed() function to update the property
- * box's dirty state.
- */
-static GtkWidget *
-build_two_radio_group (char *title,
- char *radio_1_title, GtkWidget **radio_1_widget,
- char *radio_2_title, GtkWidget **radio_2_widget,
- int radio_1_value)
-{
- GtkWidget *frame;
- GtkWidget *vbox;
-
- frame = gtk_frame_new (title);
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
-
- *radio_1_widget = gtk_radio_button_new_with_label (NULL, radio_1_title);
- gtk_box_pack_start (GTK_BOX (vbox), *radio_1_widget, FALSE, FALSE, 0);
-
- *radio_2_widget = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (*radio_1_widget),
- radio_2_title);
- gtk_box_pack_start (GTK_BOX (vbox), *radio_2_widget, FALSE, FALSE, 0);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_1_widget), radio_1_value);
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_2_widget), !radio_1_value);
-
- gtk_signal_connect (GTK_OBJECT (*radio_1_widget), "toggled",
- (GtkSignalFunc) prop_changed,
- NULL);
-
- return frame;
-}
-
-/* Callback invoked when a menu item from the start/end time option menus is selected. It adjusts
- * the other menu to the proper time, if needed.
- */
-static void
-hour_activated (GtkWidget *widget, gpointer data)
-{
- int start, end;
-
- if (data == start_omenu) {
- /* Adjust the end menu */
-
- start = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget)));
- end = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (end_omenu)));
-
- if (end < start)
- gtk_option_menu_set_history (GTK_OPTION_MENU (end_omenu), start);
- } else if (data == end_omenu) {
- /* Adjust the start menu */
-
- end = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget)));
- start = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (start_omenu)));
-
- if (start > end)
- gtk_option_menu_set_history (GTK_OPTION_MENU (start_omenu), end);
- } else
- g_assert_not_reached ();
-
- gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
-}
-
-/* Builds an option menu of 24 hours */
-static GtkWidget *
-build_hours_menu (GtkWidget **items, int active)
-{
- GtkWidget *omenu;
- GtkWidget *menu;
- int i;
- char buf[100];
- struct tm tm;
- int am_pm_flag;
-
- omenu = gtk_option_menu_new ();
- menu = gtk_menu_new ();
- am_pm_flag = GTK_TOGGLE_BUTTON (time_format_12)->active;
-
- memset (&tm, 0, sizeof (tm));
-
- for (i = 0; i < 24; i++) {
- tm.tm_hour = i;
- if (am_pm_flag)
- strftime (buf, 100, "%I:%M %p", &tm);
- else
- strftime (buf, 100, "%H:%M", &tm);
-
- items[i] = gtk_menu_item_new_with_label (buf);
- gtk_object_set_user_data (GTK_OBJECT (items[i]), GINT_TO_POINTER (i));
- gtk_signal_connect (GTK_OBJECT (items[i]), "activate",
- (GtkSignalFunc) hour_activated,
- omenu);
-
- gtk_menu_append (GTK_MENU (menu), items[i]);
- gtk_widget_show (items[i]);
- }
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
- gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), active);
- return omenu;
-}
-
-/* Creates the time display page in the preferences dialog */
-static void
-create_time_display_page (void)
-{
- GtkWidget *table;
- GtkWidget *vbox;
- GtkWidget *frame;
- GtkWidget *hbox2;
- GtkWidget *hbox3;
- GtkWidget *w;
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (table), GNOME_PAD_SMALL);
- gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
- gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
- gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), table,
- gtk_label_new (_("Time display")));
-
- /* Time format */
-
- w = build_two_radio_group (_("Time format"),
- _("12-hour (AM/PM)"), &time_format_12,
- _("24-hour"), &time_format_24,
- am_pm_flag);
- gtk_table_attach (GTK_TABLE (table), w,
- 0, 1, 0, 1,
- GTK_EXPAND | GTK_FILL,
- GTK_EXPAND | GTK_FILL,
- 0, 0);
-
- /* Weeks start on */
-
- w = build_two_radio_group (_("Weeks start on"),
- _("Sunday"), &start_on_sunday,
- _("Monday"), &start_on_monday,
- !week_starts_on_monday);
- gtk_table_attach (GTK_TABLE (table), w,
- 0, 1, 1, 2,
- GTK_EXPAND | GTK_FILL,
- GTK_EXPAND | GTK_FILL,
- 0, 0);
-
- /* Day range */
-
- frame = gtk_frame_new (_("Day range"));
- gtk_table_attach (GTK_TABLE (table), frame,
- 1, 2, 0, 2,
- GTK_EXPAND | GTK_FILL,
- GTK_EXPAND | GTK_FILL,
- 0, 0);
-
- vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
-
- w = gtk_label_new (_("Please select the start and end hours you want\n"
- "to be displayed in the day view and week view.\n"
- "Times outside this range will not be displayed\n"
- "by default."));
- gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT);
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
-
- hbox2 = gtk_hbox_new (FALSE, GNOME_PAD);
- gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
-
- /* Day start */
-
- hbox3 = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
- gtk_box_pack_start (GTK_BOX (hbox2), hbox3, FALSE, FALSE, 0);
-
- w = gtk_label_new (_("Day start:"));
- gtk_box_pack_start (GTK_BOX (hbox3), w, FALSE, FALSE, 0);
-
- start_omenu = build_hours_menu (start_items, day_begin);
- gtk_box_pack_start (GTK_BOX (hbox3), start_omenu, FALSE, FALSE, 0);
-
- /* Day end */
-
- hbox3 = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
- gtk_box_pack_start (GTK_BOX (hbox2), hbox3, FALSE, FALSE, 0);
-
- w = gtk_label_new (_("Day end:"));
- gtk_box_pack_start (GTK_BOX (hbox3), w, FALSE, FALSE, 0);
-
- end_omenu = build_hours_menu (end_items, day_end);
- gtk_box_pack_start (GTK_BOX (hbox3), end_omenu, FALSE, FALSE, 0);
-}
-
-/* Called when the canvas for the month item is size allocated. We use this to change the canvas'
- * scrolling region and the month item's size.
- */
-static void
-canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data)
-{
- gnome_canvas_item_set (month_item,
- "width", (double) (allocation->width - 1),
- "height", (double) (allocation->height - 1),
- NULL);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (widget),
- 0, 0,
- allocation->width, allocation->height);
-}
-
-/* Returns a color spec based on the color pickers */
-static char *
-color_spec_from_picker (int num)
-{
- gushort r, g, b;
-
- gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[num]), &r, &g, &b, NULL);
-
- return build_color_spec (r, g, b);
-}
-
-/* Callback used to query color information for the properties box */
-static char *
-fetch_color_spec (ColorProp propnum, gpointer data)
-{
- return color_spec_from_picker (propnum);
-}
-
-/* Marks fake event days in the month item sample */
-static void
-fake_mark_days (void)
-{
- static int day_nums[] = { 1, 4, 8, 16, 17, 18, 20, 25, 28 }; /* some random days */
- int first_day_index;
- int i;
-
- first_day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (month_item), 1);
-
- for (i = 0; i < (sizeof (day_nums) / sizeof (day_nums[0])); i++)
- mark_month_item_index (GNOME_MONTH_ITEM (month_item), first_day_index + day_nums[i] - 1,
- fetch_color_spec, NULL);
-}
-
-/* Switches the month item to the current date and highlights the current day's number */
-static void
-set_current_day (void)
-{
- struct tm tm;
- time_t t;
- GnomeCanvasItem *item;
- int day_index;
-
- /* Set the date */
-
- t = time (NULL);
- tm = *localtime (&t);
-
- gnome_canvas_item_set (month_item,
- "year", tm.tm_year + 1900,
- "month", tm.tm_mon,
- NULL);
-
- /* Highlight current day */
-
- day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (month_item), tm.tm_mday);
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (month_item), GNOME_MONTH_ITEM_DAY_LABEL + day_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_picker (COLOR_PROP_CURRENT_DAY_FG),
- "fontset", CURRENT_DAY_FONTSET,
- NULL);
-}
-
-/* This is the version of a color spec query function that is appropriate for the preferences dialog */
-static char *
-prop_color_func (ColorProp propnum, gpointer data)
-{
- return color_spec_from_picker (propnum);
-}
-
-/* Sets the colors of the month item to the current prerences */
-static void
-reconfigure_month (void)
-{
- colorify_month_item (GNOME_MONTH_ITEM (month_item), prop_color_func, NULL);
- fake_mark_days ();
- set_current_day ();
-
- /* Reset prelighting information */
-
- month_item_prepare_prelight (GNOME_MONTH_ITEM (month_item), fetch_color_spec, NULL);
-}
-
-/* Callback used when a color is changed */
-static void
-color_set (void)
-{
- reconfigure_month ();
- prop_changed ();
-}
-
-/* Creates the colors page in the preferences dialog */
-static void
-create_colors_page (void)
-{
- GtkWidget *frame;
- GtkWidget *hbox;
- GtkWidget *table;
- GtkWidget *w;
- int i;
-
- frame = gtk_frame_new (_("Colors for display"));
- gtk_container_set_border_width (GTK_CONTAINER (frame), GNOME_PAD_SMALL);
- gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), frame,
- gtk_label_new (_("Colors")));
-
- hbox = gtk_hbox_new (FALSE, GNOME_PAD);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
- gtk_container_add (GTK_CONTAINER (frame), hbox);
-
- table = gtk_table_new (COLOR_PROP_LAST, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
- gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);
-
- /* Create the color pickers */
-
- for (i = 0; i < COLOR_PROP_LAST; i++) {
- /* Label */
-
- w = gtk_label_new (_(color_props[i].label));
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (table), w,
- 0, 1, i, i + 1,
- GTK_FILL, 0,
- 0, 0);
-
- /* Color picker */
-
- color_pickers[i] = gnome_color_picker_new ();
- gnome_color_picker_set_title (GNOME_COLOR_PICKER (color_pickers[i]), _(color_props[i].label));
- gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (color_pickers[i]),
- color_props[i].r, color_props[i].g, color_props[i].b, 0);
- gtk_table_attach (GTK_TABLE (table), color_pickers[i],
- 1, 2, i, i + 1,
- 0, 0,
- 0, 0);
- gtk_signal_connect (GTK_OBJECT (color_pickers[i]), "color_set",
- (GtkSignalFunc) color_set,
- NULL);
- }
-
- /* Create the sample calendar */
-
- w = gnome_canvas_new ();
- gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
-
- month_item = gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (w)));
- gnome_canvas_item_set (month_item,
- "start_on_monday", week_starts_on_monday,
- NULL);
- reconfigure_month ();
-
- gtk_signal_connect (GTK_OBJECT (w), "size_allocate",
- canvas_size_allocate,
- NULL);
-
-}
-
-
-static void
-set_todo_page_options(void)
-{
-
-
- while (gtk_events_pending ())
- gtk_main_iteration ();
-}
-
-static void
-todo_option_set (void)
-{
- prop_changed ();
- set_todo_page_options ();
-}
-
-/* Creates the colors page in the preferences dialog */
-static GtkWidget *
-build_list_options_frame(void)
-{
- GtkWidget *frame;
- GtkWidget *vbox;
- frame = gtk_frame_new (_("Show on TODO List:"));
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
-
- due_date_show_button = gtk_check_button_new_with_label (_("Due Date"));
- priority_show_button = gtk_check_button_new_with_label (_("Priority"));
- todo_item_time_remaining_show_button = gtk_check_button_new_with_label (_("Time Until Due"));
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(due_date_show_button), todo_show_due_date);
- gtk_signal_connect (GTK_OBJECT(due_date_show_button),
- "clicked",
- (GtkSignalFunc) todo_option_set,
- NULL);
- gtk_box_pack_start (GTK_BOX (vbox), due_date_show_button, FALSE, FALSE, 0);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_time_remaining_show_button), todo_show_time_remaining);
- gtk_signal_connect (GTK_OBJECT(todo_item_time_remaining_show_button),
- "clicked",
- (GtkSignalFunc) todo_option_set,
- NULL);
- gtk_box_pack_start (GTK_BOX (vbox), todo_item_time_remaining_show_button, FALSE, FALSE, 0);
-
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(priority_show_button), todo_show_priority);
- gtk_signal_connect (GTK_OBJECT(priority_show_button),
- "clicked",
- (GtkSignalFunc) todo_option_set,
- NULL);
- gtk_box_pack_start (GTK_BOX (vbox), priority_show_button, FALSE, FALSE, 0);
- return frame;
-}
-static GtkWidget *
-build_style_list_options_frame(void)
-{
- GtkWidget *frame;
- GtkWidget *vbox;
-
- frame = gtk_frame_new (_("To Do List style options:"));
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
-
- todo_item_highlight_overdue = gtk_check_button_new_with_label (_("Highlight overdue items"));
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_highlight_overdue),
- todo_item_dstatus_highlight_overdue);
- todo_item_highlight_not_due_yet = gtk_check_button_new_with_label (_("Highlight not yet due items"));
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_highlight_not_due_yet),
- todo_item_dstatus_highlight_overdue);
- todo_item_highlight_due_today = gtk_check_button_new_with_label (_("Highlight items due today"));
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_highlight_due_today),
- todo_item_dstatus_highlight_overdue);
-
- gtk_signal_connect (GTK_OBJECT(todo_item_highlight_overdue),
- "clicked",
- (GtkSignalFunc) todo_option_set,
- NULL);
- gtk_signal_connect (GTK_OBJECT(todo_item_highlight_not_due_yet),
- "clicked",
- (GtkSignalFunc) todo_option_set,
- NULL);
- gtk_signal_connect (GTK_OBJECT(todo_item_highlight_due_today),
- "clicked",
- (GtkSignalFunc) todo_option_set,
- NULL);
-
- gtk_box_pack_start (GTK_BOX (vbox), todo_item_highlight_overdue, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), todo_item_highlight_due_today, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), todo_item_highlight_not_due_yet, FALSE, FALSE, 0);
- return frame;
-}
-static void
-create_todo_page (void)
-{
- GtkWidget *frame;
- GtkWidget *main_box;
- GtkWidget *hbox;
-
-
- frame = gtk_frame_new (_("To Do List Properties"));
- gtk_container_set_border_width (GTK_CONTAINER (frame), GNOME_PAD_SMALL);
- gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), frame,
- gtk_label_new (_("To Do List")));
-
- /* first vbox*/
- main_box = gtk_vbox_new(FALSE, GNOME_PAD);
- gtk_container_set_border_width (GTK_CONTAINER (main_box), GNOME_PAD_SMALL);
- gtk_container_add (GTK_CONTAINER (frame), main_box);
-
-
- /* first hbox*/
- hbox = gtk_hbox_new (FALSE, GNOME_PAD);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
- gtk_container_add (GTK_CONTAINER (main_box), hbox);
-
- gtk_box_pack_start (GTK_BOX(hbox), build_list_options_frame(), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX(hbox), build_style_list_options_frame(), FALSE, FALSE, 0);
-
- set_todo_page_options();
-}
-
-/* Creates and displays the preferences dialog for the whole application */
-void
-properties (GtkWidget *toplevel)
-{
- static GnomeHelpMenuEntry help_entry = { NULL, "properties" };
-
- help_entry.name = gnome_app_id;
-
- if (prop_win)
- return;
-
- prop_win = gnome_property_box_new ();
- gtk_window_set_title (GTK_WINDOW (prop_win), _("Preferences"));
- gnome_dialog_set_parent (GNOME_DIALOG (prop_win), GTK_WINDOW (toplevel));
-
- create_time_display_page ();
- create_colors_page ();
- create_todo_page ();
- create_alarm_page ();
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "destroy",
- (GtkSignalFunc) prop_cancel, NULL);
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "delete_event",
- (GtkSignalFunc) prop_cancel, NULL);
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "apply",
- (GtkSignalFunc) prop_apply, NULL);
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "help",
- GTK_SIGNAL_FUNC (gnome_help_pbox_display),
- &help_entry);
-
- gtk_widget_show_all (prop_win);
-}
-
-char *
-build_color_spec (int r, int g, int b)
-{
- static char spec[100];
-
- sprintf (spec, "#%04x%04x%04x", r, g, b);
- return spec;
-}
-
-void
-parse_color_spec (char *spec, int *r, int *g, int *b)
-{
- g_return_if_fail (spec != NULL);
- g_return_if_fail (r != NULL);
- g_return_if_fail (r != NULL);
- g_return_if_fail (r != NULL);
-
- if (sscanf (spec, "#%04x%04x%04x", r, g, b) != 3) {
- g_warning ("Invalid color specification %s, returning black", spec);
-
- *r = *g = *b = 0;
- }
-}
-
-char *
-color_spec_from_prop (ColorProp propnum)
-{
- return build_color_spec (color_props[propnum].r, color_props[propnum].g, color_props[propnum].b);
-}
-
-static void
-create_alarm_page (void)
-{
- GtkWidget *main_box;
- GtkWidget *default_frame;
- GtkWidget *default_table;
- GtkWidget *misc_frame;
- GtkWidget *misc_box;
- GtkWidget *box, *l;
-
- main_box = gtk_vbox_new (FALSE, GNOME_PAD);
- gtk_container_set_border_width (GTK_CONTAINER (main_box), GNOME_PAD_SMALL);
- gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win),
- main_box, gtk_label_new (_("Alarms")));
-
- /* build miscellaneous box */
- misc_frame = gtk_frame_new (_("Alarm Properties"));
- gtk_container_set_border_width (GTK_CONTAINER (misc_frame),
- GNOME_PAD_SMALL);
- misc_box = gtk_vbox_new (FALSE, GNOME_PAD);
-
- gtk_container_set_border_width (GTK_CONTAINER (misc_frame), GNOME_PAD_SMALL);
- gtk_container_add (GTK_CONTAINER (misc_frame), misc_box);
-
- gtk_box_pack_start (GTK_BOX (main_box), misc_frame, FALSE, FALSE, 0);
-
- enable_display_beep = gtk_check_button_new_with_label (_("Beep on display alarms"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enable_display_beep),
- beep_on_display);
- gtk_box_pack_start (GTK_BOX (misc_box), enable_display_beep, FALSE, FALSE, 0);
- gtk_signal_connect (GTK_OBJECT (enable_display_beep), "toggled",
- (GtkSignalFunc) prop_changed,
- NULL);
-
- /* audio timeout widgets */
- box = gtk_hbox_new (FALSE, GNOME_PAD);
- to_cb = gtk_check_button_new_with_label (_("Audio alarms timeout after"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (to_cb),
- enable_aalarm_timeout);
- gtk_signal_connect (GTK_OBJECT (to_cb), "toggled",
- (GtkSignalFunc) to_cb_changed, NULL);
- gtk_box_pack_start (GTK_BOX (box), to_cb, FALSE, FALSE, 0);
- to_spin = make_spin_button (audio_alarm_timeout, 1, MAX_AALARM_TIMEOUT);
- gtk_widget_set_sensitive (to_spin, enable_aalarm_timeout);
- gtk_signal_connect (GTK_OBJECT (to_spin), "changed",
- (GtkSignalFunc) prop_changed, NULL);
- gtk_box_pack_start (GTK_BOX (box), to_spin, FALSE, FALSE, 0);
- l = gtk_label_new (_(" seconds"));
- gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (misc_box), box, FALSE, FALSE, 0);
-
- /* snooze widgets */
- box = gtk_hbox_new (FALSE, GNOME_PAD);
- snooze_cb = gtk_check_button_new_with_label (_("Enable snoozing for "));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (snooze_cb),
- enable_snooze);
- gtk_signal_connect (GTK_OBJECT (snooze_cb), "toggled",
- (GtkSignalFunc) snooze_cb_changed, NULL);
- gtk_box_pack_start (GTK_BOX (box), snooze_cb, FALSE, FALSE, 0);
- snooze_spin = make_spin_button (snooze_secs, 1, MAX_SNOOZE_SECS);
- gtk_widget_set_sensitive (snooze_spin, enable_snooze);
- gtk_signal_connect (GTK_OBJECT (snooze_spin), "changed",
- (GtkSignalFunc) prop_changed, NULL);
- gtk_box_pack_start (GTK_BOX (box), snooze_spin, FALSE, FALSE, 0);
- l = gtk_label_new (_(" seconds"));
- gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (misc_box), box, FALSE, FALSE, 0);
-
- /* populate default frame/box */
- default_frame = gtk_frame_new (_("Defaults"));
- gtk_container_set_border_width (GTK_CONTAINER (default_frame), GNOME_PAD_SMALL);
- gtk_box_pack_start (GTK_BOX (main_box), default_frame, FALSE, FALSE, 0);
- default_table = gtk_table_new (1, 1, 0);
- gtk_container_set_border_width (GTK_CONTAINER (default_table), 4);
- gtk_table_set_row_spacings (GTK_TABLE (default_table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (default_table), 4);
- gtk_container_add (GTK_CONTAINER (default_frame), default_table);
-
- ee_create_ae (GTK_TABLE (default_table), _("Display"),
- &alarm_defaults [ALARM_DISPLAY], ALARM_DISPLAY, 1,
- FALSE, prop_changed);
- ee_create_ae (GTK_TABLE (default_table), _("Audio"),
- &alarm_defaults [ALARM_AUDIO], ALARM_AUDIO, 2,
- FALSE, prop_changed);
- ee_create_ae (GTK_TABLE (default_table), _("Program"),
- &alarm_defaults [ALARM_PROGRAM], ALARM_PROGRAM, 3,
- FALSE, prop_changed);
- ee_create_ae (GTK_TABLE (default_table), _("Mail"),
- &alarm_defaults [ALARM_MAIL], ALARM_MAIL, 4,
- FALSE, prop_changed);
-}
-
-static void
-prop_store_alarm_default_values (CalendarAlarm* alarm)
-{
- ee_store_alarm (alarm, alarm->type);
-
- switch (alarm->type) {
- case ALARM_DISPLAY:
- gnome_config_push_prefix ("/calendar/alarms/def_disp_");
- break;
- case ALARM_AUDIO:
- gnome_config_push_prefix ("/calendar/alarms/def_audio_");
- break;
- case ALARM_PROGRAM:
- gnome_config_push_prefix ("/calendar/alarms/def_prog_");
- break;
- case ALARM_MAIL:
- gnome_config_push_prefix ("/calendar/alarms/def_mail_");
- break;
- }
-
- gnome_config_set_int ("enabled", alarm->enabled);
- gnome_config_set_int ("count", alarm->count);
- gnome_config_set_int ("units", alarm->units);
- if (alarm->data)
- gnome_config_set_string ("data", alarm->data);
-
- gnome_config_pop_prefix ();
- gnome_config_sync ();
-}
-
-static void
-prop_apply_alarms ()
-{
- int i;
- for (i=0; i < 4; i++)
- prop_store_alarm_default_values (&alarm_defaults [i]);
-
- beep_on_display = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enable_display_beep));
- gnome_config_set_bool ("/calendar/alarms/beep_on_display", beep_on_display);
- enable_aalarm_timeout = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (to_cb));
- gnome_config_set_bool ("/calendar/alarms/enable_audio_timeout", enable_aalarm_timeout);
- audio_alarm_timeout = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (to_spin));
- gnome_config_set_int ("/calendar/alarms/audio_alarm_timeout", audio_alarm_timeout);
- enable_snooze = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (snooze_cb));
- gnome_config_set_bool ("/calendar/alarms/enable_snooze", enable_snooze);
- snooze_secs = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (snooze_spin));
- gnome_config_set_int ("/calendar/alarms/snooze_secs", snooze_secs);
-
- gnome_config_sync();
-}
-
-static void
-to_cb_changed (GtkWidget *object, gpointer data)
-{
- gboolean active =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (to_cb));
- gtk_widget_set_sensitive (to_spin, active);
- prop_changed ();
-}
-
-static void
-snooze_cb_changed (GtkWidget *object, gpointer data)
-{
- gboolean active =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (snooze_cb));
- gtk_widget_set_sensitive (snooze_spin, active);
- prop_changed ();
-}
-
-
diff --git a/calendar/gui/quick-view.c b/calendar/gui/quick-view.c
deleted file mode 100644
index c23ed612c0..0000000000
--- a/calendar/gui/quick-view.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/* Quick view widget for Gnomecal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx
- */
-
-#include <config.h>
-#include "quick-view.h"
-#include "main.h"
-
-
-#define QUICK_VIEW_FONTSET "-adobe-helvetica-medium-r-normal--10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*"
-
-
-static void quick_view_class_init (QuickViewClass *class);
-static void quick_view_init (QuickView *qv);
-
-static gint quick_view_button_release (GtkWidget *widget, GdkEventButton *event);
-static gint quick_view_map_event (GtkWidget *widget, GdkEventAny *event);
-
-
-static GtkWindowClass *parent_class;
-
-
-GtkType
-quick_view_get_type (void)
-{
- static GtkType quick_view_type = 0;
-
- if (!quick_view_type) {
- GtkTypeInfo quick_view_info = {
- "QuickView",
- sizeof (QuickView),
- sizeof (QuickViewClass),
- (GtkClassInitFunc) quick_view_class_init,
- (GtkObjectInitFunc) quick_view_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- quick_view_type = gtk_type_unique (gtk_window_get_type (), &quick_view_info);
- }
-
- return quick_view_type;
-}
-
-static void
-quick_view_class_init (QuickViewClass *class)
-{
- GtkWidgetClass *widget_class;
-
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gtk_window_get_type ());
-
- widget_class->button_release_event = quick_view_button_release;
- widget_class->map_event = quick_view_map_event;
-}
-
-static void
-quick_view_init (QuickView *qv)
-{
- GTK_WINDOW (qv)->type = GTK_WINDOW_POPUP;
- gtk_window_set_position (GTK_WINDOW (qv), GTK_WIN_POS_MOUSE);
-}
-
-static gint
-quick_view_button_release (GtkWidget *widget, GdkEventButton *event)
-{
- QuickView *qv;
-
- qv = QUICK_VIEW (widget);
-
- if (event->button != qv->button)
- return FALSE;
-
- gdk_pointer_ungrab (event->time);
- gtk_grab_remove (GTK_WIDGET (qv));
- gtk_widget_hide (GTK_WIDGET (qv));
-
- gtk_main_quit (); /* End modality of the quick view */
- return TRUE;
-}
-
-static gint
-quick_view_map_event (GtkWidget *widget, GdkEventAny *event)
-{
- GdkCursor *cursor;
-
- cursor = gdk_cursor_new (GDK_ARROW);
- gdk_pointer_grab (widget->window,
- TRUE,
- GDK_BUTTON_RELEASE_MASK,
- NULL,
- cursor,
- GDK_CURRENT_TIME);
- gdk_cursor_destroy (cursor);
-
- return FALSE;
-}
-
-/* Creates the items corresponding to a single calendar object. Takes in the y position of the
- * items to create and returns the y position of the next item to create. Also takes in the current
- * maximum width for items and returns the new maximum width.
- */
-void
-create_items_for_event (QuickView *qv, CalendarObject *co, double *y, double *max_width)
-{
- GnomeCanvas *canvas;
- GnomeCanvasItem *item;
- char start[100], end[100];
- struct tm start_tm, end_tm;
- char *str;
- GtkArg args[2];
-
- /* FIXME: make this nice */
-
- canvas = GNOME_CANVAS (qv->canvas);
-
- start_tm = *localtime (&co->ev_start);
- end_tm = *localtime (&co->ev_end);
-
- if (am_pm_flag) {
- strftime (start, sizeof (start), "%I:%M%p", &start_tm);
- strftime (end, sizeof (end), "%I:%M%p", &end_tm);
- } else {
- strftime (start, sizeof (start), "%H:%M", &start_tm);
- strftime (end, sizeof (end), "%H:%M", &end_tm);
- }
-
- str = g_strconcat (start, " - ", end, " ", co->ico->summary, NULL);
-
- item = gnome_canvas_item_new (gnome_canvas_root (canvas),
- gnome_canvas_text_get_type (),
- "x", 0.0,
- "y", *y,
- "anchor", GTK_ANCHOR_NW,
- "text", str,
- "fontset", QUICK_VIEW_FONTSET,
- NULL);
-
- g_free (str);
-
- /* Measure the text and return the proper size values */
-
- args[0].name = "text_width";
- args[1].name = "text_height";
- gtk_object_getv (GTK_OBJECT (item), 2, args);
-
- if (GTK_VALUE_DOUBLE (args[0]) > *max_width)
- *max_width = GTK_VALUE_DOUBLE (args[0]);
-
- *y += GTK_VALUE_DOUBLE (args[1]);
-}
-
-/* Creates the canvas items corresponding to the events in the list */
-static void
-setup_event_list (QuickView *qv, GList *event_list)
-{
- CalendarObject *co;
- GnomeCanvasItem *item;
- GtkArg args[2];
- double y, max_width;
-
- /* If there are no events, then just put a simple label */
-
- if (!event_list) {
- item = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (qv->canvas)),
- gnome_canvas_text_get_type (),
- "x", 0.0,
- "y", 0.0,
- "anchor", GTK_ANCHOR_NW,
- "text", _("No appointments for this day"),
- "fontset", QUICK_VIEW_FONTSET,
- NULL);
-
- /* Measure the text and set the proper sizes */
-
- args[0].name = "text_width";
- args[1].name = "text_height";
- gtk_object_getv (GTK_OBJECT (item), 2, args);
-
- y = GTK_VALUE_DOUBLE (args[1]);
- max_width = GTK_VALUE_DOUBLE (args[0]);
- } else {
- /* Create the items for all the events in the list */
-
- y = 0.0;
- max_width = 0.0;
-
- for (; event_list; event_list = event_list->next) {
- co = event_list->data;
- create_items_for_event (qv, co, &y, &max_width);
- }
- }
-
- /* Set the scrolling region to fit all the items */
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (qv->canvas),
- 0.0, 0.0,
- max_width, y);
-
- gtk_widget_set_usize (qv->canvas, max_width, y);
-}
-
-GtkWidget *
-quick_view_new (GnomeCalendar *calendar, char *title, GList *event_list)
-{
- QuickView *qv;
- GtkWidget *vbox;
- GtkWidget *w;
-
- g_return_val_if_fail (calendar != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CALENDAR (calendar), NULL);
-
- qv = gtk_type_new (quick_view_get_type ());
- qv->calendar = calendar;
-
- /* Create base widgets for the popup window */
-
- w = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (w), GTK_SHADOW_ETCHED_OUT);
- gtk_container_add (GTK_CONTAINER (qv), w);
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (w), vbox);
-
- w = gtk_label_new (title);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
-
- w = gtk_hseparator_new ();
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
-
- w = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
- gtk_container_set_border_width (GTK_CONTAINER (w), GNOME_PAD_SMALL);
- gtk_box_pack_start (GTK_BOX (vbox), w, TRUE, TRUE, 0);
-
- gtk_widget_push_visual (gdk_imlib_get_visual ());
- gtk_widget_push_colormap (gdk_imlib_get_colormap ());
-
- qv->canvas = gnome_canvas_new ();
-
- gtk_widget_pop_colormap ();
- gtk_widget_pop_visual ();
-
- gtk_container_add (GTK_CONTAINER (w), qv->canvas);
-
- /* Set up the event list */
-
- setup_event_list (qv, event_list);
-
- return GTK_WIDGET (qv);
-}
-
-void
-quick_view_do_popup (QuickView *qv, GdkEventButton *event)
-{
- g_return_if_fail (qv != NULL);
- g_return_if_fail (IS_QUICK_VIEW (qv));
- g_return_if_fail (event != NULL);
-
- /* Pop up the window */
-
- gtk_widget_show_all (GTK_WIDGET (qv));
- gtk_grab_add (GTK_WIDGET (qv));
-
- qv->button = event->button;
-
- gtk_main (); /* Begin modality */
-
- /* The button release event handler will call gtk_main_quit() */
-}
diff --git a/calendar/gui/quick-view.h b/calendar/gui/quick-view.h
deleted file mode 100644
index c6b2cf8814..0000000000
--- a/calendar/gui/quick-view.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Quick view widget for Gnomecal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx
- */
-
-#ifndef QUICK_VIEW_H
-#define QUICK_VIEW_H
-
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define TYPE_QUICK_VIEW (quick_view_get_type ())
-#define QUICK_VIEW(obj) (GTK_CHECK_CAST ((obj), TYPE_QUICK_VIEW, QuickView))
-#define QUICK_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_QUICK_VIEW, QuickViewClass))
-#define IS_QUICK_VIEW(obj) (GTK_CHECK_TYPE ((obj), TYPE_QUICK_VIEW))
-#define IS_QUICK_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_QUICK_VIEW))
-
-
-typedef struct _QuickView QuickView;
-typedef struct _QuickViewClass QuickViewClass;
-
-struct _QuickView {
- GtkWindow window;
-
- GnomeCalendar *calendar; /* The calendar we are associated to */
-
- GtkWidget *canvas; /* The canvas that displays the contents of the quick view */
-
- int button; /* The button that was pressed to pop up the quick view */
-};
-
-struct _QuickViewClass {
- GtkWindowClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType quick_view_get_type (void);
-
-/* Creates a new quick view with the specified title and the specified event list. It is associated
- * to the specified calendar. The event list must be a list of CalendarObject structures.
- */
-GtkWidget *quick_view_new (GnomeCalendar *calendar, char *title, GList *event_list);
-
-/* Pops up the quick view widget modally and loops until the uses closes it by releasing the mouse
- * button. You can destroy the quick view when this function returns.
- */
-void quick_view_do_popup (QuickView *qv, GdkEventButton *event);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/recur.xpm b/calendar/gui/recur.xpm
deleted file mode 100644
index 49836b62e7..0000000000
--- a/calendar/gui/recur.xpm
+++ /dev/null
@@ -1,83 +0,0 @@
-/* XPM */
-static char * recur_xpm[] = {
-"16 16 64 1",
-" c None",
-". c #350000",
-"+ c #2A0000",
-"@ c #1B0000",
-"# c #280000",
-"$ c #430000",
-"% c #090000",
-"& c #160000",
-"* c #250000",
-"= c #460000",
-"- c #550000",
-"; c #610000",
-"> c #0D0000",
-", c #1F0000",
-"' c #4B0000",
-") c #5E0000",
-"! c #6B0000",
-"~ c #750000",
-"{ c #790000",
-"] c #810000",
-"^ c #FFFF83",
-"/ c #FFFF89",
-"( c #FFFF93",
-"_ c #8B0000",
-": c #900000",
-"< c #930000",
-"[ c #FFFF62",
-"} c #A10000",
-"| c #FFFF41",
-"1 c #FFFF3B",
-"2 c #FFFF31",
-"3 c #B70000",
-"4 c #B20000",
-"5 c #AE0000",
-"6 c #FFFF22",
-"7 c #FFFF16",
-"8 c #FFFF06",
-"9 c #C90000",
-"0 c #C10000",
-"a c #BB0000",
-"b c #FFF600",
-"c c #FFE100",
-"d c #FFC500",
-"e c #E40000",
-"f c #D70000",
-"g c #CD0000",
-"h c #FFDB00",
-"i c #FFA900",
-"j c #FF8500",
-"k c #FF5900",
-"l c #FF2800",
-"m c #FC0000",
-"n c #ED0000",
-"o c #E10000",
-"p c #FFAF00",
-"q c #FF9400",
-"r c #FF7400",
-"s c #FF5000",
-"t c #FF0100",
-"u c #F30000",
-"v c #E80000",
-"w c #FF6900",
-"x c #FF4900",
-"y c #FF0800",
-" ",
-" . ",
-" +. ",
-" @#.$ ",
-" %&*.=-; ",
-" >,.')!~ ",
-" &. !{] ",
-" ^/( . _:< ",
-" [[[ }}} ",
-" |12 345 ",
-" 678 90a ",
-" bcd efg ",
-" hdijklmnof ",
-" pqrsltuv ",
-" wxly ",
-" "};
diff --git a/calendar/gui/test.vcf b/calendar/gui/test.vcf
deleted file mode 100644
index bfe93b3c14..0000000000
--- a/calendar/gui/test.vcf
+++ /dev/null
@@ -1,133 +0,0 @@
-BEGIN:VCALENDAR
-PRODID:-//GNOME//NONSGML GnomeCalendar//EN
-TZ:MST
-VERSION:0.13
-BEGIN:VEVENT
-UID:KOrganizer - 846930886
-SEQUENCE:1
-DTSTART:19980601T150000
-DTEND:19980601T150000
-DCREATED:19980402T023558
-LAST-MODIFIED:19980402T023558
-SUMMARY:Cada dos dias de 06/01 al 07/01
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:D2 19980701T140000
-END:VEVENT
-
-BEGIN:VEVENT
-UID:KOrganizer - 846930886
-SEQUENCE:1
-DTSTART:19980501T140000
-DTEND:19980501T140000
-DCREATED:19980402T023558
-LAST-MODIFIED:19980402T023558
-SUMMARY:5 dias.
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:D1 #5
-END:VEVENT
-
-BEGIN:VEVENT
-UID:KOrganizer - 846930886
-SEQUENCE:1
-DTSTART:19980501T140000
-DTEND:19980501T150000
-DCREATED:19980402T023558
-LAST-MODIFIED:19980429T004635
-SUMMARY:Diariamente de 05/01 al 06/01
-STATUS:NEEDS ACTION
-CLASS:PRIVATE
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:D1 19980601T000000
-END:VEVENT
-
-BEGIN:VEVENT
-UID:KOrganizer - 1804289383
-SEQUENCE:1
-DTSTART:19980415T010000
-DTEND:19980415T013000
-DCREATED:19980402T023552
-LAST-MODIFIED:19980330T225948
-SUMMARY:Diario durante 5 dias
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:D1 #5
-END:VEVENT
-
-BEGIN:VEVENT
-UID:KOrganizer - 1804289383
-SEQUENCE:1
-DTSTART:19980415T010000
-DTEND:19980415T013000
-DCREATED:19980402T023552
-LAST-MODIFIED:19980330T225948
-SUMMARY:Diario durante 5 dias
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:D1 #5
-END:VEVENT
-
-BEGIN:VTODO
-UID:KOrganizer - 846930886
-SEQUENCE:1
-DTSTART:19980415T140000
-DUE:19691231T180000
-DCREATED:19980402T023558
-LAST-MODIFIED:19980402T023558
-SUMMARY:Normal
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-END:VTODO
-
-BEGIN:VTODO
-UID:KOrganizer - 1804289383
-SEQUENCE:1
-DTSTART:19980415T120000
-DUE:19691231T180000
-DCREATED:19980402T023552
-LAST-MODIFIED:19980330T225948
-SUMMARY:Semanal -- 4 semanas
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:W1 WE #4
-END:VTODO
-
-BEGIN:VTODO
-UID:KOrganizer - 1804289383
-SEQUENCE:1
-DTSTART:19980415T003000
-DUE:19691231T180000
-DCREATED:19980402T023552
-LAST-MODIFIED:19980330T225948
-SUMMARY:Semana: Mi, Ju, Vi, Dom (10 veces)
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:W1 SU WE TH FR #10
-END:VTODO
-
-END:VCALENDAR
-
diff --git a/calendar/gui/todo-conduit-control-applet.c b/calendar/gui/todo-conduit-control-applet.c
deleted file mode 100644
index 54a26715ef..0000000000
--- a/calendar/gui/todo-conduit-control-applet.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/* Control applet ("capplet") for the gnome-pilot todo conduit, */
-/* based on */
-/* gpilotd control applet ('capplet') for use with the GNOME control center */
-/* $Id$ */
-
-#include <pwd.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <gnome.h>
-
-#include <config.h>
-#include <capplet-widget.h>
-
-#include <gpilotd/gpilotd-conduit-mgmt.h>
-#include <gpilotd/gpilotd-app.h>
-#include <gpilotd/gpilotd-app-dummy-callbacks.h>
-
-#include "todo-conduit.h"
-
-/* tell changes callbacks to ignore changes or not */
-static gboolean ignore_changes=FALSE;
-
-/* capplet widget */
-static GtkWidget *capplet=NULL;
-
-/* host/device/pilot configuration windows */
-GtkWidget *cfgOptionsWindow=NULL;
-GtkWidget *cfgStateWindow=NULL;
-GtkWidget *dialogWindow=NULL;
-
-gboolean activated,org_activation_state;
-GnomePilotConduitMgmt *conduit;
-
-static void doTrySettings(GtkWidget *widget, ConduitCfg *conduitCfg);
-static void doRevertSettings(GtkWidget *widget, ConduitCfg *conduitCfg);
-static void doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg);
-
-static void readStateCfg(GtkWidget *w);
-static void setStateCfg(GtkWidget *w);
-
-gint pilotId;
-CORBA_Environment ev;
-
-static void
-doTrySettings(GtkWidget *widget, ConduitCfg *conduitCfg)
-{
- readStateCfg(cfgStateWindow);
- if(activated)
- gpilotd_conduit_mgmt_enable(conduit,pilotId,GnomePilotConduitSyncTypeSynchronize);
- else
- gpilotd_conduit_mgmt_disable(conduit,pilotId);
-}
-
-static void
-doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg)
-{
- doTrySettings(widget, conduitCfg);
- save_configuration(NULL);
-}
-
-
-static void
-doRevertSettings(GtkWidget *widget, ConduitCfg *conduitCfg)
-{
- activated = org_activation_state;
- setStateCfg(cfgStateWindow);
-}
-
-static void
-insert_dir_callback (GtkEditable *editable, const gchar *text,
- gint len, gint *position, void *data)
-{
- gint i;
- gchar *curname;
-
- curname = gtk_entry_get_text(GTK_ENTRY(editable));
- if (*curname == '\0' && len > 0) {
- if (isspace(text[0])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text");
- return;
- }
- } else {
- for (i=0; i<len; i++) {
- if (isspace(text[i])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable),
- "insert_text");
- return;
- }
- }
- }
-}
-static void
-insert_dir_callback2(GtkEditable *editable, const gchar *text,
- gint length, gint *position,
- void *data)
-{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-static void
-clist_changed(GtkWidget *widget, gpointer data)
-{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-void about_cb (GtkWidget *widget, gpointer data) {
- GtkWidget *about;
- const gchar *authors[] = {_("Eskil Heyn Olsen <deity@eskil.dk>"),NULL};
-
- about = gnome_about_new(_("Gpilotd todo conduit"), VERSION,
- _("(C) 1998 the Free Software Foundation"),
- authors,
- _("Configuration utility for the todo conduit.\n"),
- _("gnome-unknown.xpm"));
- gtk_widget_show (about);
-
- return;
-}
-
-static void toggled_cb(GtkWidget *widget, gpointer data) {
- gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(widget)->active);
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-static GtkWidget
-*createStateCfgWindow(void)
-{
- GtkWidget *vbox, *table;
- GtkWidget *entry, *label;
- GtkWidget *button;
-
- vbox = gtk_vbox_new(FALSE, GNOME_PAD);
-
- table = gtk_table_new(2, 2, FALSE);
- gtk_table_set_row_spacings(GTK_TABLE(table), 4);
- gtk_table_set_col_spacings(GTK_TABLE(table), 10);
- gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD);
-
- label = gtk_label_new(_("Enabled"));
- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1,2);
-
- button = gtk_check_button_new();
- gtk_object_set_data(GTK_OBJECT(vbox), "conduit_on_off", button);
- gtk_signal_connect(GTK_OBJECT(button), "toggled",
- GTK_SIGNAL_FUNC(toggled_cb),
- NULL);
- gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 1,2);
-
- return vbox;
-}
-
-static void
-setStateCfg(GtkWidget *cfg)
-{
- GtkWidget *button;
- gchar num[40];
-
- button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off");
-
- g_assert(button!=NULL);
-
- ignore_changes = TRUE;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),activated);
- gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(button)->active);
- ignore_changes = FALSE;
-}
-
-
-static void
-readStateCfg(GtkWidget *cfg)
-{
- GtkWidget *button;
-
- button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off");
-
- g_assert(button!=NULL);
-
- activated = GTK_TOGGLE_BUTTON(button)->active;
-}
-
-static void
-pilot_capplet_setup(void)
-{
- GtkWidget *frame, *table;
-
- capplet = capplet_widget_new();
-
- table = gtk_table_new(1, 2, FALSE);
- gtk_container_border_width(GTK_CONTAINER(table), GNOME_PAD);
- gtk_container_add(GTK_CONTAINER(capplet), table);
-
- frame = gtk_frame_new(_("Conduit state"));
- gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL);
- gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1);
- cfgStateWindow = createStateCfgWindow();
- gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow);
-
- gtk_signal_connect(GTK_OBJECT(capplet), "try",
- GTK_SIGNAL_FUNC(doTrySettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "revert",
- GTK_SIGNAL_FUNC(doRevertSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "ok",
- GTK_SIGNAL_FUNC(doSaveSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "help",
- GTK_SIGNAL_FUNC(about_cb), NULL);
-
-
- setStateCfg(cfgStateWindow);
-
- gtk_widget_show_all(capplet);
-}
-
-void run_error_dialog(gchar *mesg,...) {
- char tmp[80];
- va_list ap;
-
- va_start(ap,mesg);
- vsnprintf(tmp,79,mesg,ap);
- dialogWindow = gnome_message_box_new(mesg,GNOME_MESSAGE_BOX_ERROR,GNOME_STOCK_BUTTON_OK,NULL);
- gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow));
- va_end(ap);
-}
-
-gint get_pilot_id_from_gpilotd() {
- gint *pilots;
- int i;
-
- i=0;
- gpilotd_get_pilot_ids(&pilots);
- if(pilots) {
- while(pilots[i]!=-1) { g_message("pilot %d = \"%d\"",i,pilots[i]); i++; }
- if(i==0) {
- run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
- return -1;
- } else {
- if(i==1)
- return pilots[0];
- else {
- g_message("too many pilots...");
- return pilots[0];
- }
- }
- } else {
- run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
- return -1;
- }
-}
-
-int
-main( int argc, char *argv[] )
-{
- /* we're a capplet */
- gnome_capplet_init ("todo conduit control applet", NULL, argc, argv,
- NULL,
- 0, NULL);
-
- /* put all code to set things up in here */
- conduit = gpilotd_conduit_mgmt_new("todo_conduit");
-
- /* get pilot name from gpilotd */
- /* 1. initialize the gpilotd connection */
- if (gpilotd_init(&argc,argv)!=0) {
- run_error_dialog(_("Cannot initialze the GnomePilot Daemon"));
- g_error(_("Cannot initialze the GnomePilot Daemon"));
- return -1;
- }
-
- /* 2 connect to gpilotd */
- if (gpilotd_connect()!=0) {
- run_error_dialog(_("Cannot connect to the GnomePilot Daemon"));
- g_error(_("Cannot connect to the GnomePilot Daemon"));
- return -1;
- }
-
- pilotId = get_pilot_id_from_gpilotd();
- if(!pilotId) return -1;
- org_activation_state = activated = gpilotd_conduit_mgmt_is_enabled(conduit,pilotId);
-
- pilot_capplet_setup();
-
-
- /* done setting up, now run main loop */
- capplet_gtk_main();
- return 0;
-}
diff --git a/calendar/gui/todo-conduit-control-applet.desktop b/calendar/gui/todo-conduit-control-applet.desktop
deleted file mode 100644
index 87788bde08..0000000000
--- a/calendar/gui/todo-conduit-control-applet.desktop
+++ /dev/null
@@ -1,6 +0,0 @@
-[Desktop Entry]
-Name=Todo conduit
-Comment=Configure the todo conduit
-Exec=todo-conduit-control-applet --cap-id=1
-Terminal=0
-Type=Application
diff --git a/calendar/gui/todo-conduit.c b/calendar/gui/todo-conduit.c
deleted file mode 100644
index 3a543816af..0000000000
--- a/calendar/gui/todo-conduit.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/* $Id$ */
-
-#include <glib.h>
-#include <gnome.h>
-
-#include <pi-source.h>
-#include <pi-socket.h>
-#include <pi-file.h>
-#include <pi-dlp.h>
-#include <pi-version.h>
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <utime.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <signal.h>
-#include <errno.h>
-#include <gpilotd/gnome-pilot-conduit.h>
-#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
-
-#include "todo-conduit.h"
-
-static gint
-load_records(GnomePilotConduit *c)
-{
- return 0;
-}
-
-static gint
-pre_sync(GnomePilotConduit *c, GnomePilotDBInfo *dbi) {
- int l;
- unsigned char *buf;
-
- gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi);
-
- load_records(c);
-
- buf = (unsigned char*)g_malloc(0xffff);
- if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff))<0) {
- return -1;
- }
- unpack_ToDoAppInfo(&(GET_DATA(c)->ai),buf,l);
- g_free(buf);
-
- return 0;
-}
-
-static gint
-post_sync(GnomePilotConduit *c) {
- return 0;
-}
-
-static gint
-match_record (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord **local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("in match_record\n");
- return 0;
-}
-static gint
-free_match (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord **local,
- gpointer data)
-{
- g_print ("entering free_match\n");
- *local = NULL;
-
- return 0;
-}
-static gint
-archive_local (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gpointer data)
-{
- g_print ("entering archive_local\n");
- return 1;
-
-}
-static gint
-archive_remote (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering archive_remote\n");
- return 1;
-}
-static gint
-store_remote (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering store_remote\n");
- g_print ("Rec:%s:\nLength:%d\n", remote->record, remote->length);
- return 1;
-}
-static gint
-clear_status_archive_local (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gpointer data)
-{
- g_print ("entering clear_status_archive_local\n");
- return 1;
-}
-static gint
-iterate (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord **local,
- gpointer data)
-{
- g_print ("entering iterate\n");
- return 1;
-}
-static gint
-iterate_specific (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord **local,
- gint flag,
- gint archived,
- gpointer data)
-{
- g_print ("entering iterate_specific\n");
- return 1;
-}
-static gint
-purge (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- gpointer data)
-{
- g_print ("entering purge\n");
- return 1;
-}
-static gint
-set_status (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gint status,
- gpointer data)
-{
- g_print ("entering set_status\n");
- return 1;
-}
-static gint
-set_archived (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gint archived,
- gpointer data)
-{
- g_print ("entering set_archived\n");
- return 1;
-}
-static gint
-set_pilot_id (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- guint32 ID,
- gpointer data)
-{
- g_print ("entering set_pilot_id\n");
- return 1;
-}
-static gint
-compare (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering compare\n");
- return 1;
-}
-static gint
-compare_backup (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering compare_backup\n");
- return 1;
-}
-static gint
-free_transmit (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering free_transmit\n");
- return 1;
-}
-static gint
-delete_all (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- gpointer data)
-{
- g_print ("entering delete_all\n");
- return 1;
-}
-static PilotRecord *
-transmit (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gpointer data)
-{
- g_print ("entering transmit\n");
- return NULL;
-}
-
-static GnomePilotConduit *
-conduit_get_gpilot_conduit (guint32 pilotId)
-{
- GtkObject *retval;
- ConduitCfg *cfg;
- ConduitData *cdata;
-
- g_print ("creating our new conduit\n");
- retval = gnome_pilot_conduit_standard_abs_new ("TodoDB", 0x0);
- g_assert (retval != NULL);
- gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"todo");
-
- cfg = g_new0(ConduitCfg,1);
- g_assert(cfg != NULL);
- gtk_object_set_data(retval,"conduit_cfg",cfg);
-
- cdata = g_new0(ConduitData,1);
- g_assert(cdata != NULL);
- gtk_object_set_data(retval,"conduit_data",cdata);
-
- gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, NULL);
- gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, NULL);
- gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, NULL);
- gtk_signal_connect (retval, "archive_remote", (GtkSignalFunc) archive_remote, NULL);
- gtk_signal_connect (retval, "store_remote", (GtkSignalFunc) store_remote, NULL);
- gtk_signal_connect (retval, "clear_status_archive_local", (GtkSignalFunc) clear_status_archive_local, NULL);
- gtk_signal_connect (retval, "iterate", (GtkSignalFunc) iterate, NULL);
- gtk_signal_connect (retval, "iterate_specific", (GtkSignalFunc) iterate_specific, NULL);
- gtk_signal_connect (retval, "purge", (GtkSignalFunc) purge, NULL);
- gtk_signal_connect (retval, "set_status", (GtkSignalFunc) set_status, NULL);
- gtk_signal_connect (retval, "set_archived", (GtkSignalFunc) set_archived, NULL);
- gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, NULL);
- gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, NULL);
- gtk_signal_connect (retval, "compare_backup", (GtkSignalFunc) compare_backup, NULL);
- gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, NULL);
- gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, NULL);
- gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, NULL);
- gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, NULL);
- gtk_signal_connect (retval, "post_sync", (GtkSignalFunc) post_sync, NULL);
-
- load_configuration(&cfg,pilotId);
-
- return GNOME_PILOT_CONDUIT (retval);
-}
-static void
-conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
-{
- ConduitCfg *cc;
- cc = GET_CONFIG(conduit);
- destroy_configuration(&cc);
- gtk_object_destroy (GTK_OBJECT (conduit));
-}
-
-
diff --git a/calendar/gui/todo-conduit.h b/calendar/gui/todo-conduit.h
deleted file mode 100644
index c224b2b1f3..0000000000
--- a/calendar/gui/todo-conduit.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* $Id$ */
-
-#ifndef __TODO_CONDUIT_H__
-#define __TODO_CONDUIT_H__
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <pi-todo.h>
-#include <gnome.h>
-
-typedef struct _ConduitCfg ConduitCfg;
-
-struct _ConduitCfg {
- gboolean open_secret;
- guint32 pilotId;
-};
-
-#define GET_CONFIG(c) ((ConduitCfg*)gtk_object_get_data(GTK_OBJECT(c),"conduit_cfg"))
-
-typedef struct _ConduitData ConduitData;
-
-struct _ConduitData {
- struct ToDoAppInfo ai;
-};
-
-#define GET_DATA(c) ((ConduitData*)gtk_object_get_data(GTK_OBJECT(c),"conduit_data"))
-
-static void load_configuration(ConduitCfg **c,guint32 pilotId) {
- gchar prefix[256];
- g_snprintf(prefix,255,"/gnome-pilot.d/todod-conduit/Pilot_%u/",pilotId);
-
- *c = g_new0(ConduitCfg,1);
- gnome_config_push_prefix(prefix);
- (*c)->open_secret = gnome_config_get_bool("open secret=FALSE");
- gnome_config_pop_prefix();
-
- (*c)->pilotId = pilotId;
-}
-
-static void save_configuration(ConduitCfg *c) {
- gchar prefix[256];
-
- g_snprintf(prefix,255,"/gnome-pilot.d/todo-conduit/Pilot_%u/",c->pilotId);
-
- gnome_config_push_prefix(prefix);
- gnome_config_set_bool("open secret",c->open_secret);
- gnome_config_pop_prefix();
-
- gnome_config_sync();
- gnome_config_drop_all();
-}
-
-static void destroy_configuration(ConduitCfg **c) {
- g_free(*c);
- *c = NULL;
-}
-
-#endif __TODO_CONDUIT_H__
diff --git a/calendar/gui/topic.dat b/calendar/gui/topic.dat
deleted file mode 100644
index edc7813b26..0000000000
--- a/calendar/gui/topic.dat
+++ /dev/null
@@ -1,2 +0,0 @@
-gnome-cal.html Manual
-gnome-cal.html#cmdline Command line options \ No newline at end of file
diff --git a/calendar/gui/view-utils.c b/calendar/gui/view-utils.c
deleted file mode 100644
index 8cb7893377..0000000000
--- a/calendar/gui/view-utils.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/* Miscellaneous utility functions for the calendar view widgets
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <string.h>
-#include "view-utils.h"
-#include <libgnomeui/gnome-icon-text.h>
-
-int am_pm_flag = 0;
-
-static char *
-nicetime (struct tm *tm)
-{
- static char buf [20];
- char *p = buf;
-
- if (am_pm_flag){
- if (tm->tm_min)
- strftime (buf, sizeof (buf), "%l:%M%p", tm);
- else
- strftime (buf, sizeof (buf), "%l%p", tm);
- } else {
- if (tm->tm_min)
- strftime (buf, sizeof (buf), "%H:%M", tm);
- else
- strftime (buf, sizeof (buf), "%H", tm);
- }
- while (*p == ' ')
- p++;
- return p;
-}
-
-typedef struct {
- GnomeIconTextInfo *layout;
- int lines;
- int assigned_lines;
-} line_info_t;
-
-void
-view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area,
- int flags, GList *events, time_t start, time_t end)
-{
- GdkFont *font = widget->style->font;
- int font_height;
- int y, max_y, items, i, need_more, nlines, base, extra;
- GList *list;
- line_info_t *lines;
-
- if (events == NULL)
- return;
-
- items = g_list_length (events);
- lines = g_new0 (line_info_t, items);
-
- font_height = font->ascent + font->descent;
- max_y = area->y + area->height - font_height * ((flags & VIEW_UTILS_DRAW_SPLIT) ? 2 : 1);
-
- /*
- * Layout all the lines, measure the space needs
- */
- for (i = 0, list = events; list; list = list->next, i++){
- CalendarObject *co = list->data;
- struct tm tm_start, tm_end;
- iCalObject *ico = co->ico;
- char buf [60];
- char *full_text;
-
- tm_start = *localtime (&co->ev_start);
- tm_end = *localtime (&co->ev_end);
-
- strcpy (buf, nicetime (&tm_start));
-
- if (flags & VIEW_UTILS_DRAW_END){
- strcat (buf, "-");
- strcat (buf, nicetime (&tm_end));
- }
-
- full_text = g_strconcat (buf, ": ", ico->summary, NULL);
- lines [i].layout = gnome_icon_layout_text (
- font, full_text, "\n -,.;:=#", area->width, TRUE);
- lines [i].lines = g_list_length (lines [i].layout->rows);
-
- g_free (full_text);
- }
-
- /*
- * Compute how many lines we will give to each row
- */
- nlines = 1 + max_y / font_height;
- base = nlines / items;
- extra = nlines % items;
- need_more = 0;
-
- for (i = 0; i < items; i++){
- if (lines [i].lines <= base){
- extra += base - lines [i].lines;
- lines [i].assigned_lines = lines [i].lines;
- } else {
- need_more++;
- lines [i].assigned_lines = base;
- }
- }
-
- /*
- * use any extra space
- */
- while (need_more && extra > 0){
- need_more = 0;
-
- for (i = 0; i < items; i++){
- if (lines [i].lines > lines [i].assigned_lines){
- lines [i].assigned_lines++;
- extra--;
- }
-
- if (extra == 0)
- break;
-
- if (lines [i].lines > lines [i].assigned_lines)
- need_more = 1;
- }
- }
-
- /*
- * Draw the information
- */
- gdk_gc_set_clip_rectangle (gc, area);
- y = area->y;
- for (i = 0; i < items; i++){
- int line;
-
- list = lines [i].layout->rows;
-
- for (line = 0; line < lines [i].assigned_lines; line++){
- GnomeIconTextInfoRow *row = list->data;
-
- list = list->next;
-
- if (row)
- gdk_draw_string (
- window, font, gc,
- area->x, y + font->ascent,
- row->text);
- y += font_height;
- }
- }
-
- gdk_gc_set_clip_rectangle (gc, NULL);
-
- /*
- * Free resources.
- */
-
- for (i = 0; i < items; i++)
- gnome_icon_text_info_free (lines [i].layout);
- g_free (lines);
-}
-
-void
-view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow)
-{
- int x, y;
- int xthick, ythick;
- GdkGC *light_gc, *dark_gc;
-
- gdk_draw_rectangle (window,
- widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- rect->x, rect->y,
- rect->width, rect->height);
-
- light_gc = widget->style->light_gc[GTK_STATE_NORMAL];
- dark_gc = widget->style->dark_gc[GTK_STATE_NORMAL];
-
- xthick = widget->style->klass->xthickness;
- ythick = widget->style->klass->ythickness;
-
- gdk_gc_set_clip_rectangle (light_gc, rect);
- gdk_gc_set_clip_rectangle (dark_gc, rect);
-
- for (y = rect->y + ythick; y < (rect->y + rect->height - ythick); y += 3)
- for (x = rect->x + xthick; x < (rect->x + rect->width - xthick); x += 6) {
- gdk_draw_point (window, light_gc, x, y);
- gdk_draw_point (window, dark_gc, x + 1, y + 1);
-
- gdk_draw_point (window, light_gc, x + 3, y + 1);
- gdk_draw_point (window, dark_gc, x + 4, y + 2);
- }
-
- gdk_gc_set_clip_rectangle (light_gc, NULL);
- gdk_gc_set_clip_rectangle (dark_gc, NULL);
-
- gtk_draw_shadow (widget->style, window,
- GTK_STATE_NORMAL, shadow,
- rect->x, rect->y,
- rect->width, rect->height);
-}
diff --git a/calendar/gui/view-utils.h b/calendar/gui/view-utils.h
deleted file mode 100644
index a1876b6032..0000000000
--- a/calendar/gui/view-utils.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Miscellaneous utility functions for the calendar view widgets
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef VIEW_UTILS_H
-#define VIEW_UTILS_H
-
-
-#include <gtk/gtk.h>
-#include "calendar.h"
-
-
-enum {
- VIEW_UTILS_DRAW_END = 1 << 0,
- VIEW_UTILS_DRAW_SPLIT = 1 << 1
-};
-
-
-void view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area,
- int flags, GList *events, time_t start, time_t end);
-
-void view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow);
-
-
-#endif
diff --git a/calendar/gui/week-view.c b/calendar/gui/week-view.c
deleted file mode 100644
index 89e489a92d..0000000000
--- a/calendar/gui/week-view.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/* Week view display for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include "year-view.h"
-
-
-static void week_view_class_init (WeekViewClass *class);
-static void week_view_init (WeekView *wv);
-
-
-GtkType
-week_view_get_type (void)
-{
- static GtkType week_view_type = 0;
-
- if (!week_view_type) {
- GtkTypeInfo week_view_info = {
- "WeekView",
- sizeof (WeekView),
- sizeof (WeekViewClass),
- (GtkClassInitFunc) week_view_class_init,
- (GtkObjectInitFunc) week_view_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- week_view_type = gtk_type_unique (gnome_canvas_get_type (), &week_view_info);
- }
-
- return week_view_type;
-}
-
-static void
-week_view_class_init (WeekViewClass *class)
-{
- /* FIXME */
-}
-
-static void
-week_view_init (WeekView *wv)
-{
- GnomeCanvasGroup *root;
-
- root = gnome_canvas_root (GNOME_CANVAS (wv));
-
- /* Title */
-
- wv->title = gnome_canvas_item_new (root,
- gnome_canvas_text_get_type (),
- "anchor", GTK_ANCHOR_N,
- "font", HEADING_FONT,
- "fill_color", "black",
- NULL);
-}
-
-GtkWidget *
-week_view_new (GnomeCalendar *calendar, time_t week)
-{
- WeekView *wv;
-
- g_return_val_if_fail (calendar != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CALENDAR (calendar), NULL);
-
- wv = gtk_type_new (week_view_get_type ());
- wv->calendar = calendar;
-
- week_view_colors_changed (wv);
- week_view_set (wv, week);
- return GTK_WIDGET (wv);
-}
-
-void
-week_view_update (WeekView *wv, iCalObject *ico, int flags)
-{
- /* FIXME */
-}
-
-void
-week_view_set (WeekView *wv, time_t week)
-{
- /* FIXME */
-}
-
-void
-week_view_time_format_changed (WeekView *wv)
-{
- /* FIXME */
-}
-
-void
-week_view_colors_changed (WeekView *wv)
-{
- /* FIXME */
-}
diff --git a/calendar/gui/week-view.h b/calendar/gui/week-view.h
deleted file mode 100644
index 1bf6a4ed02..0000000000
--- a/calendar/gui/week-view.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Week view display for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef WEEK_VIEW_H
-#define WEEK_VIEW_H
-
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define TYPE_WEEK_VIEW (week_view_get_type ())
-#define WEEK_VIEW(obj) (GTK_CHECK_CAST ((obj), TYPE_WEEK_VIEW, WeekView))
-#define WEEK_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_WEEK_VIEW, WeekViewClass))
-#define IS_WEEK_VIEW(obj) (GTK_CHECK_TYPE ((obj), TYPE_WEEK_VIEW))
-#define IS_WEEK_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_WEEK_VIEW))
-
-
-typedef struct _WeekView WeekView;
-typedef struct _WeekViewClass WeekViewClass;
-
-struct _WeekView {
- GnomeCanvas canvas;
-
- GnomeCalendar *calendar; /* The calendar we are associated to */
-
- time_t week; /* Start of the week we are viewing */
-
- GnomeCanvasItem *title; /* The title of the week view */
-};
-
-struct _WeekViewClass {
- GnomeCanvasClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType week_view_get_type (void);
-
-/* Creates a new week view associated to the specified calendar */
-GtkWidget *week_view_new (GnomeCalendar *calendar, time_t week);
-
-/* Notifies the week view that a calendar object has changed */
-void week_view_update (WeekView *wv, iCalObject *ico, int flags);
-
-/* Notifies the week view about a change of date */
-void week_view_set (WeekView *wv, time_t week);
-
-/* Notifies the week view that the time format has changed */
-void week_view_time_format_changed (WeekView *wv);
-
-/* Notifies the week view that the colors have changed */
-void week_view_colors_changed (WeekView *wv);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c
deleted file mode 100644
index 5744b4a88f..0000000000
--- a/calendar/gui/year-view.c
+++ /dev/null
@@ -1,741 +0,0 @@
-/* Year view display for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Arturo Espinosa <arturo@nuclecu.unam.mx>
- * Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include <gtk/gtkmain.h>
-#include <gnome.h>
-#include "eventedit.h"
-#include "year-view.h"
-#include "main.h"
-#include "mark.h"
-#include "quick-view.h"
-#include "timeutil.h"
-
-
-#define HEAD_SPACING 4 /* Spacing between year heading and months */
-#define TITLE_SPACING 1 /* Spacing between title and calendar */
-#define SPACING 4 /* Spacing between months */
-
-
-static void year_view_class_init (YearViewClass *class);
-static void year_view_init (YearView *yv);
-static void year_view_destroy (GtkObject *object);
-static void year_view_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void year_view_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-
-
-static GnomeCanvas *parent_class;
-
-
-GtkType
-year_view_get_type (void)
-{
- static GtkType year_view_type = 0;
-
- if (!year_view_type) {
- GtkTypeInfo year_view_info = {
- "YearView",
- sizeof (YearView),
- sizeof (YearViewClass),
- (GtkClassInitFunc) year_view_class_init,
- (GtkObjectInitFunc) year_view_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- year_view_type = gtk_type_unique (gnome_canvas_get_type (), &year_view_info);
- }
-
- return year_view_type;
-}
-
-static void
-year_view_class_init (YearViewClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gnome_canvas_get_type ());
-
- object_class->destroy = year_view_destroy;
-
- widget_class->size_request = year_view_size_request;
- widget_class->size_allocate = year_view_size_allocate;
-}
-
-/* Resizes the year view's child items. This is done in the idle loop for
- * performance (we avoid resizing on every size allocation).
- */
-static gint
-idle_handler (gpointer data)
-{
- YearView *yv;
- GtkArg arg;
- double head_height;
- double title_height;
- double width, height;
- double month_width;
- double month_height;
- double month_yofs;
- double xofs, yofs;
- double x, y;
- int i;
-
- yv = data;
-
- /* Compute the size we can use */
-
- width = MAX (GTK_WIDGET (yv)->allocation.width, yv->min_width);
- height = MAX (GTK_WIDGET (yv)->allocation.height, yv->min_height);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (yv), 0, 0, width, height);
-
- width--;
- height--;
-
- /* Get the heights of the heading and the titles */
-
- arg.name = "text_height";
- gtk_object_getv (GTK_OBJECT (yv->heading), 1, &arg);
- head_height = GTK_VALUE_DOUBLE (arg) + 2 * HEAD_SPACING;
-
- arg.name = "text_height";
- gtk_object_getv (GTK_OBJECT (yv->titles[0]), 1, &arg);
- title_height = GTK_VALUE_DOUBLE (arg);
-
- /* Offsets */
-
- xofs = (width + SPACING) / 3.0;
- yofs = (height - head_height + SPACING) / 4.0;
-
- /* Month item vertical offset */
-
- month_yofs = title_height + TITLE_SPACING;
-
- /* Month item dimensions */
-
- month_width = (width - 2 * SPACING) / 3.0;
- month_height = (yofs - SPACING) - month_yofs;
-
- /* Adjust the year heading */
-
- gnome_canvas_item_set (yv->heading,
- "x", width / 2.0,
- "y", (double) HEAD_SPACING,
- NULL);
-
- /* Adjust titles and months */
-
- for (i = 0; i < 12; i++) {
- x = (i % 3) * xofs;
- y = head_height + (i / 3) * yofs;
-
- gnome_canvas_item_set (yv->titles[i],
- "x", x + month_width / 2.0,
- "y", y,
- NULL);
-
- gnome_canvas_item_set (yv->mitems[i],
- "x", x,
- "y", y + month_yofs,
- "width", month_width,
- "height", month_height,
- NULL);
- }
-
- /* Done */
-
- yv->need_resize = FALSE;
- return FALSE;
-}
-
-/* Marks the year view as needing a resize, which will be performed during the idle loop */
-static void
-need_resize (YearView *yv)
-{
- if (yv->need_resize)
- return;
-
- yv->need_resize = TRUE;
- yv->idle_id = gtk_idle_add (idle_handler, yv);
-}
-
-/* Callback used to destroy the year view's popup menu when the year view itself is destroyed */
-static void
-destroy_menu (GtkWidget *widget, gpointer data)
-{
- gtk_widget_destroy (GTK_WIDGET (data));
-}
-
-/* Create a new appointment in the highlighted day from the year view's popup menu */
-static void
-new_appointment (GtkWidget *widget, gpointer data)
-{
- YearView *yv;
- time_t *t;
-
- yv = YEAR_VIEW (data);
- t = gtk_object_get_data (GTK_OBJECT (widget), "time_data");
-
- event_editor_new_whole_day (yv->calendar, *t);
-}
-
-/* Convenience functions to jump to a view and set the time */
-static void
-do_jump (GtkWidget *widget, gpointer data, char *view_name)
-{
- YearView *yv;
- time_t *t;
-
- yv = YEAR_VIEW (data);
-
- /* Get the time data from the menu item */
-
- t = gtk_object_get_data (GTK_OBJECT (widget), "time_data");
-
- /* Set the view and time */
-
- gnome_calendar_set_view (yv->calendar, view_name);
- gnome_calendar_goto (yv->calendar, *t);
-}
-
-/* The following three callbacks set the view in the calendar and change the time */
-
-static void
-jump_to_day (GtkWidget *widget, gpointer data)
-{
- do_jump (widget, data, "dayview");
-}
-
-static void
-jump_to_week (GtkWidget *widget, gpointer data)
-{
- do_jump (widget, data, "weekview");
-}
-
-static void
-jump_to_month (GtkWidget *widget, gpointer data)
-{
- do_jump (widget, data, "monthview");
-}
-
-/* Information for the year view's popup menu */
-static GnomeUIInfo yv_popup_menu[] = {
- GNOMEUIINFO_ITEM_STOCK (N_("_New appointment in this day..."), NULL, new_appointment, GNOME_STOCK_MENU_NEW),
-
- GNOMEUIINFO_SEPARATOR,
-
- GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _day"), NULL, jump_to_day, GNOME_STOCK_MENU_JUMP_TO),
- GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _week"), NULL, jump_to_week, GNOME_STOCK_MENU_JUMP_TO),
- GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _month"), NULL, jump_to_month, GNOME_STOCK_MENU_JUMP_TO),
- GNOMEUIINFO_END
-};
-
-/* Returns the popup menu cooresponding to the specified year view. If the menu has not been
- * created yet, it creates it and attaches it to the year view.
- */
-static GtkWidget *
-get_popup_menu (YearView *yv)
-{
- GtkWidget *menu;
-
- menu = gtk_object_get_data (GTK_OBJECT (yv), "popup_menu");
-
- if (!menu) {
- menu = gnome_popup_menu_new (yv_popup_menu);
- gtk_object_set_data (GTK_OBJECT (yv), "popup_menu", menu);
- gtk_signal_connect (GTK_OBJECT (yv), "destroy",
- (GtkSignalFunc) destroy_menu,
- menu);
- }
-
- return menu;
-}
-
-/* Executes the year view's popup menu. It may disable/enable some menu items based on the
- * specified flags. A pointer to a time_t value containing the specified time data is set in the
- * "time_data" object data key of the menu items.
- */
-static void
-do_popup_menu (YearView *yv, GdkEventButton *event, int allow_new, int allow_day, int allow_week, int allow_month,
- int year, int month, int day)
-{
- GtkWidget *menu;
- static time_t t;
-
- menu = get_popup_menu (yv);
-
- /* Enable/disable items as appropriate */
-
- gtk_widget_set_sensitive (yv_popup_menu[0].widget, allow_new);
- gtk_widget_set_sensitive (yv_popup_menu[2].widget, allow_day);
- gtk_widget_set_sensitive (yv_popup_menu[3].widget, allow_week);
- gtk_widget_set_sensitive (yv_popup_menu[4].widget, allow_month);
-
- /* Set the day item relevant to the context */
-
- t = time_from_day (year, month, day);
-
- gtk_object_set_data (GTK_OBJECT (yv_popup_menu[0].widget), "time_data", &t);
- gtk_object_set_data (GTK_OBJECT (yv_popup_menu[2].widget), "time_data", &t);
- gtk_object_set_data (GTK_OBJECT (yv_popup_menu[3].widget), "time_data", &t);
- gtk_object_set_data (GTK_OBJECT (yv_popup_menu[4].widget), "time_data", &t);
-
- gnome_popup_menu_do_popup (menu, NULL, NULL, event, yv);
-}
-
-/* Creates the quick view when the user clicks on a day */
-static void
-do_quick_view_popup (YearView *yv, GdkEventButton *event, int year, int month, int day)
-{
- time_t day_start, day_end;
- GList *list;
- GtkWidget *qv;
- char date_str[256];
-
- day_start = time_from_day (year, month, day);
- day_end = time_day_end (day_start);
-
- list = calendar_get_events_in_range (yv->calendar->cal, day_start, day_end);
-
- strftime (date_str, sizeof (date_str), _("%a %b %d %Y"), localtime (&day_start));
- qv = quick_view_new (yv->calendar, date_str, list);
-
- quick_view_do_popup (QUICK_VIEW (qv), event);
-
- gtk_widget_destroy (qv);
- calendar_destroy_event_list (list);
-}
-
-/* Event handler for days in the year's month items */
-static gint
-day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- YearView *yv;
- GnomeMonthItem *mitem;
- int child_num, day;
-
- mitem = GNOME_MONTH_ITEM (data);
- child_num = gnome_month_item_child2num (mitem, item);
- day = gnome_month_item_num2day (mitem, child_num);
-
- yv = YEAR_VIEW (item->canvas);
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if (day == 0)
- break;
-
- if (event->button.button == 1) {
- do_quick_view_popup (yv, (GdkEventButton *) event, mitem->year, mitem->month, day);
- return TRUE;
- } else if (event->button.button == 3) {
- do_popup_menu (yv, (GdkEventButton *) event, TRUE, TRUE, TRUE, TRUE,
- mitem->year, mitem->month, day);
-
- /* We have to stop the signal emission because mark.c will grab it too and
- * set the return value to FALSE. Blargh.
- */
- gtk_signal_emit_stop_by_name (GTK_OBJECT (item), "event");
- return TRUE;
- }
-
- break;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-/* Event handler for whole month items */
-static gint
-month_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- YearView *yv;
- GnomeMonthItem *mitem;
-
- mitem = GNOME_MONTH_ITEM (item);
-
- yv = YEAR_VIEW (item->canvas);
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if (event->button.button != 3)
- break;
-
- do_popup_menu (yv, (GdkEventButton *) event, FALSE, FALSE, FALSE, TRUE,
- mitem->year, mitem->month, 1);
-
- /* We have to stop the signal emission because mark.c will grab it too and
- * set the return value to FALSE. Blargh.
- */
- gtk_signal_emit_stop_by_name (GTK_OBJECT (item), "event");
- return TRUE;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-/* Sets up the month item with the specified index -- connects signals for handling events, etc. */
-static void
-setup_month_item (YearView *yv, int n)
-{
- GnomeCanvasItem *mitem;
- GnomeCanvasItem *item;
- int i;
-
- mitem = yv->mitems[n];
-
- /* Connect the day signals */
-
- for (i = 0; i < 42; i++) {
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mitem), GNOME_MONTH_ITEM_DAY_GROUP + i);
- gtk_signal_connect (GTK_OBJECT (item), "event",
- (GtkSignalFunc) day_event,
- mitem);
- }
-
- /* Connect the month signals */
-
- gtk_signal_connect (GTK_OBJECT (mitem), "event",
- (GtkSignalFunc) month_event,
- NULL);
-
- /* Prepare for prelighting */
-
- month_item_prepare_prelight (GNOME_MONTH_ITEM (mitem), default_color_func, NULL);
-}
-
-/* Computes the minimum size for the year view and stores it in its internal fields */
-static void
-compute_min_size (YearView *yv)
-{
- GtkArg args[2];
- double m_width;
- double m_height;
- double max_width;
- double w;
- int i;
-
- /* Compute the minimum size of the year heading */
-
- args[0].name = "text_width";
- args[1].name = "text_height";
- gtk_object_getv (GTK_OBJECT (yv->heading), 2, args);
-
- m_width = GTK_VALUE_DOUBLE (args[0]);
- m_height = 2 * HEAD_SPACING + GTK_VALUE_DOUBLE (args[1]);
-
- /* Add height of month titles and their spacings */
-
- args[0].name = "text_height";
- gtk_object_getv (GTK_OBJECT (yv->titles[0]), 1, &args[0]);
-
- m_height += 4 * (GTK_VALUE_DOUBLE (args[0]) + TITLE_SPACING);
-
- /* Add width of month titles */
-
- max_width = 0.0;
-
- for (i = 0; i < 12; i++) {
- args[0].name = "text_width";
- gtk_object_getv (GTK_OBJECT (yv->titles[i]), 1, &args[0]);
-
- w = GTK_VALUE_DOUBLE (args[0]);
- if (max_width < w)
- max_width = w;
- }
-
- max_width = 3 * max_width + 2 * SPACING;
-
- if (m_width < max_width)
- m_width = max_width;
-
- /* Add width of month items */
-
- args[0].name = "width";
- args[1].name = "height";
- gtk_object_getv (GTK_OBJECT (yv->mitems[0]), 2, args);
-
- max_width = 3 * GTK_VALUE_DOUBLE (args[0]) + 2 * SPACING;
-
- if (m_width < max_width)
- m_width = max_width;
-
- /* Add height of month items */
-
- m_height += 4 * GTK_VALUE_DOUBLE (args[1]) + 3 * SPACING;
-
- /* Finally, set the minimum width and height in the year view */
-
- yv->min_width = (int) (m_width + 0.5);
- yv->min_height = (int) (m_height + 0.5);
-}
-
-static void
-year_view_init (YearView *yv)
-{
- int i;
- char buf[100];
- struct tm tm;
-
- memset (&tm, 0, sizeof (tm));
-
- /* Heading */
-
- yv->heading = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (yv)),
- gnome_canvas_text_get_type (),
- "anchor", GTK_ANCHOR_N,
- "fontset", HEADING_FONTSET,
- "fill_color", "black",
- NULL);
-
- /* Months */
-
- for (i = 0; i < 12; i++) {
- /* Title */
-
- strftime (buf, 100, "%B", &tm);
- tm.tm_mon++;
-
- yv->titles[i] = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (yv)),
- gnome_canvas_text_get_type (),
- "text", buf,
- "anchor", GTK_ANCHOR_N,
- "fontset", TITLE_FONTSET,
- "fill_color", "black",
- NULL);
-
- /* Month item */
-
- yv->mitems[i] = gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (yv)));
- gnome_canvas_item_set (yv->mitems[i],
- "anchor", GTK_ANCHOR_NW,
- "start_on_monday", week_starts_on_monday,
- "heading_fontset", DAY_HEADING_FONTSET,
- "day_fontset", NORMAL_DAY_FONTSET,
- NULL);
- setup_month_item (yv, i);
- }
-
- /* We will need to resize the items when we paint for the first time */
-
- yv->old_marked_day = -1;
- yv->idle_id = -1;
- need_resize (yv);
-}
-
-static void
-year_view_destroy (GtkObject *object)
-{
- YearView *yv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_YEAR_VIEW (object));
-
- yv = YEAR_VIEW (object);
-
- if (yv->need_resize) {
- yv->need_resize = FALSE;
- gtk_idle_remove (yv->idle_id);
- }
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-GtkWidget *
-year_view_new (GnomeCalendar *calendar, time_t year)
-{
- YearView *yv;
-
- g_return_val_if_fail (calendar != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CALENDAR (calendar), NULL);
-
- yv = gtk_type_new (year_view_get_type ());
- yv->calendar = calendar;
-
- year_view_colors_changed (yv);
- year_view_set (yv, year);
- compute_min_size (yv);
-
- return GTK_WIDGET (yv);
-}
-
-static void
-year_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- YearView *yv;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (IS_YEAR_VIEW (widget));
- g_return_if_fail (requisition != NULL);
-
- yv = YEAR_VIEW (widget);
-
- requisition->width = yv->min_width;
- requisition->height = yv->min_height;
-}
-
-static void
-year_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- YearView *yv;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (IS_YEAR_VIEW (widget));
- g_return_if_fail (allocation != NULL);
-
- yv = YEAR_VIEW (widget);
-
- if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
- (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
-
- need_resize (yv);
-}
-
-void
-year_view_update (YearView *yv, iCalObject *object, int flags)
-{
- g_return_if_fail (yv != NULL);
- g_return_if_fail (IS_YEAR_VIEW (yv));
-
- /* If only the summary changed, we don't care */
-
- if (object && ((flags & CHANGE_SUMMARY) == flags))
- return;
-
- year_view_set (yv, time_year_begin (time_from_day (yv->year, 0, 1)));
-}
-
-/* Unmarks the old day that was marked as current and marks the current day if appropriate */
-static void
-mark_current_day (YearView *yv)
-{
- time_t t;
- struct tm tm;
- int month_index, day_index;
- GnomeCanvasItem *item;
-
- /* Unmark the old day */
-
- if (yv->old_marked_day != -1) {
- month_index = yv->old_marked_day / 42;
- day_index = yv->old_marked_day % 42;
-
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[month_index]),
- GNOME_MONTH_ITEM_DAY_LABEL + day_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
- "fontset", NORMAL_DAY_FONTSET,
- NULL);
-
- yv->old_marked_day = -1;
- }
-
- /* Mark the new day */
-
- t = time (NULL);
- tm = *localtime (&t);
-
- if ((tm.tm_year + 1900) == yv->year) {
- month_index = tm.tm_mon;
- day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (yv->mitems[month_index]), tm.tm_mday);
- g_assert (day_index != -1);
-
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[month_index]),
- GNOME_MONTH_ITEM_DAY_LABEL + day_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
- "fontset", CURRENT_DAY_FONTSET,
- NULL);
-
- yv->old_marked_day = month_index * 42 + day_index;
- }
-}
-
-void
-year_view_set (YearView *yv, time_t year)
-{
- struct tm tm;
- char buf[100];
- int i;
-
- g_return_if_fail (yv != NULL);
- g_return_if_fail (IS_YEAR_VIEW (yv));
-
- tm = *localtime (&year);
- yv->year = tm.tm_year + 1900;
-
- /* Heading */
-
- sprintf (buf, "%d", yv->year);
- gnome_canvas_item_set (yv->heading,
- "text", buf,
- NULL);
-
- /* Months */
-
- for (i = 0; i < 12; i++)
- gnome_canvas_item_set (yv->mitems[i],
- "year", yv->year,
- "month", i,
- NULL);
-
- /* Unmark and re-mark all the months */
-
- for (i = 0; i < 12; i++) {
- unmark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]));
- mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
- }
-
- mark_current_day (yv);
-}
-
-void
-year_view_time_format_changed (YearView *yv)
-{
- int i;
-
- g_return_if_fail (yv != NULL);
- g_return_if_fail (IS_YEAR_VIEW (yv));
-
- for (i = 0; i < 12; i++)
- gnome_canvas_item_set (yv->mitems[i],
- "start_on_monday", week_starts_on_monday,
- NULL);
-
- year_view_set (yv, time_year_begin (time_from_day (yv->year, 0, 1)));
-}
-
-void
-year_view_colors_changed (YearView *yv)
-{
- int i;
-
- g_return_if_fail (yv != NULL);
- g_return_if_fail (IS_YEAR_VIEW (yv));
-
- for (i = 0; i < 12; i++) {
- colorify_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), default_color_func, NULL);
- mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
- }
-
- mark_current_day (yv);
-}
diff --git a/calendar/gui/year-view.h b/calendar/gui/year-view.h
deleted file mode 100644
index 77e63366d5..0000000000
--- a/calendar/gui/year-view.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Year view display for Gnomecal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Arturo Espinosa <arturo@nuclecu.unam.mx>
- * Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef YEAR_VIEW_H
-#define YEAR_VIEW_H
-
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-#include "gnome-month-item.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define TYPE_YEAR_VIEW (year_view_get_type ())
-#define YEAR_VIEW(obj) (GTK_CHECK_CAST ((obj), TYPE_YEAR_VIEW, YearView))
-#define YEAR_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_YEAR_VIEW, YearViewClass))
-#define IS_YEAR_VIEW(obj) (GTK_CHECK_TYPE ((obj), TYPE_YEAR_VIEW))
-#define IS_YEAR_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_YEAR_VIEW))
-
-
-typedef struct _YearView YearView;
-typedef struct _YearViewClass YearViewClass;
-
-struct _YearView {
- GnomeCanvas canvas;
-
- GnomeCalendar *calendar; /* The calendar we are associated to */
-
- int year; /* The year we are displaying */
-
- GnomeCanvasItem *heading; /* Big heading with year */
- GnomeCanvasItem *titles[12]; /* Titles for months */
- GnomeCanvasItem *mitems[12]; /* Month items */
-
- int old_marked_day; /* The day that is marked as the current day */
-
- int min_width; /* Minimum dimensions of year view, used for size_request*/
- int min_height;
-
- guint idle_id; /* ID of idle handler for resize */
-
- int need_resize : 1; /* Specifies whether we need to resize the canvas items or not */
-};
-
-struct _YearViewClass {
- GnomeCanvasClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType year_view_get_type (void);
-
-/* Creates a new year view widget associated to the specified calendar */
-GtkWidget *year_view_new (GnomeCalendar *calendar, time_t year);
-
-/* Notifies the year view that a calendar object has changed */
-void year_view_update (YearView *yv, iCalObject *ico, int flags);
-
-/* Notifies the year view about a change of date */
-void year_view_set (YearView *yv, time_t year);
-
-/* Notifies the year view that the time format has changed */
-void year_view_time_format_changed (YearView *yv);
-
-/* Notifies the year view that colors have changed */
-void year_view_colors_changed (YearView *yv);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/html-month.c b/calendar/html-month.c
deleted file mode 100644
index 9d4af13c33..0000000000
--- a/calendar/html-month.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Creates an HTML rendering for this month
- * Copyright (C) 1999 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@kernel.org)
- */
-#include <config.h>
-#include <gnome.h>
-#include <pwd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <ctype.h>
-#include "calendar.h"
-#include "alarm.h"
-#include "eventedit.h"
-#include "gnome-cal.h"
-#include "main.h"
-#include "timeutil.h"
-
-static void
-make_html_header (GnomeCalendar *gcal, GString *s)
-{
- g_string_sprintf (s,
- "<html>\n"
- " <head>\n"
- " <title>%s</title>\n"
- " </head>\n"
- " <body>\n",
- gcal->cal->title);
-}
-
-static void
-make_html_footer (GString *s)
-{
- g_string_sprintf (s, "</html>");
-}
-
-static void
-make_days_headers (GString *s)
-{
- g_string_append (s,
- "<p><table border=1>\n"
- "<tr>\n"
- " <td></td>\n"
- " <td>MONDAY</td>\n"
- " <td>TUESDAY</td>\n"
- " <td>WEDNESDAY</td>\n"
- " <td>THURSDAY</td>\n"
- " <td>FRIDAY</td>\n"
- "</tr>\n");
-}
-
-static void
-make_days (GnomeCalendar *gcal, GString *s)
-{
- struct tm tm, month;
- time_t month_start;
- int day;
- time_t now = time (NULL);
-
- make_days_headers (s);
- tm = *localtime (&now);
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_mday = 1;
- month_start = mktime (&tm);
- month = *localtime (&month_start);
-
- for (day = 0; day < month.tm_mday; day++){
-
- }
-#if 0
- day = 0;
- for (y = 0; y < 5; y++){
- for (x = 0; x < 7; x++){
- if (month.tm_mday < day
- }
- }
-#endif
-}
-
-void
-make_month_html (GnomeCalendar *gcal, char *output)
-{
- FILE *f;
- GString *s;
-
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- f = fopen (output, "w");
- if (!f){
- g_warning ("Add nice error message here");
- return;
- }
-
- s = g_string_new ("");
-
- make_html_header (gcal, s);
- make_days (gcal, s);
- make_html_footer (s);
-
- fwrite (s->str, strlen (s->str), 1, f);
-
- g_string_free (s, TRUE);
- fclose (f);
-}
diff --git a/calendar/icalendar-types b/calendar/icalendar-types
deleted file mode 100644
index e11f4c1789..0000000000
--- a/calendar/icalendar-types
+++ /dev/null
@@ -1,39 +0,0 @@
-evento todo journal fbrequest fbreply busytime timezone
- attach attach attach
- attendee attendee attendee attendee attendee attendee
- categories categories categories
- class class class
- comment comment comment comment comment comment comment
- completed
- contact contact contact
- created created created created
- description description description
- dtstamp dtstamp
- dtend/duration due->dtend dtend [duration] dtend dtend
- dtstart dtstart dtstart dtstart dtstart dtstart dtstart
- exdate exdate exdate
- exrule exrule exrule
- geo geo
- last-mod last-mod last-mod last-mod last-mod
- location location
- organizer organizer organizer
- percent
- priority priority
- rstatus rstatus rstatus rstatus
- related related related
- resources resources
- rdate rdate rdate [rdate/rrule]
- rrule rrule rrule
- dtstamp dtstamp dtstamp dtstamp
- seq seq seq seq seq
- status status
- summary summary summary
- transp
- uid uid uid uid uid
- url url url url url
- recurid recurid recurid
- freebusy freebusy
- tzname
- tzoffset-to
- tzoffset-from
-
diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl
deleted file mode 100644
index 6746eb66a1..0000000000
--- a/calendar/idl/evolution-calendar.idl
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Evolution calendar interface
- *
- * Copyright (C) 2000 Eskil Heyn Olsen
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Authors: Eskil Heyn Olsen <deity@eskil.dk>
- * Federico Mena-Quintero <federico@helixcode.com>
- */
-
-#ifndef _EVOLUTION_CALENDAR_IDL_
-#define _EVOLUTION_CALENDAR_IDL_
-
-#include <Bonobo.idl>
-
-module Evolution {
-
-module Calendar {
- /* A calendar object (event/todo/journal/etc), represented as an
- * iCalendar string.
- */
- typedef string CalObj;
-
- /* An unique identifier for a calendar object */
- typedef string CalObjUID;
-
- interface Listener;
-
- /* Calendar client interface */
- interface Cal : Bonobo::Unknown {
- exception NotFound {};
-
- /* A calendar is identified by its URI */
- readonly attribute string uri;
-
- /* Gets an object based on its URI */
- CalObj get_object (in CalObjUID uid)
- raises (NotFound);
- };
-
- /* Listener for changes in a calendar */
- interface Listener : Bonobo::Unknown {
- /* Return status when loading a calendar; we need better error reporting */
- enum LoadStatus {
- SUCCESS,
- ERROR
- };
-
- /* Called from a CalFactory when a calendar is initially loaded
- * or created. The listener must remember the cal object.
- */
- void cal_loaded (in LoadStatus status, in Cal cal);
-
- /* Called from a Calendar when an object is added */
- void obj_added (in CalObjUID uid);
-
- /* Called from a Calendar when an object is removed */
- void obj_removed (in CalObjUID uid);
-
- /* Called from a Calendar when an object is changed */
- void obj_changed (in CalObjUID uid);
- };
-
- /* A calendar factory, can load and create calendars */
- interface CalFactory : Bonobo::Unknown {
- exception NilListener {};
-
- /* Load a calendar from an URI */
- void load (in string uri, in Listener listener)
- raises (NilListener);
-
- /* Create a new calendar at the specified URI */
- void create (in string uri, in Listener listener)
- raises (NilListener);
- };
-};
-
-};
-
-#endif
diff --git a/calendar/job.c b/calendar/job.c
deleted file mode 100644
index d97df6d883..0000000000
--- a/calendar/job.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* GNOME personal calendar server - job manager
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include "job.h"
-
-
-
-/* The job list */
-
-typedef struct {
- JobFunc func;
- gpointer data;
-} Job;
-
-static GSList *jobs_head;
-static GSList *jobs_tail;
-
-static guint jobs_idle_id;
-
-
-
-/* Runs a job and dequeues it */
-static gboolean
-run_job (gpointer data)
-{
- Job *job;
- GSList *l;
-
- g_assert (jobs_head != NULL);
-
- job = jobs_head->data;
- (* job->func) (job->data);
- g_free (job);
-
- l = jobs_head;
- jobs_head = g_slist_remove_link (jobs_head, jobs_head);
- g_slist_free_1 (l);
-
- if (!jobs_head) {
- jobs_tail = NULL;
- jobs_idle_id = 0;
- return FALSE;
- } else
- return TRUE;
-}
-
-/**
- * job_add:
- * @func: Function to run the job.
- * @data: Data to pass to @function.
- *
- * Adds a job to the queue. The job will automatically be run asynchronously.
- **/
-void
-job_add (JobFunc func, gpointer data)
-{
- Job *job;
-
- g_return_if_fail (func != NULL);
-
- job = g_new (Job, 1);
- job->func = func;
- job->data = data;
-
- if (!jobs_head) {
- g_assert (jobs_tail == NULL);
- g_assert (jobs_idle_id == 0);
-
- jobs_head = g_slist_append (NULL, job);
- jobs_tail = jobs_head;
-
- jobs_idle_id = g_idle_add (run_job, NULL);
- } else {
- g_assert (jobs_tail != NULL);
- g_assert (jobs_idle_id != 0);
-
- jobs_tail = g_slist_append (jobs_tail, job)->next;
- }
-}
diff --git a/calendar/job.h b/calendar/job.h
deleted file mode 100644
index c9bce24dd4..0000000000
--- a/calendar/job.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* GNOME personal calendar server - job manager
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef JOB_H
-#define JOB_H
-
-#include <glib.h>
-
-
-
-typedef void (* JobFunc) (gpointer data);
-
-void job_add (JobFunc func, gpointer data);
-
-
-
-#endif
diff --git a/calendar/layout.c b/calendar/layout.c
deleted file mode 100644
index 1367ae3f8f..0000000000
--- a/calendar/layout.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/* Event layout engine for Gnomecal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Miguel de Icaza <miguel@nuclecu.unam.mx>
- * Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include <stdlib.h>
-#include "layout.h"
-
-
-/* This structure is used to pass around layout information among the internal layout functions */
-struct layout_info {
- GList *events; /* List of events from client */
- int num_events; /* The number of events (length of the list) */
- LayoutQueryTimeFunc func; /* Function to convert a list item to a start/end time pair */
- int num_rows; /* Size of the time partition */
- time_t *partition; /* The time partition containing start and end time values */
- int *array; /* Working array of free and allocated time slots */
- int *allocations; /* Returned array of slot allocations */
- int *slots; /* Returned array of slots used */
- int num_slots; /* Number of slots used */
-};
-
-
-/* This defines the maximum number of events to overlap per row. More than that number of events
- * will not be displayed. This is not ideal, so sue me.
- */
-#define MAX_EVENTS_PER_ROW 32
-
-
-/* Compares two time_t values, used for qsort() */
-static int
-compare_time_t (const void *a, const void *b)
-{
- time_t ta, tb;
-
- ta = *((time_t *) a);
- tb = *((time_t *) b);
-
- if (ta < tb)
- return -1;
- else if (ta > tb)
- return 1;
- else
- return 0;
-}
-
-/* Builds a partition of the time range occupied by the events in the list. It returns an array
- * with the times that define the partition and the number of items in the partition.
- */
-static void
-build_partition (struct layout_info *li)
-{
- time_t *rows, *p, *q;
- GList *list;
- int i, unique_vals;
-
- /* This is the maximum number of rows we would need */
-
- li->num_rows = li->num_events * 2;
-
- /* Fill the rows with the times */
-
- rows = g_new (time_t, li->num_rows);
-
- for (list = li->events, p = rows; list; list = list->next) {
- (* li->func) (list, &p[0], &p[1]);
- p += 2;
- }
-
- /* Do a sort | uniq on the array */
-
- qsort (rows, li->num_rows, sizeof (time_t), compare_time_t);
-
- p = rows;
- q = rows + 1;
- unique_vals = 1;
-
- for (i = 1; i < li->num_rows; i++, q++)
- if (*q != *p) {
- unique_vals++;
- p++;
- *p = *q;
- }
-
- /* Return the number of unique values in the partition and the partition array itself */
-
- li->num_rows = unique_vals;
- li->partition = rows;
-}
-
-/* Returns the index of the element in the partition that corresponds to the specified time */
-int
-find_index (struct layout_info *li, time_t t)
-{
- int i;
-
- for (i = 0; ; i++)
- if (li->partition[i] == t)
- return i;
-
- g_assert_not_reached ();
-}
-
-#define xy(li, x, y) li->array[(y * MAX_EVENTS_PER_ROW) + (x)]
-
-/* Checks that all the cells in the slot array at the specified slot column are free to use by an
- * event that has the specified range.
- */
-static int
-range_is_empty (struct layout_info *li, int slot, time_t start, time_t end)
-{
- int i;
-
- for (i = find_index (li, start); li->partition[i] < end; i++)
- if (xy (li, slot, i) != -1)
- return FALSE;
-
- return TRUE;
-}
-
-/* Allocates a time in the slot array for the specified event's index */
-static void
-range_allocate (struct layout_info *li, int slot, time_t start, time_t end, int ev_num)
-{
- int i;
-
- for (i = find_index (li, start); li->partition[i] < end; i++)
- xy (li, slot, i) = ev_num;
-}
-
-/* Performs the initial allocation of slots for events. Each event gets one column; they will be
- * expanded in a later stage. Returns the number of columns used.
- */
-static void
-initial_allocate (struct layout_info *li)
-{
- GList *events;
- int i;
- int slot;
- int num_slots;
- time_t start, end;
-
- num_slots = 0;
-
- for (i = 0, events = li->events; events; events = events->next, i++) {
- (* li->func) (events, &start, &end);
-
- /* Start with no allocation, no columns */
-
- li->allocations[i] = -1;
- li->slots[i] = 0;
-
- /* Find a free column for the event */
-
- for (slot = 0; slot < MAX_EVENTS_PER_ROW; slot++)
- if (range_is_empty (li, slot, start, end)) {
- range_allocate (li, slot, start, end, i);
-
- li->allocations[i] = slot;
- li->slots[i] = 1;
-
- if ((slot + 1) > num_slots)
- num_slots = slot + 1;
-
- break;
- }
- }
-
- li->num_slots = num_slots;
-}
-
-/* Returns the maximum number of columns that an event can expanded by in the slot array */
-static int
-columns_to_expand (struct layout_info *li, int ev_num, time_t start, time_t end)
-{
- int cols;
- int slot;
- int i_start;
- int i;
-
- cols = 0;
-
- i_start = find_index (li, start);
-
- for (slot = li->allocations[ev_num] + 1; slot < li->num_slots; slot++) {
- for (i = i_start; li->partition[i] < end; i++)
- if (xy (li, slot, i) != -1)
- return cols;
-
- cols++;
- }
-
- return cols;
-}
-
-/* Expands an event by the specified number of columns */
-static void
-do_expansion (struct layout_info *li, int ev_num, time_t start, time_t end, int num_cols)
-{
- int i, j;
- int slot;
-
- for (i = find_index (li, start); li->partition[i] < end; i++) {
- slot = li->allocations[ev_num] + 1;
-
- for (j = 0; j < num_cols; j++)
- xy (li, slot + j, i) = ev_num;
- }
-}
-
-/* Expands the events in the slot array to occupy as many columns as possible. This is the second
- * pass of the layout algorithm.
- */
-static void
-expand_events (struct layout_info *li)
-{
- GList *events;
- time_t start, end;
- int i;
- int cols;
-
- for (i = 0, events = li->events; events; events = events->next, i++) {
- (* li->func) (events, &start, &end);
-
- cols = columns_to_expand (li, i, start, end);
-
- if (cols == 0)
- continue; /* We can't expand this event */
-
- do_expansion (li, i, start, end, cols);
-
- li->slots[i] += cols;
- }
-}
-
-void
-layout_events (GList *events, LayoutQueryTimeFunc func, int *num_slots, int **allocations, int **slots)
-{
- struct layout_info li;
- int i;
-
- g_return_if_fail (num_slots != NULL);
- g_return_if_fail (allocations != NULL);
- g_return_if_fail (slots != NULL);
-
- if (!events) {
- *num_slots = 0;
- *allocations = NULL;
- *slots = NULL;
-
- return;
- }
-
- li.events = events;
- li.num_events = g_list_length (events);
- li.func = func;
-
- /* Build the partition of the time range, and then build the array of slots */
-
- build_partition (&li);
-
- li.array = g_new (int, li.num_rows * MAX_EVENTS_PER_ROW);
- for (i = 0; i < (li.num_rows * MAX_EVENTS_PER_ROW); i++)
- li.array[i] = -1; /* This is our 'empty' value */
-
- /* Build the arrays for allocations and columns used */
-
- li.allocations = g_new (int, li.num_events);
- li.slots = g_new (int, li.num_events);
-
- /* Perform initial allocation and then expand the events to as many slots as they can occupy */
-
- initial_allocate (&li);
- expand_events (&li);
-
- /* Clean up and return values */
-
- g_free (li.array);
-
- *num_slots = li.num_slots;
- *allocations = li.allocations;
- *slots = li.slots;
-}
diff --git a/calendar/layout.h b/calendar/layout.h
deleted file mode 100644
index 734b720b8b..0000000000
--- a/calendar/layout.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Event layout engine for Gnomecal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Miguel de Icaza <miguel@nuclecu.unam.mx>
- * Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef LAYOUT_H
-#define LAYOUT_H
-
-#include <glib.h>
-#include <time.h>
-
-
-/* Functions of this type must translate the list item into two time_t values for the start and end
- * of an event.
- */
-typedef void (* LayoutQueryTimeFunc) (GList *event, time_t *start, time_t *end);
-
-
-/* This is the main layout function for overlapping events. You pass in a list of (presumably)
- * events and a function that should take a list element and return the start and end times for the
- * event corresponding to that list element.
- *
- * It returns the number of slots ("columns") that you need to take into account when actually
- * painting the events, the array of the first slot index that each event occupies, and the array of
- * number of slots that each event occupies. You have to free both arrays.
- *
- * You will get somewhat better-looking results if the list of events is sorted by using the start
- * time as the primary sort key and the end time as the secondary sort key -- so that "longer"
- * events go first in the list.
- */
-void layout_events (GList *events, LayoutQueryTimeFunc func, int *num_slots, int **allocations, int **slots);
-
-
-#endif
diff --git a/calendar/main.c b/calendar/main.c
deleted file mode 100644
index 9dead6b92e..0000000000
--- a/calendar/main.c
+++ /dev/null
@@ -1,1059 +0,0 @@
-/*
- * Main file for the GNOME Calendar program
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@kernel.org)
- * Federico Mena (federico@nuclecu.unam.mx)
- */
-
-#include <config.h>
-#include <gnome.h>
-#include <libgnorba/gnorba.h>
-#include <pwd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include "calendar.h"
-#include "alarm.h"
-#include "eventedit.h"
-#include "gnome-cal.h"
-#include "main.h"
-#include "timeutil.h"
-#include "corba-cal-factory.h"
-
-#define COOKIE_USER_HOME_DIR ((char *) -1)
-
-
-/* The username, used to set the `owner' field of the event */
-char *user_name;
-
-/* The full user name from the Gecos field */
-char *full_name;
-
-/* The user's default calendar file */
-char *user_calendar_file;
-
-/* a gnome-config string prefix that can be used to access the calendar config info */
-char *calendar_settings;
-
-/* Day begin, day end parameters */
-int day_begin, day_end;
-
-/* Whether weeks starts on Sunday or Monday */
-int week_starts_on_monday;
-
-/* If true, do not show our top level window */
-int startup_hidden = 0;
-
-/* If true, enable debug output for alarms */
-int debug_alarms = 0;
-
-/* The array of color properties -- keep in sync with the enumeration defined in main.h. The color
- * values specified here are the defaults for the program.
- */
-struct color_prop color_props[] = {
- { 0x3e72, 0x35ec, 0x8ba2, N_("Outline:"), "/calendar/Colors/outline" },
- { 0xffff, 0xffff, 0xffff, N_("Headings:"), "/calendar/Colors/headings" },
- { 0xf26c, 0xecec, 0xbbe7, N_("Empty days:"), "/calendar/Colors/empty_bg" },
- { 0xfc1e, 0xf87f, 0x5f80, N_("Appointments:"), "/calendar/Colors/mark_bg" },
- { 0xd364, 0xc6b7, 0x7969, N_("Highlighted day:"), "/calendar/Colors/prelight_bg" },
- { 0x01f0, 0x01f0, 0x01f0, N_("Day numbers:"), "/calendar/Colors/day_fg" },
- { 0x0000, 0x0000, 0xffff, N_("Current day's number:"), "/calendar/Colors/current_fg" },
- { 0xbbbb, 0xbbbb, 0x0000, N_("To-Do item that is not yet due:"), "/calendar/Colors/todo_not_yet" },
- { 0xdddd, 0xbbbb, 0x0000, N_("To-Do item that is due today:"), "/calendar/Colors/todo_today" },
- { 0xbbbb, 0xdddd, 0x0000, N_("To-Do item that is overdue:"), "/calendar/Colors/todo_overdue" }
-};
-
-/* Number of active calendars */
-int active_calendars = 0;
-
-/* A list of all of the calendars started */
-GList *all_calendars = NULL;
-
-/* For dumping part of a calendar */
-static time_t from_t, to_t;
-
-/* File to load instead of the user default's file */
-static char *load_file;
-
-/* If set, show events for the specified date and quit */
-static int show_events;
-
-/* If set, show todo items quit */
-static int show_todo;
-
-/* If set, beep on display alarms */
-gboolean beep_on_display = 0;
-
-/* If true, timeout the beeper on audio alarms */
-
-gboolean enable_aalarm_timeout = 0;
-guint audio_alarm_timeout = 0;
-const guint MAX_AALARM_TIMEOUT = 3600;
-const guint MAX_SNOOZE_SECS = 3600;
-gboolean enable_snooze = 0;
-guint snooze_secs = 60;
-
-/* Default values for alarms */
-CalendarAlarm alarm_defaults[4] = {
- { ALARM_MAIL, 0, 15, ALARM_MINUTES },
- { ALARM_PROGRAM, 0, 15, ALARM_MINUTES },
- { ALARM_DISPLAY, 0, 15, ALARM_MINUTES },
- { ALARM_AUDIO, 0, 15, ALARM_MINUTES }
-};
-
-static void
-init_username (void)
-{
- user_name = g_strdup(g_get_user_name());
- full_name = g_strdup(g_get_real_name());
-}
-
-static int
-range_check_hour (int hour)
-{
- if (hour < 0)
- hour = 0;
- else if (hour >= 24)
- hour = 23;
-
- return hour;
-}
-
-static void
-init_default_alarms (void)
-{
- int i;
- gboolean def;
-
- alarm_defaults [ALARM_DISPLAY].type = ALARM_DISPLAY;
- alarm_defaults [ALARM_AUDIO].type = ALARM_AUDIO;
- alarm_defaults [ALARM_PROGRAM].type = ALARM_PROGRAM;
- alarm_defaults [ALARM_MAIL].type = ALARM_MAIL;
-
- for (i = 0; i < 4; i++) {
- switch (alarm_defaults [i].type) {
- case ALARM_DISPLAY:
- gnome_config_push_prefix ("/calendar/alarms/def_disp_");
- break;
- case ALARM_AUDIO:
- gnome_config_push_prefix ("/calendar/alarms/def_audio_");
- break;
- case ALARM_PROGRAM:
- gnome_config_push_prefix ("/calendar/alarms/def_prog_");
- break;
- case ALARM_MAIL:
- gnome_config_push_prefix ("/calendar/alarms/def_mail_");
- break;
- }
-
- alarm_defaults[i].enabled = gnome_config_get_int ("enabled=0");
- if (alarm_defaults[i].type != ALARM_MAIL) {
- alarm_defaults[i].count = gnome_config_get_int ("count=15");
- alarm_defaults[i].units = gnome_config_get_int ("units=0");
- } else {
- alarm_defaults[i].count = gnome_config_get_int ("count=1");
- alarm_defaults[i].count = gnome_config_get_int ("count=2");
- }
-
- alarm_defaults[i].data = gnome_config_get_string_with_default ("data=",
- &def);
- if (def)
- alarm_defaults[i].data = NULL;
-
- gnome_config_pop_prefix ();
- }
-}
-
-
-/*
- * Initializes the calendar internal variables, loads defaults
- */
-static void
-init_calendar (void)
-{
- int i;
- char *cspec, *color;
- char *str;
-
- init_username ();
- user_calendar_file = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/user-cal.vcf");
-
- gnome_config_push_prefix (calendar_settings);
-
- /* Read calendar settings */
-
- day_begin = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day start=8"));
- day_end = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day end=17"));
- am_pm_flag = gnome_config_get_bool ("/calendar/Calendar/AM PM flag=0");
- week_starts_on_monday = gnome_config_get_bool ("/calendar/Calendar/Week starts on Monday=0");
-
- if (day_end < day_begin){
- day_begin = 8;
- day_end = 17;
- }
-
- /* Read color settings */
-
- for (i = 0; i < COLOR_PROP_LAST; i++) {
- cspec = build_color_spec (color_props[i].r, color_props[i].g, color_props[i].b);
- str = g_strconcat (color_props[i].key, "=", cspec, NULL);
-
- color = gnome_config_get_string (str);
- parse_color_spec (color, &color_props[i].r, &color_props[i].g, &color_props[i].b);
-
- g_free (str);
- g_free (color);
- }
-
- /* read todolist settings */
-
- todo_show_time_remaining = gnome_config_get_bool("/calendar/Todo/show_time_remain");
- todo_show_due_date = gnome_config_get_bool("/calendar/Todo/show_due_date");
-
- todo_item_dstatus_highlight_overdue = gnome_config_get_bool("/calendar/Todo/highlight_overdue");
-
- todo_item_dstatus_highlight_due_today = gnome_config_get_bool("/calendar/Todo/highlight_due_today");
-
- todo_item_dstatus_highlight_not_due_yet = gnome_config_get_bool("/calendar/Todo/highlight_not_due_yet");
-
- todo_current_sort_column = gnome_config_get_int("/calendar/Todo/sort_column");
-
- todo_current_sort_type = gnome_config_get_int("/calendar/Todo/sort_type");
-
- todo_show_priority = gnome_config_get_bool("/calendar/Todo/show_priority");
-
- /* read alarm settings */
- beep_on_display = gnome_config_get_bool ("/calendar/alarms/beep_on_display=FALSE");
- enable_aalarm_timeout = gnome_config_get_bool ("/calendar/alarms/enable_audio_timeout=FALSE");
- audio_alarm_timeout = gnome_config_get_int ("/calendar/alarms/audio_alarm_timeout=60");
- if (audio_alarm_timeout < 1)
- audio_alarm_timeout = 1;
- if (audio_alarm_timeout > MAX_AALARM_TIMEOUT)
- audio_alarm_timeout = MAX_AALARM_TIMEOUT;
- enable_snooze = gnome_config_get_bool ("/calendar/alarms/enable_snooze=FALSE");
- snooze_secs = gnome_config_get_int ("/calendar/alarms/snooze_secs=300");
- if (snooze_secs < 1)
- snooze_secs = 1;
- if (snooze_secs > MAX_SNOOZE_SECS)
- snooze_secs = MAX_SNOOZE_SECS;
-
- init_default_alarms ();
-
-
- /* Done */
-
- gnome_config_pop_prefix ();
-}
-
-
-
-static void save_calendar_cmd (GtkWidget *widget, void *data);
-
-static void
-about_calendar_cmd (GtkWidget *widget, void *data)
-{
- GtkWidget *about;
- const gchar *authors[] = {
- "Miguel de Icaza (miguel@kernel.org)",
- "Federico Mena (federico@gimp.org)",
- "Arturo Espinosa (arturo@nuclecu.unam.mx)",
- "Russell Steinthal (rms39@columbia.edu)",
- NULL
- };
-
- about = gnome_about_new (_("Gnome Calendar"), VERSION,
- "(C) 1998 the Free Software Foundation",
- authors,
- _("The GNOME personal calendar and schedule manager."),
- NULL);
- gtk_window_set_modal (GTK_WINDOW (about), TRUE);
- gnome_dialog_set_close (GNOME_DIALOG (about), TRUE);
- gtk_widget_show (about);
-}
-
-static void
-display_objedit (GtkWidget *widget, GnomeCalendar *gcal)
-{
- GtkWidget *ee;
- iCalObject *ico;
-
- /* Default to the day the user is looking at */
- ico = ical_new ("", user_name, "");
- ico->new = 1;
- ico->dtstart = time_add_minutes (gcal->current_display, day_begin * 60);
- ico->dtend = time_add_minutes (ico->dtstart, day_begin * 60 + 30 );
-
- ee = event_editor_new (gcal, ico);
- gtk_widget_show (ee);
-}
-
-static void
-display_objedit_today (GtkWidget *widget, GnomeCalendar *gcal)
-{
- GtkWidget *ee;
-
- ee = event_editor_new (gcal, NULL);
- gtk_widget_show (ee);
-}
-
-GnomeCalendar *
-gnome_calendar_locate (const char *pathname)
-{
- GList *l;
-
- if (pathname == NULL || pathname [0] == 0)
- pathname = user_calendar_file;
-
- for (l = all_calendars; l; l = l->next){
- GnomeCalendar *gcal = l->data;
-
- if (strcmp (gcal->cal->filename, pathname) == 0){
- return gcal;
- }
- }
- return NULL;
-}
-
-static void
-close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
-{
- all_calendars = g_list_remove (all_calendars, gcal);
-
- if (gcal->cal->modified){
- if (!gcal->cal->filename)
- save_calendar_cmd (widget, gcal);
- else
- calendar_save (gcal->cal, gcal->cal->filename);
- }
-
- gtk_widget_destroy (GTK_WIDGET (gcal));
- active_calendars--;
-
- if (active_calendars == 0){
- unregister_calendar_services ();
- gtk_main_quit ();
- }
-}
-
-void
-time_format_changed (void)
-{
- GList *l;
-
- for (l = all_calendars; l; l = l->next)
- gnome_calendar_time_format_changed (GNOME_CALENDAR (l->data));
-}
-
-void
-colors_changed (void)
-{
- GList *l;
-
- for (l = all_calendars; l; l = l->next)
- gnome_calendar_colors_changed (GNOME_CALENDAR (l->data));
-}
-
-void
-todo_properties_changed(void)
-{
- GList *l;
-
- for (l = all_calendars; l; l = l->next)
- gnome_calendar_todo_properties_changed (GNOME_CALENDAR (l->data));
-}
-
-
-
-static void
-quit_cmd (void)
-{
- while (all_calendars){
- GnomeCalendar *cal = GNOME_CALENDAR (all_calendars->data);
-
- close_cmd (GTK_WIDGET (cal), cal);
- }
-}
-
-/* Sets a clock cursor for the specified calendar window */
-static void
-set_clock_cursor (GnomeCalendar *gcal)
-{
- GdkCursor *cursor;
-
- cursor = gdk_cursor_new (GDK_WATCH);
- gdk_window_set_cursor (GTK_WIDGET (gcal)->window, cursor);
- gdk_cursor_destroy (cursor);
- gdk_flush ();
-}
-
-/* Resets the normal cursor for the specified calendar window */
-static void
-set_normal_cursor (GnomeCalendar *gcal)
-{
- gdk_window_set_cursor (GTK_WIDGET (gcal)->window, NULL);
- gdk_flush ();
-}
-
-static void
-previous_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- set_clock_cursor (gcal);
- gnome_calendar_previous (gcal);
- set_normal_cursor (gcal);
-}
-
-static void
-next_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- set_clock_cursor (gcal);
- gnome_calendar_next (gcal);
- set_normal_cursor (gcal);
-}
-
-static void
-today_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- set_clock_cursor (gcal);
- gnome_calendar_goto_today (gcal);
- set_normal_cursor (gcal);
-}
-
-static void
-goto_clicked (GtkWidget *widget, GnomeCalendar *gcal)
-{
- goto_dialog (gcal);
-}
-
-static void
-new_calendar_cmd (GtkWidget *widget, void *data)
-{
- new_calendar (full_name, NULL, NULL, NULL, FALSE);
-}
-
-static void
-open_ok (GtkWidget *widget, GtkFileSelection *fs)
-{
- GtkWidget *error_dialog;
- int ret;
- if(!g_file_exists (gtk_file_selection_get_filename (fs))) {
- error_dialog = gnome_message_box_new (
- _("File not found"),
- GNOME_MESSAGE_BOX_ERROR,
- GNOME_STOCK_BUTTON_OK,
- NULL);
-
- gnome_dialog_set_parent (GNOME_DIALOG (error_dialog), GTK_WINDOW (fs));
- ret = gnome_dialog_run (GNOME_DIALOG (error_dialog));
- } else {
- /* FIXME: find out who owns this calendar and use that name */
- new_calendar ("Somebody", gtk_file_selection_get_filename (fs), NULL, NULL, FALSE);
- gtk_widget_destroy (GTK_WIDGET (fs));
- }
-}
-
-static void
-open_calendar_cmd (GtkWidget *widget, void *data)
-{
- GtkFileSelection *fs;
-
- fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Open calendar")));
-
- gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked",
- (GtkSignalFunc) open_ok,
- fs);
- gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked",
- (GtkSignalFunc) gtk_widget_destroy,
- GTK_OBJECT (fs));
-
- gtk_widget_show (GTK_WIDGET (fs));
- gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me */
-}
-
-static void
-save_ok (GtkWidget *widget, GtkFileSelection *fs)
-{
- GnomeCalendar *gcal;
- gchar *fname;
-
- gcal = GNOME_CALENDAR (gtk_object_get_user_data (GTK_OBJECT (fs)));
- gtk_window_set_wmclass (GTK_WINDOW (gcal), "gnomecal", "gnomecal");
-
- fname = g_strdup (gtk_file_selection_get_filename (fs));
- calendar_save (gcal->cal, fname);
- g_free(fname);
- gtk_main_quit ();
-}
-
-static gint
-close_save (GtkWidget *w)
-{
- gtk_main_quit ();
- return TRUE;
-}
-
-static void
-save_as_calendar_cmd (GtkWidget *widget, void *data)
-{
- GtkFileSelection *fs;
-
- fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Save calendar")));
- gtk_object_set_user_data (GTK_OBJECT (fs), data);
-
- gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked",
- (GtkSignalFunc) save_ok,
- fs);
- gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked",
- (GtkSignalFunc) close_save,
- GTK_OBJECT (fs));
- gtk_signal_connect_object (GTK_OBJECT (fs), "delete_event",
- GTK_SIGNAL_FUNC (close_save),
- GTK_OBJECT (fs));
- gtk_widget_show (GTK_WIDGET (fs));
- gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me even more */
- gtk_main ();
- gtk_widget_destroy (GTK_WIDGET (fs));
-}
-
-static void
-properties_cmd (GtkWidget *widget, GtkWidget *gcal)
-{
- properties (gcal);
-}
-
-static void
-save_calendar_cmd (GtkWidget *widget, void *data)
-{
- GnomeCalendar *gcal = data;
-
- if (gcal->cal->filename){
- struct stat s;
-
- if (stat (gcal->cal->filename, &s) == -1){
- if (errno == ENOENT)
- calendar_save (gcal->cal, gcal->cal->filename);
-
- return;
- }
-
- if (s.st_mtime != gcal->cal->file_time){
- GtkWidget *box;
- char *str;
- int b;
-
- str = g_strdup_printf (
- _("File %s has changed since it was loaded\nContinue?"),
- gcal->cal->filename);
- box = gnome_message_box_new (str, GNOME_MESSAGE_BOX_INFO,
- GNOME_STOCK_BUTTON_YES,
- GNOME_STOCK_BUTTON_NO,
- NULL);
- g_free (str);
- gnome_dialog_set_default (GNOME_DIALOG (box), 1);
- b = gnome_dialog_run (GNOME_DIALOG (box));
-
- if (b != 0)
- return;
- }
-
- calendar_save (gcal->cal, gcal->cal->filename);
- } else
- save_as_calendar_cmd (widget, data);
-}
-
-/*
- * Saves @gcal if it is the default calendar
- */
-void
-save_default_calendar (GnomeCalendar *gcal)
-{
- if (!gcal->cal->filename)
- return;
-
- save_calendar_cmd (NULL, gcal);
-}
-
-#if 0
-static void
-make_html_cmd (GtkWidget *widget, GtkWidget *gcal)
-{
- make_month_html (gcal, "output.html");
-}
-#endif
-
-static GnomeUIInfo gnome_cal_file_menu [] = {
- GNOMEUIINFO_MENU_NEW_ITEM(N_("_New calendar"),
- N_("Create a new calendar"),
- new_calendar_cmd, NULL),
-
- GNOMEUIINFO_MENU_OPEN_ITEM(open_calendar_cmd, NULL),
-
- GNOMEUIINFO_MENU_SAVE_ITEM(save_calendar_cmd, NULL),
-
- GNOMEUIINFO_MENU_SAVE_AS_ITEM(save_as_calendar_cmd, NULL),
-
- GNOMEUIINFO_SEPARATOR,
-
-#if 0
- GNOMEUIINFO_ITEM(N_("Create HTML for this month"),
- N_("Creates an HTML version of this month's appointments"),
- make_html_cmd, NULL);
-#endif
- GNOMEUIINFO_SEPARATOR,
-
- GNOMEUIINFO_MENU_CLOSE_ITEM(close_cmd, NULL),
-
- GNOMEUIINFO_MENU_EXIT_ITEM(quit_cmd, NULL),
-
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_edit_menu [] = {
- { GNOME_APP_UI_ITEM, N_("_New appointment..."),
- N_("Create a new appointment"), display_objedit, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_NEW, 0, 0, NULL },
- { GNOME_APP_UI_ITEM, N_("New appointment for _today..."),
- N_("Create a new appointment for today"),
- display_objedit_today, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_NEW, 0, 0, NULL },
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_help_menu [] = {
- GNOMEUIINFO_HELP ("gnomecal"),
-
- GNOMEUIINFO_MENU_ABOUT_ITEM(about_calendar_cmd, NULL),
-
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_settings_menu [] = {
- GNOMEUIINFO_MENU_PREFERENCES_ITEM(properties_cmd, NULL),
-
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_cal_menu [] = {
- GNOMEUIINFO_MENU_FILE_TREE(gnome_cal_file_menu),
- GNOMEUIINFO_MENU_EDIT_TREE(gnome_cal_edit_menu),
- GNOMEUIINFO_MENU_SETTINGS_TREE(gnome_cal_settings_menu),
- GNOMEUIINFO_MENU_HELP_TREE(gnome_cal_help_menu),
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo gnome_toolbar [] = {
- GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new appointment"), display_objedit, GNOME_STOCK_PIXMAP_NEW),
-
- GNOMEUIINFO_SEPARATOR,
-
- GNOMEUIINFO_ITEM_STOCK (N_("Prev"), N_("Go back in time"), previous_clicked, GNOME_STOCK_PIXMAP_BACK),
- GNOMEUIINFO_ITEM_STOCK (N_("Today"), N_("Go to present time"), today_clicked, GNOME_STOCK_PIXMAP_HOME),
- GNOMEUIINFO_ITEM_STOCK (N_("Next"), N_("Go forward in time"), next_clicked, GNOME_STOCK_PIXMAP_FORWARD),
-
- GNOMEUIINFO_SEPARATOR,
-
- GNOMEUIINFO_ITEM_STOCK (N_("Go to"), N_("Go to a specific date"), goto_clicked, GNOME_STOCK_PIXMAP_JUMP_TO),
-
- GNOMEUIINFO_END
-};
-
-static void
-setup_menu (GtkWidget *gcal)
-{
- gnome_app_create_menus_with_data (GNOME_APP (gcal), gnome_cal_menu, gcal);
- gnome_app_create_toolbar_with_data (GNOME_APP (gcal), gnome_toolbar, gcal);
- gnome_app_install_menu_hints(GNOME_APP(gcal), gnome_cal_menu);
-}
-
-static void
-setup_appbar (GtkWidget *gcal)
-{
- GtkWidget *appbar;
-
- appbar = gnome_appbar_new (FALSE, TRUE, GNOME_PREFERENCES_USER);
- gnome_app_set_statusbar (GNOME_APP (gcal), GTK_WIDGET (appbar));
-}
-
-static gint
-calendar_close_event (GtkWidget *widget, GdkEvent *event, GnomeCalendar *gcal)
-{
- close_cmd (widget, gcal);
- return TRUE;
-}
-
-GnomeCalendar *
-new_calendar (char *full_name, char *calendar_file, char *geometry, char *page, gboolean hidden)
-{
- GtkWidget *toplevel;
- char title[128];
- int xpos, ypos, width, height;
-
- /* i18n: This "%s%s" indicates possession. Languages where the order is
- * the inverse should translate it to "%2$s%1$s".
- */
- g_snprintf(title, 128, _("%s%s"), full_name, _("'s calendar"));
-
- toplevel = gnome_calendar_new (title);
-
- if (gnome_parse_geometry (geometry, &xpos, &ypos, &width, &height)){
- if (xpos != -1)
- gtk_widget_set_uposition (toplevel, xpos, ypos);
-#if 0
- if (width != -1)
- gtk_widget_set_usize (toplevel, width, 600);
-#endif
- }
-#if 0
- gtk_widget_set_usize (toplevel, width, 600);
-#endif
-
- setup_appbar (toplevel);
- setup_menu (toplevel);
-
-
- if (page)
- gnome_calendar_set_view (GNOME_CALENDAR (toplevel), page);
-
- if (calendar_file && g_file_exists (calendar_file))
- gnome_calendar_load (GNOME_CALENDAR (toplevel), calendar_file);
- else
- GNOME_CALENDAR (toplevel)->cal->filename = g_strdup (calendar_file);
-
- gtk_signal_connect (GTK_OBJECT (toplevel), "delete_event",
- GTK_SIGNAL_FUNC(calendar_close_event), toplevel);
-
- active_calendars++;
- all_calendars = g_list_prepend (all_calendars, toplevel);
-
- if (hidden){
- GnomeWinState state;
-
- /* Realize the toplevel window to prevent a segfault */
- gtk_widget_realize (toplevel);
- state = gnome_win_hints_get_state (toplevel);
-
- state |= WIN_STATE_MINIMIZED;
- gnome_win_hints_set_state (toplevel, state);
- }
-
- gtk_widget_show (toplevel);
-
- return GNOME_CALENDAR (toplevel);
-}
-
-static void
-process_dates (void)
-{
- if (!from_t)
- from_t = time_day_begin (time (NULL));
-
- if (!to_t || to_t < from_t)
- to_t = time_add_day (from_t, 1);
-}
-
-enum {
- GEOMETRY_KEY = -1,
- USERFILE_KEY = -2,
- VIEW_KEY = -3,
- HIDDEN_KEY = -4,
- TODO_KEY = -5,
- DEBUG_KEY = -6
-};
-
-/* Lists used to startup various GnomeCalendars */
-static GList *start_calendars;
-static GList *start_geometries;
-static GList *start_views;
-
-static int
-same_day (struct tm *a, struct tm *b)
-{
- return (a->tm_mday == b->tm_mday &&
- a->tm_mon == b->tm_mon &&
- a->tm_year == b->tm_year);
-}
-
-static void
-dump_events (void)
-{
- Calendar *cal;
- GList *l;
- char *s;
- time_t now = time (NULL);
- struct tm today = *localtime (&now);
-
- process_dates ();
- init_calendar ();
-
- cal = calendar_new (full_name, CALENDAR_INIT_ALARMS);
- s = calendar_load (cal, load_file ? load_file : user_calendar_file);
- if (s){
- printf ("error: %s\n", s);
- exit (1);
- }
- l = calendar_get_events_in_range (cal, from_t, to_t);
- for (; l; l = l->next){
- char start [80], end [80];
- CalendarObject *co = l->data;
- struct tm ts, te;
- char *format;
-
- ts = *localtime (&co->ev_start);
- te = *localtime (&co->ev_end);
-
- if (same_day (&today, &ts))
- format = N_("%H:%M");
- else
- format = N_("%A %b %d, %H:%M");
- strftime (start, sizeof (start), _(format), &ts);
-
- if (!same_day (&ts, &te))
- format = N_("%A %b %d, %H:%M");
- strftime (end, sizeof (start), _(format), &te);
-
- printf ("%s -- %s\n", start, end);
- printf (" %s\n", co->ico->summary);
- }
- calendar_destroy_event_list (l);
- calendar_destroy (cal);
- exit (0);
-}
-
-static void
-dump_todo (void)
-{
- Calendar *cal;
- GList *l;
- char *s;
-
- process_dates ();
- init_calendar ();
-
- cal = calendar_new (full_name, CALENDAR_INIT_ALARMS);
- s = calendar_load (cal, load_file ? load_file : user_calendar_file);
- if (s){
- printf ("error: %s\n", s);
- exit (1);
- }
- for (l = cal->todo; l; l = l->next){
- iCalObject *object = l->data;
-
- if (object->type != ICAL_TODO)
- continue;
-
- printf ("[%s]: %s\n", object->organizer, object->summary);
- }
- calendar_destroy (cal);
- exit (0);
-}
-
-extern time_t get_date ();
-
-static void
-parse_an_arg (poptContext ctx,
- enum poptCallbackReason reason,
- const struct poptOption *opt,
- char *arg, void *data)
-{
- switch (opt->val){
- case 'f':
- from_t = get_date (arg, NULL);
- break;
-
- case 't':
- to_t = get_date (arg, NULL);
- break;
-
- case GEOMETRY_KEY:
- start_geometries = g_list_append (start_geometries, arg);
- break;
-
- case USERFILE_KEY:
- /* This is a special key that tells the program to load
- * the user's calendar file. This allows session management
- * to work even if the User's home directory changes location
- * (ie, on a networked setup).
- */
- arg = COOKIE_USER_HOME_DIR;
- /* fall through */
- break;
-
- case VIEW_KEY:
- start_views = g_list_append (start_views, arg);
- break;
-
- case 'F':
- start_calendars = g_list_append (start_calendars, arg);
- break;
-
- case TODO_KEY:
- show_todo = 1;
- break;
-
- case 'e':
- show_events = 1;
- break;
-
- case HIDDEN_KEY:
- startup_hidden = 1;
- break;
-
- case DEBUG_KEY:
- if (!g_strcasecmp (arg, "alarms"))
- debug_alarms = 1;
- break;
-
- default:
- }
-}
-
-static const struct poptOption options [] = {
- { NULL, '\0', POPT_ARG_CALLBACK, parse_an_arg, 0, NULL, NULL },
- { "events", 'e', POPT_ARG_NONE, NULL, 'e', N_("Show events and quit"),
- NULL },
- { "todo", 0, POPT_ARG_NONE, NULL, TODO_KEY, N_("Show TO-DO items and quit"),
- NULL },
- { "from", 'f', POPT_ARG_STRING, NULL, 'f', N_("Specifies start date [for --events]"), N_("DATE") },
- { "file", 'F', POPT_ARG_STRING, NULL, 'F', N_("File to load calendar from"), N_("FILE") },
- { "userfile", '\0', POPT_ARG_NONE, NULL, USERFILE_KEY, N_("Load the user calendar"), NULL },
- { "geometry", '\0', POPT_ARG_STRING, NULL, GEOMETRY_KEY, N_("Geometry for starting up"), N_("GEOMETRY") },
- { "view", '\0', POPT_ARG_STRING, NULL, VIEW_KEY, N_("The startup view mode (dayview, weekview, monthview, yearview)"), N_("VIEW") },
- { "to", 't', POPT_ARG_STRING, NULL, 't', N_("Specifies ending date [for --events]"), N_("DATE") },
- { "hidden", 0, POPT_ARG_NONE, NULL, HIDDEN_KEY, N_("If used, starts in iconic mode"), NULL },
- { "debug", 'd', POPT_ARG_STRING, NULL, DEBUG_KEY, N_("Enable debugging output of TYPE (alarms)"), N_("TYPE") },
- { NULL, '\0', 0, NULL, 0}
-};
-
-static void
-session_die (void)
-{
- quit_cmd ();
-}
-
-/*
- * Save the session callback
- */
-static int
-session_save_state (GnomeClient *client, gint phase, GnomeRestartStyle save_style, gint shutdown,
- GnomeInteractStyle interact_style, gint fast, gpointer client_data)
-{
- char *sess_id;
- char **argv = (char **) g_malloc (sizeof (char *) * ((active_calendars * 6) + 3));
- GList *l, *free_list = 0;
- int i;
-
- sess_id = gnome_client_get_id (client);
-
- argv [0] = client_data;
- for (i = 1, l = all_calendars; l; l = l->next){
- GnomeCalendar *gcal = GNOME_CALENDAR (l->data);
- char *geometry;
-
- geometry = gnome_geometry_string (GTK_WIDGET (gcal)->window);
-
- if (strcmp (gcal->cal->filename, user_calendar_file) == 0)
- argv [i++] = "--userfile";
- else {
- argv [i++] = "--file";
- argv [i++] = gcal->cal->filename;
- }
- argv [i++] = "--geometry";
- argv [i++] = geometry;
- argv [i++] = "--view";
- argv [i++] = gnome_calendar_get_current_view_name (gcal);
- free_list = g_list_append (free_list, geometry);
- calendar_save (gcal->cal, gcal->cal->filename);
- }
- argv [i] = NULL;
- gnome_client_set_clone_command (client, i, argv);
- gnome_client_set_restart_command (client, i, argv);
-
- for (l = free_list; l; l = l->next)
- g_free (l->data);
- g_list_free (free_list);
-
- return 1;
-}
-
-int
-main(int argc, char *argv[])
-{
- GnomeClient *client;
- CORBA_Environment ev;
-
- bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);
-
- CORBA_exception_init (&ev);
-
- gnome_CORBA_init_with_popt_table (
- "calendar", VERSION, &argc, argv,
- options, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev);
-
- orb = gnome_CORBA_ORB ();
- poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev);
- if (ev._major == CORBA_NO_EXCEPTION){
- init_corba_server ();
- }
-
- if (show_events)
- dump_events ();
- if (show_todo)
- dump_todo ();
-
- client = gnome_master_client ();
- if (client){
- gtk_signal_connect (GTK_OBJECT (client), "save_yourself",
- GTK_SIGNAL_FUNC (session_save_state), argv [0]);
- gtk_signal_connect (GTK_OBJECT (client), "die",
- GTK_SIGNAL_FUNC (session_die), NULL);
- }
-
- process_dates ();
- alarm_init ();
- init_calendar ();
-
- /*
- * Load all of the calendars specifies in the command line with
- * the geometry specificied -if any-
- */
- if (start_calendars){
- GList *p, *g, *v;
- char *title;
-
- p = start_calendars;
- g = start_geometries;
- v = start_views;
- while (p){
- char *file = p->data;
- char *geometry = g ? g->data : NULL;
- char *page_name = v ? v->data : NULL;
-
- if (file == COOKIE_USER_HOME_DIR)
- file = user_calendar_file;
-
- if (strcmp (file, user_calendar_file) == 0)
- title = full_name;
- else
- title = file;
- new_calendar (title, file, geometry, page_name, startup_hidden);
-
- p = p->next;
- if (g)
- g = g->next;
- if (v)
- v = v->next;
- }
- g_list_free (p);
- } else {
- char *geometry = start_geometries ? start_geometries->data : NULL;
- char *page_name = start_views ? start_views->data : NULL;
-
- new_calendar (full_name, user_calendar_file, geometry, page_name, startup_hidden);
- }
- gtk_main ();
- return 0;
-}
diff --git a/calendar/main.h b/calendar/main.h
deleted file mode 100644
index 2785e1d2d1..0000000000
--- a/calendar/main.h
+++ /dev/null
@@ -1,101 +0,0 @@
-#ifndef MAIN_H
-#define MAIN_H
-
-/* Calendar preferences */
-
-extern int day_begin, day_end;
-extern char *user_name;
-extern int am_pm_flag;
-extern int week_starts_on_monday;
-
-
-/* This enum and the following array define the color preferences */
-
-typedef enum {
- COLOR_PROP_OUTLINE_COLOR, /* Color of calendar outline */
- COLOR_PROP_HEADING_COLOR, /* Color for headings */
- COLOR_PROP_EMPTY_DAY_BG, /* Background color for empty days */
- COLOR_PROP_MARK_DAY_BG, /* Background color for days with appointments */
- COLOR_PROP_PRELIGHT_DAY_BG, /* Background color for prelighted day */
- COLOR_PROP_DAY_FG, /* Color for day numbers */
- COLOR_PROP_CURRENT_DAY_FG, /* Color for current day's number */
- COLOR_PROP_TODO_NOT_DUE_YET, /* Color for Todo items not yet due */
- COLOR_PROP_TODO_DUE_TODAY, /* Color for Todo items due today */
- COLOR_PROP_TODO_OVERDUE, /* Color for Todo items that are overdue */
- COLOR_PROP_LAST /* Number of color properties */
-} ColorProp;
-
-struct color_prop {
- int r; /* Values are in [0, 65535] */
- int g;
- int b;
- char *label; /* Label for properties dialog */
- char *key; /* Key for gnome_config */
-};
-
-extern struct color_prop color_props[];
-
-
-/* todo preferences */
-extern int todo_show_due_date;
-
-extern int todo_item_dstatus_highlight_overdue;
-extern int todo_item_dstatus_highlight_due_today;
-extern int todo_item_dstatus_highlight_not_due_yet;
-
-extern int todo_show_time_remaining;
-extern int todo_show_priority;
-extern char *todo_overdue_font_text;
-extern gboolean todo_style_changed;
-extern gint todo_current_sort_column;
-extern gint todo_current_sort_type;
-
-/* alarm stuff */
-extern CalendarAlarm alarm_defaults[4];
-extern gboolean beep_on_display;
-extern gboolean enable_aalarm_timeout;
-extern guint audio_alarm_timeout;
-extern const guint MAX_AALARM_TIMEOUT;
-extern gboolean enable_snooze;
-extern guint snooze_secs;
-extern const guint MAX_SNOOZE_SECS;
-
-/* Creates and runs the preferences dialog box */
-void properties (GtkWidget *toplevel);
-
-/* Asks for all the time-related displays to be updated when the user changes the time format
- * preferences.
- */
-void time_format_changed (void);
-
-/* Asks for all the month items' colors to be reset */
-void colors_changed (void);
-
-/* Asks for all todo lists to reflect the accurate properties */
-void todo_properties_changed(void);
-
-/* Creates and runs the Go-to date dialog */
-void goto_dialog (GnomeCalendar *gcal);
-
-/* Returns a pointer to a statically-allocated string with a representation of the specified color.
- * Values must be in [0, 65535].
- */
-char *build_color_spec (int r, int g, int b);
-
-/* Parses a color specification of the form "#%04x%04x%04x" and returns the color components. */
-void parse_color_spec (char *spec, int *r, int *g, int *b);
-
-/* Calls build_color_spec() for the color in the specified property number */
-char *color_spec_from_prop (ColorProp propnum);
-
-void save_default_calendar (GnomeCalendar *gcal);
-
-GnomeCalendar *new_calendar (char *full_name, char *calendar_file,
- char *geometry, char *page, gboolean hidden);
-
-#endif
-
-
-
-
-
diff --git a/calendar/mark.c b/calendar/mark.c
deleted file mode 100644
index 2de8e2b880..0000000000
--- a/calendar/mark.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/* Functions to mark calendars
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include "gnome-cal.h"
-#include "main.h"
-#include "mark.h"
-#include "timeutil.h"
-
-
-/* Frees the specified data when an object is destroyed */
-static void
-free_data (GtkObject *object, gpointer data)
-{
- g_free (data);
-}
-
-/* If the array of "marked" attributes for the days in a a month item has not been created yet, this
- * function creates the array and clears it. Otherwise, it just returns the existing array.
- */
-static char *
-get_attributes (GnomeMonthItem *mitem)
-{
- char *attrs;
-
- attrs = gtk_object_get_data (GTK_OBJECT (mitem), "day_mark_attributes");
-
- if (!attrs) {
- attrs = g_new0 (char, 42);
- gtk_object_set_data (GTK_OBJECT (mitem), "day_mark_attributes", attrs);
- gtk_signal_connect (GTK_OBJECT (mitem), "destroy",
- (GtkSignalFunc) free_data,
- attrs);
- }
-
- return attrs;
-}
-
-void
-colorify_month_item (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data)
-{
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
- g_return_if_fail (func != NULL);
-
- unmark_month_item (mitem);
-
- /* We have to do this in several calls to gnome_canvas_item_set(), as color_spec_from_prop()
- * returns a pointer to a static string -- and we need several values.
- */
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "heading_color", (* func) (COLOR_PROP_HEADING_COLOR, func_data),
- NULL);
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "outline_color", (* func) (COLOR_PROP_OUTLINE_COLOR, func_data),
- NULL);
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "day_box_color", (* func) (COLOR_PROP_EMPTY_DAY_BG, func_data),
- NULL);
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "day_color", (* func) (COLOR_PROP_DAY_FG, func_data),
- NULL);
-}
-
-/* In the month item, marks all the days that are touched by the specified time span. Assumes that
- * the time span is completely contained within the month. The array of day attributes is modified
- * accordingly.
- */
-static void
-mark_event_in_month (GnomeMonthItem *mitem, time_t start, time_t end)
-{
- struct tm tm;
- int day_index;
-
- tm = *localtime (&start);
-
- for (; start <= end; start += 60 * 60 * 24) {
- mktime (&tm); /* normalize the time */
-
- /* Figure out the day index that corresponds to this time */
-
- day_index = gnome_month_item_day2index (mitem, tm.tm_mday);
- g_assert (day_index >= 0);
-
- /* Mark the day box */
-
- mark_month_item_index (mitem, day_index, default_color_func, NULL);
-
- /* Next day */
-
- tm.tm_mday++;
- }
-}
-
-void
-mark_month_item (GnomeMonthItem *mitem, Calendar *cal)
-{
- time_t month_begin, month_end;
- GList *list, *l;
- CalendarObject *co;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
- g_return_if_fail (cal != NULL);
-
- month_begin = time_month_begin (time_from_day (mitem->year, mitem->month, 1));
- month_end = time_month_end (month_begin);
-
- list = calendar_get_events_in_range (cal, month_begin, month_end);
-
- for (l = list; l; l = l->next) {
- co = l->data;
-
- /* We clip the event's start and end times to the month's limits */
-
- mark_event_in_month (mitem, MAX (co->ev_start, month_begin), MIN (co->ev_end, month_end));
- }
-
- calendar_destroy_event_list (list);
-}
-
-void
-mark_month_item_index (GnomeMonthItem *mitem, int index, GetColorFunc func, gpointer func_data)
-{
- char *attrs;
- GnomeCanvasItem *item;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
- g_return_if_fail ((index >= 0) && (index < 42));
- g_return_if_fail (func != NULL);
-
- attrs = get_attributes (mitem);
-
- attrs[index] = TRUE;
-
- item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + index);
- gnome_canvas_item_set (item,
- "fill_color", (* func) (COLOR_PROP_MARK_DAY_BG, func_data),
- NULL);
-}
-
-void
-unmark_month_item (GnomeMonthItem *mitem)
-{
- int i;
- char *attrs;
- GnomeCanvasItem *item;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
-
- attrs = get_attributes (mitem);
-
- /* Find marked days and unmark them by turning off their marked attribute flag and changing
- * the color.
- */
-
- for (i = 0; i < 42; i++)
- if (attrs[i]) {
- attrs[i] = FALSE;
-
- item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + i);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_EMPTY_DAY_BG),
- NULL);
- }
-}
-
-/* Handles EnterNotify and LeaveNotify events from the month item's day groups, and performs
- * appropriate prelighting.
- */
-static gint
-day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- GnomeMonthItem *mitem;
- GnomeCanvasItem *box;
- int child_num, day;
- GetColorFunc func;
- gpointer func_data;
- char *color;
- char *attrs;
-
- /* We only accept enters and leaves */
-
- if (!((event->type == GDK_ENTER_NOTIFY) || (event->type == GDK_LEAVE_NOTIFY)))
- return FALSE;
-
- /* Get index information */
-
- mitem = GNOME_MONTH_ITEM (data);
- child_num = gnome_month_item_child2num (mitem, item);
- day = gnome_month_item_num2day (mitem, child_num);
-
- if (day == 0)
- return FALSE; /* it was a day outside the month's range */
-
- child_num -= GNOME_MONTH_ITEM_DAY_GROUP;
- box = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + child_num);
-
- /* Get colors */
-
- func = gtk_object_get_data (GTK_OBJECT (mitem), "prelight_color_func");
- func_data = gtk_object_get_data (GTK_OBJECT (mitem), "prelight_color_data");
-
- /* Now actually set the proper color in the item */
-
- switch (event->type) {
- case GDK_ENTER_NOTIFY:
- color = (* func) (COLOR_PROP_PRELIGHT_DAY_BG, func_data);
- gnome_canvas_item_set (box,
- "fill_color", color,
- NULL);
- break;
-
- case GDK_LEAVE_NOTIFY:
- attrs = get_attributes (mitem);
- color = (* func) (attrs[child_num] ? COLOR_PROP_MARK_DAY_BG : COLOR_PROP_EMPTY_DAY_BG,
- func_data);
- gnome_canvas_item_set (box,
- "fill_color", color,
- NULL);
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- return TRUE;
-}
-
-void
-month_item_prepare_prelight (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data)
-{
- GnomeCanvasItem *day_group;
- int i;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
- g_return_if_fail (func != NULL);
-
- /* Store the function in the object data */
-
- gtk_object_set_data (GTK_OBJECT (mitem), "prelight_color_func", func);
- gtk_object_set_data (GTK_OBJECT (mitem), "prelight_color_data", func_data);
-
- /* Connect the appropriate signals to perform prelighting */
-
- for (i = 0; i < 42; i++) {
- day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (mitem), GNOME_MONTH_ITEM_DAY_GROUP + i);
- gtk_signal_connect (GTK_OBJECT (day_group), "event",
- (GtkSignalFunc) day_event,
- mitem);
- }
-}
-
-char *
-default_color_func (ColorProp propnum, gpointer data)
-{
- return color_spec_from_prop (propnum);
-}
diff --git a/calendar/mark.h b/calendar/mark.h
deleted file mode 100644
index cf8f7c1496..0000000000
--- a/calendar/mark.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Functions to mark calendars
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef MARK_H
-#define MARK_H
-
-#include "calendar.h"
-#include "gnome-month-item.h"
-
-
-/* These are the fonts used for the montly calendars */
-
-#define HEADING_FONTSET "-adobe-helvetica-medium-r-*-*-14-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-medium-r-*-*-14-*-*-*-*-*-ksc5601.1987-0,*"
-#define TITLE_FONTSET "-adobe-helvetica-bold-r-normal--12-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-14-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--12-*-*-*-*-*-ksc5601.1987-0,*"
-#define DAY_HEADING_FONTSET "-adobe-helvetica-medium-r-normal--10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*"
-#define NORMAL_DAY_FONTSET "-adobe-helvetica-medium-r-normal--10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*"
-#define CURRENT_DAY_FONTSET "-adobe-helvetica-bold-r-normal--12-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-14-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--12-*-*-*-*-*-ksc5601.1987-0,*"
-#define BIG_DAY_HEADING_FONTSET "-adobe-helvetica-bold-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-bold-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*"
-#define BIG_NORMAL_DAY_FONTSET "-adobe-helvetica-medium-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*"
-#define BIG_CURRENT_DAY_FONTSET "-adobe-helvetica-bold-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-bold-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*"
-#define EVENT_FONTSET "-adobe-helvetica-medium-r-*-*-10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*"
-
-
-/* Functions of this type are used by the marking functions to fetch color specifications. Such
- * a function must return a color spec based on the property passed to it.
- */
-typedef char * (* GetColorFunc) (ColorProp propnum, gpointer data);
-
-
-/* Sets the user-configured colors and font for a month item. It also tags the days as unmarked. */
-void colorify_month_item (GnomeMonthItem *month, GetColorFunc func, gpointer func_data);
-
-/* Takes a monthly calendar item and marks the days that have events scheduled for them in the
- * specified calendar. It also highlights the current day.
- */
-void mark_month_item (GnomeMonthItem *mitem, Calendar *cal);
-
-/* Marks a day specified by index, not by day number */
-void mark_month_item_index (GnomeMonthItem *mitem, int index, GetColorFunc func, gpointer func_data);
-
-/* Unmarks all the days in the specified month item */
-void unmark_month_item (GnomeMonthItem *mitem);
-
-/* Prepares a monthly calendar item to prelight when the mouse goes over the days. */
-
-void month_item_prepare_prelight (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data);
-
-/* This is the default prelight function you can use for most puposes. You can use NULL as the
- * func_data.
- */
-char *default_color_func (ColorProp prop_num, gpointer data);
-
-
-#endif
diff --git a/calendar/month-view.c b/calendar/month-view.c
deleted file mode 100644
index 5df7b7a23d..0000000000
--- a/calendar/month-view.c
+++ /dev/null
@@ -1,798 +0,0 @@
-/* Month view display for gncal
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include <gnome.h>
-#include <libgnomeui/gnome-canvas-text.h>
-#include "eventedit.h"
-#include "layout.h"
-#include "month-view.h"
-#include "main.h"
-#include "mark.h"
-#include "quick-view.h"
-#include "timeutil.h"
-
-
-/* Spacing between title and calendar */
-#define SPACING 4
-
-/* Padding between day borders and event text */
-#define EVENT_PADDING 3
-
-
-static void month_view_class_init (MonthViewClass *class);
-static void month_view_init (MonthView *mv);
-static void month_view_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void month_view_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-
-
-static GnomeCanvasClass *parent_class;
-
-
-GtkType
-month_view_get_type (void)
-{
- static GtkType month_view_type = 0;
-
- if (!month_view_type) {
- GtkTypeInfo month_view_info = {
- "MonthView",
- sizeof (MonthView),
- sizeof (MonthViewClass),
- (GtkClassInitFunc) month_view_class_init,
- (GtkObjectInitFunc) month_view_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- month_view_type = gtk_type_unique (gnome_canvas_get_type (), &month_view_info);
- }
-
- return month_view_type;
-}
-
-static void
-month_view_class_init (MonthViewClass *class)
-{
- GtkWidgetClass *widget_class;
-
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gnome_canvas_get_type ());
-
- widget_class->size_request = month_view_size_request;
- widget_class->size_allocate = month_view_size_allocate;
-}
-
-/* Creates the quick view when a day is clicked in the month view */
-static void
-do_quick_view_popup (MonthView *mv, GdkEventButton *event, int day)
-{
- time_t day_begin_time, day_end_time;
- GList *list;
- GtkWidget *qv;
- char date_str[256];
-
- day_begin_time = time_from_day (mv->year, mv->month, day);
- day_end_time = time_day_end (day_begin_time);
-
- list = calendar_get_events_in_range (mv->calendar->cal, day_begin_time, day_end_time);
-
- strftime (date_str, sizeof (date_str), _("%a %b %d %Y"), localtime (&day_begin_time));
- qv = quick_view_new (mv->calendar, date_str, list);
-
- quick_view_do_popup (QUICK_VIEW (qv), event);
-
- gtk_widget_destroy (qv);
- calendar_destroy_event_list (list);
-}
-
-/* Callback used to destroy the popup menu when the month view is destroyed */
-static void
-destroy_menu (GtkWidget *widget, gpointer data)
-{
- gtk_widget_destroy (GTK_WIDGET (data));
-}
-
-/* Creates a new appointment in the current day */
-static void
-new_appointment (GtkWidget *widget, gpointer data)
-{
- MonthView *mv;
- time_t *t;
-
- mv = MONTH_VIEW (data);
- t = gtk_object_get_data (GTK_OBJECT (widget), "time_data");
-
- event_editor_new_whole_day (mv->calendar, *t);
-}
-
-/* Convenience functions to jump to a view and set the time */
-static void
-do_jump (GtkWidget *widget, gpointer data, char *view_name)
-{
- MonthView *mv;
- time_t *t;
-
- mv = MONTH_VIEW (data);
-
- /* Get the time data from the menu item */
-
- t = gtk_object_get_data (GTK_OBJECT (widget), "time_data");
-
- /* Set the view and time */
-
- gnome_calendar_set_view (mv->calendar, view_name);
- gnome_calendar_goto (mv->calendar, *t);
-}
-
-/* The following three callbacks set the view in the calendar and change the time */
-
-static void
-jump_to_day (GtkWidget *widget, gpointer data)
-{
- do_jump (widget, data, "dayview");
-}
-
-static void
-jump_to_week (GtkWidget *widget, gpointer data)
-{
- do_jump (widget, data, "weekview");
-}
-
-static void
-jump_to_year (GtkWidget *widget, gpointer data)
-{
- do_jump (widget, data, "yearview");
-}
-
-static GnomeUIInfo mv_popup_menu[] = {
- GNOMEUIINFO_ITEM_STOCK (N_("_New appointment in this day..."), NULL, new_appointment, GNOME_STOCK_MENU_NEW),
-
- GNOMEUIINFO_SEPARATOR,
-
- GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _day"), NULL, jump_to_day, GNOME_STOCK_MENU_JUMP_TO),
- GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _week"), NULL, jump_to_week, GNOME_STOCK_MENU_JUMP_TO),
- GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _year"), NULL, jump_to_year, GNOME_STOCK_MENU_JUMP_TO),
- GNOMEUIINFO_END
-};
-
-/* Creates the popup menu for the month view if it does not yet exist, and attaches it to the month
- * view object so that it can be destroyed when appropriate.
- */
-static GtkWidget *
-get_popup_menu (MonthView *mv)
-{
- GtkWidget *menu;
-
- menu = gtk_object_get_data (GTK_OBJECT (mv), "popup_menu");
-
- if (!menu) {
- menu = gnome_popup_menu_new (mv_popup_menu);
- gtk_object_set_data (GTK_OBJECT (mv), "popup_menu", menu);
- gtk_signal_connect (GTK_OBJECT (mv), "destroy",
- (GtkSignalFunc) destroy_menu,
- menu);
- }
-
- return menu;
-}
-
-/* Pops up the menu for the month view. */
-static void
-do_popup_menu (MonthView *mv, GdkEventButton *event, int day)
-{
- GtkWidget *menu;
- static time_t t;
-
- menu = get_popup_menu (mv);
-
- /* Enable or disable items as appropriate */
-
- gtk_widget_set_sensitive (mv_popup_menu[0].widget, day != 0);
- gtk_widget_set_sensitive (mv_popup_menu[2].widget, day != 0);
- gtk_widget_set_sensitive (mv_popup_menu[3].widget, day != 0);
-
- if (day == 0)
- day = 1;
-
- /* Store the time for the menu item callbacks to use */
-
- t = time_from_day (mv->year, mv->month, day);
-
- gtk_object_set_data (GTK_OBJECT (mv_popup_menu[0].widget), "time_data", &t);
- gtk_object_set_data (GTK_OBJECT (mv_popup_menu[2].widget), "time_data", &t);
- gtk_object_set_data (GTK_OBJECT (mv_popup_menu[3].widget), "time_data", &t);
- gtk_object_set_data (GTK_OBJECT (mv_popup_menu[4].widget), "time_data", &t);
-
- gnome_popup_menu_do_popup (menu, NULL, NULL, event, mv);
-}
-
-/* Event handler for day groups. When mouse button 1 is pressed, it will pop up a quick view with
- * the events in that day. When mouse button 3 is pressed, it will pop up a menu.
- */
-static gint
-day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- MonthView *mv;
- int child_num;
- int day;
-
- mv = MONTH_VIEW (data);
-
- child_num = gnome_month_item_child2num (GNOME_MONTH_ITEM (mv->mitem), item);
- day = gnome_month_item_num2day (GNOME_MONTH_ITEM (mv->mitem), child_num);
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if ((event->button.button == 1) && (day != 0)) {
- do_quick_view_popup (mv, (GdkEventButton *) event, day);
- return TRUE;
- } else if (event->button.button == 3) {
- do_popup_menu (mv, (GdkEventButton *) event, day);
- return TRUE;
- }
-
- break;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-/* Returns the index of the specified arrow in the array of arrows */
-static int
-get_arrow_index (MonthView *mv, GnomeCanvasItem *arrow)
-{
- int i;
-
- for (i = 0; i < 42; i++)
- if (mv->up[i] == arrow)
- return i;
- else if (mv->down[i] == arrow)
- return i + 42;
-
- g_warning ("Eeeek, arrow %p not found in month view %p", arrow, mv);
- return -1;
-}
-
-/* Checks whether arrows need to be displayed at the specified day index or not */
-static void
-check_arrow_visibility (MonthView *mv, int day_index)
-{
- GtkArg args[3];
- double text_height;
- double clip_height;
- double y_offset;
-
- args[0].name = "text_height";
- args[1].name = "clip_height";
- args[2].name = "y_offset";
- gtk_object_getv (GTK_OBJECT (mv->text[day_index]), 3, args);
-
- text_height = GTK_VALUE_DOUBLE (args[0]);
- clip_height = GTK_VALUE_DOUBLE (args[1]);
- y_offset = GTK_VALUE_DOUBLE (args[2]);
-
- /* Check up arrow */
-
- if (y_offset < 0.0)
- gnome_canvas_item_show (mv->up[day_index]);
- else
- gnome_canvas_item_hide (mv->up[day_index]);
-
- if (y_offset > (clip_height - text_height))
- gnome_canvas_item_show (mv->down[day_index]);
- else
- gnome_canvas_item_hide (mv->down[day_index]);
-}
-
-/* Finds which arrow was clicked and scrolls the corresponding text item in the month view */
-static void
-do_arrow_click (MonthView *mv, GnomeCanvasItem *arrow)
-{
- int arrow_index;
- int day_index;
- int up;
- GtkArg args[4];
- double text_height, clip_height;
- double y_offset;
- GdkFont *font;
-
- arrow_index = get_arrow_index (mv, arrow);
- up = (arrow_index < 42);
- day_index = up ? arrow_index : (arrow_index - 42);
-
- /* See how much we can scroll */
-
- args[0].name = "text_height";
- args[1].name = "clip_height";
- args[2].name = "y_offset";
- args[3].name = "font_gdk";
- gtk_object_getv (GTK_OBJECT (mv->text[day_index]), 4, args);
-
- text_height = GTK_VALUE_DOUBLE (args[0]);
- clip_height = GTK_VALUE_DOUBLE (args[1]);
- y_offset = GTK_VALUE_DOUBLE (args[2]);
- font = GTK_VALUE_BOXED (args[3]);
-
- if (up)
- y_offset += font->ascent + font->descent;
- else
- y_offset -= font->ascent + font->descent;
-
- if (y_offset > 0.0)
- y_offset = 0.0;
- else if (y_offset < (clip_height - text_height))
- y_offset = clip_height - text_height;
-
- /* Scroll */
-
- gnome_canvas_item_set (mv->text[day_index],
- "y_offset", y_offset,
- NULL);
-
- check_arrow_visibility (mv, day_index);
-}
-
-/* Event handler for the scroll arrows in the month view */
-static gint
-arrow_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- MonthView *mv;
-
- mv = MONTH_VIEW (data);
-
- switch (event->type) {
- case GDK_ENTER_NOTIFY:
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_PRELIGHT_DAY_BG),
- NULL);
- return TRUE;
-
- case GDK_LEAVE_NOTIFY:
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
- NULL);
- return TRUE;
-
- case GDK_BUTTON_PRESS:
- if (event->button.button != 1)
- break;
-
- do_arrow_click (mv, item);
- return TRUE;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-/* Creates a new arrow out of the specified points and connects the proper signals to it */
-static GnomeCanvasItem *
-new_arrow (MonthView *mv, GnomeCanvasGroup *group, GnomeCanvasPoints *points)
-{
- GnomeCanvasItem *item;
- char *color_spec;
-
- color_spec = color_spec_from_prop (COLOR_PROP_DAY_FG);
-
- item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
- gnome_canvas_polygon_get_type (),
- "points", points,
- "fill_color", color_spec,
- "outline_color", color_spec,
- NULL);
-
- gtk_signal_connect (GTK_OBJECT (item), "event",
- (GtkSignalFunc) arrow_event,
- mv);
-
- return item;
-}
-
-static void
-month_view_init (MonthView *mv)
-{
- int i;
- GnomeCanvasItem *day_group;
- GnomeCanvasPoints *points;
-
- /* Title */
-
- mv->title = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (mv)),
- gnome_canvas_text_get_type (),
- "anchor", GTK_ANCHOR_N,
- "fontset", HEADING_FONTSET,
- "fill_color", "black",
- NULL);
-
- /* Month item */
-
- mv->mitem = gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (mv)));
- gnome_canvas_item_set (mv->mitem,
- "x", 0.0,
- "anchor", GTK_ANCHOR_NW,
- "day_anchor", GTK_ANCHOR_NE,
- "start_on_monday", week_starts_on_monday,
- "heading_padding", 2.0,
- "heading_fontset", BIG_DAY_HEADING_FONTSET,
- "day_fontset", BIG_NORMAL_DAY_FONTSET,
- NULL);
-
- /* Arrows and text items. The arrows start hidden by default; they will be shown as
- * appropriate by the item adjustment code. Also, connect to the event signal of the
- * day groups so that we can pop up the quick view when appropriate.
- */
-
- points = gnome_canvas_points_new (3);
-
- for (i = 0; i < 42; i++) {
- day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem),
- i + GNOME_MONTH_ITEM_DAY_GROUP);
- gtk_signal_connect (GTK_OBJECT (day_group), "event",
- (GtkSignalFunc) day_event,
- mv);
-
- /* Up arrow */
-
- points->coords[0] = 3;
- points->coords[1] = 10;
- points->coords[2] = 11;
- points->coords[3] = 10;
- points->coords[4] = 7;
- points->coords[5] = 3;
-
- mv->up[i] = new_arrow (mv, GNOME_CANVAS_GROUP (day_group), points);
-
- /* Down arrow */
-
- points->coords[0] = 13;
- points->coords[1] = 3;
- points->coords[2] = 17;
- points->coords[3] = 10;
- points->coords[4] = 21;
- points->coords[5] = 3;
-
- mv->down[i] = new_arrow (mv, GNOME_CANVAS_GROUP (day_group), points);
-
- /* Text item */
-
- mv->text[i] = gnome_canvas_item_new (GNOME_CANVAS_GROUP (day_group),
- gnome_canvas_text_get_type (),
- "fontset", EVENT_FONTSET,
- "anchor", GTK_ANCHOR_NW,
- "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
- "clip", TRUE,
- NULL);
- }
- gnome_canvas_points_free (points);
-
- mv->old_current_index = -1;
-}
-
-GtkWidget *
-month_view_new (GnomeCalendar *calendar, time_t month)
-{
- MonthView *mv;
-
- g_return_val_if_fail (calendar != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CALENDAR (calendar), NULL);
-
- mv = gtk_type_new (month_view_get_type ());
- mv->calendar = calendar;
-
- month_view_colors_changed (mv);
- month_view_set (mv, month);
- return GTK_WIDGET (mv);
-}
-
-static void
-month_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (IS_MONTH_VIEW (widget));
- g_return_if_fail (requisition != NULL);
-
- if (GTK_WIDGET_CLASS (parent_class)->size_request)
- (* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition);
-
- requisition->width = 200;
- requisition->height = 150;
-}
-
-/* Adjusts the text items for events in the month view to the appropriate size. It also makes the
- * corresponding arrows visible or invisible, as appropriate.
- */
-static void
-adjust_children (MonthView *mv)
-{
- int i;
- GnomeCanvasItem *item;
- double x1, y1, x2, y2;
- GtkArg arg;
-
- for (i = 0; i < 42; i++) {
- /* Get dimensions of the day group */
-
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem), i + GNOME_MONTH_ITEM_DAY_GROUP);
- gnome_canvas_item_get_bounds (item, &x1, &y1, &x2, &y2);
-
- /* Normalize and add paddings */
-
- x2 -= x1 + EVENT_PADDING;
- x1 = EVENT_PADDING;
- y2 -= y1 + EVENT_PADDING;
- y1 = EVENT_PADDING;
-
- /* Add height of day label to y1 */
-
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem), i + GNOME_MONTH_ITEM_DAY_LABEL);
-
- arg.name = "text_height";
- gtk_object_getv (GTK_OBJECT (item), 1, &arg);
- y1 += GTK_VALUE_DOUBLE (arg);
-
- /* Set the position and clip size */
-
- gnome_canvas_item_set (mv->text[i],
- "x", x1,
- "y", y1,
- "clip_width", x2 - x1,
- "clip_height", y2 - y1,
- "x_offset", 0.0,
- "y_offset", 0.0,
- NULL);
-
- /* See what visibility state the arrows should be set to */
-
- check_arrow_visibility (mv, i);
- }
-}
-
-static void
-month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- MonthView *mv;
- GdkFont *font;
- GtkArg arg;
- int y;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (IS_MONTH_VIEW (widget));
- g_return_if_fail (allocation != NULL);
-
- mv = MONTH_VIEW (widget);
-
- if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
- (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (mv), 0, 0, allocation->width, allocation->height);
-
- /* Adjust items to new size */
-
- arg.name = "font_gdk";
- gtk_object_getv (GTK_OBJECT (mv->title), 1, &arg);
- font = GTK_VALUE_BOXED (arg);
-
- gnome_canvas_item_set (mv->title,
- "x", (double) allocation->width / 2.0,
- "y", (double) SPACING,
- NULL);
-
- y = font->ascent + font->descent + 2 * SPACING;
- gnome_canvas_item_set (mv->mitem,
- "y", (double) y,
- "width", (double) (allocation->width - 1),
- "height", (double) (allocation->height - y - 1),
- NULL);
-
- /* Adjust children */
-
- adjust_children (mv);
-}
-
-/* This defines the environment for the calendar iterator function that is used to populate the
- * month view with events.
- */
-struct iter_info {
- MonthView *mv; /* The month view we are creating children for */
- int first_day_index; /* Index of the first day of the month within the month item */
- time_t month_begin, month_end; /* Beginning and end of month */
- GString **strings; /* Array of strings to populate */
-};
-
-/* This is the calendar iterator function used to populate the string array with event information.
- * For each event, it iterates through all the days that the event touches and appends the proper
- * information to the string array in the iter_info structure.
- */
-static int
-add_event (iCalObject *ico, time_t start, time_t end, void *data)
-{
- struct iter_info *ii;
- struct tm tm;
- time_t t;
- time_t day_begin_time, day_end_time;
-
- ii = data;
-
- /* Get the first day of the event */
-
- t = MAX (start, ii->month_begin);
- day_begin_time = time_day_begin (t);
- day_end_time = time_day_end (day_begin_time);
-
- /* Loop until the event ends or the month ends. For each day touched, append the proper
- * information to the corresponding string.
- */
-
- do {
- tm = *localtime (&day_begin_time);
- g_string_sprintfa (ii->strings[ii->first_day_index + tm.tm_mday - 1], "%s\n", ico->summary);
-
- /* Next day */
-
- day_begin_time = time_add_day (day_begin_time, 1);
- day_end_time = time_day_end (day_begin_time);
- } while ((end > day_begin_time) && (day_begin_time < ii->month_end));
-
- return TRUE; /* this means we are not finished yet with event generation */
-}
-
-void
-month_view_update (MonthView *mv, iCalObject *object, int flags)
-{
- struct iter_info ii;
- GString *strings[42];
- int i;
- time_t t;
-
- g_return_if_fail (mv != NULL);
- g_return_if_fail (IS_MONTH_VIEW (mv));
-
- ii.mv = mv;
-
- /* Create an array of empty GStrings */
-
- ii.strings = strings;
-
- for (i = 0; i < 42; i++)
- strings[i] = g_string_new (NULL);
-
- ii.first_day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (mv->mitem), 1);
- g_assert (ii.first_day_index != -1);
-
- /* Populate the array of strings with events */
-
- t = time_from_day (mv->year, mv->month, 1);
- ii.month_begin = time_month_begin (t);
- ii.month_end = time_month_end (t);
-
- calendar_iterate (mv->calendar->cal, ii.month_begin, ii.month_end, add_event, &ii);
-
- for (i = 0; i < 42; i++) {
- /* Delete the last character if it is a newline */
-
- if (strings[i]->str && strings[i]->len && (strings[i]->str[strings[i]->len - 1] == '\n'))
- g_string_truncate (strings[i], strings[i]->len - 1);
-
- gnome_canvas_item_set (mv->text[i],
- "text", strings[i]->str,
- NULL);
- g_string_free (strings[i], TRUE);
- }
-
- /* Adjust children for scrolling */
-
- adjust_children (mv);
-}
-
-/* Unmarks the old day that was marked as current and marks the current day if appropriate */
-static void
-mark_current_day (MonthView *mv)
-{
- time_t t;
- struct tm tm;
- GnomeCanvasItem *item;
-
- /* Unmark the old day */
-
- if (mv->old_current_index != -1) {
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem),
- GNOME_MONTH_ITEM_DAY_LABEL + mv->old_current_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
- "fontset", BIG_NORMAL_DAY_FONTSET,
- NULL);
-
- mv->old_current_index = -1;
- }
-
- /* Mark the new day */
-
- t = time (NULL);
- tm = *localtime (&t);
-
- if (((tm.tm_year + 1900) == mv->year) && (tm.tm_mon == mv->month)) {
- mv->old_current_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (mv->mitem), tm.tm_mday);
- g_assert (mv->old_current_index != -1);
-
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem),
- GNOME_MONTH_ITEM_DAY_LABEL + mv->old_current_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
- "fontset", BIG_CURRENT_DAY_FONTSET,
- NULL);
- }
-}
-
-void
-month_view_set (MonthView *mv, time_t month)
-{
- struct tm tm;
- char buf[100];
-
- g_return_if_fail (mv != NULL);
- g_return_if_fail (IS_MONTH_VIEW (mv));
-
- /* Title */
-
- tm = *localtime (&month);
-
- mv->year = tm.tm_year + 1900;
- mv->month = tm.tm_mon;
-
- strftime (buf, 100, _("%B %Y"), &tm);
-
- gnome_canvas_item_set (mv->title,
- "text", buf,
- NULL);
-
- /* Month item */
-
- gnome_canvas_item_set (mv->mitem,
- "year", mv->year,
- "month", mv->month,
- NULL);
-
- /* Update events */
-
- month_view_update (mv, NULL, 0);
- mark_current_day (mv);
-}
-
-void
-month_view_time_format_changed (MonthView *mv)
-{
- g_return_if_fail (mv != NULL);
- g_return_if_fail (IS_MONTH_VIEW (mv));
-
- gnome_canvas_item_set (mv->mitem,
- "start_on_monday", week_starts_on_monday,
- NULL);
-
- month_view_set (mv, time_month_begin (time_from_day (mv->year, mv->month, 1)));
-}
-
-void
-month_view_colors_changed (MonthView *mv)
-{
- g_return_if_fail (mv != NULL);
- g_return_if_fail (IS_MONTH_VIEW (mv));
-
- colorify_month_item (GNOME_MONTH_ITEM (mv->mitem), default_color_func, NULL);
- mark_current_day (mv);
-
- /* FIXME: set children to the marked color */
-}
diff --git a/calendar/month-view.h b/calendar/month-view.h
deleted file mode 100644
index 6e49c2f931..0000000000
--- a/calendar/month-view.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Month view display for gncal
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef MONTH_VIEW_H
-#define MONTH_VIEW_H
-
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-#include "gnome-month-item.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define TYPE_MONTH_VIEW (month_view_get_type ())
-#define MONTH_VIEW(obj) (GTK_CHECK_CAST ((obj), TYPE_MONTH_VIEW, MonthView))
-#define MONTH_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_MONTH_VIEW, MonthViewClass))
-#define IS_MONTH_VIEW(obj) (GTK_CHECK_TYPE ((obj), TYPE_MONTH_VIEW))
-#define IS_MONTH_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_MONTH_VIEW))
-
-
-typedef struct _MonthView MonthView;
-typedef struct _MonthViewClass MonthViewClass;
-
-struct _MonthView {
- GnomeCanvas canvas;
-
- GnomeCalendar *calendar; /* The calendar we are associated to */
-
- int year; /* The year of the month we are displaying */
- int month; /* The month we are displaying */
- int old_current_index; /* The index of the day marked as current, or -1 if none */
-
- GnomeCanvasItem *up[42]; /* Arrows to go up in the days */
- GnomeCanvasItem *down[42]; /* Arrows to go down in the days */
- GnomeCanvasItem *text[42]; /* Text items for the events */
-
- GnomeCanvasItem *title; /* The title heading with the month/year */
- GnomeCanvasItem *mitem; /* The canvas month item used by this month view */
-};
-
-struct _MonthViewClass {
- GnomeCanvasClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType month_view_get_type (void);
-
-/* Creates a new month view widget associated to the specified calendar */
-GtkWidget *month_view_new (GnomeCalendar *calendar, time_t month);
-
-/* Notifies the month view that a calendar object has changed */
-void month_view_update (MonthView *mv, iCalObject *ico, int flags);
-
-/* Notifies the month view about a change of date */
-void month_view_set (MonthView *mv, time_t month);
-
-/* Notifies the month view that the time format has changed */
-void month_view_time_format_changed (MonthView *mv);
-
-/* Notifies the month view that the colors have changed */
-void month_view_colors_changed (MonthView *mv);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c
deleted file mode 100644
index 72315e3882..0000000000
--- a/calendar/pcs/cal-backend.c
+++ /dev/null
@@ -1,498 +0,0 @@
-/* Evolution calendar backend
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include "cal-backend.h"
-#include "calobj.h"
-#include "../libversit/vcc.h"
-
-
-
-/* VCalendar product ID */
-#define PRODID "-//Helix Code//NONSGML Tlacuache//EN"
-
-
-
-/* Private part of the CalBackend structure */
-typedef struct {
- /* URI where the calendar data is stored */
- GnomeVFSURI *uri;
-
- /* List of Cal client interface objects, each with its listener */
- GList *clients;
-
- /* All the iCalObject structures in the calendar, hashed by UID. The
- * hash key *is* icalobj->uid; it is not copied, so don't free it when
- * you remove an object from the hash table.
- */
- GHashTable *object_hash;
-
- /* All events, TODOs, and journals in the calendar */
- GList *events;
- GList *todos;
- GList *journals;
-
- /* Whether a calendar has been loaded */
- guint loaded : 1;
-} CalBackendPrivate;
-
-
-
-static void cal_backend_class_init (CalBackendClass *class);
-static void cal_backend_init (CalBackend *backend);
-static void cal_backend_destroy (GtkObject *object);
-
-static GtkObjectClass *parent_class;
-
-
-
-/**
- * cal_backend_get_type:
- * @void:
- *
- * Registers the #CalBackend class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the #CalBackend class.
- **/
-GtkType
-cal_backend_get_type (void)
-{
- static GtkType cal_backend_type = 0;
-
- if (!cal_backend_type) {
- static const GtkTypeInfo cal_backend_info = {
- "CalBackend",
- sizeof (CalBackend),
- sizeof (CalBackendClass),
- (GtkClassInitFunc) cal_backend_class_init,
- (GtkObjectInitFunc) cal_backend_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- cal_backend_type = gtk_type_unique (GTK_TYPE_OBJECT, &cal_backend_info);
- }
-
- return cal_backend_type;
-}
-
-/* Class initialization function for the calendar backend */
-static void
-cal_backend_class_init (CalBackendClass *class)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) class;
-
- parent_class = gtk_type_class (GTK_TYPE_OBJECT);
-
- object_class->destroy = cal_backend_destroy;
-}
-
-/* Object initialization function for the calendar backend */
-static void
-cal_backend_init (CalBackend *backend)
-{
- CalBackendPrivate *priv;
-
- priv = g_new0 (CalBackendPrivate, 1);
- backend->priv = priv;
-}
-
-/* Destroy handler for the calendar backend */
-static void
-cal_backend_destroy (GtkObject *object)
-{
- CalBackend *backend;
- CalBackendPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL_BACKEND (object));
-
- backend = CAL_BACKEND (object);
- priv = backend->priv;
-
- /* FIXME: free stuff */
-
- g_free (priv);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-
-
-/* iCalObject manipulation functions */
-
-/* Ensures that an iCalObject has a unique identifier. If it doesn't have one,
- * it will create one for it. Returns whether an UID was created or not.
- */
-static gboolean
-ensure_uid (iCalObject *ico)
-{
- char *buf;
- gulong str_time;
- static guint seqno = 0;
-
- if (ico->uid)
- return FALSE;
-
- str_time = (gulong) time (NULL);
-
- /* Is this good enough? */
-
- buf = g_strdup_printf ("Evolution-Tlacuache-%d-%ld-%u", (int) getpid(), str_time, seqno++);
- ico->uid = buf;
-
- return TRUE;
-}
-
-/* Adds an object to the calendar backend. Does *not* perform notification to
- * calendar clients.
- */
-static void
-add_object (CalBackend *backend, iCalObject *ico)
-{
- CalBackendPrivate *priv;
-
- g_assert (ico != NULL);
- priv = backend->priv;
-
-#if 0
- /* FIXME: gnomecal old code */
- ico->new = 0;
-#endif
-
- if (ensure_uid (ico))
- /* FIXME: mark the calendar as dirty so that we can re-save it
- * with the object's new UID.
- */
- ;
-
- g_hash_table_insert (priv->object_hash, ico->uid, ico);
-
- switch (ico->type) {
- case ICAL_EVENT:
- priv->events = g_list_prepend (priv->events, ico);
-#if 0
- /* FIXME: gnomecal old code */
- ical_object_try_alarms (ico);
-# ifdef DEBUGGING_MAIL_ALARM
- ico->malarm.trigger = 0;
- calendar_notify (0, ico);
-# endif
-#endif
- break;
-
- case ICAL_TODO:
- priv->todos = g_list_prepend (priv->todos, ico);
- break;
-
- case ICAL_JOURNAL:
- priv->journals = g_list_prepend (priv->journals, ico);
- break;
-
- default:
- g_assert_not_reached ();
- }
-
-#if 0
- /* FIXME: gnomecal old code */
- ico->last_mod = time (NULL);
-#endif
-}
-
-/* Load a calendar from a VObject */
-static void
-load_from_vobject (CalBackend *backend, VObject *vobject)
-{
- CalBackendPrivate *priv;
- VObjectIterator i;
-
- priv = backend->priv;
-
- g_assert (!priv->loaded);
- g_assert (priv->object_hash == NULL);
- priv->object_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
- initPropIterator (&i, vobject);
-
- while (moreIteration (&i)) {
- VObject *this;
- iCalObject *ical;
- const char *object_name;
-
- this = nextVObject (&i);
- object_name = vObjectName (this);
-#if 0
- /* FIXME? What is this used for in gnomecal? */
- if (strcmp (object_name, VCDCreatedProp) == 0) {
- cal->created = time_from_isodate (str_val (this));
- continue;
- }
-#endif
- if (strcmp (object_name, VCLocationProp) == 0)
- continue; /* FIXME: imlement */
-
- if (strcmp (object_name, VCProdIdProp) == 0)
- continue; /* FIXME: implement */
-
- if (strcmp (object_name, VCVersionProp) == 0)
- continue; /* FIXME: implement */
-
- if (strcmp (object_name, VCTimeZoneProp) == 0)
- continue; /* FIXME: implement */
-
- ical = ical_object_create_from_vobject (this, object_name);
-
- if (ical)
- add_object (backend, ical);
- }
-}
-
-/* Creates a VObject with the base information of a calendar */
-static VObject *
-get_calendar_base_vobject (CalBackend *backend)
-{
- VObject *vobj;
- time_t now;
- struct tm tm;
-
- /* We call localtime for the side effect of setting tzname */
-
- now = time (NULL);
- tm = *localtime (&now);
-
- vobj = newVObject (VCCalProp);
-
- addPropValue (vobj, VCProdIdProp, PRODID);
-
-#if defined (HAVE_TM_ZONE)
- addPropValue (vobj, VCTimeZoneProp, tm.tm_zone);
-#elif defined (HAVE_TZNAME)
- addPropValue (vobj, VCTimeZoneProp, tzname[0]);
-#endif
-
- /* Per the vCalendar spec, this must be "1.0" */
- addPropValue (vobj, VCVersionProp, "1.0");
-
- return vobj;
-}
-
-
-
-/**
- * cal_backend_new:
- * @void:
- *
- * Creates a new empty calendar backend. A calendar must then be loaded or
- * created before the backend can be used.
- *
- * Return value: A newly-created calendar backend.
- **/
-CalBackend *
-cal_backend_new (void)
-{
- return CAL_BACKEND (gtk_type_new (CAL_BACKEND_TYPE));
-}
-
-/**
- * cal_backend_get_uri:
- * @backend: A calendar backend.
- *
- * Queries the URI of a calendar backend, which must already have a loaded
- * calendar.
- *
- * Return value: The URI where the calendar is stored.
- **/
-GnomeVFSURI *
-cal_backend_get_uri (CalBackend *backend)
-{
- CalBackendPrivate *priv;
-
- g_return_val_if_fail (backend != NULL, NULL);
- g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
-
- priv = backend->priv;
- g_return_val_if_fail (priv->loaded, NULL);
- g_assert (priv->uri != NULL);
-
- return priv->uri;
-}
-
-/**
- * cal_backend_add_cal:
- * @backend: A calendar backend.
- * @cal: A calendar client interface object.
- *
- * Adds a calendar client interface object to a calendar @backend. The calendar
- * backend must already have a loaded calendar.
- **/
-void
-cal_backend_add_cal (CalBackend *backend, Cal *cal)
-{
- CalBackendPrivate *priv;
-
- g_return_if_fail (backend != NULL);
- g_return_if_fail (IS_CAL_BACKEND (backend));
-
- priv = backend->priv;
- g_return_if_fail (priv->loaded);
-
- g_return_if_fail (cal != NULL);
- g_return_if_fail (IS_CAL (cal));
-
- gtk_object_ref (GTK_OBJECT (cal));
- priv->clients = g_list_prepend (priv->clients, cal);
-}
-
-/**
- * cal_backend_remove_cal:
- * @backend: A calendar backend.
- * @cal: A calendar client interface object.
- *
- * Removes a calendar client interface object from a calendar backend. The
- * calendar backend must already have a loaded calendar.
- **/
-void
-cal_backend_remove_cal (CalBackend *backend, Cal *cal)
-{
- CalBackendPrivate *priv;
- GList *l;
-
- g_return_if_fail (backend != NULL);
- g_return_if_fail (IS_CAL_BACKEND (backend));
-
- priv = backend->priv;
- g_return_if_fail (priv->loaded);
-
- g_return_if_fail (cal != NULL);
- g_return_if_fail (IS_CAL (cal));
-
- l = g_list_find (priv->clients, cal);
- if (!l)
- return;
-
- gtk_object_unref (GTK_OBJECT (cal));
- priv->clients = g_list_remove_link (priv->clients, l);
- g_list_free_1 (l);
-}
-
-/**
- * cal_backend_load:
- * @backend: A calendar backend.
- * @uri: URI that contains the calendar data.
- *
- * Loads a calendar backend with data from a calendar stored at the specified
- * URI.
- *
- * Return value: An operation status code.
- **/
-CalBackendLoadStatus
-cal_backend_load (CalBackend *backend, GnomeVFSURI *uri)
-{
- CalBackendPrivate *priv;
- VObject *vobject;
- char *str_uri;
-
- g_return_val_if_fail (backend != NULL, CAL_BACKEND_LOAD_ERROR);
- g_return_val_if_fail (IS_CAL_BACKEND (backend), CAL_BACKEND_LOAD_ERROR);
- g_return_val_if_fail (uri != NULL, CAL_BACKEND_LOAD_ERROR);
-
- priv = backend->priv;
- g_return_val_if_fail (!priv->loaded, CAL_BACKEND_LOAD_ERROR);
-
- /* FIXME: this looks rather bad; maybe we should check for local files
- * and fail if they are remote.
- */
-
- str_uri = gnome_vfs_uri_to_string (uri,
- (GNOME_VFS_URI_HIDE_USER_NAME
- | GNOME_VFS_URI_HIDE_PASSWORD
- | GNOME_VFS_URI_HIDE_HOST_NAME
- | GNOME_VFS_URI_HIDE_HOST_PORT
- | GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD));
-
- vobject = Parse_MIME_FromFileName (str_uri);
- g_free (str_uri);
-
- if (!vobject)
- return CAL_BACKEND_LOAD_ERROR;
-
- load_from_vobject (backend, vobject);
- cleanVObject (vobject);
- cleanStrTbl ();
-
- gnome_vfs_uri_ref (uri);
-
- priv->uri = uri;
- priv->loaded = TRUE;
- return CAL_BACKEND_LOAD_SUCCESS;
-}
-
-/**
- * cal_backend_get_object:
- * @backend: A calendar backend.
- * @uid: Unique identifier for a calendar object.
- *
- * Queries a calendar backend for a calendar object based on its unique
- * identifier.
- *
- * Return value: The string representation of a complete calendar wrapping the
- * the sought object, or NULL if no object had the specified UID. A complete
- * calendar is returned because you also need the timezone data.
- **/
-char *
-cal_backend_get_object (CalBackend *backend, const char *uid)
-{
- CalBackendPrivate *priv;
- iCalObject *ico;
- VObject *vcalobj, *vobj;
- char *buf;
-
- g_return_val_if_fail (backend != NULL, NULL);
- g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
-
- priv = backend->priv;
- g_return_val_if_fail (priv->loaded, NULL);
-
- g_return_val_if_fail (uid != NULL, NULL);
-
- g_assert (priv->object_hash != NULL);
-
- ico = g_hash_table_lookup (priv->objec_hash, uid);
-
- if (!ico)
- return NULL;
-
- vcalobj = get_calendar_base_vobject (backend);
- vobj = ical_object_to_vobject (ico);
- addVObjectProp (vcalobj, vobj);
-
- buf = writeMemVObject (NULL, NULL, vcalobj);
-
- cleanVObject (vcalobj);
- cleanStrTbl ();
-
- return buf;
-}
diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h
deleted file mode 100644
index e972cbd59e..0000000000
--- a/calendar/pcs/cal-backend.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Evolution calendar backend
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CAL_BACKEND_H
-#define CAL_BACKEND_H
-
-#include <libgnome/gnome-defs.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include "evolution-calendar.h"
-#include "cal-common.h"
-#include "cal.h"
-
-BEGIN_GNOME_DECLS
-
-
-
-#define CAL_BACKEND_TYPE (cal_backend_get_type ())
-#define CAL_BACKEND(obj) (GTK_CHECK_CAST ((obj), CAL_BACKEND_TYPE, CalBackend))
-#define CAL_BACKEND_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_BACKEND_TYPE, \
- CalBackendClass))
-#define IS_CAL_BACKEND(obj) (GTK_CHECK_TYPE ((obj), CAL_BACKEND_TYPE))
-#define IS_CAL_BACKEND_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_TYPE))
-
-typedef enum {
- CAL_BACKEND_LOAD_SUCCESS, /* Loading OK */
- CAL_BACKEND_LOAD_ERROR /* We need better error reporting in libversit */
-} CalBackendLoadStatus;
-
-struct _CalBackend {
- GtkObject object;
-
- /* Private data */
- gpointer priv;
-};
-
-struct _CalBackendClass {
- GtkObjectClass parent_class;
-};
-
-GtkType cal_backend_get_type (void);
-
-CalBackend *cal_backend_new (void);
-
-GnomeVFSURI *cal_backend_get_uri (CalBackend *backend);
-
-void cal_backend_add_cal (CalBackend *backend, Cal *cal);
-void cal_backend_remove_cal (CalBackend *backend, Cal *cal);
-
-CalBackendLoadStatus cal_backend_load (CalBackend *backend, GnomeVFSURI *uri);
-
-char *cal_backend_get_object (CalBackend *backend, const char *uid);
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/pcs/cal-common.h b/calendar/pcs/cal-common.h
deleted file mode 100644
index e51ddf1bdd..0000000000
--- a/calendar/pcs/cal-common.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Evolution calendar server - common declarations
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CAL_COMMON_H
-#define CAL_COMMON_H
-
-#include <libgnome/gnome-defs.h>
-
-BEGIN_GNOME_DECLS
-
-
-
-typedef struct _CalBackend CalBackend;
-typedef struct _CalBackendClass CalBackendClass;
-
-typedef struct _Cal Cal;
-typedef struct _CalClass CalClass;
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c
deleted file mode 100644
index d5b79ef423..0000000000
--- a/calendar/pcs/cal-factory.c
+++ /dev/null
@@ -1,517 +0,0 @@
-/* Evolution calendar factory
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include "cal.h"
-#include "cal-backend.h"
-#include "cal-factory.h"
-#include "job.h"
-
-
-
-/* Private part of the CalFactory structure */
-typedef struct {
- /* Hash table from GnomeVFSURI structures to CalBackend objects */
- GHashTable *backends;
-} CalFactoryPrivate;
-
-
-
-static void cal_factory_class_init (CalFactoryClass *class);
-static void cal_factory_init (CalFactory *factory);
-static void cal_factory_destroy (GtkObject *object);
-
-static POA_Evolution_Calendar_CalFactory__vepv cal_factory_vepv;
-
-static BonoboObjectClass *parent_class;
-
-
-
-/**
- * cal_factory_get_type:
- * @void:
- *
- * Registers the #CalFactory class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the #CalFactory class.
- **/
-GtkType
-cal_factory_get_type (void)
-{
- static GtkType cal_factory_type = 0;
-
- if (!cal_factory_type) {
- static const GtkTypeInfo cal_factory_info = {
- "CalFactory",
- sizeof (CalFactory),
- sizeof (CalFactoryClass),
- (GtkClassInitFunc) cal_factory_class_init,
- (GtkObjectInitFunc) cal_factory_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- cal_factory_type = gtk_type_unique (bonobo_object_get_type (), &cal_factory_info);
- }
-
- return cal_factory_type;
-}
-
-/* CORBA class initialization function for the calendar factory */
-static void
-init_cal_factory_corba_class (void)
-{
- cal_factory_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
- cal_factory_vepv.Evolution_Calendar_CalFactory_epv = cal_factory_get_epv ();
-}
-
-/* Class initialization function for the calendar factory */
-static void
-cal_factory_class_init (CalFactoryClass *class)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) class;
-
- parent_class = gtk_type_class (bonobo_object_get_type ());
-
- object_class->destroy = cal_factory_destroy;
-
- init_cal_factory_corba_class ();
-}
-
-/* Object initialization function for the calendar factory */
-static void
-cal_factory_init (CalFactory *factory)
-{
- CalFactoryPrivate *priv;
-
- priv = g_new0 (CalFactoryPrivate, 1);
- factory->priv = priv;
-
- priv->backends = g_hash_table_new (gnome_vfs_uri_hash, gnome_vfs_uri_hequal);
-}
-
-/* Frees a uri/backend pair from the backends hash table */
-static void
-free_backend (gpointer key, gpointer value, gpointer data)
-{
- GnomeVFSURI *uri;
- CalBackend *backend;
-
- uri = key;
- backend = value;
-
- gnome_vfs_uri_unref (uri);
- gtk_object_unref (GTK_OBJECT (backend));
-}
-
-/* Destroy handler for the calendar */
-static void
-cal_factory_destroy (GtkObject *object)
-{
- CalFactory *factory;
- CalFactoryPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL_FACTORY (object));
-
- factory = CAL_FACTORY (object);
- priv = factory->priv;
-
- g_hash_table_foreach (priv->backends, free_backend, NULL);
- g_hash_table_destroy (priv->backends);
- priv->backends = NULL;
-
- g_free (priv);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-
-
-/* CORBA servant implementation */
-
-/* CalFactory::load method */
-static void
-CalFactory_load (PortableServer_Servant servant,
- const CORBA_char *uri,
- Evolution_Calendar_Listener listener,
- CORBA_Environment *ev)
-{
- CalFactory *factory;
- CalFactoryPrivate *priv;
- CORBA_Environment ev2;
- gboolean result;
-
- factory = CAL_FACTORY (bonobo_object_from_servant (servant));
- priv = factory->priv;
-
- CORBA_exception_init (&ev2);
- result = CORBA_Object_is_nil (listener, &ev2);
-
- if (ev2._major != CORBA_NO_EXCEPTION || result) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_Evolution_Calendar_CalFactory_NilListener,
- NULL);
-
- CORBA_exception_free (&ev2);
- return;
- }
- CORBA_exception_free (&ev2);
-
- cal_factory_load (factory, uri, listener);
-}
-
-/* CalFactory::create method */
-static void
-CalFactory_create (PortableServer_Servant servant,
- const CORBA_char *uri,
- Evolution_Calendar_Listener listener,
- CORBA_Environment *ev)
-{
- CalFactory *factory;
- CalFactoryPrivate *priv;
-
- factory = CAL_FACTORY (bonobo_object_from_servant (servant));
- priv = factory->priv;
-
- cal_factory_create (factory, uri, listener);
-}
-
-/**
- * cal_factory_get_epv:
- * @void:
- *
- * Creates an EPV for the CalFactory CORBA class.
- *
- * Return value: A newly-allocated EPV.
- **/
-POA_Evolution_Calendar_CalFactory__epv *
-cal_factory_get_epv (void)
-{
- POA_Evolution_Calendar_CalFactory__epv *epv;
-
- epv = g_new0 (POA_Evolution_Calendar_CalFactory__epv, 1);
- epv->load = CalFactory_load;
- epv->create = CalFactory_create;
-
- return epv;
-}
-
-
-
-/* Loading and creating calendars */
-
-/* Job data */
-typedef struct {
- CalFactory *factory;
- char *uri;
- Evolution_Calendar_Listener listener;
-} LoadCreateJobData;
-
-/* Looks up a calendar backend in a factory's hash table of uri->cal */
-static CalBackend *
-lookup_backend (CalFactory *factory, GnomeVFSURI *uri)
-{
- CalFactoryPrivate *priv;
- CalBackend *backend;
-
- priv = factory->priv;
-
- backend = g_hash_table_lookup (priv->backends, uri);
- return backend;
-}
-
-/* Loads a calendar backend and puts it in the factory's backend hash table */
-static CalBackend *
-load_backend (CalFactory *factory, GnomeVFSURI *uri, Evolution_Calendar_Listener listener)
-{
- CalFactoryPrivate *priv;
- CalBackend *backend;
- CalBackendLoadStatus status;
-
- priv = factory->priv;
-
- backend = cal_backend_new ();
- if (!backend) {
- g_message ("load_backend(): could not create the backend");
- return NULL;
- }
-
- status = cal_backend_load (backend, uri);
-
- switch (status) {
- case CAL_BACKEND_LOAD_SUCCESS:
- gnome_vfs_uri_ref (uri);
- g_hash_table_insert (priv->backends, uri, backend);
-
- return backend;
-
- case CAL_BACKEND_LOAD_ERROR:
- gtk_object_unref (GTK_OBJECT (backend));
- return NULL;
-
- default:
- g_assert_not_reached ();
- return NULL;
- }
-}
-
-/* Adds a listener to a calendar backend by creating a calendar client interface
- * object.
- */
-static void
-add_calendar_client (CalFactory *factory, CalBackend *backend, Evolution_Calendar_Listener listener)
-{
- Cal *cal;
- CORBA_Environment ev;
-
- cal = cal_new (backend, listener);
- if (!cal) {
- g_message ("add_calendar_client(): could not create the calendar client interface");
-
- CORBA_exception_init (&ev);
- Evolution_Calendar_Listener_cal_loaded (listener,
- Evolution_Calendar_Listener_ERROR,
- CORBA_OBJECT_NIL,
- &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("add_calendar_client(): could not notify the listener");
-
- CORBA_exception_free (&ev);
- return;
- }
-
- cal_backend_add_cal (backend, cal);
-
- CORBA_exception_init (&ev);
- Evolution_Calendar_Listener_cal_loaded (listener,
- Evolution_Calendar_Listener_SUCCESS,
- bonobo_object_corba_objref (BONOBO_OBJECT (cal)),
- &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("add_calendar_client(): could not notify the listener");
- cal_backend_remove_cal (backend, cal);
- }
-
- gtk_object_unref (GTK_OBJECT (cal));
-}
-
-/* Job handler for the load calendar command */
-static void
-load_fn (gpointer data)
-{
- LoadCreateJobData *jd;
- CalFactory *factory;
- GnomeVFSURI *uri;
- Evolution_Calendar_Listener listener;
- CalBackend *backend;
- CORBA_Environment ev;
-
- jd = data;
-
- /* Look up the calendar */
-
- uri = gnome_vfs_uri_new (jd->uri);
- g_free (jd->uri);
-
- factory = jd->factory;
- listener = jd->listener;
- g_free (jd);
-
- backend = lookup_backend (factory, uri);
-
- if (!backend)
- backend = load_backend (factory, uri, listener);
-
- gnome_vfs_uri_unref (uri);
-
- if (!backend) {
- g_message ("load_fn(): could not load the backend");
- CORBA_exception_init (&ev);
- Evolution_Calendar_Listener_cal_loaded (listener,
- Evolution_Calendar_Listener_ERROR,
- CORBA_OBJECT_NIL,
- &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("load_fn(): could not notify the listener");
-
- CORBA_exception_free (&ev);
- goto out;
- }
-
- add_calendar_client (factory, backend, listener);
-
- out:
-
- CORBA_exception_init (&ev);
- CORBA_Object_release (listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("load_fn(): could not release the listener");
-
- CORBA_exception_free (&ev);
-}
-
-
-
-/**
- * cal_factory_construct:
- * @factory: A calendar factory.
- * @corba_factory: CORBA object for the calendar factory.
- *
- * Constructs a calendar factory by binding the corresponding CORBA object to
- * it.
- *
- * Return value: The same object as the @factory argument.
- **/
-CalFactory *
-cal_factory_construct (CalFactory *factory, Evolution_Calendar_CalFactory corba_factory)
-{
- g_return_val_if_fail (factory != NULL, NULL);
- g_return_val_if_fail (IS_CAL_FACTORY (factory), NULL);
-
- bonobo_object_construct (BONOBO_OBJECT (factory), corba_factory);
- return factory;
-}
-
-/**
- * cal_factory_corba_object_create:
- * @object: #BonoboObject that will wrap the CORBA object.
- *
- * Creates and activates the CORBA object that is wrapped by the specified
- * calendar factory @object.
- *
- * Return value: An activated object reference or #CORBA_OBJECT_NIL in case of
- * failure.
- **/
-Evolution_Calendar_CalFactory
-cal_factory_corba_object_create (BonoboObject *object)
-{
- POA_Evolution_Calendar_CalFactory *servant;
- CORBA_Environment ev;
-
- g_return_val_if_fail (object != NULL, CORBA_OBJECT_NIL);
- g_return_val_if_fail (IS_CAL_FACTORY (object), CORBA_OBJECT_NIL);
-
- servant = (POA_Evolution_Calendar_CalFactory *) g_new0 (BonoboObjectServant, 1);
- servant->vepv = &cal_factory_vepv;
-
- CORBA_exception_init (&ev);
- POA_Evolution_Calendar_CalFactory__init ((PortableServer_Servant) servant, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_factory_corba_object_create(): could not init the servant");
- g_free (servant);
- CORBA_exception_free (&ev);
- return CORBA_OBJECT_NIL;
- }
-
- CORBA_exception_free (&ev);
- return (Evolution_Calendar_CalFactory) bonobo_object_activate_servant (object, servant);
-}
-
-/**
- * cal_factory_new:
- * @void:
- *
- * Creates a new #CalFactory object.
- *
- * Return value: A newly-created #CalFactory, or NULL if its corresponding CORBA
- * object could not be created.
- **/
-CalFactory *
-cal_factory_new (void)
-{
- CalFactory *factory;
- CORBA_Environment ev;
- Evolution_Calendar_CalFactory corba_factory;
- gboolean retval;
-
- factory = gtk_type_new (CAL_FACTORY_TYPE);
-
- corba_factory = cal_factory_corba_object_create (BONOBO_OBJECT (factory));
-
- CORBA_exception_init (&ev);
- retval = CORBA_Object_is_nil (corba_factory, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION || retval) {
- g_message ("cal_factory_new(): could not create the CORBA factory");
- gtk_object_unref (GTK_OBJECT (factory));
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- return cal_factory_construct (factory, corba_factory);
-}
-
-void
-cal_factory_load (CalFactory *factory, const char *uri, Evolution_Calendar_Listener listener)
-{
- LoadCreateJobData *jd;
- CORBA_Environment ev;
- Evolution_Calendar_Listener listener_copy;
- gboolean result;
-
- CORBA_exception_init (&ev);
- result = CORBA_Object_is_nil (listener, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_factory_load(): could not see if the listener was NIL");
- CORBA_exception_free (&ev);
- return;
- }
- CORBA_exception_free (&ev);
-
- if (result) {
- g_message ("cal_factory_load(): cannot operate on a NIL listener!");
- return;
- }
-
- listener_copy = CORBA_Object_duplicate (listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_factory_load(): could not duplicate the listener");
- CORBA_exception_free (&ev);
- return;
- }
-
- CORBA_exception_free (&ev);
-
- jd = g_new (LoadCreateJobData, 1);
- jd->factory = factory;
- jd->uri = g_strdup (uri);
- jd->listener = listener_copy;
-
- job_add (load_fn, jd);
-}
-
-void
-cal_factory_create (CalFactory *factory, const char *uri, Evolution_Calendar_Listener listener)
-{
- /* FIXME */
-}
diff --git a/calendar/pcs/cal-factory.h b/calendar/pcs/cal-factory.h
deleted file mode 100644
index 9d5fd57e2c..0000000000
--- a/calendar/pcs/cal-factory.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Evolution calendar factory
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CAL_FACTORY_H
-#define CAL_FACTORY_H
-
-#include <libgnome/gnome-defs.h>
-#include <bonobo/bonobo-object.h>
-#include "evolution-calendar.h"
-
-BEGIN_GNOME_DECLS
-
-
-
-#define CAL_FACTORY_TYPE (cal_factory_get_type ())
-#define CAL_FACTORY(obj) (GTK_CHECK_CAST ((obj), CAL_FACTORY_TYPE, CalFactory))
-#define CAL_FACTORY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_FACTORY_TYPE, \
- CalFactoryClass))
-#define IS_CAL_FACTORY(obj) (GTK_CHECK_TYPE ((obj), CAL_FACTORY_TYPE))
-#define IS_CAL_FACTORY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_FACTORY_TYPE))
-
-typedef struct _CalFactory CalFactory;
-typedef struct _CalFactoryClass CalFactoryClass;
-
-struct _CalFactory {
- BonoboObject object;
-
- /* Private data */
- gpointer priv;
-};
-
-struct _CalFactoryClass {
- BonoboObjectClass parent_class;
-};
-
-GtkType cal_factory_get_type (void);
-
-CalFactory *cal_factory_construct (CalFactory *factory, Evolution_Calendar_CalFactory corba_factory);
-Evolution_Calendar_CalFactory cal_factory_corba_object_create (BonoboObject *object);
-
-CalFactory *cal_factory_new (void);
-
-void cal_factory_load (CalFactory *factory, const char *uri, Evolution_Calendar_Listener listener);
-void cal_factory_create (CalFactory *factory, const char *uri, Evolution_Calendar_Listener listener);
-
-POA_Evolution_Calendar_CalFactory__epv *cal_factory_get_epv (void);
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c
deleted file mode 100644
index 1ce1d91716..0000000000
--- a/calendar/pcs/cal.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/* Evolution calendar client interface object
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include "cal.h"
-#include "cal-backend.h"
-
-
-
-/* Private part of the Cal structure */
-typedef struct {
- /* Our backend */
- CalBackend *backend;
-
- /* Listener on the client we notify */
- Evolution_Calendar_Listener listener;
-} CalPrivate;
-
-
-
-static void cal_class_init (CalClass *class);
-static void cal_init (Cal *cal);
-static void cal_destroy (GtkObject *object);
-
-static POA_Evolution_Calendar_Cal__vepv cal_vepv;
-
-static BonoboObjectClass *parent_class;
-
-
-
-/**
- * cal_get_type:
- * @void:
- *
- * Registers the #Cal class if necessary, and returns the type ID associated to
- * it.
- *
- * Return value: The type ID of the #Cal class.
- **/
-GtkType
-cal_get_type (void)
-{
- static GtkType cal_type = 0;
-
- if (!cal_type) {
- static const GtkTypeInfo cal_info = {
- "Cal",
- sizeof (Cal),
- sizeof (CalClass),
- (GtkClassInitFunc) cal_class_init,
- (GtkObjectInitFunc) cal_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- cal_type = gtk_type_unique (BONOBO_OBJECT_TYPE, &cal_info);
- }
-
- return cal_type;
-}
-
-/* CORBA class initialzation function for the calendar */
-static void
-init_cal_corba_class (void)
-{
- cal_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
- cal_vepv.Evolution_Calendar_Cal_epv = cal_get_epv ();
-}
-
-/* Class initialization function for the calendar */
-static void
-cal_class_init (CalClass *class)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) class;
-
- parent_class = gtk_type_class (BONOBO_OBJECT_TYPE);
-
- object_class->destroy = cal_destroy;
-
- init_cal_corba_class ();
-}
-
-/* Object initialization function for the calendar */
-static void
-cal_init (Cal *cal)
-{
- CalPrivate *priv;
-
- priv = g_new0 (CalPrivate, 1);
- cal->priv = priv;
-
- priv->listener = CORBA_OBJECT_NIL;
-}
-
-/* Destroy handler for the calendar */
-static void
-cal_destroy (GtkObject *object)
-{
- Cal *cal;
- CalPrivate *priv;
- CORBA_Environment ev;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL (object));
-
- cal = CAL (object);
- priv = cal->priv;
-
- CORBA_exception_init (&ev);
- CORBA_Object_release (priv->listener, &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("cal_destroy(): could not release the listener");
-
- CORBA_exception_free (&ev);
-
- g_free (priv);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-
-
-/* CORBA servant implementation */
-
-/* Cal::get_uri method */
-static CORBA_char *
-Cal_get_uri (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- Cal *cal;
- CalPrivate *priv;
- GnomeVFSURI *uri;
- char *str_uri;
- CORBA_char *str_uri_copy;
-
- cal = CAL (bonobo_object_from_servant (servant));
- priv = cal->priv;
-
- uri = cal_backend_get_uri (priv->backend);
- str_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
- str_uri_copy = CORBA_string_dup (str_uri);
- g_free (str_uri);
-
- return str_uri_copy;
-
-}
-
-/* Cal::get_object method */
-static Evolution_Calendar_CalObj
-Cal_get_object (PortableServer_Servant servant,
- const Evolution_Calendar_CalObjUID uid,
- CORBA_Environment *ev)
-{
- Cal *cal;
- CalPrivate *priv;
- char *calobj;
-
- cal = CAL (bonobo_object_from_servant (servant));
- priv = cal->priv;
-
- calobj = cal_backend_get_object (priv->backend, uid);
-
- if (calobj) {
- CORBA_char *calobj_copy;
-
- calobj_copy = CORBA_string_dup (calobj);
- g_free (calobj);
- return calobj_copy;
- } else {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_Evolution_Calendar_Cal_NotFound,
- NULL);
- return NULL;
- }
-}
-
-/**
- * cal_get_epv:
- * @void:
- *
- * Creates an EPV for the Cal CORBA class.
- *
- * Return value: A newly-allocated EPV.
- **/
-POA_Evolution_Calendar_Cal__epv *
-cal_get_epv (void)
-{
- POA_Evolution_Calendar_Cal__epv *epv;
-
- epv = g_new0 (POA_Evolution_Calendar_Cal__epv, 1);
- epv->_get_uri = Cal_get_uri;
- epv->get_object = Cal_get_object;
-
- return epv;
-}
-
-
-
-/**
- * cal_construct:
- * @cal: A calendar client interface.
- * @corba_cal: CORBA object for the calendar.
- * @backend: Calendar backend that this @cal presents an interface to.
- * @listener: Calendar listener for notification.
- *
- * Constructs a calendar client interface object by binding the corresponding
- * CORBA object to it. The calendar interface is bound to the specified
- * @backend, and will notify the @listener about changes to the calendar.
- *
- * Return value: The same object as the @cal argument.
- **/
-Cal *
-cal_construct (Cal *cal,
- Evolution_Calendar_Cal corba_cal,
- CalBackend *backend,
- Evolution_Calendar_Listener listener)
-{
- CalPrivate *priv;
- CORBA_Environment ev;
-
- g_return_val_if_fail (cal != NULL, NULL);
- g_return_val_if_fail (IS_CAL (cal), NULL);
- g_return_val_if_fail (backend != NULL, NULL);
- g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
-
- priv = cal->priv;
-
- CORBA_exception_init (&ev);
- priv->listener = CORBA_Object_duplicate (listener, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_construct: could not duplicate the listener");
- priv->listener = CORBA_OBJECT_NIL;
- CORBA_exception_free (&ev);
- return NULL;
- }
-
- CORBA_exception_free (&ev);
-
- priv->backend = backend;
-
- bonobo_object_construct (BONOBO_OBJECT (cal), corba_cal);
- return cal;
-}
-
-/**
- * cal_corba_object_create:
- * @object: #BonoboObject that will wrap the CORBA object.
- *
- * Creates and activates the CORBA object that is wrapped by the specified
- * calendar client interface @object.
- *
- * Return value: An activated object reference or #CORBA_OBJECT_NIL in case of
- * failure.
- **/
-Evolution_Calendar_Cal
-cal_corba_object_create (BonoboObject *object)
-{
- POA_Evolution_Calendar_Cal *servant;
- CORBA_Environment ev;
-
- g_return_val_if_fail (object != NULL, CORBA_OBJECT_NIL);
- g_return_val_if_fail (IS_CAL (object), CORBA_OBJECT_NIL);
-
- servant = (POA_Evolution_Calendar_Cal *) g_new0 (BonoboObjectServant, 1);
- servant->vepv = &cal_vepv;
-
- CORBA_exception_init (&ev);
- POA_Evolution_Calendar_Cal__init ((PortableServer_Servant) servant, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_corba_object_create(): could not init the servant");
- g_free (servant);
- CORBA_exception_free (&ev);
- return CORBA_OBJECT_NIL;
- }
-
- CORBA_exception_free (&ev);
- return (Evolution_Calendar_Cal) bonobo_object_activate_servant (object, servant);
-}
-
-/**
- * cal_new:
- * @backend: A calendar backend.
- * @listener: A calendar listener.
- *
- * Creates a new calendar client interface object and binds it to the specified
- * @backend and @listener objects.
- *
- * Return value: A newly-created #Cal calendar client interface object, or NULL
- * if its corresponding CORBA object could not be created.
- **/
-Cal *
-cal_new (CalBackend *backend, Evolution_Calendar_Listener listener)
-{
- Cal *cal, *retval;
- Evolution_Calendar_Cal corba_cal;
- CORBA_Environment ev;
- gboolean ret;
-
- g_return_val_if_fail (backend != NULL, NULL);
- g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
-
- cal = CAL (gtk_type_new (CAL_TYPE));
- corba_cal = cal_corba_object_create (BONOBO_OBJECT (cal));
-
- CORBA_exception_init (&ev);
- ret = CORBA_Object_is_nil ((CORBA_Object) corba_cal, &ev);
- if (ev._major != CORBA_NO_EXCEPTION || ret) {
- g_message ("cal_new(): could not create the CORBA object");
- gtk_object_unref (GTK_OBJECT (cal));
- CORBA_exception_free (&ev);
- return NULL;
- }
-
- CORBA_exception_free (&ev);
-
- retval = cal_construct (cal, corba_cal, backend, listener);
- if (!retval) {
- g_message ("cal_new(): could not construct the calendar client interface");
- gtk_object_unref (GTK_OBJECT (cal));
- return NULL;
- }
-
- return retval;
-}
diff --git a/calendar/pcs/cal.h b/calendar/pcs/cal.h
deleted file mode 100644
index b866470437..0000000000
--- a/calendar/pcs/cal.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Evolution calendar client interface object
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef CAL_H
-#define CAL_H
-
-#include <libgnome/gnome-defs.h>
-#include <bonobo/bonobo-object.h>
-#include "evolution-calendar.h"
-#include "cal-common.h"
-
-BEGIN_GNOME_DECLS
-
-
-
-#define CAL_TYPE (cal_get_type ())
-#define CAL(obj) (GTK_CHECK_CAST ((obj), CAL_TYPE, Cal))
-#define CAL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_TYPE, CalClass))
-#define IS_CAL(obj) (GTK_CHECK_TYPE ((obj), CAL_TYPE))
-#define IS_CAL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_TYPE))
-
-struct _Cal {
- BonoboObject object;
-
- /* Private data */
- gpointer priv;
-};
-
-struct _CalClass {
- BonoboObjectClass parent_class;
-};
-
-GtkType cal_get_type (void);
-
-Cal *cal_construct (Cal *cal,
- Evolution_Calendar_Cal corba_cal,
- CalBackend *backend,
- Evolution_Calendar_Listener listener);
-Evolution_Calendar_Cal cal_corba_object_create (BonoboObject *object);
-
-Cal *cal_new (CalBackend *backend, Evolution_Calendar_Listener listener);
-
-POA_Evolution_Calendar_Cal__epv *cal_get_epv (void);
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c
deleted file mode 100644
index f3004ddb13..0000000000
--- a/calendar/pcs/calobj.c
+++ /dev/null
@@ -1,1490 +0,0 @@
-/*
- * Calendar objects implementations.
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org)
- */
-#include <config.h>
-#include <string.h>
-#include <glib.h>
-#include <ctype.h>
-#include <unistd.h>
-#include "calobj.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
-
-extern CalendarAlarm alarm_defaults[4];
-
-static char *
-ical_gen_uid (void)
-{
- static char *hostname;
- time_t t = time (NULL);
- static int serial;
-
- if (!hostname){
- char buffer [128];
-
- if ((gethostname (buffer, sizeof (buffer)-1) == 0) &&
- (buffer [0] != 0))
- hostname = g_strdup (buffer);
- else
- hostname = g_strdup ("localhost");
- }
-
- return g_strdup_printf (
- "%s-%d-%d-%d-%d@%s",
- isodate_from_time_t (t),
- getpid (),
- getgid (),
- getppid (),
- serial++,
- hostname);
-}
-
-iCalObject *
-ical_object_new (void)
-{
- iCalObject *ico;
-
- ico = g_new0 (iCalObject, 1);
-
- ico->seq = -1;
- ico->dtstamp = time (NULL);
- ico->uid = ical_gen_uid ();
-
- ico->pilot_id = 0;
- ico->pilot_status = ICAL_PILOT_SYNC_MOD;
-
- return ico;
-}
-
-static void
-default_alarm (iCalObject *ical, CalendarAlarm *alarm, char *def_mail, enum AlarmType type)
-{
- alarm->type = type;
- alarm->enabled = alarm_defaults[type].enabled;
- alarm->count = alarm_defaults[type].count;
- alarm->units = alarm_defaults[type].units;
- if (alarm_defaults[type].data)
- alarm->data = g_strdup (alarm_defaults[type].data);
- else
- alarm->data = g_strdup ("");
-}
-
-iCalObject *
-ical_new (char *comment, char *organizer, char *summary)
-{
- iCalObject *ico;
-
- ico = ical_object_new ();
-
- ico->comment = g_strdup (comment);
- ico->organizer = g_strdup (organizer);
- ico->summary = g_strdup (summary);
- ico->class = g_strdup ("PUBLIC");
- ico->status = g_strdup ("NEEDS ACTION");
-
- default_alarm (ico, &ico->dalarm, organizer, ALARM_DISPLAY);
- default_alarm (ico, &ico->palarm, organizer, ALARM_PROGRAM);
- default_alarm (ico, &ico->malarm, organizer, ALARM_MAIL);
- default_alarm (ico, &ico->aalarm, organizer, ALARM_AUDIO);
-
- return ico;
-}
-
-static void
-my_free (gpointer data, gpointer user_dat_ignored)
-{
- g_free (data);
-}
-
-static void
-list_free (GList *list)
-{
- g_list_foreach (list, my_free, 0);
- g_list_free (list);
-}
-
-#define free_if_defined(x) if (x){ g_free (x); x = 0; }
-#define lfree_if_defined(x) if (x){ list_free (x); x = 0; }
-void
-ical_object_destroy (iCalObject *ico)
-{
- /* Regular strings */
- free_if_defined (ico->comment);
- free_if_defined (ico->organizer);
- free_if_defined (ico->summary);
- free_if_defined (ico->uid);
- free_if_defined (ico->status);
- free_if_defined (ico->class);
- free_if_defined (ico->url);
- free_if_defined (ico->recur);
-
- /* Lists */
- lfree_if_defined (ico->exdate);
- lfree_if_defined (ico->categories);
- lfree_if_defined (ico->resources);
- lfree_if_defined (ico->related);
- lfree_if_defined (ico->attach);
-
- /* Alarms */
- g_free (ico->dalarm.data);
- g_free (ico->palarm.data);
- g_free (ico->malarm.data);
- g_free (ico->aalarm.data);
-
- g_free (ico);
-}
-
-static GList *
-set_list (char *str)
-{
- GList *list = 0;
- char *s;
-
- for (s = strtok (str, ";"); s; s = strtok (NULL, ";"))
- list = g_list_prepend (list, g_strdup (s));
-
- return list;
-}
-
-static GList *
-set_date_list (char *str)
-{
- GList *list = 0;
- char *s;
-
- for (s = strtok (str, ";,"); s; s = strtok (NULL, ";,")){
- time_t *t = g_new (time_t, 1);
-
- while (*s && isspace (*s))
- s++;
- *t = time_from_isodate (s);
- list = g_list_prepend (list, t);
- }
- return list;
-}
-
-void
-ical_object_add_exdate (iCalObject *o, time_t t)
-{
- time_t *pt = g_new (time_t, 1);
-
- *pt = t;
- o->exdate = g_list_prepend (o->exdate, pt);
-}
-
-static void
-ignore_space(char **str)
-{
- while (**str && isspace (**str))
- (*str)++;
-}
-
-static void
-skip_numbers (char **str)
-{
- while (**str){
- ignore_space (str);
- if (!isdigit (**str))
- return;
- while (**str && isdigit (**str))
- (*str)++;
- }
-}
-
-static void
-weekdaylist (iCalObject *o, char **str)
-{
- int i;
- struct {
- char first_letter, second_letter;
- int index;
- } days [] = {
- { 'S', 'U', 0 },
- { 'M', 'O', 1 },
- { 'T', 'U', 2 },
- { 'W', 'E', 3 },
- { 'T', 'H', 4 },
- { 'F', 'R', 5 },
- { 'S', 'A', 6 }
- };
-
- ignore_space (str);
- do {
- for (i = 0; i < 7; i++){
- if (**str == days [i].first_letter && *(*str+1) == days [i].second_letter){
- o->recur->weekday |= 1 << i;
- *str += 2;
- if (**str == ' ')
- (*str)++;
- }
- }
- } while (isalpha (**str));
-
- if (o->recur->weekday == 0){
- struct tm tm = *localtime (&o->dtstart);
-
- o->recur->weekday = 1 << tm.tm_wday;
- }
-}
-
-static void
-weekdaynum (iCalObject *o, char **str)
-{
- int i;
- struct {
- char first_letter, second_letter;
- int index;
- } days [] = {
- { 'S', 'U', 0 },
- { 'M', 'O', 1 },
- { 'T', 'U', 2 },
- { 'W', 'E', 3 },
- { 'T', 'H', 4 },
- { 'F', 'R', 5 },
- { 'S', 'A', 6 }
- };
-
- ignore_space (str);
- do {
- for (i = 0; i < 7; i++){
- if (**str == days [i].first_letter && *(*str+1) == days [i].second_letter){
- o->recur->weekday = i;
- *str += 2;
- if (**str == ' ')
- (*str)++;
- }
- }
- } while (isalpha (**str));
-}
-
-static void
-ocurrencelist (iCalObject *o, char **str)
-{
- char *p;
-
- ignore_space (str);
- p = *str;
- if (!isdigit (*p))
- return;
-
- if (!(*p >= '1' && *p <= '5'))
- return;
-
- if (!(*(p+1) == '+' || *(p+1) == '-'))
- return;
-
- o->recur->u.month_pos = (*p-'0') * (*(p+1) == '+' ? 1 : -1);
- *str += 2;
-}
-
-static void
-daynumber (iCalObject *o, char **str)
-{
- int val = 0;
- char *p = *str;
-
- ignore_space (str);
- if (strcmp (p, "LD")){
- o->recur->u.month_day = DAY_LASTDAY;
- *str += 2;
- return;
- }
-
- if (!(isdigit (*p)))
- return;
-
- while (**str && isdigit (**str)){
- val = val * 10 + (**str - '0');
- (*str)++;
- }
-
- if (**str == '+')
- (*str)++;
-
- if (**str == '-')
- val *= -1;
- o->recur->u.month_day = val;
-}
-
-static void
-daynumberlist (iCalObject *o, char **str)
-{
- int first = 0;
- int val = 0;
-
- ignore_space (str);
-
- while (**str){
- if (!isdigit (**str))
- return;
- while (**str && isdigit (**str)){
- val = 10 * val + (**str - '0');
- (*str)++;
- }
- if (!first){
- /*
- * Some broken applications set this to zero
- */
- if (val == 0){
- struct tm day = *localtime (&o->dtstart);
-
- val = day.tm_mday;
- }
- o->recur->u.month_day = val;
- first = 1;
- val = 0;
- }
- }
-}
-
-static void
-load_recur_weekly (iCalObject *o, char **str)
-{
- weekdaylist (o, str);
-}
-
-static void
-load_recur_monthly_pos (iCalObject *o, char **str)
-{
- ocurrencelist (o, str);
- weekdaynum (o, str);
-}
-
-static void
-load_recur_monthly_day (iCalObject *o, char **str)
-{
- daynumberlist (o, str);
-}
-
-static void
-load_recur_yearly_month (iCalObject *o, char **str)
-{
- /* Skip as we do not support multiple months and we do expect
- * the dtstart to agree with the value on this field
- */
- skip_numbers (str);
-}
-
-static void
-load_recur_yearly_day (iCalObject *o, char **str)
-{
- /* Skip as we do not support multiple days and we do expect
- * the dtstart to agree with the value on this field
- *
- * FIXME: we should support every-n-years
- */
- skip_numbers (str);
-}
-
-static void
-duration (iCalObject *o, char **str)
-{
- unsigned int duration = 0;
-
- ignore_space (str);
- if (**str != '#')
- return;
- (*str)++;
- while (**str && isdigit (**str)){
- duration = duration * 10 + (**str - '0');
- (*str)++;
- }
- o->recur->duration = duration;
-}
-
-static void
-enddate (iCalObject *o, char **str)
-{
- ignore_space (str);
- if (isdigit (**str)){
- o->recur->_enddate = time_from_isodate (*str);
- *str += 16;
- }
-}
-
-static int
-load_recurrence (iCalObject *o, char *str)
-{
- enum RecurType type;
- int interval = 0;
-
- type = -1;
- switch (*str++){
- case 'D':
- type = RECUR_DAILY;
- break;
-
- case 'W':
- type = RECUR_WEEKLY;
- break;
-
- case 'M':
- if (*str == 'P')
- type = RECUR_MONTHLY_BY_POS;
- else if (*str == 'D')
- type = RECUR_MONTHLY_BY_DAY;
- str++;
- break;
-
- case 'Y':
- if (*str == 'M')
- type = RECUR_YEARLY_BY_MONTH;
- else if (*str == 'D')
- type = RECUR_YEARLY_BY_DAY;
- str++;
- break;
- }
- if (type == -1)
- return 0;
-
- o->recur = g_new0 (Recurrence, 1);
- o->recur->type = type;
- ignore_space (&str);
-
- /* Get the interval */
- for (;*str && isdigit (*str);str++)
- interval = interval * 10 + (*str-'0');
-
- if (interval == 0)
- interval = 1;
-
- o->recur->interval = interval;
-
- /* this is the default per the spec */
- o->recur->duration = 2;
-
- ignore_space (&str);
-
- switch (type){
- case RECUR_DAILY:
- break;
- case RECUR_WEEKLY:
- load_recur_weekly (o, &str);
- break;
- case RECUR_MONTHLY_BY_POS:
- load_recur_monthly_pos (o, &str);
- break;
- case RECUR_MONTHLY_BY_DAY:
- load_recur_monthly_day (o, &str);
- break;
- case RECUR_YEARLY_BY_MONTH:
- load_recur_yearly_month (o, &str);
- break;
- case RECUR_YEARLY_BY_DAY:
- load_recur_yearly_day (o, &str);
- break;
- default:
- g_warning ("Unimplemented recurrence type %d", (int) type);
- break;
- }
- duration (o, &str);
- enddate (o, &str);
-
- /* Compute the enddate */
- if (o->recur->_enddate == 0){
- if (o->recur->duration != 0){
- ical_object_compute_end (o);
- } else
- o->recur->enddate = 0;
- } else {
- o->recur->enddate = o->recur->_enddate;
- }
- return 1;
-}
-
-#define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop)
-#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj))
-#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
-
-/*
- * FIXME: This is loosing precission. Enhanec the thresholds
- */
-#define HOURS(n) (n*(60*60))
-
-static void
-setup_alarm_at (iCalObject *ico, CalendarAlarm *alarm, char *iso_time, VObject *vo)
-{
- time_t alarm_time = time_from_isodate (iso_time);
- time_t base = ico->dtstart;
- int d = difftime (base, alarm_time);
- VObject *a;
- char *the_str;
-
- alarm->enabled = 1;
- if (d > HOURS (2)){
- if (d > HOURS (48)){
- alarm->count = d / HOURS (24);
- alarm->units = ALARM_DAYS;
- } else {
- alarm->count = d / (60*60);
- alarm->units = ALARM_HOURS;
- }
- } else {
- alarm->count = d / 60;
- alarm->units = ALARM_MINUTES;
- }
-
- if ((a = is_a_prop_of (vo, VCSnoozeTimeProp))){
- alarm->snooze_secs = isodiff_to_secs (str_val (a));
- free (the_str);
- }
-
- if ((a = is_a_prop_of (vo, VCRepeatCountProp))){
- alarm->snooze_repeat = atoi (str_val (a));
- free (the_str);
- }
-}
-
-/*
- * Duplicates an iCalObject. Implementation is a grand hack
- */
-iCalObject *
-ical_object_duplicate (iCalObject *o)
-{
- VObject *vo;
- iCalObject *new;
-
- vo = ical_object_to_vobject (o);
- switch (o->type){
- case ICAL_EVENT:
- new = ical_object_create_from_vobject (vo, VCEventProp);
- break;
- case ICAL_TODO:
- new = ical_object_create_from_vobject (vo, VCTodoProp);
- break;
- default:
- new = NULL;
- }
-
- cleanVObject (vo);
- return new;
-}
-
-/* FIXME: we need to load the recurrence properties */
-iCalObject *
-ical_object_create_from_vobject (VObject *o, const char *object_name)
-{
- time_t now = time (NULL);
- iCalObject *ical;
- VObject *vo, *a;
- VObjectIterator i;
- char *the_str;
-
- ical = g_new0 (iCalObject, 1);
-
- if (strcmp (object_name, VCEventProp) == 0)
- ical->type = ICAL_EVENT;
- else if (strcmp (object_name, VCTodoProp) == 0)
- ical->type = ICAL_TODO;
- else {
- g_free (ical);
- return 0;
- }
-
- /* uid */
- if (has (o, VCUniqueStringProp)){
- ical->uid = g_strdup (str_val (vo));
- free (the_str);
- } else {
- ical->uid = ical_gen_uid ();
- }
-
- /* seq */
- if (has (o, VCSequenceProp)){
- ical->seq = atoi (str_val (vo));
- free (the_str);
- } else
- ical->seq = 0;
-
- /* dtstart */
- if (has (o, VCDTstartProp)){
- ical->dtstart = time_from_isodate (str_val (vo));
- free (the_str);
- } else
- ical->dtstart = 0;
-
- /* dtend */
- ical->dtend = 0; /* default value */
- if (ical->type == ICAL_EVENT){
- if (has (o, VCDTendProp)){
- ical->dtend = time_from_isodate (str_val (vo));
- free (the_str);
- }
- } else if (ical->type == ICAL_TODO){
- if (has (o, VCDueProp)){
- ical->dtend = time_from_isodate (str_val (vo));
- free (the_str);
- }
- }
-
- /* dcreated */
- if (has (o, VCDCreatedProp)){
- ical->created = time_from_isodate (str_val (vo));
- free (the_str);
- }
-
- /* completed */
- if (has (o, VCCompletedProp)){
- ical->completed = time_from_isodate (str_val (vo));
- free (the_str);
- }
-
- /* last_mod */
- if (has (o, VCLastModifiedProp)){
- ical->last_mod = time_from_isodate (str_val (vo));
- free (the_str);
- } else
- ical->last_mod = now;
-
- /* exdate */
- if (has (o, VCExpDateProp)){
- ical->exdate = set_date_list (str_val (vo));
- free (the_str);
- }
-
- /* description/comment */
- if (has (o, VCDescriptionProp)){
- ical->comment = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* summary */
- if (has (o, VCSummaryProp)){
- ical->summary = g_strdup (str_val (vo));
- free (the_str);
- } else
- ical->summary = g_strdup ("");
-
- /* status */
- if (has (o, VCStatusProp)){
- ical->status = g_strdup (str_val (vo));
- free (the_str);
- } else
- ical->status = g_strdup ("NEEDS ACTION");
-
- if (has (o, VCClassProp)){
- ical->class = g_strdup (str_val (vo));
- free (the_str);
- } else
- ical->class = "PUBLIC";
-
- /* categories */
- if (has (o, VCCategoriesProp)){
- ical->categories = set_list (str_val (vo));
- free (the_str);
- }
-
- /* resources */
- if (has (o, VCResourcesProp)){
- ical->resources = set_list (str_val (vo));
- free (the_str);
- }
-
- /* priority */
- if (has (o, VCPriorityProp)){
- ical->priority = atoi (str_val (vo));
- free (the_str);
- }
-
- /* tranparency */
- if (has (o, VCTranspProp)){
- ical->transp = atoi (str_val (vo)) ? ICAL_TRANSPARENT : ICAL_OPAQUE;
- free (the_str);
- }
-
- /* Organizer */
- if (has (o, VCOrgNameProp)){
- ical->organizer = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* related */
- if (has (o, VCRelatedToProp)){
- ical->related = set_list (str_val (vo));
- free (the_str);
- }
-
- /* attach */
- initPropIterator (&i, o);
- while (moreIteration (&i)){
- vo = nextVObject (&i);
- if (strcmp (vObjectName (vo), VCAttachProp) == 0){
- ical->attach = g_list_prepend (ical->attach, g_strdup (str_val (vo)));
- free (the_str);
- }
- }
-
- /* url */
- if (has (o, VCURLProp)){
- ical->url = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* dalarm */
- ical->dalarm.type = ALARM_DISPLAY;
- ical->dalarm.enabled = 0;
- if (has (o, VCDAlarmProp)){
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->dalarm, str_val (a), vo);
- free (the_str);
- }
- }
-
- /* aalarm */
- ical->aalarm.type = ALARM_AUDIO;
- ical->aalarm.enabled = 0;
- if (has (o, VCAAlarmProp)){
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->aalarm, str_val (a), vo);
- free (the_str);
- }
- }
-
- /* palarm */
- ical->palarm.type = ALARM_PROGRAM;
- ical->palarm.enabled = 0;
- if (has (o, VCPAlarmProp)){
- ical->palarm.type = ALARM_PROGRAM;
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->palarm, str_val (a), vo);
- free (the_str);
-
- if ((a = is_a_prop_of (vo, VCProcedureNameProp))){
- ical->palarm.data = g_strdup (str_val (a));
- free (the_str);
- } else
- ical->palarm.data = g_strdup ("");
- }
- }
-
- /* malarm */
- ical->malarm.type = ALARM_MAIL;
- ical->malarm.enabled = 0;
- if (has (o, VCMAlarmProp)){
- ical->malarm.type = ALARM_MAIL;
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->malarm, str_val (a), vo);
- free (the_str);
-
- if ((a = is_a_prop_of (vo, VCEmailAddressProp))){
- ical->malarm.data = g_strdup (str_val (a));
- free (the_str);
- } else
- ical->malarm.data = g_strdup ("");
- }
- }
-
- /* rrule */
- if (has (o, VCRRuleProp)){
- if (!load_recurrence (ical, str_val (vo))) {
- ical_object_destroy (ical);
- return NULL;
- }
- free (the_str);
- }
-
- /*
- * Pilot
- */
- if (has (o, XPilotIdProp)){
- ical->pilot_id = atoi (str_val (vo));
- free (the_str);
- } else
- ical->pilot_id = 0;
-
- if (has (o, XPilotStatusProp)){
- ical->pilot_status = atoi (str_val (vo));
- free (the_str);
- } else
- ical->pilot_status = ICAL_PILOT_SYNC_MOD;
-
- return ical;
-}
-
-static char *
-to_str (int num)
-{
- static char buf [40];
-
- sprintf (buf, "%d", num);
- return buf;
-}
-
-/*
- * stores a GList in the property.
- */
-static void
-store_list (VObject *o, char *prop, GList *values)
-{
- GList *l;
- int len;
- char *result, *p;
-
- for (len = 0, l = values; l; l = l->next)
- len += strlen (l->data) + 1;
-
- result = g_malloc (len);
-
- for (p = result, l = values; l; l = l->next) {
- int len = strlen (l->data);
-
- strcpy (p, l->data);
-
- if (l->next) {
- p [len] = ';';
- p += len+1;
- } else
- p += len;
- }
-
- *p = 0;
-
- addPropValue (o, prop, result);
- g_free (result);
-}
-
-static void
-store_date_list (VObject *o, char *prop, GList *values)
-{
- GList *l;
- int size, len;
- char *s, *p;
-
- size = g_list_length (values);
- s = p = g_malloc ((size * 17 + 1) * sizeof (char));
-
- for (l = values; l; l = l->next){
- strcpy (s, isodate_from_time_t (*(time_t *)l->data));
- len = strlen (s);
- s [len] = ',';
- s += len + 1;
- }
- s--;
- *s = 0;
- addPropValue (o, prop, p);
- g_free (p);
-}
-
-static char *recur_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" };
-static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" };
-static char *alarm_names [] = { VCMAlarmProp, VCPAlarmProp, VCDAlarmProp, VCAAlarmProp };
-
-static VObject *
-save_alarm (VObject *o, CalendarAlarm *alarm, iCalObject *ical)
-{
- VObject *alarm_object;
- struct tm tm;
- time_t alarm_time;
-
- if (!alarm->enabled)
- return NULL;
- tm = *localtime (&ical->dtstart);
- switch (alarm->units){
- case ALARM_MINUTES:
- tm.tm_min -= alarm->count;
- break;
-
- case ALARM_HOURS:
- tm.tm_hour -= alarm->count;
- break;
-
- case ALARM_DAYS:
- tm.tm_mday -= alarm->count;
- break;
- }
-
- alarm_time = mktime (&tm);
- alarm_object = addProp (o, alarm_names [alarm->type]);
- addPropValue (alarm_object, VCRunTimeProp, isodate_from_time_t (alarm_time));
-
- if (alarm->snooze_secs)
- addPropValue (alarm_object, VCSnoozeTimeProp, isodiff_from_secs (alarm->snooze_secs));
- else
- addPropValue (alarm_object, VCSnoozeTimeProp, "");
-
- if (alarm->snooze_repeat){
- char buf [20];
-
- sprintf (buf, "%d", alarm->snooze_repeat);
- addPropValue (alarm_object, VCRepeatCountProp, buf);
- } else
- addPropValue (alarm_object, VCRepeatCountProp, "");
- return alarm_object;
-}
-
-VObject *
-ical_object_to_vobject (iCalObject *ical)
-{
- VObject *o, *alarm, *s;
- GList *l;
-
- if (ical->type == ICAL_EVENT)
- o = newVObject (VCEventProp);
- else
- o = newVObject (VCTodoProp);
-
- /* uid */
- if (ical->uid)
- addPropValue (o, VCUniqueStringProp, ical->uid);
-
- /* seq */
- addPropValue (o, VCSequenceProp, to_str (ical->seq));
-
- /* dtstart */
- addPropValue (o, VCDTstartProp, isodate_from_time_t (ical->dtstart));
-
- /* dtend */
- if (ical->type == ICAL_EVENT){
- addPropValue (o, VCDTendProp, isodate_from_time_t (ical->dtend));
- } else if (ical->type == ICAL_TODO){
- addPropValue (o, VCDueProp, isodate_from_time_t (ical->dtend));
- }
-
- /* dcreated */
- addPropValue (o, VCDCreatedProp, isodate_from_time_t (ical->created));
-
- /* completed */
- if (ical->completed)
- addPropValue (o, VCDTendProp, isodate_from_time_t (ical->completed));
-
- /* last_mod */
- addPropValue (o, VCLastModifiedProp, isodate_from_time_t (ical->last_mod));
-
- /* exdate */
- if (ical->exdate)
- store_date_list (o, VCExpDateProp, ical->exdate);
-
- /* description/comment */
- if (ical->comment && strlen (ical->comment)){
- s = addPropValue (o, VCDescriptionProp, ical->comment);
- if (strchr (ical->comment, '\n'))
- addProp (s, VCQuotedPrintableProp);
- }
-
- /* summary */
- if (strlen (ical->summary)){
- s = addPropValue (o, VCSummaryProp, ical->summary);
- if (strchr (ical->summary, '\n'))
- addProp (s, VCQuotedPrintableProp);
- } else {
- addPropValue (o, VCSummaryProp, _("Appointment"));
- }
-
- /* status */
- addPropValue (o, VCStatusProp, ical->status);
-
- /* class */
- addPropValue (o, VCClassProp, ical->class);
-
- /* categories */
- if (ical->categories)
- store_list (o, VCCategoriesProp, ical->categories);
-
- /* resources */
- if (ical->resources)
- store_list (o, VCCategoriesProp, ical->resources);
-
- /* priority */
- addPropValue (o, VCPriorityProp, to_str (ical->priority));
-
- /* transparency */
- addPropValue (o, VCTranspProp, to_str (ical->transp));
-
- /* Owenr/organizer */
- if (ical->organizer)
- addPropValue (o, VCOrgNameProp, ical->organizer);
-
- /* related */
- if (ical->related)
- store_list (o, VCRelatedToProp, ical->related);
-
- /* attach */
- for (l = ical->attach; l; l = l->next)
- addPropValue (o, VCAttachProp, l->data);
-
- /* url */
- if (ical->url)
- addPropValue (o, VCURLProp, ical->url);
-
- if (ical->recur){
- char result [256];
- char buffer [80];
- int i;
-
- sprintf (result, "%s%d ", recur_type_name [ical->recur->type], ical->recur->interval);
- switch (ical->recur->type){
- case RECUR_DAILY:
- break;
-
- case RECUR_WEEKLY:
- for (i = 0; i < 7; i++){
- if (ical->recur->weekday & (1 << i)){
- sprintf (buffer, "%s ", recur_day_list [i]);
- strcat (result, buffer);
- }
- }
- break;
-
- case RECUR_MONTHLY_BY_POS: {
- int nega = ical->recur->u.month_pos < 0;
-
- sprintf (buffer, "%d%s ", nega ? -ical->recur->u.month_pos : ical->recur->u.month_pos,
- nega ? "-" : "+");
- strcat (result, buffer);
- /* the gui is set up for a single day, not a set here in this case */
- sprintf (buffer, "%s ", recur_day_list [ical->recur->weekday]);
- strcat (result, buffer);
- }
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- sprintf (buffer, "%d ", ical->recur->u.month_pos);
- strcat (result, buffer);
- break;
-
- case RECUR_YEARLY_BY_MONTH:
- break;
-
- case RECUR_YEARLY_BY_DAY:
- break;
- }
- if (ical->recur->_enddate == 0)
- sprintf (buffer, "#%d ",ical->recur->duration);
- else
- sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
- strcat (result, buffer);
- addPropValue (o, VCRRuleProp, result);
- }
-
- save_alarm (o, &ical->aalarm, ical);
- save_alarm (o, &ical->dalarm, ical);
-
- if ((alarm = save_alarm (o, &ical->palarm, ical)))
- addPropValue (alarm, VCProcedureNameProp, ical->palarm.data);
- if ((alarm = save_alarm (o, &ical->malarm, ical)))
- addPropValue (alarm, VCEmailAddressProp, ical->malarm.data);
-
- /* Pilot */
- {
- char buffer [20];
-
- sprintf (buffer, "%d", ical->pilot_id);
- addPropValue (o, XPilotIdProp, buffer);
- sprintf (buffer, "%d", ical->pilot_status);
- addPropValue (o, XPilotStatusProp, buffer);
- }
-
- return o;
-}
-
-void
-ical_foreach (GList *events, calendarfn fn, void *closure)
-{
- for (; events; events = events->next){
- iCalObject *ical = events->data;
-
- (*fn) (ical, ical->dtstart, ical->dtend, closure);
- }
-}
-
-static int
-is_date_in_list (GList *list, struct tm *date)
-{
- struct tm tm;
-
- for (; list; list = list->next){
- time_t *timep = list->data;
-
- tm = *localtime (timep);
- if (date->tm_mday == tm.tm_mday &&
- date->tm_mon == tm.tm_mon &&
- date->tm_year == tm.tm_year){
- return 1;
- }
- }
- return 0;
-}
-
-static int
-generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure)
-{
- struct tm dt_start, dt_end, ref;
- time_t s_t, e_t;
-
- dt_start = *localtime (&ico->dtstart);
- dt_end = *localtime (&ico->dtend);
- ref = *localtime (&reference);
-
- dt_start.tm_mday = ref.tm_mday;
- dt_start.tm_mon = ref.tm_mon;
- dt_start.tm_year = ref.tm_year;
-
- dt_end.tm_mday = ref.tm_mday;
- dt_end.tm_mon = ref.tm_mon;
- dt_end.tm_year = ref.tm_year;
-
-
- if (ref.tm_isdst > dt_start.tm_isdst){
- dt_start.tm_hour--;
- dt_end.tm_hour--;
- } else if (ref.tm_isdst < dt_start.tm_isdst){
- dt_start.tm_hour++;
- dt_end.tm_hour++;
- }
-
- s_t = mktime (&dt_start);
-
- if (ico->exdate && is_date_in_list (ico->exdate, &dt_start))
- return 1;
-
- e_t = mktime (&dt_end);
-
- if ((s_t == -1) || (e_t == -1)) {
- g_warning ("Produced invalid dates!\n");
- return 0;
- }
-
- return (*cb) (ico, s_t, e_t, closure);
-}
-
-int
-ical_object_get_first_weekday (int weekday_mask)
-{
- int i;
-
- for (i = 0; i < 7; i++)
- if (weekday_mask & (1 << i))
- return i;
-
- return -1;
-}
-
-#define time_in_range(t, a, b) ((t >= a) && (b ? (t < b) : 1))
-#define recur_in_range(t, r) (r->enddate ? (t < r->enddate) : 1)
-
-/*
- * Generate every possible event. Invokes the callback routine for
- * every occurrence of the event in the [START, END] time interval.
- *
- * If END is zero, the event is generated forever.
- * The callback routine is expected to return 0 when no further event
- * generation is requested.
- */
-void
-ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure)
-{
- time_t current;
- int first_week_day;
-
- /* If there is no recurrence, just check ranges */
-
- if (!ico->recur) {
- if ((end && (ico->dtstart < end) && (ico->dtend > start))
- || ((end == 0) && (ico->dtend > start))) {
- time_t ev_s, ev_e;
-
- /* Clip range */
-
- ev_s = MAX (ico->dtstart, start);
- ev_e = MIN (ico->dtend, end);
-
- (* cb) (ico, ev_s, ev_e, closure);
- }
- return;
- }
-
- /* The event has a recurrence rule -- check that we will generate at least one instance */
-
- if (end != 0) {
- if (ico->dtstart > end)
- return;
-
- if (!IS_INFINITE (ico->recur) && (ico->recur->enddate < start))
- return;
- }
-
- /* Generate the instances */
-
- current = ico->dtstart;
-
- switch (ico->recur->type) {
- case RECUR_DAILY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, current, cb, closure))
- return;
-
- /* Advance */
-
- current = time_add_day (current, ico->recur->interval);
-
- if (current == -1) {
- g_warning ("RECUR_DAILY: time_add_day() returned invalid time");
- return;
- }
- } while ((current < end) || (end == 0));
-
- break;
-
- case RECUR_WEEKLY:
- do {
- struct tm tm;
-
- tm = *localtime (&current);
-
- if (time_in_range (current, start, end) && recur_in_range (current, ico->recur)) {
- /* Weekdays to recur on are specified as a bitmask */
- if (ico->recur->weekday & (1 << tm.tm_wday)) {
- if (!generate (ico, current, cb, closure))
- return;
- }
- }
-
- /* Advance by day for scanning the week or by interval at week end */
-
- if (tm.tm_wday == 6)
- current = time_add_day (current, (ico->recur->interval - 1) * 7 + 1);
- else
- current = time_add_day (current, 1);
-
- if (current == -1) {
- g_warning ("RECUR_WEEKLY: time_add_day() returned invalid time\n");
- return;
- }
- } while (current < end || (end == 0));
-
- break;
-
- case RECUR_MONTHLY_BY_POS:
- /* FIXME: We only deal with positives now */
- if (ico->recur->u.month_pos < 0) {
- g_warning ("RECUR_MONTHLY_BY_POS does not support negative positions yet");
- return;
- }
-
- if (ico->recur->u.month_pos == 0)
- return;
-
- first_week_day = /* ical_object_get_first_weekday (ico->recur->weekday); */
- ico->recur->weekday; /* the i/f only lets you choose a single day of the week! */
-
- /* This should not happen, but take it into account */
- if (first_week_day == -1) {
- g_warning ("ical_object_get_first_weekday() returned -1");
- return;
- }
-
- do {
- struct tm tm;
- time_t t;
- int week_day_start;
-
- tm = *localtime (&current);
- tm.tm_mday = 1;
- t = mktime (&tm);
- tm = *localtime (&t);
- week_day_start = tm.tm_wday;
-
- tm.tm_mday = (7 * (ico->recur->u.month_pos - ((week_day_start <= first_week_day ) ? 1 : 0))
- - (week_day_start - first_week_day) + 1);
- if( tm.tm_mday > 31 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
-
- switch( tm.tm_mon )
- {
- case 3:
- case 5:
- case 8:
- case 10:
- if( tm.tm_mday > 30 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
- break;
- case 1:
- if( ((tm.tm_year+1900)%4) == 0
- && ((tm.tm_year+1900)%400) != 100
- && ((tm.tm_year+1900)%400) != 200
- && ((tm.tm_year+1900)%400) != 300 )
- {
-
- if( tm.tm_mday > 29 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
- }
- else
- {
- if( tm.tm_mday > 28 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
- }
- break;
- }
-
- t = mktime (&tm);
-
- if (time_in_range (t, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance by the appropriate number of months */
-
- current = mktime (&tm);
-
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
-
- if (current == -1) {
- g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
- return;
- }
- } while ((current < end) || (end == 0));
-
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- do {
- struct tm tm;
- time_t t;
- int p;
-
- tm = *localtime (&current);
-
- p = tm.tm_mday;
- tm.tm_mday = ico->recur->u.month_day;
- t = mktime (&tm);
- if (time_in_range (t, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance by the appropriate number of months */
-
- tm.tm_mday = p;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
-
- if (current == -1) {
- g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
- return;
- }
- } while (current < end || (end == 0));
-
- break;
-
- case RECUR_YEARLY_BY_MONTH:
- case RECUR_YEARLY_BY_DAY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, current, cb, closure))
- return;
-
- /* Advance */
-
- current = time_add_year (current, ico->recur->interval);
- } while (current < end || (end == 0));
-
- break;
-
- default:
- g_assert_not_reached ();
- }
-}
-
-static int
-duration_callback (iCalObject *ico, time_t start, time_t end, void *closure)
-{
- int *count = closure;
- struct tm tm;
-
- tm = *localtime (&start);
-
- (*count)++;
- if (ico->recur->duration == *count) {
- ico->recur->enddate = time_day_end (end);
- return 0;
- }
- return 1;
-}
-
-/* Computes ico->recur->enddate from ico->recur->duration */
-void
-ical_object_compute_end (iCalObject *ico)
-{
- int count = 0;
-
- g_return_if_fail (ico->recur != NULL);
-
- ico->recur->_enddate = 0;
- ico->recur->enddate = 0;
- ical_object_generate_events (ico, ico->dtstart, 0, duration_callback, &count);
-}
-
-int
-alarm_compute_offset (CalendarAlarm *a)
-{
- if (!a->enabled)
- return -1;
- switch (a->units){
- case ALARM_MINUTES:
- a->offset = a->count * 60;
- break;
- case ALARM_HOURS:
- a->offset = a->count * 3600;
- break;
- case ALARM_DAYS:
- a->offset = a->count * 24 * 3600;
- }
- return a->offset;
-}
-
-iCalObject *
-ical_object_new_from_string (const char *vcal_string)
-{
- iCalObject *ical = NULL;
- VObject *cal, *event;
- VObjectIterator i;
- const char *object_name;
-
- cal = Parse_MIME (vcal_string, strlen (vcal_string));
-
- initPropIterator (&i, cal);
-
- while (moreIteration (&i)){
- event = nextVObject (&i);
-
- object_name = vObjectName (event);
-
- if (strcmp (object_name, VCEventProp) == 0){
- ical = ical_object_create_from_vobject (event, object_name);
- break;
- }
- }
-
- cleanVObject (cal);
- cleanStrTbl ();
-
- return ical;
-}
-
diff --git a/calendar/pcs/calobj.h b/calendar/pcs/calobj.h
deleted file mode 100644
index fbc92a41c5..0000000000
--- a/calendar/pcs/calobj.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Internal representation of a Calendar object. This is modeled after the
- * iCalendar/vCalendar specificiation
- *
- * Authors: Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org).
- */
-#ifndef CALOBJ_H
-#define CALOBJ_H
-
-#include <libgnome/libgnome.h>
-#include "../libversit/vcc.h"
-
-BEGIN_GNOME_DECLS
-
-enum AlarmType {
- ALARM_MAIL,
- ALARM_PROGRAM,
- ALARM_DISPLAY,
- ALARM_AUDIO
-};
-
-enum AlarmUnit {
- ALARM_MINUTES,
- ALARM_HOURS,
- ALARM_DAYS
-};
-
-typedef struct {
- enum AlarmType type;
- int enabled;
- int count;
- enum AlarmUnit units;
- char *data;
-
- /* Does not get saved, internally used */
- time_t offset;
- time_t trigger;
-
- int snooze_secs;
- int snooze_repeat;
-
- /* Widgets */
- void *w_count; /* A GtkEntry */
- void *w_enabled; /* A GtkChecButton */
- void *w_timesel; /* A GtkMenu */
- void *w_entry; /* A GnomeEntryFile/GtkEntry for PROGRAM/MAIL */
- void *w_label;
-} CalendarAlarm;
-
-/* Calendar object type */
-typedef enum {
- ICAL_EVENT,
- ICAL_TODO,
- ICAL_JOURNAL,
- ICAL_FBREQUEST,
- ICAL_FBREPLY,
- ICAL_BUSYTIME,
- ICAL_TIMEZONE
-} iCalType;
-
-/* For keys that might contain binary or text/binary */
-typedef struct {
- char *data;
- int len;
-} iCalValue;
-
-typedef enum {
- ICAL_PILOT_SYNC_NONE = 0,
- ICAL_PILOT_SYNC_MOD = 1,
- ICAL_PILOT_SYNC_DEL = 3
-} iCalPilotState;
-
-typedef struct {
- int valid; /* true if the Geography was specified */
- double latitude;
- double longitude;
-} iCalGeo;
-
-typedef enum {
- ICAL_OPAQUE,
- ICAL_TRANSPARENT
-} iCalTransp;
-
-typedef char NotYet;
-
-enum RecurType {
- RECUR_DAILY,
- RECUR_WEEKLY,
- RECUR_MONTHLY_BY_POS,
- RECUR_MONTHLY_BY_DAY,
- RECUR_YEARLY_BY_MONTH,
- RECUR_YEARLY_BY_DAY,
-};
-
-#define DAY_LASTDAY 10000
-
-typedef struct {
- enum RecurType type;
-
- int interval;
-
- /* Used for recur computation */
- time_t enddate; /* If the value is zero, it is an infinite event
- * otherwise, it is either the _enddate value (if
- * this is what got specified) or it is our computed
- * ending date (computed from the duration item).
- */
-
- int weekday;
-
- union {
- int month_pos;
- int month_day;
- } u;
-
- int duration;
- time_t _enddate; /* As found on the vCalendar file */
- int __count;
-} Recurrence;
-
-#define IS_INFINITE(r) (r->duration == 0)
-
-/* Flags to indicate what has changed in an object */
-typedef enum {
- CHANGE_NEW = 1 << 0, /* new object */
- CHANGE_SUMMARY = 1 << 1, /* summary */
- CHANGE_DATES = 1 << 2, /* dtstart / dtend */
- CHANGE_ALL = CHANGE_SUMMARY | CHANGE_DATES
-} CalObjectChange;
-
-/*
- * This describes an iCalendar object, note that we never store durations, instead we
- * always compute the end time computed from the start + duration.
- */
-typedef struct {
- iCalType type;
-
- GList *attach; /* type: one or more URIs or binary data */
- GList *attendee; /* type: CAL-ADDRESS */
- GList *categories; /* type: one or more TEXT */
- char *class;
-
- char *comment; /* we collapse one or more TEXTs into one */
- time_t completed;
- time_t created;
- GList *contact; /* type: one or more TEXT */
- time_t dtstamp;
- time_t dtstart;
- time_t dtend;
- GList *exdate; /* type: one or more time_t's */
- GList *exrule; /* type: one or more RECUR */
- iCalGeo geo;
- time_t last_mod;
- char *location;
- char *organizer;
- int percent;
- int priority;
- char *rstatus; /* request status for freebusy */
- GList *related; /* type: one or more TEXT */
- GList *resources; /* type: one or more TEXT */
- GList *rdate; /* type: one or more recurrence date */
- GList *rrule; /* type: one or more recurrence rules */
- int seq;
- char *status;
- char *summary;
- iCalTransp transp;
- char *uid;
- char *url;
- time_t recurid;
-
- CalendarAlarm dalarm;
- CalendarAlarm aalarm;
- CalendarAlarm palarm;
- CalendarAlarm malarm;
-
- Recurrence *recur;
-
- int new;
- void *user_data; /* Generic data pointer */
-
- /* Pilot */
- iCalPilotState pilot_status; /* Status information */
- guint32 pilot_id; /* Pilot ID */
-} iCalObject;
-
-/* The callback for the recurrence generator */
-typedef int (*calendarfn) (iCalObject *, time_t, time_t, void *);
-
-iCalObject *ical_new (char *comment, char *organizer, char *summary);
-iCalObject *ical_object_new (void);
-iCalObject *ical_object_new_from_string (const char *vcalendar_string);
-void ical_object_destroy (iCalObject *ico);
-iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name);
-VObject *ical_object_to_vobject (iCalObject *ical);
-iCalObject *ical_object_duplicate (iCalObject *o);
-void ical_foreach (GList *events, calendarfn fn, void *closure);
-void ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure);
-void ical_object_add_exdate (iCalObject *o, time_t t);
-
-/* Computes the enddate field of the recurrence based on the duration */
-void ical_object_compute_end (iCalObject *ico);
-
-/* Returns the first toggled day in a weekday mask -- we do this because we do not support multiple
- * days on a monthly-by-pos recurrence. If no days are toggled, it returns -1.
- */
-int ical_object_get_first_weekday (int weekday_mask);
-
-/* Returns the number of seconds configured to trigger the alarm in advance to an event */
-int alarm_compute_offset (CalendarAlarm *a);
-
-END_GNOME_DECLS
-
-#endif
-
diff --git a/calendar/pcs/job.c b/calendar/pcs/job.c
deleted file mode 100644
index d97df6d883..0000000000
--- a/calendar/pcs/job.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* GNOME personal calendar server - job manager
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include "job.h"
-
-
-
-/* The job list */
-
-typedef struct {
- JobFunc func;
- gpointer data;
-} Job;
-
-static GSList *jobs_head;
-static GSList *jobs_tail;
-
-static guint jobs_idle_id;
-
-
-
-/* Runs a job and dequeues it */
-static gboolean
-run_job (gpointer data)
-{
- Job *job;
- GSList *l;
-
- g_assert (jobs_head != NULL);
-
- job = jobs_head->data;
- (* job->func) (job->data);
- g_free (job);
-
- l = jobs_head;
- jobs_head = g_slist_remove_link (jobs_head, jobs_head);
- g_slist_free_1 (l);
-
- if (!jobs_head) {
- jobs_tail = NULL;
- jobs_idle_id = 0;
- return FALSE;
- } else
- return TRUE;
-}
-
-/**
- * job_add:
- * @func: Function to run the job.
- * @data: Data to pass to @function.
- *
- * Adds a job to the queue. The job will automatically be run asynchronously.
- **/
-void
-job_add (JobFunc func, gpointer data)
-{
- Job *job;
-
- g_return_if_fail (func != NULL);
-
- job = g_new (Job, 1);
- job->func = func;
- job->data = data;
-
- if (!jobs_head) {
- g_assert (jobs_tail == NULL);
- g_assert (jobs_idle_id == 0);
-
- jobs_head = g_slist_append (NULL, job);
- jobs_tail = jobs_head;
-
- jobs_idle_id = g_idle_add (run_job, NULL);
- } else {
- g_assert (jobs_tail != NULL);
- g_assert (jobs_idle_id != 0);
-
- jobs_tail = g_slist_append (jobs_tail, job)->next;
- }
-}
diff --git a/calendar/pcs/job.h b/calendar/pcs/job.h
deleted file mode 100644
index c9bce24dd4..0000000000
--- a/calendar/pcs/job.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* GNOME personal calendar server - job manager
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef JOB_H
-#define JOB_H
-
-#include <glib.h>
-
-
-
-typedef void (* JobFunc) (gpointer data);
-
-void job_add (JobFunc func, gpointer data);
-
-
-
-#endif
diff --git a/calendar/pcs/tlacuache.c b/calendar/pcs/tlacuache.c
deleted file mode 100644
index b11b5030d8..0000000000
--- a/calendar/pcs/tlacuache.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Tlacuache - personal calendar server main module
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <libgnorba/gnorba.h>
-#include <bonobo.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include "cal-factory.h"
-#include "calobj.h"
-
-
-
-/* The calendar factory */
-static CalFactory *factory;
-
-
-
-/* Stuff that the un-converted alarm code needs to build */
-
-int debug_alarms = FALSE;
-
-void calendar_notify (time_t time, CalendarAlarm *which, void *data);
-
-CalendarAlarm alarm_defaults[4] = {
- { ALARM_MAIL, 0, 15, ALARM_MINUTES },
- { ALARM_PROGRAM, 0, 15, ALARM_MINUTES },
- { ALARM_DISPLAY, 0, 15, ALARM_MINUTES },
- { ALARM_AUDIO, 0, 15, ALARM_MINUTES }
-};
-
-void
-calendar_notify (time_t time, CalendarAlarm *which, void *data)
-{
- g_error ("calendar_notify() called!");
-}
-
-
-
-/* Creates and registers the calendar factory */
-static gboolean
-create_cal_factory (void)
-{
- CORBA_Object object;
- CORBA_Environment ev;
- int result;
-
- factory = cal_factory_new ();
- if (!factory) {
- g_message ("create_cal_factory(): could not create the calendar factory!");
- return FALSE;
- }
-
- object = bonobo_object_corba_objref (BONOBO_OBJECT (factory));
-
- CORBA_exception_init (&ev);
- result = goad_server_register (CORBA_OBJECT_NIL,
- object,
- "calendar:cal-factory",
- "object",
- &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION || result == -1) {
- g_message ("create_cal_factory(): could not register the calendar factory");
- CORBA_exception_free (&ev);
- return FALSE;
- } else if (result == -2) {
- g_message ("create_cal_factory(): a calendar factory is already registered");
- CORBA_exception_free (&ev);
- return FALSE;
- }
-
- CORBA_exception_free (&ev);
- return TRUE;
-}
-
-int
-main (int argc, char **argv)
-{
- CORBA_Environment ev;
-
- bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);
-
- CORBA_exception_init (&ev);
- gnome_CORBA_init ("tlacuache", VERSION, &argc, argv, GNORBA_INIT_SERVER_FUNC, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("main(): could not initialize the ORB");
- CORBA_exception_free (&ev);
- exit (1);
- }
- CORBA_exception_free (&ev);
-
- if (!bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL)) {
- g_message ("main(): could not initialize Bonobo");
- exit (1);
- }
-
- if (!gnome_vfs_init ()) {
- g_message ("main(): could not initialize GNOME-VFS");
- exit (1);
- }
-
- if (!create_cal_factory ())
- exit (1);
-
- bonobo_main ();
- return 0;
-}
diff --git a/calendar/pcs/tlacuache.gnorba b/calendar/pcs/tlacuache.gnorba
deleted file mode 100644
index acf2289229..0000000000
--- a/calendar/pcs/tlacuache.gnorba
+++ /dev/null
@@ -1,5 +0,0 @@
-[calendar:cal-factory]
-type=exe
-repo_id=IDL:GNOME/Calendar/CalFactory:1.0
-description=Calendar factory for the Personal Calendar Server
-location_info=tlacuache
diff --git a/calendar/popup-menu.c b/calendar/popup-menu.c
deleted file mode 100644
index 3686183146..0000000000
--- a/calendar/popup-menu.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Popup menu utilities for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#include <config.h>
-#include <gnome.h>
-#include "popup-menu.h"
-
-
-void
-popup_menu (struct menu_item *items, int nitems, GdkEventButton *event)
-{
- GtkWidget *menu;
- GtkWidget *item;
- int i;
-
- menu = gtk_menu_new (); /* FIXME: this baby is never freed */
-
- for (i = 0; i < nitems; i++) {
- if (items[i].text) {
- item = gtk_menu_item_new_with_label (_(items[i].text));
- gtk_signal_connect (GTK_OBJECT (item), "activate",
- items[i].callback,
- items[i].data);
- gtk_widget_set_sensitive (item, items[i].sensitive);
- } else
- item = gtk_menu_item_new ();
-
- gtk_widget_show (item);
- gtk_menu_append (GTK_MENU (menu), item);
- }
-
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
-}
diff --git a/calendar/popup-menu.h b/calendar/popup-menu.h
deleted file mode 100644
index a4590dbb98..0000000000
--- a/calendar/popup-menu.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Popup menu utilities for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef POPUP_MENU_H
-#define POPUP_MENU_H
-
-#include <gdk/gdktypes.h>
-#include <gtk/gtksignal.h>
-
-
-struct menu_item {
- char *text;
- GtkSignalFunc callback;
- gpointer data;
- int sensitive;
-};
-
-void popup_menu (struct menu_item *items, int nitems, GdkEventButton *event);
-
-
-#endif
diff --git a/calendar/prop.c b/calendar/prop.c
deleted file mode 100644
index 8e91f4d730..0000000000
--- a/calendar/prop.c
+++ /dev/null
@@ -1,927 +0,0 @@
-/* Calendar properties dialog box
- *
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors: Miguel de Icaza <miguel@kernel.org>
- * Federico Mena <federico@nuclecu.unam.mx>
- */
-#include <config.h>
-#ifdef HAVE_LANGINGO_H
-#include <langinfo.h>
-#else
-#include <locale.h>
-#endif
-#include <gnome.h>
-#include "gnome-cal.h"
-#include "gnome-month-item.h"
-#include "main.h"
-#include "mark.h"
-
-/* These specify the page numbers in the preferences notebook */
-enum {
- PROP_TIME_DISPLAY,
- PROP_COLORS,
- PROP_TODO,
- PROP_ALARMS
-};
-
-static GtkWidget *prop_win; /* The preferences dialog */
-
-/* Widgets for the time display page */
-
-static GtkWidget *time_format_12; /* Radio button for 12-hour format */
-static GtkWidget *time_format_24; /* Radio button for 24-hour format */
-static GtkWidget *start_on_sunday; /* Check button for weeks starting on Sunday */
-static GtkWidget *start_on_monday; /* Check button for weeks starting on Monday */
-static GtkWidget *start_omenu; /* Option menu for start of day */
-static GtkWidget *end_omenu; /* Option menu for end of day */
-static GtkWidget *start_items[24]; /* Menu items for start of day menu */
-static GtkWidget *end_items[24]; /* Menu items for end of day menu */
-
-/* Widgets for the colors page */
-
-static GtkWidget *color_pickers[COLOR_PROP_LAST];
-static GnomeCanvasItem *month_item;
-
-/* Widgets for the todo page */
-static GtkWidget *due_date_show_button;
-
-static GtkWidget *todo_item_time_remaining_show_button;
-
-static GtkWidget *todo_item_highlight_overdue;
-static GtkWidget *todo_item_highlight_not_due_yet;
-static GtkWidget *todo_item_highlight_due_today;
-
-static GtkWidget *priority_show_button;
-
-/* Widgets for the alarm page */
-static GtkWidget *enable_display_beep;
-static GtkWidget *to_cb;
-static GtkWidget *to_spin;
-static GtkWidget *snooze_cb;
-static GtkWidget *snooze_spin;
-
-/* prototypes */
-static void prop_apply_alarms (void);
-static void create_alarm_page (void);
-static void to_cb_changed (GtkWidget* object, gpointer data);
-static void snooze_cb_changed (GtkWidget* object, gpointer data);
-
-GtkWidget* make_spin_button (int val, int low, int high);
-void ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm,
- enum AlarmType type, int y, gboolean sens,
- GtkSignalFunc dirty_func);
-void ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type);
-
-/* Callback used when the property box is closed -- just sets the prop_win variable to null. */
-static int
-prop_cancel (void)
-{
- prop_win = NULL;
- return FALSE;
-}
-
-/* Returns the index of the active item in a menu */
-static int
-get_active_index (GtkWidget *menu)
-{
- GtkWidget *active;
-
- active = gtk_menu_get_active (GTK_MENU (menu));
- return GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (active)));
-}
-
-/* Applies the settings in the time display page */
-static void
-prop_apply_time_display (void)
-{
- /* Day begin/end */
-
- day_begin = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (start_omenu)));
- day_end = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (end_omenu)));
- gnome_config_set_int ("/calendar/Calendar/Day start", day_begin);
- gnome_config_set_int ("/calendar/Calendar/Day end", day_end);
-
- /* Time format */
-
- am_pm_flag = GTK_TOGGLE_BUTTON (time_format_12)->active;
- gnome_config_set_bool ("/calendar/Calendar/AM PM flag", am_pm_flag);
-
- /* Week start */
-
- week_starts_on_monday = GTK_TOGGLE_BUTTON (start_on_monday)->active;
- gnome_config_set_bool ("/calendar/Calendar/Week starts on Monday", week_starts_on_monday);
-
- gnome_config_sync ();
- time_format_changed ();
-}
-
-/* Applies the settings in the colors page */
-static void
-prop_apply_colors (void)
-{
- int i;
- char *cspec;
- gushort r, g, b;
-
- for (i = 0; i < COLOR_PROP_LAST; i++) {
- gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[i]), &r, &g, &b, NULL);
- color_props[i].r = r;
- color_props[i].g = g;
- color_props[i].b = b;
-
- cspec = build_color_spec (color_props[i].r, color_props[i].g, color_props[i].b);
- gnome_config_set_string (color_props[i].key, cspec);
- }
-
- gnome_config_sync ();
- colors_changed ();
-}
-/* Applies the settings in the todo page (FIX THIS IF ITS NOT WRITTEN) */
-static void
-prop_apply_todo(void)
-{
- todo_show_due_date = GTK_TOGGLE_BUTTON (due_date_show_button)->active;
-
- todo_item_dstatus_highlight_overdue = GTK_TOGGLE_BUTTON(todo_item_highlight_overdue)->active;
- todo_item_dstatus_highlight_not_due_yet = GTK_TOGGLE_BUTTON(todo_item_highlight_not_due_yet)->active;
- todo_item_dstatus_highlight_due_today = GTK_TOGGLE_BUTTON(todo_item_highlight_due_today)->active;
-
- todo_show_priority = GTK_TOGGLE_BUTTON (priority_show_button)->active;
-
- todo_show_time_remaining = GTK_TOGGLE_BUTTON (todo_item_time_remaining_show_button)->active;
-
- /* storing the values */
-
- gnome_config_set_bool("/calendar/Todo/show_time_remain", todo_show_time_remaining);
- gnome_config_set_bool("/calendar/Todo/highlight_overdue", todo_item_dstatus_highlight_overdue);
-
- gnome_config_set_bool("/calendar/Todo/highlight_due_today", todo_item_dstatus_highlight_due_today);
-
- gnome_config_set_bool("/calendar/Todo/highlight_not_due_yet", todo_item_dstatus_highlight_not_due_yet);
- gnome_config_set_bool("/calendar/Todo/show_due_date", todo_show_due_date);
- gnome_config_set_bool("/calendar/Todo/show_priority", todo_show_priority);
- /* need to sync our config changes. */
- gnome_config_sync ();
-
- /* apply the current changes */
- todo_properties_changed();
-}
-
-
-/* Callback used when the Apply button is clicked. */
-static void
-prop_apply (GtkWidget *w, int page)
-{
- switch (page) {
- case PROP_TIME_DISPLAY:
- prop_apply_time_display ();
- break;
-
- case PROP_COLORS:
- prop_apply_colors ();
- break;
-
- case PROP_TODO:
- prop_apply_todo ();
- break;
-
- case PROP_ALARMS:
- prop_apply_alarms ();
- break;
-
- case -1:
- break;
-
- default:
- g_warning ("We have a loose penguin!");
- g_assert_not_reached ();
- }
-}
-
-/* Notifies the property box that the data has changed */
-static void
-prop_changed (void)
-{
- gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
-}
-
-/* Builds and returns a two-element radio button group surrounded by a frame. The radio buttons are
- * stored in the specified variables, and the first radio button's state is set according to the
- * specified flag value. The buttons are connected to the prop_changed() function to update the property
- * box's dirty state.
- */
-static GtkWidget *
-build_two_radio_group (char *title,
- char *radio_1_title, GtkWidget **radio_1_widget,
- char *radio_2_title, GtkWidget **radio_2_widget,
- int radio_1_value)
-{
- GtkWidget *frame;
- GtkWidget *vbox;
-
- frame = gtk_frame_new (title);
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
-
- *radio_1_widget = gtk_radio_button_new_with_label (NULL, radio_1_title);
- gtk_box_pack_start (GTK_BOX (vbox), *radio_1_widget, FALSE, FALSE, 0);
-
- *radio_2_widget = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (*radio_1_widget),
- radio_2_title);
- gtk_box_pack_start (GTK_BOX (vbox), *radio_2_widget, FALSE, FALSE, 0);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_1_widget), radio_1_value);
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_2_widget), !radio_1_value);
-
- gtk_signal_connect (GTK_OBJECT (*radio_1_widget), "toggled",
- (GtkSignalFunc) prop_changed,
- NULL);
-
- return frame;
-}
-
-/* Callback invoked when a menu item from the start/end time option menus is selected. It adjusts
- * the other menu to the proper time, if needed.
- */
-static void
-hour_activated (GtkWidget *widget, gpointer data)
-{
- int start, end;
-
- if (data == start_omenu) {
- /* Adjust the end menu */
-
- start = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget)));
- end = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (end_omenu)));
-
- if (end < start)
- gtk_option_menu_set_history (GTK_OPTION_MENU (end_omenu), start);
- } else if (data == end_omenu) {
- /* Adjust the start menu */
-
- end = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget)));
- start = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (start_omenu)));
-
- if (start > end)
- gtk_option_menu_set_history (GTK_OPTION_MENU (start_omenu), end);
- } else
- g_assert_not_reached ();
-
- gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
-}
-
-/* Builds an option menu of 24 hours */
-static GtkWidget *
-build_hours_menu (GtkWidget **items, int active)
-{
- GtkWidget *omenu;
- GtkWidget *menu;
- int i;
- char buf[100];
- struct tm tm;
- int am_pm_flag;
-
- omenu = gtk_option_menu_new ();
- menu = gtk_menu_new ();
- am_pm_flag = GTK_TOGGLE_BUTTON (time_format_12)->active;
-
- memset (&tm, 0, sizeof (tm));
-
- for (i = 0; i < 24; i++) {
- tm.tm_hour = i;
- if (am_pm_flag)
- strftime (buf, 100, "%I:%M %p", &tm);
- else
- strftime (buf, 100, "%H:%M", &tm);
-
- items[i] = gtk_menu_item_new_with_label (buf);
- gtk_object_set_user_data (GTK_OBJECT (items[i]), GINT_TO_POINTER (i));
- gtk_signal_connect (GTK_OBJECT (items[i]), "activate",
- (GtkSignalFunc) hour_activated,
- omenu);
-
- gtk_menu_append (GTK_MENU (menu), items[i]);
- gtk_widget_show (items[i]);
- }
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
- gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), active);
- return omenu;
-}
-
-/* Creates the time display page in the preferences dialog */
-static void
-create_time_display_page (void)
-{
- GtkWidget *table;
- GtkWidget *vbox;
- GtkWidget *frame;
- GtkWidget *hbox2;
- GtkWidget *hbox3;
- GtkWidget *w;
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (table), GNOME_PAD_SMALL);
- gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
- gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
- gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), table,
- gtk_label_new (_("Time display")));
-
- /* Time format */
-
- w = build_two_radio_group (_("Time format"),
- _("12-hour (AM/PM)"), &time_format_12,
- _("24-hour"), &time_format_24,
- am_pm_flag);
- gtk_table_attach (GTK_TABLE (table), w,
- 0, 1, 0, 1,
- GTK_EXPAND | GTK_FILL,
- GTK_EXPAND | GTK_FILL,
- 0, 0);
-
- /* Weeks start on */
-
- w = build_two_radio_group (_("Weeks start on"),
- _("Sunday"), &start_on_sunday,
- _("Monday"), &start_on_monday,
- !week_starts_on_monday);
- gtk_table_attach (GTK_TABLE (table), w,
- 0, 1, 1, 2,
- GTK_EXPAND | GTK_FILL,
- GTK_EXPAND | GTK_FILL,
- 0, 0);
-
- /* Day range */
-
- frame = gtk_frame_new (_("Day range"));
- gtk_table_attach (GTK_TABLE (table), frame,
- 1, 2, 0, 2,
- GTK_EXPAND | GTK_FILL,
- GTK_EXPAND | GTK_FILL,
- 0, 0);
-
- vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
-
- w = gtk_label_new (_("Please select the start and end hours you want\n"
- "to be displayed in the day view and week view.\n"
- "Times outside this range will not be displayed\n"
- "by default."));
- gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT);
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
-
- hbox2 = gtk_hbox_new (FALSE, GNOME_PAD);
- gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
-
- /* Day start */
-
- hbox3 = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
- gtk_box_pack_start (GTK_BOX (hbox2), hbox3, FALSE, FALSE, 0);
-
- w = gtk_label_new (_("Day start:"));
- gtk_box_pack_start (GTK_BOX (hbox3), w, FALSE, FALSE, 0);
-
- start_omenu = build_hours_menu (start_items, day_begin);
- gtk_box_pack_start (GTK_BOX (hbox3), start_omenu, FALSE, FALSE, 0);
-
- /* Day end */
-
- hbox3 = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
- gtk_box_pack_start (GTK_BOX (hbox2), hbox3, FALSE, FALSE, 0);
-
- w = gtk_label_new (_("Day end:"));
- gtk_box_pack_start (GTK_BOX (hbox3), w, FALSE, FALSE, 0);
-
- end_omenu = build_hours_menu (end_items, day_end);
- gtk_box_pack_start (GTK_BOX (hbox3), end_omenu, FALSE, FALSE, 0);
-}
-
-/* Called when the canvas for the month item is size allocated. We use this to change the canvas'
- * scrolling region and the month item's size.
- */
-static void
-canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data)
-{
- gnome_canvas_item_set (month_item,
- "width", (double) (allocation->width - 1),
- "height", (double) (allocation->height - 1),
- NULL);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (widget),
- 0, 0,
- allocation->width, allocation->height);
-}
-
-/* Returns a color spec based on the color pickers */
-static char *
-color_spec_from_picker (int num)
-{
- gushort r, g, b;
-
- gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[num]), &r, &g, &b, NULL);
-
- return build_color_spec (r, g, b);
-}
-
-/* Callback used to query color information for the properties box */
-static char *
-fetch_color_spec (ColorProp propnum, gpointer data)
-{
- return color_spec_from_picker (propnum);
-}
-
-/* Marks fake event days in the month item sample */
-static void
-fake_mark_days (void)
-{
- static int day_nums[] = { 1, 4, 8, 16, 17, 18, 20, 25, 28 }; /* some random days */
- int first_day_index;
- int i;
-
- first_day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (month_item), 1);
-
- for (i = 0; i < (sizeof (day_nums) / sizeof (day_nums[0])); i++)
- mark_month_item_index (GNOME_MONTH_ITEM (month_item), first_day_index + day_nums[i] - 1,
- fetch_color_spec, NULL);
-}
-
-/* Switches the month item to the current date and highlights the current day's number */
-static void
-set_current_day (void)
-{
- struct tm tm;
- time_t t;
- GnomeCanvasItem *item;
- int day_index;
-
- /* Set the date */
-
- t = time (NULL);
- tm = *localtime (&t);
-
- gnome_canvas_item_set (month_item,
- "year", tm.tm_year + 1900,
- "month", tm.tm_mon,
- NULL);
-
- /* Highlight current day */
-
- day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (month_item), tm.tm_mday);
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (month_item), GNOME_MONTH_ITEM_DAY_LABEL + day_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_picker (COLOR_PROP_CURRENT_DAY_FG),
- "fontset", CURRENT_DAY_FONTSET,
- NULL);
-}
-
-/* This is the version of a color spec query function that is appropriate for the preferences dialog */
-static char *
-prop_color_func (ColorProp propnum, gpointer data)
-{
- return color_spec_from_picker (propnum);
-}
-
-/* Sets the colors of the month item to the current prerences */
-static void
-reconfigure_month (void)
-{
- colorify_month_item (GNOME_MONTH_ITEM (month_item), prop_color_func, NULL);
- fake_mark_days ();
- set_current_day ();
-
- /* Reset prelighting information */
-
- month_item_prepare_prelight (GNOME_MONTH_ITEM (month_item), fetch_color_spec, NULL);
-}
-
-/* Callback used when a color is changed */
-static void
-color_set (void)
-{
- reconfigure_month ();
- prop_changed ();
-}
-
-/* Creates the colors page in the preferences dialog */
-static void
-create_colors_page (void)
-{
- GtkWidget *frame;
- GtkWidget *hbox;
- GtkWidget *table;
- GtkWidget *w;
- int i;
-
- frame = gtk_frame_new (_("Colors for display"));
- gtk_container_set_border_width (GTK_CONTAINER (frame), GNOME_PAD_SMALL);
- gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), frame,
- gtk_label_new (_("Colors")));
-
- hbox = gtk_hbox_new (FALSE, GNOME_PAD);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
- gtk_container_add (GTK_CONTAINER (frame), hbox);
-
- table = gtk_table_new (COLOR_PROP_LAST, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
- gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);
-
- /* Create the color pickers */
-
- for (i = 0; i < COLOR_PROP_LAST; i++) {
- /* Label */
-
- w = gtk_label_new (_(color_props[i].label));
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (table), w,
- 0, 1, i, i + 1,
- GTK_FILL, 0,
- 0, 0);
-
- /* Color picker */
-
- color_pickers[i] = gnome_color_picker_new ();
- gnome_color_picker_set_title (GNOME_COLOR_PICKER (color_pickers[i]), _(color_props[i].label));
- gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (color_pickers[i]),
- color_props[i].r, color_props[i].g, color_props[i].b, 0);
- gtk_table_attach (GTK_TABLE (table), color_pickers[i],
- 1, 2, i, i + 1,
- 0, 0,
- 0, 0);
- gtk_signal_connect (GTK_OBJECT (color_pickers[i]), "color_set",
- (GtkSignalFunc) color_set,
- NULL);
- }
-
- /* Create the sample calendar */
-
- w = gnome_canvas_new ();
- gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
-
- month_item = gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (w)));
- gnome_canvas_item_set (month_item,
- "start_on_monday", week_starts_on_monday,
- NULL);
- reconfigure_month ();
-
- gtk_signal_connect (GTK_OBJECT (w), "size_allocate",
- canvas_size_allocate,
- NULL);
-
-}
-
-
-static void
-set_todo_page_options(void)
-{
-
-
- while (gtk_events_pending ())
- gtk_main_iteration ();
-}
-
-static void
-todo_option_set (void)
-{
- prop_changed ();
- set_todo_page_options ();
-}
-
-/* Creates the colors page in the preferences dialog */
-static GtkWidget *
-build_list_options_frame(void)
-{
- GtkWidget *frame;
- GtkWidget *vbox;
- frame = gtk_frame_new (_("Show on TODO List:"));
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
-
- due_date_show_button = gtk_check_button_new_with_label (_("Due Date"));
- priority_show_button = gtk_check_button_new_with_label (_("Priority"));
- todo_item_time_remaining_show_button = gtk_check_button_new_with_label (_("Time Until Due"));
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(due_date_show_button), todo_show_due_date);
- gtk_signal_connect (GTK_OBJECT(due_date_show_button),
- "clicked",
- (GtkSignalFunc) todo_option_set,
- NULL);
- gtk_box_pack_start (GTK_BOX (vbox), due_date_show_button, FALSE, FALSE, 0);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_time_remaining_show_button), todo_show_time_remaining);
- gtk_signal_connect (GTK_OBJECT(todo_item_time_remaining_show_button),
- "clicked",
- (GtkSignalFunc) todo_option_set,
- NULL);
- gtk_box_pack_start (GTK_BOX (vbox), todo_item_time_remaining_show_button, FALSE, FALSE, 0);
-
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(priority_show_button), todo_show_priority);
- gtk_signal_connect (GTK_OBJECT(priority_show_button),
- "clicked",
- (GtkSignalFunc) todo_option_set,
- NULL);
- gtk_box_pack_start (GTK_BOX (vbox), priority_show_button, FALSE, FALSE, 0);
- return frame;
-}
-static GtkWidget *
-build_style_list_options_frame(void)
-{
- GtkWidget *frame;
- GtkWidget *vbox;
-
- frame = gtk_frame_new (_("To Do List style options:"));
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
-
- todo_item_highlight_overdue = gtk_check_button_new_with_label (_("Highlight overdue items"));
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_highlight_overdue),
- todo_item_dstatus_highlight_overdue);
- todo_item_highlight_not_due_yet = gtk_check_button_new_with_label (_("Highlight not yet due items"));
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_highlight_not_due_yet),
- todo_item_dstatus_highlight_overdue);
- todo_item_highlight_due_today = gtk_check_button_new_with_label (_("Highlight items due today"));
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_highlight_due_today),
- todo_item_dstatus_highlight_overdue);
-
- gtk_signal_connect (GTK_OBJECT(todo_item_highlight_overdue),
- "clicked",
- (GtkSignalFunc) todo_option_set,
- NULL);
- gtk_signal_connect (GTK_OBJECT(todo_item_highlight_not_due_yet),
- "clicked",
- (GtkSignalFunc) todo_option_set,
- NULL);
- gtk_signal_connect (GTK_OBJECT(todo_item_highlight_due_today),
- "clicked",
- (GtkSignalFunc) todo_option_set,
- NULL);
-
- gtk_box_pack_start (GTK_BOX (vbox), todo_item_highlight_overdue, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), todo_item_highlight_due_today, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), todo_item_highlight_not_due_yet, FALSE, FALSE, 0);
- return frame;
-}
-static void
-create_todo_page (void)
-{
- GtkWidget *frame;
- GtkWidget *main_box;
- GtkWidget *hbox;
-
-
- frame = gtk_frame_new (_("To Do List Properties"));
- gtk_container_set_border_width (GTK_CONTAINER (frame), GNOME_PAD_SMALL);
- gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), frame,
- gtk_label_new (_("To Do List")));
-
- /* first vbox*/
- main_box = gtk_vbox_new(FALSE, GNOME_PAD);
- gtk_container_set_border_width (GTK_CONTAINER (main_box), GNOME_PAD_SMALL);
- gtk_container_add (GTK_CONTAINER (frame), main_box);
-
-
- /* first hbox*/
- hbox = gtk_hbox_new (FALSE, GNOME_PAD);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
- gtk_container_add (GTK_CONTAINER (main_box), hbox);
-
- gtk_box_pack_start (GTK_BOX(hbox), build_list_options_frame(), FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX(hbox), build_style_list_options_frame(), FALSE, FALSE, 0);
-
- set_todo_page_options();
-}
-
-/* Creates and displays the preferences dialog for the whole application */
-void
-properties (GtkWidget *toplevel)
-{
- static GnomeHelpMenuEntry help_entry = { NULL, "properties" };
-
- help_entry.name = gnome_app_id;
-
- if (prop_win)
- return;
-
- prop_win = gnome_property_box_new ();
- gtk_window_set_title (GTK_WINDOW (prop_win), _("Preferences"));
- gnome_dialog_set_parent (GNOME_DIALOG (prop_win), GTK_WINDOW (toplevel));
-
- create_time_display_page ();
- create_colors_page ();
- create_todo_page ();
- create_alarm_page ();
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "destroy",
- (GtkSignalFunc) prop_cancel, NULL);
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "delete_event",
- (GtkSignalFunc) prop_cancel, NULL);
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "apply",
- (GtkSignalFunc) prop_apply, NULL);
-
- gtk_signal_connect (GTK_OBJECT (prop_win), "help",
- GTK_SIGNAL_FUNC (gnome_help_pbox_display),
- &help_entry);
-
- gtk_widget_show_all (prop_win);
-}
-
-char *
-build_color_spec (int r, int g, int b)
-{
- static char spec[100];
-
- sprintf (spec, "#%04x%04x%04x", r, g, b);
- return spec;
-}
-
-void
-parse_color_spec (char *spec, int *r, int *g, int *b)
-{
- g_return_if_fail (spec != NULL);
- g_return_if_fail (r != NULL);
- g_return_if_fail (r != NULL);
- g_return_if_fail (r != NULL);
-
- if (sscanf (spec, "#%04x%04x%04x", r, g, b) != 3) {
- g_warning ("Invalid color specification %s, returning black", spec);
-
- *r = *g = *b = 0;
- }
-}
-
-char *
-color_spec_from_prop (ColorProp propnum)
-{
- return build_color_spec (color_props[propnum].r, color_props[propnum].g, color_props[propnum].b);
-}
-
-static void
-create_alarm_page (void)
-{
- GtkWidget *main_box;
- GtkWidget *default_frame;
- GtkWidget *default_table;
- GtkWidget *misc_frame;
- GtkWidget *misc_box;
- GtkWidget *box, *l;
-
- main_box = gtk_vbox_new (FALSE, GNOME_PAD);
- gtk_container_set_border_width (GTK_CONTAINER (main_box), GNOME_PAD_SMALL);
- gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win),
- main_box, gtk_label_new (_("Alarms")));
-
- /* build miscellaneous box */
- misc_frame = gtk_frame_new (_("Alarm Properties"));
- gtk_container_set_border_width (GTK_CONTAINER (misc_frame),
- GNOME_PAD_SMALL);
- misc_box = gtk_vbox_new (FALSE, GNOME_PAD);
-
- gtk_container_set_border_width (GTK_CONTAINER (misc_frame), GNOME_PAD_SMALL);
- gtk_container_add (GTK_CONTAINER (misc_frame), misc_box);
-
- gtk_box_pack_start (GTK_BOX (main_box), misc_frame, FALSE, FALSE, 0);
-
- enable_display_beep = gtk_check_button_new_with_label (_("Beep on display alarms"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enable_display_beep),
- beep_on_display);
- gtk_box_pack_start (GTK_BOX (misc_box), enable_display_beep, FALSE, FALSE, 0);
- gtk_signal_connect (GTK_OBJECT (enable_display_beep), "toggled",
- (GtkSignalFunc) prop_changed,
- NULL);
-
- /* audio timeout widgets */
- box = gtk_hbox_new (FALSE, GNOME_PAD);
- to_cb = gtk_check_button_new_with_label (_("Audio alarms timeout after"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (to_cb),
- enable_aalarm_timeout);
- gtk_signal_connect (GTK_OBJECT (to_cb), "toggled",
- (GtkSignalFunc) to_cb_changed, NULL);
- gtk_box_pack_start (GTK_BOX (box), to_cb, FALSE, FALSE, 0);
- to_spin = make_spin_button (audio_alarm_timeout, 1, MAX_AALARM_TIMEOUT);
- gtk_widget_set_sensitive (to_spin, enable_aalarm_timeout);
- gtk_signal_connect (GTK_OBJECT (to_spin), "changed",
- (GtkSignalFunc) prop_changed, NULL);
- gtk_box_pack_start (GTK_BOX (box), to_spin, FALSE, FALSE, 0);
- l = gtk_label_new (_(" seconds"));
- gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (misc_box), box, FALSE, FALSE, 0);
-
- /* snooze widgets */
- box = gtk_hbox_new (FALSE, GNOME_PAD);
- snooze_cb = gtk_check_button_new_with_label (_("Enable snoozing for "));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (snooze_cb),
- enable_snooze);
- gtk_signal_connect (GTK_OBJECT (snooze_cb), "toggled",
- (GtkSignalFunc) snooze_cb_changed, NULL);
- gtk_box_pack_start (GTK_BOX (box), snooze_cb, FALSE, FALSE, 0);
- snooze_spin = make_spin_button (snooze_secs, 1, MAX_SNOOZE_SECS);
- gtk_widget_set_sensitive (snooze_spin, enable_snooze);
- gtk_signal_connect (GTK_OBJECT (snooze_spin), "changed",
- (GtkSignalFunc) prop_changed, NULL);
- gtk_box_pack_start (GTK_BOX (box), snooze_spin, FALSE, FALSE, 0);
- l = gtk_label_new (_(" seconds"));
- gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (misc_box), box, FALSE, FALSE, 0);
-
- /* populate default frame/box */
- default_frame = gtk_frame_new (_("Defaults"));
- gtk_container_set_border_width (GTK_CONTAINER (default_frame), GNOME_PAD_SMALL);
- gtk_box_pack_start (GTK_BOX (main_box), default_frame, FALSE, FALSE, 0);
- default_table = gtk_table_new (1, 1, 0);
- gtk_container_set_border_width (GTK_CONTAINER (default_table), 4);
- gtk_table_set_row_spacings (GTK_TABLE (default_table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (default_table), 4);
- gtk_container_add (GTK_CONTAINER (default_frame), default_table);
-
- ee_create_ae (GTK_TABLE (default_table), _("Display"),
- &alarm_defaults [ALARM_DISPLAY], ALARM_DISPLAY, 1,
- FALSE, prop_changed);
- ee_create_ae (GTK_TABLE (default_table), _("Audio"),
- &alarm_defaults [ALARM_AUDIO], ALARM_AUDIO, 2,
- FALSE, prop_changed);
- ee_create_ae (GTK_TABLE (default_table), _("Program"),
- &alarm_defaults [ALARM_PROGRAM], ALARM_PROGRAM, 3,
- FALSE, prop_changed);
- ee_create_ae (GTK_TABLE (default_table), _("Mail"),
- &alarm_defaults [ALARM_MAIL], ALARM_MAIL, 4,
- FALSE, prop_changed);
-}
-
-static void
-prop_store_alarm_default_values (CalendarAlarm* alarm)
-{
- ee_store_alarm (alarm, alarm->type);
-
- switch (alarm->type) {
- case ALARM_DISPLAY:
- gnome_config_push_prefix ("/calendar/alarms/def_disp_");
- break;
- case ALARM_AUDIO:
- gnome_config_push_prefix ("/calendar/alarms/def_audio_");
- break;
- case ALARM_PROGRAM:
- gnome_config_push_prefix ("/calendar/alarms/def_prog_");
- break;
- case ALARM_MAIL:
- gnome_config_push_prefix ("/calendar/alarms/def_mail_");
- break;
- }
-
- gnome_config_set_int ("enabled", alarm->enabled);
- gnome_config_set_int ("count", alarm->count);
- gnome_config_set_int ("units", alarm->units);
- if (alarm->data)
- gnome_config_set_string ("data", alarm->data);
-
- gnome_config_pop_prefix ();
- gnome_config_sync ();
-}
-
-static void
-prop_apply_alarms ()
-{
- int i;
- for (i=0; i < 4; i++)
- prop_store_alarm_default_values (&alarm_defaults [i]);
-
- beep_on_display = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enable_display_beep));
- gnome_config_set_bool ("/calendar/alarms/beep_on_display", beep_on_display);
- enable_aalarm_timeout = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (to_cb));
- gnome_config_set_bool ("/calendar/alarms/enable_audio_timeout", enable_aalarm_timeout);
- audio_alarm_timeout = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (to_spin));
- gnome_config_set_int ("/calendar/alarms/audio_alarm_timeout", audio_alarm_timeout);
- enable_snooze = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (snooze_cb));
- gnome_config_set_bool ("/calendar/alarms/enable_snooze", enable_snooze);
- snooze_secs = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (snooze_spin));
- gnome_config_set_int ("/calendar/alarms/snooze_secs", snooze_secs);
-
- gnome_config_sync();
-}
-
-static void
-to_cb_changed (GtkWidget *object, gpointer data)
-{
- gboolean active =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (to_cb));
- gtk_widget_set_sensitive (to_spin, active);
- prop_changed ();
-}
-
-static void
-snooze_cb_changed (GtkWidget *object, gpointer data)
-{
- gboolean active =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (snooze_cb));
- gtk_widget_set_sensitive (snooze_spin, active);
- prop_changed ();
-}
-
-
diff --git a/calendar/quick-view.c b/calendar/quick-view.c
deleted file mode 100644
index c23ed612c0..0000000000
--- a/calendar/quick-view.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/* Quick view widget for Gnomecal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx
- */
-
-#include <config.h>
-#include "quick-view.h"
-#include "main.h"
-
-
-#define QUICK_VIEW_FONTSET "-adobe-helvetica-medium-r-normal--10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*"
-
-
-static void quick_view_class_init (QuickViewClass *class);
-static void quick_view_init (QuickView *qv);
-
-static gint quick_view_button_release (GtkWidget *widget, GdkEventButton *event);
-static gint quick_view_map_event (GtkWidget *widget, GdkEventAny *event);
-
-
-static GtkWindowClass *parent_class;
-
-
-GtkType
-quick_view_get_type (void)
-{
- static GtkType quick_view_type = 0;
-
- if (!quick_view_type) {
- GtkTypeInfo quick_view_info = {
- "QuickView",
- sizeof (QuickView),
- sizeof (QuickViewClass),
- (GtkClassInitFunc) quick_view_class_init,
- (GtkObjectInitFunc) quick_view_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- quick_view_type = gtk_type_unique (gtk_window_get_type (), &quick_view_info);
- }
-
- return quick_view_type;
-}
-
-static void
-quick_view_class_init (QuickViewClass *class)
-{
- GtkWidgetClass *widget_class;
-
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gtk_window_get_type ());
-
- widget_class->button_release_event = quick_view_button_release;
- widget_class->map_event = quick_view_map_event;
-}
-
-static void
-quick_view_init (QuickView *qv)
-{
- GTK_WINDOW (qv)->type = GTK_WINDOW_POPUP;
- gtk_window_set_position (GTK_WINDOW (qv), GTK_WIN_POS_MOUSE);
-}
-
-static gint
-quick_view_button_release (GtkWidget *widget, GdkEventButton *event)
-{
- QuickView *qv;
-
- qv = QUICK_VIEW (widget);
-
- if (event->button != qv->button)
- return FALSE;
-
- gdk_pointer_ungrab (event->time);
- gtk_grab_remove (GTK_WIDGET (qv));
- gtk_widget_hide (GTK_WIDGET (qv));
-
- gtk_main_quit (); /* End modality of the quick view */
- return TRUE;
-}
-
-static gint
-quick_view_map_event (GtkWidget *widget, GdkEventAny *event)
-{
- GdkCursor *cursor;
-
- cursor = gdk_cursor_new (GDK_ARROW);
- gdk_pointer_grab (widget->window,
- TRUE,
- GDK_BUTTON_RELEASE_MASK,
- NULL,
- cursor,
- GDK_CURRENT_TIME);
- gdk_cursor_destroy (cursor);
-
- return FALSE;
-}
-
-/* Creates the items corresponding to a single calendar object. Takes in the y position of the
- * items to create and returns the y position of the next item to create. Also takes in the current
- * maximum width for items and returns the new maximum width.
- */
-void
-create_items_for_event (QuickView *qv, CalendarObject *co, double *y, double *max_width)
-{
- GnomeCanvas *canvas;
- GnomeCanvasItem *item;
- char start[100], end[100];
- struct tm start_tm, end_tm;
- char *str;
- GtkArg args[2];
-
- /* FIXME: make this nice */
-
- canvas = GNOME_CANVAS (qv->canvas);
-
- start_tm = *localtime (&co->ev_start);
- end_tm = *localtime (&co->ev_end);
-
- if (am_pm_flag) {
- strftime (start, sizeof (start), "%I:%M%p", &start_tm);
- strftime (end, sizeof (end), "%I:%M%p", &end_tm);
- } else {
- strftime (start, sizeof (start), "%H:%M", &start_tm);
- strftime (end, sizeof (end), "%H:%M", &end_tm);
- }
-
- str = g_strconcat (start, " - ", end, " ", co->ico->summary, NULL);
-
- item = gnome_canvas_item_new (gnome_canvas_root (canvas),
- gnome_canvas_text_get_type (),
- "x", 0.0,
- "y", *y,
- "anchor", GTK_ANCHOR_NW,
- "text", str,
- "fontset", QUICK_VIEW_FONTSET,
- NULL);
-
- g_free (str);
-
- /* Measure the text and return the proper size values */
-
- args[0].name = "text_width";
- args[1].name = "text_height";
- gtk_object_getv (GTK_OBJECT (item), 2, args);
-
- if (GTK_VALUE_DOUBLE (args[0]) > *max_width)
- *max_width = GTK_VALUE_DOUBLE (args[0]);
-
- *y += GTK_VALUE_DOUBLE (args[1]);
-}
-
-/* Creates the canvas items corresponding to the events in the list */
-static void
-setup_event_list (QuickView *qv, GList *event_list)
-{
- CalendarObject *co;
- GnomeCanvasItem *item;
- GtkArg args[2];
- double y, max_width;
-
- /* If there are no events, then just put a simple label */
-
- if (!event_list) {
- item = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (qv->canvas)),
- gnome_canvas_text_get_type (),
- "x", 0.0,
- "y", 0.0,
- "anchor", GTK_ANCHOR_NW,
- "text", _("No appointments for this day"),
- "fontset", QUICK_VIEW_FONTSET,
- NULL);
-
- /* Measure the text and set the proper sizes */
-
- args[0].name = "text_width";
- args[1].name = "text_height";
- gtk_object_getv (GTK_OBJECT (item), 2, args);
-
- y = GTK_VALUE_DOUBLE (args[1]);
- max_width = GTK_VALUE_DOUBLE (args[0]);
- } else {
- /* Create the items for all the events in the list */
-
- y = 0.0;
- max_width = 0.0;
-
- for (; event_list; event_list = event_list->next) {
- co = event_list->data;
- create_items_for_event (qv, co, &y, &max_width);
- }
- }
-
- /* Set the scrolling region to fit all the items */
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (qv->canvas),
- 0.0, 0.0,
- max_width, y);
-
- gtk_widget_set_usize (qv->canvas, max_width, y);
-}
-
-GtkWidget *
-quick_view_new (GnomeCalendar *calendar, char *title, GList *event_list)
-{
- QuickView *qv;
- GtkWidget *vbox;
- GtkWidget *w;
-
- g_return_val_if_fail (calendar != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CALENDAR (calendar), NULL);
-
- qv = gtk_type_new (quick_view_get_type ());
- qv->calendar = calendar;
-
- /* Create base widgets for the popup window */
-
- w = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (w), GTK_SHADOW_ETCHED_OUT);
- gtk_container_add (GTK_CONTAINER (qv), w);
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (w), vbox);
-
- w = gtk_label_new (title);
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
-
- w = gtk_hseparator_new ();
- gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
-
- w = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
- gtk_container_set_border_width (GTK_CONTAINER (w), GNOME_PAD_SMALL);
- gtk_box_pack_start (GTK_BOX (vbox), w, TRUE, TRUE, 0);
-
- gtk_widget_push_visual (gdk_imlib_get_visual ());
- gtk_widget_push_colormap (gdk_imlib_get_colormap ());
-
- qv->canvas = gnome_canvas_new ();
-
- gtk_widget_pop_colormap ();
- gtk_widget_pop_visual ();
-
- gtk_container_add (GTK_CONTAINER (w), qv->canvas);
-
- /* Set up the event list */
-
- setup_event_list (qv, event_list);
-
- return GTK_WIDGET (qv);
-}
-
-void
-quick_view_do_popup (QuickView *qv, GdkEventButton *event)
-{
- g_return_if_fail (qv != NULL);
- g_return_if_fail (IS_QUICK_VIEW (qv));
- g_return_if_fail (event != NULL);
-
- /* Pop up the window */
-
- gtk_widget_show_all (GTK_WIDGET (qv));
- gtk_grab_add (GTK_WIDGET (qv));
-
- qv->button = event->button;
-
- gtk_main (); /* Begin modality */
-
- /* The button release event handler will call gtk_main_quit() */
-}
diff --git a/calendar/quick-view.h b/calendar/quick-view.h
deleted file mode 100644
index c6b2cf8814..0000000000
--- a/calendar/quick-view.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Quick view widget for Gnomecal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx
- */
-
-#ifndef QUICK_VIEW_H
-#define QUICK_VIEW_H
-
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define TYPE_QUICK_VIEW (quick_view_get_type ())
-#define QUICK_VIEW(obj) (GTK_CHECK_CAST ((obj), TYPE_QUICK_VIEW, QuickView))
-#define QUICK_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_QUICK_VIEW, QuickViewClass))
-#define IS_QUICK_VIEW(obj) (GTK_CHECK_TYPE ((obj), TYPE_QUICK_VIEW))
-#define IS_QUICK_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_QUICK_VIEW))
-
-
-typedef struct _QuickView QuickView;
-typedef struct _QuickViewClass QuickViewClass;
-
-struct _QuickView {
- GtkWindow window;
-
- GnomeCalendar *calendar; /* The calendar we are associated to */
-
- GtkWidget *canvas; /* The canvas that displays the contents of the quick view */
-
- int button; /* The button that was pressed to pop up the quick view */
-};
-
-struct _QuickViewClass {
- GtkWindowClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType quick_view_get_type (void);
-
-/* Creates a new quick view with the specified title and the specified event list. It is associated
- * to the specified calendar. The event list must be a list of CalendarObject structures.
- */
-GtkWidget *quick_view_new (GnomeCalendar *calendar, char *title, GList *event_list);
-
-/* Pops up the quick view widget modally and loops until the uses closes it by releasing the mouse
- * button. You can destroy the quick view when this function returns.
- */
-void quick_view_do_popup (QuickView *qv, GdkEventButton *event);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/recur.xpm b/calendar/recur.xpm
deleted file mode 100644
index 49836b62e7..0000000000
--- a/calendar/recur.xpm
+++ /dev/null
@@ -1,83 +0,0 @@
-/* XPM */
-static char * recur_xpm[] = {
-"16 16 64 1",
-" c None",
-". c #350000",
-"+ c #2A0000",
-"@ c #1B0000",
-"# c #280000",
-"$ c #430000",
-"% c #090000",
-"& c #160000",
-"* c #250000",
-"= c #460000",
-"- c #550000",
-"; c #610000",
-"> c #0D0000",
-", c #1F0000",
-"' c #4B0000",
-") c #5E0000",
-"! c #6B0000",
-"~ c #750000",
-"{ c #790000",
-"] c #810000",
-"^ c #FFFF83",
-"/ c #FFFF89",
-"( c #FFFF93",
-"_ c #8B0000",
-": c #900000",
-"< c #930000",
-"[ c #FFFF62",
-"} c #A10000",
-"| c #FFFF41",
-"1 c #FFFF3B",
-"2 c #FFFF31",
-"3 c #B70000",
-"4 c #B20000",
-"5 c #AE0000",
-"6 c #FFFF22",
-"7 c #FFFF16",
-"8 c #FFFF06",
-"9 c #C90000",
-"0 c #C10000",
-"a c #BB0000",
-"b c #FFF600",
-"c c #FFE100",
-"d c #FFC500",
-"e c #E40000",
-"f c #D70000",
-"g c #CD0000",
-"h c #FFDB00",
-"i c #FFA900",
-"j c #FF8500",
-"k c #FF5900",
-"l c #FF2800",
-"m c #FC0000",
-"n c #ED0000",
-"o c #E10000",
-"p c #FFAF00",
-"q c #FF9400",
-"r c #FF7400",
-"s c #FF5000",
-"t c #FF0100",
-"u c #F30000",
-"v c #E80000",
-"w c #FF6900",
-"x c #FF4900",
-"y c #FF0800",
-" ",
-" . ",
-" +. ",
-" @#.$ ",
-" %&*.=-; ",
-" >,.')!~ ",
-" &. !{] ",
-" ^/( . _:< ",
-" [[[ }}} ",
-" |12 345 ",
-" 678 90a ",
-" bcd efg ",
-" hdijklmnof ",
-" pqrsltuv ",
-" wxly ",
-" "};
diff --git a/calendar/test.vcf b/calendar/test.vcf
deleted file mode 100644
index bfe93b3c14..0000000000
--- a/calendar/test.vcf
+++ /dev/null
@@ -1,133 +0,0 @@
-BEGIN:VCALENDAR
-PRODID:-//GNOME//NONSGML GnomeCalendar//EN
-TZ:MST
-VERSION:0.13
-BEGIN:VEVENT
-UID:KOrganizer - 846930886
-SEQUENCE:1
-DTSTART:19980601T150000
-DTEND:19980601T150000
-DCREATED:19980402T023558
-LAST-MODIFIED:19980402T023558
-SUMMARY:Cada dos dias de 06/01 al 07/01
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:D2 19980701T140000
-END:VEVENT
-
-BEGIN:VEVENT
-UID:KOrganizer - 846930886
-SEQUENCE:1
-DTSTART:19980501T140000
-DTEND:19980501T140000
-DCREATED:19980402T023558
-LAST-MODIFIED:19980402T023558
-SUMMARY:5 dias.
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:D1 #5
-END:VEVENT
-
-BEGIN:VEVENT
-UID:KOrganizer - 846930886
-SEQUENCE:1
-DTSTART:19980501T140000
-DTEND:19980501T150000
-DCREATED:19980402T023558
-LAST-MODIFIED:19980429T004635
-SUMMARY:Diariamente de 05/01 al 06/01
-STATUS:NEEDS ACTION
-CLASS:PRIVATE
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:D1 19980601T000000
-END:VEVENT
-
-BEGIN:VEVENT
-UID:KOrganizer - 1804289383
-SEQUENCE:1
-DTSTART:19980415T010000
-DTEND:19980415T013000
-DCREATED:19980402T023552
-LAST-MODIFIED:19980330T225948
-SUMMARY:Diario durante 5 dias
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:D1 #5
-END:VEVENT
-
-BEGIN:VEVENT
-UID:KOrganizer - 1804289383
-SEQUENCE:1
-DTSTART:19980415T010000
-DTEND:19980415T013000
-DCREATED:19980402T023552
-LAST-MODIFIED:19980330T225948
-SUMMARY:Diario durante 5 dias
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:D1 #5
-END:VEVENT
-
-BEGIN:VTODO
-UID:KOrganizer - 846930886
-SEQUENCE:1
-DTSTART:19980415T140000
-DUE:19691231T180000
-DCREATED:19980402T023558
-LAST-MODIFIED:19980402T023558
-SUMMARY:Normal
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-END:VTODO
-
-BEGIN:VTODO
-UID:KOrganizer - 1804289383
-SEQUENCE:1
-DTSTART:19980415T120000
-DUE:19691231T180000
-DCREATED:19980402T023552
-LAST-MODIFIED:19980330T225948
-SUMMARY:Semanal -- 4 semanas
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:W1 WE #4
-END:VTODO
-
-BEGIN:VTODO
-UID:KOrganizer - 1804289383
-SEQUENCE:1
-DTSTART:19980415T003000
-DUE:19691231T180000
-DCREATED:19980402T023552
-LAST-MODIFIED:19980330T225948
-SUMMARY:Semana: Mi, Ju, Vi, Dom (10 veces)
-STATUS:NEEDS ACTION
-CLASS:PUBLIC
-PRIORITY:0
-TRANSP:0
-RELATED-TO:0
-RRULE:W1 SU WE TH FR #10
-END:VTODO
-
-END:VCALENDAR
-
diff --git a/calendar/timeutil.c b/calendar/timeutil.c
deleted file mode 100644
index 7ddc0e04d4..0000000000
--- a/calendar/timeutil.c
+++ /dev/null
@@ -1,501 +0,0 @@
-/* Miscellaneous time-related utilities
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <federico@nuclecu.unam.mx>
- * Miguel de Icaza <miguel@nuclecu.unam.mx>
- */
-
-#include <libgnome/libgnome.h>
-#include <string.h>
-#include "timeutil.h"
-
-#define digit_at(x,y) (x [y] - '0')
-
-time_t
-time_from_isodate (char *str)
-{
- struct tm my_tm;
- time_t t;
-
- if (strlen (str) < 14)
- return -1;
-
- my_tm.tm_year = (digit_at (str, 0) * 1000 + digit_at (str, 1) * 100 +
- digit_at (str, 2) * 10 + digit_at (str, 3)) - 1900;
-
- my_tm.tm_mon = digit_at (str, 4) * 10 + digit_at (str, 5) - 1;
- my_tm.tm_mday = digit_at (str, 6) * 10 + digit_at (str, 7);
- my_tm.tm_hour = digit_at (str, 9) * 10 + digit_at (str, 10);
- my_tm.tm_min = digit_at (str, 11) * 10 + digit_at (str, 12);
- my_tm.tm_sec = digit_at (str, 13) * 10 + digit_at (str, 14);
- my_tm.tm_isdst = -1;
-
- t = mktime (&my_tm);
-
- if (str [15] == 'Z')
-#if defined(HAVE_TM_GMTOFF)
- t -= my_tm.tm_gmtoff
-#elsif defined(HAVE_TIMEZONE)
- t -= timezone
-#endif
- ;
-
- return t;
-}
-
-void
-print_time_t (time_t t)
-{
- struct tm *tm = localtime (&t);
-
- printf ("TIEMPO: %d/%d/%d %d:%d:%d\n",
- tm->tm_mon+1, tm->tm_mday, tm->tm_year,
- tm->tm_hour, tm->tm_min, tm->tm_sec);
-}
-
-int
-get_time_t_hour (time_t t)
-{
- struct tm *tm;
-
- tm = localtime (&t);
- return tm->tm_hour;
-}
-
-char *
-isodate_from_time_t (time_t t)
-{
- struct tm *tm;
- static char isotime [40];
-
- tm = localtime (&t);
- strftime (isotime, sizeof (isotime)-1, "%Y%m%dT%H%M%S", tm);
- return isotime;
-}
-
-time_t
-time_from_start_duration (time_t start, char *duration)
-{
- printf ("Not yet implemented\n");
- return 0;
-}
-
-char *
-format_simple_hour (int hour, int use_am_pm)
-{
- static char buf[256];
-
- /* I don't know whether this is the best way to internationalize it.
- * Does any language use different conventions? - Federico
- */
-
- if (use_am_pm)
- g_snprintf (buf, sizeof(buf), "%d%s",
- (hour == 0) ? 12 : (hour > 12) ? (hour - 12) : hour,
- (hour < 12) ? _("am") : _("pm"));
- else
- g_snprintf (buf, sizeof(buf), "%02d%s", hour, _("h"));
-
- return buf;
-
-}
-
-time_t
-time_add_minutes (time_t time, int minutes)
-{
- struct tm *tm = localtime (&time);
- time_t new_time;
-
- tm->tm_min += minutes;
- if ((new_time = mktime (tm)) == -1){
- g_warning ("mktime could not handling adding a day with\n");
- print_time_t (time);
- return time;
- }
- return new_time;
-}
-
-time_t
-time_add_day (time_t time, int days)
-{
- struct tm *tm = localtime (&time);
- time_t new_time;
- int dst_flag = tm->tm_isdst;
-
- tm->tm_mday += days;
-
- if ((new_time = mktime (tm)) == -1){
- g_warning ("mktime could not handling adding a day with\n");
- print_time_t (time);
- return time;
- }
-
- if (dst_flag > tm->tm_isdst){
- tm->tm_hour++;
- new_time += 3600;
- } else if (dst_flag < tm->tm_isdst){
- tm->tm_hour--;
- new_time -= 3600;
- }
-
- return new_time;
-}
-
-time_t
-time_add_week (time_t time, int weeks)
-{
- return time_add_day (time, weeks * 7);
-}
-
-time_t
-time_add_month (time_t time, int months)
-{
- struct tm *tm = localtime (&time);
- time_t new_time;
- int mday;
-
- mday = tm->tm_mday;
-
- tm->tm_mon += months;
- tm->tm_isdst = -1;
- if ((new_time = mktime (tm)) == -1){
- g_warning ("mktime could not handling adding a month with\n");
- print_time_t (time);
- return time;
- }
- tm = localtime (&new_time);
- if (tm->tm_mday < mday){
- tm->tm_mon--;
- tm->tm_mday = time_days_in_month (tm->tm_year+1900, tm->tm_mon);
- return new_time = mktime (tm);
- }
- else
- return new_time;
-}
-
-time_t
-time_add_year (time_t time, int years)
-{
- struct tm *tm = localtime (&time);
- time_t new_time;
-
- tm->tm_year += years;
- if ((new_time = mktime (tm)) == -1){
- g_warning ("mktime could not handling adding a year with\n");
- print_time_t (time);
- return time;
- }
- return new_time;
-}
-
-time_t
-time_day_hour (time_t t, int hour)
-{
- struct tm tm;
-
- tm = *localtime (&t);
- tm.tm_hour = hour;
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- return mktime (&tm);
-}
-
-/* Number of days in a month, for normal and leap years */
-static const int days_in_month[2][12] = {
- { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
- { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
-};
-
-/* Returns whether the specified year is a leap year */
-static int
-is_leap_year (int year)
-{
- if (year <= 1752)
- return !(year % 4);
- else
- return (!(year % 4) && (year % 100)) || !(year % 400);
-}
-
-int
-time_days_in_month (int year, int month)
-{
- g_return_val_if_fail (year >= 1900, 0);
- g_return_val_if_fail ((month >= 0) && (month < 12), 0);
-
- return days_in_month [is_leap_year (year)][month];
-}
-
-time_t
-time_from_day (int year, int month, int day)
-{
- struct tm tm;
-
- memset (&tm, 0, sizeof (tm));
- tm.tm_year = year - 1900;
- tm.tm_mon = month;
- tm.tm_mday = day;
-
- return mktime (&tm);
-}
-
-time_t
-time_year_begin (time_t t)
-{
- struct tm tm;
-
- tm = *localtime (&t);
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_mon = 0;
- tm.tm_mday = 1;
- tm.tm_isdst = -1;
-
- return mktime (&tm);
-}
-
-time_t
-time_year_end (time_t t)
-{
- struct tm tm;
-
- tm = *localtime (&t);
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_mon = 0;
- tm.tm_mday = 1;
- tm.tm_year++;
- tm.tm_isdst = -1;
-
- return mktime (&tm);
-}
-
-time_t
-time_month_begin (time_t t)
-{
- struct tm tm;
-
- tm = *localtime (&t);
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_mday = 1;
- tm.tm_isdst = -1;
-
- return mktime (&tm);
-}
-
-time_t
-time_month_end (time_t t)
-{
- struct tm tm;
-
- tm = *localtime (&t);
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_mday = 1;
- tm.tm_mon++;
- tm.tm_isdst = -1;
-
- return mktime (&tm);
-}
-
-time_t
-time_week_begin (time_t t)
-{
- struct tm tm;
-
- /* FIXME: make it take week_starts_on_monday into account */
-
- tm = *localtime (&t);
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_mday -= tm.tm_wday;
-
- return mktime (&tm);
-}
-
-time_t
-time_week_end (time_t t)
-{
- struct tm tm;
-
- /* FIXME: make it take week_starts_on_monday into account */
-
- tm = *localtime (&t);
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_mday += 7 - tm.tm_wday;
-
- return mktime (&tm);
-}
-
-time_t
-time_day_begin (time_t t)
-{
- struct tm tm;
- time_t temp = t - 43200;
- int dstflag, dstflag2;
-
- tm = *localtime(&temp); /* one day */
- dstflag = tm.tm_isdst;
-
- tm = *localtime (&t);
- dstflag2 = tm.tm_isdst;
-
- if (dstflag < dstflag2)
- tm.tm_hour = 1;
- else
- tm.tm_hour = 0;
-
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- temp = mktime(&tm);
- if (dstflag > dstflag2){
- temp += 3600;
- }
-
- return temp;
-}
-
-time_t
-time_day_end (time_t t)
-{
- struct tm tm;
- time_t temp;
- int dstflag, dstflag2;
-
- t += 10800;
- temp = t - 86400;
-
- tm = *localtime(&temp); /* one day */
- dstflag = tm.tm_isdst;
-
- tm = *localtime (&t);
- dstflag2 = tm.tm_isdst;
-
- if (dstflag < dstflag2)
- tm.tm_hour = 23;
- else {
- tm.tm_mday++;
- tm.tm_hour = 0;
- }
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- temp = mktime(&tm);
- if(dstflag > dstflag2) {
- }
- return temp;
-}
-
-static char *
-pcat (char *dest, int num, char key)
-{
- int c;
-
- c = sprintf (dest, "%d%c", num, key);
- return dest + c;
-}
-
-/* Converts secs into the ISO difftime representation */
-char *
-isodiff_from_secs (int secs)
-{
- static char buffer [60], *p;
- int years, months, weeks, days, hours, minutes;
-
- years = months = weeks = days = hours = minutes = 0;
-
- years = secs / (365 * 86400);
- secs %= (365 * 86400);
- months = secs / (30 * 86400);
- secs %= (30 * 86400);
- weeks = secs / (7 * 86400);
- secs %= (7 * 86400);
- days = secs / 86400;
- secs %= 86400;
- hours = secs / 3600;
- secs %= 3600;
- minutes = secs / 60;
- secs %= 60;
-
- strcpy (buffer, "P");
- p = buffer + 1;
- if (years)
- p = pcat (p, years, 'Y');
- if (months)
- p = pcat (p, months, 'M');
- if (weeks)
- p = pcat (p, weeks, 'W');
- if (days)
- p = pcat (p, days, 'D');
- if (hours || minutes || secs){
- *p++ = 'T';
- if (hours)
- p = pcat (p, hours, 'H');
- if (minutes)
- p = pcat (p, minutes, 'M');
- if (secs)
- p = pcat (p, secs, 'S');
- }
-
- return buffer;
-}
-
-int
-isodiff_to_secs (char *str)
-{
- int value, time;
- int years, months, weeks, days, hours, minutes, seconds;
-
- value = years = months = weeks = days = hours = minutes = time = seconds = 0;
- if (*str != 'P')
- return 0;
-
- str++;
- while (*str){
- switch (*str){
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- value = value * 10 + (*str - '0');
- break;
- case 'Y':
- years = value; value = 0;
- break;
- case 'M':
- if (time)
- minutes = value;
- else
- months = value;
- value = 0;
- break;
- case 'W':
- weeks = value; value = 0;
- break;
- case 'D':
- days = value; value = 0;
- break;
- case 'T':
- value = 0; time = 1;
- break;
- case 'H':
- hours = value; value = 0;
- break;
- case 'S':
- seconds = value; value = 0;
- break;
- }
- str++;
- }
- return seconds + (minutes * 60) + (hours * 3600) +
- (days * 86400) + (weeks * 7 * 86400) +
- (months * 30 * 86400) + (years * 365 * 86400);
-}
diff --git a/calendar/timeutil.h b/calendar/timeutil.h
deleted file mode 100644
index 407213d7f8..0000000000
--- a/calendar/timeutil.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* Miscellaneous time-related utilities
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <federico@nuclecu.unam.mx>
- * Miguel de Icaza <miguel@nuclecu.unam.mx>
- */
-
-#ifndef TIMEUTIL_H
-#define TIMEUTIL_H
-
-
-#include <time.h>
-
-
-time_t time_from_isodate (char *str);
-time_t time_from_start_duration (time_t start, char *duration);
-char *isodate_from_time_t (time_t t);
-int get_time_t_hour (time_t t);
-int isodiff_to_secs (char *str);
-char *isodiff_from_secs (int secs);
-
-time_t time_add_minutes (time_t time, int minutes);
-time_t time_add_day (time_t time, int days);
-time_t time_add_week (time_t time, int weeks);
-time_t time_add_month (time_t time, int months);
-time_t time_add_year (time_t time, int years);
-
-
-/* Returns pointer to a statically-allocated buffer with a string of the form
- * 3am, 4am, 12pm, 08h, 17h, etc.
- * The string is internationalized, hopefully correctly.
- */
-char *format_simple_hour (int hour, int use_am_pm);
-
-/* Returns the number of days in the specified month. Years are full years (starting from year 1).
- * Months are in [0, 11].
- */
-int time_days_in_month (int year, int month);
-
-/* Converts the specified date to a time_t at the start of the specified day. Years are full years
- * (starting from year 1). Months are in [0, 11]. Days are 1-based.
- */
-time_t time_from_day (int year, int month, int day);
-
-time_t time_day_hour (time_t t, int hour);
-
-/* For the functions below, time ranges are considered to contain the start time, but not the end
- * time.
- */
-
-/* These two functions take a time value and return the beginning or end of the corresponding year,
- * respectively.
- */
-time_t time_year_begin (time_t t);
-time_t time_year_end (time_t t);
-
-/* These two functions take a time value and return the beginning or end of the corresponding month,
- * respectively.
- */
-time_t time_month_begin (time_t t);
-time_t time_month_end (time_t t);
-
-/* These functions take a time value and return the beginning or end of the corresponding week,
- * respectively. This takes into account the global week_starts_on_monday flag.
- */
-time_t time_week_begin (time_t t);
-time_t time_week_end (time_t t);
-
-/* These two functions take a time value and return the beginning or end of the corresponding day,
- * respectively.
- */
-time_t time_day_begin (time_t t);
-time_t time_day_end (time_t t);
-
-
-time_t parse_date (char *str);
-void print_time_t (time_t t);
-
-
-#endif
diff --git a/calendar/tlacuache.c b/calendar/tlacuache.c
deleted file mode 100644
index b11b5030d8..0000000000
--- a/calendar/tlacuache.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Tlacuache - personal calendar server main module
- *
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <libgnorba/gnorba.h>
-#include <bonobo.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include "cal-factory.h"
-#include "calobj.h"
-
-
-
-/* The calendar factory */
-static CalFactory *factory;
-
-
-
-/* Stuff that the un-converted alarm code needs to build */
-
-int debug_alarms = FALSE;
-
-void calendar_notify (time_t time, CalendarAlarm *which, void *data);
-
-CalendarAlarm alarm_defaults[4] = {
- { ALARM_MAIL, 0, 15, ALARM_MINUTES },
- { ALARM_PROGRAM, 0, 15, ALARM_MINUTES },
- { ALARM_DISPLAY, 0, 15, ALARM_MINUTES },
- { ALARM_AUDIO, 0, 15, ALARM_MINUTES }
-};
-
-void
-calendar_notify (time_t time, CalendarAlarm *which, void *data)
-{
- g_error ("calendar_notify() called!");
-}
-
-
-
-/* Creates and registers the calendar factory */
-static gboolean
-create_cal_factory (void)
-{
- CORBA_Object object;
- CORBA_Environment ev;
- int result;
-
- factory = cal_factory_new ();
- if (!factory) {
- g_message ("create_cal_factory(): could not create the calendar factory!");
- return FALSE;
- }
-
- object = bonobo_object_corba_objref (BONOBO_OBJECT (factory));
-
- CORBA_exception_init (&ev);
- result = goad_server_register (CORBA_OBJECT_NIL,
- object,
- "calendar:cal-factory",
- "object",
- &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION || result == -1) {
- g_message ("create_cal_factory(): could not register the calendar factory");
- CORBA_exception_free (&ev);
- return FALSE;
- } else if (result == -2) {
- g_message ("create_cal_factory(): a calendar factory is already registered");
- CORBA_exception_free (&ev);
- return FALSE;
- }
-
- CORBA_exception_free (&ev);
- return TRUE;
-}
-
-int
-main (int argc, char **argv)
-{
- CORBA_Environment ev;
-
- bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);
-
- CORBA_exception_init (&ev);
- gnome_CORBA_init ("tlacuache", VERSION, &argc, argv, GNORBA_INIT_SERVER_FUNC, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("main(): could not initialize the ORB");
- CORBA_exception_free (&ev);
- exit (1);
- }
- CORBA_exception_free (&ev);
-
- if (!bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL)) {
- g_message ("main(): could not initialize Bonobo");
- exit (1);
- }
-
- if (!gnome_vfs_init ()) {
- g_message ("main(): could not initialize GNOME-VFS");
- exit (1);
- }
-
- if (!create_cal_factory ())
- exit (1);
-
- bonobo_main ();
- return 0;
-}
diff --git a/calendar/tlacuache.gnorba b/calendar/tlacuache.gnorba
deleted file mode 100644
index acf2289229..0000000000
--- a/calendar/tlacuache.gnorba
+++ /dev/null
@@ -1,5 +0,0 @@
-[calendar:cal-factory]
-type=exe
-repo_id=IDL:GNOME/Calendar/CalFactory:1.0
-description=Calendar factory for the Personal Calendar Server
-location_info=tlacuache
diff --git a/calendar/todo-conduit-control-applet.c b/calendar/todo-conduit-control-applet.c
deleted file mode 100644
index 54a26715ef..0000000000
--- a/calendar/todo-conduit-control-applet.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/* Control applet ("capplet") for the gnome-pilot todo conduit, */
-/* based on */
-/* gpilotd control applet ('capplet') for use with the GNOME control center */
-/* $Id$ */
-
-#include <pwd.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <gnome.h>
-
-#include <config.h>
-#include <capplet-widget.h>
-
-#include <gpilotd/gpilotd-conduit-mgmt.h>
-#include <gpilotd/gpilotd-app.h>
-#include <gpilotd/gpilotd-app-dummy-callbacks.h>
-
-#include "todo-conduit.h"
-
-/* tell changes callbacks to ignore changes or not */
-static gboolean ignore_changes=FALSE;
-
-/* capplet widget */
-static GtkWidget *capplet=NULL;
-
-/* host/device/pilot configuration windows */
-GtkWidget *cfgOptionsWindow=NULL;
-GtkWidget *cfgStateWindow=NULL;
-GtkWidget *dialogWindow=NULL;
-
-gboolean activated,org_activation_state;
-GnomePilotConduitMgmt *conduit;
-
-static void doTrySettings(GtkWidget *widget, ConduitCfg *conduitCfg);
-static void doRevertSettings(GtkWidget *widget, ConduitCfg *conduitCfg);
-static void doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg);
-
-static void readStateCfg(GtkWidget *w);
-static void setStateCfg(GtkWidget *w);
-
-gint pilotId;
-CORBA_Environment ev;
-
-static void
-doTrySettings(GtkWidget *widget, ConduitCfg *conduitCfg)
-{
- readStateCfg(cfgStateWindow);
- if(activated)
- gpilotd_conduit_mgmt_enable(conduit,pilotId,GnomePilotConduitSyncTypeSynchronize);
- else
- gpilotd_conduit_mgmt_disable(conduit,pilotId);
-}
-
-static void
-doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg)
-{
- doTrySettings(widget, conduitCfg);
- save_configuration(NULL);
-}
-
-
-static void
-doRevertSettings(GtkWidget *widget, ConduitCfg *conduitCfg)
-{
- activated = org_activation_state;
- setStateCfg(cfgStateWindow);
-}
-
-static void
-insert_dir_callback (GtkEditable *editable, const gchar *text,
- gint len, gint *position, void *data)
-{
- gint i;
- gchar *curname;
-
- curname = gtk_entry_get_text(GTK_ENTRY(editable));
- if (*curname == '\0' && len > 0) {
- if (isspace(text[0])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text");
- return;
- }
- } else {
- for (i=0; i<len; i++) {
- if (isspace(text[i])) {
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable),
- "insert_text");
- return;
- }
- }
- }
-}
-static void
-insert_dir_callback2(GtkEditable *editable, const gchar *text,
- gint length, gint *position,
- void *data)
-{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-static void
-clist_changed(GtkWidget *widget, gpointer data)
-{
- if (!ignore_changes)
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-void about_cb (GtkWidget *widget, gpointer data) {
- GtkWidget *about;
- const gchar *authors[] = {_("Eskil Heyn Olsen <deity@eskil.dk>"),NULL};
-
- about = gnome_about_new(_("Gpilotd todo conduit"), VERSION,
- _("(C) 1998 the Free Software Foundation"),
- authors,
- _("Configuration utility for the todo conduit.\n"),
- _("gnome-unknown.xpm"));
- gtk_widget_show (about);
-
- return;
-}
-
-static void toggled_cb(GtkWidget *widget, gpointer data) {
- gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(widget)->active);
- capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
-}
-
-static GtkWidget
-*createStateCfgWindow(void)
-{
- GtkWidget *vbox, *table;
- GtkWidget *entry, *label;
- GtkWidget *button;
-
- vbox = gtk_vbox_new(FALSE, GNOME_PAD);
-
- table = gtk_table_new(2, 2, FALSE);
- gtk_table_set_row_spacings(GTK_TABLE(table), 4);
- gtk_table_set_col_spacings(GTK_TABLE(table), 10);
- gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD);
-
- label = gtk_label_new(_("Enabled"));
- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1,2);
-
- button = gtk_check_button_new();
- gtk_object_set_data(GTK_OBJECT(vbox), "conduit_on_off", button);
- gtk_signal_connect(GTK_OBJECT(button), "toggled",
- GTK_SIGNAL_FUNC(toggled_cb),
- NULL);
- gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 1,2);
-
- return vbox;
-}
-
-static void
-setStateCfg(GtkWidget *cfg)
-{
- GtkWidget *button;
- gchar num[40];
-
- button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off");
-
- g_assert(button!=NULL);
-
- ignore_changes = TRUE;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),activated);
- gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(button)->active);
- ignore_changes = FALSE;
-}
-
-
-static void
-readStateCfg(GtkWidget *cfg)
-{
- GtkWidget *button;
-
- button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off");
-
- g_assert(button!=NULL);
-
- activated = GTK_TOGGLE_BUTTON(button)->active;
-}
-
-static void
-pilot_capplet_setup(void)
-{
- GtkWidget *frame, *table;
-
- capplet = capplet_widget_new();
-
- table = gtk_table_new(1, 2, FALSE);
- gtk_container_border_width(GTK_CONTAINER(table), GNOME_PAD);
- gtk_container_add(GTK_CONTAINER(capplet), table);
-
- frame = gtk_frame_new(_("Conduit state"));
- gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL);
- gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1);
- cfgStateWindow = createStateCfgWindow();
- gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow);
-
- gtk_signal_connect(GTK_OBJECT(capplet), "try",
- GTK_SIGNAL_FUNC(doTrySettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "revert",
- GTK_SIGNAL_FUNC(doRevertSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "ok",
- GTK_SIGNAL_FUNC(doSaveSettings), NULL);
- gtk_signal_connect(GTK_OBJECT(capplet), "help",
- GTK_SIGNAL_FUNC(about_cb), NULL);
-
-
- setStateCfg(cfgStateWindow);
-
- gtk_widget_show_all(capplet);
-}
-
-void run_error_dialog(gchar *mesg,...) {
- char tmp[80];
- va_list ap;
-
- va_start(ap,mesg);
- vsnprintf(tmp,79,mesg,ap);
- dialogWindow = gnome_message_box_new(mesg,GNOME_MESSAGE_BOX_ERROR,GNOME_STOCK_BUTTON_OK,NULL);
- gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow));
- va_end(ap);
-}
-
-gint get_pilot_id_from_gpilotd() {
- gint *pilots;
- int i;
-
- i=0;
- gpilotd_get_pilot_ids(&pilots);
- if(pilots) {
- while(pilots[i]!=-1) { g_message("pilot %d = \"%d\"",i,pilots[i]); i++; }
- if(i==0) {
- run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
- return -1;
- } else {
- if(i==1)
- return pilots[0];
- else {
- g_message("too many pilots...");
- return pilots[0];
- }
- }
- } else {
- run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first."));
- return -1;
- }
-}
-
-int
-main( int argc, char *argv[] )
-{
- /* we're a capplet */
- gnome_capplet_init ("todo conduit control applet", NULL, argc, argv,
- NULL,
- 0, NULL);
-
- /* put all code to set things up in here */
- conduit = gpilotd_conduit_mgmt_new("todo_conduit");
-
- /* get pilot name from gpilotd */
- /* 1. initialize the gpilotd connection */
- if (gpilotd_init(&argc,argv)!=0) {
- run_error_dialog(_("Cannot initialze the GnomePilot Daemon"));
- g_error(_("Cannot initialze the GnomePilot Daemon"));
- return -1;
- }
-
- /* 2 connect to gpilotd */
- if (gpilotd_connect()!=0) {
- run_error_dialog(_("Cannot connect to the GnomePilot Daemon"));
- g_error(_("Cannot connect to the GnomePilot Daemon"));
- return -1;
- }
-
- pilotId = get_pilot_id_from_gpilotd();
- if(!pilotId) return -1;
- org_activation_state = activated = gpilotd_conduit_mgmt_is_enabled(conduit,pilotId);
-
- pilot_capplet_setup();
-
-
- /* done setting up, now run main loop */
- capplet_gtk_main();
- return 0;
-}
diff --git a/calendar/todo-conduit-control-applet.desktop b/calendar/todo-conduit-control-applet.desktop
deleted file mode 100644
index 87788bde08..0000000000
--- a/calendar/todo-conduit-control-applet.desktop
+++ /dev/null
@@ -1,6 +0,0 @@
-[Desktop Entry]
-Name=Todo conduit
-Comment=Configure the todo conduit
-Exec=todo-conduit-control-applet --cap-id=1
-Terminal=0
-Type=Application
diff --git a/calendar/todo-conduit.c b/calendar/todo-conduit.c
deleted file mode 100644
index 3a543816af..0000000000
--- a/calendar/todo-conduit.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/* $Id$ */
-
-#include <glib.h>
-#include <gnome.h>
-
-#include <pi-source.h>
-#include <pi-socket.h>
-#include <pi-file.h>
-#include <pi-dlp.h>
-#include <pi-version.h>
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <utime.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <signal.h>
-#include <errno.h>
-#include <gpilotd/gnome-pilot-conduit.h>
-#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
-
-#include "todo-conduit.h"
-
-static gint
-load_records(GnomePilotConduit *c)
-{
- return 0;
-}
-
-static gint
-pre_sync(GnomePilotConduit *c, GnomePilotDBInfo *dbi) {
- int l;
- unsigned char *buf;
-
- gtk_object_set_data(GTK_OBJECT(c),"dbinfo",dbi);
-
- load_records(c);
-
- buf = (unsigned char*)g_malloc(0xffff);
- if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff))<0) {
- return -1;
- }
- unpack_ToDoAppInfo(&(GET_DATA(c)->ai),buf,l);
- g_free(buf);
-
- return 0;
-}
-
-static gint
-post_sync(GnomePilotConduit *c) {
- return 0;
-}
-
-static gint
-match_record (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord **local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("in match_record\n");
- return 0;
-}
-static gint
-free_match (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord **local,
- gpointer data)
-{
- g_print ("entering free_match\n");
- *local = NULL;
-
- return 0;
-}
-static gint
-archive_local (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gpointer data)
-{
- g_print ("entering archive_local\n");
- return 1;
-
-}
-static gint
-archive_remote (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering archive_remote\n");
- return 1;
-}
-static gint
-store_remote (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering store_remote\n");
- g_print ("Rec:%s:\nLength:%d\n", remote->record, remote->length);
- return 1;
-}
-static gint
-clear_status_archive_local (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gpointer data)
-{
- g_print ("entering clear_status_archive_local\n");
- return 1;
-}
-static gint
-iterate (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord **local,
- gpointer data)
-{
- g_print ("entering iterate\n");
- return 1;
-}
-static gint
-iterate_specific (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord **local,
- gint flag,
- gint archived,
- gpointer data)
-{
- g_print ("entering iterate_specific\n");
- return 1;
-}
-static gint
-purge (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- gpointer data)
-{
- g_print ("entering purge\n");
- return 1;
-}
-static gint
-set_status (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gint status,
- gpointer data)
-{
- g_print ("entering set_status\n");
- return 1;
-}
-static gint
-set_archived (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gint archived,
- gpointer data)
-{
- g_print ("entering set_archived\n");
- return 1;
-}
-static gint
-set_pilot_id (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- guint32 ID,
- gpointer data)
-{
- g_print ("entering set_pilot_id\n");
- return 1;
-}
-static gint
-compare (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering compare\n");
- return 1;
-}
-static gint
-compare_backup (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering compare_backup\n");
- return 1;
-}
-static gint
-free_transmit (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- PilotRecord *remote,
- gpointer data)
-{
- g_print ("entering free_transmit\n");
- return 1;
-}
-static gint
-delete_all (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- gpointer data)
-{
- g_print ("entering delete_all\n");
- return 1;
-}
-static PilotRecord *
-transmit (GnomePilotConduitStandardAbs *pilot_conduit_standard_abs,
- LocalRecord *local,
- gpointer data)
-{
- g_print ("entering transmit\n");
- return NULL;
-}
-
-static GnomePilotConduit *
-conduit_get_gpilot_conduit (guint32 pilotId)
-{
- GtkObject *retval;
- ConduitCfg *cfg;
- ConduitData *cdata;
-
- g_print ("creating our new conduit\n");
- retval = gnome_pilot_conduit_standard_abs_new ("TodoDB", 0x0);
- g_assert (retval != NULL);
- gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"todo");
-
- cfg = g_new0(ConduitCfg,1);
- g_assert(cfg != NULL);
- gtk_object_set_data(retval,"conduit_cfg",cfg);
-
- cdata = g_new0(ConduitData,1);
- g_assert(cdata != NULL);
- gtk_object_set_data(retval,"conduit_data",cdata);
-
- gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, NULL);
- gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, NULL);
- gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, NULL);
- gtk_signal_connect (retval, "archive_remote", (GtkSignalFunc) archive_remote, NULL);
- gtk_signal_connect (retval, "store_remote", (GtkSignalFunc) store_remote, NULL);
- gtk_signal_connect (retval, "clear_status_archive_local", (GtkSignalFunc) clear_status_archive_local, NULL);
- gtk_signal_connect (retval, "iterate", (GtkSignalFunc) iterate, NULL);
- gtk_signal_connect (retval, "iterate_specific", (GtkSignalFunc) iterate_specific, NULL);
- gtk_signal_connect (retval, "purge", (GtkSignalFunc) purge, NULL);
- gtk_signal_connect (retval, "set_status", (GtkSignalFunc) set_status, NULL);
- gtk_signal_connect (retval, "set_archived", (GtkSignalFunc) set_archived, NULL);
- gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, NULL);
- gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, NULL);
- gtk_signal_connect (retval, "compare_backup", (GtkSignalFunc) compare_backup, NULL);
- gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, NULL);
- gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, NULL);
- gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, NULL);
- gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, NULL);
- gtk_signal_connect (retval, "post_sync", (GtkSignalFunc) post_sync, NULL);
-
- load_configuration(&cfg,pilotId);
-
- return GNOME_PILOT_CONDUIT (retval);
-}
-static void
-conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
-{
- ConduitCfg *cc;
- cc = GET_CONFIG(conduit);
- destroy_configuration(&cc);
- gtk_object_destroy (GTK_OBJECT (conduit));
-}
-
-
diff --git a/calendar/todo-conduit.h b/calendar/todo-conduit.h
deleted file mode 100644
index c224b2b1f3..0000000000
--- a/calendar/todo-conduit.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* $Id$ */
-
-#ifndef __TODO_CONDUIT_H__
-#define __TODO_CONDUIT_H__
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <pi-todo.h>
-#include <gnome.h>
-
-typedef struct _ConduitCfg ConduitCfg;
-
-struct _ConduitCfg {
- gboolean open_secret;
- guint32 pilotId;
-};
-
-#define GET_CONFIG(c) ((ConduitCfg*)gtk_object_get_data(GTK_OBJECT(c),"conduit_cfg"))
-
-typedef struct _ConduitData ConduitData;
-
-struct _ConduitData {
- struct ToDoAppInfo ai;
-};
-
-#define GET_DATA(c) ((ConduitData*)gtk_object_get_data(GTK_OBJECT(c),"conduit_data"))
-
-static void load_configuration(ConduitCfg **c,guint32 pilotId) {
- gchar prefix[256];
- g_snprintf(prefix,255,"/gnome-pilot.d/todod-conduit/Pilot_%u/",pilotId);
-
- *c = g_new0(ConduitCfg,1);
- gnome_config_push_prefix(prefix);
- (*c)->open_secret = gnome_config_get_bool("open secret=FALSE");
- gnome_config_pop_prefix();
-
- (*c)->pilotId = pilotId;
-}
-
-static void save_configuration(ConduitCfg *c) {
- gchar prefix[256];
-
- g_snprintf(prefix,255,"/gnome-pilot.d/todo-conduit/Pilot_%u/",c->pilotId);
-
- gnome_config_push_prefix(prefix);
- gnome_config_set_bool("open secret",c->open_secret);
- gnome_config_pop_prefix();
-
- gnome_config_sync();
- gnome_config_drop_all();
-}
-
-static void destroy_configuration(ConduitCfg **c) {
- g_free(*c);
- *c = NULL;
-}
-
-#endif __TODO_CONDUIT_H__
diff --git a/calendar/topic.dat b/calendar/topic.dat
deleted file mode 100644
index edc7813b26..0000000000
--- a/calendar/topic.dat
+++ /dev/null
@@ -1,2 +0,0 @@
-gnome-cal.html Manual
-gnome-cal.html#cmdline Command line options \ No newline at end of file
diff --git a/calendar/view-utils.c b/calendar/view-utils.c
deleted file mode 100644
index 8cb7893377..0000000000
--- a/calendar/view-utils.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/* Miscellaneous utility functions for the calendar view widgets
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <string.h>
-#include "view-utils.h"
-#include <libgnomeui/gnome-icon-text.h>
-
-int am_pm_flag = 0;
-
-static char *
-nicetime (struct tm *tm)
-{
- static char buf [20];
- char *p = buf;
-
- if (am_pm_flag){
- if (tm->tm_min)
- strftime (buf, sizeof (buf), "%l:%M%p", tm);
- else
- strftime (buf, sizeof (buf), "%l%p", tm);
- } else {
- if (tm->tm_min)
- strftime (buf, sizeof (buf), "%H:%M", tm);
- else
- strftime (buf, sizeof (buf), "%H", tm);
- }
- while (*p == ' ')
- p++;
- return p;
-}
-
-typedef struct {
- GnomeIconTextInfo *layout;
- int lines;
- int assigned_lines;
-} line_info_t;
-
-void
-view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area,
- int flags, GList *events, time_t start, time_t end)
-{
- GdkFont *font = widget->style->font;
- int font_height;
- int y, max_y, items, i, need_more, nlines, base, extra;
- GList *list;
- line_info_t *lines;
-
- if (events == NULL)
- return;
-
- items = g_list_length (events);
- lines = g_new0 (line_info_t, items);
-
- font_height = font->ascent + font->descent;
- max_y = area->y + area->height - font_height * ((flags & VIEW_UTILS_DRAW_SPLIT) ? 2 : 1);
-
- /*
- * Layout all the lines, measure the space needs
- */
- for (i = 0, list = events; list; list = list->next, i++){
- CalendarObject *co = list->data;
- struct tm tm_start, tm_end;
- iCalObject *ico = co->ico;
- char buf [60];
- char *full_text;
-
- tm_start = *localtime (&co->ev_start);
- tm_end = *localtime (&co->ev_end);
-
- strcpy (buf, nicetime (&tm_start));
-
- if (flags & VIEW_UTILS_DRAW_END){
- strcat (buf, "-");
- strcat (buf, nicetime (&tm_end));
- }
-
- full_text = g_strconcat (buf, ": ", ico->summary, NULL);
- lines [i].layout = gnome_icon_layout_text (
- font, full_text, "\n -,.;:=#", area->width, TRUE);
- lines [i].lines = g_list_length (lines [i].layout->rows);
-
- g_free (full_text);
- }
-
- /*
- * Compute how many lines we will give to each row
- */
- nlines = 1 + max_y / font_height;
- base = nlines / items;
- extra = nlines % items;
- need_more = 0;
-
- for (i = 0; i < items; i++){
- if (lines [i].lines <= base){
- extra += base - lines [i].lines;
- lines [i].assigned_lines = lines [i].lines;
- } else {
- need_more++;
- lines [i].assigned_lines = base;
- }
- }
-
- /*
- * use any extra space
- */
- while (need_more && extra > 0){
- need_more = 0;
-
- for (i = 0; i < items; i++){
- if (lines [i].lines > lines [i].assigned_lines){
- lines [i].assigned_lines++;
- extra--;
- }
-
- if (extra == 0)
- break;
-
- if (lines [i].lines > lines [i].assigned_lines)
- need_more = 1;
- }
- }
-
- /*
- * Draw the information
- */
- gdk_gc_set_clip_rectangle (gc, area);
- y = area->y;
- for (i = 0; i < items; i++){
- int line;
-
- list = lines [i].layout->rows;
-
- for (line = 0; line < lines [i].assigned_lines; line++){
- GnomeIconTextInfoRow *row = list->data;
-
- list = list->next;
-
- if (row)
- gdk_draw_string (
- window, font, gc,
- area->x, y + font->ascent,
- row->text);
- y += font_height;
- }
- }
-
- gdk_gc_set_clip_rectangle (gc, NULL);
-
- /*
- * Free resources.
- */
-
- for (i = 0; i < items; i++)
- gnome_icon_text_info_free (lines [i].layout);
- g_free (lines);
-}
-
-void
-view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow)
-{
- int x, y;
- int xthick, ythick;
- GdkGC *light_gc, *dark_gc;
-
- gdk_draw_rectangle (window,
- widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- rect->x, rect->y,
- rect->width, rect->height);
-
- light_gc = widget->style->light_gc[GTK_STATE_NORMAL];
- dark_gc = widget->style->dark_gc[GTK_STATE_NORMAL];
-
- xthick = widget->style->klass->xthickness;
- ythick = widget->style->klass->ythickness;
-
- gdk_gc_set_clip_rectangle (light_gc, rect);
- gdk_gc_set_clip_rectangle (dark_gc, rect);
-
- for (y = rect->y + ythick; y < (rect->y + rect->height - ythick); y += 3)
- for (x = rect->x + xthick; x < (rect->x + rect->width - xthick); x += 6) {
- gdk_draw_point (window, light_gc, x, y);
- gdk_draw_point (window, dark_gc, x + 1, y + 1);
-
- gdk_draw_point (window, light_gc, x + 3, y + 1);
- gdk_draw_point (window, dark_gc, x + 4, y + 2);
- }
-
- gdk_gc_set_clip_rectangle (light_gc, NULL);
- gdk_gc_set_clip_rectangle (dark_gc, NULL);
-
- gtk_draw_shadow (widget->style, window,
- GTK_STATE_NORMAL, shadow,
- rect->x, rect->y,
- rect->width, rect->height);
-}
diff --git a/calendar/view-utils.h b/calendar/view-utils.h
deleted file mode 100644
index a1876b6032..0000000000
--- a/calendar/view-utils.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Miscellaneous utility functions for the calendar view widgets
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef VIEW_UTILS_H
-#define VIEW_UTILS_H
-
-
-#include <gtk/gtk.h>
-#include "calendar.h"
-
-
-enum {
- VIEW_UTILS_DRAW_END = 1 << 0,
- VIEW_UTILS_DRAW_SPLIT = 1 << 1
-};
-
-
-void view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area,
- int flags, GList *events, time_t start, time_t end);
-
-void view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow);
-
-
-#endif
diff --git a/calendar/week-view.c b/calendar/week-view.c
deleted file mode 100644
index 89e489a92d..0000000000
--- a/calendar/week-view.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/* Week view display for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include "year-view.h"
-
-
-static void week_view_class_init (WeekViewClass *class);
-static void week_view_init (WeekView *wv);
-
-
-GtkType
-week_view_get_type (void)
-{
- static GtkType week_view_type = 0;
-
- if (!week_view_type) {
- GtkTypeInfo week_view_info = {
- "WeekView",
- sizeof (WeekView),
- sizeof (WeekViewClass),
- (GtkClassInitFunc) week_view_class_init,
- (GtkObjectInitFunc) week_view_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- week_view_type = gtk_type_unique (gnome_canvas_get_type (), &week_view_info);
- }
-
- return week_view_type;
-}
-
-static void
-week_view_class_init (WeekViewClass *class)
-{
- /* FIXME */
-}
-
-static void
-week_view_init (WeekView *wv)
-{
- GnomeCanvasGroup *root;
-
- root = gnome_canvas_root (GNOME_CANVAS (wv));
-
- /* Title */
-
- wv->title = gnome_canvas_item_new (root,
- gnome_canvas_text_get_type (),
- "anchor", GTK_ANCHOR_N,
- "font", HEADING_FONT,
- "fill_color", "black",
- NULL);
-}
-
-GtkWidget *
-week_view_new (GnomeCalendar *calendar, time_t week)
-{
- WeekView *wv;
-
- g_return_val_if_fail (calendar != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CALENDAR (calendar), NULL);
-
- wv = gtk_type_new (week_view_get_type ());
- wv->calendar = calendar;
-
- week_view_colors_changed (wv);
- week_view_set (wv, week);
- return GTK_WIDGET (wv);
-}
-
-void
-week_view_update (WeekView *wv, iCalObject *ico, int flags)
-{
- /* FIXME */
-}
-
-void
-week_view_set (WeekView *wv, time_t week)
-{
- /* FIXME */
-}
-
-void
-week_view_time_format_changed (WeekView *wv)
-{
- /* FIXME */
-}
-
-void
-week_view_colors_changed (WeekView *wv)
-{
- /* FIXME */
-}
diff --git a/calendar/week-view.h b/calendar/week-view.h
deleted file mode 100644
index 1bf6a4ed02..0000000000
--- a/calendar/week-view.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Week view display for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef WEEK_VIEW_H
-#define WEEK_VIEW_H
-
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define TYPE_WEEK_VIEW (week_view_get_type ())
-#define WEEK_VIEW(obj) (GTK_CHECK_CAST ((obj), TYPE_WEEK_VIEW, WeekView))
-#define WEEK_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_WEEK_VIEW, WeekViewClass))
-#define IS_WEEK_VIEW(obj) (GTK_CHECK_TYPE ((obj), TYPE_WEEK_VIEW))
-#define IS_WEEK_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_WEEK_VIEW))
-
-
-typedef struct _WeekView WeekView;
-typedef struct _WeekViewClass WeekViewClass;
-
-struct _WeekView {
- GnomeCanvas canvas;
-
- GnomeCalendar *calendar; /* The calendar we are associated to */
-
- time_t week; /* Start of the week we are viewing */
-
- GnomeCanvasItem *title; /* The title of the week view */
-};
-
-struct _WeekViewClass {
- GnomeCanvasClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType week_view_get_type (void);
-
-/* Creates a new week view associated to the specified calendar */
-GtkWidget *week_view_new (GnomeCalendar *calendar, time_t week);
-
-/* Notifies the week view that a calendar object has changed */
-void week_view_update (WeekView *wv, iCalObject *ico, int flags);
-
-/* Notifies the week view about a change of date */
-void week_view_set (WeekView *wv, time_t week);
-
-/* Notifies the week view that the time format has changed */
-void week_view_time_format_changed (WeekView *wv);
-
-/* Notifies the week view that the colors have changed */
-void week_view_colors_changed (WeekView *wv);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/year-view.c b/calendar/year-view.c
deleted file mode 100644
index 5744b4a88f..0000000000
--- a/calendar/year-view.c
+++ /dev/null
@@ -1,741 +0,0 @@
-/* Year view display for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Arturo Espinosa <arturo@nuclecu.unam.mx>
- * Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include <gtk/gtkmain.h>
-#include <gnome.h>
-#include "eventedit.h"
-#include "year-view.h"
-#include "main.h"
-#include "mark.h"
-#include "quick-view.h"
-#include "timeutil.h"
-
-
-#define HEAD_SPACING 4 /* Spacing between year heading and months */
-#define TITLE_SPACING 1 /* Spacing between title and calendar */
-#define SPACING 4 /* Spacing between months */
-
-
-static void year_view_class_init (YearViewClass *class);
-static void year_view_init (YearView *yv);
-static void year_view_destroy (GtkObject *object);
-static void year_view_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void year_view_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-
-
-static GnomeCanvas *parent_class;
-
-
-GtkType
-year_view_get_type (void)
-{
- static GtkType year_view_type = 0;
-
- if (!year_view_type) {
- GtkTypeInfo year_view_info = {
- "YearView",
- sizeof (YearView),
- sizeof (YearViewClass),
- (GtkClassInitFunc) year_view_class_init,
- (GtkObjectInitFunc) year_view_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- year_view_type = gtk_type_unique (gnome_canvas_get_type (), &year_view_info);
- }
-
- return year_view_type;
-}
-
-static void
-year_view_class_init (YearViewClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gnome_canvas_get_type ());
-
- object_class->destroy = year_view_destroy;
-
- widget_class->size_request = year_view_size_request;
- widget_class->size_allocate = year_view_size_allocate;
-}
-
-/* Resizes the year view's child items. This is done in the idle loop for
- * performance (we avoid resizing on every size allocation).
- */
-static gint
-idle_handler (gpointer data)
-{
- YearView *yv;
- GtkArg arg;
- double head_height;
- double title_height;
- double width, height;
- double month_width;
- double month_height;
- double month_yofs;
- double xofs, yofs;
- double x, y;
- int i;
-
- yv = data;
-
- /* Compute the size we can use */
-
- width = MAX (GTK_WIDGET (yv)->allocation.width, yv->min_width);
- height = MAX (GTK_WIDGET (yv)->allocation.height, yv->min_height);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (yv), 0, 0, width, height);
-
- width--;
- height--;
-
- /* Get the heights of the heading and the titles */
-
- arg.name = "text_height";
- gtk_object_getv (GTK_OBJECT (yv->heading), 1, &arg);
- head_height = GTK_VALUE_DOUBLE (arg) + 2 * HEAD_SPACING;
-
- arg.name = "text_height";
- gtk_object_getv (GTK_OBJECT (yv->titles[0]), 1, &arg);
- title_height = GTK_VALUE_DOUBLE (arg);
-
- /* Offsets */
-
- xofs = (width + SPACING) / 3.0;
- yofs = (height - head_height + SPACING) / 4.0;
-
- /* Month item vertical offset */
-
- month_yofs = title_height + TITLE_SPACING;
-
- /* Month item dimensions */
-
- month_width = (width - 2 * SPACING) / 3.0;
- month_height = (yofs - SPACING) - month_yofs;
-
- /* Adjust the year heading */
-
- gnome_canvas_item_set (yv->heading,
- "x", width / 2.0,
- "y", (double) HEAD_SPACING,
- NULL);
-
- /* Adjust titles and months */
-
- for (i = 0; i < 12; i++) {
- x = (i % 3) * xofs;
- y = head_height + (i / 3) * yofs;
-
- gnome_canvas_item_set (yv->titles[i],
- "x", x + month_width / 2.0,
- "y", y,
- NULL);
-
- gnome_canvas_item_set (yv->mitems[i],
- "x", x,
- "y", y + month_yofs,
- "width", month_width,
- "height", month_height,
- NULL);
- }
-
- /* Done */
-
- yv->need_resize = FALSE;
- return FALSE;
-}
-
-/* Marks the year view as needing a resize, which will be performed during the idle loop */
-static void
-need_resize (YearView *yv)
-{
- if (yv->need_resize)
- return;
-
- yv->need_resize = TRUE;
- yv->idle_id = gtk_idle_add (idle_handler, yv);
-}
-
-/* Callback used to destroy the year view's popup menu when the year view itself is destroyed */
-static void
-destroy_menu (GtkWidget *widget, gpointer data)
-{
- gtk_widget_destroy (GTK_WIDGET (data));
-}
-
-/* Create a new appointment in the highlighted day from the year view's popup menu */
-static void
-new_appointment (GtkWidget *widget, gpointer data)
-{
- YearView *yv;
- time_t *t;
-
- yv = YEAR_VIEW (data);
- t = gtk_object_get_data (GTK_OBJECT (widget), "time_data");
-
- event_editor_new_whole_day (yv->calendar, *t);
-}
-
-/* Convenience functions to jump to a view and set the time */
-static void
-do_jump (GtkWidget *widget, gpointer data, char *view_name)
-{
- YearView *yv;
- time_t *t;
-
- yv = YEAR_VIEW (data);
-
- /* Get the time data from the menu item */
-
- t = gtk_object_get_data (GTK_OBJECT (widget), "time_data");
-
- /* Set the view and time */
-
- gnome_calendar_set_view (yv->calendar, view_name);
- gnome_calendar_goto (yv->calendar, *t);
-}
-
-/* The following three callbacks set the view in the calendar and change the time */
-
-static void
-jump_to_day (GtkWidget *widget, gpointer data)
-{
- do_jump (widget, data, "dayview");
-}
-
-static void
-jump_to_week (GtkWidget *widget, gpointer data)
-{
- do_jump (widget, data, "weekview");
-}
-
-static void
-jump_to_month (GtkWidget *widget, gpointer data)
-{
- do_jump (widget, data, "monthview");
-}
-
-/* Information for the year view's popup menu */
-static GnomeUIInfo yv_popup_menu[] = {
- GNOMEUIINFO_ITEM_STOCK (N_("_New appointment in this day..."), NULL, new_appointment, GNOME_STOCK_MENU_NEW),
-
- GNOMEUIINFO_SEPARATOR,
-
- GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _day"), NULL, jump_to_day, GNOME_STOCK_MENU_JUMP_TO),
- GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _week"), NULL, jump_to_week, GNOME_STOCK_MENU_JUMP_TO),
- GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _month"), NULL, jump_to_month, GNOME_STOCK_MENU_JUMP_TO),
- GNOMEUIINFO_END
-};
-
-/* Returns the popup menu cooresponding to the specified year view. If the menu has not been
- * created yet, it creates it and attaches it to the year view.
- */
-static GtkWidget *
-get_popup_menu (YearView *yv)
-{
- GtkWidget *menu;
-
- menu = gtk_object_get_data (GTK_OBJECT (yv), "popup_menu");
-
- if (!menu) {
- menu = gnome_popup_menu_new (yv_popup_menu);
- gtk_object_set_data (GTK_OBJECT (yv), "popup_menu", menu);
- gtk_signal_connect (GTK_OBJECT (yv), "destroy",
- (GtkSignalFunc) destroy_menu,
- menu);
- }
-
- return menu;
-}
-
-/* Executes the year view's popup menu. It may disable/enable some menu items based on the
- * specified flags. A pointer to a time_t value containing the specified time data is set in the
- * "time_data" object data key of the menu items.
- */
-static void
-do_popup_menu (YearView *yv, GdkEventButton *event, int allow_new, int allow_day, int allow_week, int allow_month,
- int year, int month, int day)
-{
- GtkWidget *menu;
- static time_t t;
-
- menu = get_popup_menu (yv);
-
- /* Enable/disable items as appropriate */
-
- gtk_widget_set_sensitive (yv_popup_menu[0].widget, allow_new);
- gtk_widget_set_sensitive (yv_popup_menu[2].widget, allow_day);
- gtk_widget_set_sensitive (yv_popup_menu[3].widget, allow_week);
- gtk_widget_set_sensitive (yv_popup_menu[4].widget, allow_month);
-
- /* Set the day item relevant to the context */
-
- t = time_from_day (year, month, day);
-
- gtk_object_set_data (GTK_OBJECT (yv_popup_menu[0].widget), "time_data", &t);
- gtk_object_set_data (GTK_OBJECT (yv_popup_menu[2].widget), "time_data", &t);
- gtk_object_set_data (GTK_OBJECT (yv_popup_menu[3].widget), "time_data", &t);
- gtk_object_set_data (GTK_OBJECT (yv_popup_menu[4].widget), "time_data", &t);
-
- gnome_popup_menu_do_popup (menu, NULL, NULL, event, yv);
-}
-
-/* Creates the quick view when the user clicks on a day */
-static void
-do_quick_view_popup (YearView *yv, GdkEventButton *event, int year, int month, int day)
-{
- time_t day_start, day_end;
- GList *list;
- GtkWidget *qv;
- char date_str[256];
-
- day_start = time_from_day (year, month, day);
- day_end = time_day_end (day_start);
-
- list = calendar_get_events_in_range (yv->calendar->cal, day_start, day_end);
-
- strftime (date_str, sizeof (date_str), _("%a %b %d %Y"), localtime (&day_start));
- qv = quick_view_new (yv->calendar, date_str, list);
-
- quick_view_do_popup (QUICK_VIEW (qv), event);
-
- gtk_widget_destroy (qv);
- calendar_destroy_event_list (list);
-}
-
-/* Event handler for days in the year's month items */
-static gint
-day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- YearView *yv;
- GnomeMonthItem *mitem;
- int child_num, day;
-
- mitem = GNOME_MONTH_ITEM (data);
- child_num = gnome_month_item_child2num (mitem, item);
- day = gnome_month_item_num2day (mitem, child_num);
-
- yv = YEAR_VIEW (item->canvas);
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if (day == 0)
- break;
-
- if (event->button.button == 1) {
- do_quick_view_popup (yv, (GdkEventButton *) event, mitem->year, mitem->month, day);
- return TRUE;
- } else if (event->button.button == 3) {
- do_popup_menu (yv, (GdkEventButton *) event, TRUE, TRUE, TRUE, TRUE,
- mitem->year, mitem->month, day);
-
- /* We have to stop the signal emission because mark.c will grab it too and
- * set the return value to FALSE. Blargh.
- */
- gtk_signal_emit_stop_by_name (GTK_OBJECT (item), "event");
- return TRUE;
- }
-
- break;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-/* Event handler for whole month items */
-static gint
-month_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- YearView *yv;
- GnomeMonthItem *mitem;
-
- mitem = GNOME_MONTH_ITEM (item);
-
- yv = YEAR_VIEW (item->canvas);
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if (event->button.button != 3)
- break;
-
- do_popup_menu (yv, (GdkEventButton *) event, FALSE, FALSE, FALSE, TRUE,
- mitem->year, mitem->month, 1);
-
- /* We have to stop the signal emission because mark.c will grab it too and
- * set the return value to FALSE. Blargh.
- */
- gtk_signal_emit_stop_by_name (GTK_OBJECT (item), "event");
- return TRUE;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-/* Sets up the month item with the specified index -- connects signals for handling events, etc. */
-static void
-setup_month_item (YearView *yv, int n)
-{
- GnomeCanvasItem *mitem;
- GnomeCanvasItem *item;
- int i;
-
- mitem = yv->mitems[n];
-
- /* Connect the day signals */
-
- for (i = 0; i < 42; i++) {
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mitem), GNOME_MONTH_ITEM_DAY_GROUP + i);
- gtk_signal_connect (GTK_OBJECT (item), "event",
- (GtkSignalFunc) day_event,
- mitem);
- }
-
- /* Connect the month signals */
-
- gtk_signal_connect (GTK_OBJECT (mitem), "event",
- (GtkSignalFunc) month_event,
- NULL);
-
- /* Prepare for prelighting */
-
- month_item_prepare_prelight (GNOME_MONTH_ITEM (mitem), default_color_func, NULL);
-}
-
-/* Computes the minimum size for the year view and stores it in its internal fields */
-static void
-compute_min_size (YearView *yv)
-{
- GtkArg args[2];
- double m_width;
- double m_height;
- double max_width;
- double w;
- int i;
-
- /* Compute the minimum size of the year heading */
-
- args[0].name = "text_width";
- args[1].name = "text_height";
- gtk_object_getv (GTK_OBJECT (yv->heading), 2, args);
-
- m_width = GTK_VALUE_DOUBLE (args[0]);
- m_height = 2 * HEAD_SPACING + GTK_VALUE_DOUBLE (args[1]);
-
- /* Add height of month titles and their spacings */
-
- args[0].name = "text_height";
- gtk_object_getv (GTK_OBJECT (yv->titles[0]), 1, &args[0]);
-
- m_height += 4 * (GTK_VALUE_DOUBLE (args[0]) + TITLE_SPACING);
-
- /* Add width of month titles */
-
- max_width = 0.0;
-
- for (i = 0; i < 12; i++) {
- args[0].name = "text_width";
- gtk_object_getv (GTK_OBJECT (yv->titles[i]), 1, &args[0]);
-
- w = GTK_VALUE_DOUBLE (args[0]);
- if (max_width < w)
- max_width = w;
- }
-
- max_width = 3 * max_width + 2 * SPACING;
-
- if (m_width < max_width)
- m_width = max_width;
-
- /* Add width of month items */
-
- args[0].name = "width";
- args[1].name = "height";
- gtk_object_getv (GTK_OBJECT (yv->mitems[0]), 2, args);
-
- max_width = 3 * GTK_VALUE_DOUBLE (args[0]) + 2 * SPACING;
-
- if (m_width < max_width)
- m_width = max_width;
-
- /* Add height of month items */
-
- m_height += 4 * GTK_VALUE_DOUBLE (args[1]) + 3 * SPACING;
-
- /* Finally, set the minimum width and height in the year view */
-
- yv->min_width = (int) (m_width + 0.5);
- yv->min_height = (int) (m_height + 0.5);
-}
-
-static void
-year_view_init (YearView *yv)
-{
- int i;
- char buf[100];
- struct tm tm;
-
- memset (&tm, 0, sizeof (tm));
-
- /* Heading */
-
- yv->heading = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (yv)),
- gnome_canvas_text_get_type (),
- "anchor", GTK_ANCHOR_N,
- "fontset", HEADING_FONTSET,
- "fill_color", "black",
- NULL);
-
- /* Months */
-
- for (i = 0; i < 12; i++) {
- /* Title */
-
- strftime (buf, 100, "%B", &tm);
- tm.tm_mon++;
-
- yv->titles[i] = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (yv)),
- gnome_canvas_text_get_type (),
- "text", buf,
- "anchor", GTK_ANCHOR_N,
- "fontset", TITLE_FONTSET,
- "fill_color", "black",
- NULL);
-
- /* Month item */
-
- yv->mitems[i] = gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (yv)));
- gnome_canvas_item_set (yv->mitems[i],
- "anchor", GTK_ANCHOR_NW,
- "start_on_monday", week_starts_on_monday,
- "heading_fontset", DAY_HEADING_FONTSET,
- "day_fontset", NORMAL_DAY_FONTSET,
- NULL);
- setup_month_item (yv, i);
- }
-
- /* We will need to resize the items when we paint for the first time */
-
- yv->old_marked_day = -1;
- yv->idle_id = -1;
- need_resize (yv);
-}
-
-static void
-year_view_destroy (GtkObject *object)
-{
- YearView *yv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_YEAR_VIEW (object));
-
- yv = YEAR_VIEW (object);
-
- if (yv->need_resize) {
- yv->need_resize = FALSE;
- gtk_idle_remove (yv->idle_id);
- }
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-GtkWidget *
-year_view_new (GnomeCalendar *calendar, time_t year)
-{
- YearView *yv;
-
- g_return_val_if_fail (calendar != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CALENDAR (calendar), NULL);
-
- yv = gtk_type_new (year_view_get_type ());
- yv->calendar = calendar;
-
- year_view_colors_changed (yv);
- year_view_set (yv, year);
- compute_min_size (yv);
-
- return GTK_WIDGET (yv);
-}
-
-static void
-year_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- YearView *yv;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (IS_YEAR_VIEW (widget));
- g_return_if_fail (requisition != NULL);
-
- yv = YEAR_VIEW (widget);
-
- requisition->width = yv->min_width;
- requisition->height = yv->min_height;
-}
-
-static void
-year_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- YearView *yv;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (IS_YEAR_VIEW (widget));
- g_return_if_fail (allocation != NULL);
-
- yv = YEAR_VIEW (widget);
-
- if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
- (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
-
- need_resize (yv);
-}
-
-void
-year_view_update (YearView *yv, iCalObject *object, int flags)
-{
- g_return_if_fail (yv != NULL);
- g_return_if_fail (IS_YEAR_VIEW (yv));
-
- /* If only the summary changed, we don't care */
-
- if (object && ((flags & CHANGE_SUMMARY) == flags))
- return;
-
- year_view_set (yv, time_year_begin (time_from_day (yv->year, 0, 1)));
-}
-
-/* Unmarks the old day that was marked as current and marks the current day if appropriate */
-static void
-mark_current_day (YearView *yv)
-{
- time_t t;
- struct tm tm;
- int month_index, day_index;
- GnomeCanvasItem *item;
-
- /* Unmark the old day */
-
- if (yv->old_marked_day != -1) {
- month_index = yv->old_marked_day / 42;
- day_index = yv->old_marked_day % 42;
-
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[month_index]),
- GNOME_MONTH_ITEM_DAY_LABEL + day_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
- "fontset", NORMAL_DAY_FONTSET,
- NULL);
-
- yv->old_marked_day = -1;
- }
-
- /* Mark the new day */
-
- t = time (NULL);
- tm = *localtime (&t);
-
- if ((tm.tm_year + 1900) == yv->year) {
- month_index = tm.tm_mon;
- day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (yv->mitems[month_index]), tm.tm_mday);
- g_assert (day_index != -1);
-
- item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[month_index]),
- GNOME_MONTH_ITEM_DAY_LABEL + day_index);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
- "fontset", CURRENT_DAY_FONTSET,
- NULL);
-
- yv->old_marked_day = month_index * 42 + day_index;
- }
-}
-
-void
-year_view_set (YearView *yv, time_t year)
-{
- struct tm tm;
- char buf[100];
- int i;
-
- g_return_if_fail (yv != NULL);
- g_return_if_fail (IS_YEAR_VIEW (yv));
-
- tm = *localtime (&year);
- yv->year = tm.tm_year + 1900;
-
- /* Heading */
-
- sprintf (buf, "%d", yv->year);
- gnome_canvas_item_set (yv->heading,
- "text", buf,
- NULL);
-
- /* Months */
-
- for (i = 0; i < 12; i++)
- gnome_canvas_item_set (yv->mitems[i],
- "year", yv->year,
- "month", i,
- NULL);
-
- /* Unmark and re-mark all the months */
-
- for (i = 0; i < 12; i++) {
- unmark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]));
- mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
- }
-
- mark_current_day (yv);
-}
-
-void
-year_view_time_format_changed (YearView *yv)
-{
- int i;
-
- g_return_if_fail (yv != NULL);
- g_return_if_fail (IS_YEAR_VIEW (yv));
-
- for (i = 0; i < 12; i++)
- gnome_canvas_item_set (yv->mitems[i],
- "start_on_monday", week_starts_on_monday,
- NULL);
-
- year_view_set (yv, time_year_begin (time_from_day (yv->year, 0, 1)));
-}
-
-void
-year_view_colors_changed (YearView *yv)
-{
- int i;
-
- g_return_if_fail (yv != NULL);
- g_return_if_fail (IS_YEAR_VIEW (yv));
-
- for (i = 0; i < 12; i++) {
- colorify_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), default_color_func, NULL);
- mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
- }
-
- mark_current_day (yv);
-}
diff --git a/calendar/year-view.h b/calendar/year-view.h
deleted file mode 100644
index 77e63366d5..0000000000
--- a/calendar/year-view.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Year view display for Gnomecal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Arturo Espinosa <arturo@nuclecu.unam.mx>
- * Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef YEAR_VIEW_H
-#define YEAR_VIEW_H
-
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-#include "gnome-month-item.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define TYPE_YEAR_VIEW (year_view_get_type ())
-#define YEAR_VIEW(obj) (GTK_CHECK_CAST ((obj), TYPE_YEAR_VIEW, YearView))
-#define YEAR_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_YEAR_VIEW, YearViewClass))
-#define IS_YEAR_VIEW(obj) (GTK_CHECK_TYPE ((obj), TYPE_YEAR_VIEW))
-#define IS_YEAR_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_YEAR_VIEW))
-
-
-typedef struct _YearView YearView;
-typedef struct _YearViewClass YearViewClass;
-
-struct _YearView {
- GnomeCanvas canvas;
-
- GnomeCalendar *calendar; /* The calendar we are associated to */
-
- int year; /* The year we are displaying */
-
- GnomeCanvasItem *heading; /* Big heading with year */
- GnomeCanvasItem *titles[12]; /* Titles for months */
- GnomeCanvasItem *mitems[12]; /* Month items */
-
- int old_marked_day; /* The day that is marked as the current day */
-
- int min_width; /* Minimum dimensions of year view, used for size_request*/
- int min_height;
-
- guint idle_id; /* ID of idle handler for resize */
-
- int need_resize : 1; /* Specifies whether we need to resize the canvas items or not */
-};
-
-struct _YearViewClass {
- GnomeCanvasClass parent_class;
-};
-
-
-/* Standard Gtk function */
-GtkType year_view_get_type (void);
-
-/* Creates a new year view widget associated to the specified calendar */
-GtkWidget *year_view_new (GnomeCalendar *calendar, time_t year);
-
-/* Notifies the year view that a calendar object has changed */
-void year_view_update (YearView *yv, iCalObject *ico, int flags);
-
-/* Notifies the year view about a change of date */
-void year_view_set (YearView *yv, time_t year);
-
-/* Notifies the year view that the time format has changed */
-void year_view_time_format_changed (YearView *yv);
-
-/* Notifies the year view that colors have changed */
-void year_view_colors_changed (YearView *yv);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/libversit/.cvsignore b/libversit/.cvsignore
deleted file mode 100644
index e995588475..0000000000
--- a/libversit/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.deps
-Makefile
-Makefile.in
diff --git a/libversit/Makefile.am b/libversit/Makefile.am
deleted file mode 100644
index 95918fb4a0..0000000000
--- a/libversit/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-
-noinst_LTLIBRARIES = libversit.la
-
-libversit_la_SOURCES = \
- vcc.y \
- vcc.h \
- vobject.c \
- vobject.h \
- port.h \
- vcaltmp.c \
- vcaltmp.h
-
-EXTRA_DIST = README.TXT vcaltest.c vctest.c
diff --git a/libversit/README.TXT b/libversit/README.TXT
deleted file mode 100644
index c8ce8b0979..0000000000
--- a/libversit/README.TXT
+++ /dev/null
@@ -1,951 +0,0 @@
-NOTE: If you used the earlier APIs released by Versit
-then you will want to look at the document "migrate.doc"
-included with this package. It contains a discussion of
-the differences between the old API and this one.
-
-----------------------------------------------------------------
-
-The vCard/vCalendar C interface is implemented in the set
-of files as follows:
-
-vcc.y, yacc source, and vcc.c, the yacc output you will use
-implements the core parser
-
-vobject.c implements an API that insulates the caller from
-the parser and changes in the vCard/vCalendar BNF
-
-port.h defines compilation environment dependent stuff
-
-vcc.h and vobject.h are header files for their .c counterparts
-
-vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions
-which you may find useful.
-
-test.c is a standalone test driver that exercises some of
-the features of the APIs provided. Invoke test.exe on a
-VCARD/VCALENDAR input text file and you will see the pretty
-print output of the internal representation (this pretty print
-output should give you a good idea of how the internal
-representation looks like -- there is one such output in the
-following too). Also, a file with the .out suffix is generated
-to show that the internal representation can be written back
-in the original text format.
-
------------------------------------------------------------------
-
-
- VObject for VCard/VCalendar
-
-Table of Contents
-=================
-1. VObject
-2. Internal Representations of VCard/VCalendar
-3. Iterating Through VObject's Properties or Values
-4. Pretty Printing a VObject Tree
-5. Building A VObject Representation of A VCard/VCalendar
-6. Converting A VObject Representation Into Its Textual Representation
-7. Miscellaneous Notes On VObject APIs usages
-8. Brief descriptions of each APIs
-9. Additional Programming Notes.
-
-This document is mainly about the VObject and its APIs. The main
-use of a VObject is to represent a VCard or a VCalendar inside
-a program. However, its use is not limited to aforemention as it
-can represent an arbitrary information that makes up of a tree or
-forest of properties/values.
-
-1. VObject
- =======
-A VObject can have a name (id) and a list of associated properties and
-a value. Each property is itself a VObject.
-
-2. Internal Representations of VCard/VCalendar
- ===========================================
-A list of VCard or a VCalendar is represented by a list of VObjects.
-The name (id) of the VObjects in the list is either VCCardProp or
-VCCalProp. Each of these VObjects can have a list of properties.
-Since a property is represented as a VObject, each of these properties
-can have a name, a list of properties, and a value.
-
-For example, the input file "vobject.vcf":
-
-BEGIN:VCARD
-N:Alden;Roland
-FN:Roland H. Alden
-ORG:AT&T;Versit Project Office
-TITLE:Consultant
-EMAIL;WORK;PREF;INTERNET:sf!rincon!ralden@alden.attmail.com
-EMAIL;INTERNET:ralden@sfgate.com
-EMAIL;MCIMail:242-2200
-LABEL;DOM;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-Suite 2208=0A=
-One Pine Street=0A=
-San Francisco, CA 94111
-LABEL;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-Suite 2208=0A=
-One Pine Street=0A=
-San Francisco, CA 94111=0A=
-U.S.A.
-TEL;WORK;PREF;MSG:+1 415 296 9106
-TEL;WORK;FAX:+1 415 296 9016
-TEL;MSG;CELL:+1 415 608 5981
-ADR:;Suite 2208;One Pine Street;San Francisco;CA;94111;U.S.A.
-SOUND:ROW-LAND H ALL-DIN
-LOGO;GIF;BASE64:
- R0lGODdhpgBOAMQAAP///+/v797e3s7Ozr29va2trZycnIyMjHt7e2NjY1JSUkJC
- QjExMSEhIRAQEO///87v9973/73n95zW71K13jGl1nvG50Kt3iGc1gCMzq3e94zO
- 7xCU1nO952O15wAAACwAAAAApgBOAAAF/yAgjmRpnmiqrmzrvnAsz3Rt33iu73zv
- /8CgcEj8QTaeywWTyWCUno2kSK0KI5tLc8vtNi+WiHVMlj0mFK96nalsxOW4fPSw
- cNj4tQc+7xcjGh4WExJTJYUTFkp3eU0eEH6RkpOUlTARhRoWm5ydFpCWoS0QEqAu
- ARKaHRcVjV0borEoFl0cSre4Sq67FA+yvwAeTU8XHZ7HmxS6u2wVfMCVpAE3pJoW
- ylrMptDcOqSF4OHg3eQ5pInInb7lcc86mNbLzBXsZbRfUOn6ucyNHvVWJHCpQFDf
- MWwEEzLqx2YCQCqF3OnItClJNmYcJD7cSAKTuI/gtnEcOQKkyVIk6/+ds5CkFcMM
- 61LiENikwi1jBnNyuvUSjwWZOS5uIZarqNFcNl32XMMB6I06GgoJ+bZp1ZKeDl8E
- +MC1K1cBIhZ4HUu2LAsCZdOWRQDt20lxIlccSHsgrNq7Xc/ixcsWmNu34WKyYJCW
- gQjCe9XqTZy2L4pv04gg2sSKSc8OLgTcBSuWsdkVaD2TdXyiQxebFyjo1Gnx6tJm
- LuaqrdtZtNfFtruSNmF5IKujwIsmJbjwtRqNJhrcNVw79wcRAgogmE4ArIjQzj/s
- JvHAGCFDQR4UqigPK4sBe62XwO51OwADiMcqUG+iOdcFAL+hW20BfAoEexlwAnu6
- mZDAXQ1EVh//WfhxJB5gIbHgwFgOTOiVAgOuVQKAfKFg3weGwSBYFZMp4hpDGKyA
- 3lgJKECWgiMQyBVpW+0V4oJjNfhCNkR1IgWEb21QlRK9GdfFCgeOZYBsXgm4noYj
- GEBhAQHYh0J8XenoQnFGdrkUciJY6FUAK15ogozakcBhliKsyZWHDMZQ0wWC/Aim
- DB6h01KRr/lXQgFxAqDcWDACgCZpUnrVQJtjwTnWjS6MWAYqqfDnSaEkJOlVXQBo
- 2pWTMUJ53WgAuPncCR9q6VQMAYjZlXWJmknCoSUM2p4BC+SaKwG88hoZlvfFMM4f
- hQh5TXkv+RklWYtC91mopJIAKFkJlDAW/wF25ShnLbeo5gmQ+1FGkJdrKCuCi2OR
- BuwHBcwqKgABrMtVAgpem61XkLbAJ7n8uiIpvGVhO4KpH1QLbbpqLheZvQCkGoNL
- thSzSTg2UGVBBzbtaxwKsYrmgLvRAlCmWgwMAADD66rKAgR3XlGspcdkZYK8ibU7
- asgEl+XAyB8I7PCqMWiWncGGimpfAgO4ypXSPpOVLwsRCDJxRD2AoyeRRv5kApO5
- fXwzwvfOKLKtaTWtbQxccmGLTZy8xYlVSvXbhbk0M2YzrYfJJ0K8m+V9NgxpyC04
- UycI/aiuiH9Y8NftDUwWp1Wm5UABnAUKwwRsPFGBt4Oc9PZvGvNLwf8JOZt8Arpe
- eY23yDovwIDiBX74NAsPVLDJj3Hh4JEExsKcjrlKf9DsCVx3ZfLqAKBuG1s/A90C
- z2KjYHjjyPOdG1spz6BBUr+BcUxUb1nDCTa/VZD2Uv+YkLPAKJC9dNEh7628WgqI
- ybzlaA+ufxMa6bxC6ciLUQLcx5UGIAAsAkDA6wQkOxrcY39yo4cQMNWCAPTKV1R4
- wPkgaBxzOc8FtMiF1NoGoXBRJjgoPApmPsjCFlbMdzCM4TFy50IXxI2DPcHAv2rY
- gghsEIeu8CAPW6ABIPYEFkOsAeaMyIz0JfGJUExBBGRIRX0IMYovWCIT1eBELNpA
- i1vcgta8iANPCIQOghzQABl30J0tXqBla4wjFLFQxZzAUY42CIAd5OYBCuKxB2c4
- I0b28EcrQKADgmSKB9RYyDhA4BqCxIBqrtjIMTwoFeCjYSU3KZMQAAA7
-
-BEGIN:VCALENDAR
-DCREATED:19960523T100522
-PRODID:-//Alden Roland/Hand Crafted In North Carolina//NONSGML Made By Hand//EN
-VERSION:0.3
-BEGIN:VEVENT
-START:19960523T120000
-END:19960523T130000
-SUBTYPE:PHONE CALL
-SUMMARY:VERSIT PDI PR Teleconference/Interview
-DESCRIPTION:VERSIT PDI PR Teleconference/Interview With Tom Streeter and Alden Roland
-END:VEVENT
-BEGIN:VEVENT
-START:19960523T113000
-END:19960523T115500
-SUBTYPE:LUNCH
-SUMMARY:Eat in the cafeteria today
-END:VEVENT
-END:VCALENDAR
-
-END:VCARD
-
-
-will conceptually be be represented as
- vcard
- VCNameProp
- VCFamilyNameProp=Alden
- VCGivenNameProp=Roland
- VCFullNameProp=Roland H.Alden
- ....
-
-note that
- EMAIL;WORK;PREF;INTERNET:sf!rincon!ralden@alden.attmail.com
-will be represented as:
- VCEmailAddress=sf!rincon!ralden@alden.attmail.com
- VCWork
- VCPreferred
- VCInternet
-where the lower level properties are properties of the property
-VCEmailAddress.
-
-Groupings are flattened out in the VObject representation such
-that:
- a.b:blah
- a.c:blahblah
-are represented as:
- b=blah
- VCGrouping=a
- c=blahblah
- VCGrouping=a
-i.e. one can read the above as:
- the property "b" has value "blah" and property "VCGrouping"
- with the value "a".
- the property "c" has value "blahblah" and property "VCGrouping"
- with the value "a".
-likewise, multi-level groupings are flatten similarly. e.g.
- a.b.c:blah
- a.b.e:blahblah
--->
- c=blah
- VCGrouping=b
- VCGrouping=a
- e=blahblah
- VCGrouping=b
- VCGrouping=a
-which read:
- the property "c" has value "blah" and property "VCGrouping"
- with the value "b" which has property "VCGrouping"
- with value "a".
- the property "e" has value "blahblah" and property "VCGrouping"
- with the value "b" which has property "VCGrouping"
- with value "a".
-
-3. Iterating Through VObject's Properties or Values
- ================================================
-The following is a skeletal form of iterating through
-all properties of a vobject, o:
-
- // assume the object of interest, o, is of type VObject
- VObjectIterator i;
- initPropIterator(&i,o);
- while (moreIteration(&i)) {
- VObject *each = nextVObject(&i);
- // ... do something with "each" property
- }
-
-Use the API vObjectName() to access a VObject's name.
-Use the API vObjectValueType() to determine if a VObject has
- a value. For VCard/VCalendar application, you
- should not need this function as practically
- all values are either of type VCVT_USTRINGZ or
- VCVT_RAW (i.e set by setVObjectUStringZValue and
- setVObjectAnyValue APIs respectively), and the
- value returned by calls to vObjectUStringZValue
- and vObjectAnyValue are 0 if a VObject has no
- value. (There is a minor exception where VObject with
- VCDataSizeProp has value that is set by
- setVObjectLongValue).
-Use the APIs vObject???Value() to access a VObject's value.
- where ??? is the expected type.
-Use the APIs setvObject???Value() to set or modify a VObject's value.
- where ??? is the expected type.
-Use the API isAPropertyOf() to query if a name match the name of
- a property of a VObject. Since isAPropertyOf() return
- the matching property, we can use that to retrieve
- a property and subsequently the value of the property.
-
-4. Pretty Printing a VObject Tree
- ==============================
-VObject tree can be pretty printed with the printVObject() function.
-The output of pretty printing a VObject representation of the input
-test file "vobject.vcf" is shown below. Note that the indentation
-indicates the tree hirerarchy where the immediate children nodes
-of a parent node is all at the same indentation level and the
-immediate children nodes are the immediate properties of the
-associated parent nodes. In the following, {N,FN,ORG,TITLE,...}
-are immediate properties of VCARD. {F and G} are properties of N
-with value {"Alden" and "Roland"} respectively; FN has no property
-but has the value "Roland H. Alden"; EMAIL has value and
-the properties WORK, PREF, and INTERNET.
-
-
-VCARD
- N
- F="Alden"
- G="Roland"
- FN="Roland H. Alden"
- ORG
- ORGNAME="AT&T"
- OUN="Versit Project Office"
- TITLE="Consultant"
- EMAIL="sf!rincon!ralden@alden.attmail.com"
- WORK
- PREF
- INTERNET
- EMAIL="ralden@sfgate.com"
- INTERNET
- EMAIL="242-2200"
- MCIMail
- LABEL="Roland H. Alden
- Suite 2208
- One Pine Street
- San Francisco, CA 94111"
- DOM
- POSTAL
- PARCEL
- HOME
- WORK
- QP
- LABEL="Roland H. Alden
- Suite 2208
- One Pine Street
- San Francisco, CA 94111
- U.S.A."
- POSTAL
- PARCEL
- HOME
- WORK
- QP
- TEL="+1 415 296 9106"
- WORK
- PREF
- MSG
- TEL="+1 415 296 9016"
- WORK
- FAX
- TEL="+1 415 608 5981"
- MSG
- CELL
- ADR
- EXT ADD="Suite 2208"
- STREET="One Pine Street"
- L="San Francisco"
- R="CA"
- PC="94111"
- C="U.S.A."
- SOUND="ROW-LAND H ALL-DIN"
- LOGO=[raw data]
- GIF
- BASE64
- DataSize=1482
-VCALENDAR
- DCREATED="19960523T100522"
- PRODID="-//Alden Roland/Hand Crafted In North Carolina//NONSGML Made By Hand//EN"
- VERSION="0.3"
- VEVENT
- START="19960523T120000"
- END="19960523T130000"
- SUBTYPE="PHONE CALL"
- SUMMARY="VERSIT PDI PR Teleconference/Interview"
- DESCRIPTION="VERSIT PDI PR Teleconference/Interview With Tom Streeter and Alden Roland"
- VEVENT
- START="19960523T113000"
- END="19960523T115500"
- SUBTYPE="LUNCH"
- SUMMARY="Eat in the cafeteria today"
-
-5. Building A VObject Representation of A VCard/VCalendar
- ======================================================
-The parser in vcc.y converts an input file with one or more
-VCard/VCalendar that is in their textual representation
-into their corresponding VObject representation.
-
-VObject representation of a VCard/VCalendar can also be built
-directly with calls to the VObject building APIs. e.g.
-
- VObject *prop;
- VObject *vcard = newVObject(VCCardProp);
- prop = addProp(vcard,VCNameProp);
- addPropValue(prop,VCFamilyNameProp,"Alden");
- addPropValue(prop,VCGivenNameProp,"Roland");
- addPropValue(vcard,VCFullNameProp,"Roland H. Alden");
- ....
-
-6. Converting A VObject Representation Into Its Textual Representation
- ===================================================================
-The VObject representation can be converted back to its textual
-representation via the call to writeVObject() or writeMemVObject()
-API. e.g.
- a. to write to a file:
- // assume vcard is of type VObject
- FILE *fp = fopen("alden.vcf","w");
- writeVObject(fp,vcard);
- a. to write to memory, and let the API allocate the required memory.
- char* clipboard = writeVObject(0,0,vcard);
- ... do something to clipboard
- free(clipboard);
- b. to write to a user allocated buffer:
- char clipboard[16384];
- int len = 16384;
- char *buf = writeVObject(clipboard,&len,vcard);
- ... buf will be equal to clipboard if the write
- is successful otherwise 0.
-
-In the case of writing to memory, the memory buffer can be either
-allocated by the API or the user. If the user allocate the
-memory for the buffer, then the length of the buffer needs to be
-communicated to the API via a variable. The variable passed as
-the length argument will be overwritten with the actual size
-of the text output. A 0 return value from writeMemVObject()
-indicates an error which could be caused by overflowing the
-size of the buffer or lack of heap memory.
-
-7. Miscellaneous Notes On VObject APIs usages
- ==========================================
-a. vcc.h -- contains basic interfaces to the parser:
- VObject* Parse_MIME(const char *input, unsigned long len);
- VObject* Parse_MIME_FromFile(FILE *file);
- -- both of this return a null-terminated list of
- VObject that is either a VCARD or VCALENDAR.
- To iterate through this list, do
- VObject *t, *v;
- v = Parse_Mime_FromFile(fp);
- while (v) {
- // ... do something to v.
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
- note that call to cleanVObject will release
- resource used to represent the VObject.
-
-b. vobject.h -- contains basic interfaces to the VObject APIs.
- see the header for more details.
- The structure of VObject is purposely (hiddened) not exposed
- to the user. Every access has to be done via
- the APIs. This way, if we need to change the
- structure or implementation, the client need not
- recompile as long as the interfaces remain the
- same.
-
-c. values of a property is determined by the property definition
- itself. The vobject APIs does not attempt to enforce
- any of such definition. It is the consumer responsibility
- to know what value is expected from a property. e.g
- most properties have unicode string value, so to access
- the value of these type of properties, you will use
- the vObjectUStringZValue() to read the value and
- setVObjectUStringZValue() to set or modify the value.
- Refer to the VCard and VCalendar specifications for
- the definition of each property.
-
-d. properties name (id) are case incensitive.
-
-8. Brief descriptions of each APIs
- ===============================
- * the predefined properties' names (id) are listed under vobject.h
- each is of the form VC*Prop. e.g.
- #define VC7bitProp "7BIT"
- #define VCAAlarmProp "AALARM"
- ....
-
- * consumer of a VObject can only define pointers to VObject.
-
- * a variable of type VObjectIterator, say "i", can be used to iterate
- through a VObject's properties, say "o". The APIs related to
- VObjectIterator are:
- void initPropIterator(VObjectIterator *i, VObject *o);
- -- e.g. usage
- initPropIterator(&i,o);
- int moreIteration(VObjectIterator *i);
- -- e.g. usage
- while (moreIteration(&i)) { ... }
- VObject* nextVObject(VObjectIterator *i);
- -- e.g. usage
- while (moreIteration(&i)) {
- VObject *each = nextVObject(&i);
- }
-
- * VObject can be chained together to form a list. e.g. of such
- use is in the parser where the return value of the parser is
- a link list of VObject. A link list of VObject can be
- built by:
- void addList(VObject **o, VObject *p);
- and iterated by
- VObject* nextVObjectInList(VObject *o);
- -- next VObjectInList return 0 if the list
- is exhausted.
-
- * the following APIs are mainly used to construct a VObject tree:
- VObject* newVObject(const char *id);
- -- used extensively internally by VObject APIs but when
- used externally, its use is mainly limited to the
- construction of top level object (e.g. an object
- with VCCardProp or VCCalendarProp id).
-
- void deleteVObject(VObject *p);
- -- to deallocate single VObject, for most user, use
- cleanVObject(VObject *o) instead for freeing all
- resources associated with the VObject.
-
- char* dupStr(const char *s, unsigned int size);
- -- duplicate a string s. If size is 0, the string is
- assume to be a null-terminated.
-
- void deleteStr(const char *p);
- -- used to deallocate a string allocated by dupStr();
-
- void setVObjectName(VObject *o, const char* id);
- -- set the id of VObject o. This function is not
- normally used by the user. The setting of id
- is normally done as part of other APIs (e.g.
- addProp()).
-
- void setVObjectStringZValue(VObject *o, const char *s);
- -- set a string value of a VObject.
-
- void setVObjectUStringZValue(VObject *o, const wchar_t *s);
- -- set a Unicode string value of a VObject.
-
- void setVObjectIntegerValue(VObject *o, unsigned int i);
- -- set an integer value of a VObject.
-
- void setVObjectLongValue(VObject *o, unsigned long l);
- -- set an long integer value of a VObject.
-
- void setVObjectAnyValue(VObject *o, void *t);
- -- set any value of a VObject. The value type is
- unspecified.
-
- VObject* setValueWithSize(VObject *prop, void *val, unsigned int size);
- -- set a raw data (stream of bytes) value of a VObject
- whose size is size. The internal VObject representation
- is
- this object = val
- VCDataSizeProp=size
- i.e. the value val will be attached to the VObject prop
- and a property of VCDataSize whose value is size
- is also added to the object.
-
- void setVObjectVObjectValue(VObject *o, VObject *p);
- -- set a VObject as the value of another VObject.
-
- const char* vObjectName(VObject *o);
- -- retrieve the VObject's Name (i.e. id).
-
- const char* vObjectStringZValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- null-terminated string.
-
- const wchar_t* vObjectUStringZValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- null-terminated unicode string.
-
- unsigned int vObjectIntegerValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- integer.
-
- unsigned long vObjectLongValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- long integer.
-
- void* vObjectAnyValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- any value.
-
- VObject* vObjectVObjectValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- a VObject.
-
- VObject* addVObjectProp(VObject *o, VObject *p);
- -- add a VObject p as a property of VObject o.
- (not normally used externally for building a
- VObject).
-
- VObject* addProp(VObject *o, const char *id);
- -- add a property whose name is id to VObject o.
-
- VObject* addPropValue(VObject *o, const char *id, const char *v);
- -- add a property whose name is id and whose value
- is a null-terminated string to VObject o.
-
- VObject* addPropSizedValue(VObject *o, const char *id,
- const char *v, unsigned int size);
- -- add a property whose name is id and whose value
- is a stream of bytes of size size, to VObject o.
-
- VObject* addGroup(VObject *o, const char *g);
- -- add a group g to VObject o.
- e.g. if g is a.b.c, you will have
- o
- c
- VCGroupingProp=b
- VCGroupingProp=a
- and the object c is returned.
-
- VObject* isAPropertyOf(VObject *o, const char *id);
- -- query if a property by the name id is in o and
- return the VObject that represent that property.
-
- void printVObject(VObject *o);
- -- pretty print VObject o to stdout (for debugging use).
-
- void writeVObject(FILE *fp, VObject *o);
- -- convert VObject o to its textual representation and
- write it to file.
-
- char* writeMemVObject(char *s, int *len, VObject *o);
- -- convert VObject o to its textual representation and
- write it to memory. If s is 0, then memory required
- to hold the textual representation will be allocated
- by this API. If a variable len is passed, len will
- be overwriten with the byte size of the textual
- representation. If s is non-zero, then s has to
- be a user allocated buffer whose size has be passed
- in len as a variable. Memory allocated by the API
- has to be freed with call to free. The return value
- of this API is either the user supplied buffer,
- the memory allocated by the API, or 0 (in case of
- failure).
-
- void cleanStrTbl();
- -- this function has to be called when all
- VObject has been destroyed.
-
- void cleanVObject(VObject *o);
- -- release all resources used by VObject o.
-
- wchar_t* fakeUnicode(const char *ps, int *bytes);
- -- convert char* to wchar_t*.
-
- extern int uStrLen(const wchar_t *u);
- -- length of unicode u.
-
- char *fakeCString(const wchar_t *u);
- -- convert wchar_t to CString (blindly assumes that
- this could be done).
-
-9. Additional Programming Notes
- ============================
-In the following notes, please refers to the listing
-of Example.vcf and its VObject Representation
-(shown at the end of this section).
-
-* Handling the Return Value of the VCard/VCalendar Parser
- The example input text file contains two root VObjects
- (a VCalendar and a VCard). The output of the VCard/VCalendar
- parser is a null-terminated list of VObjects. For this
- particular input file, the list will have two VObjects.
- The following shows a template for iterating through the
- output of the Parser:
-
- VObject *t, *v;
- v = Parse_Mime_fromFileName("example.vcf");
- while (v) {
- // currently, v will either be a VCard or a VCalendar
- // do whatever your application need to do to
- // v here ...
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
-
-* Iterating Through a VCard/VCalendar VObject
- From the VObject APIs point of view, a VCard VObject
- is the same as a VCalendar VObject. However, the application
- needs to know what are in a VCard or a VCalendar.
- For example, A VCalendar VObject can have VCDCreatedProp,
- a VCGEOLocationProp, etc, and one or more VCEventProp and
- or VCTodoProp. The VCEventProp and VCTodoProp can have
- many properties of their own, which in turn could have
- more properties (e.g. VCDAlarmProp can be a VCEventProp
- VObject's property, and VCRunTimeProp can be a
- VCDAlarmProp VObject's property. Because a VObject tree
- can be arbitrarily complex, in general, to process all
- properties and values of a VObject tree, a recursive walk
- is desirable. An example recursive VObject tree walk
- can be found in the vobject.c source lines for printVObject*
- and writeVObject* APIs. Depending on what the application need
- to do with a VCard or a VCalendar, a recursive walk
- of the VObject tree may or may not be desirable. An example
- template of a non-recursive walk is shown below:
-
- void processVCardVCalendar(char *inputFile)
- {
- VObject *t, *v;
- v = Parse_Mime_fromFileName(inputFile);
- while (v) {
- char *n = vObjectName(v);
- if (strcmp(n,VCCardProp) == 0) {
- do_VCard(v);
- }
- else if (strcmp(n,VCCalendarProp) == 0) {
- do_VCalendar(v);
- }
- else {
- // don't know how to handle anything else!
- }
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
- }
-
- void do_VCard(VObject *vcard)
- {
- VObjectIterator t;
- initPropIterator(&t,vcard);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- // The primarly purpose of this example is to
- // show how to iterate through a VCard VObject,
- // it is not meant to be efficient at all.
- char *n = vObjectName(eachProp);
- if (strcmp(n,VCNameProp)==0) {
- do_name(eachProp);
- }
- else if (strcmp(n,VCEmailProp)==0) {
- do_email(eachProp);
- }
- else if (strcmp(n,VCLabelProp)==0) {
- do_label(eachProp);
- }
- else if ....
- }
- }
-
- void do_VCalendar(VObject *vcal)
- {
- VObjectIterator t;
- initPropIterator(&t,vcard);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- // The primarly purpose of this example is to
- // show how to iterate through a VCalendar VObject,
- // it is not meant to be efficient at all.
- char *n = vObjectName(eachProp);
- if (strcmp(n,VCDCreatedProp)==0) {
- do_DCreated(eachProp);
- }
- else if (strcmp(n,VCVersionProp)==0) {
- do_Version(eachProp);
- }
- else if (strcmp(n,VCTodoProp)==0) {
- do_Todo(eachProp);
- }
- else if (strcmp(n,VCEventProp)==0) {
- do_Event(eachProp);
- }
- else if ....
- }
- }
-
- void do_Todo(VObject *vtodo) { ... }
-
- void do_Event(VObject *vevent) { ... }
-
- ...
-
-* Property's Values and Properties
- The VObject APIs do not attempt to check for the
- correctness of the values of a property. Nor do they
- will prevent the user from attaching a non-VCard/VCalendar
- standard property to a VCard/VCalendar property. Take
- the example of line [11] of the example, "O.K" is not
- a valid value of VCStatusProp. It is up to the application
- to accept or reject the value of a property.
-
-* Output of printVObject
- PrintVObject pretty prints a VObject tree in human
- readable form. See the listing at the end of the file
- for an example output of printVObject on the example
- input file "Example.vcf".
-
- Note that binary data are not shown in the output of
- printVObject. Instead, a note is made ([raw data]) to
- indicate that there exists such a binary data.
-
-* Note on Binary Data
- When the value of a property is a binary data, it is only
- useful to know the size of the binary data.
-
- In the case of the VCard/VCalendar parser, it chooses
- to represent the size information as a separate property
- called VCDataSizeProp whose value is the size of the binary
- data. The APIs sequence to construct the VObject subtree
- of line [44] of Example.vcf is
-
- // VObject *vcard;
- VObject *p1 = addProp(vcard,VCLogoProp);
- (void) addProp(p1,VCGIFProp);
- (void) addProp(p1,VCBASE64Prop);
- VObject *p2 = addProp(p1,VCDataSizeProp);
- (void) setVObjectLongValue(p2,1482);
- setVObjectAnyValue(vcard,...pointer to binary data);
-
- Note the presence of VCBase64Prop will cause the
- writeVObject API to output the binary data as BASE64 text.
- For VCard/VCalendar application, having the VCBase64Prop
- property is pratically always neccessary for property with
- binary data as its value.
-
-* Note on Quoted-Printable String
- String value with embedded newline are written out as
- quoted-prinatable string. It is therefore important
- to mark a property with a string value that has
- one or more embedded newlines, with the VCQutedPrintableProp
- property. e.g.
-
- // VObject *root;
- char *msg="To be\nor\nnot to be";
- VObject *p = addPropValue(root,VCDescriptionProp,msg);
- // the following is how you mark a property with
- // a property. In this case, the marker is
- // VCQuotedPrintableProp
- addProp(p,VCQuotedPrintableProp);
-
-* Note on Unicode
- Although, the current parser takes ASCII text file only,
- string values are all stored as Unicode in the VObject tree.
- For now, when using the VObject APIs to construct a
- VObject tree, one should always convert ASCII string value
- to a Unicode string value:
-
- // VObject *root;
- VObject *p = addProp(root,VCSomeProp);
- setVObjectUStringZValue(p,fakeUnicode(someASCIIStringZvalue));
-
- An API is provided to simplify the above process:
-
- addPropValue(root,VCSomeProp,someASCIIStringZValue);
-
- Note that someASCIISTringZValue is automatically converted to
- Unicode by addPropValue API, where as, the former code
- sequence do an explicit call to fakeUnicode.
-
- To read back the value, one should use the vObjectUStringZValue
- API not vObjectStringZValue API. The value returned by the
- vObjectUStringZValue API is a Unicode string. If the application
- do not know how to handle Unicode string, it can use the
- fakeCString API to convert it back to ASCII string (as long
- as the conversion is meaningful).
-
- Note that fakeCString return a heap allocated memory. It is
- important to call deleteStr on fakeCString return value if
- it is not longer required (or there will be memory leak).
-
- NOTE: Unfortunately, at the point when this document is written,
- there is still no consensus on how Unicode is to be handled
- in the textual representation of VCard/VCalendar. So, there
- is no version of writeVObject and the parser to output and
- input Unicode textual representation of VCard/VCalendar.
-
-
-Example.vcf
------------
-line
-number Input Text (example.vcf)
------- ----------
-1 BEGIN:VCALENDAR
-2 DCREATED:19961102T100522
-3 GEO:0,0
-4 VERSION:1.0
-5 BEGIN:VEVENT
-6 DTSTART:19961103T000000
-7 DTEND:20000101T000000
-8 DESCRIPTION;QUOTED-PRINTABLE:To be =0A=
-9 or =0A=
-10 not to be
-11 STATUS:O.K.
-12 X-ACTION:No action required
-13 DALARM:19961103T114500;5;3;Enjoy
-14 MALARM:19970101T120000;;;johny@nowhere.com;Call Mom.
-15 END:VEVENT
-16
-17 BEGIN:VTODO
-18 DUE:19960614T0173000
-19 DESCRIPTION:Relex.
-20 END:VTODO
-21
-22 END:VCALENDAR
-23
-24 BEGIN:VCARD
-25 N:Alden;Roland
-26 FN:Roland H. Alden
-27 ORG:AT&T;Versit Project Office
-28 TITLE:Consultant
-29 EMAIL;WORK;PREF;INTERNET:ralden@ralden.com
-30 LABEL;DOM;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-31 Suite 2208=0A=
-32 One Pine Street=0A=
-33 San Francisco, CA 94111
-34 LABEL;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-35 Suite 2208=0A=
-36 One Pine Street=0A=
-37 San Francisco, CA 94111=0A=
-38 U.S.A.
-39 TEL;WORK;PREF;MSG:+1 415 296 9106
-40 TEL;WORK;FAX:+1 415 296 9016
-41 TEL;MSG;CELL:+1 415 608 5981
-42 ADR:;Suite 2208;One Pine Street;San Francisco;CA;94111;U.S.A.
-43 SOUND:ROW-LAND H ALL-DIN
-44 LOGO;GIF;BASE64:
-45 R0lGODdhpgBOAMQAAP///+/v797e3s7Ozr29va2trZycnIyMjHt7e2NjY1JSUkJC
- ... 30 lines of BASE64 data not shown here.
-76 END:VCARD
-
-
-VObject Representation of Example.vcf:
--------------------------------------
-line
-in
-text
-file VObject Tree as Printed by printVObject API
----- -------------------------------------------
-1 VCALENDAR
-2 DCREATED="19961102T100522"
-3 GEO="0,0"
-4 VERSION="1.0"
-5 VEVENT
-6 DTSTART="19961103T000000"
-7 DTEND="20000101T000000"
-8 DESCRIPTION="To be
-9 or
-10 not to be"
-8 QUOTED-PRINTABLE
-11 STATUS="O.K."
-12 X-ACTION="No action required"
-13 DALARM
-13 RUNTIME="19961103T114500"
-13 SNOOZETIME="5"
-13 REPEATCOUNT="3"
-13 DISPLAYSTRING="Enjoy"
-14 MALARM
-14 RUNTIME="19970101T120000"
-14 EMAIL="johny@nowhere.com"
-14 NOTE="Call Mom"
-17 VTODO
-18 DUE="19960614T0173000"
-19 DESCRIPTION="Relex."
-24 VCARD
-25 N
-25 F="Alden"
-25 G="Roland"
-26 FN="Roland H. Alden"
-27 ORG
-27 ORGNAME="AT&T"
-27 OUN="Versit Project Office"
-28 TITLE="Consultant"
-29 EMAIL="ralden@alden.com"
-29 WORK
-29 PREF
-29 INTERNET
-30 LABEL="Roland H. Alden
-31 Suite 2208
-32 One Pine Street
-33 San Francisco, CA 94111"
-30 DOM
-30 POSTAL
-30 PARCEL
-30 HOME
-30 WORK
-30 QUOTED-PRINTABLE
-34 LABEL="Roland H. Alden
-35 Suite 2208
-36 One Pine Street
-37 San Francisco, CA 94111
-38 U.S.A."
-34 POSTAL
-34 PARCEL
-34 HOME
-34 WORK
-34 QUOTED-PRINTABLE
-39 TEL="+1 415 296 9106"
-39 WORK
-39 PREF
-39 MSG
-40 TEL="+1 415 296 9016"
-40 WORK
-40 FAX
-41 TEL="+1 415 608 5981"
-41 MSG
-41 CELL
-42 ADR
-42 EXT ADD="Suite 2208"
-42 STREET="One Pine Street"
-42 L="San Francisco"
-42 R="CA"
-42 PC="94111"
-42 C="U.S.A."
-43 SOUND="ROW-LAND H ALL-DIN"
-44 LOGO=[raw data]
-44 GIF
-44 BASE64
-44 DATASIZE=1482
-
diff --git a/libversit/port.h b/libversit/port.h
deleted file mode 100644
index 1768beebd8..0000000000
--- a/libversit/port.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-#ifndef __PORT_H__
-#define __PORT_H__ 1
-
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-extern "C" {
-#endif
-
-/* some of these #defines are commented out because */
-/* Visual C++ sets them on the compiler command line instead */
-
-/* #define _DEBUG */
-/* #define WIN32 */
-/* #define WIN16 */
-/* #define _WINDOWS */
-/* #define __MWERKS__ */
-/* #define INCLUDEMFC */
-
-#define vCardClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCard"
-#define vCalendarClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCalendar"
-
-/* The above strings vCardClipboardFormat and vCalendarClipboardFormat
-are globally unique IDs which can be used to generate clipboard format
-ID's as per the requirements of a specific platform. For example, in
-Windows they are used as the parameter in a call to RegisterClipboardFormat.
-For example:
-
- CLIPFORMAT foo = RegisterClipboardFormat(vCardClipboardFormat);
-
-*/
-
-#define vCardMimeType "text/x-vCard"
-#define vCalendarMimeType "text/x-vCalendar"
-
-#define DLLEXPORT(t) t
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#define stricmp strcasecmp
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-}
-#endif
-
-#endif /* __PORT_H__ */
diff --git a/libversit/vcaltest.c b/libversit/vcaltest.c
deleted file mode 100644
index 5528aab1d1..0000000000
--- a/libversit/vcaltest.c
+++ /dev/null
@@ -1,118 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "vcaltmp.h"
-
-#if 0
-This testcase would generate a file call "frankcal.vcf" with
-the following content:
-
-BEGIN:VCALENDAR
-DCREATED:19960523T100522
-GEO:37.24,-17.87
-PRODID:-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN
-VERSION:0.3
-BEGIN:VEVENT
-DTSTART:19960523T120000
-DTEND:19960523T130000
-DESCRIPTION;QUOTED-PRINTABLE:VERSIT PDI PR Teleconference/Interview =0A=
-With Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar=0A=
-activities with European Press representatives.
-SUMMARY:VERSIT PDI PR Teleconference/Interview
-SUBTYPE:PHONE CALL
-STATUS:CONFIRMED
-TRANSP:19960523T100522-4000F100582713-009251
-UID:http://www.ibm.com/raleigh/fdawson/~c:\or2\orgfiles\versit.or2
-DALARM:19960523T114500;5;3;Your Telecon Starts At Noon!!!;
-MALARM:19960522T120000;;;fdawson@raleigh.ibm.com;Remember 05/23 Noon Telecon!!!;
-PALARM:19960523T115500;;;c:\or2\organize.exe c:\or2\orgfiles\versit.or2;
-X-LDC-OR2-OLE:c:\temp\agenda.doc
-END:VEVENT
-
-BEGIN:VTODO
-DUE:19960614T0173000
-DESCRIPTION:Review VCalendar helper API.
-END:VTODO
-
-END:VCALENDAR
-
-#endif
-
-FILE *cfp;
-
-void testVcalAPIs() {
- FILE *fp;
- VObject *vcal, *vevent;
-#if _CONSOLE
- cfp = stdout;
-#else
- cfp = fopen("vcaltest.out","w");
-#endif
- if (cfp == 0) return;
- vcal = vcsCreateVCal(
- "19960523T100522",
- "37.24,-17.87",
- "-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN",
- 0,
- "0.3"
- );
-
- vevent = vcsAddEvent(
- vcal,
- "19960523T120000",
- "19960523T130000",
- "VERSIT PDI PR Teleconference/Interview \nWith Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar\nactivities with European Press representatives.",
- "VERSIT PDI PR Teleconference/Interview",
- "PHONE CALL",
- 0,
- "CONFIRMED",
- "19960523T100522-4000F100582713-009251",
- "http://www.ibm.com/raleigh/fdawson/~c:\\or2\\orgfiles\\versit.or2",
- 0
- );
-
- vcsAddDAlarm(vevent, "19960523T114500", "5", "3",
- "Your Telecon Starts At Noon!!!");
- vcsAddMAlarm(vevent, "19960522T120000", 0, 0, "fdawson@raleigh.ibm.com",
- "Remember 05/23 Noon Telecon!!!");
- vcsAddPAlarm(vevent, "19960523T115500", 0 ,0,
- "c:\\or2\\organize.exe c:\\or2\\orgfiles\\versit.or2");
-
- addPropValue(vevent, "X-LDC-OR2-OLE", "c:\\temp\\agenda.doc");
-
- vcsAddTodo(
- vcal,
- 0,
- "19960614T0173000",
- 0,
- "Review VCalendar helper API.",
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
- );
-
- /* now do something to the resulting VObject */
- /* pretty print on stdout for fun */
- printVObject(cfp,vcal);
- /* open the output text file */
-
-#define OUTFILE "frankcal.vcf"
-
- fp = fopen(OUTFILE, "w");
- if (fp) {
- /* write it in text form */
- writeVObject(fp,vcal);
- fclose(fp);
- }
- else {
- fprintf(cfp,"open output file '%s' failed\n", OUTFILE);
- }
- if (cfp != stdout) fclose(cfp);
- }
-
-void main() {
- testVcalAPIs();
- }
-
diff --git a/libversit/vcaltmp.c b/libversit/vcaltmp.c
deleted file mode 100644
index ccb21a649a..0000000000
--- a/libversit/vcaltmp.c
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
-This module provides some helper APIs for creating
-a VCalendar object.
-
-Note on APIs:
- 1. The APIs does not attempt to verify if the arguments
- passed are correct.
- 2. Where the argument to an API is not applicable, pass
- the value 0.
- 3. See the test program at the bottom of this file as an
- example of usage.
- 4. This code calls APIs in vobject.c.
-
-*/
-
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-
-#include <stdio.h>
-#include <string.h>
-#include "vcaltmp.h"
-
-
-DLLEXPORT(VObject*) vcsCreateVCal(
- char *date_created,
- char *location,
- char *product_id,
- char *time_zone,
- char *version
- )
- {
- VObject *vcal = newVObject(VCCalProp);
-#define Z(p,v) if (v) addPropValue(vcal,p,v);
- Z(VCDCreatedProp, date_created);
- Z(VCLocationProp, location)
- Z(VCProdIdProp, product_id)
- Z(VCTimeZoneProp, time_zone)
- Z(VCVersionProp, version)
-#undef Z
- return vcal;
- }
-
-
-DLLEXPORT(VObject*) vcsAddEvent(
- VObject *vcal,
- char *start_date_time,
- char *end_date_time,
- char *description,
- char *summary,
- char *categories,
- char *classification,
- char *status,
- char *transparency,
- char *uid,
- char *url
- )
- {
- VObject *vevent = addProp(vcal,VCEventProp);
-#define Z(p,v) if (v) addPropValue(vevent,p,v);
- Z(VCDTstartProp,start_date_time);
- Z(VCDTendProp,end_date_time);
- if (description) {
- VObject *p = addPropValue(vevent,VCDescriptionProp,description);
- if (strchr(description,'\n'))
- addProp(p,VCQuotedPrintableProp);
- }
- Z(VCSummaryProp,summary);
- Z(VCCategoriesProp,categories);
- Z(VCClassProp,classification);
- Z(VCStatusProp,status);
- Z(VCTranspProp,transparency);
- Z(VCUniqueStringProp,uid);
- Z(VCURLProp,url);
-#undef Z
- return vevent;
- }
-
-
-DLLEXPORT(VObject*) vcsAddTodo(
- VObject *vcal,
- char *start_date_time,
- char *due_date_time,
- char *date_time_complete,
- char *description,
- char *summary,
- char *priority,
- char *classification,
- char *status,
- char *uid,
- char *url
- )
- {
- VObject *vtodo = addProp(vcal,VCTodoProp);
-#define Z(p,v) if (v) addPropValue(vtodo,p,v);
- Z(VCDTstartProp,start_date_time);
- Z(VCDueProp,due_date_time);
- Z(VCCompletedProp,date_time_complete);
- if (description) {
- VObject *p = addPropValue(vtodo,VCDescriptionProp,description);
- if (strchr(description,'\n'))
- addProp(p,VCQuotedPrintableProp);
- }
- Z(VCSummaryProp,summary);
- Z(VCPriorityProp,priority);
- Z(VCClassProp,classification);
- Z(VCStatusProp,status);
- Z(VCUniqueStringProp,uid);
- Z(VCURLProp,url);
-#undef Z
- return vtodo;
- }
-
-
-DLLEXPORT(VObject*) vcsAddAAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *audio_content
- )
- {
- VObject *aalarm= addProp(vevent,VCAAlarmProp);
-#define Z(p,v) if (v) addPropValue(aalarm,p,v);
- Z(VCRunTimeProp,run_time);
- Z(VCSnoozeTimeProp,snooze_time);
- Z(VCRepeatCountProp,repeat_count);
- Z(VCAudioContentProp,audio_content);
-#undef Z
- return aalarm;
- }
-
-
-DLLEXPORT(VObject*) vcsAddMAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *email_address,
- char *note
- )
- {
- VObject *malarm= addProp(vevent,VCMAlarmProp);
-#define Z(p,v) if (v) addPropValue(malarm,p,v);
- Z(VCRunTimeProp,run_time);
- Z(VCSnoozeTimeProp,snooze_time);
- Z(VCRepeatCountProp,repeat_count);
- Z(VCEmailAddressProp,email_address);
- Z(VCNoteProp,note);
-#undef Z
- return malarm;
- }
-
-
-DLLEXPORT(VObject*) vcsAddDAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *display_string
- )
- {
- VObject *dalarm= addProp(vevent,VCDAlarmProp);
-#define Z(p,v) if (v) addPropValue(dalarm,p,v);
- Z(VCRunTimeProp,run_time);
- Z(VCSnoozeTimeProp,snooze_time);
- Z(VCRepeatCountProp,repeat_count);
- Z(VCDisplayStringProp,display_string);
-#undef Z
- return dalarm;
- }
-
-
-DLLEXPORT(VObject*) vcsAddPAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *procedure_name
- )
- {
- VObject *palarm= addProp(vevent,VCPAlarmProp);
-#define Z(p,v) if (v) addPropValue(palarm,p,v);
- Z(VCRunTimeProp,run_time);
- Z(VCSnoozeTimeProp,snooze_time);
- Z(VCRepeatCountProp,repeat_count);
- Z(VCProcedureNameProp,procedure_name);
-#undef Z
- return palarm;
- }
-
-
-#ifdef _TEST
-
-#if 0
-This testcase would generate a file call "frankcal.vcf" with
-the following content:
-
-BEGIN:VCALENDAR
-DCREATED:19960523T100522
-GEO:37.24,-17.87
-PRODID:-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN
-VERSION:0.3
-BEGIN:VEVENT
-DTSTART:19960523T120000
-DTEND:19960523T130000
-DESCRIPTION;QUOTED-PRINTABLE:VERSIT PDI PR Teleconference/Interview =0A=
-With Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar=0A=
-activities with European Press representatives.
-SUMMARY:VERSIT PDI PR Teleconference/Interview
-CATEGORIES:PHONE CALL
-STATUS:CONFIRMED
-TRANSP:19960523T100522-4000F100582713-009251
-UID:http://www.ibm.com/raleigh/fdawson/~c:\or2\orgfiles\versit.or2
-DALARM:19960523T114500;5;3;Your Telecon Starts At Noon!!!;
-MALARM:19960522T120000;;;fdawson@raleigh.ibm.com;Remember 05/23 Noon Telecon!!!;
-PALARM:19960523T115500;;;c:\or2\organize.exe c:\or2\orgfiles\versit.or2;
-X-LDC-OR2-OLE:c:\temp\agenda.doc
-END:VEVENT
-
-BEGIN:VTODO
-DUE:19960614T0173000
-DESCRIPTION:Review VCalendar helper API.
-END:VTODO
-
-END:VCALENDAR
-
-#endif
-
-void testVcalAPIs() {
- FILE *fp;
- VObject *vcal = vcsCreateVCal(
- "19960523T100522",
- "37.24,-17.87",
- "-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN",
- 0,
- "0.3"
- );
-
- VObject *vevent = vcsAddEvent(
- vcal,
- "19960523T120000",
- "19960523T130000",
- "VERSIT PDI PR Teleconference/Interview \nWith Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar\nactivities with European Press representatives.",
- "VERSIT PDI PR Teleconference/Interview",
- "PHONE CALL",
- 0,
- "CONFIRMED",
- "19960523T100522-4000F100582713-009251",
- "http://www.ibm.com/raleigh/fdawson/~c:\\or2\\orgfiles\\versit.or2",
- 0
- );
-
- vcsAddDAlarm(vevent, "19960523T114500", "5", "3",
- "Your Telecon Starts At Noon!!!");
- vcsAddMAlarm(vevent, "19960522T120000", 0, 0, "fdawson@raleigh.ibm.com",
- "Remember 05/23 Noon Telecon!!!");
- vcsAddPAlarm(vevent, "19960523T115500", 0 ,0,
- "c:\\or2\\organize.exe c:\\or2\\orgfiles\\versit.or2");
-
- addPropValue(vevent, "X-LDC-OR2-OLE", "c:\\temp\\agenda.doc");
-
- vcsAddTodo(
- vcal,
- 0,
- "19960614T0173000",
- 0,
- "Review VCalendar helper API.",
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
- );
-
- /* now do something to the resulting VObject */
- /* pretty print on stdout for fun */
- printVObject(vcal);
- /* open the output text file */
-
-#define OUTFILE "frankcal.vcf"
-
- fp = fopen(OUTFILE, "w");
- if (fp) {
- /* write it in text form */
- writeVObject(fp,vcal);
- fclose(fp);
- }
- else {
- printf("open output file '%s' failed\n", OUTFILE);
- }
- }
-
-void main() {
- testVcalAPIs();
- }
-
-#endif
-
-
-/* end of source file vcaltmp.c */
diff --git a/libversit/vcaltmp.h b/libversit/vcaltmp.h
deleted file mode 100644
index 4c4afde963..0000000000
--- a/libversit/vcaltmp.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-#include "vcc.h"
-
-#ifndef __VCALTMP_H__
-#define __VCALTMP_H__
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-extern "C" {
-#endif
-
-extern DLLEXPORT(VObject*) vcsCreateVCal(
- char *date_created,
- char *location,
- char *product_id,
- char *time_zone,
- char *version
- );
-
-extern DLLEXPORT(VObject*) vcsAddEvent(
- VObject *vcal,
- char *start_date_time,
- char *end_date_time,
- char *description,
- char *summary,
- char *categories,
- char *classification,
- char *status,
- char *transparency,
- char *uid,
- char *url
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddTodo(
- VObject *vcal,
- char *start_date_time,
- char *due_date_time,
- char *date_time_complete,
- char *description,
- char *summary,
- char *priority,
- char *classification,
- char *status,
- char *uid,
- char *url
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddAAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *audio_content
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddMAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *email_address,
- char *note
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddDAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *display_string
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddPAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *procedure_name
- );
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-}
-#endif
-
-#endif /* __VCALTMP_H__ */
-
-
diff --git a/libversit/vcc.h b/libversit/vcc.h
deleted file mode 100644
index 0e52034710..0000000000
--- a/libversit/vcc.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-#ifndef __VCC_H__
-#define __VCC_H__ 1
-
-#include "vobject.h"
-
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-extern "C" {
-#endif
-
-typedef void (*MimeErrorHandler)(char *);
-
-extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler);
-
-extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len);
-extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname);
-
-
-/* NOTE regarding Parse_MIME_FromFile
-The function above, Parse_MIME_FromFile, comes in two flavors,
-neither of which is exported from the DLL. Each version takes
-a CFile or FILE* as a parameter, neither of which can be
-passed across a DLL interface (at least that is my experience).
-If you are linking this code into your build directly then
-you may find them a more convenient API that the other flavors
-that take a file name. If you use them with the DLL LIB you
-will get a link error.
-*/
-
-
-#if INCLUDEMFC
-extern VObject* Parse_MIME_FromFile(CFile *file);
-#else
-extern VObject* Parse_MIME_FromFile(FILE *file);
-#endif
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-}
-#endif
-
-#endif /* __VCC_H__ */
-
diff --git a/libversit/vcc.y b/libversit/vcc.y
deleted file mode 100644
index fa314efeb5..0000000000
--- a/libversit/vcc.y
+++ /dev/null
@@ -1,1218 +0,0 @@
-%{
-
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-/*
- * src: vcc.c
- * doc: Parser for vCard and vCalendar. Note that this code is
- * generated by a yacc parser generator. Generally it should not
- * be edited by hand. The real source is vcc.y. The #line directives
- * can be commented out here to make it easier to trace through
- * in a debugger. However, if a bug is found it should
- * be fixed in vcc.y and this file regenerated.
- */
-
-
-/* debugging utilities */
-#if __DEBUG
-#define DBG_(x) printf x
-#else
-#define DBG_(x)
-#endif
-
-/**** External Functions ****/
-
-/* assign local name to parser variables and functions so that
- we can use more than one yacc based parser.
-*/
-
-#define yyparse mime_parse
-#define yylex mime_lex
-#define yyerror mime_error
-#define yychar mime_char
-/* #define p_yyval p_mime_val */
-#undef yyval
-#define yyval mime_yyval
-/* #define p_yylval p_mime_lval */
-#undef yylval
-#define yylval mime_yylval
-#define yydebug mime_debug
-#define yynerrs mime_nerrs
-#define yyerrflag mime_errflag
-#define yyss mime_ss
-#define yyssp mime_ssp
-#define yyvs mime_vs
-#define yyvsp mime_vsp
-#define yylhs mime_lhs
-#define yylen mime_len
-#define yydefred mime_defred
-#define yydgoto mime_dgoto
-#define yysindex mime_sindex
-#define yyrindex mime_rindex
-#define yygindex mime_gindex
-#define yytable mime_table
-#define yycheck mime_check
-#define yyname mime_name
-#define yyrule mime_rule
-#define YYPREFIX "mime_"
-
-
-#ifndef _NO_LINE_FOLDING
-#define _SUPPORT_LINE_FOLDING 1
-#endif
-
-/* undef below if compile with MFC */
-/* #define INCLUDEMFC 1 */
-
-#if defined(WIN32) || defined(_WIN32)
-#ifdef INCLUDEMFC
-#include <afx.h>
-#endif
-#endif
-
-#include <string.h>
-#ifndef __MWERKS__
-#include <malloc.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include "vcc.h"
-
-/**** Types, Constants ****/
-
-#define YYDEBUG 1 /* 1 to compile in some debugging code */
-#define MAXTOKEN 256 /* maximum token (line) length */
-#define YYSTACKSIZE 50 /* ~unref ? */
-#define MAXLEVEL 10 /* max # of nested objects parseable */
- /* (includes outermost) */
-
-
-/**** Global Variables ****/
-int mime_lineNum, mime_numErrors; /* yyerror() can use these */
-static VObject* vObjList;
-static VObject *curProp;
-static VObject *curObj;
-static VObject* ObjStack[MAXLEVEL];
-static int ObjStackTop;
-
-
-/* A helpful utility for the rest of the app. */
-#if __CPLUSPLUS__
-extern "C" {
-#endif
-
- extern void Parse_Debug(const char *s);
- extern void yyerror(char *s);
-
-#if __CPLUSPLUS__
- };
-#endif
-
-int yyparse();
-
-enum LexMode {
- L_NORMAL,
- L_VCARD,
- L_VCAL,
- L_VEVENT,
- L_VTODO,
- L_VALUES,
- L_BASE64,
- L_QUOTED_PRINTABLE
- };
-
-/**** Private Forward Declarations ****/
-static int pushVObject(const char *prop);
-static VObject* popVObject();
-static char* lexDataFromBase64();
-static void lexPopMode(int top);
-static int lexWithinMode(enum LexMode mode);
-static void lexPushMode(enum LexMode mode);
-static void enterProps(const char *s);
-static void enterAttr(const char *s1, const char *s2);
-static void enterValues(const char *value);
-static void mime_error_(char *s);
-
-%}
-
-/***************************************************************************/
-/*** The grammar ****/
-/***************************************************************************/
-
-%union {
- char *str;
- VObject *vobj;
- }
-
-%token
- EQ COLON DOT SEMICOLON SPACE HTAB LINESEP NEWLINE
- BEGIN_VCARD END_VCARD BEGIN_VCAL END_VCAL
- BEGIN_VEVENT END_VEVENT BEGIN_VTODO END_VTODO
- ID
-
-/*
- * NEWLINE is the token that would occur outside a vCard,
- * while LINESEP is the token that would occur inside a vCard.
- */
-
-%token <str>
- STRING ID
-
-%type <str> name value
-
-%type <vobj> vcard vcal vobject
-
-%start mime
-
-%%
-
-
-mime: vobjects
- ;
-
-vobjects: vobject
- { addList(&vObjList, $1); curObj = 0; }
- vobjects
- | vobject
- { addList(&vObjList, $1); curObj = 0; }
- ;
-
-vobject: vcard
- | vcal
- ;
-
-vcard:
- BEGIN_VCARD
- {
- lexPushMode(L_VCARD);
- if (!pushVObject(VCCardProp)) YYERROR;
- }
- items END_VCARD
- {
- lexPopMode(0);
- $$ = popVObject();
- }
- | BEGIN_VCARD
- {
- lexPushMode(L_VCARD);
- if (!pushVObject(VCCardProp)) YYERROR;
- }
- END_VCARD
- {
- lexPopMode(0);
- $$ = popVObject();
- }
- ;
-
-items: item items
- | item
- ;
-
-item: prop COLON
- {
- lexPushMode(L_VALUES);
- }
- values LINESEP
- {
- if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE))
- lexPopMode(0);
- lexPopMode(0);
- }
- | error
- ;
-
-prop: name
- {
- enterProps($1);
- }
- attr_params
- | name
- {
- enterProps($1);
- }
- ;
-
-attr_params: attr_param attr_params
- | attr_param
- ;
-
-attr_param: SEMICOLON attr
- ;
-
-attr: name
- {
- enterAttr($1,0);
- }
- | name EQ name
- {
- enterAttr($1,$3);
-
- }
- ;
-
-name: ID
- ;
-
-values: value SEMICOLON { enterValues($1); } values
- | value
- { enterValues($1); }
- ;
-
-value: STRING
- | { $$ = 0; }
- ;
-
-vcal:
- BEGIN_VCAL
- { if (!pushVObject(VCCalProp)) YYERROR; }
- calitems
- END_VCAL
- { $$ = popVObject(); }
- | BEGIN_VCAL
- { if (!pushVObject(VCCalProp)) YYERROR; }
- END_VCAL
- { $$ = popVObject(); }
- ;
-
-calitems: calitem calitems
- | calitem
- ;
-
-calitem:
- eventitem
- | todoitem
- | items
- ;
-
-eventitem:
- BEGIN_VEVENT
- {
- lexPushMode(L_VEVENT);
- if (!pushVObject(VCEventProp)) YYERROR;
- }
- items
- END_VEVENT
- {
- lexPopMode(0);
- popVObject();
- }
- | BEGIN_VEVENT
- {
- lexPushMode(L_VEVENT);
- if (!pushVObject(VCEventProp)) YYERROR;
- }
- END_VEVENT
- {
- lexPopMode(0);
- popVObject();
- }
- ;
-
-todoitem:
- BEGIN_VTODO
- {
- lexPushMode(L_VTODO);
- if (!pushVObject(VCTodoProp)) YYERROR;
- }
- items
- END_VTODO
- {
- lexPopMode(0);
- popVObject();
- }
- | BEGIN_VTODO
- {
- lexPushMode(L_VTODO);
- if (!pushVObject(VCTodoProp)) YYERROR;
- }
- END_VTODO
- {
- lexPopMode(0);
- popVObject();
- }
- ;
-
-%%
-/*/////////////////////////////////////////////////////////////////////////*/
-static int pushVObject(const char *prop)
- {
- VObject *newObj;
- if (ObjStackTop == MAXLEVEL)
- return FALSE;
-
- ObjStack[++ObjStackTop] = curObj;
-
- if (curObj) {
- newObj = addProp(curObj,prop);
- curObj = newObj;
- }
- else
- curObj = newVObject(prop);
-
- return TRUE;
- }
-
-
-/*/////////////////////////////////////////////////////////////////////////*/
-/* This pops the recently built vCard off the stack and returns it. */
-static VObject* popVObject()
- {
- VObject *oldObj;
- if (ObjStackTop < 0) {
- yyerror("pop on empty Object Stack\n");
- return 0;
- }
- oldObj = curObj;
- curObj = ObjStack[ObjStackTop--];
-
- return oldObj;
- }
-
-
-static void enterValues(const char *value)
- {
- if (fieldedProp && *fieldedProp) {
- if (value) {
- addPropValue(curProp,*fieldedProp,value);
- }
- /* else this field is empty, advance to next field */
- fieldedProp++;
- }
- else {
- if (value) {
- setVObjectUStringZValue_(curProp,fakeUnicode(value,0));
- }
- }
- deleteStr(value);
- }
-
-static void enterProps(const char *s)
- {
- curProp = addGroup(curObj,s);
- deleteStr(s);
- }
-
-static void enterAttr(const char *s1, const char *s2)
- {
- const char *p1, *p2;
- p1 = lookupProp_(s1);
- if (s2) {
- VObject *a;
- p2 = lookupProp_(s2);
- a = addProp(curProp,p1);
- setVObjectStringZValue(a,p2);
- }
- else
- addProp(curProp,p1);
- if (stricmp(p1,VCBase64Prop) == 0 || (s2 && stricmp(p2,VCBase64Prop)==0))
- lexPushMode(L_BASE64);
- else if (stricmp(p1,VCQuotedPrintableProp) == 0
- || (s2 && stricmp(p2,VCQuotedPrintableProp)==0))
- lexPushMode(L_QUOTED_PRINTABLE);
- deleteStr(s1); deleteStr(s2);
- }
-
-
-#define MAX_LEX_LOOKAHEAD_0 32
-#define MAX_LEX_LOOKAHEAD 64
-#define MAX_LEX_MODE_STACK_SIZE 10
-#define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop])
-
-struct LexBuf {
- /* input */
-#ifdef INCLUDEMFC
- CFile *inputFile;
-#else
- FILE *inputFile;
-#endif
- char *inputString;
- unsigned long curPos;
- unsigned long inputLen;
- /* lookahead buffer */
- /* -- lookahead buffer is short instead of char so that EOF
- / can be represented correctly.
- */
- unsigned long len;
- short buf[MAX_LEX_LOOKAHEAD];
- unsigned long getPtr;
- /* context stack */
- unsigned long lexModeStackTop;
- enum LexMode lexModeStack[MAX_LEX_MODE_STACK_SIZE];
- /* token buffer */
- unsigned long maxToken;
- char *strs;
- unsigned long strsLen;
- } lexBuf;
-
-static void lexPushMode(enum LexMode mode)
- {
- if (lexBuf.lexModeStackTop == (MAX_LEX_MODE_STACK_SIZE-1))
- yyerror("lexical context stack overflow");
- else {
- lexBuf.lexModeStack[++lexBuf.lexModeStackTop] = mode;
- }
- }
-
-static void lexPopMode(int top)
- {
- /* special case of pop for ease of error recovery -- this
- version will never underflow */
- if (top)
- lexBuf.lexModeStackTop = 0;
- else
- if (lexBuf.lexModeStackTop > 0) lexBuf.lexModeStackTop--;
- }
-
-static int lexWithinMode(enum LexMode mode) {
- unsigned long i;
- for (i=0;i<lexBuf.lexModeStackTop;i++)
- if (mode == lexBuf.lexModeStack[i]) return 1;
- return 0;
- }
-
-static char lexGetc_()
- {
- /* get next char from input, no buffering. */
- if (lexBuf.curPos == lexBuf.inputLen)
- return EOF;
- else if (lexBuf.inputString)
- return *(lexBuf.inputString + lexBuf.curPos++);
- else {
-#ifdef INCLUDEMFC
- char result;
- return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF;
-#else
- return fgetc(lexBuf.inputFile);
-#endif
- }
- }
-
-static int lexGeta()
- {
- ++lexBuf.len;
- return (lexBuf.buf[lexBuf.getPtr] = lexGetc_());
- }
-
-static int lexGeta_(int i)
- {
- ++lexBuf.len;
- return (lexBuf.buf[(lexBuf.getPtr+i)%MAX_LEX_LOOKAHEAD] = lexGetc_());
- }
-
-static void lexSkipLookahead() {
- if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
- /* don't skip EOF. */
- lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
- lexBuf.len--;
- }
- }
-
-static int lexLookahead() {
- int c = (lexBuf.len)?
- lexBuf.buf[lexBuf.getPtr]:
- lexGeta();
- /* do the \r\n -> \n or \r -> \n translation here */
- if (c == '\r') {
- int a = (lexBuf.len>1)?
- lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]:
- lexGeta_(1);
- if (a == '\n') {
- lexSkipLookahead();
- }
- lexBuf.buf[lexBuf.getPtr] = c = '\n';
- }
- else if (c == '\n') {
- int a = (lexBuf.len>1)?
- lexBuf.buf[lexBuf.getPtr+1]:
- lexGeta_(1);
- if (a == '\r') {
- lexSkipLookahead();
- }
- lexBuf.buf[lexBuf.getPtr] = '\n';
- }
- return c;
- }
-
-static int lexGetc() {
- int c = lexLookahead();
- if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
- /* EOF will remain in lookahead buffer */
- lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
- lexBuf.len--;
- }
- return c;
- }
-
-static void lexSkipLookaheadWord() {
- if (lexBuf.strsLen <= lexBuf.len) {
- lexBuf.len -= lexBuf.strsLen;
- lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD;
- }
- }
-
-static void lexClearToken()
- {
- lexBuf.strsLen = 0;
- }
-
-static void lexAppendc(int c)
- {
- lexBuf.strs[lexBuf.strsLen] = c;
- /* append up to zero termination */
- if (c == 0) return;
- lexBuf.strsLen++;
- if (lexBuf.strsLen > lexBuf.maxToken) {
- /* double the token string size */
- lexBuf.maxToken <<= 1;
- lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken);
- }
- }
-
-static char* lexStr() {
- return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1);
- }
-
-static void lexSkipWhite() {
- int c = lexLookahead();
- while (c == ' ' || c == '\t') {
- lexSkipLookahead();
- c = lexLookahead();
- }
- }
-
-static char* lexGetWord() {
- int c;
- lexSkipWhite();
- lexClearToken();
- c = lexLookahead();
- while (c != EOF && !strchr("\t\n ;:=",c)) {
- lexAppendc(c);
- lexSkipLookahead();
- c = lexLookahead();
- }
- lexAppendc(0);
- return lexStr();
- }
-
-static void lexPushLookahead(char *s, int len) {
- int putptr;
- if (len == 0) len = strlen(s);
- putptr = (int)lexBuf.getPtr - len;
- /* this function assumes that length of word to push back
- / is not greater than MAX_LEX_LOOKAHEAD.
- */
- if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD;
- lexBuf.getPtr = putptr;
- while (*s) {
- lexBuf.buf[putptr] = *s++;
- putptr = (putptr + 1) % MAX_LEX_LOOKAHEAD;
- }
- lexBuf.len += len;
- }
-
-static void lexPushLookaheadc(int c) {
- int putptr;
- /* can't putback EOF, because it never leaves lookahead buffer */
- if (c == EOF) return;
- putptr = (int)lexBuf.getPtr - 1;
- if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD;
- lexBuf.getPtr = putptr;
- lexBuf.buf[putptr] = c;
- lexBuf.len += 1;
- }
-
-static char* lexLookaheadWord() {
- /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0
- / and thing bigger than that will stop the lookahead and return 0;
- / leading white spaces are not recoverable.
- */
- int c;
- int len = 0;
- int curgetptr = 0;
- lexSkipWhite();
- lexClearToken();
- curgetptr = (int)lexBuf.getPtr; /* remember! */
- while (len < (MAX_LEX_LOOKAHEAD_0)) {
- c = lexGetc();
- len++;
- if (c == EOF || strchr("\t\n ;:=", c)) {
- lexAppendc(0);
- /* restore lookahead buf. */
- lexBuf.len += len;
- lexBuf.getPtr = curgetptr;
- return lexStr();
- }
- else
- lexAppendc(c);
- }
- lexBuf.len += len; /* char that has been moved to lookahead buffer */
- lexBuf.getPtr = curgetptr;
- return 0;
- }
-
-#ifdef _SUPPORT_LINE_FOLDING
-static void handleMoreRFC822LineBreak(int c) {
- /* suport RFC 822 line break in cases like
- * ADR: foo;
- * morefoo;
- * more foo;
- */
- if (c == ';') {
- int a;
- lexSkipLookahead();
- /* skip white spaces */
- a = lexLookahead();
- while (a == ' ' || a == '\t') {
- lexSkipLookahead();
- a = lexLookahead();
- }
- if (a == '\n') {
- lexSkipLookahead();
- a = lexLookahead();
- if (a == ' ' || a == '\t') {
- /* continuation, throw away all the \n and spaces read so
- * far
- */
- lexSkipWhite();
- lexPushLookaheadc(';');
- }
- else {
- lexPushLookaheadc('\n');
- lexPushLookaheadc(';');
- }
- }
- else {
- lexPushLookaheadc(';');
- }
- }
- }
-
-static char* lexGet1Value() {
- int size = 0;
- int c;
- lexSkipWhite();
- c = lexLookahead();
- lexClearToken();
- while (c != EOF && c != ';') {
- if (c == '\n') {
- int a;
- lexSkipLookahead();
- a = lexLookahead();
- if (a == ' ' || a == '\t') {
- lexAppendc(' ');
- lexSkipLookahead();
- }
- else {
- lexPushLookaheadc('\n');
- break;
- }
- }
- else {
- lexAppendc(c);
- lexSkipLookahead();
- }
- c = lexLookahead();
- }
- lexAppendc(0);
- handleMoreRFC822LineBreak(c);
- return c==EOF?0:lexStr();
- }
-#endif
-
-static char* lexGetStrUntil(char *termset) {
- int size = 0;
- int c = lexLookahead();
- lexClearToken();
- while (c != EOF && !strchr(termset,c)) {
- lexAppendc(c);
- lexSkipLookahead();
- c = lexLookahead();
- }
- lexAppendc(0);
- return c==EOF?0:lexStr();
- }
-
-static int match_begin_name(int end) {
- char *n = lexLookaheadWord();
- int token = ID;
- if (n) {
- if (!stricmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD;
- else if (!stricmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL;
- else if (!stricmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT;
- else if (!stricmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO;
- deleteStr(n);
- return token;
- }
- return 0;
- }
-
-
-#ifdef INCLUDEMFC
-void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile)
-#else
-void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile)
-#endif
- {
- /* initialize lex mode stack */
- lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL;
-
- /* iniatialize lex buffer. */
- lexBuf.inputString = (char*) inputstring;
- lexBuf.inputLen = inputlen;
- lexBuf.curPos = 0;
- lexBuf.inputFile = inputfile;
-
- lexBuf.len = 0;
- lexBuf.getPtr = 0;
-
- lexBuf.maxToken = MAXTOKEN;
- lexBuf.strs = (char*)malloc(MAXTOKEN);
- lexBuf.strsLen = 0;
-
- }
-
-static void finiLex() {
- free(lexBuf.strs);
- }
-
-
-/*/////////////////////////////////////////////////////////////////////////*/
-/* This parses and converts the base64 format for binary encoding into
- * a decoded buffer (allocated with new). See RFC 1521.
- */
-static char * lexGetDataFromBase64()
- {
- unsigned long bytesLen = 0, bytesMax = 0;
- int quadIx = 0, pad = 0;
- unsigned long trip = 0;
- unsigned char b;
- int c;
- unsigned char *bytes = NULL;
- unsigned char *oldBytes = NULL;
-
- DBG_(("db: lexGetDataFromBase64\n"));
- while (1) {
- c = lexGetc();
- if (c == '\n') {
- ++mime_lineNum;
- if (lexLookahead() == '\n') {
- /* a '\n' character by itself means end of data */
- break;
- }
- else continue; /* ignore '\n' */
- }
- else {
- if ((c >= 'A') && (c <= 'Z'))
- b = (unsigned char)(c - 'A');
- else if ((c >= 'a') && (c <= 'z'))
- b = (unsigned char)(c - 'a') + 26;
- else if ((c >= '0') && (c <= '9'))
- b = (unsigned char)(c - '0') + 52;
- else if (c == '+')
- b = 62;
- else if (c == '/')
- b = 63;
- else if (c == '=') {
- b = 0;
- pad++;
- } else if ((c == ' ') || (c == '\t')) {
- continue;
- } else { /* error condition */
- if (bytes) free(bytes);
- else if (oldBytes) free(oldBytes);
- /* error recovery: skip until 2 adjacent newlines. */
- DBG_(("db: invalid character 0x%x '%c'\n", c,c));
- if (c != EOF) {
- c = lexGetc();
- while (c != EOF) {
- if (c == '\n' && lexLookahead() == '\n') {
- ++mime_lineNum;
- break;
- }
- c = lexGetc();
- }
- }
- return NULL;
- }
- trip = (trip << 6) | b;
- if (++quadIx == 4) {
- unsigned char outBytes[3];
- int numOut;
- int i;
- for (i = 0; i < 3; i++) {
- outBytes[2-i] = (unsigned char)(trip & 0xFF);
- trip >>= 8;
- }
- numOut = 3 - pad;
- if (bytesLen + numOut > bytesMax) {
- if (!bytes) {
- bytesMax = 1024;
- bytes = (unsigned char*)malloc((size_t)bytesMax);
- }
- else {
- bytesMax <<= 2;
- oldBytes = bytes;
- bytes = (unsigned char*)realloc(bytes,(size_t)bytesMax);
- }
- if (bytes == 0) {
- mime_error("out of memory while processing BASE64 data\n");
- }
- }
- if (bytes) {
- memcpy(bytes + bytesLen, outBytes, numOut);
- bytesLen += numOut;
- }
- trip = 0;
- quadIx = 0;
- }
- }
- } /* while */
- DBG_(("db: bytesLen = %d\n", bytesLen));
- /* kludge: all this won't be necessary if we have tree form
- representation */
- if (bytes) {
- setValueWithSize(curProp,bytes,(unsigned int)bytesLen);
- free(bytes);
- }
- else if (oldBytes) {
- setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen);
- free(oldBytes);
- }
- return 0;
- }
-
-static int match_begin_end_name(int end) {
- int token;
- lexSkipWhite();
- if (lexLookahead() != ':') return ID;
- lexSkipLookahead();
- lexSkipWhite();
- token = match_begin_name(end);
- if (token == ID) {
- lexPushLookaheadc(':');
- DBG_(("db: ID '%s'\n", yylval.str));
- return ID;
- }
- else if (token != 0) {
- lexSkipLookaheadWord();
- deleteStr(yylval.str);
- DBG_(("db: begin/end %d\n", token));
- return token;
- }
- return 0;
- }
-
-static char* lexGetQuotedPrintable()
- {
- char cur;
- unsigned long len = 0;
-
- lexClearToken();
- do {
- cur = lexGetc();
- switch (cur) {
- case '=': {
- int c = 0;
- int next[2];
- int i;
- for (i = 0; i < 2; i++) {
- next[i] = lexGetc();
- if (next[i] >= '0' && next[i] <= '9')
- c = c * 16 + next[i] - '0';
- else if (next[i] >= 'A' && next[i] <= 'F')
- c = c * 16 + next[i] - 'A' + 10;
- else
- break;
- }
- if (i == 0) {
- /* single '=' follow by LINESEP is continuation sign? */
- if (next[0] == '\n') {
- ++mime_lineNum;
- }
- else {
- lexPushLookaheadc('=');
- goto EndString;
- }
- }
- else if (i == 1) {
- lexPushLookaheadc(next[1]);
- lexPushLookaheadc(next[0]);
- lexAppendc('=');
- } else {
- lexAppendc(c);
- }
- break;
- } /* '=' */
- case '\n': {
- lexPushLookaheadc('\n');
- goto EndString;
- }
- case (char)EOF:
- break;
- default:
- lexAppendc(cur);
- break;
- } /* switch */
- } while (cur != (char)EOF);
-
-EndString:
- lexAppendc(0);
- return lexStr();
- } /* LexQuotedPrintable */
-
-static int yylex() {
- int token = 0;
-
- int lexmode = LEXMODE();
- if (lexmode == L_VALUES) {
- int c = lexGetc();
- if (c == ';') {
- DBG_(("db: SEMICOLON\n"));
- lexPushLookaheadc(c);
-#ifdef _SUPPORT_LINE_FOLDING
- handleMoreRFC822LineBreak(c);
-#endif
- lexSkipLookahead();
- return SEMICOLON;
- }
- else if (strchr("\n",c)) {
- ++mime_lineNum;
- /* consume all line separator(s) adjacent to each other */
- c = lexLookahead();
- while (strchr("\n",c)) {
- lexSkipLookahead();
- c = lexLookahead();
- ++mime_lineNum;
- }
- DBG_(("db: LINESEP\n"));
- return LINESEP;
- }
- else {
- char *p = 0;
- lexPushLookaheadc(c);
- if (lexWithinMode(L_BASE64)) {
- /* get each char and convert to bin on the fly... */
- p = lexGetDataFromBase64();
- yylval.str = p;
- return STRING;
- }
- else if (lexWithinMode(L_QUOTED_PRINTABLE)) {
- p = lexGetQuotedPrintable();
- }
- else {
-#ifdef _SUPPORT_LINE_FOLDING
- p = lexGet1Value();
-#else
- p = lexGetStrUntil(";\n");
-#endif
- }
- if (p) {
- DBG_(("db: STRING: '%s'\n", p));
- yylval.str = p;
- return STRING;
- }
- else return 0;
- }
- }
- else {
- /* normal mode */
- while (1) {
- int c = lexGetc();
- switch(c) {
- case ':': {
- /* consume all line separator(s) adjacent to each other */
- /* ignoring linesep immediately after colon. */
-/* c = lexLookahead();
- while (strchr("\n",c)) {
- lexSkipLookahead();
- c = lexLookahead();
- ++mime_lineNum;
- }*/
- DBG_(("db: COLON\n"));
- return COLON;
- }
- case ';':
- DBG_(("db: SEMICOLON\n"));
- return SEMICOLON;
- case '=':
- DBG_(("db: EQ\n"));
- return EQ;
- /* ignore whitespace in this mode */
- case '\t':
- case ' ': continue;
- case '\n': {
- ++mime_lineNum;
- continue;
- }
- case EOF: return 0;
- break;
- default: {
- lexPushLookaheadc(c);
- if (isalpha(c)) {
- char *t = lexGetWord();
- yylval.str = t;
- if (!stricmp(t, "begin")) {
- return match_begin_end_name(0);
- }
- else if (!stricmp(t,"end")) {
- return match_begin_end_name(1);
- }
- else {
- DBG_(("db: ID '%s'\n", t));
- return ID;
- }
- }
- else {
- /* unknow token */
- return 0;
- }
- break;
- }
- }
- }
- }
- return 0;
- }
-
-
-/***************************************************************************/
-/*** Public Functions ****/
-/***************************************************************************/
-
-static VObject* Parse_MIMEHelper()
- {
- ObjStackTop = -1;
- mime_numErrors = 0;
- mime_lineNum = 1;
- vObjList = 0;
- curObj = 0;
-
- if (yyparse() != 0)
- return 0;
-
- finiLex();
- return vObjList;
- }
-
-/*/////////////////////////////////////////////////////////////////////////*/
-DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len)
- {
- initLex(input, len, 0);
- return Parse_MIMEHelper();
- }
-
-
-#if INCLUDEMFC
-
-DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file)
- {
- unsigned long startPos;
- VObject *result;
-
- initLex(0,-1,file);
- startPos = file->GetPosition();
- if (!(result = Parse_MIMEHelper()))
- file->Seek(startPos, CFile::begin);
- return result;
- }
-
-#else
-
-VObject* Parse_MIME_FromFile(FILE *file)
- {
- VObject *result;
- long startPos;
-
- initLex(0,(unsigned long)-1,file);
- startPos = ftell(file);
- if (!(result = Parse_MIMEHelper())) {
- fseek(file,startPos,SEEK_SET);
- }
- return result;
- }
-
-DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname)
- {
- FILE *fp = fopen(fname,"r");
- if (fp) {
- VObject* o = Parse_MIME_FromFile(fp);
- fclose(fp);
- return o;
- }
- else {
- char msg[256];
- snprintf(msg, sizeof(msg), "can't open file '%s' for reading\n", fname);
- mime_error_(msg);
- return 0;
- }
- }
-
-#endif
-
-/*/////////////////////////////////////////////////////////////////////////*/
-static void YYDebug(const char *s)
-{
-/* Parse_Debug(s); */
-}
-
-
-static MimeErrorHandler mimeErrorHandler;
-
-DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler me)
- {
- mimeErrorHandler = me;
- }
-
-static void mime_error(char *s)
- {
- char msg[256];
- if (mimeErrorHandler) {
- sprintf(msg,"%s at line %d", s, mime_lineNum);
- mimeErrorHandler(msg);
- }
- }
-
-static void mime_error_(char *s)
- {
- if (mimeErrorHandler) {
- mimeErrorHandler(s);
- }
- }
-
diff --git a/libversit/vctest.c b/libversit/vctest.c
deleted file mode 100644
index 7975d1e200..0000000000
--- a/libversit/vctest.c
+++ /dev/null
@@ -1,95 +0,0 @@
-
-#include <stdio.h>
-#include <string.h>
-#include "vcc.h"
-
-FILE *cfp;
-
-void myMimeErrorHandler(char *s)
-{
- printf("%s\n", s);
-}
-
-void main(int argc, char **argv)
-{
- int testmem = 0;
-
- char * foo[2] = {"foo","alden.vcf"};
-
-argc = 2;
-argv = foo;
-
-#ifdef _CONSOLE
- cfp = stdout;
- registerMimeErrorHandler(myMimeErrorHandler);
-#else
- cfp = fopen("vctest.out", "w");
- if (!cfp) return;
-#endif
- ++argv;
- while (--argc) {
- FILE *fp;
- if (strcmp(*argv,"-testmem") == 0) {
- testmem = 1;
- argv++;
- continue;
- }
- fprintf(cfp,"processing %s\n",*argv);
- fp = fopen(*argv,"r");
- if (!fp) {
- fprintf(cfp,"error opening file\n");
- }
- else {
- VObject *v, *t;
- FILE *ofp;
- char buf[256];
- char *p;
- strcpy(buf,*argv);
- p = strchr(buf,'.');
- if (p) *p = 0;
- strcat(buf,".out");
- fprintf(cfp,"reading text input from '%s'...\n", *argv);
- /*v = Parse_MIME_FromFile(fp); */
- v = Parse_MIME_FromFileName(*argv);
- writeVObjectToFile(buf,v);
- cleanVObject(v);
-
- /*
- fprintf(cfp,"pretty print internal format of '%s'...\n", *argv);
- ofp = fopen(buf,"w");
- while (v) {
- printVObject(cfp,v);
- if (testmem) {
- char *s, *p;
- fprintf(cfp,"test writing to mem...\n");
- p = s = writeMemVObject(0,0,v);
- if (s) {
- while (*s) {
- fputc(*s,ofp);
- s++;
- }
- free(p);
- }
- }
- else {
- writeVObject(ofp,v);
- }
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
-
- fclose(ofp);
- fclose(fp);
- */
- }
-
- cleanStrTbl();
- argv++;
-
- }
-
- if (cfp != stdout) fclose(cfp);
-
-}
-
diff --git a/libversit/vobject.c b/libversit/vobject.c
deleted file mode 100644
index d685b04278..0000000000
--- a/libversit/vobject.c
+++ /dev/null
@@ -1,1452 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-/*
- * src: vobject.c
- * doc: vobject and APIs to construct vobject, APIs pretty print
- * vobject, and convert a vobject into its textual representation.
- */
-
-#ifndef MWERKS
-#include <malloc.h>
-#endif
-
-#include "vobject.h"
-#include <string.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-
-#define NAME_OF(o) o->id
-#define VALUE_TYPE(o) o->valType
-#define STRINGZ_VALUE_OF(o) o->val.strs
-#define USTRINGZ_VALUE_OF(o) o->val.ustrs
-#define INTEGER_VALUE_OF(o) o->val.i
-#define LONG_VALUE_OF(o) o->val.l
-#define ANY_VALUE_OF(o) o->val.any
-#define VOBJECT_VALUE_OF(o) o->val.vobj
-
-typedef union ValueItem {
- const char *strs;
- const wchar_t *ustrs;
- unsigned int i;
- unsigned long l;
- void *any;
- VObject *vobj;
- } ValueItem;
-
-struct VObject {
- VObject *next;
- const char *id;
- VObject *prop;
- unsigned short valType;
- ValueItem val;
- };
-
-typedef struct StrItem StrItem;
-
-struct StrItem {
- StrItem *next;
- const char *s;
- unsigned int refCnt;
- };
-
-const char** fieldedProp;
-
-
-
-/*----------------------------------------------------------------------
- The following functions involve with memory allocation:
- newVObject
- deleteVObject
- dupStr
- deleteStr
- newStrItem
- deleteStrItem
- ----------------------------------------------------------------------*/
-
-DLLEXPORT(VObject*) newVObject_(const char *id)
-{
- VObject *p = (VObject*)malloc(sizeof(VObject));
- p->next = 0;
- p->id = id;
- p->prop = 0;
- VALUE_TYPE(p) = 0;
- ANY_VALUE_OF(p) = 0;
- return p;
-}
-
-DLLEXPORT(VObject*) newVObject(const char *id)
-{
- return newVObject_(lookupStr(id));
-}
-
-DLLEXPORT(void) deleteVObject(VObject *p)
-{
- unUseStr(p->id);
- free(p);
-}
-
-DLLEXPORT(char*) dupStr(const char *s, unsigned int size)
-{
- char *t;
- if (size == 0) {
- size = strlen(s);
- }
- t = (char*)malloc(size+1);
- if (t) {
- memcpy(t,s,size);
- t[size] = 0;
- return t;
- }
- else {
- return (char*)0;
- }
-}
-
-DLLEXPORT(void) deleteStr(const char *p)
-{
- if (p) free((void*)p);
-}
-
-
-static StrItem* newStrItem(const char *s, StrItem *next)
-{
- StrItem *p = (StrItem*)malloc(sizeof(StrItem));
- p->next = next;
- p->s = s;
- p->refCnt = 1;
- return p;
-}
-
-static void deleteStrItem(StrItem *p)
-{
- free((void*)p);
-}
-
-
-/*----------------------------------------------------------------------
- The following function provide accesses to VObject's value.
- ----------------------------------------------------------------------*/
-
-DLLEXPORT(const char*) vObjectName(VObject *o)
-{
- return NAME_OF(o);
-}
-
-DLLEXPORT(void) setVObjectName(VObject *o, const char* id)
-{
- NAME_OF(o) = id;
-}
-
-DLLEXPORT(const char*) vObjectStringZValue(VObject *o)
-{
- return STRINGZ_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s)
-{
- STRINGZ_VALUE_OF(o) = dupStr(s,0);
- VALUE_TYPE(o) = VCVT_STRINGZ;
-}
-
-DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s)
-{
- STRINGZ_VALUE_OF(o) = s;
- VALUE_TYPE(o) = VCVT_STRINGZ;
-}
-
-DLLEXPORT(const wchar_t*) vObjectUStringZValue(VObject *o)
-{
- return USTRINGZ_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectUStringZValue(VObject *o, const wchar_t *s)
-{
- USTRINGZ_VALUE_OF(o) = (wchar_t*) dupStr((char*)s,(uStrLen(s)+1)*2);
- VALUE_TYPE(o) = VCVT_USTRINGZ;
-}
-
-DLLEXPORT(void) setVObjectUStringZValue_(VObject *o, const wchar_t *s)
-{
- USTRINGZ_VALUE_OF(o) = s;
- VALUE_TYPE(o) = VCVT_USTRINGZ;
-}
-
-DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o)
-{
- return INTEGER_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i)
-{
- INTEGER_VALUE_OF(o) = i;
- VALUE_TYPE(o) = VCVT_UINT;
-}
-
-DLLEXPORT(unsigned long) vObjectLongValue(VObject *o)
-{
- return LONG_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l)
-{
- LONG_VALUE_OF(o) = l;
- VALUE_TYPE(o) = VCVT_ULONG;
-}
-
-DLLEXPORT(void*) vObjectAnyValue(VObject *o)
-{
- return ANY_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t)
-{
- ANY_VALUE_OF(o) = t;
- VALUE_TYPE(o) = VCVT_RAW;
-}
-
-DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o)
-{
- return VOBJECT_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p)
-{
- VOBJECT_VALUE_OF(o) = p;
- VALUE_TYPE(o) = VCVT_VOBJECT;
-}
-
-DLLEXPORT(int) vObjectValueType(VObject *o)
-{
- return VALUE_TYPE(o);
-}
-
-
-/*----------------------------------------------------------------------
- The following functions can be used to build VObject.
- ----------------------------------------------------------------------*/
-
-DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p)
-{
- /* circular link list pointed to tail */
- /*
- o {next,id,prop,val}
- V
- pn {next,id,prop,val}
- V
- ...
- p1 {next,id,prop,val}
- V
- pn
- -->
- o {next,id,prop,val}
- V
- pn {next,id,prop,val}
- V
- p {next,id,prop,val}
- ...
- p1 {next,id,prop,val}
- V
- pn
- */
-
- VObject *tail = o->prop;
- if (tail) {
- p->next = tail->next;
- o->prop = tail->next = p;
- }
- else {
- o->prop = p->next = p;
- }
- return p;
-}
-
-DLLEXPORT(VObject*) addProp(VObject *o, const char *id)
-{
- return addVObjectProp(o,newVObject(id));
-}
-
-DLLEXPORT(VObject*) addProp_(VObject *o, const char *id)
-{
- return addVObjectProp(o,newVObject_(id));
-}
-
-DLLEXPORT(void) addList(VObject **o, VObject *p)
-{
- p->next = 0;
- if (*o == 0) {
- *o = p;
- }
- else {
- VObject *t = *o;
- while (t->next) {
- t = t->next;
- }
- t->next = p;
- }
-}
-
-DLLEXPORT(VObject*) nextVObjectInList(VObject *o)
-{
- return o->next;
-}
-
-DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size)
-{
- VObject *sizeProp;
- setVObjectAnyValue(prop, val);
- sizeProp = addProp(prop,VCDataSizeProp);
- setVObjectLongValue(sizeProp, size);
- return prop;
-}
-
-DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size)
-{
- void *p = dupStr((const char *)val,size);
- return setValueWithSize_(prop,p,p?size:0);
-}
-
-DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o)
-{
- i->start = o->prop;
- i->next = 0;
-}
-
-DLLEXPORT(void) initVObjectIterator(VObjectIterator *i, VObject *o)
-{
- i->start = o->next;
- i->next = 0;
-}
-
-DLLEXPORT(int) moreIteration(VObjectIterator *i)
-{
- return (i->start && (i->next==0 || i->next!=i->start));
-}
-
-DLLEXPORT(VObject*) nextVObject(VObjectIterator *i)
-{
- if (i->start && i->next != i->start) {
- if (i->next == 0) {
- i->next = i->start->next;
- return i->next;
- }
- else {
- i->next = i->next->next;
- return i->next;
- }
- }
- else return (VObject*)0;
-}
-
-DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id)
-{
- VObjectIterator i;
- initPropIterator(&i,o);
- while (moreIteration(&i)) {
- VObject *each = nextVObject(&i);
- if (!stricmp(id,each->id))
- return each;
- }
- return (VObject*)0;
-}
-
-DLLEXPORT(VObject*) addGroup(VObject *o, const char *g)
-{
- /*
- a.b.c
- -->
- prop(c)
- prop(VCGrouping=b)
- prop(VCGrouping=a)
- */
- char *dot = strrchr(g,'.');
- if (dot) {
- VObject *p, *t;
- char *gs, *n = dot+1;
- gs = dupStr(g,0); /* so we can write to it. */
- /* used to be
- * t = p = addProp_(o,lookupProp_(n));
- */
- t = p = addProp_(o,lookupProp(n));
- dot = strrchr(gs,'.');
- *dot = 0;
- do {
- dot = strrchr(gs,'.');
- if (dot) {
- n = dot+1;
- *dot=0;
- }
- else
- n = gs;
- /* property(VCGroupingProp=n);
- * and the value may have VCGrouping property
- */
- t = addProp(t,VCGroupingProp);
- setVObjectStringZValue(t,lookupProp_(n));
- } while (n != gs);
- deleteStr(gs);
- return p;
- }
- else
- return addProp_(o,lookupProp(g));
-}
-
-DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v)
-{
- VObject *prop;
- prop = addProp(o,p);
- setVObjectUStringZValue_(prop, fakeUnicode(v,0));
- return prop;
-}
-
-DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v,
- unsigned int size)
-{
- VObject *prop;
- prop = addProp(o,p);
- setValueWithSize_(prop, (void*)v, size);
- return prop;
-}
-
-DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v,
- unsigned int size)
-{
- return addPropSizedValue_(o,p,dupStr(v,size),size);
-}
-
-
-
-/*----------------------------------------------------------------------
- The following pretty print a VObject
- ----------------------------------------------------------------------*/
-
-static void printVObject_(FILE *fp, VObject *o, int level);
-
-static void indent(FILE *fp, int level)
-{
- int i;
- for (i=0;i<level*4;i++) {
- fputc(' ', fp);
- }
-}
-
-static void printValue(FILE *fp, VObject *o, int level)
-{
- switch (VALUE_TYPE(o)) {
- case VCVT_USTRINGZ: {
- char c;
- char *t,*s;
- s = t = fakeCString(USTRINGZ_VALUE_OF(o));
- fputc('"',fp);
- while (c=*t,c) {
- fputc(c,fp);
- if (c == '\n') indent(fp,level+2);
- t++;
- }
- fputc('"',fp);
- deleteStr(s);
- break;
- }
- case VCVT_STRINGZ: {
- char c;
- const char *s = STRINGZ_VALUE_OF(o);
- fputc('"',fp);
- while (c=*s,c) {
- fputc(c,fp);
- if (c == '\n') indent(fp,level+2);
- s++;
- }
- fputc('"',fp);
- break;
- }
- case VCVT_UINT:
- fprintf(fp,"%d", INTEGER_VALUE_OF(o)); break;
- case VCVT_ULONG:
- fprintf(fp,"%ld", LONG_VALUE_OF(o)); break;
- case VCVT_RAW:
- fprintf(fp,"[raw data]"); break;
- case VCVT_VOBJECT:
- fprintf(fp,"[vobject]\n");
- printVObject_(fp,VOBJECT_VALUE_OF(o),level+1);
- break;
- case 0:
- fprintf(fp,"[none]"); break;
- default:
- fprintf(fp,"[unknown]"); break;
- }
-}
-
-static void printNameValue(FILE *fp,VObject *o, int level)
-{
- indent(fp,level);
- if (NAME_OF(o)) {
- fprintf(fp,"%s", NAME_OF(o));
- }
- if (VALUE_TYPE(o)) {
- fputc('=',fp);
- printValue(fp,o, level);
- }
- fprintf(fp,"\n");
-}
-
-static void printVObject_(FILE *fp, VObject *o, int level)
- {
- VObjectIterator t;
- if (o == 0) {
- fprintf(fp,"[NULL]\n");
- return;
- }
- printNameValue(fp,o,level);
- initPropIterator(&t,o);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- printVObject_(fp,eachProp,level+1);
- }
- }
-
-void printVObject(FILE *fp,VObject *o)
-{
- printVObject_(fp,o,0);
-}
-
-DLLEXPORT(void) printVObjectToFile(char *fname,VObject *o)
-{
- FILE *fp = fopen(fname,"w");
- if (fp) {
- printVObject(fp,o);
- fclose(fp);
- }
-}
-
-DLLEXPORT(void) printVObjectsToFile(char *fname,VObject *list)
-{
- FILE *fp = fopen(fname,"w");
- if (fp) {
- while (list) {
- printVObject(fp,list);
- list = nextVObjectInList(list);
- }
- fclose(fp);
- }
-}
-
-DLLEXPORT(void) cleanVObject(VObject *o)
-{
- if (o == 0) return;
- if (o->prop) {
- /* destroy time: cannot use the iterator here.
- Have to break the cycle in the circular link
- list and turns it into regular NULL-terminated
- list -- since at some point of destruction,
- the reference entry for the iterator to work
- will not longer be valid.
- */
- VObject *p;
- p = o->prop->next;
- o->prop->next = 0;
- do {
- VObject *t = p->next;
- cleanVObject(p);
- p = t;
- } while (p);
- }
- switch (VALUE_TYPE(o)) {
- case VCVT_USTRINGZ:
- case VCVT_STRINGZ:
- case VCVT_RAW:
- /* assume they are all allocated by malloc. */
- free((char*)STRINGZ_VALUE_OF(o));
- break;
- case VCVT_VOBJECT:
- cleanVObject(VOBJECT_VALUE_OF(o));
- break;
- }
- deleteVObject(o);
-}
-
-DLLEXPORT(void) cleanVObjects(VObject *list)
-{
- while (list) {
- VObject *t = list;
- list = nextVObjectInList(list);
- cleanVObject(t);
- }
-}
-
-/*----------------------------------------------------------------------
- The following is a String Table Facilities.
- ----------------------------------------------------------------------*/
-
-#define STRTBLSIZE 255
-
-static StrItem *strTbl[STRTBLSIZE];
-
-static unsigned int hashStr(const char *s)
-{
- unsigned int h = 0;
- int i;
- for (i=0;s[i];i++) {
- h += s[i]*i;
- }
- return h % STRTBLSIZE;
-}
-
-DLLEXPORT(const char*) lookupStr(const char *s)
-{
- StrItem *t;
- unsigned int h = hashStr(s);
- if ((t = strTbl[h]) != 0) {
- do {
- if (stricmp(t->s,s) == 0) {
- t->refCnt++;
- return t->s;
- }
- t = t->next;
- } while (t);
- }
- s = dupStr(s,0);
- strTbl[h] = newStrItem(s,strTbl[h]);
- return s;
-}
-
-DLLEXPORT(void) unUseStr(const char *s)
-{
- StrItem *t, *p;
- unsigned int h = hashStr(s);
- if ((t = strTbl[h]) != 0) {
- p = t;
- do {
- if (stricmp(t->s,s) == 0) {
- t->refCnt--;
- if (t->refCnt == 0) {
- if (p == strTbl[h]) {
- strTbl[h] = t->next;
- }
- else {
- p->next = t->next;
- }
- deleteStr(t->s);
- deleteStrItem(t);
- return;
- }
- }
- p = t;
- t = t->next;
- } while (t);
- }
-}
-
-DLLEXPORT(void) cleanStrTbl()
-{
- int i;
- for (i=0; i<STRTBLSIZE;i++) {
- StrItem *t = strTbl[i];
- while (t) {
- StrItem *p;
- deleteStr(t->s);
- p = t;
- t = t->next;
- deleteStrItem(p);
- } while (t);
- strTbl[i] = 0;
- }
-}
-
-
-struct PreDefProp {
- const char *name;
- const char *alias;
- const char** fields;
- unsigned int flags;
- };
-
-/* flags in PreDefProp */
-#define PD_BEGIN 0x1
-#define PD_INTERNAL 0x2
-
-static const char *adrFields[] = {
- VCPostalBoxProp,
- VCExtAddressProp,
- VCStreetAddressProp,
- VCCityProp,
- VCRegionProp,
- VCPostalCodeProp,
- VCCountryNameProp,
- 0
-};
-
-static const char *nameFields[] = {
- VCFamilyNameProp,
- VCGivenNameProp,
- VCAdditionalNamesProp,
- VCNamePrefixesProp,
- VCNameSuffixesProp,
- NULL
- };
-
-static const char *orgFields[] = {
- VCOrgNameProp,
- VCOrgUnitProp,
- VCOrgUnit2Prop,
- VCOrgUnit3Prop,
- VCOrgUnit4Prop,
- NULL
- };
-
-static const char *AAlarmFields[] = {
- VCRunTimeProp,
- VCSnoozeTimeProp,
- VCRepeatCountProp,
- VCAudioContentProp,
- 0
- };
-
-/* ExDate -- has unamed fields */
-/* RDate -- has unamed fields */
-
-static const char *DAlarmFields[] = {
- VCRunTimeProp,
- VCSnoozeTimeProp,
- VCRepeatCountProp,
- VCDisplayStringProp,
- 0
- };
-
-static const char *MAlarmFields[] = {
- VCRunTimeProp,
- VCSnoozeTimeProp,
- VCRepeatCountProp,
- VCEmailAddressProp,
- VCNoteProp,
- 0
- };
-
-static const char *PAlarmFields[] = {
- VCRunTimeProp,
- VCSnoozeTimeProp,
- VCRepeatCountProp,
- VCProcedureNameProp,
- 0
- };
-
-static struct PreDefProp propNames[] = {
- { VC7bitProp, 0, 0, 0 },
- { VC8bitProp, 0, 0, 0 },
- { VCAAlarmProp, 0, AAlarmFields, 0 },
- { VCAdditionalNamesProp, 0, 0, 0 },
- { VCAdrProp, 0, adrFields, 0 },
- { VCAgentProp, 0, 0, 0 },
- { VCAIFFProp, 0, 0, 0 },
- { VCAOLProp, 0, 0, 0 },
- { VCAppleLinkProp, 0, 0, 0 },
- { VCAttachProp, 0, 0, 0 },
- { VCAttendeeProp, 0, 0, 0 },
- { VCATTMailProp, 0, 0, 0 },
- { VCAudioContentProp, 0, 0, 0 },
- { VCAVIProp, 0, 0, 0 },
- { VCBase64Prop, 0, 0, 0 },
- { VCBBSProp, 0, 0, 0 },
- { VCBirthDateProp, 0, 0, 0 },
- { VCBMPProp, 0, 0, 0 },
- { VCBodyProp, 0, 0, 0 },
- { VCBusinessRoleProp, 0, 0, 0 },
- { VCCalProp, 0, 0, PD_BEGIN },
- { VCCaptionProp, 0, 0, 0 },
- { VCCardProp, 0, 0, PD_BEGIN },
- { VCCarProp, 0, 0, 0 },
- { VCCategoriesProp, 0, 0, 0 },
- { VCCellularProp, 0, 0, 0 },
- { VCCGMProp, 0, 0, 0 },
- { VCCharSetProp, 0, 0, 0 },
- { VCCIDProp, VCContentIDProp, 0, 0 },
- { VCCISProp, 0, 0, 0 },
- { VCCityProp, 0, 0, 0 },
- { VCClassProp, 0, 0, 0 },
- { VCCommentProp, 0, 0, 0 },
- { VCCompletedProp, 0, 0, 0 },
- { VCContentIDProp, 0, 0, 0 },
- { VCCountryNameProp, 0, 0, 0 },
- { VCDAlarmProp, 0, DAlarmFields, 0 },
- { VCDataSizeProp, 0, 0, PD_INTERNAL },
- { VCDayLightProp, 0, 0, 0 },
- { VCDCreatedProp, 0, 0, 0 },
- { VCDeliveryLabelProp, 0, 0, 0 },
- { VCDescriptionProp, 0, 0, 0 },
- { VCDIBProp, 0, 0, 0 },
- { VCDisplayStringProp, 0, 0, 0 },
- { VCDomesticProp, 0, 0, 0 },
- { VCDTendProp, 0, 0, 0 },
- { VCDTstartProp, 0, 0, 0 },
- { VCDueProp, 0, 0, 0 },
- { VCEmailAddressProp, 0, 0, 0 },
- { VCEncodingProp, 0, 0, 0 },
- { VCEndProp, 0, 0, 0 },
- { VCEventProp, 0, 0, PD_BEGIN },
- { VCEWorldProp, 0, 0, 0 },
- { VCExNumProp, 0, 0, 0 },
- { VCExpDateProp, 0, 0, 0 },
- { VCExpectProp, 0, 0, 0 },
- { VCExtAddressProp, 0, 0, 0 },
- { VCFamilyNameProp, 0, 0, 0 },
- { VCFaxProp, 0, 0, 0 },
- { VCFullNameProp, 0, 0, 0 },
- { VCGeoLocationProp, 0, 0, 0 },
- { VCGeoProp, 0, 0, 0 },
- { VCGIFProp, 0, 0, 0 },
- { VCGivenNameProp, 0, 0, 0 },
- { VCGroupingProp, 0, 0, 0 },
- { VCHomeProp, 0, 0, 0 },
- { VCIBMMailProp, 0, 0, 0 },
- { VCInlineProp, 0, 0, 0 },
- { VCInternationalProp, 0, 0, 0 },
- { VCInternetProp, 0, 0, 0 },
- { VCISDNProp, 0, 0, 0 },
- { VCJPEGProp, 0, 0, 0 },
- { VCLanguageProp, 0, 0, 0 },
- { VCLastModifiedProp, 0, 0, 0 },
- { VCLastRevisedProp, 0, 0, 0 },
- { VCLocationProp, 0, 0, 0 },
- { VCLogoProp, 0, 0, 0 },
- { VCMailerProp, 0, 0, 0 },
- { VCMAlarmProp, 0, MAlarmFields, 0 },
- { VCMCIMailProp, 0, 0, 0 },
- { VCMessageProp, 0, 0, 0 },
- { VCMETProp, 0, 0, 0 },
- { VCModemProp, 0, 0, 0 },
- { VCMPEG2Prop, 0, 0, 0 },
- { VCMPEGProp, 0, 0, 0 },
- { VCMSNProp, 0, 0, 0 },
- { VCNamePrefixesProp, 0, 0, 0 },
- { VCNameProp, 0, nameFields, 0 },
- { VCNameSuffixesProp, 0, 0, 0 },
- { VCNoteProp, 0, 0, 0 },
- { VCOrgNameProp, 0, 0, 0 },
- { VCOrgProp, 0, orgFields, 0 },
- { VCOrgUnit2Prop, 0, 0, 0 },
- { VCOrgUnit3Prop, 0, 0, 0 },
- { VCOrgUnit4Prop, 0, 0, 0 },
- { VCOrgUnitProp, 0, 0, 0 },
- { VCPagerProp, 0, 0, 0 },
- { VCPAlarmProp, 0, PAlarmFields, 0 },
- { VCParcelProp, 0, 0, 0 },
- { VCPartProp, 0, 0, 0 },
- { VCPCMProp, 0, 0, 0 },
- { VCPDFProp, 0, 0, 0 },
- { VCPGPProp, 0, 0, 0 },
- { VCPhotoProp, 0, 0, 0 },
- { VCPICTProp, 0, 0, 0 },
- { VCPMBProp, 0, 0, 0 },
- { VCPostalBoxProp, 0, 0, 0 },
- { VCPostalCodeProp, 0, 0, 0 },
- { VCPostalProp, 0, 0, 0 },
- { VCPowerShareProp, 0, 0, 0 },
- { VCPreferredProp, 0, 0, 0 },
- { VCPriorityProp, 0, 0, 0 },
- { VCProcedureNameProp, 0, 0, 0 },
- { VCProdIdProp, 0, 0, 0 },
- { VCProdigyProp, 0, 0, 0 },
- { VCPronunciationProp, 0, 0, 0 },
- { VCPSProp, 0, 0, 0 },
- { VCPublicKeyProp, 0, 0, 0 },
- { VCQPProp, VCQuotedPrintableProp, 0, 0 },
- { VCQuickTimeProp, 0, 0, 0 },
- { VCQuotedPrintableProp, 0, 0, 0 },
- { VCRDateProp, 0, 0, 0 },
- { VCRegionProp, 0, 0, 0 },
- { VCRelatedToProp, 0, 0, 0 },
- { VCRepeatCountProp, 0, 0, 0 },
- { VCResourcesProp, 0, 0, 0 },
- { VCRNumProp, 0, 0, 0 },
- { VCRoleProp, 0, 0, 0 },
- { VCRRuleProp, 0, 0, 0 },
- { VCRSVPProp, 0, 0, 0 },
- { VCRunTimeProp, 0, 0, 0 },
- { VCSequenceProp, 0, 0, 0 },
- { VCSnoozeTimeProp, 0, 0, 0 },
- { VCStartProp, 0, 0, 0 },
- { VCStatusProp, 0, 0, 0 },
- { VCStreetAddressProp, 0, 0, 0 },
- { VCSubTypeProp, 0, 0, 0 },
- { VCSummaryProp, 0, 0, 0 },
- { VCTelephoneProp, 0, 0, 0 },
- { VCTIFFProp, 0, 0, 0 },
- { VCTimeZoneProp, 0, 0, 0 },
- { VCTitleProp, 0, 0, 0 },
- { VCTLXProp, 0, 0, 0 },
- { VCTodoProp, 0, 0, PD_BEGIN },
- { VCTranspProp, 0, 0, 0 },
- { VCUniqueStringProp, 0, 0, 0 },
- { VCURLProp, 0, 0, 0 },
- { VCURLValueProp, 0, 0, 0 },
- { VCValueProp, 0, 0, 0 },
- { VCVersionProp, 0, 0, 0 },
- { VCVideoProp, 0, 0, 0 },
- { VCVoiceProp, 0, 0, 0 },
- { VCWAVEProp, 0, 0, 0 },
- { VCWMFProp, 0, 0, 0 },
- { VCWorkProp, 0, 0, 0 },
- { VCX400Prop, 0, 0, 0 },
- { VCX509Prop, 0, 0, 0 },
- { VCXRuleProp, 0, 0, 0 },
- { 0,0,0,0 }
- };
-
-
-static struct PreDefProp* lookupPropInfo(const char* str)
-{
- /* brute force for now, could use a hash table here. */
- int i;
-
- for (i = 0; propNames[i].name; i++)
- if (stricmp(str, propNames[i].name) == 0) {
- return &propNames[i];
- }
-
- return 0;
-}
-
-
-DLLEXPORT(const char*) lookupProp_(const char* str)
-{
- int i;
-
- for (i = 0; propNames[i].name; i++)
- if (stricmp(str, propNames[i].name) == 0) {
- const char* s;
- s = propNames[i].alias?propNames[i].alias:propNames[i].name;
- return lookupStr(s);
- }
- return lookupStr(str);
-}
-
-
-DLLEXPORT(const char*) lookupProp(const char* str)
-{
- int i;
-
- for (i = 0; propNames[i].name; i++)
- if (stricmp(str, propNames[i].name) == 0) {
- const char *s;
- fieldedProp = propNames[i].fields;
- s = propNames[i].alias?propNames[i].alias:propNames[i].name;
- return lookupStr(s);
- }
- fieldedProp = 0;
- return lookupStr(str);
-}
-
-
-/*----------------------------------------------------------------------
- APIs to Output text form.
- ----------------------------------------------------------------------*/
-#define OFILE_REALLOC_SIZE 256
-typedef struct OFile {
- FILE *fp;
- char *s;
- int len;
- int limit;
- int alloc:1;
- int fail:1;
- } OFile;
-
-#if 0
-static void appendsOFile(OFile *fp, const char *s)
-{
- int slen;
- if (fp->fail) return;
- slen = strlen(s);
- if (fp->fp) {
- fwrite(s,1,slen,fp->fp);
- }
- else {
-stuff:
- if (fp->len + slen < fp->limit) {
- memcpy(fp->s+fp->len,s,slen);
- fp->len += slen;
- return;
- }
- else if (fp->alloc) {
- fp->limit = fp->limit + OFILE_REALLOC_SIZE;
- if (OFILE_REALLOC_SIZE <= slen) fp->limit += slen;
- fp->s = (char *) realloc(fp->s,fp->limit);
- if (fp->s) goto stuff;
- }
- if (fp->alloc)
- free(fp->s);
- fp->s = 0;
- fp->fail = 1;
- }
-}
-
-static void appendcOFile(OFile *fp, char c)
-{
- if (fp->fail) return;
- if (fp->fp) {
- fputc(c,fp->fp);
- }
- else {
-stuff:
- if (fp->len+1 < fp->limit) {
- fp->s[fp->len] = c;
- fp->len++;
- return;
- }
- else if (fp->alloc) {
- fp->limit = fp->limit + OFILE_REALLOC_SIZE;
- fp->s = (char *) realloc(fp->s,fp->limit);
- if (fp->s) goto stuff;
- }
- if (fp->alloc)
- free(fp->s);
- fp->s = 0;
- fp->fail = 1;
- }
-}
-#else
-static void appendcOFile_(OFile *fp, char c)
-{
- if (fp->fail) return;
- if (fp->fp) {
- fputc(c,fp->fp);
- }
- else {
-stuff:
- if (fp->len+1 < fp->limit) {
- fp->s[fp->len] = c;
- fp->len++;
- return;
- }
- else if (fp->alloc) {
- fp->limit = fp->limit + OFILE_REALLOC_SIZE;
- fp->s = realloc(fp->s,fp->limit);
- if (fp->s) goto stuff;
- }
- if (fp->alloc)
- free(fp->s);
- fp->s = 0;
- fp->fail = 1;
- }
-}
-
-static void appendcOFile(OFile *fp, char c)
-{
- if (c == '\n') {
- /* write out as <CR><LF> */
- appendcOFile_(fp,0xd);
- appendcOFile_(fp,0xa);
- }
- else
- appendcOFile_(fp,c);
-}
-
-static void appendsOFile(OFile *fp, const char *s)
-{
- int i, slen;
- slen = strlen(s);
- for (i=0; i<slen; i++) {
- appendcOFile(fp,s[i]);
- }
-}
-
-#endif
-
-static void initOFile(OFile *fp, FILE *ofp)
-{
- fp->fp = ofp;
- fp->s = 0;
- fp->len = 0;
- fp->limit = 0;
- fp->alloc = 0;
- fp->fail = 0;
-}
-
-static void initMemOFile(OFile *fp, char *s, int len)
-{
- fp->fp = 0;
- fp->s = s;
- fp->len = 0;
- fp->limit = s?len:0;
- fp->alloc = s?0:1;
- fp->fail = 0;
-}
-
-
-static int writeBase64(OFile *fp, unsigned char *s, long len)
-{
- long cur = 0;
- int i, numQuads = 0;
- unsigned long trip;
- unsigned char b;
- char quad[5];
-#define MAXQUADS 16
-
- quad[4] = 0;
-
- while (cur < len) {
- /* collect the triplet of bytes into 'trip' */
- trip = 0;
- for (i = 0; i < 3; i++) {
- b = (cur < len) ? *(s + cur) : 0;
- cur++;
- trip = trip << 8 | b;
- }
- /* fill in 'quad' with the appropriate four characters */
- for (i = 3; i >= 0; i--) {
- b = (unsigned char)(trip & 0x3F);
- trip = trip >> 6;
- if ((3 - i) < (cur - len))
- quad[i] = '='; /* pad char */
- else if (b < 26) quad[i] = (char)b + 'A';
- else if (b < 52) quad[i] = (char)(b - 26) + 'a';
- else if (b < 62) quad[i] = (char)(b - 52) + '0';
- else if (b == 62) quad[i] = '+';
- else quad[i] = '/';
- }
- /* now output 'quad' with appropriate whitespace and line ending */
- appendsOFile(fp, (numQuads == 0 ? " " : ""));
- appendsOFile(fp, quad);
- appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : "")));
- numQuads = (numQuads + 1) % MAXQUADS;
- }
- appendcOFile(fp,'\n');
-
- return 1;
-}
-
-static void writeString(OFile *fp, const char *s)
-{
- appendsOFile(fp,s);
-}
-
-static void writeQPString(OFile *fp, const char *s)
-{
- char buf[4];
- int count=0;
- const char *p = s;
-
- while (*p) {
- /* break up lines biggger than 75 chars */
- if(count >=74){
- count=0;
- appendsOFile(fp,"=\n");
- }
-
- /* escape any non ASCII characters and '=' as per rfc1521 */
- if (*p<= 0x1f || *p >=0x7f || *p == '=' ) {
- sprintf(buf,"=%02X",(unsigned char)*p);
- appendsOFile(fp,buf);
- count+=3;
- } else {
- appendcOFile(fp,*p);
- count++;
- }
- p++;
- }
-}
-
-
-
-static void writeVObject_(OFile *fp, VObject *o);
-
-static void writeValue(OFile *fp, VObject *o, unsigned long size,int quote)
-{
- if (o == 0) return;
- switch (VALUE_TYPE(o)) {
- case VCVT_USTRINGZ: {
- char *s = fakeCString(USTRINGZ_VALUE_OF(o));
- if(quote) writeQPString(fp, s);
- else writeString(fp,s);
- deleteStr(s);
- break;
- }
- case VCVT_STRINGZ: {
- if(quote) writeQPString(fp, STRINGZ_VALUE_OF(o));
- else writeString(fp,STRINGZ_VALUE_OF(o));
- break;
- }
- case VCVT_UINT: {
- char buf[16];
- sprintf(buf,"%u", INTEGER_VALUE_OF(o));
- appendsOFile(fp,buf);
- break;
- }
- case VCVT_ULONG: {
- char buf[16];
- sprintf(buf,"%lu", LONG_VALUE_OF(o));
- appendsOFile(fp,buf);
- break;
- }
- case VCVT_RAW: {
- appendcOFile(fp,'\n');
- writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size);
- break;
- }
- case VCVT_VOBJECT:
- appendcOFile(fp,'\n');
- writeVObject_(fp,VOBJECT_VALUE_OF(o));
- break;
- }
-}
-
-static void writeAttrValue(OFile *fp, VObject *o)
-{
- if (NAME_OF(o)) {
- struct PreDefProp *pi;
- pi = lookupPropInfo(NAME_OF(o));
- if (pi && ((pi->flags & PD_INTERNAL) != 0)) return;
- appendcOFile(fp,';');
- appendsOFile(fp,NAME_OF(o));
- }
- else
- appendcOFile(fp,';');
- if (VALUE_TYPE(o)) {
- appendcOFile(fp,'=');
- writeValue(fp,o,0,0);
- }
-}
-
-static void writeGroup(OFile *fp, VObject *o)
-{
- char buf1[256];
- char buf2[256];
- strcpy(buf1,NAME_OF(o));
- while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) {
- strcpy(buf2,STRINGZ_VALUE_OF(o));
- strcat(buf2,".");
- strcat(buf2,buf1);
- strcpy(buf1,buf2);
- }
- appendsOFile(fp,buf1);
-}
-
-static int inList(const char **list, const char *s)
-{
- if (list == 0) return 0;
- while (*list) {
- if (stricmp(*list,s) == 0) return 1;
- list++;
- }
- return 0;
-}
-
-static void writeProp(OFile *fp, VObject *o)
-{
- int isQuoted=0;
- if (NAME_OF(o)) {
- struct PreDefProp *pi;
- VObjectIterator t;
- const char **fields_ = 0;
- pi = lookupPropInfo(NAME_OF(o));
- if (pi && ((pi->flags & PD_BEGIN) != 0)) {
- writeVObject_(fp,o);
- return;
- }
- if (isAPropertyOf(o,VCGroupingProp))
- writeGroup(fp,o);
- else
- appendsOFile(fp,NAME_OF(o));
- if (pi) fields_ = pi->fields;
- initPropIterator(&t,o);
- while (moreIteration(&t)) {
- const char *s;
- VObject *eachProp = nextVObject(&t);
- s = NAME_OF(eachProp);
- if (stricmp(VCGroupingProp,s) && !inList(fields_,s))
- writeAttrValue(fp,eachProp);
- if (stricmp(VCQPProp,s)==0 || stricmp(VCQuotedPrintableProp,s)==0)
- isQuoted=1;
- }
- if (fields_) {
- int i = 0, n = 0;
- const char** fields = fields_;
- /* output prop as fields */
- appendcOFile(fp,':');
- while (*fields) {
- VObject *t = isAPropertyOf(o,*fields);
- i++;
- if (t) n = i;
- fields++;
- }
- fields = fields_;
- for (i=0;i<n;i++) {
- writeValue(fp,isAPropertyOf(o,*fields),0,isQuoted);
- fields++;
- if (i<(n-1)) appendcOFile(fp,';');
- }
- }
- }
-
- if (VALUE_TYPE(o)) {
- unsigned long size = 0;
- VObject *p = isAPropertyOf(o,VCDataSizeProp);
- if (p) size = LONG_VALUE_OF(p);
- appendcOFile(fp,':');
- writeValue(fp,o,size,isQuoted);
- }
-
- appendcOFile(fp,'\n');
-}
-
-static void writeVObject_(OFile *fp, VObject *o)
-{
- if (NAME_OF(o)) {
- struct PreDefProp *pi;
- pi = lookupPropInfo(NAME_OF(o));
-
- if (pi && ((pi->flags & PD_BEGIN) != 0)) {
- VObjectIterator t;
- const char *begin = NAME_OF(o);
- appendsOFile(fp,"BEGIN:");
- appendsOFile(fp,begin);
- appendcOFile(fp,'\n');
- initPropIterator(&t,o);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- writeProp(fp, eachProp);
- }
- appendsOFile(fp,"END:");
- appendsOFile(fp,begin);
- appendsOFile(fp,"\n\n");
- }
- }
-}
-
-void writeVObject(FILE *fp, VObject *o)
-{
- OFile ofp;
- initOFile(&ofp,fp);
- writeVObject_(&ofp,o);
-}
-
-DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o)
-{
- FILE *fp = fopen(fname,"w");
- if (fp) {
- writeVObject(fp,o);
- fclose(fp);
- }
-}
-
-DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list)
-{
- FILE *fp = fopen(fname,"w");
- if (fp) {
- while (list) {
- writeVObject(fp,list);
- list = nextVObjectInList(list);
- }
- fclose(fp);
- }
-}
-
-DLLEXPORT(char*) writeMemVObject(char *s, int *len, VObject *o)
-{
- OFile ofp;
- initMemOFile(&ofp,s,len?*len:0);
- writeVObject_(&ofp,o);
- if (len) *len = ofp.len;
- appendcOFile(&ofp,0);
- return ofp.s;
-}
-
-DLLEXPORT(char*) writeMemVObjects(char *s, int *len, VObject *list)
-{
- OFile ofp;
- initMemOFile(&ofp,s,len?*len:0);
- while (list) {
- writeVObject_(&ofp,list);
- list = nextVObjectInList(list);
- }
- if (len) *len = ofp.len;
- appendcOFile(&ofp,0);
- return ofp.s;
-}
-
-/*----------------------------------------------------------------------
- APIs to do fake Unicode stuff.
- ----------------------------------------------------------------------*/
-DLLEXPORT(wchar_t*) fakeUnicode(const char *ps, int *bytes)
-{
- wchar_t *r, *pw;
- int len = strlen(ps)+1;
-
- pw = r = (wchar_t*)malloc(sizeof(wchar_t)*len);
- if (bytes)
- *bytes = len * sizeof(wchar_t);
-
- while (*ps) {
- if (*ps == '\n')
- *pw = (wchar_t)0x2028;
- else if (*ps == '\r')
- *pw = (wchar_t)0x2029;
- else
- *pw = (wchar_t)(unsigned char)*ps;
- ps++; pw++;
- }
- *pw = (wchar_t)0;
-
- return r;
-}
-
-DLLEXPORT(int) uStrLen(const wchar_t *u)
-{
- int i = 0;
- while (*u != (wchar_t)0) { u++; i++; }
- return i;
-}
-
-DLLEXPORT(char*) fakeCString(const wchar_t *u)
-{
- char *s, *t;
- int len = uStrLen(u) + 1;
- t = s = (char*)malloc(len);
- while (*u) {
- if (*u == (wchar_t)0x2028)
- *t = '\n';
- else if (*u == (wchar_t)0x2029)
- *t = '\r';
- else
- *t = (char)*u;
- u++; t++;
- }
- *t = 0;
- return s;
-}
-
-/* end of source file vobject.c */
diff --git a/libversit/vobject.h b/libversit/vobject.h
deleted file mode 100644
index bc31dc8297..0000000000
--- a/libversit/vobject.h
+++ /dev/null
@@ -1,366 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-/*
-
-The vCard/vCalendar C interface is implemented in the set
-of files as follows:
-
-vcc.y, yacc source, and vcc.c, the yacc output you will use
-implements the core parser
-
-vobject.c implements an API that insulates the caller from
-the parser and changes in the vCard/vCalendar BNF
-
-port.h defines compilation environment dependent stuff
-
-vcc.h and vobject.h are header files for their .c counterparts
-
-vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions
-which you may find useful.
-
-test.c is a standalone test driver that exercises some of
-the features of the APIs provided. Invoke test.exe on a
-VCARD/VCALENDAR input text file and you will see the pretty
-print output of the internal representation (this pretty print
-output should give you a good idea of how the internal
-representation looks like -- there is one such output in the
-following too). Also, a file with the .out suffix is generated
-to show that the internal representation can be written back
-in the original text format.
-
-For more information on this API see the readme.txt file
-which accompanied this distribution.
-
- Also visit:
-
- http://www.versit.com
- http://www.ralden.com
-
-*/
-
-
-#ifndef __VOBJECT_H__
-#define __VOBJECT_H__ 1
-
-
-#include "port.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-extern "C" {
-#endif
-
-
-#define VC7bitProp "7BIT"
-#define VC8bitProp "8BIT"
-#define VCAAlarmProp "AALARM"
-#define VCAdditionalNamesProp "ADDN"
-#define VCAdrProp "ADR"
-#define VCAgentProp "AGENT"
-#define VCAIFFProp "AIFF"
-#define VCAOLProp "AOL"
-#define VCAppleLinkProp "APPLELINK"
-#define VCAttachProp "ATTACH"
-#define VCAttendeeProp "ATTENDEE"
-#define VCATTMailProp "ATTMAIL"
-#define VCAudioContentProp "AUDIOCONTENT"
-#define VCAVIProp "AVI"
-#define VCBase64Prop "BASE64"
-#define VCBBSProp "BBS"
-#define VCBirthDateProp "BDAY"
-#define VCBMPProp "BMP"
-#define VCBodyProp "BODY"
-#define VCBusinessRoleProp "ROLE"
-#define VCCalProp "VCALENDAR"
-#define VCCaptionProp "CAP"
-#define VCCardProp "VCARD"
-#define VCCarProp "CAR"
-#define VCCategoriesProp "CATEGORIES"
-#define VCCellularProp "CELL"
-#define VCCGMProp "CGM"
-#define VCCharSetProp "CS"
-#define VCCIDProp "CID"
-#define VCCISProp "CIS"
-#define VCCityProp "L"
-#define VCClassProp "CLASS"
-#define VCCommentProp "NOTE"
-#define VCCompletedProp "COMPLETED"
-#define VCContentIDProp "CONTENT-ID"
-#define VCCountryNameProp "C"
-#define VCDAlarmProp "DALARM"
-#define VCDataSizeProp "DATASIZE"
-#define VCDayLightProp "DAYLIGHT"
-#define VCDCreatedProp "DCREATED"
-#define VCDeliveryLabelProp "LABEL"
-#define VCDescriptionProp "DESCRIPTION"
-#define VCDIBProp "DIB"
-#define VCDisplayStringProp "DISPLAYSTRING"
-#define VCDomesticProp "DOM"
-#define VCDTendProp "DTEND"
-#define VCDTstartProp "DTSTART"
-#define VCDueProp "DUE"
-#define VCEmailAddressProp "EMAIL"
-#define VCEncodingProp "ENCODING"
-#define VCEndProp "END"
-#define VCEventProp "VEVENT"
-#define VCEWorldProp "EWORLD"
-#define VCExNumProp "EXNUM"
-#define VCExpDateProp "EXDATE"
-#define VCExpectProp "EXPECT"
-#define VCExtAddressProp "EXT ADD"
-#define VCFamilyNameProp "F"
-#define VCFaxProp "FAX"
-#define VCFullNameProp "FN"
-#define VCGeoProp "GEO"
-#define VCGeoLocationProp "GEO"
-#define VCGIFProp "GIF"
-#define VCGivenNameProp "G"
-#define VCGroupingProp "Grouping"
-#define VCHomeProp "HOME"
-#define VCIBMMailProp "IBMMail"
-#define VCInlineProp "INLINE"
-#define VCInternationalProp "INTL"
-#define VCInternetProp "INTERNET"
-#define VCISDNProp "ISDN"
-#define VCJPEGProp "JPEG"
-#define VCLanguageProp "LANG"
-#define VCLastModifiedProp "LAST-MODIFIED"
-#define VCLastRevisedProp "REV"
-#define VCLocationProp "LOCATION"
-#define VCLogoProp "LOGO"
-#define VCMailerProp "MAILER"
-#define VCMAlarmProp "MALARM"
-#define VCMCIMailProp "MCIMAIL"
-#define VCMessageProp "MSG"
-#define VCMETProp "MET"
-#define VCModemProp "MODEM"
-#define VCMPEG2Prop "MPEG2"
-#define VCMPEGProp "MPEG"
-#define VCMSNProp "MSN"
-#define VCNamePrefixesProp "NPRE"
-#define VCNameProp "N"
-#define VCNameSuffixesProp "NSUF"
-#define VCNoteProp "NOTE"
-#define VCOrgNameProp "ORGNAME"
-#define VCOrgProp "ORG"
-#define VCOrgUnit2Prop "OUN2"
-#define VCOrgUnit3Prop "OUN3"
-#define VCOrgUnit4Prop "OUN4"
-#define VCOrgUnitProp "OUN"
-#define VCPagerProp "PAGER"
-#define VCPAlarmProp "PALARM"
-#define VCParcelProp "PARCEL"
-#define VCPartProp "PART"
-#define VCPCMProp "PCM"
-#define VCPDFProp "PDF"
-#define VCPGPProp "PGP"
-#define VCPhotoProp "PHOTO"
-#define VCPICTProp "PICT"
-#define VCPMBProp "PMB"
-#define VCPostalBoxProp "BOX"
-#define VCPostalCodeProp "PC"
-#define VCPostalProp "POSTAL"
-#define VCPowerShareProp "POWERSHARE"
-#define VCPreferredProp "PREF"
-#define VCPriorityProp "PRIORITY"
-#define VCProcedureNameProp "PROCEDURENAME"
-#define VCProdIdProp "PRODID"
-#define VCProdigyProp "PRODIGY"
-#define VCPronunciationProp "SOUND"
-#define VCPSProp "PS"
-#define VCPublicKeyProp "KEY"
-#define VCQPProp "QP"
-#define VCQuickTimeProp "QTIME"
-#define VCQuotedPrintableProp "QUOTED-PRINTABLE"
-#define VCRDateProp "RDATE"
-#define VCRegionProp "R"
-#define VCRelatedToProp "RELATED-TO"
-#define VCRepeatCountProp "REPEATCOUNT"
-#define VCResourcesProp "RESOURCES"
-#define VCRNumProp "RNUM"
-#define VCRoleProp "ROLE"
-#define VCRRuleProp "RRULE"
-#define VCRSVPProp "RSVP"
-#define VCRunTimeProp "RUNTIME"
-#define VCSequenceProp "SEQUENCE"
-#define VCSnoozeTimeProp "SNOOZETIME"
-#define VCStartProp "START"
-#define VCStatusProp "STATUS"
-#define VCStreetAddressProp "STREET"
-#define VCSubTypeProp "SUBTYPE"
-#define VCSummaryProp "SUMMARY"
-#define VCTelephoneProp "TEL"
-#define VCTIFFProp "TIFF"
-#define VCTimeZoneProp "TZ"
-#define VCTitleProp "TITLE"
-#define VCTLXProp "TLX"
-#define VCTodoProp "VTODO"
-#define VCTranspProp "TRANSP"
-#define VCUniqueStringProp "UID"
-#define VCURLProp "URL"
-#define VCURLValueProp "URLVAL"
-#define VCValueProp "VALUE"
-#define VCVersionProp "VERSION"
-#define VCVideoProp "VIDEO"
-#define VCVoiceProp "VOICE"
-#define VCWAVEProp "WAVE"
-#define VCWMFProp "WMF"
-#define VCWorkProp "WORK"
-#define VCX400Prop "X400"
-#define VCX509Prop "X509"
-#define VCXRuleProp "XRULE"
-
-/* Extensions */
-
-#define XPilotIdProp "X-PILOTID"
-#define XPilotStatusProp "X-PILOTSTAT"
-
-typedef struct VObject VObject;
-
-typedef struct VObjectIterator {
- VObject* start;
- VObject* next;
- } VObjectIterator;
-
-extern DLLEXPORT(VObject*) newVObject(const char *id);
-extern DLLEXPORT(void) deleteVObject(VObject *p);
-extern DLLEXPORT(char*) dupStr(const char *s, unsigned int size);
-extern DLLEXPORT(void) deleteStr(const char *p);
-extern DLLEXPORT(void) unUseStr(const char *s);
-
-extern DLLEXPORT(void) setVObjectName(VObject *o, const char* id);
-extern DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s);
-extern DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s);
-extern DLLEXPORT(void) setVObjectUStringZValue(VObject *o, const wchar_t *s);
-extern DLLEXPORT(void) setVObjectUStringZValue_(VObject *o, const wchar_t *s);
-extern DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i);
-extern DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l);
-extern DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t);
-extern DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size);
-extern DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size);
-
-extern DLLEXPORT(const char*) vObjectName(VObject *o);
-extern DLLEXPORT(const char*) vObjectStringZValue(VObject *o);
-extern DLLEXPORT(const wchar_t*) vObjectUStringZValue(VObject *o);
-extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o);
-extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o);
-extern DLLEXPORT(void*) vObjectAnyValue(VObject *o);
-extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o);
-extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p);
-
-extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p);
-extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id);
-extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id);
-extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v);
-extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size);
-extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size);
-extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g);
-extern DLLEXPORT(void) addList(VObject **o, VObject *p);
-
-extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id);
-
-extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o);
-extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o);
-extern DLLEXPORT(int) moreIteration(VObjectIterator *i);
-extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i);
-
-extern DLLEXPORT(char*) writeMemVObject(char *s, int *len, VObject *o);
-extern DLLEXPORT(char*) writeMemVObjects(char *s, int *len, VObject *list);
-
-extern DLLEXPORT(const char*) lookupStr(const char *s);
-extern DLLEXPORT(void) cleanStrTbl();
-
-extern DLLEXPORT(void) cleanVObject(VObject *o);
-extern DLLEXPORT(void) cleanVObjects(VObject *list);
-
-extern DLLEXPORT(const char*) lookupProp(const char* str);
-extern DLLEXPORT(const char*) lookupProp_(const char* str);
-
-extern DLLEXPORT(wchar_t*) fakeUnicode(const char *ps, int *bytes);
-extern DLLEXPORT(int) uStrLen(const wchar_t *u);
-extern DLLEXPORT(char*) fakeCString(const wchar_t *u);
-
-extern DLLEXPORT(void) printVObjectToFile(char *fname,VObject *o);
-extern DLLEXPORT(void) printVObjectsToFile(char *fname,VObject *list);
-extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o);
-extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list);
-
-extern DLLEXPORT(int) vObjectValueType(VObject *o);
-
-/* return type of vObjectValueType: */
-#define VCVT_NOVALUE 0
- /* if the VObject has no value associated with it. */
-#define VCVT_STRINGZ 1
- /* if the VObject has value set by setVObjectStringZValue. */
-#define VCVT_USTRINGZ 2
- /* if the VObject has value set by setVObjectUStringZValue. */
-#define VCVT_UINT 3
- /* if the VObject has value set by setVObjectIntegerValue. */
-#define VCVT_ULONG 4
- /* if the VObject has value set by setVObjectLongValue. */
-#define VCVT_RAW 5
- /* if the VObject has value set by setVObjectAnyValue. */
-#define VCVT_VOBJECT 6
- /* if the VObject has value set by setVObjectVObjectValue. */
-
-extern const char** fieldedProp;
-
-/* NOTE regarding printVObject and writeVObject
-
-The functions below are not exported from the DLL because they
-take a FILE* as a parameter, which cannot be passed across a DLL
-interface (at least that is my experience). Instead you can use
-their companion functions which take file names or pointers
-to memory. However, if you are linking this code into
-your build directly then you may find them a more convenient API
-and you can go ahead and use them. If you try to use them with
-the DLL LIB you will get a link error.
-*/
-extern void printVObject(FILE *fp,VObject *o);
-extern void writeVObject(FILE *fp, VObject *o);
-
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-}
-#endif
-
-#endif /* __VOBJECT_H__ */
-
-
diff --git a/macros/ChangeLog b/macros/ChangeLog
index b752b6036c..33918c0368 100644
--- a/macros/ChangeLog
+++ b/macros/ChangeLog
@@ -7,91 +7,6 @@
(GNOME_LIBGTOP_TYPES): Check for <sys/bitypes.h> for Tru64 and
use AC_LIBGTOP_CHECK_TYPE rather than AC_CHECK_TYPE.
-2000-01-26 Dave Camp <campd@oit.edu>
-
- * gnome-bonobo-check.m4 Include <bonobo.h> rather than
- <bonobo/gnome-object.h>
-
-2000-01-26 Dave Camp <campd@oit.edu>
-
- * gnome-bonobo-check.m4: Check for bonobo_object_get_type() rather
- than gnome_object_get_type().
-
-2000-01-23 Peter Teichman <peter@helixcode.com>
-
- * gnome-pilot.m4: i broke the version-checking macro for other
- distribs in my last commit. fixing that now.
-
-2000-01-22 Peter Teichman <peter@helixcode.com>
-
- * gnome-pilot.m4 (PILOT_LIBS): fix the version-checking macro for
- debian
-
-2000-01-20 Raja R Harinath <harinath@cs.umn.edu>
-
- * gnome-objc-checks.m4: Look for sched_yield in -lrt, too.
- Suggested by Drazen Kazar <dave@srce.hr>.
-
-2000-01-16 Vadim Strizhevsky <vadim@optonline.net>
-
- * gnome-pilot.m4: Fix typo in PILOT_LINK_HOOK.
-
-2000-01-15 Eskil Heyn Olsen <deity@eskil.dk>
-
- * gnome-pilot.m4: PILOT_LINK_HOOK now check pilot-link version.
- GNOME_PILOT_CHECK defaults to requiring 0.9.3.
-
-2000-01-09 Martin Baulig <martin@home-of-linux.org>
-
- * gnome-libgtop-check.m4: Applied patch from R. Bernstein
- <rocky@panix.com> - print a better error message when
- LibGTop's major version number mismatches.
-
-1999-12-25 Martin Baulig <martin@home-of-linux.org>
-
- * gnome-pilot.m4: Applied patch from Colin Walters to make
- it compile under Debian GNU/Linux.
-
-1999-12-05 Martin Baulig <martin@home-of-linux.org>
-
- * gnome-libgtop-checks.m4: Removed all guile variables.
-
-1999-11-18 Jeff Garzik <jgarzik@mandrakesoft.com>
-
- * gnome-xml-check.m4: Better scoping of below fix.
-
-1999-11-16 Jeff Garzik <jgarzik@mandrakesoft.com>
-
- * gnome-xml-check.m4: always AC_SUBST GNOME_XML_LIB, so that
- output variable will always be present.
-
-1999-11-09 Eskil Heyn Olsen <deity@eskil.dk>
-
- * gnome-pilot.m4: uses test -r instead of test -e, was reported as
- a portability bug wrt solaris.
-
-1999-10-31 Eskil Heyn Olsen <deity@eskil.dk>
-
- * gnome-pilot.m4: added PILOT_LINK_CHECK, used by
- GNOME_PILOT_CHECK. Adds --with-pisock=$dir_for_pilot_link.
-
-1999-10-24 Jacob Berkman <jberkman@andrew.cmu.edu>
-
- * gnome-ghttp-check.m4: this should be a better fix
-
-1999-10-21 Jacob Berkman <jberkman@andrew.cmu.edu>
-
- * gnome-ghttp-check.m4: use a temp value until we know that
- ghttp exists. This will hopefully fix building on Solaris
- machines
-
-1999-09-26 Jody Goldberg <jgoldberg@home.com>
-
- * compiler-flags.m4 : Remove -Wpointer-arith. It generates large
- numbers of warnings under glibc2.1.2 with a recent egcs release.
- The glibc maintainers have suggested removing this flag because it
- is useless.
-
1999-09-01 Havoc Pennington <hp@pobox.com>
* gnome-xml-check.m4: If you're going to AC_PATH_PROG then use the
diff --git a/macros/Makefile.am b/macros/Makefile.am
index 2b7b6ebbc8..e03dbeed1a 100644
--- a/macros/Makefile.am
+++ b/macros/Makefile.am
@@ -1,11 +1,11 @@
## Please update this variable if any new macros are created
-
MACROS= \
aclocal-include.m4 \
compiler-flags.m4 \
curses.m4 \
gnome-bonobo-check.m4 \
gnome-fileutils.m4 \
+ gnome-gettext.m4 \
gnome-ghttp-check.m4 \
gnome-gnorba-check.m4 \
gnome-guile-checks.m4 \
@@ -20,7 +20,6 @@ MACROS= \
gnome-x-checks.m4 \
gnome-xml-check.m4 \
gnome.m4 \
- gperf-check.m4 \
linger.m4 \
need-declaration.m4
diff --git a/macros/autogen.sh b/macros/autogen.sh
index 5662d01ff4..7027391368 100644
--- a/macros/autogen.sh
+++ b/macros/autogen.sh
@@ -3,12 +3,6 @@
DIE=0
-if [ -n "$GNOME2_PATH" ]; then
- ACLOCAL_FLAGS="-I $GNOME2_DIR/share/aclocal $ACLOCAL_FLAGS"
- PATH="$GNOME2_DIR/bin:$PATH"
- export PATH
-fi
-
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`autoconf' installed to compile Gnome."
@@ -94,21 +88,12 @@ do
echo processing $dr
macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin`
( cd $dr
- DELETEFILES="`find . -name gnome-gettext.m4`"
aclocalinclude="$ACLOCAL_FLAGS"
- for k in $aclocalinclude; do
- if test -d $k; then
- if [ -f $k/gnome.m4 -a "$GNOME_INTERFACE_VERSION" = "1.0" ]; then
- rm -f $DELETEFILES
- fi
- fi
- done
for k in $macrodirs; do
if test -d $k; then
aclocalinclude="$aclocalinclude -I $k"
- if [ -f $k/gnome.m4 -a "$GNOME_INTERFACE_VERSION" = "1.0" ]; then
- rm -f $DELETEFILES
- fi
+ ##else
+ ## echo "**Warning**: No such directory \`$k'. Ignored."
fi
done
if grep "^AM_GNU_GETTEXT" configure.in >/dev/null; then
diff --git a/macros/compiler-flags.m4 b/macros/compiler-flags.m4
index 63f8e2e6ac..278d5099c0 100644
--- a/macros/compiler-flags.m4
+++ b/macros/compiler-flags.m4
@@ -21,7 +21,7 @@ AC_DEFUN([GNOME_COMPILE_WARNINGS],[
## -W is not all that useful. And it cannot be controlled
## with individual -Wno-xxx flags, unlike -Wall
if test "x$enable_compile_warnings" = "xyes"; then
- warnCFLAGS="$warnCFLAGS -Wmissing-prototypes -Wmissing-declarations"
+ warnCFLAGS="$warnCFLAGS -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith"
fi
fi
fi
@@ -75,7 +75,7 @@ AC_DEFUN([GNOME_CXX_WARNINGS],[
## -W is not all that useful. And it cannot be controlled
## with individual -Wno-xxx flags, unlike -Wall
if test "x$enable_cxx_warnings" = "xyes"; then
- warnCXXFLAGS="$warnCXXFLAGS -Wmissing-prototypes -Wmissing-declarations -Wshadow -Woverloaded-virtual"
+ warnCXXFLAGS="$warnCXXFLAGS -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wshadow -Woverloaded-virtual"
fi
fi
fi
diff --git a/macros/gnome-bonobo-check.m4 b/macros/gnome-bonobo-check.m4
index 7eb2b2653d..65e272cf7a 100644
--- a/macros/gnome-bonobo-check.m4
+++ b/macros/gnome-bonobo-check.m4
@@ -64,7 +64,7 @@ dnl
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <bonobo.h>
+#include <bonobo/gnome-object.h>
static char*
my_strdup (char *str)
@@ -88,7 +88,7 @@ int main ()
char *tmp_version;
system ("touch conf.bonobotest");
- bonobo_object_get_type ();
+ gnome_object_get_type ();
return 0;
}
diff --git a/macros/gnome-libgtop-check.m4 b/macros/gnome-libgtop-check.m4
index 0ce6f6f612..038719276b 100644
--- a/macros/gnome-libgtop-check.m4
+++ b/macros/gnome-libgtop-check.m4
@@ -40,7 +40,7 @@ AC_DEFUN([GNOME_LIBGTOP_TYPES],
[
AC_CHECK_HEADERS(sys/bitypes.h)
AC_LIBGTOP_CHECK_TYPE(u_int64_t, unsigned long long int)
- AC_LIBGTOP_CHECK_TYPE(int64_t, signed long long int)
+ AC_LIBGTOP_CHECK_TYPE(int64_t, long long int)
])
dnl
@@ -61,6 +61,10 @@ AC_DEFUN([GNOME_LIBGTOP_HOOK],
AC_SUBST(LIBGTOP_INCS)
AC_SUBST(LIBGTOP_NAMES_LIBS)
AC_SUBST(LIBGTOP_NAMES_INCS)
+ AC_SUBST(LIBGTOP_GUILE_INCS)
+ AC_SUBST(LIBGTOP_GUILE_LIBS)
+ AC_SUBST(LIBGTOP_GUILE_NAMES_INCS)
+ AC_SUBST(LIBGTOP_GUILE_NAMES_LIBS)
AC_SUBST(LIBGTOP_MAJOR_VERSION)
AC_SUBST(LIBGTOP_MINOR_VERSION)
AC_SUBST(LIBGTOP_MICRO_VERSION)
@@ -149,13 +153,10 @@ AC_DEFUN([GNOME_LIBGTOP_HOOK],
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
libgtop_micro_version=`$LIBGTOP_CONFIG --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
- if test $libgtop_major_version != $min_libgtop_major ; then
- no_libgtop=mismatch
- else
- test $libgtop_minor_version -lt $min_libgtop_minor && no_libgtop=yes
- if test $libgtop_minor_version = $min_libgtop_minor ; then
- test $libgtop_micro_version -lt $min_libgtop_micro && no_libgtop=yes
- fi
+ test $libgtop_major_version != $min_libgtop_major && no_libgtop=yes
+ test $libgtop_minor_version -lt $min_libgtop_minor && no_libgtop=yes
+ if test $libgtop_minor_version = $min_libgtop_minor ; then
+ test $libgtop_micro_version -lt $min_libgtop_micro && no_libgtop=yes
fi
. $configfile
fi
@@ -172,9 +173,6 @@ AC_DEFUN([GNOME_LIBGTOP_HOOK],
ifelse([$2], [], :, [$2])
else
AC_MSG_RESULT(no)
- if test "$no_libgtop"x = mismatchx; then
- AC_MSG_ERROR(LibGTop major version mismatch $libgtop_major_version != $min_libgtop_major)
- fi
if test "x$3" = "xfail"; then
AC_MSG_ERROR(LibGTop >= $min_libgtop_version not found)
else
diff --git a/macros/gnome-pilot.m4 b/macros/gnome-pilot.m4
index 16e081a366..a497b51a39 100644
--- a/macros/gnome-pilot.m4
+++ b/macros/gnome-pilot.m4
@@ -3,99 +3,6 @@ dnl GNOME_PILOT_HOOK(script if found, fail)
dnl if fail = "failure", abort if gnome-pilot not found
dnl
-GNOME_PILOT_CFLAGS=
-GNOME_PILOT_LIBS=
-PISOCK_INCLUDEDIR=
-PISOCK_LIBS=
-PILOT_BINS=
-PILOT_LIBS=
-
-AC_SUBST(GNOME_PILOT_CFLAGS)
-AC_SUBST(GNOME_PILOT_LIBS)
-AC_SUBST(PISOCK_INCLUDEDIR)
-AC_SUBST(PISOCK_LIBS)
-AC_SUBST(PILOT_BINS)
-AC_SUBST(PILOT_LIBS)
-
-AC_DEFUN([PILOT_LINK_HOOK],[
- AC_ARG_WITH(pisock,
- [ --with-pisock Specify prefix for pisock files],[
- if test x$withval = xyes; then
- dnl Note that an empty true branch is not valid sh syntax.
- ifelse([$1], [], :, [$1])
- else
- PISOCK_INCLUDEDIR="-I$withval/include"
- PISOCK_LIBDIR="-L$withval/lib"
- PISOCK_LIBS="-lpisock"
- AC_MSG_CHECKING("for existance of $withval/lib/libpisock.so")
- if test -r $withval/lib/libpisock.so; then
- AC_MSG_RESULT("yes")
- else
- AC_MSG_ERROR("Unable to find libpisock. Try ftp://ryeham.ee.ryerson.ca/pub/PalmOS/.")
- fi
- AC_SUBST(PISOCK_INCLUDEDIR)
- AC_SUBST(PISOCK_LIBDIR)
- fi
- ])
-
- if test x$PISOCK_INCLUDEDIR = x; then
- AC_CHECK_HEADER(pi-version.h, [], [
- AC_CHECK_HEADER(libpisock/pi-version.h, [PISOCK_INCLUDEDIR="-I/usr/include/libpisock"
- piversion_include="libpisock/pi-version.h"],
- AC_MSG_ERROR("Unable to find pi-version.h")) ])
- fi
-
- AC_SUBST(PISOCK_INCLUDEDIR)
-
- if test x$PISOCK_LIBDIR = x; then
- AC_CHECK_LIB(pisock, pi_accept, [ PISOCK_LIBS=-lpisock ],
- [ AC_MSG_ERROR("Unable to find libpisock. Try ftp://ryeham.ee.ryerson.ca/pub/PalmOS/.") ])
- fi
-
- AC_ARG_ENABLE(pilotlinktest,
- [ --enable-pilotlinktest Test for correct version of pilot-link],
- [testplversion=$enableval],
- [ testplversion=yes ]
- )
-
- if test x$piversion_include = x; then
- piversion_include="pi-version.h"
- fi
-
- if test x$testplversion = xyes; then
- AC_MSG_CHECKING(for pilot-link version >= $1)
- pl_ve=`echo $1|sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
- pl_ma=`echo $1|sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
- pl_mi=`echo $1|sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
- AC_TRY_RUN(
- [
- #include <$piversion_include>
- int main(int argc,char *argv[]) {
- if (PILOT_LINK_VERSION == $pl_ve) {
- if (PILOT_LINK_MAJOR == $pl_ma) {
- if (PILOT_LINK_MINOR >= $pl_mi) {
- exit(0);
- }
- } else if (PILOT_LINK_MAJOR > $pl_ma) {
- exit(0);
- }
- } else if (PILOT_LINK_VERSION > $pl_ve) {
- exit(0);
- }
- exit(1);
- }
- ],
- [AC_MSG_RESULT(yes)],
- [AC_MSG_ERROR("pilot-link >= $1 required")],
- [AC_MSG_WARN("No action taken for crosscompile")]
- )
- fi
-])
-
-AC_DEFUN([PILOT_LINK_CHECK],[
- PILOT_LINK_HOOK($1,[],nofailure)
-])
-
AC_DEFUN([GNOME_PILOT_HOOK],[
AC_PATH_PROG(GNOME_PILOT_CONFIG,gnome-pilot-config,no)
AC_CACHE_CHECK([for gnome-pilot environment],gnome_cv_pilot_found,[
@@ -107,22 +14,25 @@ AC_DEFUN([GNOME_PILOT_HOOK],[
])
AM_CONDITIONAL(HAVE_GNOME_PILOT,test x$gnome_cv_pilot_found = xyes)
if test x$gnome_cv_pilot_found = xyes; then
- PILOT_LINK_CHECK($1)
+ $1
+ AC_CHECK_HEADER(pi-version.h, [PISOCK_INCLUDEDIR=""], [
+ AC_CHECK_HEADER(libpisock/pi-version.h, [PISOCK_INCLUDEDIR="-I/usr/include/libpisock"])])
+ AC_CHECK_LIB(pisock, pi_accept, [ PISOCK_LIBS="-lpisock" ])
GNOME_PILOT_CFLAGS=`gnome-pilot-config --cflags client conduitmgmt`
GNOME_PILOT_LIBS=`gnome-pilot-config --libs client conduitmgmt`
- $2
+ AC_SUBST(GNOME_PILOT_CFLAGS)
+ AC_SUBST(GNOME_PILOT_LIBS)
+ AC_SUBST(PISOCK_INCLUDEDIR)
+ AC_SUBST(PISOCK_LIBS)
+ AC_SUBST(PILOT_BINS)
+ AC_SUBST(PILOT_LIBS)
else
- if test x$3 = xfailure; then
+ if test x$2 = xfailure; then
AC_MSG_ERROR(Gnome-pilot not installed or installation problem)
fi
fi
])
AC_DEFUN([GNOME_PILOT_CHECK],[
- if test x$1 = x; then
- GNOME_PILOT_HOOK(0.9.3,[],nofailure)
- else
- GNOME_PILOT_HOOK($1,[],nofailure)
- fi
+ GNOME_PILOT_HOOK([],nofailure)
])
-
diff --git a/macros/gnome-xml-check.m4 b/macros/gnome-xml-check.m4
index 4bc91d124d..2410f35db7 100644
--- a/macros/gnome-xml-check.m4
+++ b/macros/gnome-xml-check.m4
@@ -16,13 +16,13 @@ AC_DEFUN([GNOME_XML_HOOK],[
fi
AC_CHECK_LIB(xml, xmlNewDoc, [
$1
+ AC_SUBST(GNOME_XML_LIB)
GNOME_XML_LIB=`$GNOME_CONFIG --libs xml`
], [
if test x$2 = xfailure; then
AC_MSG_ERROR(Could not link sample xml program)
fi
], `$GNOME_CONFIG --libs xml`)
- AC_SUBST(GNOME_XML_LIB)
])
AC_DEFUN([GNOME_XML_CHECK], [
diff --git a/widgets/.cvsignore b/widgets/.cvsignore
deleted file mode 100644
index d5b3a2ad62..0000000000
--- a/widgets/.cvsignore
+++ /dev/null
@@ -1,9 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-*.lo
-*.la
-minicard-test
-minicard-label-test
-reflow-test
diff --git a/widgets/LICENSE b/widgets/LICENSE
deleted file mode 100644
index b1f6ae08a4..0000000000
--- a/widgets/LICENSE
+++ /dev/null
@@ -1 +0,0 @@
-This code is released under the terms of the GNU GPL.
diff --git a/widgets/Makefile.am b/widgets/Makefile.am
deleted file mode 100644
index e2659cac03..0000000000
--- a/widgets/Makefile.am
+++ /dev/null
@@ -1,57 +0,0 @@
-
-SUBDIRS = \
- meeting-time-sel shortcut-bar e-table
-
-INCLUDES = \
- -I$(top_srcdir)/camel \
- -I$(top_builddir)/camel \
- $(GNOME_INCLUDEDIR)
-
-noinst_LIBRARIES = \
- libevolutionwidgets.a
-
-libevolutionwidgets_a_SOURCES = \
- e-canvas.c \
- e-canvas.h \
- e-canvas-utils.c \
- e-canvas-utils.h \
- e-cursors.c \
- e-cursors.h \
- e-minicard.c \
- e-minicard.h \
- e-minicard-label.c \
- e-minicard-label.h \
- e-reflow.c \
- e-reflow.h \
- e-text.c \
- e-text.h \
- e-text-event-processor.c \
- e-text-event-processor.h \
- e-text-event-processor-emacs-like.c \
- e-text-event-processor-emacs-like.h
-
-noinst_PROGRAMS = \
- minicard-label-test \
- minicard-test \
- reflow-test
-
-minicard_label_test_SOURCES = \
- test-minicard-label.c
-
-minicard_label_test_LDADD = \
- $(EXTRA_GNOME_LIBS) \
- libevolutionwidgets.a
-
-minicard_test_SOURCES = \
- test-minicard.c
-
-minicard_test_LDADD = \
- $(EXTRA_GNOME_LIBS) \
- libevolutionwidgets.a
-
-reflow_test_SOURCES = \
- test-reflow.c
-
-reflow_test_LDADD = \
- $(EXTRA_GNOME_LIBS) \
- libevolutionwidgets.a
diff --git a/widgets/e-canvas-utils.c b/widgets/e-canvas-utils.c
deleted file mode 100644
index 2b50248124..0000000000
--- a/widgets/e-canvas-utils.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-canvas-utils.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "e-canvas-utils.h"
-
-void
-e_canvas_item_move_absolute (GnomeCanvasItem *item, double dx, double dy)
-{
- double translate[6];
-
- g_return_if_fail (item != NULL);
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
-
- art_affine_translate (translate, dx, dy);
-
- gnome_canvas_item_affine_absolute (item, translate);
-}
diff --git a/widgets/e-canvas-utils.h b/widgets/e-canvas-utils.h
deleted file mode 100644
index 13ec43117c..0000000000
--- a/widgets/e-canvas-utils.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-canvas-utils.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-void e_canvas_item_move_absolute (GnomeCanvasItem *item, double dx, double dy);
diff --git a/widgets/e-canvas.c b/widgets/e-canvas.c
deleted file mode 100644
index 850e438386..0000000000
--- a/widgets/e-canvas.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-canvas.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include "e-canvas.h"
-static void e_canvas_init (ECanvas *card);
-static void e_canvas_class_init (ECanvasClass *klass);
-static gint e_canvas_key (GtkWidget *widget,
- GdkEventKey *event);
-
-static gint e_canvas_focus_in (GtkWidget *widget,
- GdkEventFocus *event);
-static gint e_canvas_focus_out (GtkWidget *widget,
- GdkEventFocus *event);
-
-static int emit_event (GnomeCanvas *canvas, GdkEvent *event);
-
-static GnomeCanvasClass *parent_class = NULL;
-
-GtkType
-e_canvas_get_type (void)
-{
- static GtkType canvas_type = 0;
-
- if (!canvas_type)
- {
- static const GtkTypeInfo canvas_info =
- {
- "ECanvas",
- sizeof (ECanvas),
- sizeof (ECanvasClass),
- (GtkClassInitFunc) e_canvas_class_init,
- (GtkObjectInitFunc) e_canvas_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- canvas_type = gtk_type_unique (gnome_canvas_get_type (), &canvas_info);
- }
-
- return canvas_type;
-}
-
-static void
-e_canvas_class_init (ECanvasClass *klass)
-{
- GtkObjectClass *object_class;
- GnomeCanvasClass *canvas_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass*) klass;
- canvas_class = (GnomeCanvasClass *) klass;
- widget_class = (GtkWidgetClass *) klass;
-
- parent_class = gtk_type_class (gnome_canvas_get_type ());
-
- widget_class->key_press_event = e_canvas_key;
- widget_class->key_release_event = e_canvas_key;
- widget_class->focus_in_event = e_canvas_focus_in;
- widget_class->focus_out_event = e_canvas_focus_out;
-}
-
-static void
-e_canvas_init (ECanvas *canvas)
-{
-}
-
-GtkWidget *
-e_canvas_new()
-{
- return GTK_WIDGET (gtk_type_new (e_canvas_get_type ()));
-}
-
-
-/* Returns whether the item is an inferior of or is equal to the parent. */
-static int
-is_descendant (GnomeCanvasItem *item, GnomeCanvasItem *parent)
-{
- for (; item; item = item->parent)
- if (item == parent)
- return TRUE;
-
- return FALSE;
-}
-
-/* Emits an event for an item in the canvas, be it the current item, grabbed
- * item, or focused item, as appropriate.
- */
-static int
-emit_event (GnomeCanvas *canvas, GdkEvent *event)
-{
- GdkEvent ev;
- gint finished;
- GnomeCanvasItem *item;
- GnomeCanvasItem *parent;
- guint mask;
-
- /* Perform checks for grabbed items */
-
- if (canvas->grabbed_item && !is_descendant (canvas->current_item, canvas->grabbed_item))
- return FALSE;
-
- if (canvas->grabbed_item) {
- switch (event->type) {
- case GDK_ENTER_NOTIFY:
- mask = GDK_ENTER_NOTIFY_MASK;
- break;
-
- case GDK_LEAVE_NOTIFY:
- mask = GDK_LEAVE_NOTIFY_MASK;
- break;
-
- case GDK_MOTION_NOTIFY:
- mask = GDK_POINTER_MOTION_MASK;
- break;
-
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- mask = GDK_BUTTON_PRESS_MASK;
- break;
-
- case GDK_BUTTON_RELEASE:
- mask = GDK_BUTTON_RELEASE_MASK;
- break;
-
- case GDK_KEY_PRESS:
- mask = GDK_KEY_PRESS_MASK;
- break;
-
- case GDK_KEY_RELEASE:
- mask = GDK_KEY_RELEASE_MASK;
- break;
-
- default:
- mask = 0;
- break;
- }
-
- if (!(mask & canvas->grabbed_event_mask))
- return FALSE;
- }
-
- /* Convert to world coordinates -- we have two cases because of diferent
- * offsets of the fields in the event structures.
- */
-
- ev = *event;
-
- switch (ev.type) {
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY:
- gnome_canvas_window_to_world (canvas,
- ev.crossing.x, ev.crossing.y,
- &ev.crossing.x, &ev.crossing.y);
- break;
-
- case GDK_MOTION_NOTIFY:
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- gnome_canvas_window_to_world (canvas,
- ev.motion.x, ev.motion.y,
- &ev.motion.x, &ev.motion.y);
- break;
-
- default:
- break;
- }
-
- /* Choose where we send the event */
-
- item = canvas->current_item;
-
- if (canvas->focused_item
- && ((event->type == GDK_KEY_PRESS) || (event->type == GDK_KEY_RELEASE) || (event->type == GDK_FOCUS_CHANGE)))
- item = canvas->focused_item;
-
- /* The event is propagated up the hierarchy (for if someone connected to
- * a group instead of a leaf event), and emission is stopped if a
- * handler returns TRUE, just like for GtkWidget events.
- */
-
- finished = FALSE;
-
- while (item && !finished) {
- gtk_object_ref (GTK_OBJECT (item));
-
- gtk_signal_emit_by_name (GTK_OBJECT (item), "event",
- &ev,
- &finished);
-
- if (GTK_OBJECT_DESTROYED (item))
- finished = TRUE;
-
- parent = item->parent;
- gtk_object_unref (GTK_OBJECT (item));
-
- item = parent;
- }
-
- return finished;
-}
-
-/* Key event handler for the canvas */
-static gint
-e_canvas_key (GtkWidget *widget, GdkEventKey *event)
-{
- GnomeCanvas *canvas;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNOME_IS_CANVAS (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- canvas = GNOME_CANVAS (widget);
-
- return emit_event (canvas, (GdkEvent *) event);
-}
-
-
-/**
- * e_canvas_item_grab_focus:
- * @item: A canvas item.
- *
- * Makes the specified item take the keyboard focus, so all keyboard events will
- * be sent to it. If the canvas widget itself did not have the focus, it grabs
- * it as well.
- **/
-void
-e_canvas_item_grab_focus (GnomeCanvasItem *item)
-{
- GnomeCanvasItem *focused_item;
- GdkEvent ev;
-
- g_return_if_fail (item != NULL);
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
- g_return_if_fail (GTK_WIDGET_CAN_FOCUS (GTK_WIDGET (item->canvas)));
-
- focused_item = item->canvas->focused_item;
-
- if (focused_item) {
- ev.focus_change.type = GDK_FOCUS_CHANGE;
- ev.focus_change.window = GTK_LAYOUT (item->canvas)->bin_window;
- ev.focus_change.send_event = FALSE;
- ev.focus_change.in = FALSE;
-
- emit_event (item->canvas, &ev);
- }
-
- item->canvas->focused_item = item;
- gtk_widget_grab_focus (GTK_WIDGET (item->canvas));
-}
-
-/* Focus in handler for the canvas */
-static gint
-e_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event)
-{
- GnomeCanvas *canvas;
-
- canvas = GNOME_CANVAS (widget);
-
- if (canvas->focused_item)
- return emit_event (canvas, (GdkEvent *) event);
- else
- return FALSE;
-}
-
-/* Focus out handler for the canvas */
-static gint
-e_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event)
-{
- GnomeCanvas *canvas;
-
- canvas = GNOME_CANVAS (widget);
-
- if (canvas->focused_item)
- return emit_event (canvas, (GdkEvent *) event);
- else
- return FALSE;
-}
diff --git a/widgets/e-canvas.h b/widgets/e-canvas.h
deleted file mode 100644
index 0ece5ae3b4..0000000000
--- a/widgets/e-canvas.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-canvas.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_CANVAS_H__
-#define __E_CANVAS_H__
-
-#include <gnome.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* ECanvas - A class derived from canvas for the purpose of adding
- * evolution specific canvas hacks.
- */
-
-#define E_CANVAS_TYPE (e_canvas_get_type ())
-#define E_CANVAS(obj) (GTK_CHECK_CAST ((obj), E_CANVAS_TYPE, ECanvas))
-#define E_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CANVAS_TYPE, ECanvasClass))
-#define E_IS_CANVAS(obj) (GTK_CHECK_TYPE ((obj), E_CANVAS_TYPE))
-#define E_IS_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CANVAS_TYPE))
-
-
-typedef struct _ECanvas ECanvas;
-typedef struct _ECanvasClass ECanvasClass;
-
-struct _ECanvas
-{
- GnomeCanvas parent;
-
- /* item specific fields */
-};
-
-struct _ECanvasClass
-{
- GnomeCanvasClass parent_class;
-};
-
-
-GtkType e_canvas_get_type (void);
-GtkWidget *e_canvas_new (void);
-
-/* Used to send all of the keystroke events to a specific item as well as
- * GDK_FOCUS_CHANGE events.
- */
-void e_canvas_item_grab_focus (GnomeCanvasItem *item);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_CANVAS_H__ */
diff --git a/widgets/e-cursors.c b/widgets/e-cursors.c
deleted file mode 100644
index 150b84b90a..0000000000
--- a/widgets/e-cursors.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * cursors.c: cursor handling for Evolution.
- * copied from Gnumeric.
- *
- * Authors:
- * Miguel de Icaza (miguel@gnu.org)
- */
-#include <config.h>
-#include <gnome.h>
-#include "e-cursors.h"
-
-static GdkColor black, white;
-
-#define GDK_INTERNAL_CURSOR -1
-
-typedef struct {
- GdkCursor *cursor;
- int hot_x, hot_y;
- char **xpm;
-} CursorDef;
-
-static CursorDef cursors [] = {
- { NULL, GDK_INTERNAL_CURSOR, GDK_CROSSHAIR, NULL },
- { NULL, GDK_INTERNAL_CURSOR, GDK_LEFT_PTR, NULL },
- { NULL, GDK_INTERNAL_CURSOR, GDK_FLEUR, NULL },
- { NULL, GDK_INTERNAL_CURSOR, GDK_SB_H_DOUBLE_ARROW, NULL },
- { NULL, GDK_INTERNAL_CURSOR, GDK_SB_V_DOUBLE_ARROW, NULL },
- { NULL, 0, 0, NULL }
-};
-
-
-static void
-create_bitmap_and_mask_from_xpm (GdkBitmap **bitmap, GdkBitmap **mask, gchar **xpm)
-{
- int height, width, colors;
- char pixmap_buffer [(32 * 32)/8];
- char mask_buffer [(32 * 32)/8];
- int x, y, pix, yofs;
- int transparent_color, black_color;
-
- sscanf (xpm [0], "%d %d %d %d", &height, &width, &colors, &pix);
-
- g_assert (height == 32);
- g_assert (width == 32);
- g_assert (colors <= 3);
-
- transparent_color = ' ';
- black_color = '.';
-
- yofs = colors + 1;
- for (y = 0; y < 32; y++){
- for (x = 0; x < 32;){
- char value = 0, maskv = 0;
-
- for (pix = 0; pix < 8; pix++, x++){
- if (xpm [y + yofs][x] != transparent_color){
- maskv |= 1 << pix;
-
- /*
- * Invert the colours here because it seems
- * to workaround a bug the Matrox G100 Xserver?
- * We reverse the foreground & background in the next
- * routine to compensate.
- */
- if (xpm [y + yofs][x] == black_color){
- value |= 1 << pix;
- }
- }
- }
- pixmap_buffer [(y * 4 + x/8)-1] = value;
- mask_buffer [(y * 4 + x/8)-1] = maskv;
- }
- }
- *bitmap = gdk_bitmap_create_from_data (NULL, pixmap_buffer, 32, 32);
- *mask = gdk_bitmap_create_from_data (NULL, mask_buffer, 32, 32);
-}
-
-void
-e_cursors_init (void)
-{
- GdkColormap *colormap;
- int i;
-
- colormap = gtk_widget_get_default_colormap ();
- gdk_color_white (colormap, &white);
- gdk_color_black (colormap, &black);
-
- for (i = 0; cursors [i].hot_x; i++){
- GdkBitmap *bitmap, *mask;
-
- if (cursors [i].hot_x < 0)
- cursors [i].cursor = gdk_cursor_new (cursors [i].hot_y);
- else {
- create_bitmap_and_mask_from_xpm (&bitmap, &mask, cursors [i].xpm);
-
- /* The foreground and background colours are reversed.
- * See comment above for explanation.
- */
- cursors [i].cursor =
- gdk_cursor_new_from_pixmap (
- bitmap, mask,
- &black, &white,
- cursors [i].hot_x,
- cursors [i].hot_y);
- }
- }
-
- g_assert (i == E_NUM_CURSORS);
-}
-
-void
-e_cursors_shutdown (void)
-{
- int i;
-
- for (i = 0; cursors [i].hot_x; i++)
- gdk_cursor_destroy (cursors [i].cursor);
-}
-
-
-/* Returns a cursor given its type */
-GdkCursor *
-e_cursor_get (ECursorType type)
-{
- g_return_val_if_fail (type >= 0 && type < E_NUM_CURSORS, NULL);
-
- return cursors [type].cursor;
-}
diff --git a/widgets/e-cursors.h b/widgets/e-cursors.h
deleted file mode 100644
index 771e5f6d4d..0000000000
--- a/widgets/e-cursors.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef E_CURSORS_H
-#define E_CURSORS_H
-
-/* Copied from Gnumeric */
-
-typedef enum {
- E_CURSOR_THIN_CROSS,
- E_CURSOR_ARROW,
- E_CURSOR_MOVE,
- E_CURSOR_SIZE_X,
- E_CURSOR_SIZE_Y,
- E_NUM_CURSORS
-} ECursorType;
-
-void e_cursors_init (void);
-void e_cursors_shutdown (void);
-
-#define e_cursor_set(win, c) \
-G_STMT_START { \
- if (win) \
- gdk_window_set_cursor (win, e_cursor_get (c)); \
-} G_STMT_END
-
-#define e_cursor_set_widget(w, c) \
-G_STMT_START { \
- if (GTK_WIDGET (w)->window) \
- gdk_window_set_cursor (GTK_WIDGET (w)->window, e_cursor_get (c)); \
-} G_STMT_END
-
-GdkCursor *e_cursor_get (ECursorType type);
-
-#endif /* E_CURSORS_H */
-
diff --git a/widgets/e-minicard-label.c b/widgets/e-minicard-label.c
deleted file mode 100644
index 43603f2d6d..0000000000
--- a/widgets/e-minicard-label.c
+++ /dev/null
@@ -1,456 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-minicard-label.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include "e-minicard-label.h"
-#include "e-text.h"
-#include "e-canvas.h"
-static void e_minicard_label_init (EMinicardLabel *card);
-static void e_minicard_label_class_init (EMinicardLabelClass *klass);
-static void e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
-static void e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static gboolean e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event);
-static void e_minicard_label_realize (GnomeCanvasItem *item);
-static void e_minicard_label_unrealize (GnomeCanvasItem *item);
-
-static void _update_label( EMinicardLabel *minicard_label );
-static void _resize( GtkObject *object, gpointer data );
-
-static GnomeCanvasGroupClass *parent_class = NULL;
-
-enum {
- E_MINICARD_LABEL_RESIZE,
- E_MINICARD_LABEL_LAST_SIGNAL
-};
-
-static guint e_minicard_label_signals[E_MINICARD_LABEL_LAST_SIGNAL] = { 0 };
-
-/* The arguments we take */
-enum {
- ARG_0,
- ARG_WIDTH,
- ARG_HEIGHT,
- ARG_HAS_FOCUS,
- ARG_FIELD,
- ARG_FIELDNAME
-};
-
-GtkType
-e_minicard_label_get_type (void)
-{
- static GtkType minicard_label_type = 0;
-
- if (!minicard_label_type)
- {
- static const GtkTypeInfo minicard_label_info =
- {
- "EMinicardLabel",
- sizeof (EMinicardLabel),
- sizeof (EMinicardLabelClass),
- (GtkClassInitFunc) e_minicard_label_class_init,
- (GtkObjectInitFunc) e_minicard_label_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- minicard_label_type = gtk_type_unique (gnome_canvas_group_get_type (), &minicard_label_info);
- }
-
- return minicard_label_type;
-}
-
-static void
-e_minicard_label_class_init (EMinicardLabelClass *klass)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass*) klass;
- item_class = (GnomeCanvasItemClass *) klass;
-
- parent_class = gtk_type_class (gnome_canvas_group_get_type ());
-
- e_minicard_label_signals[E_MINICARD_LABEL_RESIZE] =
- gtk_signal_new ("resize",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EMinicardLabelClass, resize),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
-
- gtk_object_class_add_signals (object_class, e_minicard_label_signals, E_MINICARD_LABEL_LAST_SIGNAL);
-
- gtk_object_add_arg_type ("EMinicardLabel::width", GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE, ARG_WIDTH);
- gtk_object_add_arg_type ("EMinicardLabel::height", GTK_TYPE_DOUBLE,
- GTK_ARG_READABLE, ARG_HEIGHT);
- gtk_object_add_arg_type ("EMinicardLabel::has_focus", GTK_TYPE_BOOL,
- GTK_ARG_READWRITE, ARG_HAS_FOCUS);
- gtk_object_add_arg_type ("EMinicardLabel::field", GTK_TYPE_STRING,
- GTK_ARG_READWRITE, ARG_FIELD);
- gtk_object_add_arg_type ("EMinicardLabel::fieldname", GTK_TYPE_STRING,
- GTK_ARG_READWRITE, ARG_FIELDNAME);
-
- klass->resize = NULL;
-
- object_class->set_arg = e_minicard_label_set_arg;
- object_class->get_arg = e_minicard_label_get_arg;
- /* object_class->destroy = e_minicard_label_destroy; */
-
- /* GnomeCanvasItem method overrides */
- item_class->realize = e_minicard_label_realize;
- item_class->unrealize = e_minicard_label_unrealize;
- item_class->event = e_minicard_label_event;
-}
-
-static void
-e_minicard_label_init (EMinicardLabel *minicard_label)
-{
- minicard_label->width = 10;
- minicard_label->height = 10;
- minicard_label->rect = NULL;
- minicard_label->fieldname = NULL;
- minicard_label->field = NULL;
- minicard_label->fieldname_text = NULL;
- minicard_label->field_text = NULL;
-}
-
-static void
-e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EMinicardLabel *e_minicard_label;
-
- item = GNOME_CANVAS_ITEM (o);
- e_minicard_label = E_MINICARD_LABEL (o);
-
- switch (arg_id){
- case ARG_WIDTH:
- e_minicard_label->width = GTK_VALUE_DOUBLE (*arg);
- _update_label( e_minicard_label );
- gnome_canvas_item_request_update (item);
- break;
- case ARG_HAS_FOCUS:
- if (e_minicard_label->field && GTK_VALUE_BOOL(*arg))
- e_canvas_item_grab_focus(e_minicard_label->field);
- break;
- case ARG_FIELD:
- if ( e_minicard_label->field )
- gnome_canvas_item_set( e_minicard_label->field, "text", GTK_VALUE_STRING (*arg), NULL );
- else
- e_minicard_label->field_text = g_strdup( GTK_VALUE_STRING (*arg) );
- break;
- case ARG_FIELDNAME:
- if ( e_minicard_label->fieldname )
- gnome_canvas_item_set( e_minicard_label->fieldname, "text", GTK_VALUE_STRING (*arg), NULL );
- else
- e_minicard_label->fieldname_text = g_strdup( GTK_VALUE_STRING (*arg) );
- break;
- }
-}
-
-static void
-e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- EMinicardLabel *e_minicard_label;
- char *temp;
-
- e_minicard_label = E_MINICARD_LABEL (object);
-
- switch (arg_id) {
- case ARG_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = e_minicard_label->width;
- break;
- case ARG_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = e_minicard_label->height;
- break;
- case ARG_HAS_FOCUS:
- GTK_VALUE_BOOL (*arg) = e_minicard_label->has_focus;
- break;
- case ARG_FIELD:
- if ( e_minicard_label->field ) {
- gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "text", &temp, NULL );
- GTK_VALUE_STRING (*arg) = temp;
- } else
- GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->field_text );
- break;
- case ARG_FIELDNAME:
- if ( e_minicard_label->fieldname ) {
- gtk_object_get( GTK_OBJECT( e_minicard_label->fieldname ), "text", &temp, NULL );
- GTK_VALUE_STRING (*arg) = temp;
- } else
- GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->fieldname_text );
- break;
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-static void
-e_minicard_label_realize (GnomeCanvasItem *item)
-{
- EMinicardLabel *e_minicard_label;
- GnomeCanvasGroup *group;
-
- e_minicard_label = E_MINICARD_LABEL (item);
- group = GNOME_CANVAS_GROUP( item );
-
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->realize)
- (* GNOME_CANVAS_ITEM_CLASS( parent_class )->realize) (item);
-
- e_minicard_label->rect =
- gnome_canvas_item_new( group,
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) e_minicard_label->width - 1,
- "y2", (double) e_minicard_label->height - 1,
- "outline_color", NULL,
- NULL );
- e_minicard_label->fieldname =
- gnome_canvas_item_new( group,
- e_text_get_type(),
- "x", (double) 2,
- "y", (double) 1,
- "anchor", GTK_ANCHOR_NW,
- "clip_width", (double) ( e_minicard_label->width / 2 - 4 ),
- "clip_height", (double) 1,
- "clip", TRUE,
- "use_ellipsis", TRUE,
- "font", "lucidasans-10",
- "fill_color", "black",
- NULL );
- if ( e_minicard_label->fieldname_text )
- {
- gnome_canvas_item_set( e_minicard_label->fieldname,
- "text", e_minicard_label->fieldname_text,
- NULL );
- g_free( e_minicard_label->fieldname_text );
- }
- gtk_signal_connect(GTK_OBJECT(e_minicard_label->fieldname),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard_label);
-
- e_minicard_label->field =
- gnome_canvas_item_new( group,
- e_text_get_type(),
- "x", (double) ( e_minicard_label->width / 2 + 2 ),
- "y", (double) 1,
- "anchor", GTK_ANCHOR_NW,
- "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ),
- "clip_height", (double) 1,
- "clip", TRUE,
- "use_ellipsis", TRUE,
- "font", "lucidasans-10",
- "fill_color", "black",
- "editable", TRUE,
- NULL );
- if ( e_minicard_label->field_text )
- {
- gnome_canvas_item_set( e_minicard_label->field,
- "text", e_minicard_label->field_text,
- NULL );
- g_free( e_minicard_label->field_text );
- }
-
- gtk_signal_connect(GTK_OBJECT(e_minicard_label->field),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard_label);
-
- _update_label (e_minicard_label);
-
- if (!item->canvas->aa)
- {
- }
-
-}
-
-static void
-e_minicard_label_unrealize (GnomeCanvasItem *item)
-{
- EMinicardLabel *e_minicard_label;
-
- e_minicard_label = E_MINICARD_LABEL (item);
-
- if (!item->canvas->aa)
- {
- }
-
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize)
- (* GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize) (item);
-}
-
-static gboolean
-e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EMinicardLabel *e_minicard_label;
-
- e_minicard_label = E_MINICARD_LABEL (item);
-
- switch( event->type )
- {
- case GDK_FOCUS_CHANGE:
- {
- GdkEventFocus *focus_event = (GdkEventFocus *) event;
- if ( focus_event->in )
- {
- gnome_canvas_item_set( e_minicard_label->rect,
- "outline_color", "grey50",
- "fill_color", "grey90",
- NULL );
- e_minicard_label->has_focus = TRUE;
- }
- else
- {
- gnome_canvas_item_set( e_minicard_label->rect,
- "outline_color", NULL,
- "fill_color", NULL,
- NULL );
- e_minicard_label->has_focus = FALSE;
- }
- }
- break;
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- case GDK_MOTION_NOTIFY:
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY: {
- GnomeCanvasItem *field;
- ArtPoint p;
- double inv[6], affine[6];
- gboolean return_val;
-
- field = e_minicard_label->field;
- art_affine_identity (affine);
-
- if (field->xform != NULL) {
- if (field->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) {
- art_affine_multiply (affine, affine, field->xform);
- } else {
- affine[4] += field->xform[0];
- affine[5] += field->xform[1];
- }
- }
-
- art_affine_invert (inv, affine);
- switch(event->type) {
- case GDK_MOTION_NOTIFY:
- p.x = event->motion.x;
- p.y = event->motion.y;
- art_affine_point (&p, &p, inv);
- event->motion.x = p.x;
- event->motion.y = p.y;
- break;
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- p.x = event->button.x;
- p.y = event->button.y;
- art_affine_point (&p, &p, inv);
- event->button.x = p.x;
- event->button.y = p.y;
- break;
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY:
- p.x = event->crossing.x;
- p.y = event->crossing.y;
- art_affine_point (&p, &p, inv);
- event->crossing.x = p.x;
- event->crossing.y = p.y;
- break;
- default:
- break;
- }
-
- gtk_signal_emit_by_name(GTK_OBJECT(e_minicard_label->field), "event", event, &return_val);
- return return_val;
- break;
- }
- default:
- break;
- }
-
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event)
- return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event);
- else
- return 0;
-}
-
-static void
-_update_label( EMinicardLabel *e_minicard_label )
-{
- if ( GTK_OBJECT_FLAGS( e_minicard_label ) & GNOME_CANVAS_ITEM_REALIZED )
- {
- gint old_height;
- gdouble text_height;
- old_height = e_minicard_label->height;
-
- gtk_object_get(GTK_OBJECT(e_minicard_label->fieldname),
- "text_height", &text_height,
- NULL);
- gnome_canvas_item_set(e_minicard_label->fieldname,
- "clip_height", (double) text_height,
- NULL);
-
- e_minicard_label->height = text_height;
-
-
- gtk_object_get(GTK_OBJECT(e_minicard_label->field),
- "text_height", &text_height,
- NULL);
- gnome_canvas_item_set(e_minicard_label->field,
- "clip_height", (double) text_height,
- NULL);
-
- if (e_minicard_label->height < text_height)
- e_minicard_label->height = text_height;
- e_minicard_label->height += 3;
-
- gnome_canvas_item_set( e_minicard_label->rect,
- "x2", (double) e_minicard_label->width - 1,
- "y2", (double) e_minicard_label->height - 1,
- NULL );
- gnome_canvas_item_set( e_minicard_label->fieldname,
- "clip_width", (double) ( e_minicard_label->width / 2 - 4 ),
- NULL );
- gnome_canvas_item_set( e_minicard_label->field,
- "x", (double) ( e_minicard_label->width / 2 + 2 ),
- "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ),
- NULL );
-
- if (old_height != e_minicard_label->height)
- gtk_signal_emit_by_name (GTK_OBJECT (e_minicard_label), "resize");
-
- }
-}
-
-
-
-static void
-_resize( GtkObject *object, gpointer data )
-{
- _update_label(E_MINICARD_LABEL(data));
-}
diff --git a/widgets/e-minicard-label.h b/widgets/e-minicard-label.h
deleted file mode 100644
index ddbe7ab191..0000000000
--- a/widgets/e-minicard-label.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-minicard-label.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_MINICARD_LABEL_H__
-#define __E_MINICARD_LABEL_H__
-
-#include <gnome.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* EMinicardLabel - A label doing focus with non-marching ants.
- *
- * The following arguments are available:
- *
- * name type read/write description
- * --------------------------------------------------------------------------------
- * width double RW width of the label
- * height double R height of the label
- * field string RW text in the field label
- * fieldname string RW text in the fieldname label
- */
-
-#define E_MINICARD_LABEL_TYPE (e_minicard_label_get_type ())
-#define E_MINICARD_LABEL(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_LABEL_TYPE, EMinicardLabel))
-#define E_MINICARD_LABEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_LABEL_TYPE, EMiniCardLabelClass))
-#define E_IS_MINICARD_LABEL(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_LABEL_TYPE))
-#define E_IS_MINICARD_LABEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_LABEL_TYPE))
-
-
-typedef struct _EMinicardLabel EMinicardLabel;
-typedef struct _EMinicardLabelClass EMinicardLabelClass;
-
-struct _EMinicardLabel
-{
- GnomeCanvasGroup parent;
-
- /* item specific fields */
- double width;
- double height;
- GnomeCanvasItem *fieldname;
- GnomeCanvasItem *field;
- GnomeCanvasItem *rect;
- char *fieldname_text;
- char *field_text;
-
- gboolean has_focus;
-};
-
-struct _EMinicardLabelClass
-{
- GnomeCanvasGroupClass parent_class;
-
- void (* resize) (EMinicardLabel *text);
-};
-
-
-GtkType e_minicard_label_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_MINICARD_LABEL_H__ */
diff --git a/widgets/e-minicard.c b/widgets/e-minicard.c
deleted file mode 100644
index b667f1ac21..0000000000
--- a/widgets/e-minicard.c
+++ /dev/null
@@ -1,462 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-minicard.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include "e-minicard.h"
-#include "e-minicard-label.h"
-#include "e-text.h"
-#include "e-canvas.h"
-static void e_minicard_init (EMinicard *card);
-static void e_minicard_class_init (EMinicardClass *klass);
-static void e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
-static void e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static gboolean e_minicard_event (GnomeCanvasItem *item, GdkEvent *event);
-static void e_minicard_realize (GnomeCanvasItem *item);
-static void e_minicard_unrealize (GnomeCanvasItem *item);
-
-static void _update_card ( EMinicard *minicard );
-static void _resize( GtkObject *object, gpointer data );
-
-static GnomeCanvasGroupClass *parent_class = NULL;
-
-enum {
- E_MINICARD_RESIZE,
- E_MINICARD_LAST_SIGNAL
-};
-
-static guint e_minicard_signals[E_MINICARD_LAST_SIGNAL] = { 0 };
-
-/* The arguments we take */
-enum {
- ARG_0,
- ARG_WIDTH,
- ARG_HEIGHT,
- ARG_HAS_FOCUS,
- ARG_CARD
-};
-
-GtkType
-e_minicard_get_type (void)
-{
- static GtkType minicard_type = 0;
-
- if (!minicard_type)
- {
- static const GtkTypeInfo minicard_info =
- {
- "EMinicard",
- sizeof (EMinicard),
- sizeof (EMinicardClass),
- (GtkClassInitFunc) e_minicard_class_init,
- (GtkObjectInitFunc) e_minicard_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- minicard_type = gtk_type_unique (gnome_canvas_group_get_type (), &minicard_info);
- }
-
- return minicard_type;
-}
-
-static void
-e_minicard_class_init (EMinicardClass *klass)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass*) klass;
- item_class = (GnomeCanvasItemClass *) klass;
-
- parent_class = gtk_type_class (gnome_canvas_group_get_type ());
-
- e_minicard_signals[E_MINICARD_RESIZE] =
- gtk_signal_new ("resize",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EMinicardClass, resize),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
-
- gtk_object_class_add_signals (object_class, e_minicard_signals, E_MINICARD_LAST_SIGNAL);
-
- gtk_object_add_arg_type ("EMinicard::width", GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE, ARG_WIDTH);
- gtk_object_add_arg_type ("EMinicard::height", GTK_TYPE_DOUBLE,
- GTK_ARG_READABLE, ARG_HEIGHT);
- gtk_object_add_arg_type ("EMinicard::has_focus", GTK_TYPE_BOOL,
- GTK_ARG_READWRITE, ARG_HAS_FOCUS);
- gtk_object_add_arg_type ("EMinicard::card", GTK_TYPE_OBJECT,
- GTK_ARG_READWRITE, ARG_CARD);
-
- object_class->set_arg = e_minicard_set_arg;
- object_class->get_arg = e_minicard_get_arg;
- /* object_class->destroy = e_minicard_destroy; */
-
- /* GnomeCanvasItem method overrides */
- item_class->realize = e_minicard_realize;
- item_class->unrealize = e_minicard_unrealize;
- item_class->event = e_minicard_event;
-}
-
-static void
-e_minicard_init (EMinicard *minicard)
-{
- /* minicard->card = NULL;*/
- minicard->rect = NULL;
- minicard->fields = NULL;
- minicard->width = 10;
- minicard->height = 10;
- minicard->has_focus = FALSE;
-}
-
-static void
-e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EMinicard *e_minicard;
-
- item = GNOME_CANVAS_ITEM (o);
- e_minicard = E_MINICARD (o);
-
- switch (arg_id){
- case ARG_WIDTH:
- if (e_minicard->width != GTK_VALUE_DOUBLE (*arg)) {
- e_minicard->width = GTK_VALUE_DOUBLE (*arg);
- _update_card(e_minicard);
- gnome_canvas_item_request_update (item);
- }
- break;
- case ARG_HAS_FOCUS:
- if (e_minicard->fields)
- gnome_canvas_item_set(GNOME_CANVAS_ITEM(e_minicard->fields->data),
- "has_focus", GTK_VALUE_BOOL(*arg),
- NULL);
- else
- e_canvas_item_grab_focus(GNOME_CANVAS_ITEM(e_minicard));
- break;
- case ARG_CARD:
- /* e_minicard->card = GTK_VALUE_POINTER (*arg);
- _update_card(e_minicard);
- gnome_canvas_item_request_update (item);*/
- break;
- }
-}
-
-static void
-e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- EMinicard *e_minicard;
-
- e_minicard = E_MINICARD (object);
-
- switch (arg_id) {
- case ARG_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = e_minicard->width;
- break;
- case ARG_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = e_minicard->height;
- break;
- case ARG_HAS_FOCUS:
- GTK_VALUE_BOOL (*arg) = e_minicard->has_focus;
- break;
- case ARG_CARD:
- /* GTK_VALUE_POINTER (*arg) = e_minicard->card; */
- break;
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-static void
-e_minicard_realize (GnomeCanvasItem *item)
-{
- EMinicard *e_minicard;
- GnomeCanvasGroup *group;
- GnomeCanvasItem *new_item;
-
- e_minicard = E_MINICARD (item);
- group = GNOME_CANVAS_GROUP( item );
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize)
- (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item);
-
- e_minicard->rect =
- gnome_canvas_item_new( group,
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) e_minicard->width - 1,
- "y2", (double) e_minicard->height - 1,
- "outline_color", NULL,
- NULL );
-
- e_minicard->header_rect =
- gnome_canvas_item_new( group,
- gnome_canvas_rect_get_type(),
- "x1", (double) 2,
- "y1", (double) 2,
- "x2", (double) e_minicard->width - 3,
- "y2", (double) e_minicard->height - 3,
- "fill_color", "grey70",
- NULL );
-
- e_minicard->header_text =
- gnome_canvas_item_new( group,
- e_text_get_type(),
- "x", (double) 6,
- "y", (double) 6,
- "anchor", GTK_ANCHOR_NW,
- "clip_width", (double) ( e_minicard->width - 12 ),
- "clip", TRUE,
- "use_ellipsis", TRUE,
- "font", "lucidasans-bold-10",
- "fill_color", "black",
- "text", "Chris Lahey",
- NULL );
-
- gtk_signal_connect(GTK_OBJECT(e_minicard->header_text),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard);
- if ( rand() % 2 ) {
- new_item = gnome_canvas_item_new( group,
- e_minicard_label_get_type(),
- "x", (double) 2,
- "y", e_minicard->height,
- "width", e_minicard->width - 4,
- "fieldname", "Full Name:",
- "field", "Christopher James Lahey",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
-
- gtk_signal_connect(GTK_OBJECT(new_item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard);
- }
-
- if (rand() % 2) {
- new_item = gnome_canvas_item_new( group,
- e_minicard_label_get_type(),
- "x", (double) 2,
- "y", e_minicard->height,
- "width", e_minicard->width - 4,
- "fieldname", "Address:",
- "field", "100 Main St\nHome town, USA",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
-
- gtk_signal_connect(GTK_OBJECT(new_item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard);
- }
-
- if (rand() % 2) {
- new_item = gnome_canvas_item_new( group,
- e_minicard_label_get_type(),
- "x", (double) 2,
- "y", e_minicard->height,
- "width", e_minicard->width - 4.0,
- "fieldname", "Email:",
- "field", "clahey@address.com",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
-
- gtk_signal_connect(GTK_OBJECT(new_item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard);
- }
- _update_card( e_minicard );
-
- if (!item->canvas->aa) {
- }
-}
-
-static void
-e_minicard_unrealize (GnomeCanvasItem *item)
-{
- EMinicard *e_minicard;
-
- e_minicard = E_MINICARD (item);
-
- if (!item->canvas->aa)
- {
- }
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize)
- (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item);
-}
-
-static gboolean
-e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EMinicard *e_minicard;
-
- e_minicard = E_MINICARD (item);
-
- switch( event->type )
- {
- case GDK_FOCUS_CHANGE:
- {
- GdkEventFocus *focus_event = (GdkEventFocus *) event;
- if ( focus_event->in )
- {
- gnome_canvas_item_set( e_minicard->rect,
- "outline_color", "grey50",
- NULL );
- gnome_canvas_item_set( e_minicard->header_rect,
- "fill_color", "darkblue",
- NULL );
- gnome_canvas_item_set( e_minicard->header_text,
- "fill_color", "white",
- NULL );
- e_minicard->has_focus = TRUE;
- }
- else
- {
- gnome_canvas_item_set( e_minicard->rect,
- "outline_color", NULL,
- NULL );
- gnome_canvas_item_set( e_minicard->header_rect,
- "fill_color", "grey70",
- NULL );
- gnome_canvas_item_set( e_minicard->header_text,
- "fill_color", "black",
- NULL );
- e_minicard->has_focus = FALSE;
- }
- }
- break;
- case GDK_BUTTON_PRESS:
- if (event->button.button == 1) {
- e_canvas_item_grab_focus(item);
- }
- break;
- case GDK_KEY_PRESS:
- if (event->key.keyval == GDK_Tab ||
- event->key.keyval == GDK_KP_Tab ||
- event->key.keyval == GDK_ISO_Left_Tab) {
- GList *list;
- for (list = e_minicard->fields; list; list = list->next) {
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data);
- gboolean has_focus;
- gtk_object_get(GTK_OBJECT(item),
- "has_focus", &has_focus,
- NULL);
- if (has_focus) {
- if (event->key.state & GDK_SHIFT_MASK)
- list = list->prev;
- else
- list = list->next;
- if (list) {
- item = GNOME_CANVAS_ITEM (list->data);
- gnome_canvas_item_set(item,
- "has_focus", TRUE,
- NULL);
- return 1;
- } else {
- return 0;
- }
- }
- }
- }
- default:
- break;
- }
-
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event)
- return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event);
- else
- return 0;
-}
-
-static void
-_update_card( EMinicard *e_minicard )
-{
- if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) {
- GList *list;
- gdouble text_height;
- gint old_height;
-
- old_height = e_minicard->height;
-
- gtk_object_get( GTK_OBJECT( e_minicard->header_text ),
- "text_height", &text_height,
- NULL );
-
- e_minicard->height = text_height + 10.0;
-
- gnome_canvas_item_set( e_minicard->header_rect,
- "y2", text_height + 9.0,
- NULL );
-
- gnome_canvas_item_set( e_minicard->header_text,
- "clip_height", (double)text_height,
- NULL );
-
- for(list = e_minicard->fields; list; list = g_list_next(list)) {
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &text_height,
- NULL);
- gnome_canvas_item_set(GNOME_CANVAS_ITEM(list->data),
- "y", (double) e_minicard->height,
- NULL);
- e_minicard->height += text_height;
- }
- e_minicard->height += 2;
-
- gnome_canvas_item_set( e_minicard->rect,
- "y2", (double) e_minicard->height - 1,
- NULL );
-
- gnome_canvas_item_set( e_minicard->rect,
- "x2", (double) e_minicard->width - 1.0,
- "y2", (double) e_minicard->height - 1.0,
- NULL );
- gnome_canvas_item_set( e_minicard->header_rect,
- "x2", (double) e_minicard->width - 3.0,
- NULL );
- gnome_canvas_item_set( e_minicard->header_text,
- "clip_width", (double) e_minicard->width - 12,
- NULL );
- for ( list = e_minicard->fields; list; list = g_list_next( list ) ) {
- gnome_canvas_item_set( GNOME_CANVAS_ITEM( list->data ),
- "width", (double) e_minicard->width - 4.0,
- NULL );
-
- if (old_height != e_minicard->height)
- gtk_signal_emit_by_name (GTK_OBJECT (e_minicard), "resize");
- }
- }
-}
-
-static void
-_resize( GtkObject *object, gpointer data )
-{
- _update_card(E_MINICARD(data));
-}
diff --git a/widgets/e-minicard.h b/widgets/e-minicard.h
deleted file mode 100644
index 3be80c1586..0000000000
--- a/widgets/e-minicard.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-minicard.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_MINICARD_H__
-#define __E_MINICARD_H__
-
-#include <gnome.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* EMinicard - A small card displaying information about a contact.
- *
- * The following arguments are available:
- *
- * name type read/write description
- * --------------------------------------------------------------------------------
- * width double RW width of the card
- * height double R height of the card
- * card ECard* RW Pointer to the ECard
- */
-
-#define E_MINICARD_TYPE (e_minicard_get_type ())
-#define E_MINICARD(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_TYPE, EMinicard))
-#define E_MINICARD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_TYPE, EMinicardClass))
-#define E_IS_MINICARD(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_TYPE))
-#define E_IS_MINICARD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_TYPE))
-
-
-typedef struct _EMinicard EMinicard;
-typedef struct _EMinicardClass EMinicardClass;
-typedef enum _EMinicardFocusType EMinicardFocusType;
-
-enum _EMinicardFocusType {
- E_MINICARD_FOCUS_TYPE_START,
- E_MINICARD_FOCUS_TYPE_END
-};
-
-struct _EMinicard
-{
- GnomeCanvasGroup parent;
-
- /* item specific fields */
- /* ECard *card; */
-
- GnomeCanvasItem *rect;
- GnomeCanvasItem *header_rect;
- GnomeCanvasItem *header_text;
- GList *fields; /* Of type GnomeCanvasItem. */
-
- gboolean has_focus;
-
- double width;
- double height;
-};
-
-struct _EMinicardClass
-{
- GnomeCanvasGroupClass parent_class;
-
- void (* resize) (EMinicard *minicard);
-};
-
-
-GtkType e_minicard_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_MINICARD_H__ */
diff --git a/widgets/e-minicard/e-minicard-label.c b/widgets/e-minicard/e-minicard-label.c
deleted file mode 100644
index 43603f2d6d..0000000000
--- a/widgets/e-minicard/e-minicard-label.c
+++ /dev/null
@@ -1,456 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-minicard-label.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include "e-minicard-label.h"
-#include "e-text.h"
-#include "e-canvas.h"
-static void e_minicard_label_init (EMinicardLabel *card);
-static void e_minicard_label_class_init (EMinicardLabelClass *klass);
-static void e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
-static void e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static gboolean e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event);
-static void e_minicard_label_realize (GnomeCanvasItem *item);
-static void e_minicard_label_unrealize (GnomeCanvasItem *item);
-
-static void _update_label( EMinicardLabel *minicard_label );
-static void _resize( GtkObject *object, gpointer data );
-
-static GnomeCanvasGroupClass *parent_class = NULL;
-
-enum {
- E_MINICARD_LABEL_RESIZE,
- E_MINICARD_LABEL_LAST_SIGNAL
-};
-
-static guint e_minicard_label_signals[E_MINICARD_LABEL_LAST_SIGNAL] = { 0 };
-
-/* The arguments we take */
-enum {
- ARG_0,
- ARG_WIDTH,
- ARG_HEIGHT,
- ARG_HAS_FOCUS,
- ARG_FIELD,
- ARG_FIELDNAME
-};
-
-GtkType
-e_minicard_label_get_type (void)
-{
- static GtkType minicard_label_type = 0;
-
- if (!minicard_label_type)
- {
- static const GtkTypeInfo minicard_label_info =
- {
- "EMinicardLabel",
- sizeof (EMinicardLabel),
- sizeof (EMinicardLabelClass),
- (GtkClassInitFunc) e_minicard_label_class_init,
- (GtkObjectInitFunc) e_minicard_label_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- minicard_label_type = gtk_type_unique (gnome_canvas_group_get_type (), &minicard_label_info);
- }
-
- return minicard_label_type;
-}
-
-static void
-e_minicard_label_class_init (EMinicardLabelClass *klass)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass*) klass;
- item_class = (GnomeCanvasItemClass *) klass;
-
- parent_class = gtk_type_class (gnome_canvas_group_get_type ());
-
- e_minicard_label_signals[E_MINICARD_LABEL_RESIZE] =
- gtk_signal_new ("resize",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EMinicardLabelClass, resize),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
-
- gtk_object_class_add_signals (object_class, e_minicard_label_signals, E_MINICARD_LABEL_LAST_SIGNAL);
-
- gtk_object_add_arg_type ("EMinicardLabel::width", GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE, ARG_WIDTH);
- gtk_object_add_arg_type ("EMinicardLabel::height", GTK_TYPE_DOUBLE,
- GTK_ARG_READABLE, ARG_HEIGHT);
- gtk_object_add_arg_type ("EMinicardLabel::has_focus", GTK_TYPE_BOOL,
- GTK_ARG_READWRITE, ARG_HAS_FOCUS);
- gtk_object_add_arg_type ("EMinicardLabel::field", GTK_TYPE_STRING,
- GTK_ARG_READWRITE, ARG_FIELD);
- gtk_object_add_arg_type ("EMinicardLabel::fieldname", GTK_TYPE_STRING,
- GTK_ARG_READWRITE, ARG_FIELDNAME);
-
- klass->resize = NULL;
-
- object_class->set_arg = e_minicard_label_set_arg;
- object_class->get_arg = e_minicard_label_get_arg;
- /* object_class->destroy = e_minicard_label_destroy; */
-
- /* GnomeCanvasItem method overrides */
- item_class->realize = e_minicard_label_realize;
- item_class->unrealize = e_minicard_label_unrealize;
- item_class->event = e_minicard_label_event;
-}
-
-static void
-e_minicard_label_init (EMinicardLabel *minicard_label)
-{
- minicard_label->width = 10;
- minicard_label->height = 10;
- minicard_label->rect = NULL;
- minicard_label->fieldname = NULL;
- minicard_label->field = NULL;
- minicard_label->fieldname_text = NULL;
- minicard_label->field_text = NULL;
-}
-
-static void
-e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EMinicardLabel *e_minicard_label;
-
- item = GNOME_CANVAS_ITEM (o);
- e_minicard_label = E_MINICARD_LABEL (o);
-
- switch (arg_id){
- case ARG_WIDTH:
- e_minicard_label->width = GTK_VALUE_DOUBLE (*arg);
- _update_label( e_minicard_label );
- gnome_canvas_item_request_update (item);
- break;
- case ARG_HAS_FOCUS:
- if (e_minicard_label->field && GTK_VALUE_BOOL(*arg))
- e_canvas_item_grab_focus(e_minicard_label->field);
- break;
- case ARG_FIELD:
- if ( e_minicard_label->field )
- gnome_canvas_item_set( e_minicard_label->field, "text", GTK_VALUE_STRING (*arg), NULL );
- else
- e_minicard_label->field_text = g_strdup( GTK_VALUE_STRING (*arg) );
- break;
- case ARG_FIELDNAME:
- if ( e_minicard_label->fieldname )
- gnome_canvas_item_set( e_minicard_label->fieldname, "text", GTK_VALUE_STRING (*arg), NULL );
- else
- e_minicard_label->fieldname_text = g_strdup( GTK_VALUE_STRING (*arg) );
- break;
- }
-}
-
-static void
-e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- EMinicardLabel *e_minicard_label;
- char *temp;
-
- e_minicard_label = E_MINICARD_LABEL (object);
-
- switch (arg_id) {
- case ARG_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = e_minicard_label->width;
- break;
- case ARG_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = e_minicard_label->height;
- break;
- case ARG_HAS_FOCUS:
- GTK_VALUE_BOOL (*arg) = e_minicard_label->has_focus;
- break;
- case ARG_FIELD:
- if ( e_minicard_label->field ) {
- gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "text", &temp, NULL );
- GTK_VALUE_STRING (*arg) = temp;
- } else
- GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->field_text );
- break;
- case ARG_FIELDNAME:
- if ( e_minicard_label->fieldname ) {
- gtk_object_get( GTK_OBJECT( e_minicard_label->fieldname ), "text", &temp, NULL );
- GTK_VALUE_STRING (*arg) = temp;
- } else
- GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->fieldname_text );
- break;
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-static void
-e_minicard_label_realize (GnomeCanvasItem *item)
-{
- EMinicardLabel *e_minicard_label;
- GnomeCanvasGroup *group;
-
- e_minicard_label = E_MINICARD_LABEL (item);
- group = GNOME_CANVAS_GROUP( item );
-
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->realize)
- (* GNOME_CANVAS_ITEM_CLASS( parent_class )->realize) (item);
-
- e_minicard_label->rect =
- gnome_canvas_item_new( group,
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) e_minicard_label->width - 1,
- "y2", (double) e_minicard_label->height - 1,
- "outline_color", NULL,
- NULL );
- e_minicard_label->fieldname =
- gnome_canvas_item_new( group,
- e_text_get_type(),
- "x", (double) 2,
- "y", (double) 1,
- "anchor", GTK_ANCHOR_NW,
- "clip_width", (double) ( e_minicard_label->width / 2 - 4 ),
- "clip_height", (double) 1,
- "clip", TRUE,
- "use_ellipsis", TRUE,
- "font", "lucidasans-10",
- "fill_color", "black",
- NULL );
- if ( e_minicard_label->fieldname_text )
- {
- gnome_canvas_item_set( e_minicard_label->fieldname,
- "text", e_minicard_label->fieldname_text,
- NULL );
- g_free( e_minicard_label->fieldname_text );
- }
- gtk_signal_connect(GTK_OBJECT(e_minicard_label->fieldname),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard_label);
-
- e_minicard_label->field =
- gnome_canvas_item_new( group,
- e_text_get_type(),
- "x", (double) ( e_minicard_label->width / 2 + 2 ),
- "y", (double) 1,
- "anchor", GTK_ANCHOR_NW,
- "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ),
- "clip_height", (double) 1,
- "clip", TRUE,
- "use_ellipsis", TRUE,
- "font", "lucidasans-10",
- "fill_color", "black",
- "editable", TRUE,
- NULL );
- if ( e_minicard_label->field_text )
- {
- gnome_canvas_item_set( e_minicard_label->field,
- "text", e_minicard_label->field_text,
- NULL );
- g_free( e_minicard_label->field_text );
- }
-
- gtk_signal_connect(GTK_OBJECT(e_minicard_label->field),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard_label);
-
- _update_label (e_minicard_label);
-
- if (!item->canvas->aa)
- {
- }
-
-}
-
-static void
-e_minicard_label_unrealize (GnomeCanvasItem *item)
-{
- EMinicardLabel *e_minicard_label;
-
- e_minicard_label = E_MINICARD_LABEL (item);
-
- if (!item->canvas->aa)
- {
- }
-
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize)
- (* GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize) (item);
-}
-
-static gboolean
-e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EMinicardLabel *e_minicard_label;
-
- e_minicard_label = E_MINICARD_LABEL (item);
-
- switch( event->type )
- {
- case GDK_FOCUS_CHANGE:
- {
- GdkEventFocus *focus_event = (GdkEventFocus *) event;
- if ( focus_event->in )
- {
- gnome_canvas_item_set( e_minicard_label->rect,
- "outline_color", "grey50",
- "fill_color", "grey90",
- NULL );
- e_minicard_label->has_focus = TRUE;
- }
- else
- {
- gnome_canvas_item_set( e_minicard_label->rect,
- "outline_color", NULL,
- "fill_color", NULL,
- NULL );
- e_minicard_label->has_focus = FALSE;
- }
- }
- break;
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- case GDK_MOTION_NOTIFY:
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY: {
- GnomeCanvasItem *field;
- ArtPoint p;
- double inv[6], affine[6];
- gboolean return_val;
-
- field = e_minicard_label->field;
- art_affine_identity (affine);
-
- if (field->xform != NULL) {
- if (field->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) {
- art_affine_multiply (affine, affine, field->xform);
- } else {
- affine[4] += field->xform[0];
- affine[5] += field->xform[1];
- }
- }
-
- art_affine_invert (inv, affine);
- switch(event->type) {
- case GDK_MOTION_NOTIFY:
- p.x = event->motion.x;
- p.y = event->motion.y;
- art_affine_point (&p, &p, inv);
- event->motion.x = p.x;
- event->motion.y = p.y;
- break;
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- p.x = event->button.x;
- p.y = event->button.y;
- art_affine_point (&p, &p, inv);
- event->button.x = p.x;
- event->button.y = p.y;
- break;
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY:
- p.x = event->crossing.x;
- p.y = event->crossing.y;
- art_affine_point (&p, &p, inv);
- event->crossing.x = p.x;
- event->crossing.y = p.y;
- break;
- default:
- break;
- }
-
- gtk_signal_emit_by_name(GTK_OBJECT(e_minicard_label->field), "event", event, &return_val);
- return return_val;
- break;
- }
- default:
- break;
- }
-
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event)
- return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event);
- else
- return 0;
-}
-
-static void
-_update_label( EMinicardLabel *e_minicard_label )
-{
- if ( GTK_OBJECT_FLAGS( e_minicard_label ) & GNOME_CANVAS_ITEM_REALIZED )
- {
- gint old_height;
- gdouble text_height;
- old_height = e_minicard_label->height;
-
- gtk_object_get(GTK_OBJECT(e_minicard_label->fieldname),
- "text_height", &text_height,
- NULL);
- gnome_canvas_item_set(e_minicard_label->fieldname,
- "clip_height", (double) text_height,
- NULL);
-
- e_minicard_label->height = text_height;
-
-
- gtk_object_get(GTK_OBJECT(e_minicard_label->field),
- "text_height", &text_height,
- NULL);
- gnome_canvas_item_set(e_minicard_label->field,
- "clip_height", (double) text_height,
- NULL);
-
- if (e_minicard_label->height < text_height)
- e_minicard_label->height = text_height;
- e_minicard_label->height += 3;
-
- gnome_canvas_item_set( e_minicard_label->rect,
- "x2", (double) e_minicard_label->width - 1,
- "y2", (double) e_minicard_label->height - 1,
- NULL );
- gnome_canvas_item_set( e_minicard_label->fieldname,
- "clip_width", (double) ( e_minicard_label->width / 2 - 4 ),
- NULL );
- gnome_canvas_item_set( e_minicard_label->field,
- "x", (double) ( e_minicard_label->width / 2 + 2 ),
- "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ),
- NULL );
-
- if (old_height != e_minicard_label->height)
- gtk_signal_emit_by_name (GTK_OBJECT (e_minicard_label), "resize");
-
- }
-}
-
-
-
-static void
-_resize( GtkObject *object, gpointer data )
-{
- _update_label(E_MINICARD_LABEL(data));
-}
diff --git a/widgets/e-minicard/e-minicard-label.h b/widgets/e-minicard/e-minicard-label.h
deleted file mode 100644
index ddbe7ab191..0000000000
--- a/widgets/e-minicard/e-minicard-label.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-minicard-label.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_MINICARD_LABEL_H__
-#define __E_MINICARD_LABEL_H__
-
-#include <gnome.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* EMinicardLabel - A label doing focus with non-marching ants.
- *
- * The following arguments are available:
- *
- * name type read/write description
- * --------------------------------------------------------------------------------
- * width double RW width of the label
- * height double R height of the label
- * field string RW text in the field label
- * fieldname string RW text in the fieldname label
- */
-
-#define E_MINICARD_LABEL_TYPE (e_minicard_label_get_type ())
-#define E_MINICARD_LABEL(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_LABEL_TYPE, EMinicardLabel))
-#define E_MINICARD_LABEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_LABEL_TYPE, EMiniCardLabelClass))
-#define E_IS_MINICARD_LABEL(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_LABEL_TYPE))
-#define E_IS_MINICARD_LABEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_LABEL_TYPE))
-
-
-typedef struct _EMinicardLabel EMinicardLabel;
-typedef struct _EMinicardLabelClass EMinicardLabelClass;
-
-struct _EMinicardLabel
-{
- GnomeCanvasGroup parent;
-
- /* item specific fields */
- double width;
- double height;
- GnomeCanvasItem *fieldname;
- GnomeCanvasItem *field;
- GnomeCanvasItem *rect;
- char *fieldname_text;
- char *field_text;
-
- gboolean has_focus;
-};
-
-struct _EMinicardLabelClass
-{
- GnomeCanvasGroupClass parent_class;
-
- void (* resize) (EMinicardLabel *text);
-};
-
-
-GtkType e_minicard_label_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_MINICARD_LABEL_H__ */
diff --git a/widgets/e-minicard/e-minicard.c b/widgets/e-minicard/e-minicard.c
deleted file mode 100644
index b667f1ac21..0000000000
--- a/widgets/e-minicard/e-minicard.c
+++ /dev/null
@@ -1,462 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-minicard.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include "e-minicard.h"
-#include "e-minicard-label.h"
-#include "e-text.h"
-#include "e-canvas.h"
-static void e_minicard_init (EMinicard *card);
-static void e_minicard_class_init (EMinicardClass *klass);
-static void e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
-static void e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static gboolean e_minicard_event (GnomeCanvasItem *item, GdkEvent *event);
-static void e_minicard_realize (GnomeCanvasItem *item);
-static void e_minicard_unrealize (GnomeCanvasItem *item);
-
-static void _update_card ( EMinicard *minicard );
-static void _resize( GtkObject *object, gpointer data );
-
-static GnomeCanvasGroupClass *parent_class = NULL;
-
-enum {
- E_MINICARD_RESIZE,
- E_MINICARD_LAST_SIGNAL
-};
-
-static guint e_minicard_signals[E_MINICARD_LAST_SIGNAL] = { 0 };
-
-/* The arguments we take */
-enum {
- ARG_0,
- ARG_WIDTH,
- ARG_HEIGHT,
- ARG_HAS_FOCUS,
- ARG_CARD
-};
-
-GtkType
-e_minicard_get_type (void)
-{
- static GtkType minicard_type = 0;
-
- if (!minicard_type)
- {
- static const GtkTypeInfo minicard_info =
- {
- "EMinicard",
- sizeof (EMinicard),
- sizeof (EMinicardClass),
- (GtkClassInitFunc) e_minicard_class_init,
- (GtkObjectInitFunc) e_minicard_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- minicard_type = gtk_type_unique (gnome_canvas_group_get_type (), &minicard_info);
- }
-
- return minicard_type;
-}
-
-static void
-e_minicard_class_init (EMinicardClass *klass)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass*) klass;
- item_class = (GnomeCanvasItemClass *) klass;
-
- parent_class = gtk_type_class (gnome_canvas_group_get_type ());
-
- e_minicard_signals[E_MINICARD_RESIZE] =
- gtk_signal_new ("resize",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EMinicardClass, resize),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
-
- gtk_object_class_add_signals (object_class, e_minicard_signals, E_MINICARD_LAST_SIGNAL);
-
- gtk_object_add_arg_type ("EMinicard::width", GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE, ARG_WIDTH);
- gtk_object_add_arg_type ("EMinicard::height", GTK_TYPE_DOUBLE,
- GTK_ARG_READABLE, ARG_HEIGHT);
- gtk_object_add_arg_type ("EMinicard::has_focus", GTK_TYPE_BOOL,
- GTK_ARG_READWRITE, ARG_HAS_FOCUS);
- gtk_object_add_arg_type ("EMinicard::card", GTK_TYPE_OBJECT,
- GTK_ARG_READWRITE, ARG_CARD);
-
- object_class->set_arg = e_minicard_set_arg;
- object_class->get_arg = e_minicard_get_arg;
- /* object_class->destroy = e_minicard_destroy; */
-
- /* GnomeCanvasItem method overrides */
- item_class->realize = e_minicard_realize;
- item_class->unrealize = e_minicard_unrealize;
- item_class->event = e_minicard_event;
-}
-
-static void
-e_minicard_init (EMinicard *minicard)
-{
- /* minicard->card = NULL;*/
- minicard->rect = NULL;
- minicard->fields = NULL;
- minicard->width = 10;
- minicard->height = 10;
- minicard->has_focus = FALSE;
-}
-
-static void
-e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EMinicard *e_minicard;
-
- item = GNOME_CANVAS_ITEM (o);
- e_minicard = E_MINICARD (o);
-
- switch (arg_id){
- case ARG_WIDTH:
- if (e_minicard->width != GTK_VALUE_DOUBLE (*arg)) {
- e_minicard->width = GTK_VALUE_DOUBLE (*arg);
- _update_card(e_minicard);
- gnome_canvas_item_request_update (item);
- }
- break;
- case ARG_HAS_FOCUS:
- if (e_minicard->fields)
- gnome_canvas_item_set(GNOME_CANVAS_ITEM(e_minicard->fields->data),
- "has_focus", GTK_VALUE_BOOL(*arg),
- NULL);
- else
- e_canvas_item_grab_focus(GNOME_CANVAS_ITEM(e_minicard));
- break;
- case ARG_CARD:
- /* e_minicard->card = GTK_VALUE_POINTER (*arg);
- _update_card(e_minicard);
- gnome_canvas_item_request_update (item);*/
- break;
- }
-}
-
-static void
-e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- EMinicard *e_minicard;
-
- e_minicard = E_MINICARD (object);
-
- switch (arg_id) {
- case ARG_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = e_minicard->width;
- break;
- case ARG_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = e_minicard->height;
- break;
- case ARG_HAS_FOCUS:
- GTK_VALUE_BOOL (*arg) = e_minicard->has_focus;
- break;
- case ARG_CARD:
- /* GTK_VALUE_POINTER (*arg) = e_minicard->card; */
- break;
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-static void
-e_minicard_realize (GnomeCanvasItem *item)
-{
- EMinicard *e_minicard;
- GnomeCanvasGroup *group;
- GnomeCanvasItem *new_item;
-
- e_minicard = E_MINICARD (item);
- group = GNOME_CANVAS_GROUP( item );
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize)
- (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item);
-
- e_minicard->rect =
- gnome_canvas_item_new( group,
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) e_minicard->width - 1,
- "y2", (double) e_minicard->height - 1,
- "outline_color", NULL,
- NULL );
-
- e_minicard->header_rect =
- gnome_canvas_item_new( group,
- gnome_canvas_rect_get_type(),
- "x1", (double) 2,
- "y1", (double) 2,
- "x2", (double) e_minicard->width - 3,
- "y2", (double) e_minicard->height - 3,
- "fill_color", "grey70",
- NULL );
-
- e_minicard->header_text =
- gnome_canvas_item_new( group,
- e_text_get_type(),
- "x", (double) 6,
- "y", (double) 6,
- "anchor", GTK_ANCHOR_NW,
- "clip_width", (double) ( e_minicard->width - 12 ),
- "clip", TRUE,
- "use_ellipsis", TRUE,
- "font", "lucidasans-bold-10",
- "fill_color", "black",
- "text", "Chris Lahey",
- NULL );
-
- gtk_signal_connect(GTK_OBJECT(e_minicard->header_text),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard);
- if ( rand() % 2 ) {
- new_item = gnome_canvas_item_new( group,
- e_minicard_label_get_type(),
- "x", (double) 2,
- "y", e_minicard->height,
- "width", e_minicard->width - 4,
- "fieldname", "Full Name:",
- "field", "Christopher James Lahey",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
-
- gtk_signal_connect(GTK_OBJECT(new_item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard);
- }
-
- if (rand() % 2) {
- new_item = gnome_canvas_item_new( group,
- e_minicard_label_get_type(),
- "x", (double) 2,
- "y", e_minicard->height,
- "width", e_minicard->width - 4,
- "fieldname", "Address:",
- "field", "100 Main St\nHome town, USA",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
-
- gtk_signal_connect(GTK_OBJECT(new_item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard);
- }
-
- if (rand() % 2) {
- new_item = gnome_canvas_item_new( group,
- e_minicard_label_get_type(),
- "x", (double) 2,
- "y", e_minicard->height,
- "width", e_minicard->width - 4.0,
- "fieldname", "Email:",
- "field", "clahey@address.com",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
-
- gtk_signal_connect(GTK_OBJECT(new_item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard);
- }
- _update_card( e_minicard );
-
- if (!item->canvas->aa) {
- }
-}
-
-static void
-e_minicard_unrealize (GnomeCanvasItem *item)
-{
- EMinicard *e_minicard;
-
- e_minicard = E_MINICARD (item);
-
- if (!item->canvas->aa)
- {
- }
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize)
- (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item);
-}
-
-static gboolean
-e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EMinicard *e_minicard;
-
- e_minicard = E_MINICARD (item);
-
- switch( event->type )
- {
- case GDK_FOCUS_CHANGE:
- {
- GdkEventFocus *focus_event = (GdkEventFocus *) event;
- if ( focus_event->in )
- {
- gnome_canvas_item_set( e_minicard->rect,
- "outline_color", "grey50",
- NULL );
- gnome_canvas_item_set( e_minicard->header_rect,
- "fill_color", "darkblue",
- NULL );
- gnome_canvas_item_set( e_minicard->header_text,
- "fill_color", "white",
- NULL );
- e_minicard->has_focus = TRUE;
- }
- else
- {
- gnome_canvas_item_set( e_minicard->rect,
- "outline_color", NULL,
- NULL );
- gnome_canvas_item_set( e_minicard->header_rect,
- "fill_color", "grey70",
- NULL );
- gnome_canvas_item_set( e_minicard->header_text,
- "fill_color", "black",
- NULL );
- e_minicard->has_focus = FALSE;
- }
- }
- break;
- case GDK_BUTTON_PRESS:
- if (event->button.button == 1) {
- e_canvas_item_grab_focus(item);
- }
- break;
- case GDK_KEY_PRESS:
- if (event->key.keyval == GDK_Tab ||
- event->key.keyval == GDK_KP_Tab ||
- event->key.keyval == GDK_ISO_Left_Tab) {
- GList *list;
- for (list = e_minicard->fields; list; list = list->next) {
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data);
- gboolean has_focus;
- gtk_object_get(GTK_OBJECT(item),
- "has_focus", &has_focus,
- NULL);
- if (has_focus) {
- if (event->key.state & GDK_SHIFT_MASK)
- list = list->prev;
- else
- list = list->next;
- if (list) {
- item = GNOME_CANVAS_ITEM (list->data);
- gnome_canvas_item_set(item,
- "has_focus", TRUE,
- NULL);
- return 1;
- } else {
- return 0;
- }
- }
- }
- }
- default:
- break;
- }
-
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event)
- return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event);
- else
- return 0;
-}
-
-static void
-_update_card( EMinicard *e_minicard )
-{
- if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) {
- GList *list;
- gdouble text_height;
- gint old_height;
-
- old_height = e_minicard->height;
-
- gtk_object_get( GTK_OBJECT( e_minicard->header_text ),
- "text_height", &text_height,
- NULL );
-
- e_minicard->height = text_height + 10.0;
-
- gnome_canvas_item_set( e_minicard->header_rect,
- "y2", text_height + 9.0,
- NULL );
-
- gnome_canvas_item_set( e_minicard->header_text,
- "clip_height", (double)text_height,
- NULL );
-
- for(list = e_minicard->fields; list; list = g_list_next(list)) {
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &text_height,
- NULL);
- gnome_canvas_item_set(GNOME_CANVAS_ITEM(list->data),
- "y", (double) e_minicard->height,
- NULL);
- e_minicard->height += text_height;
- }
- e_minicard->height += 2;
-
- gnome_canvas_item_set( e_minicard->rect,
- "y2", (double) e_minicard->height - 1,
- NULL );
-
- gnome_canvas_item_set( e_minicard->rect,
- "x2", (double) e_minicard->width - 1.0,
- "y2", (double) e_minicard->height - 1.0,
- NULL );
- gnome_canvas_item_set( e_minicard->header_rect,
- "x2", (double) e_minicard->width - 3.0,
- NULL );
- gnome_canvas_item_set( e_minicard->header_text,
- "clip_width", (double) e_minicard->width - 12,
- NULL );
- for ( list = e_minicard->fields; list; list = g_list_next( list ) ) {
- gnome_canvas_item_set( GNOME_CANVAS_ITEM( list->data ),
- "width", (double) e_minicard->width - 4.0,
- NULL );
-
- if (old_height != e_minicard->height)
- gtk_signal_emit_by_name (GTK_OBJECT (e_minicard), "resize");
- }
- }
-}
-
-static void
-_resize( GtkObject *object, gpointer data )
-{
- _update_card(E_MINICARD(data));
-}
diff --git a/widgets/e-minicard/e-minicard.h b/widgets/e-minicard/e-minicard.h
deleted file mode 100644
index 3be80c1586..0000000000
--- a/widgets/e-minicard/e-minicard.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-minicard.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_MINICARD_H__
-#define __E_MINICARD_H__
-
-#include <gnome.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* EMinicard - A small card displaying information about a contact.
- *
- * The following arguments are available:
- *
- * name type read/write description
- * --------------------------------------------------------------------------------
- * width double RW width of the card
- * height double R height of the card
- * card ECard* RW Pointer to the ECard
- */
-
-#define E_MINICARD_TYPE (e_minicard_get_type ())
-#define E_MINICARD(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_TYPE, EMinicard))
-#define E_MINICARD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_TYPE, EMinicardClass))
-#define E_IS_MINICARD(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_TYPE))
-#define E_IS_MINICARD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_TYPE))
-
-
-typedef struct _EMinicard EMinicard;
-typedef struct _EMinicardClass EMinicardClass;
-typedef enum _EMinicardFocusType EMinicardFocusType;
-
-enum _EMinicardFocusType {
- E_MINICARD_FOCUS_TYPE_START,
- E_MINICARD_FOCUS_TYPE_END
-};
-
-struct _EMinicard
-{
- GnomeCanvasGroup parent;
-
- /* item specific fields */
- /* ECard *card; */
-
- GnomeCanvasItem *rect;
- GnomeCanvasItem *header_rect;
- GnomeCanvasItem *header_text;
- GList *fields; /* Of type GnomeCanvasItem. */
-
- gboolean has_focus;
-
- double width;
- double height;
-};
-
-struct _EMinicardClass
-{
- GnomeCanvasGroupClass parent_class;
-
- void (* resize) (EMinicard *minicard);
-};
-
-
-GtkType e_minicard_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_MINICARD_H__ */
diff --git a/widgets/e-minicard/e-reflow.c b/widgets/e-minicard/e-reflow.c
deleted file mode 100644
index c1022f8f78..0000000000
--- a/widgets/e-minicard/e-reflow.c
+++ /dev/null
@@ -1,787 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-reflow.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include <math.h>
-#include "e-reflow.h"
-#include "e-canvas-utils.h"
-static void e_reflow_init (EReflow *card);
-static void e_reflow_class_init (EReflowClass *klass);
-static void e_reflow_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
-static void e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static gboolean e_reflow_event (GnomeCanvasItem *item, GdkEvent *event);
-static void e_reflow_realize (GnomeCanvasItem *item);
-static void e_reflow_unrealize (GnomeCanvasItem *item);
-static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height);
-static void e_reflow_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags);
-static double e_reflow_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, GnomeCanvasItem **actual_item);
-
-static void _update_reflow ( EReflow *reflow );
-static void _resize( GtkObject *object, gpointer data );
-static void _queue_reflow(EReflow *e_reflow);
-
-#define E_REFLOW_DIVIDER_WIDTH 2
-#define E_REFLOW_BORDER_WIDTH 7
-#define E_REFLOW_FULL_GUTTER (E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH * 2)
-
-static GnomeCanvasGroupClass *parent_class = NULL;
-
-enum {
- E_REFLOW_RESIZE,
- E_REFLOW_LAST_SIGNAL
-};
-
-static guint e_reflow_signals[E_REFLOW_LAST_SIGNAL] = { 0 };
-
-/* The arguments we take */
-enum {
- ARG_0,
- ARG_MINIMUM_WIDTH,
- ARG_WIDTH,
- ARG_HEIGHT
-};
-
-GtkType
-e_reflow_get_type (void)
-{
- static GtkType reflow_type = 0;
-
- if (!reflow_type)
- {
- static const GtkTypeInfo reflow_info =
- {
- "EReflow",
- sizeof (EReflow),
- sizeof (EReflowClass),
- (GtkClassInitFunc) e_reflow_class_init,
- (GtkObjectInitFunc) e_reflow_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- reflow_type = gtk_type_unique (gnome_canvas_group_get_type (), &reflow_info);
- }
-
- return reflow_type;
-}
-
-static void
-e_reflow_class_init (EReflowClass *klass)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass*) klass;
- item_class = (GnomeCanvasItemClass *) klass;
-
- parent_class = gtk_type_class (gnome_canvas_group_get_type ());
-
- e_reflow_signals[E_REFLOW_RESIZE] =
- gtk_signal_new ("resize",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EReflowClass, resize),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, e_reflow_signals, E_REFLOW_LAST_SIGNAL);
-
- gtk_object_add_arg_type ("EReflow::minimum_width", GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE, ARG_MINIMUM_WIDTH);
- gtk_object_add_arg_type ("EReflow::width", GTK_TYPE_DOUBLE,
- GTK_ARG_READABLE, ARG_WIDTH);
- gtk_object_add_arg_type ("EReflow::height", GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE, ARG_HEIGHT);
-
- object_class->set_arg = e_reflow_set_arg;
- object_class->get_arg = e_reflow_get_arg;
- /* object_class->destroy = e_reflow_destroy; */
-
- /* GnomeCanvasItem method overrides */
- item_class->event = e_reflow_event;
- item_class->realize = e_reflow_realize;
- item_class->unrealize = e_reflow_unrealize;
- item_class->draw = e_reflow_draw;
- item_class->update = e_reflow_update;
- item_class->point = e_reflow_point;
-}
-
-static void
-e_reflow_init (EReflow *reflow)
-{
- /* reflow->card = NULL;*/
- reflow->items = NULL;
- reflow->columns = NULL;
- reflow->column_width = 150;
-
- reflow->minimum_width = 10;
- reflow->width = 10;
- reflow->height = 10;
- reflow->idle = 0;
-
- reflow->column_drag = FALSE;
-
- reflow->need_height_update = FALSE;
- reflow->need_column_resize = FALSE;
-
- reflow->default_cursor_shown = TRUE;
- reflow->arrow_cursor = NULL;
- reflow->default_cursor = NULL;
-}
-
-static void
-e_reflow_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EReflow *e_reflow;
-
- item = GNOME_CANVAS_ITEM (o);
- e_reflow = E_REFLOW (o);
-
- switch (arg_id){
- case ARG_HEIGHT:
- e_reflow->height = GTK_VALUE_DOUBLE (*arg);
- _queue_reflow(e_reflow);
- break;
- case ARG_MINIMUM_WIDTH:
- e_reflow->minimum_width = GTK_VALUE_DOUBLE (*arg);
- _queue_reflow(e_reflow);
- break;
- }
-}
-
-static void
-e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- EReflow *e_reflow;
-
- e_reflow = E_REFLOW (object);
-
- switch (arg_id) {
- case ARG_MINIMUM_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = e_reflow->minimum_width;
- break;
- case ARG_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = e_reflow->width;
- break;
- case ARG_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = e_reflow->height;
- break;
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-static void
-e_reflow_realize (GnomeCanvasItem *item)
-{
- EReflow *e_reflow;
- GnomeCanvasGroup *group;
- GList *list;
- GtkAdjustment *adjustment;
-
- e_reflow = E_REFLOW (item);
- group = GNOME_CANVAS_GROUP( item );
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize)
- (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item);
-
- e_reflow->arrow_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
- e_reflow->default_cursor = gdk_cursor_new (GDK_LEFT_PTR);
-
- for(list = e_reflow->items; list; list = g_list_next(list)) {
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM(list->data);
- gtk_signal_connect(GTK_OBJECT(item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_reflow);
- gnome_canvas_item_set(item,
- "width", (double) e_reflow->column_width,
- NULL);
- }
-
- _queue_reflow( e_reflow );
-
- adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- adjustment->step_increment = (e_reflow->column_width + E_REFLOW_FULL_GUTTER) / 2;
- adjustment->page_increment = adjustment->page_size - adjustment->step_increment;
- gtk_adjustment_changed(adjustment);
-
- if (!item->canvas->aa) {
- }
-}
-
-static void
-e_reflow_unrealize (GnomeCanvasItem *item)
-{
- EReflow *e_reflow;
-
- e_reflow = E_REFLOW (item);
-
- if (!item->canvas->aa)
- {
- }
-
- gdk_cursor_destroy (e_reflow->arrow_cursor);
- gdk_cursor_destroy (e_reflow->default_cursor);
-
- g_list_free (e_reflow->items);
- g_list_free (e_reflow->columns);
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize)
- (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item);
-}
-
-static gint
-e_reflow_pick_line (EReflow *e_reflow, double x)
-{
- x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- x /= e_reflow->column_width + E_REFLOW_FULL_GUTTER;
- return x;
-}
-
-static gboolean
-e_reflow_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EReflow *e_reflow;
-
- e_reflow = E_REFLOW (item);
-
- switch( event->type )
- {
- case GDK_KEY_PRESS:
- if (event->key.keyval == GDK_Tab ||
- event->key.keyval == GDK_KP_Tab ||
- event->key.keyval == GDK_ISO_Left_Tab) {
- GList *list;
- for (list = e_reflow->items; list; list = list->next) {
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data);
- gboolean has_focus;
- gtk_object_get(GTK_OBJECT(item),
- "has_focus", &has_focus,
- NULL);
- if (has_focus) {
- if (event->key.state & GDK_SHIFT_MASK)
- list = list->prev;
- else
- list = list->next;
- if (list) {
- item = GNOME_CANVAS_ITEM(list->data);
- gnome_canvas_item_set(item,
- "has_focus", TRUE,
- NULL);
- return 1;
- } else {
- return 0;
- }
- }
- }
- }
- break;
- case GDK_BUTTON_PRESS:
- switch(event->button.button)
- {
- case 1:
- {
- GdkEventButton *button = (GdkEventButton *) event;
- double n_x;
- n_x = button->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( button->y >= E_REFLOW_BORDER_WIDTH && button->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) {
- e_reflow->which_column_dragged = e_reflow_pick_line(e_reflow, button->x);
- e_reflow->start_x = e_reflow->which_column_dragged * (e_reflow->column_width + E_REFLOW_FULL_GUTTER) - E_REFLOW_DIVIDER_WIDTH / 2;
- e_reflow->temp_column_width = e_reflow->column_width;
- e_reflow->column_drag = TRUE;
-
- gnome_canvas_item_grab (item,
- GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
- e_reflow->arrow_cursor,
- button->time);
-
- e_reflow->previous_temp_column_width = -1;
- e_reflow->need_column_resize = TRUE;
- gnome_canvas_item_request_update(item);
- return TRUE;
- }
- }
- break;
- case 4:
- {
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- gdouble new_value = adjustment->value;
- new_value -= adjustment->step_increment;
- gtk_adjustment_set_value(adjustment, new_value);
- }
- break;
- case 5:
- {
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- gdouble new_value = adjustment->value;
- new_value += adjustment->step_increment;
- if ( new_value > adjustment->upper - adjustment->page_size )
- new_value = adjustment->upper - adjustment->page_size;
- gtk_adjustment_set_value(adjustment, new_value);
- }
- break;
- }
- break;
- case GDK_BUTTON_RELEASE:
- if (e_reflow->column_drag) {
- gdouble old_width = e_reflow->column_width;
- GdkEventButton *button = (GdkEventButton *) event;
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- e_reflow->temp_column_width = e_reflow->column_width +
- (button->x - e_reflow->start_x)/(e_reflow->which_column_dragged - e_reflow_pick_line(e_reflow, adjustment->value));
- if ( e_reflow->temp_column_width < 50 )
- e_reflow->temp_column_width = 50;
- e_reflow->column_drag = FALSE;
- if ( old_width != e_reflow->temp_column_width ) {
- gtk_adjustment_set_value(adjustment, adjustment->value + e_reflow_pick_line(e_reflow, adjustment->value) * (e_reflow->temp_column_width - e_reflow->column_width));
- e_reflow->column_width = e_reflow->temp_column_width;
- adjustment->step_increment = (e_reflow->column_width + E_REFLOW_FULL_GUTTER) / 2;
- adjustment->page_increment = adjustment->page_size - adjustment->step_increment;
- gtk_adjustment_changed(adjustment);
- _queue_reflow(e_reflow);
- } else {
- e_reflow->need_column_resize = TRUE;
- gnome_canvas_item_request_update(item);
- }
- gnome_canvas_item_ungrab (item, button->time);
- return TRUE;
- }
- break;
- case GDK_MOTION_NOTIFY:
- if (e_reflow->column_drag) {
- double old_width = e_reflow->temp_column_width;
- GdkEventMotion *motion = (GdkEventMotion *) event;
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- e_reflow->temp_column_width = e_reflow->column_width +
- (motion->x - e_reflow->start_x)/(e_reflow->which_column_dragged - e_reflow_pick_line(e_reflow, adjustment->value));
- if (e_reflow->temp_column_width < 50)
- e_reflow->temp_column_width = 50;
- if (old_width != e_reflow->temp_column_width) {
- e_reflow->need_column_resize = TRUE;
- gnome_canvas_item_request_update(item);
- }
- return TRUE;
- } else {
- GdkEventMotion *motion = (GdkEventMotion *) event;
- double n_x;
- n_x = motion->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( motion->y >= E_REFLOW_BORDER_WIDTH && motion->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) {
- if ( e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->arrow_cursor);
- e_reflow->default_cursor_shown = FALSE;
- }
- } else
- if ( ! e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->default_cursor);
- e_reflow->default_cursor_shown = TRUE;
- }
-
- }
- break;
- case GDK_ENTER_NOTIFY:
- if (!e_reflow->column_drag) {
- GdkEventCrossing *crossing = (GdkEventCrossing *) event;
- double n_x;
- n_x = crossing->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( crossing->y >= E_REFLOW_BORDER_WIDTH && crossing->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) {
- if ( e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->arrow_cursor);
- e_reflow->default_cursor_shown = FALSE;
- }
- }
- }
- break;
- case GDK_LEAVE_NOTIFY:
- if (!e_reflow->column_drag) {
- GdkEventCrossing *crossing = (GdkEventCrossing *) event;
- double n_x;
- n_x = crossing->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( !( crossing->y >= E_REFLOW_BORDER_WIDTH && crossing->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) ) {
- if ( ! e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->default_cursor);
- e_reflow->default_cursor_shown = TRUE;
- }
- }
- }
- break;
- default:
- break;
- }
-
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event)
- return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event);
- else
- return 0;
-}
-
-void
-e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item)
-{
- e_reflow->items = g_list_append(e_reflow->items, item);
- if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) {
- gtk_signal_connect(GTK_OBJECT(item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_reflow);
- gnome_canvas_item_set(item,
- "width", (double) e_reflow->column_width,
- NULL);
- _queue_reflow(e_reflow);
- }
-
-}
-
-static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height)
-{
- int x_rect, y_rect, width_rect, height_rect;
- gdouble running_width;
- EReflow *e_reflow = E_REFLOW(item);
- int i;
- double column_width;
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->draw)
- GNOME_CANVAS_ITEM_CLASS(parent_class)->draw (item, drawable, x, y, width, height);
- column_width = e_reflow->column_width;
- running_width = E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- x_rect = running_width;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- /* Compute first column to draw. */
- i = x;
- i /= column_width + E_REFLOW_FULL_GUTTER;
- running_width += i * (column_width + E_REFLOW_FULL_GUTTER);
-
- for ( ; i < e_reflow->column_count; i++) {
- if ( running_width > x + width )
- break;
- x_rect = running_width;
- gtk_paint_flat_box(GTK_WIDGET(item->canvas)->style,
- drawable,
- GTK_STATE_ACTIVE,
- GTK_SHADOW_NONE,
- NULL,
- GTK_WIDGET(item->canvas),
- "reflow",
- x_rect - x,
- y_rect - y,
- width_rect,
- height_rect);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- if (e_reflow->column_drag) {
- int start_line = e_reflow_pick_line(e_reflow,
- gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas))->value);
- i = x - start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width = start_line * (column_width + E_REFLOW_FULL_GUTTER);
- column_width = e_reflow->temp_column_width;
- running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER);
- i += start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- x_rect = running_width;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- /* Compute first column to draw. */
- i /= column_width + E_REFLOW_FULL_GUTTER;
- running_width += i * (column_width + E_REFLOW_FULL_GUTTER);
-
- for ( ; i < e_reflow->column_count; i++) {
- if ( running_width > x + width )
- break;
- x_rect = running_width;
- gdk_draw_rectangle(drawable,
- GTK_WIDGET(item->canvas)->style->fg_gc[GTK_STATE_NORMAL],
- TRUE,
- x_rect - x,
- y_rect - y,
- width_rect - 1,
- height_rect - 1);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- }
-}
-
-static void
-e_reflow_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags)
-{
- EReflow *e_reflow;
- double x0, x1, y0, y1;
-
- e_reflow = E_REFLOW (item);
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->update)
- GNOME_CANVAS_ITEM_CLASS(parent_class)->update (item, affine, clip_path, flags);
-
- x0 = item->x1;
- y0 = item->y1;
- x1 = item->x2;
- y1 = item->y2;
- if ( x1 < x0 + e_reflow->width )
- x1 = x0 + e_reflow->width;
- if ( y1 < y0 + e_reflow->height )
- y1 = y0 + e_reflow->height;
- item->x2 = x1;
- item->y2 = y1;
-
- if (e_reflow->need_height_update) {
- x0 = item->x1;
- y0 = item->y1;
- x1 = item->x2;
- y1 = item->y2;
- if ( x0 > 0 )
- x0 = 0;
- if ( y0 > 0 )
- y0 = 0;
- if ( x1 < E_REFLOW(item)->width )
- x1 = E_REFLOW(item)->width;
- if ( x1 < E_REFLOW(item)->height )
- x1 = E_REFLOW(item)->height;
-
- gnome_canvas_request_redraw(item->canvas, x0, y0, x1, y1);
- e_reflow->need_height_update = FALSE;
- } else if (e_reflow->need_column_resize) {
- int x_rect, y_rect, width_rect, height_rect;
- int start_line = e_reflow_pick_line(e_reflow,
- gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas))->value);
- gdouble running_width;
- int i;
- double column_width;
-
- if ( e_reflow->previous_temp_column_width != -1 ) {
- running_width = start_line * (e_reflow->column_width + E_REFLOW_FULL_GUTTER);
- column_width = e_reflow->previous_temp_column_width;
- running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- for ( i = 0; i < e_reflow->column_count; i++) {
- x_rect = running_width;
- gnome_canvas_request_redraw(item->canvas, x_rect, y_rect, x_rect + width_rect, y_rect + height_rect);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- }
-
- if ( e_reflow->temp_column_width != -1 ) {
- running_width = start_line * (e_reflow->column_width + E_REFLOW_FULL_GUTTER);
- column_width = e_reflow->temp_column_width;
- running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- for ( i = 0; i < e_reflow->column_count; i++) {
- x_rect = running_width;
- gnome_canvas_request_redraw(item->canvas, x_rect, y_rect, x_rect + width_rect, y_rect + height_rect);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- }
-
- e_reflow->previous_temp_column_width = e_reflow->temp_column_width;
- e_reflow->need_column_resize = FALSE;
- }
-}
-
-static double
-e_reflow_point (GnomeCanvasItem *item,
- double x, double y, int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- EReflow *e_reflow = E_REFLOW(item);
- double distance = 1;
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->point)
- distance = GNOME_CANVAS_ITEM_CLASS(parent_class)->point (item, x, y, cx, cy, actual_item);
- if (*actual_item)
- return 0;
-
- *actual_item = item;
- return 0;
-#if 0
- if (y >= E_REFLOW_BORDER_WIDTH && y <= e_reflow->height - E_REFLOW_BORDER_WIDTH) {
- float n_x;
- n_x = x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x, (e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if (n_x < E_REFLOW_FULL_GUTTER) {
- *actual_item = item;
- return 0;
- }
- }
- return distance;
-#endif
-}
-
-static void
-_reflow( EReflow *e_reflow )
-{
- gdouble running_height;
- GList *list;
- double item_height;
-
- if (e_reflow->columns) {
- g_list_free (e_reflow->columns);
- e_reflow->columns = NULL;
- }
-
- e_reflow->column_count = 0;
-
- if (e_reflow->items == NULL) {
- e_reflow->columns = NULL;
- e_reflow->column_count = 1;
- return;
- }
-
- list = e_reflow->items;
-
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
- running_height = E_REFLOW_BORDER_WIDTH + item_height + E_REFLOW_BORDER_WIDTH;
- e_reflow->columns = g_list_append (e_reflow->columns, list);
- e_reflow->column_count = 1;
-
- list = g_list_next(list);
-
- for ( ; list; list = g_list_next(list)) {
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
- if (running_height + item_height + E_REFLOW_BORDER_WIDTH > e_reflow->height) {
- running_height = E_REFLOW_BORDER_WIDTH + item_height + E_REFLOW_BORDER_WIDTH;
- e_reflow->columns = g_list_append (e_reflow->columns, list);
- e_reflow->column_count ++;
- } else {
- running_height += item_height + E_REFLOW_BORDER_WIDTH;
- }
- }
-}
-
-static void
-_update_reflow( EReflow *e_reflow )
-{
- if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) {
-
- gdouble old_width;
- gdouble running_width;
-
- _reflow (e_reflow);
-
- old_width = e_reflow->width;
-
- running_width = E_REFLOW_BORDER_WIDTH;
-
- if (e_reflow->items == NULL) {
- } else {
- GList *list;
- GList *next_column;
- gdouble item_height;
- gdouble running_height;
-
- running_height = E_REFLOW_BORDER_WIDTH;
-
- list = e_reflow->items;
- gtk_object_set (GTK_OBJECT(list->data),
- "width", e_reflow->column_width,
- NULL);
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
- e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data),
- (double) running_width,
- (double) running_height);
- running_height += item_height + E_REFLOW_BORDER_WIDTH;
- next_column = g_list_next(e_reflow->columns);
- list = g_list_next(list);
-
- for( ; list; list = g_list_next(list)) {
- gtk_object_set (GTK_OBJECT(list->data),
- "width", e_reflow->column_width,
- NULL);
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
-
- if (next_column && (next_column->data == list)) {
- next_column = g_list_next (next_column);
- running_height = E_REFLOW_BORDER_WIDTH;
- running_width += e_reflow->column_width + E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH;
- }
- e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data),
- (double) running_width,
- (double) running_height);
-
- running_height += item_height + E_REFLOW_BORDER_WIDTH;
- }
-
- }
- e_reflow->width = running_width + e_reflow->column_width + E_REFLOW_BORDER_WIDTH;
- if ( e_reflow->width < e_reflow->minimum_width )
- e_reflow->width = e_reflow->minimum_width;
- if (old_width != e_reflow->width)
- gtk_signal_emit_by_name (GTK_OBJECT (e_reflow), "resize");
- }
-}
-
-
-static gboolean
-_idle_reflow(gpointer data)
-{
- EReflow *e_reflow = E_REFLOW(data);
- _update_reflow(e_reflow);
- e_reflow->need_height_update = TRUE;
- gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(e_reflow));
- e_reflow->idle = 0;
- return FALSE;
-}
-
-static void
-_queue_reflow(EReflow *e_reflow)
-{
- if (e_reflow->idle == 0)
- e_reflow->idle = g_idle_add(_idle_reflow, e_reflow);
-}
-
-static void
-_resize( GtkObject *object, gpointer data )
-{
- _queue_reflow(E_REFLOW(data));
-}
diff --git a/widgets/e-minicard/e-reflow.h b/widgets/e-minicard/e-reflow.h
deleted file mode 100644
index 3a731474cb..0000000000
--- a/widgets/e-minicard/e-reflow.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-reflow.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_REFLOW_H__
-#define __E_REFLOW_H__
-
-#include <gnome.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* EReflow - A canvas item container.
- *
- * The following arguments are available:
- *
- * name type read/write description
- * --------------------------------------------------------------------------------
- * minimum_width double RW minimum width of the reflow. width >= minimum_width
- * width double R width of the reflow
- * height double RW height of the reflow
- */
-
-#define E_REFLOW_TYPE (e_reflow_get_type ())
-#define E_REFLOW(obj) (GTK_CHECK_CAST ((obj), E_REFLOW_TYPE, EReflow))
-#define E_REFLOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_REFLOW_TYPE, EReflowClass))
-#define E_IS_REFLOW(obj) (GTK_CHECK_TYPE ((obj), E_REFLOW_TYPE))
-#define E_IS_REFLOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_REFLOW_TYPE))
-
-
-typedef struct _EReflow EReflow;
-typedef struct _EReflowClass EReflowClass;
-
-struct _EReflow
-{
- GnomeCanvasGroup parent;
-
- /* item specific fields */
- /* EBook *book; */
-
- GList *items; /* Of type GnomeCanvasItem */
- GList *columns; /* Of type GList pointing to type GnomeCanvasItem (points into items) */
- gint column_count; /* Number of columnns */
-
- double minimum_width;
- double width;
- double height;
-
- double column_width;
-
- int idle;
-
- /* These are all for when the column is being dragged. */
- gboolean column_drag;
- gdouble start_x;
- gint which_column_dragged;
- double temp_column_width;
- double previous_temp_column_width;
-
- guint need_height_update : 1;
- guint need_column_resize : 1;
-
- guint default_cursor_shown : 1;
- GdkCursor *arrow_cursor;
- GdkCursor *default_cursor;
-};
-
-struct _EReflowClass
-{
- GnomeCanvasGroupClass parent_class;
-
- void (* resize) (EReflow *reflow);
-};
-
-/* To be added to a reflow, an item must have the arguments "x", "y",
- and "width" as Read/Write arguments and "height" as a Read Only
- argument. It must also have a "resize" signal. */
-void e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item);
-GtkType e_reflow_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_REFLOW_H__ */
diff --git a/widgets/e-minicard/test-minicard-label.c b/widgets/e-minicard/test-minicard-label.c
deleted file mode 100644
index 67c17a0ace..0000000000
--- a/widgets/e-minicard/test-minicard-label.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* test-minicard-label.c
- *
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * 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.
- */
-
-
-
-#include "config.h"
-
-#include <gnome.h>
-#include "e-minicard-label.h"
-
-/* This is a horrible thing to do, but it is just a test. */
-GnomeCanvasItem *label;
-GnomeCanvasItem *rect;
-
-static void destroy_callback(GtkWidget *app, gpointer data)
-{
- exit(0);
-}
-
-static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data)
-{
- gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height );
- gnome_canvas_item_set( label,
- "width", (double) allocation->width,
- "height", (double) allocation->height,
- NULL );
- gnome_canvas_item_set( rect,
- "x2", (double) allocation->width,
- "y2", (double) allocation->height,
- NULL );
-}
-
-static void about_callback( GtkWidget *widget, gpointer data )
-{
-
- const gchar *authors[] =
- {
- "Christopher James Lahey <clahey@umich.edu>",
- NULL
- };
-
- GtkWidget *about =
- gnome_about_new ( _( "Minicard Label Test" ), VERSION,
- _( "Copyright (C) 2000, Helix Code, Inc." ),
- authors,
- _( "This should test the minicard label canvas item" ),
- NULL);
- gtk_widget_show (about);
-}
-
-static void button_press_callback( GtkWidget *widget, gpointer data )
-{
- gnome_canvas_item_grab_focus( label );
-}
-
-int main( int argc, char *argv[] )
-{
- GtkWidget *app;
- GtkWidget *canvas;
-
- /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);*/
-
- gnome_init( "Minicard Label Test", VERSION, argc, argv);
- app = gnome_app_new("Minicard Label Test", NULL);
-
- canvas = gnome_canvas_new();
- rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) 100,
- "y2", (double) 100,
- "fill_color", "white",
- NULL );
- label = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- e_minicard_label_get_type(),
- "x", (double) 0,
- "y", (double) 0,
- "width", (double) 100,
- "height", (double) 100,
- "fieldname", "Full Name:",
- "field", "Christopher James Lahey",
- NULL );
- gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ),
- 0, 0,
- 100, 100 );
-
- gnome_app_set_contents( GNOME_APP( app ), canvas );
-
-
- /* Connect the signals */
- gtk_signal_connect( GTK_OBJECT( app ), "destroy",
- GTK_SIGNAL_FUNC( destroy_callback ),
- ( gpointer ) app );
-
- gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate",
- GTK_SIGNAL_FUNC( allocate_callback ),
- ( gpointer ) app );
-
- gtk_signal_connect( GTK_OBJECT( canvas ), "button_press_event",
- GTK_SIGNAL_FUNC( button_press_callback ),
- ( gpointer ) app );
-
- gtk_widget_show_all( app );
-
- gtk_main();
-
- /* Not reached. */
- return 0;
-}
diff --git a/widgets/e-minicard/test-minicard.c b/widgets/e-minicard/test-minicard.c
deleted file mode 100644
index 79077c4b2d..0000000000
--- a/widgets/e-minicard/test-minicard.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* test-minicard.c
- *
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * 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.
- */
-
-
-
-#include "config.h"
-
-#include <gnome.h>
-#include "e-minicard.h"
-
-/* This is a horrible thing to do, but it is just a test. */
-GnomeCanvasItem *card;
-GnomeCanvasItem *rect;
-
-static void destroy_callback(GtkWidget *app, gpointer data)
-{
- exit(0);
-}
-
-static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data)
-{
- gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height );
- gnome_canvas_item_set( card,
- "width", (double) allocation->width,
- NULL );
- gnome_canvas_item_set( rect,
- "x2", (double) allocation->width,
- "y2", (double) allocation->height,
- NULL );
-}
-
-static void about_callback( GtkWidget *widget, gpointer data )
-{
-
- const gchar *authors[] =
- {
- "Christopher James Lahey <clahey@umich.edu>",
- NULL
- };
-
- GtkWidget *about =
- gnome_about_new ( _( "Minicard Test" ), VERSION,
- _( "Copyright (C) 2000, Helix Code, Inc." ),
- authors,
- _( "This should test the minicard canvas item" ),
- NULL);
- gtk_widget_show (about);
-}
-
-int main( int argc, char *argv[] )
-{
- GtkWidget *app;
- GtkWidget *canvas;
- int i;
-
- /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);*/
-
- gnome_init( "Minicard Test", VERSION, argc, argv);
- app = gnome_app_new("Minicard Test", NULL);
-
- canvas = gnome_canvas_new();
- rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) 100,
- "y2", (double) 100,
- "fill_color", "white",
- NULL );
- for ( i = 0; i < 1; i++ )
- {
- card = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- e_minicard_get_type(),
- "x", (double) 0,
- "y", (double) 0,
- "width", (double) 100,
- NULL );
- }
- gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ),
- 0, 0,
- 100, 100 );
-
- gnome_app_set_contents( GNOME_APP( app ), canvas );
-
- /* Connect the signals */
- gtk_signal_connect( GTK_OBJECT( app ), "destroy",
- GTK_SIGNAL_FUNC( destroy_callback ),
- ( gpointer ) app );
-
- gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate",
- GTK_SIGNAL_FUNC( allocate_callback ),
- ( gpointer ) app );
-
- gtk_widget_show_all( app );
-
- gtk_main();
-
- /* Not reached. */
- return 0;
-}
diff --git a/widgets/e-minicard/test-reflow.c b/widgets/e-minicard/test-reflow.c
deleted file mode 100644
index 4533e0249d..0000000000
--- a/widgets/e-minicard/test-reflow.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* test-reflow.c
- *
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * 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.
- */
-
-
-
-#include "config.h"
-
-#include <gnome.h>
-#include "e-canvas.h"
-#include "e-reflow.h"
-#include "e-minicard.h"
-
-/* This is a horrible thing to do, but it is just a test. */
-GnomeCanvasItem *reflow;
-GnomeCanvasItem *rect;
-GtkAllocation last_alloc;
-
-static void destroy_callback(GtkWidget *app, gpointer data)
-{
- exit(0);
-}
-
-static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data)
-{
- double width;
- last_alloc = *allocation;
- gnome_canvas_item_set( reflow,
- "height", (double) allocation->height,
- NULL );
- gnome_canvas_item_set( reflow,
- "minimum_width", (double) allocation->width,
- NULL );
- gtk_object_get(GTK_OBJECT(reflow),
- "width", &width,
- NULL);
- width = MAX(width, allocation->width);
- gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, width, allocation->height );
- gnome_canvas_item_set( rect,
- "x2", (double) width,
- "y2", (double) allocation->height,
- NULL );
-}
-
-static void resize(GnomeCanvasItem *item, gpointer data)
-{
- double width;
- gtk_object_get(GTK_OBJECT(reflow),
- "width", &width,
- NULL);
- width = MAX(width, last_alloc.width);
- gnome_canvas_set_scroll_region(item->canvas , 0, 0, width, last_alloc.height );
- gnome_canvas_item_set( rect,
- "x2", (double) width,
- "y2", (double) last_alloc.height,
- NULL );
-}
-
-static void about_callback( GtkWidget *widget, gpointer data )
-{
-
- const gchar *authors[] =
- {
- "Christopher James Lahey <clahey@umich.edu>",
- NULL
- };
-
- GtkWidget *about =
- gnome_about_new ( _( "Reflow Test" ), VERSION,
- _( "Copyright (C) 2000, Helix Code, Inc." ),
- authors,
- _( "This should test the reflow canvas item" ),
- NULL);
- gtk_widget_show (about);
-}
-
-int main( int argc, char *argv[] )
-{
- GtkWidget *app;
- GtkWidget *canvas;
- GtkWidget *vbox;
- GtkWidget *scrollbar;
- int i;
-
- /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);*/
-
- gnome_init( "Reflow Test", VERSION, argc, argv);
- app = gnome_app_new("Reflow Test", NULL);
-
- vbox = gtk_vbox_new(FALSE, 0);
-
- canvas = e_canvas_new();
- rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) 100,
- "y2", (double) 100,
- "fill_color", "white",
- NULL );
- reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- e_reflow_get_type(),
- "x", (double) 0,
- "y", (double) 0,
- "height", (double) 100,
- "minimum_width", (double) 100,
- NULL );
- gtk_signal_connect( GTK_OBJECT( reflow ), "resize",
- GTK_SIGNAL_FUNC( resize ),
- ( gpointer ) app);
- for ( i = 0; i < 200; i++ )
- {
- GnomeCanvasItem *item;
- item = gnome_canvas_item_new( GNOME_CANVAS_GROUP(reflow),
- e_minicard_get_type(),
- NULL);
- e_reflow_add_item(E_REFLOW(reflow), item);
- }
- gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ),
- 0, 0,
- 100, 100 );
-
- gtk_box_pack_start(GTK_BOX(vbox), canvas, TRUE, TRUE, 0);
-
- scrollbar = gtk_hscrollbar_new(gtk_layout_get_hadjustment(GTK_LAYOUT(canvas)));
-
- gtk_box_pack_start(GTK_BOX(vbox), scrollbar, FALSE, FALSE, 0);
-
- gnome_app_set_contents( GNOME_APP( app ), vbox );
-
- /* Connect the signals */
- gtk_signal_connect( GTK_OBJECT( app ), "destroy",
- GTK_SIGNAL_FUNC( destroy_callback ),
- ( gpointer ) app );
-
- gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate",
- GTK_SIGNAL_FUNC( allocate_callback ),
- ( gpointer ) app );
-
- gtk_widget_show_all( app );
- gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE);
-
- gtk_main();
-
- /* Not reached. */
- return 0;
-}
diff --git a/widgets/e-reflow.c b/widgets/e-reflow.c
deleted file mode 100644
index c1022f8f78..0000000000
--- a/widgets/e-reflow.c
+++ /dev/null
@@ -1,787 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-reflow.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include <math.h>
-#include "e-reflow.h"
-#include "e-canvas-utils.h"
-static void e_reflow_init (EReflow *card);
-static void e_reflow_class_init (EReflowClass *klass);
-static void e_reflow_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
-static void e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static gboolean e_reflow_event (GnomeCanvasItem *item, GdkEvent *event);
-static void e_reflow_realize (GnomeCanvasItem *item);
-static void e_reflow_unrealize (GnomeCanvasItem *item);
-static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height);
-static void e_reflow_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags);
-static double e_reflow_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, GnomeCanvasItem **actual_item);
-
-static void _update_reflow ( EReflow *reflow );
-static void _resize( GtkObject *object, gpointer data );
-static void _queue_reflow(EReflow *e_reflow);
-
-#define E_REFLOW_DIVIDER_WIDTH 2
-#define E_REFLOW_BORDER_WIDTH 7
-#define E_REFLOW_FULL_GUTTER (E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH * 2)
-
-static GnomeCanvasGroupClass *parent_class = NULL;
-
-enum {
- E_REFLOW_RESIZE,
- E_REFLOW_LAST_SIGNAL
-};
-
-static guint e_reflow_signals[E_REFLOW_LAST_SIGNAL] = { 0 };
-
-/* The arguments we take */
-enum {
- ARG_0,
- ARG_MINIMUM_WIDTH,
- ARG_WIDTH,
- ARG_HEIGHT
-};
-
-GtkType
-e_reflow_get_type (void)
-{
- static GtkType reflow_type = 0;
-
- if (!reflow_type)
- {
- static const GtkTypeInfo reflow_info =
- {
- "EReflow",
- sizeof (EReflow),
- sizeof (EReflowClass),
- (GtkClassInitFunc) e_reflow_class_init,
- (GtkObjectInitFunc) e_reflow_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- reflow_type = gtk_type_unique (gnome_canvas_group_get_type (), &reflow_info);
- }
-
- return reflow_type;
-}
-
-static void
-e_reflow_class_init (EReflowClass *klass)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass*) klass;
- item_class = (GnomeCanvasItemClass *) klass;
-
- parent_class = gtk_type_class (gnome_canvas_group_get_type ());
-
- e_reflow_signals[E_REFLOW_RESIZE] =
- gtk_signal_new ("resize",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EReflowClass, resize),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, e_reflow_signals, E_REFLOW_LAST_SIGNAL);
-
- gtk_object_add_arg_type ("EReflow::minimum_width", GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE, ARG_MINIMUM_WIDTH);
- gtk_object_add_arg_type ("EReflow::width", GTK_TYPE_DOUBLE,
- GTK_ARG_READABLE, ARG_WIDTH);
- gtk_object_add_arg_type ("EReflow::height", GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE, ARG_HEIGHT);
-
- object_class->set_arg = e_reflow_set_arg;
- object_class->get_arg = e_reflow_get_arg;
- /* object_class->destroy = e_reflow_destroy; */
-
- /* GnomeCanvasItem method overrides */
- item_class->event = e_reflow_event;
- item_class->realize = e_reflow_realize;
- item_class->unrealize = e_reflow_unrealize;
- item_class->draw = e_reflow_draw;
- item_class->update = e_reflow_update;
- item_class->point = e_reflow_point;
-}
-
-static void
-e_reflow_init (EReflow *reflow)
-{
- /* reflow->card = NULL;*/
- reflow->items = NULL;
- reflow->columns = NULL;
- reflow->column_width = 150;
-
- reflow->minimum_width = 10;
- reflow->width = 10;
- reflow->height = 10;
- reflow->idle = 0;
-
- reflow->column_drag = FALSE;
-
- reflow->need_height_update = FALSE;
- reflow->need_column_resize = FALSE;
-
- reflow->default_cursor_shown = TRUE;
- reflow->arrow_cursor = NULL;
- reflow->default_cursor = NULL;
-}
-
-static void
-e_reflow_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EReflow *e_reflow;
-
- item = GNOME_CANVAS_ITEM (o);
- e_reflow = E_REFLOW (o);
-
- switch (arg_id){
- case ARG_HEIGHT:
- e_reflow->height = GTK_VALUE_DOUBLE (*arg);
- _queue_reflow(e_reflow);
- break;
- case ARG_MINIMUM_WIDTH:
- e_reflow->minimum_width = GTK_VALUE_DOUBLE (*arg);
- _queue_reflow(e_reflow);
- break;
- }
-}
-
-static void
-e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- EReflow *e_reflow;
-
- e_reflow = E_REFLOW (object);
-
- switch (arg_id) {
- case ARG_MINIMUM_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = e_reflow->minimum_width;
- break;
- case ARG_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = e_reflow->width;
- break;
- case ARG_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = e_reflow->height;
- break;
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-static void
-e_reflow_realize (GnomeCanvasItem *item)
-{
- EReflow *e_reflow;
- GnomeCanvasGroup *group;
- GList *list;
- GtkAdjustment *adjustment;
-
- e_reflow = E_REFLOW (item);
- group = GNOME_CANVAS_GROUP( item );
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize)
- (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item);
-
- e_reflow->arrow_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
- e_reflow->default_cursor = gdk_cursor_new (GDK_LEFT_PTR);
-
- for(list = e_reflow->items; list; list = g_list_next(list)) {
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM(list->data);
- gtk_signal_connect(GTK_OBJECT(item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_reflow);
- gnome_canvas_item_set(item,
- "width", (double) e_reflow->column_width,
- NULL);
- }
-
- _queue_reflow( e_reflow );
-
- adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- adjustment->step_increment = (e_reflow->column_width + E_REFLOW_FULL_GUTTER) / 2;
- adjustment->page_increment = adjustment->page_size - adjustment->step_increment;
- gtk_adjustment_changed(adjustment);
-
- if (!item->canvas->aa) {
- }
-}
-
-static void
-e_reflow_unrealize (GnomeCanvasItem *item)
-{
- EReflow *e_reflow;
-
- e_reflow = E_REFLOW (item);
-
- if (!item->canvas->aa)
- {
- }
-
- gdk_cursor_destroy (e_reflow->arrow_cursor);
- gdk_cursor_destroy (e_reflow->default_cursor);
-
- g_list_free (e_reflow->items);
- g_list_free (e_reflow->columns);
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize)
- (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item);
-}
-
-static gint
-e_reflow_pick_line (EReflow *e_reflow, double x)
-{
- x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- x /= e_reflow->column_width + E_REFLOW_FULL_GUTTER;
- return x;
-}
-
-static gboolean
-e_reflow_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EReflow *e_reflow;
-
- e_reflow = E_REFLOW (item);
-
- switch( event->type )
- {
- case GDK_KEY_PRESS:
- if (event->key.keyval == GDK_Tab ||
- event->key.keyval == GDK_KP_Tab ||
- event->key.keyval == GDK_ISO_Left_Tab) {
- GList *list;
- for (list = e_reflow->items; list; list = list->next) {
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data);
- gboolean has_focus;
- gtk_object_get(GTK_OBJECT(item),
- "has_focus", &has_focus,
- NULL);
- if (has_focus) {
- if (event->key.state & GDK_SHIFT_MASK)
- list = list->prev;
- else
- list = list->next;
- if (list) {
- item = GNOME_CANVAS_ITEM(list->data);
- gnome_canvas_item_set(item,
- "has_focus", TRUE,
- NULL);
- return 1;
- } else {
- return 0;
- }
- }
- }
- }
- break;
- case GDK_BUTTON_PRESS:
- switch(event->button.button)
- {
- case 1:
- {
- GdkEventButton *button = (GdkEventButton *) event;
- double n_x;
- n_x = button->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( button->y >= E_REFLOW_BORDER_WIDTH && button->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) {
- e_reflow->which_column_dragged = e_reflow_pick_line(e_reflow, button->x);
- e_reflow->start_x = e_reflow->which_column_dragged * (e_reflow->column_width + E_REFLOW_FULL_GUTTER) - E_REFLOW_DIVIDER_WIDTH / 2;
- e_reflow->temp_column_width = e_reflow->column_width;
- e_reflow->column_drag = TRUE;
-
- gnome_canvas_item_grab (item,
- GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
- e_reflow->arrow_cursor,
- button->time);
-
- e_reflow->previous_temp_column_width = -1;
- e_reflow->need_column_resize = TRUE;
- gnome_canvas_item_request_update(item);
- return TRUE;
- }
- }
- break;
- case 4:
- {
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- gdouble new_value = adjustment->value;
- new_value -= adjustment->step_increment;
- gtk_adjustment_set_value(adjustment, new_value);
- }
- break;
- case 5:
- {
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- gdouble new_value = adjustment->value;
- new_value += adjustment->step_increment;
- if ( new_value > adjustment->upper - adjustment->page_size )
- new_value = adjustment->upper - adjustment->page_size;
- gtk_adjustment_set_value(adjustment, new_value);
- }
- break;
- }
- break;
- case GDK_BUTTON_RELEASE:
- if (e_reflow->column_drag) {
- gdouble old_width = e_reflow->column_width;
- GdkEventButton *button = (GdkEventButton *) event;
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- e_reflow->temp_column_width = e_reflow->column_width +
- (button->x - e_reflow->start_x)/(e_reflow->which_column_dragged - e_reflow_pick_line(e_reflow, adjustment->value));
- if ( e_reflow->temp_column_width < 50 )
- e_reflow->temp_column_width = 50;
- e_reflow->column_drag = FALSE;
- if ( old_width != e_reflow->temp_column_width ) {
- gtk_adjustment_set_value(adjustment, adjustment->value + e_reflow_pick_line(e_reflow, adjustment->value) * (e_reflow->temp_column_width - e_reflow->column_width));
- e_reflow->column_width = e_reflow->temp_column_width;
- adjustment->step_increment = (e_reflow->column_width + E_REFLOW_FULL_GUTTER) / 2;
- adjustment->page_increment = adjustment->page_size - adjustment->step_increment;
- gtk_adjustment_changed(adjustment);
- _queue_reflow(e_reflow);
- } else {
- e_reflow->need_column_resize = TRUE;
- gnome_canvas_item_request_update(item);
- }
- gnome_canvas_item_ungrab (item, button->time);
- return TRUE;
- }
- break;
- case GDK_MOTION_NOTIFY:
- if (e_reflow->column_drag) {
- double old_width = e_reflow->temp_column_width;
- GdkEventMotion *motion = (GdkEventMotion *) event;
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- e_reflow->temp_column_width = e_reflow->column_width +
- (motion->x - e_reflow->start_x)/(e_reflow->which_column_dragged - e_reflow_pick_line(e_reflow, adjustment->value));
- if (e_reflow->temp_column_width < 50)
- e_reflow->temp_column_width = 50;
- if (old_width != e_reflow->temp_column_width) {
- e_reflow->need_column_resize = TRUE;
- gnome_canvas_item_request_update(item);
- }
- return TRUE;
- } else {
- GdkEventMotion *motion = (GdkEventMotion *) event;
- double n_x;
- n_x = motion->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( motion->y >= E_REFLOW_BORDER_WIDTH && motion->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) {
- if ( e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->arrow_cursor);
- e_reflow->default_cursor_shown = FALSE;
- }
- } else
- if ( ! e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->default_cursor);
- e_reflow->default_cursor_shown = TRUE;
- }
-
- }
- break;
- case GDK_ENTER_NOTIFY:
- if (!e_reflow->column_drag) {
- GdkEventCrossing *crossing = (GdkEventCrossing *) event;
- double n_x;
- n_x = crossing->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( crossing->y >= E_REFLOW_BORDER_WIDTH && crossing->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) {
- if ( e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->arrow_cursor);
- e_reflow->default_cursor_shown = FALSE;
- }
- }
- }
- break;
- case GDK_LEAVE_NOTIFY:
- if (!e_reflow->column_drag) {
- GdkEventCrossing *crossing = (GdkEventCrossing *) event;
- double n_x;
- n_x = crossing->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( !( crossing->y >= E_REFLOW_BORDER_WIDTH && crossing->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) ) {
- if ( ! e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->default_cursor);
- e_reflow->default_cursor_shown = TRUE;
- }
- }
- }
- break;
- default:
- break;
- }
-
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event)
- return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event);
- else
- return 0;
-}
-
-void
-e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item)
-{
- e_reflow->items = g_list_append(e_reflow->items, item);
- if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) {
- gtk_signal_connect(GTK_OBJECT(item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_reflow);
- gnome_canvas_item_set(item,
- "width", (double) e_reflow->column_width,
- NULL);
- _queue_reflow(e_reflow);
- }
-
-}
-
-static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height)
-{
- int x_rect, y_rect, width_rect, height_rect;
- gdouble running_width;
- EReflow *e_reflow = E_REFLOW(item);
- int i;
- double column_width;
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->draw)
- GNOME_CANVAS_ITEM_CLASS(parent_class)->draw (item, drawable, x, y, width, height);
- column_width = e_reflow->column_width;
- running_width = E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- x_rect = running_width;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- /* Compute first column to draw. */
- i = x;
- i /= column_width + E_REFLOW_FULL_GUTTER;
- running_width += i * (column_width + E_REFLOW_FULL_GUTTER);
-
- for ( ; i < e_reflow->column_count; i++) {
- if ( running_width > x + width )
- break;
- x_rect = running_width;
- gtk_paint_flat_box(GTK_WIDGET(item->canvas)->style,
- drawable,
- GTK_STATE_ACTIVE,
- GTK_SHADOW_NONE,
- NULL,
- GTK_WIDGET(item->canvas),
- "reflow",
- x_rect - x,
- y_rect - y,
- width_rect,
- height_rect);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- if (e_reflow->column_drag) {
- int start_line = e_reflow_pick_line(e_reflow,
- gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas))->value);
- i = x - start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width = start_line * (column_width + E_REFLOW_FULL_GUTTER);
- column_width = e_reflow->temp_column_width;
- running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER);
- i += start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- x_rect = running_width;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- /* Compute first column to draw. */
- i /= column_width + E_REFLOW_FULL_GUTTER;
- running_width += i * (column_width + E_REFLOW_FULL_GUTTER);
-
- for ( ; i < e_reflow->column_count; i++) {
- if ( running_width > x + width )
- break;
- x_rect = running_width;
- gdk_draw_rectangle(drawable,
- GTK_WIDGET(item->canvas)->style->fg_gc[GTK_STATE_NORMAL],
- TRUE,
- x_rect - x,
- y_rect - y,
- width_rect - 1,
- height_rect - 1);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- }
-}
-
-static void
-e_reflow_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags)
-{
- EReflow *e_reflow;
- double x0, x1, y0, y1;
-
- e_reflow = E_REFLOW (item);
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->update)
- GNOME_CANVAS_ITEM_CLASS(parent_class)->update (item, affine, clip_path, flags);
-
- x0 = item->x1;
- y0 = item->y1;
- x1 = item->x2;
- y1 = item->y2;
- if ( x1 < x0 + e_reflow->width )
- x1 = x0 + e_reflow->width;
- if ( y1 < y0 + e_reflow->height )
- y1 = y0 + e_reflow->height;
- item->x2 = x1;
- item->y2 = y1;
-
- if (e_reflow->need_height_update) {
- x0 = item->x1;
- y0 = item->y1;
- x1 = item->x2;
- y1 = item->y2;
- if ( x0 > 0 )
- x0 = 0;
- if ( y0 > 0 )
- y0 = 0;
- if ( x1 < E_REFLOW(item)->width )
- x1 = E_REFLOW(item)->width;
- if ( x1 < E_REFLOW(item)->height )
- x1 = E_REFLOW(item)->height;
-
- gnome_canvas_request_redraw(item->canvas, x0, y0, x1, y1);
- e_reflow->need_height_update = FALSE;
- } else if (e_reflow->need_column_resize) {
- int x_rect, y_rect, width_rect, height_rect;
- int start_line = e_reflow_pick_line(e_reflow,
- gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas))->value);
- gdouble running_width;
- int i;
- double column_width;
-
- if ( e_reflow->previous_temp_column_width != -1 ) {
- running_width = start_line * (e_reflow->column_width + E_REFLOW_FULL_GUTTER);
- column_width = e_reflow->previous_temp_column_width;
- running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- for ( i = 0; i < e_reflow->column_count; i++) {
- x_rect = running_width;
- gnome_canvas_request_redraw(item->canvas, x_rect, y_rect, x_rect + width_rect, y_rect + height_rect);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- }
-
- if ( e_reflow->temp_column_width != -1 ) {
- running_width = start_line * (e_reflow->column_width + E_REFLOW_FULL_GUTTER);
- column_width = e_reflow->temp_column_width;
- running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- for ( i = 0; i < e_reflow->column_count; i++) {
- x_rect = running_width;
- gnome_canvas_request_redraw(item->canvas, x_rect, y_rect, x_rect + width_rect, y_rect + height_rect);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- }
-
- e_reflow->previous_temp_column_width = e_reflow->temp_column_width;
- e_reflow->need_column_resize = FALSE;
- }
-}
-
-static double
-e_reflow_point (GnomeCanvasItem *item,
- double x, double y, int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- EReflow *e_reflow = E_REFLOW(item);
- double distance = 1;
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->point)
- distance = GNOME_CANVAS_ITEM_CLASS(parent_class)->point (item, x, y, cx, cy, actual_item);
- if (*actual_item)
- return 0;
-
- *actual_item = item;
- return 0;
-#if 0
- if (y >= E_REFLOW_BORDER_WIDTH && y <= e_reflow->height - E_REFLOW_BORDER_WIDTH) {
- float n_x;
- n_x = x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x, (e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if (n_x < E_REFLOW_FULL_GUTTER) {
- *actual_item = item;
- return 0;
- }
- }
- return distance;
-#endif
-}
-
-static void
-_reflow( EReflow *e_reflow )
-{
- gdouble running_height;
- GList *list;
- double item_height;
-
- if (e_reflow->columns) {
- g_list_free (e_reflow->columns);
- e_reflow->columns = NULL;
- }
-
- e_reflow->column_count = 0;
-
- if (e_reflow->items == NULL) {
- e_reflow->columns = NULL;
- e_reflow->column_count = 1;
- return;
- }
-
- list = e_reflow->items;
-
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
- running_height = E_REFLOW_BORDER_WIDTH + item_height + E_REFLOW_BORDER_WIDTH;
- e_reflow->columns = g_list_append (e_reflow->columns, list);
- e_reflow->column_count = 1;
-
- list = g_list_next(list);
-
- for ( ; list; list = g_list_next(list)) {
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
- if (running_height + item_height + E_REFLOW_BORDER_WIDTH > e_reflow->height) {
- running_height = E_REFLOW_BORDER_WIDTH + item_height + E_REFLOW_BORDER_WIDTH;
- e_reflow->columns = g_list_append (e_reflow->columns, list);
- e_reflow->column_count ++;
- } else {
- running_height += item_height + E_REFLOW_BORDER_WIDTH;
- }
- }
-}
-
-static void
-_update_reflow( EReflow *e_reflow )
-{
- if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) {
-
- gdouble old_width;
- gdouble running_width;
-
- _reflow (e_reflow);
-
- old_width = e_reflow->width;
-
- running_width = E_REFLOW_BORDER_WIDTH;
-
- if (e_reflow->items == NULL) {
- } else {
- GList *list;
- GList *next_column;
- gdouble item_height;
- gdouble running_height;
-
- running_height = E_REFLOW_BORDER_WIDTH;
-
- list = e_reflow->items;
- gtk_object_set (GTK_OBJECT(list->data),
- "width", e_reflow->column_width,
- NULL);
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
- e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data),
- (double) running_width,
- (double) running_height);
- running_height += item_height + E_REFLOW_BORDER_WIDTH;
- next_column = g_list_next(e_reflow->columns);
- list = g_list_next(list);
-
- for( ; list; list = g_list_next(list)) {
- gtk_object_set (GTK_OBJECT(list->data),
- "width", e_reflow->column_width,
- NULL);
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
-
- if (next_column && (next_column->data == list)) {
- next_column = g_list_next (next_column);
- running_height = E_REFLOW_BORDER_WIDTH;
- running_width += e_reflow->column_width + E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH;
- }
- e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data),
- (double) running_width,
- (double) running_height);
-
- running_height += item_height + E_REFLOW_BORDER_WIDTH;
- }
-
- }
- e_reflow->width = running_width + e_reflow->column_width + E_REFLOW_BORDER_WIDTH;
- if ( e_reflow->width < e_reflow->minimum_width )
- e_reflow->width = e_reflow->minimum_width;
- if (old_width != e_reflow->width)
- gtk_signal_emit_by_name (GTK_OBJECT (e_reflow), "resize");
- }
-}
-
-
-static gboolean
-_idle_reflow(gpointer data)
-{
- EReflow *e_reflow = E_REFLOW(data);
- _update_reflow(e_reflow);
- e_reflow->need_height_update = TRUE;
- gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(e_reflow));
- e_reflow->idle = 0;
- return FALSE;
-}
-
-static void
-_queue_reflow(EReflow *e_reflow)
-{
- if (e_reflow->idle == 0)
- e_reflow->idle = g_idle_add(_idle_reflow, e_reflow);
-}
-
-static void
-_resize( GtkObject *object, gpointer data )
-{
- _queue_reflow(E_REFLOW(data));
-}
diff --git a/widgets/e-reflow.h b/widgets/e-reflow.h
deleted file mode 100644
index 3a731474cb..0000000000
--- a/widgets/e-reflow.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-reflow.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_REFLOW_H__
-#define __E_REFLOW_H__
-
-#include <gnome.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* EReflow - A canvas item container.
- *
- * The following arguments are available:
- *
- * name type read/write description
- * --------------------------------------------------------------------------------
- * minimum_width double RW minimum width of the reflow. width >= minimum_width
- * width double R width of the reflow
- * height double RW height of the reflow
- */
-
-#define E_REFLOW_TYPE (e_reflow_get_type ())
-#define E_REFLOW(obj) (GTK_CHECK_CAST ((obj), E_REFLOW_TYPE, EReflow))
-#define E_REFLOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_REFLOW_TYPE, EReflowClass))
-#define E_IS_REFLOW(obj) (GTK_CHECK_TYPE ((obj), E_REFLOW_TYPE))
-#define E_IS_REFLOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_REFLOW_TYPE))
-
-
-typedef struct _EReflow EReflow;
-typedef struct _EReflowClass EReflowClass;
-
-struct _EReflow
-{
- GnomeCanvasGroup parent;
-
- /* item specific fields */
- /* EBook *book; */
-
- GList *items; /* Of type GnomeCanvasItem */
- GList *columns; /* Of type GList pointing to type GnomeCanvasItem (points into items) */
- gint column_count; /* Number of columnns */
-
- double minimum_width;
- double width;
- double height;
-
- double column_width;
-
- int idle;
-
- /* These are all for when the column is being dragged. */
- gboolean column_drag;
- gdouble start_x;
- gint which_column_dragged;
- double temp_column_width;
- double previous_temp_column_width;
-
- guint need_height_update : 1;
- guint need_column_resize : 1;
-
- guint default_cursor_shown : 1;
- GdkCursor *arrow_cursor;
- GdkCursor *default_cursor;
-};
-
-struct _EReflowClass
-{
- GnomeCanvasGroupClass parent_class;
-
- void (* resize) (EReflow *reflow);
-};
-
-/* To be added to a reflow, an item must have the arguments "x", "y",
- and "width" as Read/Write arguments and "height" as a Read Only
- argument. It must also have a "resize" signal. */
-void e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item);
-GtkType e_reflow_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_REFLOW_H__ */
diff --git a/widgets/e-reflow/e-reflow.c b/widgets/e-reflow/e-reflow.c
deleted file mode 100644
index c1022f8f78..0000000000
--- a/widgets/e-reflow/e-reflow.c
+++ /dev/null
@@ -1,787 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-reflow.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include <math.h>
-#include "e-reflow.h"
-#include "e-canvas-utils.h"
-static void e_reflow_init (EReflow *card);
-static void e_reflow_class_init (EReflowClass *klass);
-static void e_reflow_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
-static void e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static gboolean e_reflow_event (GnomeCanvasItem *item, GdkEvent *event);
-static void e_reflow_realize (GnomeCanvasItem *item);
-static void e_reflow_unrealize (GnomeCanvasItem *item);
-static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height);
-static void e_reflow_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags);
-static double e_reflow_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, GnomeCanvasItem **actual_item);
-
-static void _update_reflow ( EReflow *reflow );
-static void _resize( GtkObject *object, gpointer data );
-static void _queue_reflow(EReflow *e_reflow);
-
-#define E_REFLOW_DIVIDER_WIDTH 2
-#define E_REFLOW_BORDER_WIDTH 7
-#define E_REFLOW_FULL_GUTTER (E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH * 2)
-
-static GnomeCanvasGroupClass *parent_class = NULL;
-
-enum {
- E_REFLOW_RESIZE,
- E_REFLOW_LAST_SIGNAL
-};
-
-static guint e_reflow_signals[E_REFLOW_LAST_SIGNAL] = { 0 };
-
-/* The arguments we take */
-enum {
- ARG_0,
- ARG_MINIMUM_WIDTH,
- ARG_WIDTH,
- ARG_HEIGHT
-};
-
-GtkType
-e_reflow_get_type (void)
-{
- static GtkType reflow_type = 0;
-
- if (!reflow_type)
- {
- static const GtkTypeInfo reflow_info =
- {
- "EReflow",
- sizeof (EReflow),
- sizeof (EReflowClass),
- (GtkClassInitFunc) e_reflow_class_init,
- (GtkObjectInitFunc) e_reflow_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- reflow_type = gtk_type_unique (gnome_canvas_group_get_type (), &reflow_info);
- }
-
- return reflow_type;
-}
-
-static void
-e_reflow_class_init (EReflowClass *klass)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass*) klass;
- item_class = (GnomeCanvasItemClass *) klass;
-
- parent_class = gtk_type_class (gnome_canvas_group_get_type ());
-
- e_reflow_signals[E_REFLOW_RESIZE] =
- gtk_signal_new ("resize",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EReflowClass, resize),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, e_reflow_signals, E_REFLOW_LAST_SIGNAL);
-
- gtk_object_add_arg_type ("EReflow::minimum_width", GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE, ARG_MINIMUM_WIDTH);
- gtk_object_add_arg_type ("EReflow::width", GTK_TYPE_DOUBLE,
- GTK_ARG_READABLE, ARG_WIDTH);
- gtk_object_add_arg_type ("EReflow::height", GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE, ARG_HEIGHT);
-
- object_class->set_arg = e_reflow_set_arg;
- object_class->get_arg = e_reflow_get_arg;
- /* object_class->destroy = e_reflow_destroy; */
-
- /* GnomeCanvasItem method overrides */
- item_class->event = e_reflow_event;
- item_class->realize = e_reflow_realize;
- item_class->unrealize = e_reflow_unrealize;
- item_class->draw = e_reflow_draw;
- item_class->update = e_reflow_update;
- item_class->point = e_reflow_point;
-}
-
-static void
-e_reflow_init (EReflow *reflow)
-{
- /* reflow->card = NULL;*/
- reflow->items = NULL;
- reflow->columns = NULL;
- reflow->column_width = 150;
-
- reflow->minimum_width = 10;
- reflow->width = 10;
- reflow->height = 10;
- reflow->idle = 0;
-
- reflow->column_drag = FALSE;
-
- reflow->need_height_update = FALSE;
- reflow->need_column_resize = FALSE;
-
- reflow->default_cursor_shown = TRUE;
- reflow->arrow_cursor = NULL;
- reflow->default_cursor = NULL;
-}
-
-static void
-e_reflow_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EReflow *e_reflow;
-
- item = GNOME_CANVAS_ITEM (o);
- e_reflow = E_REFLOW (o);
-
- switch (arg_id){
- case ARG_HEIGHT:
- e_reflow->height = GTK_VALUE_DOUBLE (*arg);
- _queue_reflow(e_reflow);
- break;
- case ARG_MINIMUM_WIDTH:
- e_reflow->minimum_width = GTK_VALUE_DOUBLE (*arg);
- _queue_reflow(e_reflow);
- break;
- }
-}
-
-static void
-e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- EReflow *e_reflow;
-
- e_reflow = E_REFLOW (object);
-
- switch (arg_id) {
- case ARG_MINIMUM_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = e_reflow->minimum_width;
- break;
- case ARG_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = e_reflow->width;
- break;
- case ARG_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = e_reflow->height;
- break;
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-static void
-e_reflow_realize (GnomeCanvasItem *item)
-{
- EReflow *e_reflow;
- GnomeCanvasGroup *group;
- GList *list;
- GtkAdjustment *adjustment;
-
- e_reflow = E_REFLOW (item);
- group = GNOME_CANVAS_GROUP( item );
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize)
- (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item);
-
- e_reflow->arrow_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
- e_reflow->default_cursor = gdk_cursor_new (GDK_LEFT_PTR);
-
- for(list = e_reflow->items; list; list = g_list_next(list)) {
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM(list->data);
- gtk_signal_connect(GTK_OBJECT(item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_reflow);
- gnome_canvas_item_set(item,
- "width", (double) e_reflow->column_width,
- NULL);
- }
-
- _queue_reflow( e_reflow );
-
- adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- adjustment->step_increment = (e_reflow->column_width + E_REFLOW_FULL_GUTTER) / 2;
- adjustment->page_increment = adjustment->page_size - adjustment->step_increment;
- gtk_adjustment_changed(adjustment);
-
- if (!item->canvas->aa) {
- }
-}
-
-static void
-e_reflow_unrealize (GnomeCanvasItem *item)
-{
- EReflow *e_reflow;
-
- e_reflow = E_REFLOW (item);
-
- if (!item->canvas->aa)
- {
- }
-
- gdk_cursor_destroy (e_reflow->arrow_cursor);
- gdk_cursor_destroy (e_reflow->default_cursor);
-
- g_list_free (e_reflow->items);
- g_list_free (e_reflow->columns);
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize)
- (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item);
-}
-
-static gint
-e_reflow_pick_line (EReflow *e_reflow, double x)
-{
- x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- x /= e_reflow->column_width + E_REFLOW_FULL_GUTTER;
- return x;
-}
-
-static gboolean
-e_reflow_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EReflow *e_reflow;
-
- e_reflow = E_REFLOW (item);
-
- switch( event->type )
- {
- case GDK_KEY_PRESS:
- if (event->key.keyval == GDK_Tab ||
- event->key.keyval == GDK_KP_Tab ||
- event->key.keyval == GDK_ISO_Left_Tab) {
- GList *list;
- for (list = e_reflow->items; list; list = list->next) {
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data);
- gboolean has_focus;
- gtk_object_get(GTK_OBJECT(item),
- "has_focus", &has_focus,
- NULL);
- if (has_focus) {
- if (event->key.state & GDK_SHIFT_MASK)
- list = list->prev;
- else
- list = list->next;
- if (list) {
- item = GNOME_CANVAS_ITEM(list->data);
- gnome_canvas_item_set(item,
- "has_focus", TRUE,
- NULL);
- return 1;
- } else {
- return 0;
- }
- }
- }
- }
- break;
- case GDK_BUTTON_PRESS:
- switch(event->button.button)
- {
- case 1:
- {
- GdkEventButton *button = (GdkEventButton *) event;
- double n_x;
- n_x = button->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( button->y >= E_REFLOW_BORDER_WIDTH && button->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) {
- e_reflow->which_column_dragged = e_reflow_pick_line(e_reflow, button->x);
- e_reflow->start_x = e_reflow->which_column_dragged * (e_reflow->column_width + E_REFLOW_FULL_GUTTER) - E_REFLOW_DIVIDER_WIDTH / 2;
- e_reflow->temp_column_width = e_reflow->column_width;
- e_reflow->column_drag = TRUE;
-
- gnome_canvas_item_grab (item,
- GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
- e_reflow->arrow_cursor,
- button->time);
-
- e_reflow->previous_temp_column_width = -1;
- e_reflow->need_column_resize = TRUE;
- gnome_canvas_item_request_update(item);
- return TRUE;
- }
- }
- break;
- case 4:
- {
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- gdouble new_value = adjustment->value;
- new_value -= adjustment->step_increment;
- gtk_adjustment_set_value(adjustment, new_value);
- }
- break;
- case 5:
- {
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- gdouble new_value = adjustment->value;
- new_value += adjustment->step_increment;
- if ( new_value > adjustment->upper - adjustment->page_size )
- new_value = adjustment->upper - adjustment->page_size;
- gtk_adjustment_set_value(adjustment, new_value);
- }
- break;
- }
- break;
- case GDK_BUTTON_RELEASE:
- if (e_reflow->column_drag) {
- gdouble old_width = e_reflow->column_width;
- GdkEventButton *button = (GdkEventButton *) event;
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- e_reflow->temp_column_width = e_reflow->column_width +
- (button->x - e_reflow->start_x)/(e_reflow->which_column_dragged - e_reflow_pick_line(e_reflow, adjustment->value));
- if ( e_reflow->temp_column_width < 50 )
- e_reflow->temp_column_width = 50;
- e_reflow->column_drag = FALSE;
- if ( old_width != e_reflow->temp_column_width ) {
- gtk_adjustment_set_value(adjustment, adjustment->value + e_reflow_pick_line(e_reflow, adjustment->value) * (e_reflow->temp_column_width - e_reflow->column_width));
- e_reflow->column_width = e_reflow->temp_column_width;
- adjustment->step_increment = (e_reflow->column_width + E_REFLOW_FULL_GUTTER) / 2;
- adjustment->page_increment = adjustment->page_size - adjustment->step_increment;
- gtk_adjustment_changed(adjustment);
- _queue_reflow(e_reflow);
- } else {
- e_reflow->need_column_resize = TRUE;
- gnome_canvas_item_request_update(item);
- }
- gnome_canvas_item_ungrab (item, button->time);
- return TRUE;
- }
- break;
- case GDK_MOTION_NOTIFY:
- if (e_reflow->column_drag) {
- double old_width = e_reflow->temp_column_width;
- GdkEventMotion *motion = (GdkEventMotion *) event;
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- e_reflow->temp_column_width = e_reflow->column_width +
- (motion->x - e_reflow->start_x)/(e_reflow->which_column_dragged - e_reflow_pick_line(e_reflow, adjustment->value));
- if (e_reflow->temp_column_width < 50)
- e_reflow->temp_column_width = 50;
- if (old_width != e_reflow->temp_column_width) {
- e_reflow->need_column_resize = TRUE;
- gnome_canvas_item_request_update(item);
- }
- return TRUE;
- } else {
- GdkEventMotion *motion = (GdkEventMotion *) event;
- double n_x;
- n_x = motion->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( motion->y >= E_REFLOW_BORDER_WIDTH && motion->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) {
- if ( e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->arrow_cursor);
- e_reflow->default_cursor_shown = FALSE;
- }
- } else
- if ( ! e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->default_cursor);
- e_reflow->default_cursor_shown = TRUE;
- }
-
- }
- break;
- case GDK_ENTER_NOTIFY:
- if (!e_reflow->column_drag) {
- GdkEventCrossing *crossing = (GdkEventCrossing *) event;
- double n_x;
- n_x = crossing->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( crossing->y >= E_REFLOW_BORDER_WIDTH && crossing->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) {
- if ( e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->arrow_cursor);
- e_reflow->default_cursor_shown = FALSE;
- }
- }
- }
- break;
- case GDK_LEAVE_NOTIFY:
- if (!e_reflow->column_drag) {
- GdkEventCrossing *crossing = (GdkEventCrossing *) event;
- double n_x;
- n_x = crossing->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( !( crossing->y >= E_REFLOW_BORDER_WIDTH && crossing->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) ) {
- if ( ! e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->default_cursor);
- e_reflow->default_cursor_shown = TRUE;
- }
- }
- }
- break;
- default:
- break;
- }
-
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event)
- return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event);
- else
- return 0;
-}
-
-void
-e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item)
-{
- e_reflow->items = g_list_append(e_reflow->items, item);
- if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) {
- gtk_signal_connect(GTK_OBJECT(item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_reflow);
- gnome_canvas_item_set(item,
- "width", (double) e_reflow->column_width,
- NULL);
- _queue_reflow(e_reflow);
- }
-
-}
-
-static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height)
-{
- int x_rect, y_rect, width_rect, height_rect;
- gdouble running_width;
- EReflow *e_reflow = E_REFLOW(item);
- int i;
- double column_width;
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->draw)
- GNOME_CANVAS_ITEM_CLASS(parent_class)->draw (item, drawable, x, y, width, height);
- column_width = e_reflow->column_width;
- running_width = E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- x_rect = running_width;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- /* Compute first column to draw. */
- i = x;
- i /= column_width + E_REFLOW_FULL_GUTTER;
- running_width += i * (column_width + E_REFLOW_FULL_GUTTER);
-
- for ( ; i < e_reflow->column_count; i++) {
- if ( running_width > x + width )
- break;
- x_rect = running_width;
- gtk_paint_flat_box(GTK_WIDGET(item->canvas)->style,
- drawable,
- GTK_STATE_ACTIVE,
- GTK_SHADOW_NONE,
- NULL,
- GTK_WIDGET(item->canvas),
- "reflow",
- x_rect - x,
- y_rect - y,
- width_rect,
- height_rect);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- if (e_reflow->column_drag) {
- int start_line = e_reflow_pick_line(e_reflow,
- gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas))->value);
- i = x - start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width = start_line * (column_width + E_REFLOW_FULL_GUTTER);
- column_width = e_reflow->temp_column_width;
- running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER);
- i += start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- x_rect = running_width;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- /* Compute first column to draw. */
- i /= column_width + E_REFLOW_FULL_GUTTER;
- running_width += i * (column_width + E_REFLOW_FULL_GUTTER);
-
- for ( ; i < e_reflow->column_count; i++) {
- if ( running_width > x + width )
- break;
- x_rect = running_width;
- gdk_draw_rectangle(drawable,
- GTK_WIDGET(item->canvas)->style->fg_gc[GTK_STATE_NORMAL],
- TRUE,
- x_rect - x,
- y_rect - y,
- width_rect - 1,
- height_rect - 1);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- }
-}
-
-static void
-e_reflow_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags)
-{
- EReflow *e_reflow;
- double x0, x1, y0, y1;
-
- e_reflow = E_REFLOW (item);
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->update)
- GNOME_CANVAS_ITEM_CLASS(parent_class)->update (item, affine, clip_path, flags);
-
- x0 = item->x1;
- y0 = item->y1;
- x1 = item->x2;
- y1 = item->y2;
- if ( x1 < x0 + e_reflow->width )
- x1 = x0 + e_reflow->width;
- if ( y1 < y0 + e_reflow->height )
- y1 = y0 + e_reflow->height;
- item->x2 = x1;
- item->y2 = y1;
-
- if (e_reflow->need_height_update) {
- x0 = item->x1;
- y0 = item->y1;
- x1 = item->x2;
- y1 = item->y2;
- if ( x0 > 0 )
- x0 = 0;
- if ( y0 > 0 )
- y0 = 0;
- if ( x1 < E_REFLOW(item)->width )
- x1 = E_REFLOW(item)->width;
- if ( x1 < E_REFLOW(item)->height )
- x1 = E_REFLOW(item)->height;
-
- gnome_canvas_request_redraw(item->canvas, x0, y0, x1, y1);
- e_reflow->need_height_update = FALSE;
- } else if (e_reflow->need_column_resize) {
- int x_rect, y_rect, width_rect, height_rect;
- int start_line = e_reflow_pick_line(e_reflow,
- gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas))->value);
- gdouble running_width;
- int i;
- double column_width;
-
- if ( e_reflow->previous_temp_column_width != -1 ) {
- running_width = start_line * (e_reflow->column_width + E_REFLOW_FULL_GUTTER);
- column_width = e_reflow->previous_temp_column_width;
- running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- for ( i = 0; i < e_reflow->column_count; i++) {
- x_rect = running_width;
- gnome_canvas_request_redraw(item->canvas, x_rect, y_rect, x_rect + width_rect, y_rect + height_rect);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- }
-
- if ( e_reflow->temp_column_width != -1 ) {
- running_width = start_line * (e_reflow->column_width + E_REFLOW_FULL_GUTTER);
- column_width = e_reflow->temp_column_width;
- running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- for ( i = 0; i < e_reflow->column_count; i++) {
- x_rect = running_width;
- gnome_canvas_request_redraw(item->canvas, x_rect, y_rect, x_rect + width_rect, y_rect + height_rect);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- }
-
- e_reflow->previous_temp_column_width = e_reflow->temp_column_width;
- e_reflow->need_column_resize = FALSE;
- }
-}
-
-static double
-e_reflow_point (GnomeCanvasItem *item,
- double x, double y, int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- EReflow *e_reflow = E_REFLOW(item);
- double distance = 1;
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->point)
- distance = GNOME_CANVAS_ITEM_CLASS(parent_class)->point (item, x, y, cx, cy, actual_item);
- if (*actual_item)
- return 0;
-
- *actual_item = item;
- return 0;
-#if 0
- if (y >= E_REFLOW_BORDER_WIDTH && y <= e_reflow->height - E_REFLOW_BORDER_WIDTH) {
- float n_x;
- n_x = x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x, (e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if (n_x < E_REFLOW_FULL_GUTTER) {
- *actual_item = item;
- return 0;
- }
- }
- return distance;
-#endif
-}
-
-static void
-_reflow( EReflow *e_reflow )
-{
- gdouble running_height;
- GList *list;
- double item_height;
-
- if (e_reflow->columns) {
- g_list_free (e_reflow->columns);
- e_reflow->columns = NULL;
- }
-
- e_reflow->column_count = 0;
-
- if (e_reflow->items == NULL) {
- e_reflow->columns = NULL;
- e_reflow->column_count = 1;
- return;
- }
-
- list = e_reflow->items;
-
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
- running_height = E_REFLOW_BORDER_WIDTH + item_height + E_REFLOW_BORDER_WIDTH;
- e_reflow->columns = g_list_append (e_reflow->columns, list);
- e_reflow->column_count = 1;
-
- list = g_list_next(list);
-
- for ( ; list; list = g_list_next(list)) {
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
- if (running_height + item_height + E_REFLOW_BORDER_WIDTH > e_reflow->height) {
- running_height = E_REFLOW_BORDER_WIDTH + item_height + E_REFLOW_BORDER_WIDTH;
- e_reflow->columns = g_list_append (e_reflow->columns, list);
- e_reflow->column_count ++;
- } else {
- running_height += item_height + E_REFLOW_BORDER_WIDTH;
- }
- }
-}
-
-static void
-_update_reflow( EReflow *e_reflow )
-{
- if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) {
-
- gdouble old_width;
- gdouble running_width;
-
- _reflow (e_reflow);
-
- old_width = e_reflow->width;
-
- running_width = E_REFLOW_BORDER_WIDTH;
-
- if (e_reflow->items == NULL) {
- } else {
- GList *list;
- GList *next_column;
- gdouble item_height;
- gdouble running_height;
-
- running_height = E_REFLOW_BORDER_WIDTH;
-
- list = e_reflow->items;
- gtk_object_set (GTK_OBJECT(list->data),
- "width", e_reflow->column_width,
- NULL);
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
- e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data),
- (double) running_width,
- (double) running_height);
- running_height += item_height + E_REFLOW_BORDER_WIDTH;
- next_column = g_list_next(e_reflow->columns);
- list = g_list_next(list);
-
- for( ; list; list = g_list_next(list)) {
- gtk_object_set (GTK_OBJECT(list->data),
- "width", e_reflow->column_width,
- NULL);
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
-
- if (next_column && (next_column->data == list)) {
- next_column = g_list_next (next_column);
- running_height = E_REFLOW_BORDER_WIDTH;
- running_width += e_reflow->column_width + E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH;
- }
- e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data),
- (double) running_width,
- (double) running_height);
-
- running_height += item_height + E_REFLOW_BORDER_WIDTH;
- }
-
- }
- e_reflow->width = running_width + e_reflow->column_width + E_REFLOW_BORDER_WIDTH;
- if ( e_reflow->width < e_reflow->minimum_width )
- e_reflow->width = e_reflow->minimum_width;
- if (old_width != e_reflow->width)
- gtk_signal_emit_by_name (GTK_OBJECT (e_reflow), "resize");
- }
-}
-
-
-static gboolean
-_idle_reflow(gpointer data)
-{
- EReflow *e_reflow = E_REFLOW(data);
- _update_reflow(e_reflow);
- e_reflow->need_height_update = TRUE;
- gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(e_reflow));
- e_reflow->idle = 0;
- return FALSE;
-}
-
-static void
-_queue_reflow(EReflow *e_reflow)
-{
- if (e_reflow->idle == 0)
- e_reflow->idle = g_idle_add(_idle_reflow, e_reflow);
-}
-
-static void
-_resize( GtkObject *object, gpointer data )
-{
- _queue_reflow(E_REFLOW(data));
-}
diff --git a/widgets/e-reflow/e-reflow.h b/widgets/e-reflow/e-reflow.h
deleted file mode 100644
index 3a731474cb..0000000000
--- a/widgets/e-reflow/e-reflow.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-reflow.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_REFLOW_H__
-#define __E_REFLOW_H__
-
-#include <gnome.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* EReflow - A canvas item container.
- *
- * The following arguments are available:
- *
- * name type read/write description
- * --------------------------------------------------------------------------------
- * minimum_width double RW minimum width of the reflow. width >= minimum_width
- * width double R width of the reflow
- * height double RW height of the reflow
- */
-
-#define E_REFLOW_TYPE (e_reflow_get_type ())
-#define E_REFLOW(obj) (GTK_CHECK_CAST ((obj), E_REFLOW_TYPE, EReflow))
-#define E_REFLOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_REFLOW_TYPE, EReflowClass))
-#define E_IS_REFLOW(obj) (GTK_CHECK_TYPE ((obj), E_REFLOW_TYPE))
-#define E_IS_REFLOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_REFLOW_TYPE))
-
-
-typedef struct _EReflow EReflow;
-typedef struct _EReflowClass EReflowClass;
-
-struct _EReflow
-{
- GnomeCanvasGroup parent;
-
- /* item specific fields */
- /* EBook *book; */
-
- GList *items; /* Of type GnomeCanvasItem */
- GList *columns; /* Of type GList pointing to type GnomeCanvasItem (points into items) */
- gint column_count; /* Number of columnns */
-
- double minimum_width;
- double width;
- double height;
-
- double column_width;
-
- int idle;
-
- /* These are all for when the column is being dragged. */
- gboolean column_drag;
- gdouble start_x;
- gint which_column_dragged;
- double temp_column_width;
- double previous_temp_column_width;
-
- guint need_height_update : 1;
- guint need_column_resize : 1;
-
- guint default_cursor_shown : 1;
- GdkCursor *arrow_cursor;
- GdkCursor *default_cursor;
-};
-
-struct _EReflowClass
-{
- GnomeCanvasGroupClass parent_class;
-
- void (* resize) (EReflow *reflow);
-};
-
-/* To be added to a reflow, an item must have the arguments "x", "y",
- and "width" as Read/Write arguments and "height" as a Read Only
- argument. It must also have a "resize" signal. */
-void e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item);
-GtkType e_reflow_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_REFLOW_H__ */
diff --git a/widgets/e-table/.cvsignore b/widgets/e-table/.cvsignore
deleted file mode 100644
index 0963d457d9..0000000000
--- a/widgets/e-table/.cvsignore
+++ /dev/null
@@ -1,7 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-*.lo
-*.la
-table-test
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
deleted file mode 100644
index 58dc500e8d..0000000000
--- a/widgets/e-table/ChangeLog
+++ /dev/null
@@ -1,583 +0,0 @@
-2000-01-30 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-simple.c (e_table_simple_new): Add data field back in.
-
-1999-12-30 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-item.c (eti_attach_cell_views): New routine, creates the
- cell views.
- (eti_detach_cell_views): Detaches the cell_views from the
- ETableItem.
- (eti_realize_cell_views, eti_unrealize_cell_views): Simplified to
- just do realize/unrealize notification.
- (eti_add_table_model): Only attach the cells when we have both the
- table model and the header model.
-
- * e-cell.h (ECellClass): Added two new methods: new_view and
- kill_view which drive the view process (instead of putting that on
- realize/unrealize).
-
- * e-cell.c: Adapt the code to use the new scheme for view
- instantiation.
-
- * e-cell-text.c, e-cell-toggle.c: Adapted to the new class
- changes.
-
-1999-12-22 Miguel de Icaza <miguel@helixcode.com>
-
- * e-table-item.c (e_table_item_focus): grab focus here with the
- canvas method.
-
-1999-12-20 Miguel de Icaza <miguel@helixcode.com>
-
- * e-table-group.c (etg_update): Change the dimensions only if the
- child changes its own.
-
- * e-table-item.c (eti_table_model_changed): Emit new signal on
- table height change.
- (eti_class_init): Register new "height_change" signal.
-
-1999-12-19 Damon Chaplin <damon@karuna.freeserve.co.uk>
-
- * Makefile.am (SUBDIRS): created SUBDIRS with meeting-time-sel.
-
- * meeting-time-sel/Makefile.am:
- * meeting-time-sel/.cvsignore:
- * meeting-time-sel/e-meeting-time-sel.h:
- * meeting-time-sel/e-meeting-time-sel.c:
- * meeting-time-sel/e-meeting-time-sel-item.h:
- * meeting-time-sel/e-meeting-time-sel-item.c:
- * meeting-time-sel/e-meeting-time-sel-list-item.h:
- * meeting-time-sel/e-meeting-time-sel-list-item.c:
- * meeting-time-sel/e-meeting-time-sel-mail.xpm:
- * meeting-time-sel/e-meeting-time-sel-no-mail.xpm:
- * meeting-time-sel/test-meeting-time-sel.c: new files implementing
- the meeting time selector.
-
-1999-12-12 Miguel de Icaza <miguel@helixcode.com>
-
- * e-table-item.c (eti_class_init): X and Y arguments are now
- doubles (to make it consistent with the rest of the canvas x, y
- arguments).
-
- * e-table.c (e_table_create_leaf): Use new argument values here
-
- * test-*.c: Update to new argument types for x and y
-
- * e-table-group.c: New implementation as a canvas item used to
- group childs.
-
- * e-table-item.c (eti_update): Make this play nicely with groups.
- (eti_draw): ditto.
- (eti_request_region_redraw): ditto.
- (eti_item_region_redraw): New function.
-
- * e-table-subset.c (etss_proxy_model_row_changed): Added model
- proxying.
-
- * e-cell.h: Drop ETableModel from the ECell;
- (realize): Now takes an ETableModel
-
- * e-cell-checkbox.c: Adapted to new class
- changes;
- * e-cell-toggle.c: ditto
-
- * e-table-subset.c (etss_row_count): Fix this guy.
-
-1999-12-11 Miguel de Icaza <miguel@helixcode.com>
-
- * e-table-item.c (eti_unrealize_cell_views): Null the cell views.
- (eti_header_structure_changed): Only unrealize/realize if we were
- realized before.
-
- * e-table-header.c (e_table_header_add_column): Allow -1 as an
- insert position
-
-1999-12-11 Miguel de Icaza <miguel@helixcode.com>
-
- * e-table.c: Massive fixage.
-
- * test-table.c: Updates to test the mega widget.
-
-1999-12-10 Miguel de Icaza <miguel@helixcode.com>
-
- * e-table.c: New file, implements the mega widget.
-
-1999-12-09 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-header.c (e_table_header_col_diff): fix this routine.
-
-1999-12-04 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-header-item.c (ethi_event): Started drag and drop
- support.
-
- * e-table-item.c (eti_table_model_changed): The columns are
- controled by the Header, not by the TableModel.
-
- * e-table-header-item.c (ethi_draw): Fixed redraw logic to support
- arbitrary header positioning.
-
- * e-cell.h: Revamped e-cell interface. We now provide the model
- column and the view column to all methods (so that the methods can
- talk to the view and to the model at the same time).
-
- * e-table-item.c: Update to new API
- * e-cell-test.c: Update to new API
-
-1999-12-03 Miguel de Icaza <miguel@gnu.org>
-
- * e-cell.c (e_cell_class_init): Provide emtpy methods for
- enter_edit, and leave_edit.
-
- * e-table-item.c: Killed draw cell.
- (eti_draw): Perform column mapping here.
- (e_table_item_leave_edit): ditto.
- (e_table_item_enter_edit): ditto.
- (eti_event): ditto.
-
-1999-12-02 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-header.c (e_table_header_index): fixed api.
-
-1999-12-01 Miguel de Icaza <miguel@gnu.org>
-
- * test-cols.c (multi_cols_test): Update to simplified API.
- * test-check.c (check_test): ditto
- * test-table.c (table_browser_test): ditto
-
- * e-table-simple.c (e_table_simple_class_init): Kill column_name method.
-
- * e-table-model.h: Kill column_name method.
-
- * e-table-col.c (e_table_col_new): Instead of using a column name,
- use a column index.
-
- * e-cell-text.c (ect_draw): Keep track of the originally allocated
- piece of code.
-
- * e-table-header-item.c (ethi_unrealize): Removed change cursor
- from here.
-
- * e-cell-text.c (ect_draw): Memory leak fix.
-
- * table-test.c (main): Enhance the demo to load sample.table
- automatically, to get memprof working.
-
- * e-table-header.c (eth_do_remove): Take an argument: do -remove.
-
- * e-table-header.c (e_table_header_add_column): Sink ETableCol to
- own the object.
-
- * e-table-col.h: Made ETableCol a GtkObject to make reference
- counting the lifecycle method for these objects.
-
- * e-table-col.c (e_table_col_destroy): New API call.
-
- * e-table-subset.c (e_table_subset_get_toplevel): New API call.
-
-1999-11-30 Miguel de Icaza <miguel@gnu.org>
-
- * e-cell-checkbox.c (e_cell_checkbox_new): This one derives from
- e-cell-toggle.
-
- * check-emtpy.xpm, check-filled.xpm: new files.
-
- * e-cell-toggle.c (etog_draw): Paint in white.
- If we have transparency enabled, do the nice alpha computation.
-
- * test-table.c, test-cols.c: new files; They implement the split
- tests.
-
-1999-11-29 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-col.c (e_table_col_new): Set etc->resizeable.
-
- * e-table-header-item.c (ethi_event): Handle non-resizeables
- columns; Add support for minimum width.
-
- * e-cell-toggle.c, e-cell-toggle.h: New file. Implement a
- multi-state image toggle cell object.
-
- * e-cell-text.c (ect_leave_edit): Handle the case of us calling
- leave edit manually.
- (ect_stop_editing): Leave manually editing here.
- (ect_draw): Add one pixel to the border for left and right;
- Handle off-screen cursor (must be improved).
- (ect_edit_select_all): New function.
- (ect_event): Select all text on editing start
-
- * e-table-item.c (eti_event): Map mouse events and dispatch them.
- (eti_event): Add spreadsheet mode for editing; Enter editing only
- with visual characters;
- Leave editing mode when a different row has been selected.
- (eti_get_height): Fix the computation for this; Fix logic for the
- length_threshold.
-
- (eti_draw): Add borders on all sides of the box;
- Only draw focus if the cell is not being edited.
-
-1999-11-28 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-item.c (eti_draw): Focus inside, not outside.
- (eti_realize): Enhance our focus gc.
-
- * e-cell-text.c (ect_enter_edit, ect_leave_edit): New methods;
- They implement editing.
-
- * e-cell.h: new methods: enter_edit, leave_edit
-
- * e-table-model.h (set_value_at): make val argument const.
-
- * e-table-simple.c (simple_set_value_at): Make value argument const;
-
- * e-table-item.c (eti_set_arg): Add new mode: draw_focus;
-
-1999-11-27 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-item.c (eti_event): beginning of the keyboard navigation.
-
- * e-table-model.c (e_table_model_row_changed): new function.
- (e_table_model_cell_changed): new function.
- (e_table_model_class_init): New signals.
-
- * e-table-item.c (eti_request_region_redraw): x2, y2 offsets were
- wrong.
- (eti_select): Repaint selected region.
- (eti_request_region_redraw): Fix range.
- (eti_draw): Correct offset computation here.
- (e_table_item_class_init): New method: row_selection, handles the
- selection.
-
- Now it implement GTK_SELECTION_SINGLE and GTK_SELECTION_MULTIPLE.
-
- Focusing and selection should be correct now.
-
-1999-11-26 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-item.c (eti_realize): Compute height using the ecell
- methods here.
- (eti_get_height): new method to compute dimensions.
-
- * e-cursors.c: use a different cursor.
-
- * e-table-model.h: kill height and row_height methods.
-
- * e-cell.c (ec_height): New method.
-
- * e-cell-text.c (ect_realize): Load the font from the canvas.
- (ect_draw): New color setup.
- Center in the row.
- (ect_height): Implement new method.
-
-1999-11-26 Michael Meeks <mmeeks@gnu.org>
-
- * ROADMAP.e-table: small spelling/typo fixes.
-
-1999-11-25 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-item.c (eti_event): Work on mouse-button event
- propagation to cells.
-
- * e-cell-text.c (ect_draw): Use CellViews now.
-
- * e-table-item.c (eti_realize_cell_views): New routine: Realizes
- the cell views
- (eti_unrealize_cell_views): New routine: unrealizes the cell views.
-
- * e-table-item.h: Move cell_views array here.
-
- * table-test.c (value_at): Fix return value.
- (main): use new invocation method.
-
- * e-table-header-item.c (ethi_realize): Realize cells.
-
- * e-table-item.c (eti_header_dim_changed): redraw before and after.
-
- * e-table-header-item.c (ethi_event): Add continuous resizing.
-
-1999-11-24 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-subset.h, e-table-subset.c: New files, used to implement
- subset tables.
-
- * e-table-sorted.h, e-table-sorted.c: Now they derive from
- e-table-subset.
-
- * e-cell.c, e-cell.h: realize method now return per view instance
- data.
-
-1999-11-20 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-item.c (eti_draw): WOOOOHOOOOOoO! It took me quite a
- while to figure this one out. Fixed.
-
- * e-table-header-item.c (ethi_set_arg): Compute width, keep track
- of it.
- (ethi_add_table_header): Monitor changes to the Header model;
- Queue updates.
- (ethi_draw): Fix the redraw logic here.
-
- * table-test.c (main): Change the sample code, so we can better
- debug this.
-
- * e-table-item.c (eti_header_structure_changed): Keep track of
- width;
- (eti_header_dim_changed): ditto.
- (eti_draw): Many redraw fixes.
-
-1999-11-19 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-item.c (eti_realize): Hook up; Load gcs.
- (eti_unrealize): Hook up.
-
- * e-table-sorted.c: Finished implementing.
-
-1999-11-18 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-model.c (e_table_model_class_init): Add model_changed
- signal here.
-
- * e-table-item.c, e-table-item.h: New files. They implement the
- view of the ETableModel as Canvas Items.
-
- * e-table-header-item.c (ethi_set_arg): Ref header here.
- (ethi_destroy): Unref it here.
-
-1999-11-17 Ettore Perazzoli <ettore@gnu.org>
-
- * e-msg-composer-address-dialog.c: Moved to `$(srcdir)/composer'.
- * e-msg-composer-address-dialog.h: Likewise.
- * e-msg-composer-address-entry.c: Likewise.
- * e-msg-composer-address-entry.h: Likewise.
- * e-msg-composer-attachment-bar.c: Likewise.
- * e-msg-composer-attachment-bar.h: Likewise.
- * e-msg-composer-attachment.c: Likewise.
- * e-msg-composer-attachment.h: Likewise.
- * e-msg-composer-hdrs.c: Likewise.
- * e-msg-composer-hdrs.h: Likewise.
- * e-msg-composer.c: Likewise.
- * e-msg-composer.h: Likewise.
- * e-msg-composer-address-dialog.glade: Likewise.
- * e-msg-composer-attachment.glade: Likewise.
- * e-msg-composer.glade: Likewise.
- * Makefile.am: Updated accordingly.
-
-Nov 14 1999 Elliot Lee
- * Makefile.am: It's libevolutionwidgets.la, not .a
-
-1999-11-14 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-header-item.c (is_pointer_on_division): Add resizing
- capabilities.
-
- * e-table-sorted.c: Finish implementation.
-
-1999-11-13 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-sorted.c: Implement e-table-sorted object.
-
-1999-11-12 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-header-item.c: Make the thing configurable.
-
- * e-table-header-item.h: Add font field, location, height.
-
-1999-11-12 Ettore Perazzoli <ettore@gnu.org>
-
- * e-msg-composer-hdrs.c: New member `tooltips' in `struct
- _EMsgComposerHdrsPrivate'.
- (init): Initialize it.
- (destroy): New function.
- (class_init): Install it as the `destroy' GtkObject method.
- (add_header): New parameters `tip', `tip_private'. Setup a
- tooltip for the entry with them.
- (setup_headers): Updated accordingly.
-
-1999-11-11 Miguel de Icaza <miguel@gnu.org>
-
- * e-table-header.c (e_table_header_add_column): Update offsets.
- (eth_update_offsets): New routine.
-
- * e-table-col.h, e-table-col.c: New files.
-
- * e-table-header.h (e_table_header_get_selected_indexes):
- Pretify.
-
- * table-test.c (main): New file; used for testing ETable package.
-
- * e-table-simple.h: Fix type.
-
-1999-11-12 Ettore Perazzoli <ettore@gnu.org>
-
- * e-msg-composer-address-dialog.glade: Cosmetical changes.
-
- * e-msg-composer-attachment-bar.c (size_to_string): New helper
- function.
- (update): Put the size in the icon's label using this function.
- (ICON_SEPARATORS): Remove '.' to avoid wrapping of the size string
- on the decimal dot. But gnome-libs is broken and this has no real
- effect! :-(
- (e_msg_composer_attachment_bar_new): No longer make text editable.
- Use the `GTK_SELECTION_MULTIPLE' selection mode.
- (remove_selected): No longer assume only one attachment is
- selected.
-
- * e-msg-composer-attachment.c: #include <sys/stat.h>
- (init): Initialize all the members.
- (e_msg_composer_attachment_new): Set size using `stat()'.
-
- * e-msg-composer-attachment.h: New member `size' in `struct
- _EMsgComposerAttachment'.
-
- * e-msg-composer.c (setup_signals): Connect `address_dialog_cb' to
- the "show_address_dialog" signal of the header widget.
-
- * e-msg-composer-hdrs.c (add_address_header): Renamed to
- `add_header'. New parameter `addrbook_button': if true, use a
- button instead of a label and make it trigger an
- "show_address_dialog" signal.
- (address_button_clicked_cb): Signal handler to handle this on a
- "clicked" signal from the button.
- (setup_headers): Updated accordingly. Also, make "Subject" the
- last item. (This makes it look more like Outlook and friends.)
-
- * e-msg-composer-hdrs.c: New signal "show_address_dialog".
- * e-msg-composer-hdrs.h: Updated accordingly.
-
- * e-msg-composer-hdrs.c (add_address_header): Reduce padding
- considerably.
-
- * e-msg-composer.c (e_msg_composer_construct): Do not use any
- padding in the main vbox.
-
- * Makefile.am: Moved the `e-table*' sources to `EXTRA_DIST'.
- Compile as a shared library.
-
-1999-11-08 Ettore Perazzoli <ettore@gnu.org>
-
- * e-msg-composer-address-dialog.c: Implemented cut & paste for the
- recipient lists.
- (init): Initialize `cut_buffer'.
- (destroy): Free it.
- (recipient_clist_selection_get_cb): New function.
- (recipient_clist_selection_received_cb): New function.
- (recipient_clist_selection_clear_event_cb): New function.
- (setup_recipient_list_signals): Install them as signal handlers
- for "selection_get", "selection_received" and
- "selection_clear_event" respectively.
- (copy_recipient_cb): New function implementing the "copy"
- operation.
- (cut_recipient_cb): New function implementing the "cut" operation.
- (paste_recipient_cb): New function implementing the "paste"
- operation.
-
- * e-msg-composer-address-dialog.h: New member `cut_buffer' in
- `struct _EMsgComposerAddressDialog'.
-
-1999-11-07 Ettore Perazzoli <ettore@gnu.org>
-
- * e-msg-composer-address-dialog.c: New context menu
- `recipient_list_popup_info' for the recipient CLists.
- (recipient_clist_button_press_cb): New function.
- (setup_signals): Install it as the "button_press_event" signal
- handler for popping up the CList context menu.
-
- * e-msg-composer.c (free_string_list): New helper function.
- (setup_address_dialog): Setup the initial values in the address
- dialog according to the ones in the header widget.
-
- * e-msg-composer-hdrs.c (e_msg_composer_hdrs_get_to): New function.
- (e_msg_composer_hdrs_get_cc): New function.
- (e_msg_composer_hdrs_get_bcc): New function.
-
- * e-msg-composer.c (setup_address_dialog): New helper function.
- (address_dialog_cb): Use it.
-
- * e-msg-composer-address-dialog.c (add_address): Do not set the
- row data anymore. Instead, put the full address description
- (i.e. complete with the email address, not just the full name) in
- the CList.
- (add_address): Do nothing if no item is selected in the address
- CList.
- (get_list): Get the address list from the CList without passing
- through the address CList.
- (set_list): New helper function.
- (e_msg_composer_address_dialog_set_to_list): New function.
- (e_msg_composer_address_dialog_set_cc_list): New function.
- (e_msg_composer_address_dialog_set_bcc_list): New function.
-
- * e-msg-composer.c (address_dialog_apply_cb): Apply values from
- the address dialog into the composer.
-
- * e-msg-composer-hdrs.c (e_msg_composer_hdrs_set_to): New function.
- (e_msg_composer_hdrs_set_cc): New function.
- (e_msg_composer_hdrs_set_bcc): New function.
-
- * e-msg-composer-address-entry.c
- (e_msg_composer_address_entry_set_list): New function.
-
- * e-msg-composer-address-dialog.c (apply): New helper function.
- (clicked): New function, `clicked' method for the `GnomeDialog'
- class.
- (class_init): Install it.
-
-1999-11-06 Ettore Perazzoli <ettore@gnu.org>
-
- * e-msg-composer-attachment-bar.c (destroy): Call the destroy
- method of the parent class.
-
- * e-msg-composer.c: #include "e-msg-composer-address-dialog.h".
- (address_dialog_cb): New callback to start the address dialog.
- (setup_signals): Connect it to the appropriate button/menu item.
- (init): Initialize the new `address_dialog' member to NULL.
- (destroy): Destroy the `address_dialog' if not NULL.
-
- * e-msg-composer.h: New member `address_dialog' in `struct
- _EMsgComposer'.
-
- * e-msg-composer.glade: Added button to activate the address
- composition dialog.
-
- * e-msg-composer-address-dialog.h, e-msg-composer-address-dialog.c:
- New files implementing the address composition dialog for Evolution.
-
- * e-msg-composer-address-dialog.glade: New file.
-
- * e-msg-composer-attachment.c: `signals' made static.
-
-1999-11-05 Ettore Perazzoli <ettore@gnu.org>
-
- * Makefile.am: Compile the new files in a `libevolutionwidgets'
- library.
- (CPPFLAGS): #define `E_GUIDIR'.
-
- * e-msg-composer.c, e-msg-composer.h: New files implementing an
- initial version of the Evolution message composer widget.
-
- * e-msg-composer-address-entry.c, e-msg-composer-address-entry.h:
- New files implementing a GtkEntry customized for entering email
- address lists.
-
- * e-msg-composer-attachment-bar.c, e-msg-composer-attachment-bar.h:
- New files implementing a widget for editing mail attachments.
-
- * e-msg-composer-attachment.c, e-msg-composer-attachment.h: New
- files implementing file attachment objects for the message
- composer.
-
- * e-msg-composer-hdrs.c, e-msg-composer-hdrs.h: New files
- implementing a widget for editing of email message headers.
-
- * e-msg-composer-attachment.glade: New file.
- * e-msg-composer.glade: New file.
-
-1999-10-31 Miguel de Icaza <miguel@gnu.org>
-
- * widgets/e-table-column.c, e-table-column.h: New file, implements the
- e-table-column object.
-
- * widget/e-table-model.h, e-table-model.c, e-table-simple.c,
- e-table-simple.h: New files. Implements the column model and
- a simple table wrapper.
-
diff --git a/widgets/e-table/LICENSE b/widgets/e-table/LICENSE
deleted file mode 100644
index b1f6ae08a4..0000000000
--- a/widgets/e-table/LICENSE
+++ /dev/null
@@ -1 +0,0 @@
-This code is released under the terms of the GNU GPL.
diff --git a/widgets/e-table/Makefile.am b/widgets/e-table/Makefile.am
deleted file mode 100644
index 3d972991f4..0000000000
--- a/widgets/e-table/Makefile.am
+++ /dev/null
@@ -1,60 +0,0 @@
-INCLUDES = \
- $(GNOME_INCLUDEDIR) \
- -I$(top_srcdir)/e-util \
- -I$(top_srcdir)
-
-noinst_LIBRARIES = \
- libetable.a
-
-libetable_a_SOURCES = \
- e-cell.c \
- e-cell.h \
- e-cell-checkbox.c \
- e-cell-checkbox.h \
- e-cell-text.c \
- e-cell-text.h \
- e-cell-toggle.c \
- e-cell-toggle.h \
- e-table.c \
- e-table.h \
- e-table-col.c \
- e-table-col.h \
- e-table-group.c \
- e-table-group.h \
- e-table-header.c \
- e-table-header.h \
- e-table-header-item.c \
- e-table-header-item.h \
- e-table-item.c \
- e-table-item.h \
- e-table-model.c \
- e-table-model.h \
- e-table-simple.c \
- e-table-simple.h \
- e-table-sorted.c \
- e-table-sorted.h \
- e-table-subset.c \
- e-table-subset.h
-
-noinst_PROGRAMS = \
- table-test
-
-table_test_SOURCES = \
- test-table.c \
- test-check.c \
- test-cols.c \
- table-test.c
-
-table_test_LDADD = \
- $(EXTRA_GNOME_LIBS) \
- libetable.a \
- $(top_builddir)/e-util/libeutil.a
-
-table_test_LDFLAGS = `gnome-config --libs gdk_pixbuf`
-
-EXTRA_DIST = \
- sample.table \
- add-col.xpm \
- check-empty.xpm \
- check-filled.xpm \
- remove-col.xpm
diff --git a/widgets/e-table/ROADMAP.e-table b/widgets/e-table/ROADMAP.e-table
deleted file mode 100644
index 4edacced86..0000000000
--- a/widgets/e-table/ROADMAP.e-table
+++ /dev/null
@@ -1,113 +0,0 @@
-
-The E-Table package implements an editable table that provides
-user-defined rendering, user-defined editing, sorting and grouping of
-the objects displayed.
-
-It is inspired by Java's Swing JTable object. There are models for
-the actual table contents and for the table headers; they are the
-actual repository of information.
-
-The objects are rendered by various view objects. In the current code
-base, we use we use GnomeCanvasItems to do the rendering. One for
-each table and one for the headers.
-
-* The main widget
-
-e-table.c, e-table.h:
-
- Implements a full widget. Uses various components described
- below. Handles column display as well as grouping/nesting
-
-* The Models
-
-All of them are GtkObjects.
-
-e-table-model.h, e-table-model.c:
-
- These implement the abstract E-Table-Model class. You
- can derive this object to create your own data repository.
-
- These emits signals to notify the views about selection, and
- changes in the model.
-
-e-table-simple.h, e-table-simple.c:
-
- A simple implementation of e-table-model that uses callback
- routines (you provide the callbacks). For lazy people, like
- me.
-
-e-cell.c, e-cell.h:
-
- These are actually mis-named. Objects of type e-cell know
- about rendering a single cell, and these are attached to the
- e-table-cols (described next).
-
- The user provides the various rendering modes as e-cells (they
- are actually column-rendering repositories).
-
- This is just an abstract class. I will provide various
- e-cells: a text cell, a checkbox cell, an image cell, and
- perhaps an n-state image cell (one that switches the image when
- the cell is clicked).
-
-e-table-col.h, e-table-col.c:
-
- Describes a single column (the size, the string displayed, the
- rendering function for each row and comparison function for
- this field).
-
-
-* The Views
-
-e-table-header.h, e-table-header.c:
-
- These implement the ETableHeaderItem canvas item. This item is
- used both to control the columns displayed as well as displaying them.
-
- They describe what columns are shown in the screen and in
- which order.
-
- These emit signals: column-size-changed and structure-changed
- (if a column is added/removed)
-
-e-table-item.c, e-table-item.h
-
- This is a canvas item that renders the contents of a
- ETableModel into the screen.
-
-e-table-header-item.c, e-table-header-item.h
-
- This canvas item renders the ETableHeader headings.
-
-e-cell-text.c, e-cell-text.h
-
- Not really a view, but actually a derivative of e-cell that
- implements text display: supports justification and font
- setting. Will add color in the future most likely
-
-e-cell-toggle.c, e-cell-toggle.h
-
- A derivative of e-cell as well that support N-toggle values
- using images.
-
-e-cell-check.c, e-cell-check.h
-
- An e-cell-toggle with two states only (for checkboxes).
-
-* The Filters
-
-e-table-sorted.c, e-table-sorted.h
-
- This is an ETableModel that can sort an existing ETableModel.
-
-e-table-subset.c, e-table-subset.h
-
- Not finished, but it is just an ETableModel that happens to be
- a subset of another ETableModel.
-
-* Everything
-
-e-table.c, e-table.h
-
- In the future these guys will implement the whole widget for
- doing table editing. Nothing done about these yet.
diff --git a/widgets/e-table/TODO b/widgets/e-table/TODO
deleted file mode 100644
index 29dbd454e5..0000000000
--- a/widgets/e-table/TODO
+++ /dev/null
@@ -1,24 +0,0 @@
-Implement e-cell-height
-Implement computation of heights from the e-cell-heights
-Make sure we compute the height from that
-Include spacing in columns and rows for the decoration lines
-Add threshold to compute a "global" size
-Implement the two methods for row finding: by full thing, or by a factor.
-
-
-Add editing
-mouse grabbing for scrolling
-
-
-1. Make sure that all values are updated on header changes and table
- model changes (they are slightly out of sync now)
-
-* Correctness
-
- * Make sure we can boot and shutdown with no memory leaks.
-
- * Run Insure on the thing.
-
-* Propagation
-
- * Row changes should be reflected in the subsets.
diff --git a/widgets/e-table/add-col.xpm b/widgets/e-table/add-col.xpm
deleted file mode 100644
index 9c5f314c8e..0000000000
--- a/widgets/e-table/add-col.xpm
+++ /dev/null
@@ -1,22 +0,0 @@
-/* XPM */
-static char * add_col_xpm[] = {
-"16 16 3 1",
-" c None",
-". c #000000",
-"+ c #FFFFFF",
-" ",
-" ",
-" ",
-" ",
-" .............. ",
-" .++++++++++++. ",
-" .++++++++++++. ",
-" ....+++....... ",
-" .+. ",
-" . ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" "};
diff --git a/widgets/e-table/check-empty.xpm b/widgets/e-table/check-empty.xpm
deleted file mode 100644
index 2dd873e137..0000000000
--- a/widgets/e-table/check-empty.xpm
+++ /dev/null
@@ -1,21 +0,0 @@
-/* XPM */
-static char * check_empty_xpm[] = {
-"16 16 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" ............ ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" ............ ",
-" ",
-" "};
diff --git a/widgets/e-table/check-filled.xpm b/widgets/e-table/check-filled.xpm
deleted file mode 100644
index 689d7a7967..0000000000
--- a/widgets/e-table/check-filled.xpm
+++ /dev/null
@@ -1,21 +0,0 @@
-/* XPM */
-static char * check_filled_xpm[] = {
-"16 16 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" ............ ",
-" . . ",
-" . . . ",
-" . .. . ",
-" . ... . ",
-" . . ... . ",
-" . .. ... . ",
-" . ..... . ",
-" . ... . ",
-" . . . ",
-" . . ",
-" ............ ",
-" ",
-" "};
diff --git a/widgets/e-table/e-cell-checkbox.c b/widgets/e-table/e-cell-checkbox.c
deleted file mode 100644
index 431c1663d1..0000000000
--- a/widgets/e-table/e-cell-checkbox.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * e-cell-checkbox.c: Checkbox cell renderer
- *
- * Author:
- * Miguel de Icaza (miguel@kernel.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include <gtk/gtkenums.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtksignal.h>
-#include <gdk/gdkkeysyms.h>
-#include <libgnomeui/gnome-canvas.h>
-#include "e-cell-checkbox.h"
-#include "e-util/e-util.h"
-#include "e-table-item.h"
-
-#include "check-empty.xpm"
-#include "check-filled.xpm"
-
-#define PARENT_TYPE e_cell_toggle_get_type()
-
-static GdkPixbuf *checks [2];
-
-static void
-e_cell_checkbox_class_init (GtkObjectClass *object_class)
-{
- checks [0] = gdk_pixbuf_new_from_xpm_data (check_empty_xpm);
- checks [1] = gdk_pixbuf_new_from_xpm_data (check_filled_xpm);
-}
-
-E_MAKE_TYPE(e_cell_checkbox, "ECellCheckbox", ECellCheckbox, e_cell_checkbox_class_init, NULL, PARENT_TYPE);
-
-ECell *
-e_cell_checkbox_new (void)
-{
- ECellCheckbox *eccb = gtk_type_new (e_cell_checkbox_get_type ());
-
- e_cell_toggle_construct (E_CELL_TOGGLE (eccb), 2, 2, checks);
-
- return (ECell *) eccb;
-}
diff --git a/widgets/e-table/e-cell-checkbox.h b/widgets/e-table/e-cell-checkbox.h
deleted file mode 100644
index 969e4a5edc..0000000000
--- a/widgets/e-table/e-cell-checkbox.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _E_CELL_CHECKBOX_H_
-#define _E_CELL_CHECKBOX_H_
-
-#include "e-cell-toggle.h"
-
-#define E_CELL_CHECKBOX_TYPE (e_cell_checkbox_get_type ())
-#define E_CELL_CHECKBOX(o) (GTK_CHECK_CAST ((o), E_CELL_CHECKBOX_TYPE, ECellCheckbox))
-#define E_CELL_CHECKBOX_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_CHECKBOX_TYPE, ECellCheckboxClass))
-#define E_IS_CELL_CHECKBOX(o) (GTK_CHECK_TYPE ((o), E_CELL_CHECKBOX_TYPE))
-#define E_IS_CELL_CHECKBOX_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_CHECKBOX_TYPE))
-
-typedef struct {
- ECellToggle parent;
-} ECellCheckbox;
-
-typedef struct {
- ECellToggleClass parent_class;
-} ECellCheckboxClass;
-
-GtkType e_cell_checkbox_get_type (void);
-ECell *e_cell_checkbox_new (void);
-
-#endif /* _E_CELL_CHECKBOX_H_ */
-
diff --git a/widgets/e-table/e-cell-string.c b/widgets/e-table/e-cell-string.c
deleted file mode 100644
index 992b1bd10e..0000000000
--- a/widgets/e-table/e-cell-string.c
+++ /dev/null
@@ -1,9 +0,0 @@
-ECell *
-e_cell_string_new (void)
-{
- ECell *ecell;
-
- ecell = gtk_type_new (ecell);
-
- return ecell;
-}
diff --git a/widgets/e-table/e-cell-text.c b/widgets/e-table/e-cell-text.c
deleted file mode 100644
index fead3d4654..0000000000
--- a/widgets/e-table/e-cell-text.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * e-cell-text.c: Text cell renderer
- *
- * Author:
- * Miguel de Icaza (miguel@kernel.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include <gtk/gtkenums.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtksignal.h>
-#include <gdk/gdkkeysyms.h>
-#include <libgnomeui/gnome-canvas.h>
-#include <stdio.h>
-#include "e-cell-text.h"
-#include "e-util/e-util.h"
-#include "e-table-item.h"
-
-#define PARENT_TYPE e_cell_get_type()
-
-#define TEXT_PAD 2
-
-typedef struct {
- char *old_text;
- GtkWidget *entry_top;
- GtkEntry *entry;
-
- /*
- * Where the editing is taking place
- */
- int model_col, view_col, row;
-} CellEdit;
-
-typedef struct {
- ECellView cell_view;
- GdkGC *gc;
- GdkFont *font;
- GnomeCanvas *canvas;
-
- /*
- * During edition.
- */
- CellEdit *edit;
-} ECellTextView;
-
-static ECellClass *parent_class;
-
-static void
-ect_queue_redraw (ECellTextView *text_view, int view_col, int view_row)
-{
- e_table_item_redraw_range (
- text_view->cell_view.e_table_item_view,
- view_col, view_row, view_col, view_row);
-}
-
-/*
- * Accept the currently edited text
- */
-static void
-ect_accept_edits (ECellTextView *text_view)
-{
- const char *text = gtk_entry_get_text (text_view->edit->entry);
- CellEdit *edit = text_view->edit;
-
- e_table_model_set_value_at (text_view->cell_view.e_table_model, edit->model_col, edit->row, text);
-}
-
-/*
- * Shuts down the editing process
- */
-static void
-ect_stop_editing (ECellTextView *text_view)
-{
- CellEdit *edit = text_view->edit;
-
- g_free (edit->old_text);
- edit->old_text = NULL;
- gtk_widget_destroy (edit->entry_top);
- edit->entry_top = NULL;
- edit->entry = NULL;
-
- g_free (edit);
-
- text_view->edit = NULL;
-
- e_table_item_leave_edit (text_view->cell_view.e_table_item_view);
-}
-
-/*
- * Cancels the edits
- */
-static void
-ect_cancel_edit (ECellTextView *text_view)
-{
- ect_queue_redraw (text_view, text_view->edit->view_col, text_view->edit->row);
- ect_stop_editing (text_view);
-}
-
-/*
- * ECell::new_view method
- */
-static ECellView *
-ect_new_view (ECell *ecell, ETableModel *table_model, void *e_table_item_view)
-{
- ECellText *ect = E_CELL_TEXT (ecell);
- ECellTextView *text_view = g_new0 (ECellTextView, 1);
- GnomeCanvas *canvas = GNOME_CANVAS_ITEM (e_table_item_view)->canvas;
-
- text_view->cell_view.ecell = ecell;
- text_view->cell_view.e_table_model = table_model;
- text_view->cell_view.e_table_item_view = e_table_item_view;
-
- if (ect->font_name){
- GdkFont *f;
-
- f = gdk_fontset_load (ect->font_name);
- text_view->font = f;
- }
- if (!text_view->font){
- text_view->font = GTK_WIDGET (canvas)->style->font;
-
- gdk_font_ref (text_view->font);
- }
-
- text_view->canvas = canvas;
-
- return (ECellView *)text_view;
-}
-
-/*
- * ECell::kill_view method
- */
-static void
-ect_kill_view (ECellView *ecv)
-{
- ECellTextView *text_view = (ECellTextView *) ecv;
-
- gdk_font_unref (text_view->font);
- text_view->font = NULL;
-
- g_free (text_view);
-}
-
-/*
- * ECell::realize method
- */
-static void
-ect_realize (ECellView *ecell_view)
-{
- ECellTextView *text_view = (ECellTextView *) ecell_view;
-
- text_view->gc = gdk_gc_new (GTK_WIDGET (text_view->canvas)->window);
-}
-
-/*
- * ECell::unrealize method
- */
-static void
-ect_unrealize (ECellView *ecv)
-{
- ECellTextView *text_view = (ECellTextView *) ecv;
-
- gdk_gc_unref (text_view->gc);
- text_view->gc = NULL;
-}
-
-/*
- * ECell::draw method
- */
-static void
-ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
- int x1, int y1, int x2, int y2)
-{
- ECellText *ect = E_CELL_TEXT (ecell_view->ecell);
- ECellTextView *text_view = (ECellTextView *) ecell_view;
- GtkWidget *w = GTK_WIDGET (text_view->canvas);
- GdkRectangle rect;
- const char *str = e_table_model_value_at (ecell_view->e_table_model, model_col, row);
- GdkFont *font = text_view->font;
- const int height = font->ascent + font->descent;
- int xoff;
- gboolean edit_display = FALSE;
-
- /*
- * Figure if this cell is being edited
- */
- if (text_view->edit){
- CellEdit *edit = text_view->edit;
-
- if ((edit->view_col == view_col) && (edit->row == row))
- edit_display = TRUE;
- }
-
- /*
- * Be a nice citizen: clip to the region we are supposed to draw on
- */
- rect.x = x1;
- rect.y = y1;
- rect.width = x2 - x1;
- rect.height = y2 - y1;
- gdk_gc_set_clip_rectangle (text_view->gc, &rect);
-
- if (edit_display){
- CellEdit *edit = text_view->edit;
- const char *text = gtk_entry_get_text (edit->entry);
- GdkWChar *p, *text_wc = g_new (GdkWChar, strlen (text) + 1);
- int text_wc_len = gdk_mbstowcs (text_wc, text, strlen (text));
- const int cursor_pos = GTK_EDITABLE (edit->entry)->current_pos;
- const int left_len = gdk_text_width_wc (text_view->font, text_wc, cursor_pos);
-
- text_wc [text_wc_len] = 0;
- /*
- * Paint
- */
- gdk_gc_set_foreground (text_view->gc, &w->style->base [GTK_STATE_NORMAL]);
- gdk_draw_rectangle (drawable, text_view->gc, TRUE,
- rect.x, rect.y, rect.width, rect.height);
- gdk_gc_set_foreground (text_view->gc, &w->style->text [GTK_STATE_NORMAL]);
-
- {
- GdkGC *gc = text_view->gc;
- const int y = y2 - font->descent - ((y2-y1-height)/2);
- int px, i;
-
- /*
- * Border
- */
- x1 += 2;
- x2--;
-
- px = x1;
-
- /*
- * If the cursor is outside the visible range
- *
- * FIXME: we really want a better behaviour.
- */
- if ((px + left_len) > x2)
- px -= left_len - (x2-x1);
-
- /*
- * Draw
- */
- for (i = 0, p = text_wc; *p; p++, i++){
- gdk_draw_text_wc (
- drawable, font, gc, px, y, p, 1);
-
- if (i == cursor_pos){
- gdk_draw_line (
- drawable, gc,
- px, y - font->ascent,
- px, y + font->descent - 1);
- }
-
- px += gdk_text_width_wc (font, p, 1);
- }
-
- if (i == cursor_pos){
- gdk_draw_line (
- drawable, gc,
- px, y - font->ascent,
- px, y + font->descent - 1);
- }
- }
- g_free (text_wc);
- } else {
- /*
- * Regular cell
- */
- GdkColor *background, *foreground;
- int width;
-
- /*
- * Border
- */
- x1++;
- x2--;
-
- /*
- * Compute draw mode
- */
- switch (ect->justify){
- case GTK_JUSTIFY_LEFT:
- xoff = 1;
- break;
-
- case GTK_JUSTIFY_RIGHT:
- width = 1 + gdk_text_width (font, str, strlen (str));
- xoff = (x2 - x1) - width;
- break;
-
- case GTK_JUSTIFY_CENTER:
- xoff = ((x2 - x1) - gdk_text_width (font, str, strlen (str))) / 2;
- break;
- default:
- xoff = 0;
- g_warning ("Can not handle GTK_JUSTIFY_FILL");
- break;
- }
-
-
- if (selected){
- background = &w->style->bg [GTK_STATE_SELECTED];
- foreground = &w->style->text [GTK_STATE_SELECTED];
- } else {
- background = &w->style->base [GTK_STATE_NORMAL];
- foreground = &w->style->text [GTK_STATE_NORMAL];
- }
-
- gdk_gc_set_foreground (text_view->gc, background);
- gdk_draw_rectangle (drawable, text_view->gc, TRUE,
- rect.x, rect.y, rect.width, rect.height);
- gdk_gc_set_foreground (text_view->gc, foreground);
-
- gdk_draw_string (
- drawable, font, text_view->gc,
- x1 + xoff,
- y2 - font->descent - ((y2-y1-height)/2), str);
- }
-}
-
-/*
- * Selects the entire string
- */
-static void
-ect_edit_select_all (ECellTextView *text_view)
-{
- g_assert (text_view->edit);
-
- gtk_editable_select_region (GTK_EDITABLE (text_view->edit->entry), 0, -1);
-}
-
-/*
- * ECell::event method
- */
-static gint
-ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row)
-{
- ECellTextView *text_view = (ECellTextView *) ecell_view;
-
- switch (event->type){
- case GDK_BUTTON_PRESS:
- /*
- * Adjust for the border we use
- */
- event->button.x++;
-
- printf ("Button pressed at %g %g\n", event->button.x, event->button.y);
- if (text_view->edit){
- printf ("FIXME: Should handle click here\n");
- } else
- e_table_item_enter_edit (text_view->cell_view.e_table_item_view, view_col, row);
- break;
-
- case GDK_BUTTON_RELEASE:
- /*
- * Adjust for the border we use
- */
- event->button.x++;
- printf ("Button released at %g %g\n", event->button.x, event->button.y);
- return TRUE;
-
- case GDK_KEY_PRESS:
- if (event->key.keyval == GDK_Escape){
- ect_cancel_edit (text_view);
- return TRUE;
- }
-
- if (!text_view->edit){
- e_table_item_enter_edit (text_view->cell_view.e_table_item_view, view_col, row);
- ect_edit_select_all (text_view);
- }
-
- gtk_widget_event (GTK_WIDGET (text_view->edit->entry), event);
- ect_queue_redraw (text_view, view_col, row);
- break;
-
- case GDK_KEY_RELEASE:
- break;
-
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-/*
- * ECell::height method
- */
-static int
-ect_height (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- ECellTextView *text_view = (ECellTextView *) ecell_view;
-
- return (text_view->font->ascent + text_view->font->descent) + TEXT_PAD;
-}
-
-/*
- * Callback: invoked when the user pressed "enter" on the GtkEntry
- */
-static void
-ect_entry_activate (GtkEntry *entry, ECellTextView *text_view)
-{
- e_table_item_leave_edit (text_view->cell_view.e_table_item_view);
-}
-
-/*
- * ECellView::enter_edit method
- */
-static void *
-ect_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- ECellTextView *text_view = (ECellTextView *) ecell_view;
- const char *str = e_table_model_value_at (ecell_view->e_table_model, model_col, row);
- CellEdit *edit;
-
- edit = g_new (CellEdit, 1);
- text_view->edit = edit;
-
- edit->model_col = model_col;
- edit->view_col = view_col;
- edit->row = row;
-
- edit->entry = (GtkEntry *) gtk_entry_new ();
- gtk_entry_set_text (edit->entry, str);
- edit->old_text = g_strdup (str);
- gtk_signal_connect (GTK_OBJECT (edit->entry), "activate",
- GTK_SIGNAL_FUNC (ect_entry_activate), text_view);
-
- /*
- * The hack: create this window off-screen
- */
- edit->entry_top = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_container_add (GTK_CONTAINER (edit->entry_top), GTK_WIDGET (edit->entry));
- gtk_widget_set_uposition (edit->entry_top, 20000, 20000);
- gtk_widget_show_all (edit->entry_top);
-
- ect_queue_redraw (text_view, view_col, row);
-
- return NULL;
-}
-
-/*
- * ECellView::leave_edit method
- */
-static void
-ect_leave_edit (ECellView *ecell_view, int model_col, int view_col, int row, void *edit_context)
-{
- ECellTextView *text_view = (ECellTextView *) ecell_view;
-
- if (text_view->edit){
- ect_accept_edits (text_view);
- ect_stop_editing (text_view);
- } else {
- /*
- * We did invoke this leave edit internally
- */
- }
-}
-
-/*
- * GtkObject::destroy method
- */
-static void
-ect_destroy (GtkObject *object)
-{
- ECellText *ect = E_CELL_TEXT (object);
-
- g_free (ect->font_name);
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
-e_cell_text_class_init (GtkObjectClass *object_class)
-{
- ECellClass *ecc = (ECellClass *) object_class;
-
- object_class->destroy = ect_destroy;
-
- ecc->new_view = ect_new_view;
- ecc->kill_view = ect_kill_view;
- ecc->realize = ect_realize;
- ecc->unrealize = ect_unrealize;
- ecc->draw = ect_draw;
- ecc->event = ect_event;
- ecc->height = ect_height;
- ecc->enter_edit = ect_enter_edit;
- ecc->leave_edit = ect_leave_edit;
-
- parent_class = gtk_type_class (PARENT_TYPE);
-}
-
-E_MAKE_TYPE(e_cell_text, "ECellText", ECellText, e_cell_text_class_init, NULL, PARENT_TYPE);
-
-ECell *
-e_cell_text_new (ETableModel *etm, const char *fontname, GtkJustification justify)
-{
- ECellText *ect = gtk_type_new (e_cell_text_get_type ());
-
- ect->font_name = g_strdup (fontname);
- ect->justify = justify;
-
- return (ECell *) ect;
-}
diff --git a/widgets/e-table/e-cell-text.h b/widgets/e-table/e-cell-text.h
deleted file mode 100644
index de9629b97b..0000000000
--- a/widgets/e-table/e-cell-text.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef _E_CELL_TEXT_H_
-#define _E_CELL_TEXT_H_
-
-#include <libgnomeui/gnome-canvas.h>
-#include "e-cell.h"
-
-#define E_CELL_TEXT_TYPE (e_cell_text_get_type ())
-#define E_CELL_TEXT(o) (GTK_CHECK_CAST ((o), E_CELL_TEXT_TYPE, ECellText))
-#define E_CELL_TEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TEXT_TYPE, ECellTextClass))
-#define E_IS_CELL_TEXT(o) (GTK_CHECK_TYPE ((o), E_CELL_TEXT_TYPE))
-#define E_IS_CELL_TEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TEXT_TYPE))
-
-typedef struct {
- ECell parent;
-
- GtkJustification justify;
- char *font_name;
-} ECellText;
-
-typedef struct {
- ECellClass parent_class;
-} ECellTextClass;
-
-GtkType e_cell_text_get_type (void);
-ECell *e_cell_text_new (ETableModel *model, const char *fontname, GtkJustification justify);
-
-#endif /* _E_CELL_TEXT_H_ */
-
diff --git a/widgets/e-table/e-cell-toggle.c b/widgets/e-table/e-cell-toggle.c
deleted file mode 100644
index 679d04a0ca..0000000000
--- a/widgets/e-table/e-cell-toggle.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * e-cell-toggle.c: Multi-state image toggle cell object.
- *
- * Author:
- * Miguel de Icaza (miguel@kernel.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include <gtk/gtkenums.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtksignal.h>
-#include <gdk/gdkkeysyms.h>
-#include <libgnomeui/gnome-canvas.h>
-#include "e-cell-toggle.h"
-#include "e-util/e-util.h"
-#include "e-table-item.h"
-
-#define PARENT_TYPE e_cell_get_type()
-
-typedef struct {
- ECellView cell_view;
- GdkGC *gc;
- GnomeCanvas *canvas;
-} ECellToggleView;
-
-static ECellClass *parent_class;
-
-static void
-etog_queue_redraw (ECellToggleView *text_view, int view_col, int view_row)
-{
- e_table_item_redraw_range (
- text_view->cell_view.e_table_item_view,
- view_col, view_row, view_col, view_row);
-}
-
-/*
- * ECell::realize method
- */
-static ECellView *
-etog_new_view (ECell *ecell, ETableModel *table_model, void *e_table_item_view)
-{
- ECellToggleView *toggle_view = g_new0 (ECellToggleView, 1);
- ETableItem *eti = E_TABLE_ITEM (e_table_item_view);
- GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas;
-
- toggle_view->cell_view.ecell = ecell;
- toggle_view->cell_view.e_table_model = table_model;
- toggle_view->cell_view.e_table_item_view = e_table_item_view;
- toggle_view->canvas = canvas;
-
- return (ECellView *) toggle_view;
-}
-
-static void
-etog_kill_view (ECellView *ecell_view)
-{
- g_free (ecell_view);
-}
-
-static void
-etog_realize (ECellView *ecell_view)
-{
- ECellToggleView *toggle_view = (ECellToggleView *) ecell_view;
-
- toggle_view->gc = gdk_gc_new (GTK_WIDGET (toggle_view->canvas)->window);
-}
-
-/*
- * ECell::unrealize method
- */
-static void
-etog_unrealize (ECellView *ecv)
-{
- ECellToggleView *toggle_view = (ECellToggleView *) ecv;
-
- gdk_gc_unref (toggle_view->gc);
- toggle_view->gc = NULL;
-}
-
-/*
- * ECell::draw method
- */
-static void
-etog_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
- int x1, int y1, int x2, int y2)
-{
- ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell);
- ECellToggleView *toggle_view = (ECellToggleView *) ecell_view;
- GdkPixbuf *image;
- ArtPixBuf *art;
- int x, y, width, height;
- const int value = GPOINTER_TO_INT (
- e_table_model_value_at (ecell_view->e_table_model, model_col, row));
-
- if (value >= toggle->n_states){
- g_warning ("Value from the table model is %d, the states we support are [0..%d)\n",
- value, toggle->n_states);
- return;
- }
-
- /*
- * Paint the background
- */
- gdk_draw_rectangle (drawable, GTK_WIDGET (toggle_view->canvas)->style->white_gc, TRUE, x1, y1, x2 - x1, y2 - y1);
-
- image = toggle->images [value];
- art = image->art_pixbuf;
-
- if ((x2 - x1) < art->width){
- x = x1;
- width = x2 - x1;
- } else {
- x = x1 + ((x2 - x1) - art->width) / 2;
- width = art->width;
- }
-
- if ((y2 - y1) < art->height){
- y = y1;
- height = y2 - y1;
- } else {
- y = y1 + ((y2 - y1) - art->height) / 2;
- height = art->height;
- }
-
- width = y2 - y1;
-
- if (image->art_pixbuf->has_alpha){
- GdkColor background;
- guchar *buffer;
- int alpha, ix, iy;
-
- buffer = g_malloc (art->rowstride * art->height * 3);
-
- background.red = 255;
- background.green = 255;
- background.blue = 255;
-
- for (iy = 0; iy < art->height; iy++){
- unsigned char *dest;
- unsigned char *src;
-
- dest = buffer + (iy * art->rowstride);
- src = art->pixels + (iy * art->rowstride);
-
- for (ix = 0; ix < art->width; ix++){
- alpha = src [3];
- if (alpha == 0){
- *dest++ = background.red;
- *dest++ = background.green;
- *dest++ = background.blue;
- src += 3;
- } else if (alpha == 255){
- *dest++ = *src++;
- *dest++ = *src++;
- *dest++ = *src++;
- } else {
- *dest++ = (background.red + ((*src++ - background.red) * alpha + 0x80)) >> 8;
- *dest++ = (background.green + ((*src++ - background.green) * alpha + 0x80)) >> 8;
- *dest++ = (background.blue + ((*src++ - background.blue) * alpha + 0x80)) >> 8;
- }
- src++;
- }
- }
-
- gdk_draw_rgb_image_dithalign (
- drawable, toggle_view->gc, x, y, width, height,
- GDK_RGB_DITHER_NORMAL, buffer, art->rowstride, 0, 0);
-
- g_free (buffer);
- } else
- gdk_draw_rgb_image_dithalign (
- drawable, toggle_view->gc, x, y, width, height,
- GDK_RGB_DITHER_NORMAL, art->pixels, art->rowstride, 0, 0);
-}
-
-static void
-etog_set_value (ECellToggleView *toggle_view, int model_col, int view_col, int row, int value)
-{
- ECell *ecell = toggle_view->cell_view.ecell;
- ECellToggle *toggle = E_CELL_TOGGLE (ecell);
-
- if (value >= toggle->n_states)
- value = 0;
-
- e_table_model_set_value_at (toggle_view->cell_view.e_table_model,
- model_col, row, GINT_TO_POINTER (value));
- etog_queue_redraw (toggle_view, view_col, row);
-}
-
-/*
- * ECell::event method
- */
-static gint
-etog_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row)
-{
- ECellToggleView *toggle_view = (ECellToggleView *) ecell_view;
- void *_value = e_table_model_value_at (ecell_view->e_table_model, model_col, row);
- const int value = GPOINTER_TO_INT (_value);
-
- switch (event->type){
- case GDK_BUTTON_RELEASE:
- etog_set_value (toggle_view, model_col, view_col, row, value + 1);
- return TRUE;
-
- case GDK_KEY_PRESS:
- if (event->key.keyval == GDK_space){
- etog_set_value (toggle_view, model_col, view_col, row, value + 1);
- return TRUE;
- }
- return FALSE;
-
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-/*
- * ECell::height method
- */
-static int
-etog_height (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell);
-
- return toggle->height;
-}
-
-static void
-etog_destroy (GtkObject *object)
-{
- ECellToggle *etog = E_CELL_TOGGLE (object);
- int i;
-
- for (i = 0; i < etog->n_states; i++)
- gdk_pixbuf_unref (etog->images [i]);
-
- g_free (etog->images);
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
-e_cell_toggle_class_init (GtkObjectClass *object_class)
-{
- ECellClass *ecc = (ECellClass *) object_class;
-
- object_class->destroy = etog_destroy;
-
- ecc->new_view = etog_new_view;
- ecc->kill_view = etog_kill_view;
- ecc->realize = etog_realize;
- ecc->unrealize = etog_unrealize;
- ecc->draw = etog_draw;
- ecc->event = etog_event;
- ecc->height = etog_height;
-
- parent_class = gtk_type_class (PARENT_TYPE);
-}
-
-E_MAKE_TYPE(e_cell_toggle, "ECellToggle", ECellToggle, e_cell_toggle_class_init, NULL, PARENT_TYPE);
-
-void
-e_cell_toggle_construct (ECellToggle *etog, int border, int n_states, GdkPixbuf **images)
-{
- int max_height = 0;
- int i;
-
- etog->border = border;
- etog->n_states = n_states;
-
- etog->images = g_new (GdkPixbuf *, n_states);
-
- for (i = 0; i < n_states; i++){
- etog->images [i] = images [i];
- gdk_pixbuf_ref (images [i]);
-
- if (images [i]->art_pixbuf->height > max_height)
- max_height = images [i]->art_pixbuf->height;
- }
-
- etog->height = max_height;
-}
-
-ECell *
-e_cell_toggle_new (int border, int n_states, GdkPixbuf **images)
-{
- ECellToggle *etog = gtk_type_new (e_cell_toggle_get_type ());
-
- e_cell_toggle_construct (etog, border, n_states, images);
-
- return (ECell *) etog;
-}
-
-
diff --git a/widgets/e-table/e-cell-toggle.h b/widgets/e-table/e-cell-toggle.h
deleted file mode 100644
index d5773b454a..0000000000
--- a/widgets/e-table/e-cell-toggle.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef _E_CELL_TOGGLE_H_
-#define _E_CELL_TOGGLE_H_
-
-#include <libgnomeui/gnome-canvas.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include "e-cell.h"
-
-#define E_CELL_TOGGLE_TYPE (e_cell_toggle_get_type ())
-#define E_CELL_TOGGLE(o) (GTK_CHECK_CAST ((o), E_CELL_TOGGLE_TYPE, ECellToggle))
-#define E_CELL_TOGGLE_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TOGGLE_TYPE, ECellToggleClass))
-#define E_IS_CELL_TOGGLE(o) (GTK_CHECK_TYPE ((o), E_CELL_TOGGLE_TYPE))
-#define E_IS_CELL_TOGGLE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TOGGLE_TYPE))
-
-typedef struct {
- ECell parent;
-
- int border;
- int n_states;
- GdkPixbuf **images;
-
- int height;
-} ECellToggle;
-
-typedef struct {
- ECellClass parent_class;
-} ECellToggleClass;
-
-GtkType e_cell_toggle_get_type (void);
-ECell *e_cell_toggle_new (int border, int n_states, GdkPixbuf **images);
-void e_cell_toggle_construct (ECellToggle *etog, int border,
- int n_states, GdkPixbuf **images);
-
-#endif /* _E_CELL_TOGGLE_H_ */
-
-
diff --git a/widgets/e-table/e-cell.c b/widgets/e-table/e-cell.c
deleted file mode 100644
index f1345e8c6b..0000000000
--- a/widgets/e-table/e-cell.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * e-cell.c: base class for cell renderers in e-table
- *
- * Author:
- * Miguel de Icaza (miguel@kernel.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include "e-cell.h"
-#include "e-util/e-util.h"
-
-#define PARENT_TYPE gtk_object_get_type()
-
-static ECellView *
-ec_new_view (ECell *ecell, ETableModel *table_model, void *e_table_item_view)
-{
- return NULL;
-}
-
-static void
-ec_realize (ECellView *e_cell)
-{
-}
-
-static void
-ec_kill_view (ECellView *ecell_view)
-{
-}
-
-static void
-ec_unrealize (ECellView *e_cell)
-{
-}
-
-static void
-ec_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
- int x1, int y1, int x2, int y2)
-{
- g_error ("e-cell-draw invoked\n");
-}
-
-static gint
-ec_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row)
-{
- g_error ("e-cell-event invoked\n");
- return 0;
-}
-
-static gint
-ec_height (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- g_error ("e-cell-event invoked\n");
- return 0;
-}
-
-static void
-ec_focus (ECellView *ecell_view, int model_col, int view_col, int row, int x1, int y1, int x2, int y2)
-{
- ecell_view->focus_col = view_col;
- ecell_view->focus_row = row;
- ecell_view->focus_x1 = x1;
- ecell_view->focus_y1 = y1;
- ecell_view->focus_x2 = x2;
- ecell_view->focus_y2 = y2;
-}
-
-static void
-ec_unfocus (ECellView *ecell_view)
-{
- ecell_view->focus_col = -1;
- ecell_view->focus_row = -1;
- ecell_view->focus_x1 = -1;
- ecell_view->focus_y1 = -1;
- ecell_view->focus_x2 = -1;
- ecell_view->focus_y2 = -1;
-}
-
-static void *
-ec_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- return NULL;
-}
-
-static void
-ec_leave_edit (ECellView *ecell_view, int model_col, int view_col, int row, void *context)
-{
-}
-
-static void
-e_cell_class_init (GtkObjectClass *object_class)
-{
- ECellClass *ecc = (ECellClass *) object_class;
-
- ecc->realize = ec_realize;
- ecc->unrealize = ec_unrealize;
- ecc->new_view = ec_new_view;
- ecc->kill_view = ec_kill_view;
- ecc->draw = ec_draw;
- ecc->event = ec_event;
- ecc->focus = ec_focus;
- ecc->unfocus = ec_unfocus;
- ecc->height = ec_height;
- ecc->enter_edit = ec_enter_edit;
- ecc->leave_edit = ec_leave_edit;
-}
-
-static void
-e_cell_init (GtkObject *object)
-{
-}
-
-E_MAKE_TYPE(e_cell, "ECell", ECell, e_cell_class_init, e_cell_init, PARENT_TYPE);
-
-
-void
-e_cell_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row)
-{
- E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->event (
- ecell_view, event, model_col, view_col, row);
-}
-
-ECellView *
-e_cell_new_view (ECell *ecell, ETableModel *table_model, void *e_table_item_view)
-{
- return E_CELL_CLASS (GTK_OBJECT (ecell)->klass)->new_view (
- ecell, table_model, e_table_item_view);
-}
-
-void
-e_cell_view_realize (ECellView *ecell_view)
-{
- return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->realize (ecell_view);
-}
-
-void
-e_cell_kill_view (ECellView *ecell_view)
-{
- E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->kill_view (ecell_view);
-}
-
-void
-e_cell_unrealize (ECellView *ecell_view)
-{
- E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->unrealize (ecell_view);
-}
-
-void
-e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected, int x1, int y1, int x2, int y2)
-{
- E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->draw (
- ecell_view, drawable, model_col, view_col, row, selected, x1, y1, x2, y2);
-}
-
-int
-e_cell_height (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->height (
- ecell_view, model_col, view_col, row);
-}
-
-void *
-e_cell_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->enter_edit (
- ecell_view, model_col, view_col, row);
-}
-
-void
-e_cell_leave_edit (ECellView *ecell_view, int model_col, int view_col, int row, void *edit_context)
-{
- E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->leave_edit (
- ecell_view, model_col, view_col, row, edit_context);
-}
diff --git a/widgets/e-table/e-cell.h b/widgets/e-table/e-cell.h
deleted file mode 100644
index 3c258689e4..0000000000
--- a/widgets/e-table/e-cell.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef _E_CELL_H_
-#define _E_CELL_H_
-
-#include <gdk/gdktypes.h>
-#include "e-table-model.h"
-
-#define E_CELL_TYPE (e_cell_get_type ())
-#define E_CELL(o) (GTK_CHECK_CAST ((o), E_CELL_TYPE, ECell))
-#define E_CELL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TYPE, ECellClass))
-#define E_IS_CELL(o) (GTK_CHECK_TYPE ((o), E_CELL_TYPE))
-#define E_IS_CELL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TYPE))
-
-typedef struct _ECell ECell;
-typedef struct _ECellView ECellView;
-
-struct _ECell {
- GtkObject object;
-};
-
-struct _ECellView {
- ECell *ecell;
- ETableModel *e_table_model;
- void *e_table_item_view;
-
- gint focus_x1, focus_y1, focus_x2, focus_y2;
- gint focus_col, focus_row;
-};
-
-#define E_CELL_IS_FOCUSED(ecell_view) (ecell_view->focus_x1 != -1)
-
-typedef struct {
- GtkObjectClass parent_class;
-
- ECellView *(*new_view) (ECell *ecell, ETableModel *table_model, void *e_table_item_view);
- void (*kill_view) (ECellView *ecell_view);
-
- void (*realize) (ECellView *ecell_view);
- void (*unrealize) (ECellView *ecell_view);
-
- void (*draw) (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row,
- gboolean selected, int x1, int y1, int x2, int y2);
- gint (*event) (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row);
- void (*focus) (ECellView *ecell_view, int model_col, int view_col,
- int row, int x1, int y1, int x2, int y2);
- void (*unfocus) (ECellView *ecell_view);
- int (*height) (ECellView *ecell_view, int model_col, int view_col, int row);
-
- void *(*enter_edit)(ECellView *ecell_view, int model_col, int view_col, int row);
- void (*leave_edit)(ECellView *ecell_view, int model_col, int view_col, int row, void *context);
-} ECellClass;
-
-GtkType e_cell_get_type (void);
-ECellView *e_cell_new_view (ECell *ecell, ETableModel *table_model, void *e_table_item_view);
-void e_cell_kill_view (ECellView *ecell_view);
-
-void e_cell_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row);
-
-void e_cell_realize (ECellView *ecell_view);
-void e_cell_unrealize (ECellView *ecell_view);
-
-void e_cell_draw (ECellView *ecell_view, GdkDrawable *dr,
- int model_col, int view_col, int row, gboolean selected,
- int x1, int y1, int x2, int y2);
-void e_cell_focus (ECellView *ecell_view, int model_col, int view_col, int row,
- int x1, int y1, int x2, int y2);
-void e_cell_unfocus (ECellView *ecell_view);
-int e_cell_height (ECellView *ecell_view, int model_col, int view_col, int row);
-
-void *e_cell_enter_edit(ECellView *ecell_view, int model_col, int view_col, int row);
-void e_cell_leave_edit(ECellView *ecell_view, int model_col, int view_col, int row, void *edit_context);
-
-#endif /* _E_CELL_H_ */
diff --git a/widgets/e-table/e-table-col-dnd.h b/widgets/e-table/e-table-col-dnd.h
deleted file mode 100644
index c1c26175c7..0000000000
--- a/widgets/e-table/e-table-col-dnd.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _E_TABLE_COL_DND_H_
-#define _E_TABLE_COL_DND_H_
-
-#define TARGET_ETABLE_COL_TYPE "application/x-etable-column-header"
-
-enum {
- TARGET_ETABLE_COL_HEADER
-};
-
-#endif /* _E_TABLE_COL_DND_H_ */
diff --git a/widgets/e-table/e-table-col.c b/widgets/e-table/e-table-col.c
deleted file mode 100644
index 6f475158a5..0000000000
--- a/widgets/e-table/e-table-col.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * E-table-col.c: ETableCol implementation
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include <gtk/gtkobject.h>
-#include <gtk/gtksignal.h>
-#include "e-table-col.h"
-#include "e-util/e-util.h"
-
-#define PARENT_TYPE (gtk_object_get_type ())
-
-static GtkObjectClass *parent_class;
-
-static void
-etc_destroy (GtkObject *object)
-{
- ETableCol *etc = E_TABLE_COL (object);
-
- g_free (etc->text);
-
- (*parent_class->destroy)(object);
-}
-
-static void
-e_table_col_class_init (GtkObjectClass *object_class)
-{
- parent_class = gtk_type_class (PARENT_TYPE);
- object_class->destroy = etc_destroy;
-}
-
-E_MAKE_TYPE(e_table_col, "ETableCol", ETableCol, e_table_col_class_init, NULL, PARENT_TYPE);
-
-ETableCol *
-e_table_col_new (int col_idx, const char *text, int width, int min_width,
- ECell *ecell, GCompareFunc compare, gboolean resizable)
-{
- ETableCol *etc;
-
- g_return_val_if_fail (width >= 0, NULL);
- g_return_val_if_fail (min_width >= 0, NULL);
- g_return_val_if_fail (width >= min_width, NULL);
- g_return_val_if_fail (compare != NULL, NULL);
-
- etc = gtk_type_new (E_TABLE_COL_TYPE);
-
- etc->col_idx = col_idx;
- etc->text = g_strdup (text);
- etc->width = width;
- etc->min_width = min_width;
- etc->ecell = ecell;
- etc->compare = compare;
-
- etc->selected = 0;
- etc->resizeable = resizable;
-
- return etc;
-}
-
-
diff --git a/widgets/e-table/e-table-col.h b/widgets/e-table/e-table-col.h
deleted file mode 100644
index 54f03ae237..0000000000
--- a/widgets/e-table/e-table-col.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef _E_TABLE_COL_H_
-#define _E_TABLE_COL_H_
-
-#include "e-cell.h"
-
-#define E_TABLE_COL_TYPE (e_table_col_get_type ())
-#define E_TABLE_COL(o) (GTK_CHECK_CAST ((o), E_TABLE_COL_TYPE, ETableCol))
-#define E_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_COL_TYPE, ETableColClass))
-#define E_IS_TABLE_COL(o) (GTK_CHECK_TYPE ((o), E_TABLE_COL_TYPE))
-#define E_IS_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_COL_TYPE))
-
-typedef struct _ETableCol ETableCol;
-
-/*
- * Information about a single column
- */
-struct _ETableCol {
- GtkObject base;
- char *text;
- short width;
- short min_width;
- short x;
- GCompareFunc compare;
- unsigned int selected:1;
- unsigned int resizeable:1;
- int col_idx;
-
- ECell *ecell;
-};
-
-typedef struct {
- GtkObjectClass parent_class;
-} ETableColClass;
-
-GtkType e_table_col_get_type (void);
-ETableCol *e_table_col_new (int col_idx, const char *text,
- int width, int min_width,
- ECell *ecell, GCompareFunc compare,
- gboolean resizable);
-void e_table_col_destroy (ETableCol *etc);
-
-
-#endif /* _E_TABLE_COL_H_ */
-
diff --git a/widgets/e-table/e-table-column-item.c b/widgets/e-table/e-table-column-item.c
deleted file mode 100644
index 0616327a93..0000000000
--- a/widgets/e-table/e-table-column-item.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * E-table-column-view.c: A canvas view of the TableColumn.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * Copyright 1999, Helix Code, Inc.
- */
-#include <config.h>
-#include "e-table-column.h"
-#include "e-table-column-view.h"
-
-#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type ()
-
-static GnomeCanvasItemClass *etci_parent_class;
-
-enum {
- ARG_0,
- ARG_TABLE_COLUMN
-};
-
-static void
-etci_destroy (GtkObject *object)
-{
- ETableColumnItem *etcv = E_TABLE_COLUMN_VIEW (object);
-
- gtk_object_unref (GTK_OBJECT (etcv));
-
- if (GTK_OBJECT_CLASS (etcv_parent_class)->destroy)
- (*GTK_OBJECT_CLASS (etcv_parent_class)->destroy) (object);
-}
-
-static void
-etci_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- if (GNOME_CANVAS_ITEM_CLASS(item_bar_parent_class)->update)
- (*GNOME_CANVAS_ITEM_CLASS(item_bar_parent_class)->update)(item, affine, clip_path, flags);
-
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = INT_MAX;
- item->y2 = INT_MAX;
- gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
-}
-
-static void
-etci_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- ETableColumnItem *etci;
- int v;
-
- item = GNOME_CANVAS_ITEM (o);
- etci = E_TABLE_COLUMN_ITEM (o);
-
- switch (arg_id){
- case ARG_TABLE_COLUMN:
- etci->etci = GTK_VALUE_POINTER (*arg);
- break;
- }
- etci_update (item, NULL, NULL, 0);
-}
-
-static void
-etci_realize (GnomeCanvasItem *item)
-{
- ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item);
- GdkWindow *window;
- GdkColor c;
-
- if (GNOME_CANVAS_ITEM_CLASS (etci_parent_class)-> realize)
- (*GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->realize)(item);
-
- window = GTK_WIDGET (item->canvas)->window;
-
- etci->gc = gdk_gc_new (window);
- gnome_canvas_get_color (item->canvas, "black", &c);
- gdk_gc_set_foreground (etci->gc, &c);
-
- etci->normal_cursor = gdk_cursor_new (GDK_ARROW);
-}
-
-static void
-etci_unrealize (GnomeCanvasItem *item)
-{
- ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item);
-
- gdk_gc_unref (etci->gc);
- etci->gc = NULL;
-
- gdk_cursor_destroy (etci->change_cursor);
- etci->change_cursor = NULL;
-
- gdk_cursor_destroy (etci->normal_cursor);
- etci->normal_cursor = NULL;
-
- if (GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->unrealize)
- (*GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->unrealize)(item);
-}
-
-static void
-etci_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x1, int y1, int width, int height)
-{
- ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item);
- GnomeCanvas *canvas = item->canvas;
- GdkGC *gc;
- const int cols = e_table_column_count (etci->etc);
- int x2 = x1 + width;
- int col, total;
-
- total = 0;
- for (col = 0; col < cols; col++){
- ETableCol *col = e_table_column_get_column (etci->etc, col);
- const int col_width = col->width;
-
- if (x1 > total + col_width)
- continue;
-
- if (x2 < total)
- return;
-
- gc = canvas->style->bg_gc [GTK_STATE_ACTIVE];
- gdk_draw_rectangle (drawble, gc, TRUE,
- gtk_draw_shadow (canvas->style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- x, y, width, height
- }
-}
-
-static double
-etci_point (GnomeCanvasItem *item, double x, double y, int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- *actual_item = *item;
- return 0.0;
-}
-
-static void
-etci_event (GnomeCanvasItem *item, GdkEvent *e)
-{
- switch (e->type){
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-static void
-etci_class_init (GtkObjectClass *object_class)
-{
- GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class;
-
- object_class->destroy = etci_destroy;
- object_class->set_arg = etci_set_arg;
-
- item_class->update = etci_update;
- item_class->realize = etci_realize;
- item_class->unrealize = etci_unrealize;
- item_class->draw = etci_draw;
- item_class->point = etci_point;
- item_class->event = etci_event;
-
- gtk_object_add_arg_type ("ETableColumnItem::ETableColumn", GTK_TYPE_POINTER,
- GTK_ARG_WRITABLE, ARG_TABLE_COLUMN);
-}
-
-static void
-etci_init (GnomeCanvasItem *item)
-{
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = 0;
- item->y2 = 0;
-}
-
-GtkType
-e_table_column_view_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableColumnItem",
- sizeof (ETableColumnItem),
- sizeof (ETableColumnItemClass),
- (GtkClassInitFunc) etci_class_init,
- (GtkObjectInitFunc) etci_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (PARENT_OBJECT_TYPE, &info);
- }
-
- return type;
-}
-
-
-
diff --git a/widgets/e-table/e-table-column-item.h b/widgets/e-table/e-table-column-item.h
deleted file mode 100644
index fd38681a73..0000000000
--- a/widgets/e-table/e-table-column-item.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _E_TABLE_COLUMN_VIEW_H
-#defein _E_TABLE_COLUMN_VIEW_H
-
-#include "e-table-column.h"
-
-typedef struct {
- GnomeCanvasItem parent;
- ETableColumn *etc;
-
- GdkGC *gc;
- GdkCursor *change_cursor, *normal_cursor;
-} ETableColumnView;
-
-typedef struct {
- GnomeCanvasItemClass parent_class;
-} ETableColumnViewClass;
-
-GtkType e_table_column_item_get_type (void);
-
-#endif /* _E_TABLE_COLUMN_VIEW_H */
diff --git a/widgets/e-table/e-table-column-model.h b/widgets/e-table/e-table-column-model.h
deleted file mode 100644
index 043dd783ca..0000000000
--- a/widgets/e-table/e-table-column-model.h
+++ /dev/null
@@ -1,5 +0,0 @@
-
-class ETableColumnModel {
- virtual void add_column (ETableCol *et) = 0;
- virtual ETableCol *get_column (int column);
- virtual
diff --git a/widgets/e-table/e-table-column.c b/widgets/e-table/e-table-column.c
deleted file mode 100644
index d17a285321..0000000000
--- a/widgets/e-table/e-table-column.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * e-table-column.c: TableColumn implementation
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include "e-table-column.h"
-
-enum {
- STRUCTURE_CHANGE,
- DIMENSION_CHANGE,
- LAST_SIGNAL
-};
-
-static guint etc_signals [LAST_SIGNAL] = { 0, };
-
-static GtkObjectClass *e_table_column_parent_class;
-
-static void
-e_table_column_destroy (GtkObject *object)
-{
- ETableColumn *etc = E_TABLE_COLUMN (object);
- const int cols = etc->col_count;
-
- /*
- * Destroy listeners
- */
- for (l = etc->listeners; l; l = l->next)
- g_free (l->data);
- g_slist_free (etc->listeners);
- etc->listeners = NULL;
-
- /*
- * Destroy columns
- */
- for (i = 0; i < cols; i++)
- e_table_column_remove (etc, i);
-
- if (e_table_column_parent_class->destroy)
- e_table_column_parent_class->destroy (object);
-}
-
-static void
-e_table_column_class_init (GtkObjectClass *object_class)
-{
- object_class->destroy = e_table_column_destroy;
-
- e_table_column_parent_class = (gtk_type_class (gtk_object_get_type ()));
-
- etc_signals [STRUCTURE_CHANGE] =
- gtk_signal_new ("structure_change",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableColumn, structure_change),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
- etc_signals [DIMENSION_CHANGE] =
- gtk_signal_new ("dimension_change",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableColumn, dimension_change),
- gtk_marshal_NONE__INT,
- GTK_TYPE_NONE, 1, GTK_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, etc_signals, LAST_SIGNAL);
-}
-
-GtkType
-e_table_column_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableColumn",
- sizeof (ETableColumn),
- sizeof (ETableColumnClass),
- (GtkClassInitFunc) e_table_column_class_init,
- (GtkObjectInitFunc) NULL,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (gtk_object_get_type (), &info);
- }
-
- return type;
-}
-
-static void
-etc_do_insert (ETableColumn *etc, int pos, ETableCol *val)
-{
- memcpy (&etc->columns [pos+1], &etc->columns [pos],
- sizeof (ETableCol *) * (etc->col_count - pos));
- etc->columns [pos] = val;
-}
-
-void
-e_table_column_add_column (ETableColumn *etc, ETableCol *tc, int pos)
-{
- ETableCol **new_ptr;
-
- g_return_if_fail (etc != NULL);
- g_return_if_fail (E_IS_TABLE_COLUMN (etc));
- g_return_if_fail (tc != NULL);
- g_return_if_fail (pos >= 0 && pos < etc->col_count);
-
- if (pos == -1)
- pos = etc->col_count;
- etc->columns = g_realloc (etc->columns, sizeof (ETableCol *) * (etc->col_count + 1));
- etc_do_insert (etc, pos, tc);
- etc->col_count++;
-
- gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]);
-}
-
-ETableCol *
-e_table_column_get_column (ETableColumn *etc, int column)
-{
- g_return_val_if_fail (etc != NULL, NULL);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), NULL);
-
- if (column < 0)
- return NULL;
-
- if (column >= etc->col_count)
- return NULL;
-
- return etc->columns [column];
-}
-
-int
-e_table_column_count (ETableColumn *etc)
-{
- g_return_val_if_fail (etc != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0);
-
- return etc->col_count;
-}
-
-int
-e_table_column_index (ETableColumn *etc, const char *identifier)
-{
- int i;
-
- g_return_val_if_fail (etc != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0);
- g_return_val_if_fail (identifier != NULL, 0);
-
- for (i = 0; i < etc->col_count; i++){
- ETableCol *tc = etc->columns [i];
-
- if (strcmp (i->id, identifier) == 0)
- return i;
- }
-
- return -1;
-}
-
-int
-e_table_column_get_index_at (ETableColumn *etc, int x_offset)
-{
- int i, total;
-
- g_return_val_if_fail (etc != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0);
- g_return_val_if_fail (identifier != NULL, 0);
-
- total = 0;
- for (i = 0; i < etc->col_count; i++){
- total += etc->columns [i]->width;
-
- if (x_offset < total)
- return i;
- }
-
- return -1;
-}
-
-ETableCol **
-e_table_column_get_columns (ETableColumn *etc)
-{
- ETableCol **ret;
- int i;
-
- g_return_val_if_fail (etc != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0);
-
- ret = g_new (ETableCol *, etc->col_count + 1);
- memcpy (ret, etc->columns, sizeof (ETableCol *) * etc->col_count);
- ret [etc->col_count] = NULL;
-
- return ret;
-}
-
-gboolean
-e_table_column_selection_ok (ETableColumn *etc)
-{
- g_return_val_if_fail (etc != NULL, FALSE);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), FALSE);
-
- return etc->selectable;
-}
-
-int
-ve_table_column_get_selected (ETableColumn *etc)
-{
- int i;
- int selected = 0;
-
- g_return_val_if_fail (etc != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0);
-
- for (i = 0; i < etc->col_count; i++){
- if (etc->columns [i]->selected)
- selected++;
- }
-
- return selected;
-}
-
-int
-e_table_column_total_width (ETableColumn *etc)
-{
- int total;
-
- g_return_val_if_fail (etc != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0);
-
- total = 0;
- for (i = 0; i < etc->col_count; i++)
- total += etc->columns [i].width;
-
- return total;
-}
-
-static void
-etc_do_remove (ETableColumn *etc, int idx)
-{
- memcpy (&etc->columns [idx], &etc->columns [idx+1],
- sizeof (ETableCol *) * etc->col_count - idx);
- etc->col_count--;
-}
-
-void
-e_table_column_move (ETableColumn *etc, int source_index, int target_index)
-{
- g_return_if_fail (etc != NULL);
- g_return_if_fail (E_IS_TABLE_COLUMN (etc));
- g_return_if_fail (source_index >= 0);
- g_return_if_fail (target_index >= 0);
- g_return_if_fail (source_index < etc->col_count);
- g_return_if_fail (target_index < etc->col_count);
-
- old = etc->columns [source_index];
- etc_do_remove (etc, source_index);
- etc_do_insert (etc, target_index, old);
- gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]);
-}
-
-void
-e_table_column_remove (ETableColumn *etc, int idx)
-{
- g_return_if_fail (etc != NULL);
- g_return_if_fail (E_IS_TABLE_COLUMN (etc));
- g_return_if_fail (idx >= 0);
- g_return_if_fail (idx < etc->col_count);
-
- etc_do_remove (etc, idx);
- gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]);
-}
-
-void
-e_table_column_set_selection (ETableColumn *etc, gboolean allow_selection);
-{
-}
-
-void
-e_table_column_set_size (ETableColumn *etc, int idx, int size)
-{
- g_return_if_fail (etc != NULL);
- g_return_if_fail (E_IS_TABLE_COLUMN (etc));
- g_return_if_fail (idx >= 0);
- g_return_if_fail (idx < etc->col_count);
- g_return_if_fail (size > 0);
-
- etc->columns [idx]->width = size;
- gtk_signal_emit (GTK_OBJECT (etc), etc_signals [SIZE_CHANGE], idx);
-}
diff --git a/widgets/e-table/e-table-group.c b/widgets/e-table/e-table-group.c
deleted file mode 100644
index 8783fbaa02..0000000000
--- a/widgets/e-table/e-table-group.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * E-Table-Group.c: Implements the grouping objects for elements on a table
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org()
- *
- * Copyright 1999, Helix Code, Inc.
- */
-
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include "e-table-group.h"
-#include "e-table-item.h"
-#include <libgnomeui/gnome-canvas-rect-ellipse.h>
-#include "e-util/e-util.h"
-
-#define TITLE_HEIGHT 16
-#define GROUP_INDENT 10
-
-#define PARENT_TYPE gnome_canvas_group_get_type ()
-
-static GnomeCanvasGroupClass *etg_parent_class;
-
-enum {
- HEIGHT_CHANGED,
- LAST_SIGNAL
-};
-
-static gint etg_signals [LAST_SIGNAL] = { 0, };
-
-static void
-etg_destroy (GtkObject *object)
-{
- ETableGroup *etg = E_TABLE_GROUP (object);
-
- GTK_OBJECT_CLASS (etg_parent_class)->destroy (object);
-}
-
-static void
-etg_dim (ETableGroup *etg, int *width, int *height)
-{
- GSList *l;
-
- *width = *height = 0;
-
- for (l = etg->children; l; l = l->next){
- GnomeCanvasItem *child = l->data;
-
- *height += child->y2 - child->y1;
- *width += child->x2 - child->x1;
- }
-
- if (!etg->transparent){
- *height += TITLE_HEIGHT;
- *width += GROUP_INDENT;
- }
-}
-
-void
-e_table_group_construct (GnomeCanvasGroup *parent, ETableGroup *etg,
- ETableCol *ecol, gboolean open,
- gboolean transparent)
-{
- gnome_canvas_item_constructv (GNOME_CANVAS_ITEM (etg), parent, 0, NULL);
-
- etg->ecol = ecol;
- etg->open = open;
- etg->transparent = transparent;
-
- etg_dim (etg, &etg->width, &etg->height);
-
- if (!etg->transparent)
- etg->rect = gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (etg),
- gnome_canvas_rect_get_type (),
- "fill_color", "gray",
- "outline_color", "gray20",
- "x1", 0.0,
- "y1", 0.0,
- "x2", (double) etg->width,
- "y2", (double) etg->height,
- NULL);
-
-#if 0
- /*
- * Reparent the child into our space.
- */
- gnome_canvas_item_reparent (child, GNOME_CANVAS_GROUP (etg));
-
- gnome_canvas_item_set (
- child,
- "x", (double) GROUP_INDENT,
- "y", (double) TITLE_HEIGHT,
- NULL);
-
- /*
- * Force dimension computation
- */
- GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->update (
- GNOME_CANVAS_ITEM (etg), NULL, NULL, GNOME_CANVAS_UPDATE_REQUESTED);
-#endif
-}
-
-GnomeCanvasItem *
-e_table_group_new (GnomeCanvasGroup *parent, ETableCol *ecol,
- gboolean open, gboolean transparent)
-{
- ETableGroup *etg;
-
- g_return_val_if_fail (parent != NULL, NULL);
- g_return_val_if_fail (ecol != NULL, NULL);
-
- etg = gtk_type_new (e_table_group_get_type ());
-
- e_table_group_construct (parent, etg, ecol, open, transparent);
-
- return GNOME_CANVAS_ITEM (etg);
-}
-
-static void
-etg_relayout (GnomeCanvasItem *eti, ETableGroup *etg)
-{
- GSList *l;
- int height = etg->transparent ? 0 : GROUP_INDENT;
- gboolean move = FALSE;
-
- printf ("Relaying out\n");
-
- for (l = etg->children; l->next; l = l->next){
- GnomeCanvasItem *child = l->data;
-
- height += child->y2 - child->y1;
-
- if (child == eti)
- move = TRUE;
-
- if (move){
- printf ("Moving item %p\n", child);
- gnome_canvas_item_set (
- child,
- "y", (double) height,
- NULL);
- }
- }
- if (height != etg->height){
- etg->height = height;
- gtk_signal_emit (GTK_OBJECT (etg), etg_signals [HEIGHT_CHANGED]);
- }
-}
-
-void
-e_table_group_add (ETableGroup *etg, GnomeCanvasItem *item)
-{
- double x1, y1, x2, y2;
-
- g_return_if_fail (etg != NULL);
- g_return_if_fail (item != NULL);
- g_return_if_fail (E_IS_TABLE_GROUP (etg));
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
-
- etg->children = g_slist_append (etg->children, item);
-
- GNOME_CANVAS_ITEM_CLASS (GTK_OBJECT (etg)->klass)->bounds (etg, &x1, &y1, &x2, &y2);
-
- if (GTK_OBJECT (etg)->flags & GNOME_CANVAS_ITEM_REALIZED){
- GSList *l;
- int height = etg->transparent ? 0 : TITLE_HEIGHT;
- int x = etg->transparent ? 0 : GROUP_INDENT;
-
- for (l = etg->children; l->next; l = l->next){
- GnomeCanvasItem *child = l->data;
-
- height += child->y2 - child->y1;
- }
-
- printf ("Positioning item %p at %d\n", item, height);
- gnome_canvas_item_set (
- item,
- "y", (double) height,
- "x", (double) x,
- NULL);
-
-
- if (E_IS_TABLE_ITEM (item)){
-
- printf ("Table item! ---------\n");
- gtk_signal_connect (GTK_OBJECT (item), "height_changed",
- GTK_SIGNAL_FUNC (etg_relayout), etg);
- }
- }
-}
-
-static void
-etg_realize (GnomeCanvasItem *item)
-{
- ETableGroup *etg = E_TABLE_GROUP (item);
- GSList *l;
- int height = 0;
-
- GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->realize (item);
-
- for (l = etg->children; l; l = l->next){
- GnomeCanvasItem *child = l->data;
-
- printf ("During realization for child %p -> %d\n", child, height);
- gnome_canvas_item_set (
- child,
- "y", (double) height,
- NULL);
-
- height += child->y2 - child->y1;
- }
-}
-
-static void
-etg_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- ETableGroup *etg = E_TABLE_GROUP (item);
-
- GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->update (item, affine, clip_path, flags);
-
- if (!etg->transparent){
- int current_width, current_height;
-
- etg_dim (etg, &current_width, &current_height);
-
- if ((current_height != etg->height) || (current_width != etg->width)){
- etg->width = current_width;
- etg->height = current_height;
-
- gnome_canvas_item_set (
- etg->rect,
- "x1", 0.0,
- "y1", 0.0,
- "x2", (double) etg->width,
- "y2", (double) etg->height,
- NULL);
- }
- }
-}
-
-static void
-etg_class_init (GtkObjectClass *object_class)
-{
- GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class;
-
- object_class->destroy = etg_destroy;
-
- item_class->realize = etg_realize;
- item_class->update = etg_update;
-
- etg_parent_class = gtk_type_class (PARENT_TYPE);
-
- etg_signals [HEIGHT_CHANGED] =
- gtk_signal_new ("height_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableGroupClass, height_changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, etg_signals, LAST_SIGNAL);
-
-}
-
-E_MAKE_TYPE (e_table_group, "ETableGroup", ETableGroup, etg_class_init, NULL, PARENT_TYPE);
-
-
-
diff --git a/widgets/e-table/e-table-group.h b/widgets/e-table/e-table-group.h
deleted file mode 100644
index 468d5dd794..0000000000
--- a/widgets/e-table/e-table-group.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef _E_TABLE_TREE_H_
-#define _E_TABLE_TREE_H_
-
-#include <libgnomeui/gnome-canvas.h>
-#include "e-table-model.h"
-#include "e-table-header.h"
-
-#define E_TABLE_GROUP_TYPE (e_table_group_get_type ())
-#define E_TABLE_GROUP(o) (GTK_CHECK_CAST ((o), E_TABLE_GROUP_TYPE, ETableGroup))
-#define E_TABLE_GROUP_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_GROUP_TYPE, ETableGroupClass))
-#define E_IS_TABLE_GROUP(o) (GTK_CHECK_TYPE ((o), E_TABLE_GROUP_TYPE))
-#define E_IS_TABLE_GROUP_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_GROUP_TYPE))
-
-typedef struct {
- GnomeCanvasGroup group;
-
- /*
- * The ETableCol used to group this set
- */
- ETableCol *ecol;
-
- /*
- * The canvas rectangle that contains the children
- */
- GnomeCanvasItem *rect;
-
- /*
- * Dimensions of the ETableGroup
- */
- int width, height;
-
- /*
- * State: the ETableGroup is open or closed
- */
- guint open:1;
-
- /*
- * Whether we should add indentation and open/close markers,
- * or if we just act as containers of subtables.
- */
- guint transparent:1;
-
- /*
- * List of GnomeCanvasItems we stack
- */
- GSList *children;
-} ETableGroup;
-
-typedef struct {
- GnomeCanvasGroupClass parent_class;
- void (*height_changed) (ETableGroup *etg);
-} ETableGroupClass;
-
-GnomeCanvasItem *e_table_group_new (GnomeCanvasGroup *parent, ETableCol *ecol,
- gboolean open, gboolean transparent);
-void e_table_group_construct (GnomeCanvasGroup *parent, ETableGroup *etg,
- ETableCol *ecol, gboolean open, gboolean transparent);
-
-void e_table_group_add (ETableGroup *etg, GnomeCanvasItem *child);
-
-GtkType e_table_group_get_type (void);
-
-#endif /* _E_TABLE_TREE_H_ */
diff --git a/widgets/e-table/e-table-header-item.c b/widgets/e-table/e-table-header-item.c
deleted file mode 100644
index 5f23f06fa3..0000000000
--- a/widgets/e-table/e-table-header-item.c
+++ /dev/null
@@ -1,793 +0,0 @@
-/*
- * E-table-column-view.c: A canvas item based view of the ETableColumn.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * Copyright 1999, Helix Code, Inc.
- */
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkdnd.h>
-#include <libgnomeui/gnome-canvas.h>
-#include <libgnomeui/gnome-canvas-util.h>
-#include <libgnomeui/gnome-canvas-polygon.h>
-#include <libgnomeui/gnome-canvas-rect-ellipse.h>
-#include "e-util/e-cursors.h"
-#include "e-table-header.h"
-#include "e-table-header-item.h"
-#include "e-table-col-dnd.h"
-
-#include "add-col.xpm"
-#include "remove-col.xpm"
-
-/* Padding above and below of the string in the header display */
-#define PADDING 4
-
-/* Defines the tolerance for proximity of the column division to the cursor position */
-#define TOLERANCE 2
-
-#define ETHI_RESIZING(x) ((x)->resize_col != -1)
-
-#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type ()
-
-#define ELEMENTS(x) (sizeof (x) / sizeof (x[0]))
-
-static GnomeCanvasItemClass *ethi_parent_class;
-
-/*
- * DnD icons
- */
-static GdkColormap *dnd_colormap;
-static GdkPixmap *remove_col_pixmap, *remove_col_mask;
-static GdkPixmap *add_col_pixmap, *add_col_mask;
-
-enum {
- ARG_0,
- ARG_TABLE_HEADER,
- ARG_TABLE_X,
- ARG_TABLE_Y,
- ARG_TABLE_FONTSET
-};
-
-static GtkTargetEntry ethi_drag_types [] = {
- { TARGET_ETABLE_COL_TYPE, 0, TARGET_ETABLE_COL_HEADER },
-};
-
-static GtkTargetEntry ethi_drop_types [] = {
- { TARGET_ETABLE_COL_TYPE, 0, TARGET_ETABLE_COL_HEADER },
-};
-
-static void
-ethi_destroy (GtkObject *object)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (object);
-
- gtk_object_unref (GTK_OBJECT (ethi->eth));
-
- if (GTK_OBJECT_CLASS (ethi_parent_class)->destroy)
- (*GTK_OBJECT_CLASS (ethi_parent_class)->destroy) (object);
-}
-
-static void
-ethi_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
-
- if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update)
- (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update)(item, affine, clip_path, flags);
-
- item->x1 = ethi->x1;
- item->y1 = ethi->y1;
- item->x2 = ethi->x1 + ethi->width;
- item->y2 = ethi->y1 + ethi->height;
-
- gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
-}
-
-static void
-ethi_font_load (ETableHeaderItem *ethi, char *font)
-{
- if (ethi->font)
- gdk_font_unref (ethi->font);
-
- ethi->font = gdk_fontset_load (font);
- if (ethi->font == NULL)
- ethi->font = gdk_font_load ("fixed");
-
- ethi->height = ethi->font->ascent + ethi->font->descent + PADDING;
-}
-
-static void
-ethi_drop_table_header (ETableHeaderItem *ethi)
-{
- GtkObject *header;
-
- if (!ethi->eth)
- return;
-
- header = GTK_OBJECT (ethi->eth);
- gtk_signal_disconnect (header, ethi->structure_change_id);
- gtk_signal_disconnect (header, ethi->dimension_change_id);
-
- gtk_object_unref (header);
- ethi->eth = NULL;
- ethi->width = 0;
-}
-
-static void
-structure_changed (ETableHeader *header, ETableHeaderItem *ethi)
-{
- ethi->width = e_table_header_total_width (header);
-
- ethi_update (GNOME_CANVAS_ITEM (ethi), NULL, NULL, 0);
-}
-
-static void
-dimension_changed (ETableHeader *header, int col, ETableHeaderItem *ethi)
-{
- ethi->width = e_table_header_total_width (header);
-
- ethi_update (GNOME_CANVAS_ITEM (ethi), NULL, NULL, 0);
-}
-
-static void
-ethi_add_table_header (ETableHeaderItem *ethi, ETableHeader *header)
-{
- ethi->eth = header;
- gtk_object_ref (GTK_OBJECT (ethi->eth));
- ethi->width = e_table_header_total_width (header);
-
- ethi->structure_change_id = gtk_signal_connect (
- GTK_OBJECT (header), "structure_change",
- GTK_SIGNAL_FUNC(structure_changed), ethi);
- ethi->dimension_change_id = gtk_signal_connect (
- GTK_OBJECT (header), "dimension_change",
- GTK_SIGNAL_FUNC(dimension_changed), ethi);
-}
-
-static void
-ethi_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- ETableHeaderItem *ethi;
-
- item = GNOME_CANVAS_ITEM (o);
- ethi = E_TABLE_HEADER_ITEM (o);
-
- switch (arg_id){
- case ARG_TABLE_HEADER:
- ethi_drop_table_header (ethi);
- ethi_add_table_header (ethi, GTK_VALUE_POINTER (*arg));
- break;
-
- case ARG_TABLE_X:
- ethi->x1 = GTK_VALUE_INT (*arg);
- break;
-
- case ARG_TABLE_Y:
- ethi->y1 = GTK_VALUE_INT (*arg);
- break;
-
- case ARG_TABLE_FONTSET:
- ethi_font_load (ethi, GTK_VALUE_STRING (*arg));
- break;
-
- }
- ethi_update (item, NULL, NULL, 0);
-}
-
-static int
-ethi_find_col_by_x (ETableHeaderItem *ethi, int x)
-{
- const int cols = e_table_header_count (ethi->eth);
- int x1 = ethi->x1;
- int col;
-
- if (x < x1)
- return -1;
-
- for (col = 0; col < cols; col++){
- ETableCol *ecol = e_table_header_get_column (ethi->eth, col);
-
- if ((x >= x1) && (x <= x1 + ecol->width))
- return col;
-
- x1 += ecol->width;
- }
- return -1;
-}
-
-static void
-ethi_remove_drop_marker (ETableHeaderItem *ethi)
-{
- if (ethi->drag_mark == -1)
- return;
-
- ethi->drag_mark = -1;
- gtk_object_destroy (GTK_OBJECT (ethi->drag_mark_item));
- ethi->drag_mark_item = NULL;
-}
-
-static void
-ethi_add_drop_marker (ETableHeaderItem *ethi, int col)
-{
- GnomeCanvasPoints *points;
- int x;
-
- if (ethi->drag_mark == col)
- return;
-
- if (ethi->drag_mark_item)
- gtk_object_destroy (GTK_OBJECT (ethi->drag_mark_item));
-
- ethi->drag_mark = col;
-
- ethi->drag_mark_item = gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (GNOME_CANVAS_ITEM (ethi)->canvas->root),
- gnome_canvas_group_get_type (),
- "x", 0,
- "y", 0,
- NULL);
-
- points = gnome_canvas_points_new (3);
-
- x = e_table_header_col_diff (ethi->eth, 0, col);
-
- points->coords [0] = ethi->x1 + x - 5;
- points->coords [1] = ethi->y1;
- points->coords [2] = points->coords [0] + 10;
- points->coords [3] = points->coords [1];
- points->coords [4] = ethi->x1 + x;
- points->coords [5] = ethi->y1 + 5;
-
- gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (ethi->drag_mark_item),
- gnome_canvas_polygon_get_type (),
- "points", points,
- "fill_color", "red",
- NULL);
-
- points->coords [0] --;
- points->coords [1] += ethi->height - 1;
- points->coords [3] = points->coords [1];
- points->coords [5] = points->coords [1] - 6;
-
- gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (ethi->drag_mark_item),
- gnome_canvas_polygon_get_type (),
- "points", points,
- "fill_color", "red",
- NULL);
-
- gnome_canvas_points_unref (points);
-}
-
-#define gray50_width 2
-#define gray50_height 2
-static char gray50_bits [] = {
- 0x02, 0x01, };
-
-static void
-ethi_add_destroy_marker (ETableHeaderItem *ethi)
-{
- double x1;
-
- if (ethi->remove_item)
- gtk_object_destroy (GTK_OBJECT (ethi->remove_item));
-
- if (!ethi->stipple)
- ethi->stipple = gdk_bitmap_create_from_data (NULL, gray50_bits, gray50_width, gray50_height);
-
- x1 = ethi->x1 + (double) e_table_header_col_diff (ethi->eth, 0, ethi->drag_col);
- ethi->remove_item = gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (GNOME_CANVAS_ITEM (ethi)->canvas->root),
- gnome_canvas_rect_get_type (),
- "x1", x1 + 1,
- "y1", (double) ethi->y1 + 1,
- "x2", (double) x1 + e_table_header_col_diff (ethi->eth, ethi->drag_col, ethi->drag_col+1) - 2,
- "y2", (double) ethi->y1 + ethi->height - 2,
- "fill_color", "red",
- "fill_stipple", ethi->stipple,
- NULL);
-}
-
-static void
-ethi_remove_destroy_marker (ETableHeaderItem *ethi)
-{
- if (!ethi->remove_item)
- return;
-
- gtk_object_destroy (GTK_OBJECT (ethi->remove_item));
- ethi->remove_item = NULL;
-}
-
-static gboolean
-ethi_drag_motion (GtkObject *canvas, GdkDragContext *context,
- gint x, gint y, guint time,
- ETableHeaderItem *ethi)
-{
-
- if ((x >= ethi->x1) && (x <= (ethi->x1 + ethi->width)) &&
- (y >= ethi->y1) && (y <= (ethi->y1 + ethi->height))){
- int col;
-
- col = ethi_find_col_by_x (ethi, x);
-
- if (col != -1){
- ethi_remove_destroy_marker (ethi);
- ethi_add_drop_marker (ethi, col);
- } else {
- ethi_remove_drop_marker (ethi);
- ethi_add_destroy_marker (ethi);
- }
- } else {
- ethi_remove_drop_marker (ethi);
- ethi_add_destroy_marker (ethi);
- }
-
- gdk_drag_status (context, context->suggested_action, time);
-
- return TRUE;
-}
-
-static void
-ethi_drag_end (GtkWidget *canvas, GdkDragContext *context, ETableHeaderItem *ethi)
-{
- ethi_remove_drop_marker (ethi);
- ethi_remove_destroy_marker (ethi);
- ethi->drag_col = -1;
-}
-
-static void
-ethi_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, ETableHeaderItem *ethi)
-{
- ethi_remove_drop_marker (ethi);
- ethi_add_destroy_marker (ethi);
-}
-
-static void
-ethi_realize (GnomeCanvasItem *item)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
- GdkWindow *window;
- GdkColor c;
-
- if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)-> realize)
- (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->realize)(item);
-
- window = GTK_WIDGET (item->canvas)->window;
-
- ethi->gc = gdk_gc_new (window);
- gnome_canvas_get_color (item->canvas, "black", &c);
- gdk_gc_set_foreground (ethi->gc, &c);
-
- ethi->normal_cursor = gdk_cursor_new (GDK_ARROW);
-
- if (!ethi->font)
- ethi_font_load (ethi, "fixed");
-
- /*
- * Now, configure DnD
- */
- gtk_drag_dest_set (GTK_WIDGET (item->canvas), GTK_DEST_DEFAULT_ALL,
- ethi_drop_types, ELEMENTS (ethi_drop_types),
- GDK_ACTION_MOVE);
-
- ethi->drag_motion_id = gtk_signal_connect (
- GTK_OBJECT (item->canvas), "drag_motion",
- GTK_SIGNAL_FUNC (ethi_drag_motion), ethi);
-
- ethi->drag_leave_id = gtk_signal_connect (
- GTK_OBJECT (item->canvas), "drag_leave",
- GTK_SIGNAL_FUNC (ethi_drag_leave), ethi);
-
- ethi->drag_end_id = gtk_signal_connect (
- GTK_OBJECT (item->canvas), "drag_end",
- GTK_SIGNAL_FUNC (ethi_drag_end), ethi);
-}
-
-static void
-ethi_unrealize (GnomeCanvasItem *item)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
-
- gdk_gc_unref (ethi->gc);
- ethi->gc = NULL;
-
- gdk_cursor_destroy (ethi->normal_cursor);
- ethi->normal_cursor = NULL;
-
- gtk_signal_disconnect (GTK_OBJECT (item->canvas), ethi->drag_motion_id);
- gtk_signal_disconnect (GTK_OBJECT (item->canvas), ethi->drag_end_id);
- gtk_signal_disconnect (GTK_OBJECT (item->canvas), ethi->drag_leave_id);
-
- if (ethi->stipple){
- gdk_bitmap_unref (ethi->stipple);
- ethi->stipple = NULL;
- }
-
- if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->unrealize)
- (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->unrealize)(item);
-}
-
-static void
-draw_button (ETableHeaderItem *ethi, ETableCol *col,
- GdkDrawable *drawable, GdkGC *gc, GtkStyle *style,
- int x, int y, int width, int height)
-{
- GdkRectangle clip;
- int xtra;
-
- gdk_draw_rectangle (
- drawable, gc, TRUE,
- x + 1, y + 1, width - 2, height -2);
-
- gtk_draw_shadow (
- style, drawable,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- x , y, width, height);
-
- clip.x = x + 2;
- clip.y = y + 2;
- clip.width = width - 4;
- clip.height = ethi->height;
-
- gdk_gc_set_clip_rectangle (ethi->gc, &clip);
-
- /* Center the thing */
- xtra = (clip.width - gdk_string_measure (ethi->font, col->text))/2;
-
- if (xtra < 0)
- xtra = 0;
-
- /* Skip over border */
- x += xtra + 2;
-
- gdk_draw_text (
- drawable, ethi->font,
- ethi->gc, x, y + ethi->height - PADDING,
- col->text, strlen (col->text));
-}
-
-static void
-ethi_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
- GnomeCanvas *canvas = item->canvas;
- GdkGC *gc;
- const int cols = e_table_header_count (ethi->eth);
- int x1, x2;
- int col;
-
-#if 0
- printf ("My coords are: %g %g %g %g\n",
- item->x1, item->y1, item->x2, item->y2);
-#endif
- x1 = x2 = ethi->x1;
- for (col = 0; col < cols; col++, x1 = x2){
- ETableCol *ecol = e_table_header_get_column (ethi->eth, col);
- int col_width;
-
- if (col == ethi->resize_col)
- col_width = ethi->resize_width;
- else
- col_width = ecol->width;
-
- x2 += col_width;
-
- if (x1 > (x + width))
- break;
-
- if (x2 < x)
- continue;
-
- gc = GTK_WIDGET (canvas)->style->bg_gc [GTK_STATE_ACTIVE];
-
- draw_button (ethi, ecol, drawable, gc,
- GTK_WIDGET (canvas)->style,
- x1 - x, ethi->y1 - y, col_width, ethi->height);
- }
-}
-
-static double
-ethi_point (GnomeCanvasItem *item, double x, double y, int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- *actual_item = item;
- return 0.0;
-}
-
-/*
- * is_pointer_on_division:
- *
- * Returns whether @pos is a column header division; If @the_total is not NULL,
- * then the actual position is returned here. If @return_ecol is not NULL,
- * then the ETableCol that actually contains this point is returned here
- */
-static gboolean
-is_pointer_on_division (ETableHeaderItem *ethi, int pos, int *the_total, int *return_col)
-{
- const int cols = e_table_header_count (ethi->eth);
- int col, total;
-
- total = 0;
- for (col = 0; col < cols; col++){
- ETableCol *ecol = e_table_header_get_column (ethi->eth, col);
-
- total += ecol->width;
-
- if ((total - TOLERANCE < pos ) && (pos < total + TOLERANCE)){
- if (return_col)
- *return_col = col;
- if (the_total)
- *the_total = total;
-
- return TRUE;
- }
-
- if (total > pos + TOLERANCE)
- return FALSE;
- }
-
- return FALSE;
-}
-
-#define convert(c,sx,sy,x,y) gnome_canvas_w2c (c,sx,sy,x,y)
-
-static void
-set_cursor (ETableHeaderItem *ethi, int pos)
-{
- GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas);
-
- /* We might be invoked before we are realized */
- if (!canvas->window)
- return;
-
- if (is_pointer_on_division (ethi, pos, NULL, NULL))
- e_cursor_set (canvas->window, E_CURSOR_SIZE_X);
- else
- e_cursor_set (canvas->window, E_CURSOR_ARROW);
-}
-
-static void
-ethi_request_redraw (ETableHeaderItem *ethi)
-{
- GnomeCanvas *canvas = GNOME_CANVAS_ITEM (ethi)->canvas;
-
- /*
- * request a redraw
- */
- gnome_canvas_request_redraw (
- canvas, ethi->x1, ethi->y1, ethi->x1 + ethi->width, ethi->x1 + ethi->height);
-}
-
-static void
-ethi_end_resize (ETableHeaderItem *ethi, int new_size)
-{
- e_table_header_set_size (ethi->eth, ethi->resize_col, new_size);
-
- ethi->resize_col = -1;
- ethi_request_redraw (ethi);
-}
-
-static gboolean
-ethi_maybe_start_drag (ETableHeaderItem *ethi, GdkEventMotion *event)
-{
- if (!ethi->maybe_drag)
- return FALSE;
-
- if (MAX (abs (ethi->click_x - event->x),
- abs (ethi->click_y - event->y)) <= 3)
- return FALSE;
-
- return TRUE;
-}
-
-static void
-ethi_start_drag (ETableHeaderItem *ethi, GdkEvent *event)
-{
- GtkWidget *widget = GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas);
- GtkTargetList *list;
- GdkDragContext *context;
-
- ethi->drag_col = ethi_find_col_by_x (ethi, event->motion.x);
- if (ethi->drag_col == -1)
- return;
-
- list = gtk_target_list_new (ethi_drag_types, ELEMENTS (ethi_drag_types));
- context = gtk_drag_begin (widget, list, GDK_ACTION_MOVE, 1, event);
- ethi->maybe_drag = FALSE;
-}
-
-/*
- * Handles the events on the ETableHeaderItem, particularly it handles resizing
- */
-static int
-ethi_event (GnomeCanvasItem *item, GdkEvent *e)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
- GnomeCanvas *canvas = item->canvas;
- const gboolean resizing = ETHI_RESIZING (ethi);
- int x, y, start, col;
-
- switch (e->type){
- case GDK_ENTER_NOTIFY:
- convert (canvas, e->crossing.x, e->crossing.y, &x, &y);
- set_cursor (ethi, x);
- break;
-
- case GDK_LEAVE_NOTIFY:
- e_cursor_set (GTK_WIDGET (canvas)->window, E_CURSOR_ARROW);
- break;
-
- case GDK_MOTION_NOTIFY:
- convert (canvas, e->motion.x, e->motion.y, &x, &y);
- if (resizing){
- int new_width;
-
- if (ethi->resize_guide == NULL){
- /* Quick hack until I actually bind the views */
- ethi->resize_guide = GINT_TO_POINTER (1);
- gnome_canvas_item_grab (item,
- GDK_POINTER_MOTION_MASK |
- GDK_BUTTON_RELEASE_MASK,
- e_cursor_get (E_CURSOR_SIZE_X),
- e->button.time);
- }
-
- new_width = x - ethi->resize_start_pos;
- if (new_width <= 0)
- break;
-
- if (new_width < ethi->resize_min_width)
- break;
-
- ethi_request_redraw (ethi);
-
- ethi->resize_width = new_width;
- e_table_header_set_size (ethi->eth, ethi->resize_col, ethi->resize_width);
-
- ethi_request_redraw (ethi);
- } else if (ethi_maybe_start_drag (ethi, &e->motion)){
- ethi_start_drag (ethi, e);
- } else
- set_cursor (ethi, x);
- break;
-
- case GDK_BUTTON_PRESS:
- convert (canvas, e->button.x, e->button.y, &x, &y);
-
- if (is_pointer_on_division (ethi, x, &start, &col)){
- ETableCol *ecol;
-
- /*
- * Record the important bits.
- *
- * By setting resize_pos to a non -1 value,
- * we know that we are being resized (used in the
- * other event handlers).
- */
- ecol = e_table_header_get_column (ethi->eth, col);
-
- if (!ecol->resizeable)
- break;
- ethi->resize_col = col;
- ethi->resize_width = ecol->width;
- ethi->resize_start_pos = start - ecol->width;
- ethi->resize_min_width = ecol->min_width;
- } else {
- if (e->button.button == 1){
- ethi->click_x = e->button.x;
- ethi->click_y = e->button.y;
- ethi->maybe_drag = TRUE;
- }
- }
- break;
-
- case GDK_2BUTTON_PRESS:
- if (!resizing)
- break;
-
- if (e->button.button != 1)
- break;
- break;
-
- case GDK_BUTTON_RELEASE: {
- gboolean needs_ungrab = FALSE;
-
- if (ethi->resize_col != -1){
- needs_ungrab = (ethi->resize_guide != NULL);
- ethi_end_resize (ethi, ethi->resize_width);
- }
- if (needs_ungrab)
- gnome_canvas_item_ungrab (item, e->button.time);
-
- ethi->maybe_drag = FALSE;
- break;
- }
-
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-static void
-ethi_class_init (GtkObjectClass *object_class)
-{
- GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class;
-
- ethi_parent_class = gtk_type_class (PARENT_OBJECT_TYPE);
-
- object_class->destroy = ethi_destroy;
- object_class->set_arg = ethi_set_arg;
-
- item_class->update = ethi_update;
- item_class->realize = ethi_realize;
- item_class->unrealize = ethi_unrealize;
- item_class->draw = ethi_draw;
- item_class->point = ethi_point;
- item_class->event = ethi_event;
-
- gtk_object_add_arg_type ("ETableHeaderItem::ETableHeader", GTK_TYPE_POINTER,
- GTK_ARG_WRITABLE, ARG_TABLE_HEADER);
- gtk_object_add_arg_type ("ETableHeaderItem::x", GTK_TYPE_INT,
- GTK_ARG_WRITABLE, ARG_TABLE_X);
- gtk_object_add_arg_type ("ETableHeaderItem::y", GTK_TYPE_INT,
- GTK_ARG_WRITABLE, ARG_TABLE_Y);
- gtk_object_add_arg_type ("ETableHeaderItem::fontset", GTK_TYPE_STRING,
- GTK_ARG_WRITABLE, ARG_TABLE_FONTSET);
-
- /*
- * Create our pixmaps for DnD
- */
- dnd_colormap = gtk_widget_get_default_colormap ();
- remove_col_pixmap = gdk_pixmap_colormap_create_from_xpm_d (
- NULL, dnd_colormap,
- &remove_col_mask, NULL, remove_col_xpm);
-
- add_col_pixmap = gdk_pixmap_colormap_create_from_xpm_d (
- NULL, dnd_colormap,
- &add_col_mask, NULL, add_col_xpm);
-}
-
-static void
-ethi_init (GnomeCanvasItem *item)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
-
- ethi->resize_col = -1;
-
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = 0;
- item->y2 = 0;
-
- ethi->drag_col = -1;
- ethi->drag_mark = -1;
-}
-
-GtkType
-e_table_header_item_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableHeaderItem",
- sizeof (ETableHeaderItem),
- sizeof (ETableHeaderItemClass),
- (GtkClassInitFunc) ethi_class_init,
- (GtkObjectInitFunc) ethi_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (PARENT_OBJECT_TYPE, &info);
- }
-
- return type;
-}
-
diff --git a/widgets/e-table/e-table-header-item.h b/widgets/e-table/e-table-header-item.h
deleted file mode 100644
index 5522d24fae..0000000000
--- a/widgets/e-table/e-table-header-item.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef _E_TABLE_HEADER_ITEM_H_
-#define _E_TABLE_HEADER_ITEM_H_
-
-#include <libgnomeui/gnome-canvas.h>
-#include "e-table-header.h"
-
-#define E_TABLE_HEADER_ITEM_TYPE (e_table_header_item_get_type ())
-#define E_TABLE_HEADER_ITEM(o) (GTK_CHECK_CAST ((o), E_TABLE_HEADER_ITEM_TYPE, ETableHeaderItem))
-#define E_TABLE_HEADER_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_HEADER_ITEM_TYPE, ETableHeaderItemClass))
-#define E_IS_TABLE_HEADER_ITEM(o) (GTK_CHECK_TYPE ((o), E_TABLE_HEADER_ITEM_TYPE))
-#define E_IS_TABLE_HEADER_ITEM_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_HEADER_ITEM_TYPE))
-
-typedef struct {
- GnomeCanvasItem parent;
- ETableHeader *eth;
-
- GdkGC *gc;
- GdkCursor *change_cursor, *normal_cursor;
-
- short x1, y1, height, width;
- GdkFont *font;
-
- /*
- * Used during resizing; Could be shorts
- */
- int resize_col;
- int resize_width;
- int resize_start_pos;
- int resize_min_width;
-
- GtkObject *resize_guide;
-
- /*
- * Ids
- */
- int structure_change_id, dimension_change_id;
-
- /*
- * For dragging columns
- */
- guint maybe_drag:1;
- guint dnd_ready:1;
- int click_x, click_y;
- int drag_col, drag_mark;
- guint drag_motion_id, drag_end_id, drag_leave_id;
- GnomeCanvasItem *drag_mark_item, *remove_item;
- GdkBitmap *stipple;
-} ETableHeaderItem;
-
-typedef struct {
- GnomeCanvasItemClass parent_class;
-} ETableHeaderItemClass;
-
-GtkType e_table_header_item_get_type (void);
-
-#endif /* _E_TABLE_HEADER_ITEM_H_ */
diff --git a/widgets/e-table/e-table-header.c b/widgets/e-table/e-table-header.c
deleted file mode 100644
index 7c54bd936e..0000000000
--- a/widgets/e-table/e-table-header.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * E-table-col-head.c: TableColHead implementation
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include <gtk/gtkobject.h>
-#include <gtk/gtksignal.h>
-#include "e-table-header.h"
-
-enum {
- STRUCTURE_CHANGE,
- DIMENSION_CHANGE,
- LAST_SIGNAL
-};
-
-static guint eth_signals [LAST_SIGNAL] = { 0, };
-
-static GtkObjectClass *e_table_header_parent_class;
-
-static void
-e_table_header_destroy (GtkObject *object)
-{
- ETableHeader *eth = E_TABLE_HEADER (object);
- const int cols = eth->col_count;
- int i;
-
- /*
- * Destroy columns
- */
- for (i = 0; i < cols; i++){
- e_table_header_remove (eth, i);
- }
-
- if (e_table_header_parent_class->destroy)
- e_table_header_parent_class->destroy (object);
-}
-
-static void
-e_table_header_class_init (GtkObjectClass *object_class)
-{
- object_class->destroy = e_table_header_destroy;
-
- e_table_header_parent_class = (gtk_type_class (gtk_object_get_type ()));
-
- eth_signals [STRUCTURE_CHANGE] =
- gtk_signal_new ("structure_change",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableHeaderClass, structure_change),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
- eth_signals [DIMENSION_CHANGE] =
- gtk_signal_new ("dimension_change",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableHeaderClass, dimension_change),
- gtk_marshal_NONE__INT,
- GTK_TYPE_NONE, 1, GTK_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, eth_signals, LAST_SIGNAL);
-}
-
-GtkType
-e_table_header_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableHeader",
- sizeof (ETableHeader),
- sizeof (ETableHeaderClass),
- (GtkClassInitFunc) e_table_header_class_init,
- (GtkObjectInitFunc) NULL,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (gtk_object_get_type (), &info);
- }
-
- return type;
-}
-
-ETableHeader *
-e_table_header_new (void)
-{
- ETableHeader *eth;
-
- eth = gtk_type_new (e_table_header_get_type ());
-
- return eth;
-}
-
-static void
-eth_do_insert (ETableHeader *eth, int pos, ETableCol *val)
-{
- memcpy (&eth->columns [pos+1], &eth->columns [pos],
- sizeof (ETableCol *) * (eth->col_count - pos));
- eth->columns [pos] = val;
-}
-
-static void
-eth_update_offsets (ETableHeader *eth)
-{
- int i;
- int x = 0;
-
- for (i = 0; i < eth->col_count; i++){
- ETableCol *etc = eth->columns [i];
-
- etc->x = x;
- x += etc->width;
- }
-}
-
-void
-e_table_header_add_column (ETableHeader *eth, ETableCol *tc, int pos)
-{
- g_return_if_fail (eth != NULL);
- g_return_if_fail (E_IS_TABLE_HEADER (eth));
- g_return_if_fail (tc != NULL);
- g_return_if_fail (E_IS_TABLE_COL (tc));
- g_return_if_fail (pos >= -1 && pos <= eth->col_count);
-
- if (pos == -1)
- pos = eth->col_count;
- eth->columns = g_realloc (eth->columns, sizeof (ETableCol *) * (eth->col_count + 1));
-
- /*
- * We are the primary owners of the column
- */
- gtk_object_ref (GTK_OBJECT (tc));
- gtk_object_sink (GTK_OBJECT (tc));
-
- eth_do_insert (eth, pos, tc);
- eth->col_count++;
- eth_update_offsets (eth);
-
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
-}
-
-ETableCol *
-e_table_header_get_column (ETableHeader *eth, int column)
-{
- g_return_val_if_fail (eth != NULL, NULL);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), NULL);
-
- if (column < 0)
- return NULL;
-
- if (column >= eth->col_count)
- return NULL;
-
- return eth->columns [column];
-}
-
-int
-e_table_header_count (ETableHeader *eth)
-{
- g_return_val_if_fail (eth != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0);
-
- return eth->col_count;
-}
-
-int
-e_table_header_index (ETableHeader *eth, int col)
-{
- g_return_val_if_fail (eth != NULL, -1);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), -1);
- g_return_val_if_fail (col < eth->col_count, -1);
-
- return eth->columns [col]->col_idx;
-}
-
-int
-e_table_header_get_index_at (ETableHeader *eth, int x_offset)
-{
- int i, total;
-
- g_return_val_if_fail (eth != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0);
-
- total = 0;
- for (i = 0; i < eth->col_count; i++){
- total += eth->columns [i]->width;
-
- if (x_offset < total)
- return i;
- }
-
- return -1;
-}
-
-ETableCol **
-e_table_header_get_columns (ETableHeader *eth)
-{
- ETableCol **ret;
-
- g_return_val_if_fail (eth != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0);
-
- ret = g_new (ETableCol *, eth->col_count + 1);
- memcpy (ret, eth->columns, sizeof (ETableCol *) * eth->col_count);
- ret [eth->col_count] = NULL;
-
- return ret;
-}
-
-gboolean
-e_table_header_selection_ok (ETableHeader *eth)
-{
- g_return_val_if_fail (eth != NULL, FALSE);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), FALSE);
-
- return eth->selectable;
-}
-
-int
-e_table_header_get_selected (ETableHeader *eth)
-{
- int i;
- int selected = 0;
-
- g_return_val_if_fail (eth != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0);
-
- for (i = 0; i < eth->col_count; i++){
- if (eth->columns [i]->selected)
- selected++;
- }
-
- return selected;
-}
-
-int
-e_table_header_total_width (ETableHeader *eth)
-{
- int total, i;
-
- g_return_val_if_fail (eth != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0);
-
- total = 0;
- for (i = 0; i < eth->col_count; i++)
- total += eth->columns [i]->width;
-
- return total;
-}
-
-static void
-eth_do_remove (ETableHeader *eth, int idx, gboolean do_unref)
-{
- if (do_unref)
- gtk_object_unref (GTK_OBJECT (eth->columns [idx]));
-
- memcpy (&eth->columns [idx], &eth->columns [idx+1],
- sizeof (ETableCol *) * eth->col_count - idx);
- eth->col_count--;
-}
-
-void
-e_table_header_move (ETableHeader *eth, int source_index, int target_index)
-{
- ETableCol *old;
-
- g_return_if_fail (eth != NULL);
- g_return_if_fail (E_IS_TABLE_HEADER (eth));
- g_return_if_fail (source_index >= 0);
- g_return_if_fail (target_index >= 0);
- g_return_if_fail (source_index < eth->col_count);
- g_return_if_fail (target_index < eth->col_count);
-
- old = eth->columns [source_index];
- eth_do_remove (eth, source_index, FALSE);
- eth_do_insert (eth, target_index, old);
- eth_update_offsets (eth);
-
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
-}
-
-void
-e_table_header_remove (ETableHeader *eth, int idx)
-{
- g_return_if_fail (eth != NULL);
- g_return_if_fail (E_IS_TABLE_HEADER (eth));
- g_return_if_fail (idx >= 0);
- g_return_if_fail (idx < eth->col_count);
-
- eth_do_remove (eth, idx, TRUE);
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
-}
-
-void
-e_table_header_set_selection (ETableHeader *eth, gboolean allow_selection)
-{
-}
-
-void
-e_table_header_set_size (ETableHeader *eth, int idx, int size)
-{
- g_return_if_fail (eth != NULL);
- g_return_if_fail (E_IS_TABLE_HEADER (eth));
- g_return_if_fail (idx >= 0);
- g_return_if_fail (idx < eth->col_count);
- g_return_if_fail (size > 0);
-
- eth->columns [idx]->width = size;
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE], idx);
-}
-
-int
-e_table_header_col_diff (ETableHeader *eth, int start_col, int end_col)
-{
- int total, col;
-
- g_return_val_if_fail (eth != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0);
-
- {
- const int max_col = eth->col_count;
-
- total = 0;
- for (col = start_col; col < end_col; col++){
-
- if (col == max_col)
- break;
- total += eth->columns [col]->width;
- }
- }
-
- return total;
-}
diff --git a/widgets/e-table/e-table-header.h b/widgets/e-table/e-table-header.h
deleted file mode 100644
index 96e65fdc2f..0000000000
--- a/widgets/e-table/e-table-header.h
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef _E_TABLE_COLUMN_H_
-#define _E_TABLE_COLUMN_H_
-
-#include <gtk/gtkobject.h>
-#include <gdk/gdk.h>
-#include "e-table-col.h"
-
-typedef struct _ETableHeader ETableHeader;
-
-#define E_TABLE_HEADER_TYPE (e_table_header_get_type ())
-#define E_TABLE_HEADER(o) (GTK_CHECK_CAST ((o), E_TABLE_HEADER_TYPE, ETableHeader))
-#define E_TABLE_HEADER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_HEADER_TYPE, ETableHeaderClass))
-#define E_IS_TABLE_HEADER(o) (GTK_CHECK_TYPE ((o), E_TABLE_HEADER_TYPE))
-#define E_IS_TABLE_HEADER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_HEADER_TYPE))
-
-/*
- * A Columnar header.
- */
-struct _ETableHeader {
- GtkObject base;
-
- int col_count;
- ETableCol **columns;
- gboolean selectable;
-};
-
-typedef struct {
- GtkObjectClass parent_class;
-
- void (*structure_change) (ETableHeader *eth);
- void (*dimension_change) (ETableHeader *eth, int col);
-} ETableHeaderClass;
-
-GtkType e_table_header_get_type (void);
-ETableHeader *e_table_header_new (void);
-
-void e_table_header_add_column (ETableHeader *eth,
- ETableCol *tc, int pos);
-ETableCol * e_table_header_get_column (ETableHeader *eth,
- int column);
-int e_table_header_count (ETableHeader *eth);
-int e_table_header_index (ETableHeader *eth,
- int col);
-int e_table_header_get_index_at (ETableHeader *eth,
- int x_offset);
-ETableCol **e_table_header_get_columns (ETableHeader *eth);
-gboolean e_table_header_selection_ok (ETableHeader *eth);
-int e_table_header_get_selected (ETableHeader *eth);
-int e_table_header_total_width (ETableHeader *eth);
-void e_table_header_move (ETableHeader *eth,
- int source_index,
- int target_index);
-void e_table_header_remove (ETableHeader *eth, int idx);
-void e_table_header_set_size (ETableHeader *eth, int idx, int size);
-void e_table_header_set_selection (ETableHeader *eth,
- gboolean allow_selection);
-
-int e_table_header_col_diff (ETableHeader *eth,
- int start_col, int end_col);
-
-GList *e_table_header_get_selected_indexes(ETableHeader *eth);
-
-
-#endif /* _E_TABLE_HEADER_H_ */
-
diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c
deleted file mode 100644
index 33f0c18616..0000000000
--- a/widgets/e-table/e-table-item.c
+++ /dev/null
@@ -1,1316 +0,0 @@
-/*
- * E-table-item.c: A GnomeCanvasItem that is a view of an ETableModel.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * TODO:
- * Add a border to the thing, so that focusing works properly.
- *
- */
-#include <config.h>
-#include <stdio.h>
-#include <gtk/gtksignal.h>
-#include <gdk/gdkkeysyms.h>
-#include <math.h>
-#include "e-table-item.h"
-#include "e-cell.h"
-
-#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type ()
-
-#define FOCUSED_BORDER 2
-
-static GnomeCanvasItemClass *eti_parent_class;
-
-enum {
- ROW_SELECTION,
- HEIGHT_CHANGED,
- LAST_SIGNAL
-};
-
-static gint eti_signals [LAST_SIGNAL] = { 0, };
-
-enum {
- ARG_0,
- ARG_TABLE_HEADER,
- ARG_TABLE_MODEL,
- ARG_TABLE_X,
- ARG_TABLE_Y,
- ARG_TABLE_DRAW_GRID,
- ARG_TABLE_DRAW_FOCUS,
- ARG_MODE_SPREADSHEET,
- ARG_LENGHT_THRESHOLD
-};
-
-static gboolean
-eti_editing (ETableItem *eti)
-{
- if (eti->editing_col == -1)
- return FALSE;
- else
- return TRUE;
-}
-
-/*
- * During realization, we have to invoke the per-ecell realize routine
- * (On our current setup, we have one e-cell per column.
- *
- * We might want to optimize this to only realize the unique e-cells:
- * ie, a strings-only table, uses the same e-cell for every column, and
- * we might want to avoid realizing each e-cell.
- */
-static void
-eti_realize_cell_views (ETableItem *eti)
-{
- int i;
-
- for (i = 0; i < eti->n_cells; i++)
- e_cell_view_realize (eti->cell_views [i], eti);
- eti->cell_views_realized = 1;
-}
-
-static void eti_compute_height (ETableItem *eti);
-
-static void
-eti_attach_cell_views (ETableItem *eti)
-{
- int i;
-
- g_assert (eti->header);
- g_assert (eti->table_model);
-
- /*
- * Now realize the various ECells
- */
- eti->n_cells = eti->cols;
- eti->cell_views = g_new (ECellView *, eti->n_cells);
-
- for (i = 0; i < eti->n_cells; i++){
- ETableCol *col = e_table_header_get_column (eti->header, i);
-
- eti->cell_views [i] = e_cell_new_view (col->ecell, eti->table_model, eti);
- }
-
- eti_compute_height (eti);
-}
-
-/*
- * During unrealization: we invoke every e-cell (one per column in the current
- * setup) to dispose all X resources allocated
- */
-static void
-eti_unrealize_cell_views (ETableItem *eti)
-{
- int i;
-
- if (eti->cell_views_realized == 0)
- return;
-
- for (i = 0; i < eti->n_cells; i++)
- e_cell_unrealize (eti->cell_views [i]);
- eti->cell_views_realized = 0;
-}
-
-static void
-eti_detach_cell_views (ETableItem *eti)
-{
- int i;
-
- for (i = 0; i < eti->n_cells; i++){
- e_cell_kill_view (eti->cell_views [i]);
- eti->cell_views [i] = NULL;
- }
-
- g_free (eti->cell_views);
- eti->cell_views = NULL;
- eti->n_cells = 0;
-}
-
-static void
-eti_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
-{
- double i2c [6];
- ArtPoint c1, c2, i1, i2;
- ETableItem *eti = E_TABLE_ITEM (item);
-
- gnome_canvas_item_i2c_affine (item, i2c);
- i1.x = eti->x1;
- i1.y = eti->y1;
- i2.x = eti->x1 + eti->width;
- i2.y = eti->y1 + eti->height;
- art_affine_point (&c1, &i1, i2c);
- art_affine_point (&c2, &i2, i2c);
-
- item->x1 = c1.x;
- item->y1 = c1.y;
- item->x2 = c2.x;
- item->y2 = c2.y;
-}
-
-
-/*
- * GnomeCanvasItem::update method
- */
-static void
-eti_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)
- (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)(item, affine, clip_path, flags);
-
- eti_bounds (item, &item->x1, &item->y1, &item->x2, &item->y2);
- gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
-}
-
-/*
- * eti_remove_table_model:
- *
- * Invoked to release the table model associated with this ETableItem
- */
-static void
-eti_remove_table_model (ETableItem *eti)
-{
- if (!eti->table_model)
- return;
-
- gtk_signal_disconnect (GTK_OBJECT (eti->table_model),
- eti->table_model_change_id);
- gtk_signal_disconnect (GTK_OBJECT (eti->table_model),
- eti->table_model_row_change_id);
- gtk_object_unref (GTK_OBJECT (eti->table_model));
-
- eti->table_model_change_id = 0;
- eti->table_model_row_change_id = 0;
- eti->table_model = NULL;
-}
-
-/*
- * eti_remove_header_model:
- *
- * Invoked to release the header model associated with this ETableItem
- */
-static void
-eti_remove_header_model (ETableItem *eti)
-{
- if (!eti->header)
- return;
-
- gtk_signal_disconnect (GTK_OBJECT (eti->header),
- eti->header_structure_change_id);
- gtk_signal_disconnect (GTK_OBJECT (eti->header),
- eti->header_dim_change_id);
-
- if (eti->cell_views){
- eti_unrealize_cell_views (eti);
- eti_detach_cell_views (eti);
- }
- gtk_object_unref (GTK_OBJECT (eti->header));
-
-
- eti->header_structure_change_id = 0;
- eti->header_dim_change_id = 0;
- eti->header = NULL;
-}
-
-/*
- * eti_row_height:
- *
- * Returns the height used by row @row. This does not include the one-pixel
- * used as a separator between rows
- */
-static int
-eti_row_height (ETableItem *eti, int row)
-{
- const int cols = e_table_header_count (eti->header);
- int col;
- int h, max_h;
-
- g_assert (eti->cell_views);
-
- max_h = 0;
-
- for (col = 0; col < cols; col++){
- ETableCol *ecol = e_table_header_get_column (eti->header, col);
-
- h = e_cell_height (eti->cell_views [col], ecol->col_idx, col, row);
-
- if (h > max_h)
- max_h = h;
- }
- return max_h;
-}
-
-/*
- * eti_get_height:
- *
- * Returns the height of the ETableItem.
- *
- * The ETableItem might compute the whole height by asking every row its
- * size. There is a special mode (designed to work when there are too
- * many rows in the table that performing the previous step could take
- * too long) set by the ETableItem->length_threshold that would determine
- * when the height is computed by using the first row as the size for
- * every other row in the ETableItem.
- */
-static int
-eti_get_height (ETableItem *eti)
-{
- const int rows = eti->rows;
- int row;
- int height;
-
- if (rows == 0)
- return 0;
-
- if (eti->length_threshold != -1){
- if (rows > eti->length_threshold){
- height = (eti_row_height (eti, 0) + 1) * rows;
-
- /*
- * 1 pixel at the top
- */
- return height + 1;
- }
- }
-
- height = 1;
- for (row = 0; row < rows; row++)
- height += eti_row_height (eti, row) + 1;
-
- return height;
-}
-
-static void
-eti_compute_height (ETableItem *eti)
-{
- int new_height = eti_get_height (eti);
-
- if (new_height != eti->height){
- double x1, y1, x2, y2;
- printf ("Emitting!\n");
-
- eti->height = new_height;
- eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0);
-
- gtk_signal_emit (GTK_OBJECT (eti), eti_signals [HEIGHT_CHANGED]);
- }
-}
-
-/*
- * Callback routine: invoked when the ETableModel has suffered a change
- */
-static void
-eti_table_model_changed (ETableModel *table_model, ETableItem *eti)
-{
- eti->rows = e_table_model_row_count (eti->table_model);
-
- if (eti->cell_views)
- eti_compute_height (eti);
-
- eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0);
-}
-
-static void
-eti_item_region_redraw (ETableItem *eti, int x0, int y0, int x1, int y1)
-{
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti);
- ArtDRect rect;
- double i2c [6];
-
- rect.x0 = x0;
- rect.y0 = y0;
- rect.x1 = x1;
- rect.y1 = y1;
-
- gnome_canvas_item_i2c_affine (item, i2c);
- art_drect_affine_transform (&rect, &rect, i2c);
-
- gnome_canvas_request_redraw (item->canvas, rect.x0, rect.y0, rect.x1, rect.y1);
-}
-
-/*
- * eti_request_redraw:
- *
- * Queues a canvas redraw for the entire ETableItem.
- */
-static void
-eti_request_redraw (ETableItem *eti)
-{
- eti_item_region_redraw (eti, eti->x1, eti->y1, eti->x1 + eti->width + 1, eti->y1 + eti->height + 1);
-}
-
-/*
- * Computes the distance between @start_row and @end_row in pixels
- */
-static int
-eti_row_diff (ETableItem *eti, int start_row, int end_row)
-{
- int row, total;
-
- total = 0;
-
- for (row = start_row; row < end_row; row++)
- total += eti_row_height (eti, row) + 1;
-
- return total;
-}
-
-/*
- * eti_request_region_redraw:
- *
- * Request a canvas redraw on the range (start_col, start_row) to (end_col, end_row).
- * This is inclusive (ie, you can use: 0,0-0,0 to redraw the first cell).
- *
- * The @border argument is a number of pixels around the region that should also be queued
- * for redraw. This is typically used by the focus routines to queue a redraw for the
- * border as well.
- */
-static void
-eti_request_region_redraw (ETableItem *eti,
- int start_col, int start_row,
- int end_col, int end_row, int border)
-{
- int x1, y1, width, height;
-
- x1 = e_table_header_col_diff (eti->header, 0, start_col);
- y1 = eti_row_diff (eti, 0, start_row);
- width = e_table_header_col_diff (eti->header, start_col, end_col + 1);
- height = eti_row_diff (eti, start_row, end_row + 1);
-
- eti_item_region_redraw (eti, eti->x1 + x1 - border,
- eti->y1 + y1 - border,
- eti->x1 + x1 + width + 1 + border,
- eti->y1 + y1 + height + 1 + border);
-}
-
-static void
-eti_table_model_row_changed (ETableModel *table_model, int row, ETableItem *eti)
-{
- if (eti->renderers_can_change_size){
- eti_table_model_changed (table_model, eti);
- return;
- }
-
- eti_request_region_redraw (eti, 0, row, eti->cols, row, 0);
-}
-
-void
-e_table_item_redraw_range (ETableItem *eti,
- int start_col, int start_row,
- int end_col, int end_row)
-{
- int border;
-
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- if ((start_col == eti->focused_col) ||
- (end_col == eti->focused_col) ||
- (start_row == eti->focused_row) ||
- (end_row == eti->focused_row))
- border = 2;
- else
- border = 0;
-
- eti_request_region_redraw (eti, start_col, start_row, end_col, end_row, border);
-}
-
-static void
-eti_add_table_model (ETableItem *eti, ETableModel *table_model)
-{
- g_assert (eti->table_model == NULL);
-
- eti->table_model = table_model;
- gtk_object_ref (GTK_OBJECT (eti->table_model));
-
- eti->table_model_change_id = gtk_signal_connect (
- GTK_OBJECT (table_model), "model_changed",
- GTK_SIGNAL_FUNC (eti_table_model_changed), eti);
-
- eti->table_model_row_change_id = gtk_signal_connect (
- GTK_OBJECT (table_model), "model_row_changed",
- GTK_SIGNAL_FUNC (eti_table_model_row_changed), eti);
-
- if (eti->header){
- eti_detach_cell_views (eti);
- eti_attach_cell_views (eti);
- }
-
- eti_table_model_changed (table_model, eti);
-}
-
-static void
-eti_header_dim_changed (ETableHeader *eth, int col, ETableItem *eti)
-{
- eti_request_redraw (eti);
-
- eti->width = e_table_header_total_width (eti->header);
- eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0);
-
- eti_request_redraw (eti);
-}
-
-static void
-eti_header_structure_changed (ETableHeader *eth, ETableItem *eti)
-{
- eti_request_redraw (eti);
-
- eti->cols = e_table_header_count (eti->header);
- eti->width = e_table_header_total_width (eti->header);
-
- if (eti->cell_views){
- eti_unrealize_cell_views (eti);
- eti_detach_cell_views (eti);
- eti_attach_cell_views (eti);
- eti_realize_cell_views (eti);
- } else {
- if (eti->table_model){
- eti_detach_cell_views (eti);
- eti_attach_cell_views (eti);
- }
- }
-
- eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0);
-
- eti_request_redraw (eti);
-}
-
-static void
-eti_add_header_model (ETableItem *eti, ETableHeader *header)
-{
- g_assert (eti->header == NULL);
-
- eti->header = header;
- gtk_object_ref (GTK_OBJECT (header));
-
- eti_header_structure_changed (header, eti);
-
- eti->header_dim_change_id = gtk_signal_connect (
- GTK_OBJECT (header), "dimension_change",
- GTK_SIGNAL_FUNC (eti_header_dim_changed), eti);
-
- eti->header_structure_change_id = gtk_signal_connect (
- GTK_OBJECT (header), "structure_change",
- GTK_SIGNAL_FUNC (eti_header_structure_changed), eti);
-}
-
-/*
- * GtkObject::destroy method
- */
-static void
-eti_destroy (GtkObject *object)
-{
- ETableItem *eti = E_TABLE_ITEM (object);
-
- eti_remove_header_model (eti);
- eti_remove_table_model (eti);
-
- g_slist_free (eti->selection);
-
- if (GTK_OBJECT_CLASS (eti_parent_class)->destroy)
- (*GTK_OBJECT_CLASS (eti_parent_class)->destroy) (object);
-}
-
-static void
-eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- ETableItem *eti;
-
- item = GNOME_CANVAS_ITEM (o);
- eti = E_TABLE_ITEM (o);
-
- switch (arg_id){
- case ARG_TABLE_HEADER:
- eti_remove_header_model (eti);
- eti_add_header_model (eti, GTK_VALUE_POINTER (*arg));
- break;
-
- case ARG_TABLE_MODEL:
- eti_remove_table_model (eti);
- eti_add_table_model (eti, GTK_VALUE_POINTER (*arg));
- break;
-
- case ARG_TABLE_X:
- eti->x1 = GTK_VALUE_DOUBLE (*arg);
- break;
-
- case ARG_TABLE_Y:
- eti->y1 = GTK_VALUE_DOUBLE (*arg);
- break;
-
- case ARG_LENGHT_THRESHOLD:
- eti->length_threshold = GTK_VALUE_INT (*arg);
- break;
-
- case ARG_TABLE_DRAW_GRID:
- eti->draw_grid = GTK_VALUE_BOOL (*arg);
- break;
-
- case ARG_TABLE_DRAW_FOCUS:
- eti->draw_focus = GTK_VALUE_BOOL (*arg);
- break;
-
- case ARG_MODE_SPREADSHEET:
- eti->mode_spreadsheet = GTK_VALUE_BOOL (*arg);
- break;
- }
- eti_update (item, NULL, NULL, 0);
-}
-
-static void
-eti_init (GnomeCanvasItem *item)
-{
- ETableItem *eti = E_TABLE_ITEM (item);
-
- eti->focused_col = -1;
- eti->focused_row = -1;
- eti->editing_col = -1;
- eti->editing_row = -1;
- eti->height = 0;
-
- eti->length_threshold = -1;
- eti->renderers_can_change_size = 0;
-
- eti->selection_mode = GTK_SELECTION_SINGLE;
-}
-
-#define gray50_width 2
-#define gray50_height 2
-static const char gray50_bits[] = {
- 0x02, 0x01, };
-
-static void
-eti_realize (GnomeCanvasItem *item)
-{
- ETableItem *eti = E_TABLE_ITEM (item);
- GtkWidget *canvas_widget = GTK_WIDGET (item->canvas);
- GdkWindow *window;
-
- if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize)
- (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize)(item);
-
- /*
- * Gdk Resource allocation
- */
- window = canvas_widget->window;
-
- eti->fill_gc = canvas_widget->style->white_gc;
- gdk_gc_ref (canvas_widget->style->white_gc);
-
- eti->grid_gc = gdk_gc_new (window);
-#if 0
- /* This sets it to gray */
-/* gdk_gc_set_foreground (eti->grid_gc, &canvas_widget->style->bg [GTK_STATE_NORMAL]); */
-#else
- gdk_gc_set_foreground (eti->grid_gc, &canvas_widget->style->black);
-#endif
- eti->focus_gc = gdk_gc_new (window);
- gdk_gc_set_foreground (eti->focus_gc, &canvas_widget->style->bg [GTK_STATE_NORMAL]);
- gdk_gc_set_background (eti->focus_gc, &canvas_widget->style->fg [GTK_STATE_NORMAL]);
- eti->stipple = gdk_bitmap_create_from_data (NULL, gray50_bits, gray50_width, gray50_height);
- gdk_gc_set_ts_origin (eti->focus_gc, 0, 0);
- gdk_gc_set_stipple (eti->focus_gc, eti->stipple);
- gdk_gc_set_fill (eti->focus_gc, GDK_OPAQUE_STIPPLED);
-
- if (eti->cell_views == NULL)
- eti_attach_cell_views (eti);
-
- eti_realize_cell_views (eti);
-
- eti_compute_height (eti);
-
- eti_update (item, NULL, NULL, 0);
-}
-
-static void
-eti_unrealize (GnomeCanvasItem *item)
-{
- ETableItem *eti = E_TABLE_ITEM (item);
-
- gdk_gc_unref (eti->fill_gc);
- eti->fill_gc = NULL;
- gdk_gc_unref (eti->grid_gc);
- eti->grid_gc = NULL;
- gdk_gc_unref (eti->focus_gc);
- eti->focus_gc = NULL;
- gdk_bitmap_unref (eti->stipple);
- eti->stipple = NULL;
-
- eti_unrealize_cell_views (eti);
-
- eti->height = 0;
-
- if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->unrealize)
- (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->unrealize)(item);
-}
-
-static void
-eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height)
-{
- ETableItem *eti = E_TABLE_ITEM (item);
- const int rows = eti->rows;
- const int cols = eti->cols;
- int row, col, y1, y2;
- int first_col, last_col, x_offset;
- int first_row, last_row, y_offset, yd;
- int x1, x2;
- int f_x1, f_x2, f_y1, f_y2;
- gboolean f_found;
- double i2c [6];
- ArtPoint eti_base, eti_base_item;
-
- /*
- * Clear the background
- */
-#if 0
- gdk_draw_rectangle (
- drawable, eti->fill_gc, TRUE,
- eti->x1 - x, eti->y1 - y, eti->width, eti->height);
-#endif
-
- /*
- * Find out our real position after grouping
- */
- gnome_canvas_item_i2c_affine (item, i2c);
- eti_base_item.x = eti->x1;
- eti_base_item.y = eti->y1;
- art_affine_point (&eti_base, &eti_base_item, i2c);
-
- /*
- * First column to draw, last column to draw
- */
- first_col = -1;
- last_col = x_offset = 0;
- x1 = x2 = floor (eti_base.x);
- for (col = 0; col < cols; col++, x1 = x2){
- ETableCol *ecol = e_table_header_get_column (eti->header, col);
-
- x2 = x1 + ecol->width;
-
- if (x1 > (x + width))
- break;
- if (x2 < x)
- continue;
- if (first_col == -1){
- x_offset = x1 - x;
- first_col = col;
- }
- }
- last_col = col;
-
- /*
- * Nothing to paint
- */
- if (first_col == -1)
- return;
-
- /*
- * Compute row span.
- */
- first_row = -1;
- y_offset = 0;
- y1 = y2 = floor (eti_base.y) + 1;
- for (row = 0; row < rows; row++, y1 = y2){
-
- y2 += eti_row_height (eti, row) + 1;
-
- if (y1 > y + height)
- break;
-
- if (y2 < y)
- continue;
-
- if (first_row == -1){
- y_offset = y1 - y;
- first_row = row;
- }
- }
- last_row = row;
-
- if (first_row == -1)
- return;
-
- /*
- * Draw cells
- */
- yd = y_offset;
- f_x1 = f_x2 = f_y1 = f_y2 = -1;
- f_found = FALSE;
-
- if (eti->draw_grid && first_row == 0){
- gdk_draw_line (
- drawable, eti->grid_gc,
- eti_base.x - x, yd, eti_base.x + eti->width - x, yd);
- }
- yd++;
-
- for (row = first_row; row < last_row; row++){
- int xd, height;
- gboolean selected;
-
- height = eti_row_height (eti, row);
-
- xd = x_offset;
-/* printf ("paint: %d %d\n", yd, yd + height); */
-
- selected = g_slist_find (eti->selection, GINT_TO_POINTER (row)) != NULL;
-
- for (col = first_col; col < last_col; col++){
- ETableCol *ecol = e_table_header_get_column (eti->header, col);
- ECellView *ecell_view = eti->cell_views [col];
-
- e_cell_draw (ecell_view, drawable, ecol->col_idx, col, row, selected,
- xd, yd, xd + ecol->width, yd + height);
-
- if (col == eti->focused_col && row == eti->focused_row){
- f_x1 = xd;
- f_x2 = xd + ecol->width;
- f_y1 = yd;
- f_y2 = yd + height;
- f_found = TRUE;
- }
-
- xd += ecol->width;
- }
- yd += height;
-
- if (eti->draw_grid)
- gdk_draw_line (
- drawable, eti->grid_gc,
- eti_base.x - x, yd, eti_base.x + eti->width - x, yd);
- yd++;
- }
-
- if (eti->draw_grid){
- int xd = x_offset;
-
- for (col = first_col; col <= last_col; col++){
- ETableCol *ecol = e_table_header_get_column (eti->header, col);
-
- gdk_draw_line (
- drawable, eti->grid_gc,
- xd, y_offset, xd, yd - 1);
-
- /*
- * This looks wierd, but it is to draw the last line
- */
- if (ecol)
- xd += ecol->width;
- }
- }
-
- /*
- * Draw focus
- */
- if (f_found && eti->draw_focus){
-
- if (!eti_editing (eti))
- gdk_draw_rectangle (
- drawable, eti->focus_gc, FALSE,
- f_x1 + 1, f_y1, f_x2 - f_x1 - 2, f_y2 - f_y1 - 1);
- }
-}
-
-static double
-eti_point (GnomeCanvasItem *item, double x, double y, int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- *actual_item = item;
-
- return 0.0;
-}
-
-static gboolean
-find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, double *x1_res, double *y1_res)
-{
- const int cols = eti->cols;
- const int rows = eti->rows;
- gdouble x1, y1, x2, y2;
- int col, row;
-
- /* FIXME: this routine is inneficient, fix later */
-
- x -= eti->x1;
- y -= eti->y1;
-
- x1 = 0;
- for (col = 0; col < cols; col++, x1 = x2){
- ETableCol *ecol = e_table_header_get_column (eti->header, col);
-
- if (x < x1)
- return FALSE;
-
- x2 = x1 + ecol->width;
-
- if (x > x2)
- continue;
-
- *col_res = col;
- if (x1_res)
- *x1_res = x - x1;
- break;
- }
-
- y1 = y2 = 0;
- for (row = 0; row < rows; row++, y1 = y2){
- if (y < y1)
- return FALSE;
-
- y2 += eti_row_height (eti, row) + 1;
-
- if (y > y2)
- continue;
-
- *row_res = row;
- if (y1_res)
- *y1_res = y - y1;
- break;
- }
-
- return TRUE;
-}
-
-static void
-eti_cursor_move_left (ETableItem *eti)
-{
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->focused_col - 1, eti->focused_row);
-}
-
-static void
-eti_cursor_move_right (ETableItem *eti)
-{
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->focused_col + 1, eti->focused_row);
-}
-
-static void
-eti_cursor_move_up (ETableItem *eti)
-{
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->focused_col, eti->focused_row - 1);
-}
-
-static void
-eti_cursor_move_down (ETableItem *eti)
-{
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->focused_col, eti->focused_row + 1);
-}
-
-static int
-eti_event (GnomeCanvasItem *item, GdkEvent *e)
-{
- ETableItem *eti = E_TABLE_ITEM (item);
- ECellView *ecell_view;
- ETableCol *ecol;
-
- switch (e->type){
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- case GDK_2BUTTON_PRESS: {
- double x1, y1;
- int col, row;
-
- gnome_canvas_item_w2i (item, &e->button.x, &e->button.y);
-
- if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1))
- return TRUE;
-
- if (eti->focused_row == row && eti->focused_col == col){
-
- ecol = e_table_header_get_column (eti->header, col);
- ecell_view = eti->cell_views [col];
-
- /*
- * Adjust the event positions
- */
- e->button.x = x1;
- e->button.y = y1;
-
- e_cell_event (ecell_view, e, ecol->col_idx, col, row);
- } else {
- /*
- * Focus the cell, and select the row
- */
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, col, row);
- e_table_item_select_row (eti, row);
- }
- break;
- }
-
- case GDK_MOTION_NOTIFY: {
- int col, row;
- double x1, y1;
-
- gnome_canvas_item_w2i (item, &e->button.x, &e->button.y);
-
- if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1))
- return TRUE;
-
- if (eti->focused_row == row && eti->focused_col == col){
- ecol = e_table_header_get_column (eti->header, col);
- ecell_view = eti->cell_views [col];
-
- /*
- * Adjust the event positions
- */
- e->button.x -= (x1 + eti->x1);
- e->button.y -= (y1 + eti->y1);
-
- e_cell_event (ecell_view, e, ecol->col_idx, col, row);
- }
- break;
- }
-
- case GDK_KEY_PRESS:
- if (eti->focused_col == -1)
- return FALSE;
-
- switch (e->key.keyval){
- case GDK_Left:
- if (!eti->mode_spreadsheet && eti_editing (eti))
- break;
-
- if (eti->focused_col > 0)
- eti_cursor_move_left (eti);
-
- return TRUE;
-
- case GDK_Right:
- if (!eti->mode_spreadsheet && eti_editing (eti))
- break;
-
- if ((eti->focused_col + 1) < eti->cols)
- eti_cursor_move_right (eti);
- return TRUE;
-
- case GDK_Up:
- if (eti->focused_row > 0)
- eti_cursor_move_up (eti);
- return TRUE;
-
- case GDK_Down:
- if ((eti->focused_row + 1) < eti->rows)
- eti_cursor_move_down (eti);
-
- return TRUE;
-
- case GDK_Tab:
- if ((e->key.state & GDK_SHIFT_MASK) != 0){
- /* shift tab */
- if (eti->focused_col > 0)
- eti_cursor_move_left (eti);
- else if (eti->focused_row > 0){
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->cols - 1, eti->focused_row - 1);
- } else {
- /* FIXME: request focus leave backward */
- }
- } else {
- if ((eti->focused_col + 1) < eti->cols)
- eti_cursor_move_right (eti);
- else if ((eti->focused_row + 1) < eti->rows){
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, 0, eti->rows - 1);
- } else {
- /* FIXME: request focus leave forward */
- }
- }
- break;
-
- default:
- if (!eti_editing (eti)){
- if ((e->key.state & (GDK_MOD1_MASK | GDK_CONTROL_MASK)) != 0)
- return 0;
-
- if (!(e->key.keyval >= 0x20 && e->key.keyval <= 0xff))
- return 0;
- }
- }
-
- ecol = e_table_header_get_column (eti->header, eti->focused_col);
- ecell_view = eti->cell_views [eti->focused_col];
- e_cell_event (ecell_view, e, ecol->col_idx, eti->focused_col, eti->focused_row);
- break;
-
- case GDK_KEY_RELEASE:
- if (eti->focused_col == -1)
- return FALSE;
-
- if (eti_editing (eti)){
- ecell_view = eti->cell_views [eti->editing_col];
- ecol = e_table_header_get_column (eti->header, eti->editing_col);
- e_cell_event (ecell_view, e, ecol->col_idx, eti->editing_col, eti->editing_row);
- }
- break;
-
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-/*
- * ETableItem::row_selection method
- */
-static void
-eti_row_selection (ETableItem *eti, int row, gboolean selected)
-{
- eti_request_region_redraw (eti, 0, row, eti->cols - 1, row, 0);
-
- if (selected)
- eti->selection = g_slist_prepend (eti->selection, GINT_TO_POINTER (row));
- else
- eti->selection = g_slist_remove (eti->selection, GINT_TO_POINTER (row));
-
-}
-
-static void
-eti_class_init (GtkObjectClass *object_class)
-{
- GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class;
- ETableItemClass *eti_class = (ETableItemClass *) object_class;
-
- eti_parent_class = gtk_type_class (PARENT_OBJECT_TYPE);
-
- object_class->destroy = eti_destroy;
- object_class->set_arg = eti_set_arg;
-
- item_class->update = eti_update;
- item_class->realize = eti_realize;
- item_class->unrealize = eti_unrealize;
- item_class->draw = eti_draw;
- item_class->point = eti_point;
- item_class->event = eti_event;
- item_class->bounds = eti_bounds;
-
- eti_class->row_selection = eti_row_selection;
-
- gtk_object_add_arg_type ("ETableItem::ETableHeader", GTK_TYPE_POINTER,
- GTK_ARG_WRITABLE, ARG_TABLE_HEADER);
- gtk_object_add_arg_type ("ETableItem::ETableModel", GTK_TYPE_POINTER,
- GTK_ARG_WRITABLE, ARG_TABLE_MODEL);
- gtk_object_add_arg_type ("ETableItem::x", GTK_TYPE_DOUBLE,
- GTK_ARG_WRITABLE, ARG_TABLE_X);
- gtk_object_add_arg_type ("ETableItem::y", GTK_TYPE_DOUBLE,
- GTK_ARG_WRITABLE, ARG_TABLE_Y);
- gtk_object_add_arg_type ("ETableItem::drawgrid", GTK_TYPE_BOOL,
- GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID);
- gtk_object_add_arg_type ("ETableItem::drawfocus", GTK_TYPE_BOOL,
- GTK_ARG_WRITABLE, ARG_TABLE_DRAW_FOCUS);
- gtk_object_add_arg_type ("ETableItem::spreadsheet", GTK_TYPE_BOOL,
- GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET);
-
- eti_signals [ROW_SELECTION] =
- gtk_signal_new ("row_selection",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableItemClass, row_selection),
- gtk_marshal_NONE__INT_INT,
- GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
-
- eti_signals [HEIGHT_CHANGED] =
- gtk_signal_new ("height_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableItemClass, height_changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, eti_signals, LAST_SIGNAL);
-
-}
-
-GtkType
-e_table_item_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableItem",
- sizeof (ETableItem),
- sizeof (ETableItemClass),
- (GtkClassInitFunc) eti_class_init,
- (GtkObjectInitFunc) eti_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (PARENT_OBJECT_TYPE, &info);
- }
-
- return type;
-}
-
-void
-e_table_item_focus (ETableItem *eti, int col, int row)
-{
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- if (eti->focused_col != -1)
- e_table_item_unfocus (eti);
-
- eti->focused_col = col;
- eti->focused_row = row;
-
- eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER);
-
- /*
- * make sure we have the Gtk Focus
- */
- gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (eti));
-}
-
-void
-e_table_item_unfocus (ETableItem *eti)
-{
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- if (eti->focused_row == -1)
- return;
-
- {
- const int col = eti->focused_col;
- const int row = eti->focused_row;
-
- eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER);
- }
- eti->focused_col = -1;
- eti->focused_row = -1;
-}
-
-const GSList *
-e_table_item_get_selection (ETableItem *eti)
-{
- g_return_val_if_fail (eti != NULL, NULL);
- g_return_val_if_fail (E_IS_TABLE_ITEM (eti), NULL);
-
- return eti->selection;
-}
-
-GtkSelectionMode
-e_table_item_get_selection_mode (ETableItem *eti)
-{
- g_return_val_if_fail (eti != NULL, GTK_SELECTION_SINGLE);
- g_return_val_if_fail (E_IS_TABLE_ITEM (eti), GTK_SELECTION_SINGLE);
-
- return eti->selection_mode;
-}
-
-void
-e_table_item_set_selection_mode (ETableItem *eti, GtkSelectionMode selection_mode)
-{
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- if (selection_mode == GTK_SELECTION_BROWSE ||
- selection_mode == GTK_SELECTION_EXTENDED){
- g_error ("GTK_SELECTION_BROWSE and GTK_SELECTION_EXTENDED are not implemented");
- }
-
- eti->selection_mode = selection_mode;
-}
-
-gboolean
-e_table_item_is_row_selected (ETableItem *eti, int row)
-{
- g_return_val_if_fail (eti != NULL, FALSE);
- g_return_val_if_fail (E_IS_TABLE_ITEM (eti), FALSE);
-
- if (g_slist_find (eti->selection, GINT_TO_POINTER (row)))
- return TRUE;
- else
- return FALSE;
-}
-
-void
-e_table_item_unselect_row (ETableItem *eti, int row)
-{
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- if (e_table_item_is_row_selected (eti, row)){
- gtk_signal_emit (
- GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
- row, 0);
- }
-}
-
-void
-e_table_item_select_row (ETableItem *eti, int row)
-{
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- switch (eti->selection_mode){
- case GTK_SELECTION_SINGLE:
- if (eti->selection){
- gtk_signal_emit (
- GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
- GPOINTER_TO_INT (eti->selection->data), 0);
- }
- g_slist_free (eti->selection);
- eti->selection = NULL;
-
- gtk_signal_emit (
- GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
- GINT_TO_POINTER (row), 1);
- break;
-
- case GTK_SELECTION_MULTIPLE:
- if (g_slist_find (eti->selection, GINT_TO_POINTER (row)))
- return;
- gtk_signal_emit (
- GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
- GINT_TO_POINTER (row), 1);
- break;
-
- default:
-
- }
-}
-
-void
-e_table_item_enter_edit (ETableItem *eti, int col, int row)
-{
- ETableCol *ecol;
-
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- eti->editing_col = col;
- eti->editing_row = row;
-
- ecol = e_table_header_get_column (eti->header, col);
- eti->edit_ctx = e_cell_enter_edit (eti->cell_views [col], ecol->col_idx, col, row);
-}
-
-void
-e_table_item_leave_edit (ETableItem *eti)
-{
- ETableCol *ecol;
-
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- if (!eti_editing (eti))
- return;
-
- ecol = e_table_header_get_column (eti->header, eti->editing_col);
- e_cell_leave_edit (
- eti->cell_views [eti->editing_col],
- ecol->col_idx, eti->editing_col,
- eti->editing_row, eti->edit_ctx);
- eti->editing_col = -1;
- eti->editing_row = -1;
- eti->edit_ctx = NULL;
-}
-
diff --git a/widgets/e-table/e-table-item.h b/widgets/e-table/e-table-item.h
deleted file mode 100644
index f19819f2fc..0000000000
--- a/widgets/e-table/e-table-item.h
+++ /dev/null
@@ -1,106 +0,0 @@
-#ifndef _E_TABLE_ITEM_H_
-#define _E_TABLE_ITEM_H_
-
-#include <libgnomeui/gnome-canvas.h>
-#include "e-table-model.h"
-#include "e-table-header.h"
-
-#define E_TABLE_ITEM_TYPE (e_table_item_get_type ())
-#define E_TABLE_ITEM(o) (GTK_CHECK_CAST ((o), E_TABLE_ITEM_TYPE, ETableItem))
-#define E_TABLE_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_ITEM_TYPE, ETableItemClass))
-#define E_IS_TABLE_ITEM(o) (GTK_CHECK_TYPE ((o), E_TABLE_ITEM_TYPE))
-#define E_IS_TABLE_ITEM_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_ITEM_TYPE))
-
-typedef struct {
- GnomeCanvasItem parent;
- ETableModel *table_model;
- ETableHeader *header;
-
- int x1, y1;
- int width, height;
-
- int cols, rows;
-
- /*
- * Ids for the signals we connect to
- */
- int header_dim_change_id;
- int header_structure_change_id;
- int table_model_change_id;
- int table_model_row_change_id;
-
- GdkGC *fill_gc;
- GdkGC *grid_gc;
- GdkGC *focus_gc;
- GdkBitmap *stipple;
-
- unsigned int draw_grid:1;
- unsigned int draw_focus:1;
- unsigned int mode_spreadsheet:1;
- unsigned int renderers_can_change_size:1;
- unsigned int cell_views_realized:1;
-
- int focused_col, focused_row;
-
- /*
- * Realized views, per column
- */
- ECellView **cell_views;
- int n_cells;
-
- /*
- * Lengh Threshold: above this, we stop computing correctly
- * the size
- */
- int length_threshold;
-
- GSList *selection;
- GtkSelectionMode selection_mode;
-
- /*
- * During edition
- */
- int editing_col, editing_row;
- void *edit_ctx;
-} ETableItem;
-
-typedef struct {
- GnomeCanvasItemClass parent_class;
-
- void (*row_selection) (ETableItem *eti, int row, gboolean selected);
- void (*height_changed) (ETableItem *eti);
-} ETableItemClass;
-
-GtkType e_table_item_get_type (void);
-
-/*
- * Focus
- */
-void e_table_item_focus (ETableItem *eti, int col, int row);
-void e_table_item_unfocus (ETableItem *eti);
-
-/*
- * Selection
- */
-void e_table_item_select_row (ETableItem *e_table_Item, int row);
-void e_table_item_unselect_row (ETableItem *e_table_Item, int row);
-
-/*
- * Handling the selection
- */
-const GSList*e_table_item_get_selection (ETableItem *e_table_Item);
-
-GtkSelectionMode e_table_item_get_selection_mode (ETableItem *e_table_Item);
-void e_table_item_set_selection_mode (ETableItem *e_table_Item,
- GtkSelectionMode selection_mode);
-gboolean e_table_item_is_row_selected (ETableItem *e_table_Item,
- int row);
-
-void e_table_item_leave_edit (ETableItem *eti);
-void e_table_item_enter_edit (ETableItem *eti, int col, int row);
-
-void e_table_item_redraw_range (ETableItem *eti,
- int start_col, int start_row,
- int end_col, int end_row);
-
-#endif /* _E_TABLE_ITEM_H_ */
diff --git a/widgets/e-table/e-table-model.c b/widgets/e-table/e-table-model.c
deleted file mode 100644
index 9e397710ef..0000000000
--- a/widgets/e-table/e-table-model.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * e-table-model.c: a Table Model
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc.
- */
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include "e-table-model.h"
-
-#define ETM_CLASS(e) ((ETableModelClass *)((GtkObject *)e)->klass)
-
-static GtkObjectClass *e_table_model_parent_class;
-
-enum {
- MODEL_CHANGED,
- MODEL_ROW_CHANGED,
- MODEL_CELL_CHANGED,
- ROW_SELECTION,
- LAST_SIGNAL
-};
-
-static guint e_table_model_signals [LAST_SIGNAL] = { 0, };
-
-int
-e_table_model_column_count (ETableModel *e_table_model)
-{
- g_return_val_if_fail (e_table_model != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), 0);
-
- return ETM_CLASS (e_table_model)->column_count (e_table_model);
-}
-
-
-int
-e_table_model_row_count (ETableModel *e_table_model)
-{
- g_return_val_if_fail (e_table_model != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), 0);
-
- return ETM_CLASS (e_table_model)->row_count (e_table_model);
-}
-
-void *
-e_table_model_value_at (ETableModel *e_table_model, int col, int row)
-{
- g_return_val_if_fail (e_table_model != NULL, NULL);
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), NULL);
-
- return ETM_CLASS (e_table_model)->value_at (e_table_model, col, row);
-}
-
-void
-e_table_model_set_value_at (ETableModel *e_table_model, int col, int row, const void *data)
-{
- g_return_if_fail (e_table_model != NULL);
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
-
- ETM_CLASS (e_table_model)->set_value_at (e_table_model, col, row, data);
-
- gtk_signal_emit (GTK_OBJECT (e_table_model),
- e_table_model_signals [MODEL_ROW_CHANGED], row);
- gtk_signal_emit (GTK_OBJECT (e_table_model),
- e_table_model_signals [MODEL_CELL_CHANGED], col, row);
-
- /*
- * Notice that "model_changed" is not emitted
- */
-}
-
-gboolean
-e_table_model_is_cell_editable (ETableModel *e_table_model, int col, int row)
-{
- g_return_val_if_fail (e_table_model != NULL, FALSE);
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), FALSE);
-
- return ETM_CLASS (e_table_model)->is_cell_editable (e_table_model, col, row);
-}
-
-static void
-e_table_model_destroy (GtkObject *object)
-{
- if (e_table_model_parent_class->destroy)
- (*e_table_model_parent_class->destroy)(object);
-}
-
-static void
-e_table_model_class_init (GtkObjectClass *object_class)
-{
- e_table_model_parent_class = gtk_type_class (gtk_object_get_type ());
-
- object_class->destroy = e_table_model_destroy;
-
- e_table_model_signals [MODEL_CHANGED] =
- gtk_signal_new ("model_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableModelClass, model_changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- e_table_model_signals [MODEL_ROW_CHANGED] =
- gtk_signal_new ("model_row_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableModelClass, model_row_changed),
- gtk_marshal_NONE__INT,
- GTK_TYPE_NONE, 1, GTK_TYPE_INT);
-
- e_table_model_signals [MODEL_CELL_CHANGED] =
- gtk_signal_new ("model_cell_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableModelClass, model_cell_changed),
- gtk_marshal_NONE__INT_INT,
- GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, e_table_model_signals, LAST_SIGNAL);
-}
-
-GtkType
-e_table_model_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableModel",
- sizeof (ETableModel),
- sizeof (ETableModelClass),
- (GtkClassInitFunc) e_table_model_class_init,
- (GtkObjectInitFunc) NULL,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (gtk_object_get_type (), &info);
- }
-
- return type;
-}
-
-void
-e_table_model_changed (ETableModel *e_table_model)
-{
- g_return_if_fail (e_table_model != NULL);
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
-
- gtk_signal_emit (GTK_OBJECT (e_table_model),
- e_table_model_signals [MODEL_CHANGED]);
-}
-
-void
-e_table_model_row_changed (ETableModel *e_table_model, int row)
-{
- g_return_if_fail (e_table_model != NULL);
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
-
- gtk_signal_emit (GTK_OBJECT (e_table_model),
- e_table_model_signals [MODEL_ROW_CHANGED], row);
-}
-
-void
-e_table_model_cell_changed (ETableModel *e_table_model, int col, int row)
-{
- g_return_if_fail (e_table_model != NULL);
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
-
- gtk_signal_emit (GTK_OBJECT (e_table_model),
- e_table_model_signals [MODEL_CELL_CHANGED], col, row);
-}
-
-
diff --git a/widgets/e-table/e-table-model.h b/widgets/e-table/e-table-model.h
deleted file mode 100644
index 2d08f3744e..0000000000
--- a/widgets/e-table/e-table-model.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef _E_TABLE_MODEL_H_
-#define _E_TABLE_MODEL_H_
-
-#include <gtk/gtkobject.h>
-
-#define E_TABLE_MODEL_TYPE (e_table_model_get_type ())
-#define E_TABLE_MODEL(o) (GTK_CHECK_CAST ((o), E_TABLE_MODEL_TYPE, ETableModel))
-#define E_TABLE_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_MODEL_TYPE, ETableModelClass))
-#define E_IS_TABLE_MODEL(o) (GTK_CHECK_TYPE ((o), E_TABLE_MODEL_TYPE))
-#define E_IS_TABLE_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_MODEL_TYPE))
-
-typedef struct {
- GtkObject base;
-} ETableModel;
-
-typedef struct {
- GtkObjectClass parent_class;
-
- /*
- * Virtual methods
- */
- int (*column_count) (ETableModel *etm);
- int (*row_count) (ETableModel *etm);
- void *(*value_at) (ETableModel *etm, int col, int row);
- void (*set_value_at) (ETableModel *etm, int col, int row, const void *value);
- gboolean (*is_cell_editable) (ETableModel *etm, int col, int row);
-
- /*
- * Signals
- */
-
- /*
- * Major structural changes: model_changed
- * Changes only in a row: row_changed
- * Only changes in a cell: cell_changed
- */
- void (*model_changed) (ETableModel *etm);
- void (*model_row_changed) (ETableModel *etm, int row);
- void (*model_cell_changed) (ETableModel *etm, int col, int row);
-} ETableModelClass;
-
-GtkType e_table_model_get_type (void);
-
-int e_table_model_column_count (ETableModel *e_table_model);
-const char *e_table_model_column_name (ETableModel *e_table_model, int col);
-int e_table_model_row_count (ETableModel *e_table_model);
-void *e_table_model_value_at (ETableModel *e_table_model, int col, int row);
-void e_table_model_set_value_at (ETableModel *e_table_model, int col, int row, const void *data);
-gboolean e_table_model_is_cell_editable (ETableModel *e_table_model, int col, int row);
-
-/*
- * Routines for emitting signals on the e_table
- */
-void e_table_model_changed (ETableModel *e_table_model);
-void e_table_model_row_changed (ETableModel *e_table_model, int row);
-void e_table_model_cell_changed (ETableModel *e_table_model, int col, int row);
-
-#endif /* _E_TABLE_MODEL_H_ */
diff --git a/widgets/e-table/e-table-render.c b/widgets/e-table/e-table-render.c
deleted file mode 100644
index 49d742132b..0000000000
--- a/widgets/e-table/e-table-render.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * E-table-render.c: Various renderers
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * Copyright 1999, Helix Code, Inc.
- */
-#include <config.h>
-#include "e-table-header.h"
-#include "e-table-header-item.h"
-#include "e-table-col.h"
-#include "e-table-render.h"
-
-void
-e_table_render_string (ERenderContext *ctxt)
-{
- printf ("Rendering string: %s\n", ctxt->render_data);
-}
-
diff --git a/widgets/e-table/e-table-render.h b/widgets/e-table/e-table-render.h
deleted file mode 100644
index ebc65968f0..0000000000
--- a/widgets/e-table/e-table-render.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef E_TABLE_RENDER_H
-#define E_TABLE_RENDER_H
-
-#include <libgnomeui/gnome-canvas.h>
-
-struct ERenderContext {
- ETableCol *etc;
- int row;
- int base_x, base_y;
- GnomeCanvasItem *gnome_canvas_item;
- GdkDrawable *drawable;
- int drawable_width;
- int drawable_height;
- void *render_data;
- void *closure;
-};
-
-void e_table_render_string (ERenderContext *ctxt);
-
-
-#endif
diff --git a/widgets/e-table/e-table-simple.c b/widgets/e-table/e-table-simple.c
deleted file mode 100644
index 38e1dd8eb0..0000000000
--- a/widgets/e-table/e-table-simple.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * e-table-model.c: a simple table model implementation that uses function
- * pointers to simplify the creation of new, exotic and colorful tables in
- * no time.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc.
- */
-
-#include <config.h>
-#include "e-table-simple.h"
-
-#define PARENT_TYPE e_table_model_get_type()
-
-static int
-simple_column_count (ETableModel *etm)
-{
- ETableSimple *simple = (ETableSimple *)etm;
-
- return simple->col_count (etm, simple->data);
-}
-
-static int
-simple_row_count (ETableModel *etm)
-{
- ETableSimple *simple = (ETableSimple *)etm;
-
- return simple->row_count (etm, simple->data);
-}
-
-static void *
-simple_value_at (ETableModel *etm, int col, int row)
-{
- ETableSimple *simple = (ETableSimple *)etm;
-
- return simple->value_at (etm, col, row, simple->data);
-}
-
-static void
-simple_set_value_at (ETableModel *etm, int col, int row, const void *val)
-{
- ETableSimple *simple = (ETableSimple *)etm;
-
- simple->set_value_at (etm, col, row, val, simple->data);
-}
-
-static gboolean
-simple_is_cell_editable (ETableModel *etm, int col, int row)
-{
- ETableSimple *simple = (ETableSimple *)etm;
-
- return simple->is_cell_editable (etm, col, row, simple->data);
-}
-
-static void
-e_table_simple_class_init (GtkObjectClass *object_class)
-{
- ETableModelClass *model_class = (ETableModelClass *) object_class;
-
- model_class->column_count = simple_column_count;
- model_class->row_count = simple_row_count;
- model_class->value_at = simple_value_at;
- model_class->set_value_at = simple_set_value_at;
- model_class->is_cell_editable = simple_is_cell_editable;
-}
-
-GtkType
-e_table_simple_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableSimple",
- sizeof (ETableSimple),
- sizeof (ETableSimpleClass),
- (GtkClassInitFunc) e_table_simple_class_init,
- (GtkObjectInitFunc) NULL,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (PARENT_TYPE, &info);
- }
-
- return type;
-}
-
-ETableModel *
-e_table_simple_new (ETableSimpleColumnCountFn col_count,
- ETableSimpleRowCountFn row_count,
- ETableSimpleValueAtFn value_at,
- ETableSimpleSetValueAtFn set_value_at,
- ETableSimpleIsCellEditableFn is_cell_editable,
- void *data)
-{
- ETableSimple *et;
-
- et = gtk_type_new (e_table_simple_get_type ());
-
- et->col_count = col_count;
- et->row_count = row_count;
- et->value_at = value_at;
- et->set_value_at = set_value_at;
- et->is_cell_editable = is_cell_editable;
- et->data = data;
-
- return (ETableModel *) et;
-}
diff --git a/widgets/e-table/e-table-simple.h b/widgets/e-table/e-table-simple.h
deleted file mode 100644
index d890245386..0000000000
--- a/widgets/e-table/e-table-simple.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _E_TABLE_SIMPLE_H_
-#define _E_TABLE_SIMPLE_H_
-
-#include "e-table-model.h"
-
-typedef int (*ETableSimpleColumnCountFn) (ETableModel *etm, void *data);
-typedef int (*ETableSimpleRowCountFn) (ETableModel *etm, void *data);
-typedef void *(*ETableSimpleValueAtFn) (ETableModel *etm, int col, int row, void *data);
-typedef void (*ETableSimpleSetValueAtFn) (ETableModel *etm, int col, int row, const void *val, void *data);
-typedef gboolean (*ETableSimpleIsCellEditableFn) (ETableModel *etm, int col, int row, void *data);
-
-typedef struct {
- ETableModel parent;
-
- ETableSimpleColumnCountFn col_count;
- ETableSimpleRowCountFn row_count;
- ETableSimpleValueAtFn value_at;
- ETableSimpleSetValueAtFn set_value_at;
- ETableSimpleIsCellEditableFn is_cell_editable;
- void *data;
-} ETableSimple;
-
-typedef struct {
- ETableModelClass parent_class;
-} ETableSimpleClass;
-
-GtkType e_table_simple_get_type (void);
-
-ETableModel *e_table_simple_new (ETableSimpleColumnCountFn col_count,
- ETableSimpleRowCountFn row_count,
- ETableSimpleValueAtFn value_at,
- ETableSimpleSetValueAtFn set_value_at,
- ETableSimpleIsCellEditableFn is_cell_editable,
- void *data);
-
-#endif /* _E_TABLE_SIMPLE_H_ */
-
diff --git a/widgets/e-table/e-table-sorted.c b/widgets/e-table/e-table-sorted.c
deleted file mode 100644
index 16644a45b1..0000000000
--- a/widgets/e-table/e-table-sorted.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * E-table-sorted.c: Implements a table that sorts another table
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc.
- */
-#include <config.h>
-#include <stdlib.h>
-#include "e-util/e-util.h"
-#include "e-table-sorted.h"
-
-#define PARENT_TYPE E_TABLE_SUBSET_TYPE
-
-static ETableModelClass *ets_parent_class;
-
-static void
-ets_class_init (GtkObjectClass *klass)
-{
- ets_parent_class = gtk_type_class (PARENT_TYPE);
-}
-
-E_MAKE_TYPE(e_table_sorted, "ETableSorted", ETableSorted, ets_class_init, NULL, PARENT_TYPE);
-
-static ETableSorted *sort_ets;
-
-static int
-my_sort (const void *a, const void *b)
-{
- ETableModel *source = E_TABLE_SUBSET (sort_ets)->source;
- const int *ia = (const int *) a;
- const int *ib = (const int *) b;
- void *va, *vb;
-
- va = e_table_model_value_at (source, sort_ets->sort_col, *ia);
- vb = e_table_model_value_at (source, sort_ets->sort_col, *ib);
-
- return (*sort_ets->compare) (va, vb);
-}
-
-static void
-do_sort (ETableSorted *ets)
-{
- ETableSubset *etss = E_TABLE_SUBSET (ets);
- g_assert (sort_ets == NULL);
-
- sort_ets = ets;
- qsort (etss->map_table, etss->n_map, sizeof (unsigned int), my_sort);
- sort_ets = NULL;
-}
-
-ETableModel *
-e_table_sorted_new (ETableModel *source, int col, GCompareFunc compare)
-{
- ETableSorted *ets = gtk_type_new (E_TABLE_SORTED_TYPE);
- ETableSubset *etss = E_TABLE_SUBSET (ets);
- const int nvals = e_table_model_row_count (source);
- int i;
-
- if (e_table_subset_construct (etss, source, nvals) == NULL){
- gtk_object_destroy (GTK_OBJECT (ets));
- return NULL;
- }
-
- ets->compare = compare;
- ets->sort_col = col;
-
- /* Init */
- for (i = 0; i < nvals; i++)
- etss->map_table [i] = i;
-
- do_sort (ets);
-
- return (ETableModel *) ets;
-}
-
-void
-e_table_sorted_resort (ETableSorted *ets, int col, GCompareFunc compare)
-{
- if (col == -1 || compare == NULL)
- do_sort (ets);
- else {
- ets->sort_col = col;
- ets->compare = compare;
- do_sort (ets);
- }
-}
-
diff --git a/widgets/e-table/e-table-sorted.h b/widgets/e-table/e-table-sorted.h
deleted file mode 100644
index 2ec52df2e7..0000000000
--- a/widgets/e-table/e-table-sorted.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef _E_TABLE_SORTED_H_
-#define _E_TABLE_SORTED_H_
-
-#include <gtk/gtkobject.h>
-#include "e-table-model.h"
-#include "e-table-subset.h"
-
-#define E_TABLE_SORTED_TYPE (e_table_sorted_get_type ())
-#define E_TABLE_SORTED(o) (GTK_CHECK_CAST ((o), E_TABLE_SORTED_TYPE, ETableSorted))
-#define E_TABLE_SORTED_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_SORTED_TYPE, ETableSortedClass))
-#define E_IS_TABLE_SORTED(o) (GTK_CHECK_TYPE ((o), E_TABLE_SORTED_TYPE))
-#define E_IS_TABLE_SORTED_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_SORTED_TYPE))
-
-typedef struct {
- ETableSubset base;
-
- short sort_col;
- GCompareFunc compare;
-} ETableSorted;
-
-typedef struct {
- ETableSubset parent_class;
-} ETableSortedClass;
-
-GtkType e_table_sorted_get_type (void);
-ETableModel *e_table_sorted_new (ETableModel *etm, int col, GCompareFunc compare);
-void e_table_sorted_resort (ETableSorted *ets, int col, GCompareFunc compare);
-
-#endif /* _E_TABLE_SORTED_H_ */
diff --git a/widgets/e-table/e-table-subset.c b/widgets/e-table/e-table-subset.c
deleted file mode 100644
index a9e4a5c5a4..0000000000
--- a/widgets/e-table/e-table-subset.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * E-table-subset.c: Implements a table that contains a subset of another table.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc.
- */
-#include <config.h>
-#include <stdlib.h>
-#include <gtk/gtksignal.h>
-#include "e-util/e-util.h"
-#include "e-table-subset.h"
-
-#define PARENT_TYPE E_TABLE_MODEL_TYPE
-
-static ETableModelClass *etss_parent_class;
-
-static void
-etss_destroy (GtkObject *object)
-{
- ETableSubset *etss = E_TABLE_SUBSET (object);
-
- if (etss->source)
- gtk_object_unref (GTK_OBJECT (etss->source));
-
- if (etss->map_table)
- free (etss->map_table);
-
- GTK_OBJECT_CLASS (etss_parent_class)->destroy (object);
-}
-
-static int
-etss_column_count (ETableModel *etm)
-{
- ETableSubset *etss = (ETableSubset *)etm;
-
- return e_table_model_column_count (etss->source);
-}
-
-static int
-etss_row_count (ETableModel *etm)
-{
- ETableSubset *etss = (ETableSubset *)etm;
-
- return etss->n_map;
-}
-
-static void *
-etss_value_at (ETableModel *etm, int col, int row)
-{
- ETableSubset *etss = (ETableSubset *)etm;
-
- return e_table_model_value_at (etss->source, col, etss->map_table [row]);
-}
-
-static void
-etss_set_value_at (ETableModel *etm, int col, int row, const void *val)
-{
- ETableSubset *etss = (ETableSubset *)etm;
-
- return e_table_model_set_value_at (etss->source, col, etss->map_table [row], val);
-}
-
-static gboolean
-etss_is_cell_editable (ETableModel *etm, int col, int row)
-{
- ETableSubset *etss = (ETableSubset *)etm;
-
- return e_table_model_is_cell_editable (etss->source, col, etss->map_table [row]);
-}
-
-static void
-etss_class_init (GtkObjectClass *klass)
-{
- ETableModelClass *table_class = (ETableModelClass *) klass;
-
- etss_parent_class = gtk_type_class (PARENT_TYPE);
-
- klass->destroy = etss_destroy;
-
- table_class->column_count = etss_column_count;
- table_class->row_count = etss_row_count;
- table_class->value_at = etss_value_at;
- table_class->set_value_at = etss_set_value_at;
- table_class->is_cell_editable = etss_is_cell_editable;
-}
-
-E_MAKE_TYPE(e_table_subset, "ETableSubset", ETableSubset, etss_class_init, NULL, PARENT_TYPE);
-
-static void
-etss_proxy_model_changed (ETableModel *etm, ETableSubset *etss)
-{
- e_table_model_changed (E_TABLE_MODEL (etss));
-}
-
-static void
-etss_proxy_model_row_changed (ETableModel *etm, int row, ETableSubset *etss)
-{
- const int n = etss->n_map;
- const int * const map_table = etss->map_table;
- int i;
-
- for (i = 0; i < n; i++){
- if (map_table [i] == row){
- e_table_model_row_changed (E_TABLE_MODEL (etss), i);
- return;
- }
- }
-}
-
-static void
-etss_proxy_model_cell_changed (ETableModel *etm, int col, int row, ETableSubset *etss)
-{
- const int n = etss->n_map;
- const int * const map_table = etss->map_table;
- int i;
-
- for (i = 0; i < n; i++){
- if (map_table [i] == row){
- e_table_model_cell_changed (E_TABLE_MODEL (etss), col, i);
- return;
- }
- }
-}
-
-ETableModel *
-e_table_subset_construct (ETableSubset *etss, ETableModel *source, int nvals)
-{
- unsigned int *buffer;
- int i;
-
- buffer = (unsigned int *) malloc (sizeof (unsigned int) * nvals);
- if (buffer == NULL)
- return NULL;
- etss->map_table = buffer;
- etss->n_map = nvals;
- etss->source = source;
- gtk_object_ref (GTK_OBJECT (source));
-
- /* Init */
- for (i = 0; i < nvals; i++)
- etss->map_table [i] = i;
-
- gtk_signal_connect (GTK_OBJECT (source), "model_changed",
- GTK_SIGNAL_FUNC (etss_proxy_model_changed), etss);
- gtk_signal_connect (GTK_OBJECT (source), "model_row_changed",
- GTK_SIGNAL_FUNC (etss_proxy_model_row_changed), etss);
- gtk_signal_connect (GTK_OBJECT (source), "model_cell_changed",
- GTK_SIGNAL_FUNC (etss_proxy_model_cell_changed), etss);
-
- return E_TABLE_MODEL (etss);
-}
-
-ETableModel *
-e_table_subset_new (ETableModel *source, const int nvals)
-{
- ETableSubset *etss = gtk_type_new (E_TABLE_SUBSET_TYPE);
-
- if (e_table_subset_construct (etss, source, nvals) == NULL){
- gtk_object_destroy (GTK_OBJECT (etss));
- return NULL;
- }
-
- return (ETableModel *) etss;
-}
-
-ETableModel *
-e_table_subset_get_toplevel (ETableSubset *table)
-{
- g_return_val_if_fail (table != NULL, NULL);
- g_return_val_if_fail (E_IS_TABLE_SUBSET (table), NULL);
-
- if (E_IS_TABLE_SUBSET (table->source))
- return e_table_subset_get_toplevel (E_TABLE_SUBSET (table->source));
- else
- return table->source;
-}
diff --git a/widgets/e-table/e-table-subset.h b/widgets/e-table/e-table-subset.h
deleted file mode 100644
index 314f28aea6..0000000000
--- a/widgets/e-table/e-table-subset.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef _E_TABLE_SUBSET_H_
-#define _E_TABLE_SUBSET_H_
-
-#include <gtk/gtkobject.h>
-#include "e-table-model.h"
-
-#define E_TABLE_SUBSET_TYPE (e_table_subset_get_type ())
-#define E_TABLE_SUBSET(o) (GTK_CHECK_CAST ((o), E_TABLE_SUBSET_TYPE, ETableSubset))
-#define E_TABLE_SUBSET_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_SUBSET_TYPE, ETableSubsetClass))
-#define E_IS_TABLE_SUBSET(o) (GTK_CHECK_TYPE ((o), E_TABLE_SUBSET_TYPE))
-#define E_IS_TABLE_SUBSET_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_SUBSET_TYPE))
-
-typedef struct {
- ETableModel base;
-
- ETableModel *source;
- int n_map;
- int *map_table;
-} ETableSubset;
-
-typedef struct {
- ETableModelClass parent_class;
-} ETableSubsetClass;
-
-GtkType e_table_subset_get_type (void);
-ETableModel *e_table_subset_new (ETableModel *etm, int n_vals);
-ETableModel *e_table_subset_construct (ETableSubset *ets, ETableModel *source, int nvals);
-
-ETableModel *e_table_subset_get_toplevel (ETableSubset *table_model);
-
-#endif /* _E_TABLE_SUBSET_H_ */
-
diff --git a/widgets/e-table/e-table-tree.h b/widgets/e-table/e-table-tree.h
deleted file mode 100644
index e7e125a6af..0000000000
--- a/widgets/e-table/e-table-tree.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef _E_TABLE_TREE_H_
-#define _E_TABLE_TREE_H_
-
-typedef struct {
- char *title;
-
- union {
- ETableModel *table;
- GList *children;
- } u;
-
- guint expanded :1;
- guint is_leaf :1;
-} ETableGroup;
-
-ETableGroup *e_table_group_new (const char *title, ETableModel *table);
-ETableGroup *e_table_group_new_leaf (const char *title);
-
-#endif /* _E_TABLE_TREE_H_ */
diff --git a/widgets/e-table/e-table.c b/widgets/e-table/e-table.c
deleted file mode 100644
index a42aaf111b..0000000000
--- a/widgets/e-table/e-table.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * E-table-view.c: A graphical view of a Table.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * Copyright 1999, Helix Code, Inc
- */
-#include <config.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <alloca.h>
-#include <stdio.h>
-#include <libgnomeui/gnome-canvas.h>
-#include <gtk/gtksignal.h>
-#include "e-util/e-util.h"
-#include "e-table.h"
-#include "e-table-header-item.h"
-#include "e-table-subset.h"
-#include "e-table-item.h"
-#include "e-table-group.h"
-
-#define COLUMN_HEADER_HEIGHT 16
-#define TITLE_HEIGHT 16
-#define GROUP_INDENT 10
-
-#define PARENT_TYPE gtk_table_get_type ()
-
-static GtkObjectClass *e_table_parent_class;
-
-static void
-et_destroy (GtkObject *object)
-{
- ETable *et = E_TABLE (object);
-
- gtk_object_unref (GTK_OBJECT (et->model));
- gtk_object_unref (GTK_OBJECT (et->full_header));
- gtk_object_unref (GTK_OBJECT (et->header));
-
- g_free (et->group_spec);
-
- (*e_table_parent_class->destroy)(object);
-}
-
-static void
-e_table_init (GtkObject *object)
-{
- ETable *e_table = E_TABLE (object);
-
- e_table->draw_grid = 1;
- e_table->draw_focus = 1;
- e_table->spreadsheet = 1;
-}
-
-static ETableHeader *
-e_table_make_header (ETable *e_table, ETableHeader *full_header, const char *cols)
-{
- ETableHeader *nh;
- char *copy = alloca (strlen (cols) + 1);
- char *p, *state;
- const int max_cols = e_table_header_count (full_header);
-
- nh = e_table_header_new ();
- strcpy (copy, cols);
- while ((p = strtok_r (copy, ",", &state)) != NULL){
- int col = atoi (p);
-
- copy = NULL;
- if (col >= max_cols)
- continue;
-
- e_table_header_add_column (nh, e_table_header_get_column (full_header, col), -1);
- }
-
- return nh;
-}
-
-static void
-header_canvas_size_alocate (GtkWidget *widget, GtkAllocation *alloc, ETable *e_table)
-{
- gnome_canvas_set_scroll_region (
- GNOME_CANVAS (e_table->header_canvas),
- 0, 0, alloc->width, COLUMN_HEADER_HEIGHT);
-}
-
-static void
-e_table_setup_header (ETable *e_table)
-{
- e_table->header_canvas = GNOME_CANVAS (gnome_canvas_new ());
-
- gtk_widget_show (GTK_WIDGET (e_table->header_canvas));
-
- e_table->header_item = gnome_canvas_item_new (
- gnome_canvas_root (e_table->header_canvas),
- e_table_header_item_get_type (),
- "ETableHeader", e_table->header,
- "x", 0,
- "y", 0,
- NULL);
-
- gtk_signal_connect (
- GTK_OBJECT (e_table->header_canvas), "size_allocate",
- GTK_SIGNAL_FUNC (header_canvas_size_alocate), e_table);
-
- gtk_widget_set_usize (GTK_WIDGET (e_table->header_canvas), -1, COLUMN_HEADER_HEIGHT);
-
- gtk_table_attach (
- GTK_TABLE (e_table), GTK_WIDGET (e_table->header_canvas),
- 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
-
-}
-
-typedef struct {
- void *value;
- GArray *array;
-} group_key_t;
-
-static GArray *
-e_table_create_groups (ETableModel *etm, int key_col, GCompareFunc comp)
-{
- GArray *groups;
- const int rows = e_table_model_row_count (etm);
- int row, i;
-
- groups = g_array_new (FALSE, FALSE, sizeof (group_key_t));
-
- for (row = 0; row < rows; row++){
- void *val = e_table_model_value_at (etm, key_col, row);
- const int n_groups = groups->len;
-
- /*
- * Should replace this with a bsearch later
- */
- for (i = 0; i < n_groups; i++){
- group_key_t *g = &g_array_index (groups, group_key_t, i);
-
- if ((*comp) (g->value, val)){
- g_array_append_val (g->array, row);
- break;
- }
- }
- if (i != n_groups)
- continue;
-
- /*
- * We need to create a new group
- */
- {
- group_key_t gk;
-
- gk.value = val;
- gk.array = g_array_new (FALSE, FALSE, sizeof (int));
-
- g_array_append_val (gk.array, row);
- g_array_append_val (groups, gk);
- }
- }
-
- return groups;
-}
-
-static void
-e_table_destroy_groups (GArray *groups)
-{
- const int n = groups->len;
- int i;
-
- for (i = 0; i < n; i++){
- group_key_t *g = &g_array_index (groups, group_key_t, i);
-
- g_array_free (g->array, TRUE);
- }
- g_array_free (groups, TRUE);
-}
-
-static ETableModel **
-e_table_make_subtables (ETableModel *model, GArray *groups)
-{
- const int n_groups = groups->len;
- ETableModel **tables;
- int i;
-
- tables = g_new (ETableModel *, n_groups+1);
-
- for (i = 0; i < n_groups; i++){
- group_key_t *g = &g_array_index (groups, group_key_t, i);
- const int sub_size = g->array->len;
- ETableSubset *ss;
- int j;
-
- tables [i] = e_table_subset_new (model, sub_size);
- ss = E_TABLE_SUBSET (tables [i]);
-
- for (j = 0; j < sub_size; j++)
- ss->map_table [j] = g_array_index (g->array, int, j);
- }
- tables [i] = NULL;
-
- return (ETableModel **) tables;
-}
-
-typedef struct _Node Node;
-
-struct _Node {
- Node *parent;
- GnomeCanvasItem *item;
- ETableModel *table_model;
- GSList *children;
-
- guint is_leaf:1;
-};
-
-static Node *
-leaf_new (GnomeCanvasItem *table_item, ETableModel *table_model, Node *parent)
-{
- Node *node = g_new (Node, 1);
-
- g_assert (table_item != NULL);
- g_assert (table_model != NULL);
- g_assert (parent != NULL);
-
- node->item = table_item;
- node->parent = parent;
- node->table_model = table_model;
- node->is_leaf = 1;
-
- g_assert (!parent->is_leaf);
-
- parent->children = g_slist_append (parent->children, node);
-
- e_table_group_add (E_TABLE_GROUP (parent->item), table_item);
-
- return node;
-}
-
-static Node *
-node_new (GnomeCanvasItem *group_item, ETableModel *table_model, Node *parent)
-{
- Node *node = g_new (Node, 1);
-
- g_assert (table_model != NULL);
-
- node->children = NULL;
- node->item = group_item;
- node->parent = parent;
- node->table_model = table_model;
- node->is_leaf = 0;
-
- if (parent){
- parent->children = g_slist_append (parent->children, node);
-
- e_table_group_add (E_TABLE_GROUP (parent->item), group_item);
- }
-
- return node;
-}
-
-static Node *
-e_table_create_leaf (ETable *e_table, ETableModel *etm, Node *parent)
-{
- GnomeCanvasItem *table_item;
- static double last_y;
- Node *leaf;
-
- table_item = gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (parent->item),
- e_table_item_get_type (),
- "ETableHeader", e_table->header,
- "ETableModel", etm,
- "drawgrid", e_table->draw_grid,
- "drawfocus", e_table->draw_focus,
- "spreadsheet", e_table->spreadsheet,
- NULL);
-
- leaf = leaf_new (table_item, etm, parent);
-
- return leaf;
-}
-
-static int
-leaf_height (Node *leaf)
-{
- const GnomeCanvasItem *item = leaf->item;
-
- return item->y2 - item->y1;
-}
-
-static int
-leaf_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- static int last_x = -1;
- static int last_y = -1;
-
- if (event->type == GDK_BUTTON_PRESS){
- last_x = event->button.x;
- last_y = event->button.y;
- } else if (event->type == GDK_BUTTON_RELEASE){
- last_x = -1;
- last_y = -1;
- } else if (event->type == GDK_MOTION_NOTIFY){
- if (last_x == -1)
- return FALSE;
-
- gnome_canvas_item_move (item, event->motion.x - last_x, event->motion.y - last_y);
- last_x = event->motion.x;
- last_y = event->motion.y;
- } else
- return FALSE;
- return TRUE;
-}
-
-static Node *
-e_table_create_nodes (ETable *e_table, ETableModel *model, ETableHeader *header,
- GnomeCanvasGroup *root, Node *parent, int *groups_list)
-{
- GArray *groups;
- ETableModel **tables;
- ETableCol *ecol;
- int key_col, i;
- GnomeCanvasItem *group_item;
- Node *group;
-
- key_col = *groups_list;
- g_assert (key_col != -1);
-
- /*
- * Create groups
- */
- ecol = e_table_header_get_column (header, key_col);
-
- g_assert (ecol != NULL);
-
- groups = e_table_create_groups (model, key_col, ecol->compare);
- tables = e_table_make_subtables (e_table->model, groups);
- e_table_destroy_groups (groups);
-
- group_item = e_table_group_new (root, ecol, TRUE, parent == NULL);
- group = node_new (group_item, model, parent);
-
- for (i = 0; tables [i] != NULL; i++){
- Node *node;
-
- /*
- * Leafs
- */
- if (groups_list [1] == -1){
- GnomeCanvasItem *item_leaf_header;
- Node *leaf_header;
-
- item_leaf_header = e_table_group_new (
- GNOME_CANVAS_GROUP (group_item), ecol, TRUE, FALSE);
- leaf_header = node_new (item_leaf_header, tables [i], group);
-
- e_table_create_leaf (e_table, tables [i], leaf_header);
- } else {
- e_table_create_nodes (
- e_table, tables [i], header, GNOME_CANVAS_GROUP (group_item),
- group, &groups_list [1]);
- }
- }
-
- return group;
-}
-
-static int *
-group_spec_to_desc (const char *group_spec)
-{
- int a_size = 10;
- int *elements;
- char *p, *copy, *follow;
- int n_elements = 0;
-
- if (group_spec == NULL)
- return NULL;
-
- elements = g_new (int, a_size);
- copy = alloca (strlen (group_spec) + 1);
- strcpy (copy, group_spec);
-
- while ((p = strtok_r (copy, ",", &follow)) != NULL){
- elements [n_elements] = atoi (p);
- ++n_elements;
- if (n_elements+1 == a_size){
- int *new_e;
-
- n_elements += 10;
- new_e = g_renew (int, elements, n_elements);
- if (new_e == NULL){
- g_free (elements);
- return NULL;
- }
- elements = new_e;
- }
- copy = NULL;
- }
-
- /* Tag end */
- elements [n_elements] = -1;
-
- return elements;
-}
-
-/*
- * The ETableCanvas object is just used to enable us to
- * hook up to the realize/unrealize phases of the canvas
- * initialization (as laying out the subtables requires us to
- * know the actual size of the subtables we are inserting
- */
-
-#define E_TABLE_CANVAS_PARENT_TYPE gnome_canvas_get_type ()
-
-typedef struct {
- GnomeCanvas base;
-
- ETable *e_table;
-} ETableCanvas;
-
-typedef struct {
- GnomeCanvasClass base_class;
-} ETableCanvasClass;
-
-static GnomeCanvasClass *e_table_canvas_parent_class;
-
-static void
-e_table_canvas_realize (GtkWidget *widget)
-{
- ETableCanvas *e_table_canvas = (ETableCanvas *) widget;
- ETable *e_table = e_table_canvas->e_table;
- int *groups;
- Node *leaf;
-
- GTK_WIDGET_CLASS (e_table_canvas_parent_class)->realize (widget);
-
- groups = group_spec_to_desc (e_table->group_spec);
-
- e_table->root = gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (e_table->table_canvas->root),
- gnome_canvas_group_get_type (),
- "x", 0.0,
- "y", 0.0,
- NULL);
-
- leaf = e_table_create_nodes (
- e_table, e_table->model,
- e_table->header, GNOME_CANVAS_GROUP (e_table->root), 0, groups);
-
- gnome_canvas_set_scroll_region (
- GNOME_CANVAS (e_table_canvas),
- 0, 0,
- e_table_header_total_width (e_table->header) + 200,
- leaf_height (leaf));
-
- if (groups)
- g_free (groups);
-}
-
-static void
-e_table_canvas_unrealize (GtkWidget *widget)
-{
- ETableCanvas *e_table_canvas = (ETableCanvas *) widget;
- ETable *e_table = e_table_canvas->e_table;
-
- gtk_object_destroy (GTK_OBJECT (e_table->root));
- e_table->root = NULL;
-
- GTK_WIDGET_CLASS (e_table_canvas_parent_class)->unrealize (widget);
-}
-
-static void
-e_table_canvas_class_init (GtkObjectClass *object_class)
-{
- GtkWidgetClass *widget_class = (GtkWidgetClass *) object_class;
-
- widget_class->realize = e_table_canvas_realize;
- widget_class->unrealize = e_table_canvas_unrealize;
-
- e_table_canvas_parent_class = gtk_type_class (E_TABLE_CANVAS_PARENT_TYPE);
-}
-
-static void
-e_table_canvas_init (GtkObject *canvas)
-{
- GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS);
-}
-
-GtkType e_table_canvas_get_type (void);
-
-E_MAKE_TYPE (e_table_canvas, "ETableCanvas", ETableCanvas, e_table_canvas_class_init,
- e_table_canvas_init, E_TABLE_CANVAS_PARENT_TYPE);
-
-static GnomeCanvas *
-e_table_canvas_new (ETable *e_table)
-{
- ETableCanvas *e_table_canvas;
-
- e_table_canvas = gtk_type_new (e_table_canvas_get_type ());
- e_table_canvas->e_table = e_table;
-
- return GNOME_CANVAS (e_table_canvas);
-}
-
-static void
-e_table_setup_table (ETable *e_table)
-{
- e_table->table_canvas = e_table_canvas_new (e_table);
-
- gtk_widget_show (GTK_WIDGET (e_table->table_canvas));
- gtk_table_attach (
- GTK_TABLE (e_table), GTK_WIDGET (e_table->table_canvas),
- 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
-}
-
-void
-e_table_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm,
- const char *cols_spec, const char *group_spec)
-{
- GTK_TABLE (e_table)->homogeneous = FALSE;
-
- gtk_table_resize (GTK_TABLE (e_table), 1, 2);
-
- e_table->full_header = full_header;
- gtk_object_ref (GTK_OBJECT (full_header));
-
- e_table->model = etm;
- gtk_object_ref (GTK_OBJECT (etm));
-
- e_table->header = e_table_make_header (e_table, full_header, cols_spec);
-
- e_table_setup_header (e_table);
- e_table_setup_table (e_table);
-
- e_table->group_spec = g_strdup (group_spec);
-
-}
-
-GtkWidget *
-e_table_new (ETableHeader *full_header, ETableModel *etm, const char *cols_spec, const char *group_spec)
-{
- ETable *e_table;
-
- e_table = gtk_type_new (e_table_get_type ());
-
- e_table_construct (e_table, full_header, etm, cols_spec, group_spec);
-
- return (GtkWidget *) e_table;
-}
-
-static void
-e_table_class_init (GtkObjectClass *object_class)
-{
- e_table_parent_class = gtk_type_class (PARENT_TYPE);
-
- object_class->destroy = et_destroy;
-}
-
-E_MAKE_TYPE(e_table, "ETable", ETable, e_table_class_init, e_table_init, PARENT_TYPE);
-
diff --git a/widgets/e-table/e-table.h b/widgets/e-table/e-table.h
deleted file mode 100644
index 63c131324f..0000000000
--- a/widgets/e-table/e-table.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef _E_TABLE_H_
-#define _E_TABLE_H_
-
-#include <libgnomeui/gnome-canvas.h>
-#include <gtk/gtktable.h>
-#include "e-table-model.h"
-#include "e-table-header.h"
-
-BEGIN_GNOME_DECLS
-
-#define E_TABLE_TYPE (e_table_get_type ())
-#define E_TABLE(o) (GTK_CHECK_CAST ((o), E_TABLE_TYPE, ETable))
-#define E_TABLE_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_TYPE, ETableClass))
-#define E_IS_TABLE(o) (GTK_CHECK_TYPE ((o), E_TABLE_TYPE))
-#define E_IS_TABLE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_TYPE))
-
-typedef struct {
- GtkTable parent;
-
- ETableModel *model;
-
- ETableHeader *full_header, *header;
-
- GnomeCanvas *header_canvas, *table_canvas;
-
- GnomeCanvasItem *header_item, *root;
-
- guint draw_grid:1;
- guint draw_focus:1;
- guint spreadsheet:1;
-
- char *group_spec;
-} ETable;
-
-typedef struct {
- GtkTableClass parent_class;
-} ETableClass;
-
-GtkType e_table_get_type (void);
-void e_table_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm,
- const char *cols_spec, const char *group_spec);
-GtkWidget *e_table_new (ETableHeader *full_header, ETableModel *etm,
- const char *cols_spec, const char *group_spec);
-
-
-END_GNOME_DECLS
-
- #endif /* _E_TABLE_H_ */
diff --git a/widgets/e-table/image1.png b/widgets/e-table/image1.png
deleted file mode 100644
index 8326ac241f..0000000000
--- a/widgets/e-table/image1.png
+++ /dev/null
Binary files differ
diff --git a/widgets/e-table/image2.png b/widgets/e-table/image2.png
deleted file mode 100644
index e6a4c75dbe..0000000000
--- a/widgets/e-table/image2.png
+++ /dev/null
Binary files differ
diff --git a/widgets/e-table/image3.png b/widgets/e-table/image3.png
deleted file mode 100644
index 50e16e8620..0000000000
--- a/widgets/e-table/image3.png
+++ /dev/null
Binary files differ
diff --git a/widgets/e-table/remove-col.xpm b/widgets/e-table/remove-col.xpm
deleted file mode 100644
index ff1024f0c9..0000000000
--- a/widgets/e-table/remove-col.xpm
+++ /dev/null
@@ -1,22 +0,0 @@
-/* XPM */
-static char * remove_col_xpm[] = {
-"16 16 3 1",
-" c None",
-". c #000000",
-"+ c #FF0000",
-"... ...",
-".++. .++.",
-".+++. .+++.",
-" .+++. .+++. ",
-" .+++. .+++. ",
-" .+++..+++. ",
-" .++++++. ",
-" .++++. ",
-" .++++. ",
-" .++++++. ",
-" .+++..+++. ",
-" .+++. .+++. ",
-" .+++. .+++. ",
-".+++. .+++.",
-".++. .++.",
-"... ..."};
diff --git a/widgets/e-table/sample.table b/widgets/e-table/sample.table
deleted file mode 100644
index 45c8ff0691..0000000000
--- a/widgets/e-table/sample.table
+++ /dev/null
@@ -1,11 +0,0 @@
-Col1 Col2 Address Title Dorks
-c1.a c2.a a.a tit-1 DorkA
-c1.b c2.b a.b tit-2 DDork
-c1.c c2.c a.c tit-1 DorkB
-c1.d c2.d a.d tit-2 ADork
-c1.e c2.e a.e tit-1 DorkC
-c1.f c2.f a.f tit-2 UDork
-c1.g c2.g a.g tit-3 Dork---
-j k k tit-1 DorkA
-
-
diff --git a/widgets/e-table/table-test.c b/widgets/e-table/table-test.c
deleted file mode 100644
index e18f38c5ec..0000000000
--- a/widgets/e-table/table-test.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Test code for the ETable package
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- */
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <gnome.h>
-#include "e-util/e-cursors.h"
-#include "table-test.h"
-
-int
-main (int argc, char *argv [])
-{
-
- if (isatty (0)){
- int fd;
-
- close (0);
- fd = open ("sample.table", O_RDONLY);
- if (fd == -1){
- fprintf (stderr, "Could not find sample.table, try feeding a table on stdin");
- exit (1);
- }
- dup2 (fd, 0);
- }
-
- gnome_init ("TableTest", "TableTest", argc, argv);
- e_cursors_init ();
-
- table_browser_test ();
- multi_cols_test ();
- check_test ();
- e_table_test ();
-
- gtk_main ();
-
- e_cursors_shutdown ();
- return 0;
-}
diff --git a/widgets/e-table/table-test.h b/widgets/e-table/table-test.h
deleted file mode 100644
index ad8cfcc083..0000000000
--- a/widgets/e-table/table-test.h
+++ /dev/null
@@ -1,4 +0,0 @@
-void table_browser_test (void);
-void multi_cols_test (void);
-void check_test (void);
-void e_table_test (void);
diff --git a/widgets/e-table/test-check.c b/widgets/e-table/test-check.c
deleted file mode 100644
index 8cc5f6834e..0000000000
--- a/widgets/e-table/test-check.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Test code for the ETable package
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- */
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <gnome.h>
-#include "e-table-simple.h"
-#include "e-table-header.h"
-#include "e-table-header-item.h"
-#include "e-table-item.h"
-#include "e-util/e-cursors.h"
-#include "e-cell-text.h"
-#include "e-cell-checkbox.h"
-
-#include "table-test.h"
-
-#define LINES 4
-
-static struct {
- int value;
- char *string;
-} my_table [LINES] = {
- { 0, "Buy food" },
- { 1, "Breathe " },
- { 0, "Cancel gdb session with shrink" },
- { 1, "Make screenshots" },
-};
-/*
- * ETableSimple callbacks
- */
-static int
-col_count (ETableModel *etc, void *data)
-{
- return 2;
-}
-
-static int
-row_count (ETableModel *etc, void *data)
-{
- return LINES;
-}
-
-static void *
-value_at (ETableModel *etc, int col, int row, void *data)
-{
- g_assert (col < 2);
- g_assert (row < LINES);
-
- if (col == 0)
- return GINT_TO_POINTER (my_table [row].value);
- else
- return my_table [row].string;
-
-}
-
-static void
-set_value_at (ETableModel *etc, int col, int row, const void *val, void *data)
-{
- g_assert (col < 2);
- g_assert (row < LINES);
-
- if (col == 0){
- my_table [row].value = GPOINTER_TO_INT (val);
- printf ("Value at %d,%d set to %d\n", col, row, GPOINTER_TO_INT (val));
- } else {
- my_table [row].string = g_strdup (val);
- printf ("Value at %d,%d set to %s\n", col, row, (char *) val);
- }
-}
-
-static gboolean
-is_cell_editable (ETableModel *etc, int col, int row, void *data)
-{
- return TRUE;
-}
-
-static void
-set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc)
-{
- gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height);
-}
-
-void
-check_test (void)
-{
- GtkWidget *canvas, *window;
- ETableModel *e_table_model;
- ETableHeader *e_table_header;
- ETableCol *col_0, *col_1;
- ECell *cell_left_just, *cell_image_check;
-
- gtk_widget_push_visual (gdk_rgb_get_visual ());
- gtk_widget_push_colormap (gdk_rgb_get_cmap ());
-
- e_table_model = e_table_simple_new (
- col_count, row_count, value_at,
- set_value_at, is_cell_editable, NULL);
-
- /*
- * Header
- */
- e_table_header = e_table_header_new ();
-
- cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT);
-
- cell_image_check = e_cell_checkbox_new ();
- col_0 = e_table_col_new (0, "", 18, 18, cell_image_check, g_int_equal, TRUE);
- e_table_header_add_column (e_table_header, col_0, 0);
-
- col_1 = e_table_col_new (1, "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
- e_table_header_add_column (e_table_header, col_1, 1);
-
- /*
- * GUI
- */
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- canvas = gnome_canvas_new ();
-
- gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate",
- GTK_SIGNAL_FUNC (set_canvas_size), NULL);
-
- gtk_container_add (GTK_CONTAINER (window), canvas);
- gtk_widget_show_all (window);
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_header_item_get_type (),
- "ETableHeader", e_table_header,
- "x", 0,
- "y", 0,
- NULL);
-
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_item_get_type (),
- "ETableHeader", e_table_header,
- "ETableModel", e_table_model,
- "x", (double) 0,
- "y", (double) 30,
- "drawgrid", TRUE,
- "drawfocus", TRUE,
- "spreadsheet", TRUE,
- NULL);
-
-}
-
-
-
-
-
diff --git a/widgets/e-table/test-cols.c b/widgets/e-table/test-cols.c
deleted file mode 100644
index 288e2bd408..0000000000
--- a/widgets/e-table/test-cols.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Test code for the ETable package
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- */
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <gnome.h>
-#include "e-util/e-cursors.h"
-#include "e-table-simple.h"
-#include "e-table-header.h"
-#include "e-table-header-item.h"
-#include "e-table-item.h"
-#include "e-cell-text.h"
-#include "e-cell-toggle.h"
-
-#include "table-test.h"
-
-#define LINES 4
-
-static struct {
- int value;
- char *string;
-} my_table [LINES] = {
- { 0, "You are not" },
- { 1, "A beautiful and unique " },
- { 0, "Snowflake" },
- { 2, "You are not your wallet" },
-};
-/*
- * ETableSimple callbacks
- */
-static int
-col_count (ETableModel *etc, void *data)
-{
- return 2;
-}
-
-static int
-row_count (ETableModel *etc, void *data)
-{
- return LINES;
-}
-
-static void *
-value_at (ETableModel *etc, int col, int row, void *data)
-{
- g_assert (col < 2);
- g_assert (row < LINES);
-
- if (col == 0)
- return GINT_TO_POINTER (my_table [row].value);
- else
- return my_table [row].string;
-
-}
-
-static void
-set_value_at (ETableModel *etc, int col, int row, const void *val, void *data)
-{
- g_assert (col < 2);
- g_assert (row < LINES);
-
- if (col == 0){
- my_table [row].value = GPOINTER_TO_INT (val);
- printf ("Value at %d,%d set to %d\n", col, row, GPOINTER_TO_INT (val));
- } else {
- my_table [row].string = g_strdup (val);
- printf ("Value at %d,%d set to %s\n", col, row, (char *) val);
- }
-}
-
-static gboolean
-is_cell_editable (ETableModel *etc, int col, int row, void *data)
-{
- return TRUE;
-}
-
-static void
-set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc)
-{
- gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height);
-}
-
-void
-multi_cols_test (void)
-{
- GtkWidget *canvas, *window;
- ETableModel *e_table_model;
- ETableHeader *e_table_header, *e_table_header_multiple;
- ETableCol *col_0, *col_1;
- ECell *cell_left_just, *cell_image_toggle;
-
- gtk_widget_push_visual (gdk_rgb_get_visual ());
- gtk_widget_push_colormap (gdk_rgb_get_cmap ());
-
- e_table_model = e_table_simple_new (
- col_count, row_count, value_at,
- set_value_at, is_cell_editable, NULL);
-
- /*
- * Header
- */
- e_table_header = e_table_header_new ();
-
- cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT);
-
- {
- GdkPixbuf **images = g_new (GdkPixbuf *, 3);
- int i;
-
- images [0] = gdk_pixbuf_new_from_file ("image1.png");
- images [1] = gdk_pixbuf_new_from_file ("image2.png");
- images [2] = gdk_pixbuf_new_from_file ("image3.png");
-
- cell_image_toggle = e_cell_toggle_new (0, 3, images);
-
- for (i = 0; i < 3; i++)
- gdk_pixbuf_unref (images [i]);
-
- g_free (images);
- }
-
- col_1 = e_table_col_new (1, "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
- e_table_header_add_column (e_table_header, col_1, 0);
-
- col_0 = e_table_col_new (0, "A", 48, 48, cell_image_toggle, g_int_equal, TRUE);
- e_table_header_add_column (e_table_header, col_0, 1);
-
- /*
- * Second test
- */
- e_table_header_multiple = e_table_header_new ();
- e_table_header_add_column (e_table_header_multiple, col_0, 0);
- e_table_header_add_column (e_table_header_multiple, col_1, 1);
- e_table_header_add_column (e_table_header_multiple, col_1, 2);
-
- /*
- * GUI
- */
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- canvas = gnome_canvas_new ();
-
- gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate",
- GTK_SIGNAL_FUNC (set_canvas_size), NULL);
-
- gtk_container_add (GTK_CONTAINER (window), canvas);
- gtk_widget_show_all (window);
-
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_header_item_get_type (),
- "ETableHeader", e_table_header,
- "x", 0,
- "y", 0,
- NULL);
-
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_item_get_type (),
- "ETableHeader", e_table_header,
- "ETableModel", e_table_model,
- "x", (double) 0,
- "y", (double) 30,
- "drawgrid", TRUE,
- "drawfocus", TRUE,
- "spreadsheet", TRUE,
- NULL);
-
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_header_item_get_type (),
- "ETableHeader", e_table_header_multiple,
- "x", 300,
- "y", 0,
- NULL);
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_item_get_type (),
- "ETableHeader", e_table_header_multiple,
- "ETableModel", e_table_model,
- "x", (double) 300,
- "y", (double) 30,
- "drawgrid", TRUE,
- "drawfocus", TRUE,
- "spreadsheet", TRUE,
- NULL);
-
-}
-
-
-
-
-
diff --git a/widgets/e-table/test-table.c b/widgets/e-table/test-table.c
deleted file mode 100644
index 053f81cfa6..0000000000
--- a/widgets/e-table/test-table.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Test code for the ETable package
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- */
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <gnome.h>
-#include "e-util/e-cursors.h"
-#include "e-table-simple.h"
-#include "e-table-header.h"
-#include "e-table-header-item.h"
-#include "e-table-item.h"
-#include "e-cell-text.h"
-#include "e-table.h"
-
-#include "table-test.h"
-
-char buffer [1024];
-char **column_labels;
-char ***table_data;
-int cols = 0;
-int lines = 0;
-int lines_alloc = 0;
-
-static void
-parse_headers ()
-{
- char *p, *s;
- int in_value = 0, i;
-
- fgets (buffer, sizeof (buffer)-1, stdin);
-
- for (p = buffer; *p; p++){
- if (*p == ' ' || *p == '\t'){
- if (in_value){
- cols++;
- in_value = 0;
- }
- } else
- in_value = 1;
- }
- if (in_value)
- cols++;
-
- if (!cols){
- fprintf (stderr, "No columns in first row\n");
- exit (1);
- }
-
- column_labels = g_new0 (char *, cols);
-
- p = buffer;
- for (i = 0; (s = strtok (p, " \t")) != NULL; i++){
- column_labels [i] = g_strdup (s);
- p = NULL;
- }
-
- printf ("%d headers:\n", cols);
- for (i = 0; i < cols; i++){
- printf ("header %d: %s\n", i, column_labels [i]);
- }
-}
-
-static char **
-load_line (char *buffer, int cols)
-{
- char **line = g_new0 (char *, cols);
- char *p;
- int i;
-
- for (i = 0; i < cols; i++){
- p = strtok (buffer, " \t\n");
- if (p == NULL){
- for (; i < cols; i++)
- line [i] = g_strdup ("");
- return line;
- } else
- line [i] = g_strdup (p);
- buffer = NULL;
- }
- return line;
-}
-
-static void
-append_line (char **line)
-{
- if (lines <= lines_alloc){
- lines_alloc = lines + 50;
- table_data = g_renew (char **, table_data, lines_alloc);
- }
- table_data [lines] = line;
- lines++;
-}
-
-static void
-load_data ()
-{
- int i;
-
- {
- static int loaded;
-
- if (loaded)
- return;
-
- loaded = TRUE;
- }
-
-
- parse_headers ();
-
- while (fgets (buffer, sizeof (buffer)-1, stdin) != NULL){
- char **line;
-
- if (buffer [0] == '\n')
- continue;
- line = load_line (buffer, cols);
- append_line (line);
- }
-
- for (i = 0; i < lines; i++){
- int j;
-
- printf ("Line %d: ", i);
- for (j = 0; j < cols; j++)
- printf ("[%s] ", table_data [i][j]);
- printf ("\n");
- }
-}
-
-/*
- * ETableSimple callbacks
- */
-static int
-col_count (ETableModel *etc, void *data)
-{
- return cols;
-}
-
-static int
-row_count (ETableModel *etc, void *data)
-{
- return lines;
-}
-
-static void *
-value_at (ETableModel *etc, int col, int row, void *data)
-{
- g_assert (col < cols);
- g_assert (row < lines);
-
- return (void *) table_data [row][col];
-}
-
-static void
-set_value_at (ETableModel *etc, int col, int row, const void *val, void *data)
-{
- g_assert (col < cols);
- g_assert (row < lines);
-
- g_free (table_data [row][col]);
- table_data [row][col] = g_strdup (val);
-
- printf ("Value at %d,%d set to %s\n", col, row, (char *) val);
-}
-
-static gboolean
-is_cell_editable (ETableModel *etc, int col, int row, void *data)
-{
- return TRUE;
-}
-
-static void
-set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc)
-{
- gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height);
-}
-
-void
-table_browser_test (void)
-{
- GtkWidget *canvas, *window;
- ETableModel *e_table_model;
- ETableHeader *e_table_header;
- ECell *cell_left_just;
- GnomeCanvasItem *group;
- int i;
-
- load_data ();
-
- /*
- * Data model
- */
- e_table_model = e_table_simple_new (
- col_count, row_count, value_at,
- set_value_at, is_cell_editable, NULL);
-
- /*
- * Header
- */
- e_table_header = e_table_header_new ();
- cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT);
-
- for (i = 0; i < cols; i++){
- ETableCol *ecol = e_table_col_new (
- i, column_labels [i],
- 80, 20, cell_left_just,
- g_str_equal, TRUE);
-
- e_table_header_add_column (e_table_header, ecol, i);
- }
-
- /*
- * Setup GUI
- */
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- canvas = gnome_canvas_new ();
-
- gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate",
- GTK_SIGNAL_FUNC (set_canvas_size), NULL);
-
- gtk_container_add (GTK_CONTAINER (window), canvas);
- gtk_widget_show_all (window);
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_header_item_get_type (),
- "ETableHeader", e_table_header,
- "x", 0,
- "y", 0,
- NULL);
-
- group = gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- gnome_canvas_group_get_type (),
- "x", 30.0,
- "y", 30.0,
- NULL);
-
- gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (group),
- e_table_item_get_type (),
- "ETableHeader", e_table_header,
- "ETableModel", e_table_model,
- "x", (double) 0,
- "y", (double) 0,
- "drawgrid", TRUE,
- "drawfocus", TRUE,
- "spreadsheet", TRUE,
- NULL);
-}
-
-static void
-do_e_table_demo (const char *col_spec, const char *group_spec)
-{
- GtkWidget *e_table, *window;
- ETableModel *e_table_model;
- ECell *cell_left_just;
- ETableHeader *full_header;
- int i;
-
- /*
- * Data model
- */
- e_table_model = e_table_simple_new (
- col_count, row_count, value_at,
- set_value_at, is_cell_editable, NULL);
-
- full_header = e_table_header_new ();
- cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT);
-
- for (i = 0; i < cols; i++){
- ETableCol *ecol = e_table_col_new (
- i, column_labels [i],
- 80, 20, cell_left_just,
- g_str_equal, TRUE);
-
- e_table_header_add_column (full_header, ecol, i);
- }
-
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- e_table = e_table_new (full_header, e_table_model, col_spec, group_spec);
-
- gtk_container_add (GTK_CONTAINER (window), e_table);
-
- gtk_widget_set_usize (window, 200, 200);
- gtk_widget_show (e_table);
- gtk_widget_show (window);
-}
-
-void
-e_table_test (void)
-{
- load_data ();
-
- if (getenv ("DO")){
- do_e_table_demo ("0,1,2,3,4", NULL);
- do_e_table_demo ("0,1,2,3,4", "3,4");
- }
- do_e_table_demo ("0,1,2,3,4", "3");
-}
diff --git a/widgets/e-table/test.c b/widgets/e-table/test.c
deleted file mode 100644
index 0eece34467..0000000000
--- a/widgets/e-table/test.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <config.h>
-#include "e-table-simple.h"
-
-struct {
- char *str;
- int val;
-} data [] = {
- { "Miguel", 10 },
- { "Nat", 20 },
- { NULL, 0 },
-};
-
-main ()
-{
-
-}
-
diff --git a/widgets/e-text-event-processor-emacs-like.c b/widgets/e-text-event-processor-emacs-like.c
deleted file mode 100644
index 41bcd0c31d..0000000000
--- a/widgets/e-text-event-processor-emacs-like.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include "e-text-event-processor-emacs-like.h"
-static void e_text_event_processor_emacs_like_init (ETextEventProcessorEmacsLike *card);
-static void e_text_event_processor_emacs_like_class_init (ETextEventProcessorEmacsLikeClass *klass);
-static gint e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event);
-
-static ETextEventProcessorClass *parent_class = NULL;
-
-/* The arguments we take */
-enum {
- ARG_0
-};
-
-static const ETextEventProcessorCommand control_keys[26] =
-{
- { E_TEP_START_OF_LINE, E_TEP_MOVE, 0, "" }, /* a */
- { E_TEP_BACKWARD_CHARACTER, E_TEP_MOVE, 0, "" }, /* b */
- { E_TEP_SELECTION, E_TEP_COPY, 0, "" }, /* c */
- { E_TEP_FORWARD_CHARACTER, E_TEP_DELETE, 0, "" }, /* d */
- { E_TEP_END_OF_LINE, E_TEP_MOVE, 0, "" }, /* e */
- { E_TEP_FORWARD_CHARACTER, E_TEP_MOVE, 0, "" }, /* f */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* g */
- { E_TEP_BACKWARD_CHARACTER, E_TEP_DELETE, 0, "" }, /* h */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* i */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* j */
- { E_TEP_END_OF_LINE, E_TEP_DELETE, 0, "" }, /* k */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* l */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* m */
- { E_TEP_FORWARD_LINE, E_TEP_MOVE, 0, "" }, /* n */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* o */
- { E_TEP_BACKWARD_LINE, E_TEP_MOVE, 0, "" }, /* p */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* q */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* r */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* s */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* t */
- { E_TEP_START_OF_LINE, E_TEP_DELETE, 0, "" }, /* u */
- { E_TEP_SELECTION, E_TEP_PASTE, 0, "" }, /* v */
- { E_TEP_BACKWARD_WORD, E_TEP_DELETE, 0, "" }, /* w */
- { E_TEP_SELECTION, E_TEP_DELETE, 0, "" }, /* x */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* y */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" } /* z */
-};
-
-static const ETextEventProcessorCommand alt_keys[26] =
-{
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* a */
- { E_TEP_BACKWARD_WORD, E_TEP_MOVE, 0, "" }, /* b */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* c */
- { E_TEP_FORWARD_WORD, E_TEP_DELETE, 0, "" }, /* d */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* e */
- { E_TEP_FORWARD_WORD, E_TEP_MOVE, 0, "" }, /* f */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* g */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* h */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* i */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* j */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* k */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* l */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* m */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* n */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* o */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* p */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* q */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* r */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* s */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* t */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* u */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* v */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* w */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* x */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* y */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" } /* z */
-
-};
-
-GtkType
-e_text_event_processor_emacs_like_get_type (void)
-{
- static GtkType text_event_processor_emacs_like_type = 0;
-
- if (!text_event_processor_emacs_like_type)
- {
- static const GtkTypeInfo text_event_processor_emacs_like_info =
- {
- "ETextEventProcessorEmacsLike",
- sizeof (ETextEventProcessorEmacsLike),
- sizeof (ETextEventProcessorEmacsLikeClass),
- (GtkClassInitFunc) e_text_event_processor_emacs_like_class_init,
- (GtkObjectInitFunc) e_text_event_processor_emacs_like_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- text_event_processor_emacs_like_type = gtk_type_unique (e_text_event_processor_get_type (), &text_event_processor_emacs_like_info);
- }
-
- return text_event_processor_emacs_like_type;
-}
-
-static void
-e_text_event_processor_emacs_like_class_init (ETextEventProcessorEmacsLikeClass *klass)
-{
- GtkObjectClass *object_class;
- ETextEventProcessorClass *processor_class;
-
- object_class = (GtkObjectClass*) klass;
- processor_class = (ETextEventProcessorClass*) klass;
-
- parent_class = gtk_type_class (e_text_event_processor_get_type ());
-
- processor_class->event = e_text_event_processor_emacs_like_event;
-}
-
-static void
-e_text_event_processor_emacs_like_init (ETextEventProcessorEmacsLike *tep)
-{
-}
-
-static gint
-e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event)
-{
- ETextEventProcessorCommand command;
- ETextEventProcessorEmacsLike *tep_el = E_TEXT_EVENT_PROCESSOR_EMACS_LIKE(tep);
- command.action = E_TEP_NOP;
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if (event->button.button == 1) {
- command.action = E_TEP_GRAB;
- command.time = event->button.time;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
- if (event->button.state & GDK_SHIFT_MASK)
- command.action = E_TEP_SELECT;
- else
- command.action = E_TEP_MOVE;
- command.position = E_TEP_VALUE;
- command.value = event->button.position;
- command.time = event->button.time;
- tep_el->mouse_down = TRUE;
- }
- break;
- case GDK_BUTTON_RELEASE:
- if (event->button.button == 1) {
- command.action = E_TEP_UNGRAB;
- command.time = event->button.time;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
- command.time = event->button.time;
- tep_el->mouse_down = FALSE;
- } else if (event->button.button == 2) {
- command.action = E_TEP_MOVE;
- command.position = E_TEP_VALUE;
- command.value = event->button.position;
- command.time = event->button.time;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
-
- command.action = E_TEP_GET_SELECTION;
- command.position = E_TEP_SELECTION;
- command.value = 0;
- command.time = event->button.time;
- }
- break;
- case GDK_MOTION_NOTIFY:
- if (tep_el->mouse_down) {
- command.action = E_TEP_SELECT;
- command.position = E_TEP_VALUE;
- command.time = event->motion.time;
- command.value = event->motion.position;
- }
- break;
- case GDK_KEY_PRESS:
- {
- ETextEventProcessorEventKey key = event->key;
- command.time = event->key.time;
- if (key.state & GDK_SHIFT_MASK)
- command.action = E_TEP_SELECT;
- else
- command.action = E_TEP_MOVE;
- switch(key.keyval) {
- case GDK_Home:
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_START_OF_BUFFER;
- else
- command.position = E_TEP_START_OF_LINE;
- break;
- case GDK_End:
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_END_OF_BUFFER;
- else
- command.position = E_TEP_END_OF_LINE;
- break;
- case GDK_Page_Up: command.position = E_TEP_BACKWARD_PAGE; break;
- case GDK_Page_Down: command.position = E_TEP_FORWARD_PAGE; break;
- /* CUA has Ctrl-Up/Ctrl-Down as paragraph up down */
- case GDK_Up: command.position = E_TEP_BACKWARD_LINE; break;
- case GDK_Down: command.position = E_TEP_FORWARD_LINE; break;
- case GDK_Left:
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_BACKWARD_WORD;
- else
- command.position = E_TEP_BACKWARD_CHARACTER;
- break;
- case GDK_Right:
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_FORWARD_WORD;
- else
- command.position = E_TEP_FORWARD_CHARACTER;
- break;
-
- case GDK_BackSpace:
- command.action = E_TEP_DELETE;
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_BACKWARD_WORD;
- else
- command.position = E_TEP_BACKWARD_CHARACTER;
- break;
- case GDK_Clear:
- command.action = E_TEP_DELETE;
- command.position = E_TEP_END_OF_LINE;
- break;
- case GDK_Insert:
- if (key.state & GDK_SHIFT_MASK) {
- command.action = E_TEP_PASTE;
- command.position = E_TEP_SELECTION;
- } else if (key.state & GDK_CONTROL_MASK) {
- command.action = E_TEP_COPY;
- command.position = E_TEP_SELECTION;
- } else {
- /* gtk_toggle_insert(text) -- IMPLEMENT */
- }
- break;
- case GDK_Delete:
- if (key.state & GDK_CONTROL_MASK){
- command.action = E_TEP_DELETE;
- command.position = E_TEP_FORWARD_WORD;
- } else if (key.state & GDK_SHIFT_MASK) {
- command.action = E_TEP_COPY;
- command.position = E_TEP_SELECTION;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
-
- command.action = E_TEP_DELETE;
- command.position = E_TEP_SELECTION;
- } else {
- command.action = E_TEP_DELETE;
- command.position = E_TEP_FORWARD_CHARACTER;
- }
- break;
- case GDK_Tab:
- /* Don't insert literally */
- command.action = E_TEP_NOP;
- command.position = E_TEP_SELECTION;
- break;
- case GDK_Return:
- if (key.state & GDK_CONTROL_MASK) {
- command.action = E_TEP_ACTIVATE;
- command.position = E_TEP_SELECTION;
- } else {
- command.action = E_TEP_INSERT;
- command.position = E_TEP_SELECTION;
- command.value = 1;
- command.string = "\n";
- }
- break;
- case GDK_Escape:
- /* Don't insert literally */
- command.action = E_TEP_NOP;
- command.position = E_TEP_SELECTION;
- break;
-
- default:
- if (key.state & GDK_CONTROL_MASK) {
- if ((key.keyval >= 'A') && (key.keyval <= 'Z'))
- key.keyval -= 'A' - 'a';
-
- if ((key.keyval >= 'a') && (key.keyval <= 'z')) {
- command.position = control_keys[(int) (key.keyval - 'a')].position;
- if (control_keys[(int) (key.keyval - 'a')].action != E_TEP_MOVE)
- command.action = control_keys[(int) (key.keyval - 'a')].action;
- command.value = control_keys[(int) (key.keyval - 'a')].value;
- command.string = control_keys[(int) (key.keyval - 'a')].string;
- }
-
- if (key.keyval == 'x') {
- command.action = E_TEP_COPY;
- command.position = E_TEP_SELECTION;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
-
- command.action = E_TEP_DELETE;
- command.position = E_TEP_SELECTION;
- }
-
- break;
- } else if (key.state & GDK_MOD1_MASK) {
- if ((key.keyval >= 'A') && (key.keyval <= 'Z'))
- key.keyval -= 'A' - 'a';
-
- if ((key.keyval >= 'a') && (key.keyval <= 'z')) {
- command.position = alt_keys[(int) (key.keyval - 'a')].position;
- if (alt_keys[(int) (key.keyval - 'a')].action != E_TEP_MOVE)
- command.action = alt_keys[(int) (key.keyval - 'a')].action;
- command.value = alt_keys[(int) (key.keyval - 'a')].value;
- command.string = alt_keys[(int) (key.keyval - 'a')].string;
- }
- } else if (key.length > 0) {
- command.action = E_TEP_INSERT;
- command.position = E_TEP_SELECTION;
- command.value = strlen(key.string);
- command.string = key.string;
-
- } else {
- command.action = E_TEP_NOP;
- }
- }
- break;
- case GDK_KEY_RELEASE:
- command.time = event->key.time;
- command.action = E_TEP_NOP;
- break;
- default:
- command.action = E_TEP_NOP;
- break;
- }
- }
- if (command.action != E_TEP_NOP) {
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
- return 1;
- }
- else
- return 0;
-}
-
-ETextEventProcessor *
-e_text_event_processor_emacs_like_new (void)
-{
- ETextEventProcessorEmacsLike *retval = gtk_type_new (e_text_event_processor_emacs_like_get_type ());
- return E_TEXT_EVENT_PROCESSOR (retval);
-}
-
diff --git a/widgets/e-text-event-processor-emacs-like.h b/widgets/e-text-event-processor-emacs-like.h
deleted file mode 100644
index 651bb552b3..0000000000
--- a/widgets/e-text-event-processor-emacs-like.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor-emacs-like.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__
-#define __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__
-
-#include <gnome.h>
-#include "e-text-event-processor.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* ETextEventProcessorEmacsLike - Turns events on a text widget into commands. Uses an emacs-ish interface.
- *
- */
-
-#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE (e_text_event_processor_emacs_like_get_type ())
-#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE(obj) (GTK_CHECK_CAST ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE, ETextEventProcessorEmacsLike))
-#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE, ETextEventProcessorEmacsLikeClass))
-#define E_IS_TEXT_EVENT_PROCESSOR_EMACS_LIKE(obj) (GTK_CHECK_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE))
-#define E_IS_TEXT_EVENT_PROCESSOR_EMACS_LIKE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE))
-
-
-typedef struct _ETextEventProcessorEmacsLike ETextEventProcessorEmacsLike;
-typedef struct _ETextEventProcessorEmacsLikeClass ETextEventProcessorEmacsLikeClass;
-
-struct _ETextEventProcessorEmacsLike
-{
- ETextEventProcessor parent;
-
- /* object specific fields */
- gboolean mouse_down;
-};
-
-struct _ETextEventProcessorEmacsLikeClass
-{
- ETextEventProcessorClass parent_class;
-};
-
-
-GtkType e_text_event_processor_emacs_like_get_type (void);
-ETextEventProcessor *e_text_event_processor_emacs_like_new (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__ */
diff --git a/widgets/e-text-event-processor-types.h b/widgets/e-text-event-processor-types.h
deleted file mode 100644
index 32a39bf0c0..0000000000
--- a/widgets/e-text-event-processor-types.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __E_TEXT_EVENT_PROCESSOR_TYPES_H__
-#define __E_TEXT_EVENT_PROCESSOR_TYPES_H__
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#include <gdk/gdktypes.h>
-
-typedef enum _ETextEventProcessorCommandPosition ETextEventProcessorCommandPosition;
-typedef enum _ETextEventProcessorCommandAction ETextEventProcessorCommandAction;
-typedef struct _ETextEventProcessorCommand ETextEventProcessorCommand;
-
-typedef union _ETextEventProcessorEvent ETextEventProcessorEvent;
-typedef struct _ETextEventProcessorEventButton ETextEventProcessorEventButton;
-typedef struct _ETextEventProcessorEventKey ETextEventProcessorEventKey;
-typedef struct _ETextEventProcessorEventMotion ETextEventProcessorEventMotion;
-
-enum _ETextEventProcessorCommandPosition {
- E_TEP_VALUE,
- E_TEP_SELECTION,
-
- E_TEP_START_OF_BUFFER,
- E_TEP_END_OF_BUFFER,
-
- E_TEP_START_OF_LINE,
- E_TEP_END_OF_LINE,
-
- E_TEP_FORWARD_CHARACTER,
- E_TEP_BACKWARD_CHARACTER,
-
- E_TEP_FORWARD_WORD,
- E_TEP_BACKWARD_WORD,
-
- E_TEP_FORWARD_LINE,
- E_TEP_BACKWARD_LINE,
-
- E_TEP_FORWARD_PARAGRAPH,
- E_TEP_BACKWARD_PARAGRAPH,
-
- E_TEP_FORWARD_PAGE,
- E_TEP_BACKWARD_PAGE
-};
-
-enum _ETextEventProcessorCommandAction {
- E_TEP_MOVE,
- E_TEP_SELECT,
- E_TEP_DELETE,
- E_TEP_INSERT,
-
- E_TEP_COPY,
- E_TEP_PASTE,
- E_TEP_GET_SELECTION,
- E_TEP_SET_SELECT_BY_WORD,
- E_TEP_ACTIVATE,
-
- E_TEP_GRAB,
- E_TEP_UNGRAB,
-
- E_TEP_NOP
-};
-
-struct _ETextEventProcessorCommand {
- ETextEventProcessorCommandPosition position;
- ETextEventProcessorCommandAction action;
- int value;
- char *string;
- guint32 time;
-};
-
-struct _ETextEventProcessorEventButton {
- GdkEventType type;
- guint32 time;
- guint state;
- guint button;
- gint position;
-};
-
-struct _ETextEventProcessorEventKey {
- GdkEventType type;
- guint32 time;
- guint state;
- guint keyval;
- gint length;
- gchar *string;
-};
-
-struct _ETextEventProcessorEventMotion {
- GdkEventType type;
- guint32 time;
- guint state;
- gint position;
-};
-
-union _ETextEventProcessorEvent {
- GdkEventType type;
- ETextEventProcessorEventButton button;
- ETextEventProcessorEventKey key;
- ETextEventProcessorEventMotion motion;
-};
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_TEXT_EVENT_PROCESSOR_TYPES_H__ */
diff --git a/widgets/e-text-event-processor.c b/widgets/e-text-event-processor.c
deleted file mode 100644
index 47f028ca62..0000000000
--- a/widgets/e-text-event-processor.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include "e-text-event-processor.h"
-static void e_text_event_processor_init (ETextEventProcessor *card);
-static void e_text_event_processor_class_init (ETextEventProcessorClass *klass);
-
-static GtkObjectClass *parent_class = NULL;
-
-/* The arguments we take */
-enum {
- ARG_0
-};
-
-enum {
- E_TEP_EVENT,
- E_TEP_LAST_SIGNAL
-};
-
-static guint e_tep_signals[E_TEP_LAST_SIGNAL] = { 0 };
-
-GtkType
-e_text_event_processor_get_type (void)
-{
- static GtkType text_event_processor_type = 0;
-
- if (!text_event_processor_type)
- {
- static const GtkTypeInfo text_event_processor_info =
- {
- "ETextEventProcessor",
- sizeof (ETextEventProcessor),
- sizeof (ETextEventProcessorClass),
- (GtkClassInitFunc) e_text_event_processor_class_init,
- (GtkObjectInitFunc) e_text_event_processor_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- text_event_processor_type = gtk_type_unique (gtk_object_get_type (), &text_event_processor_info);
- }
-
- return text_event_processor_type;
-}
-
-static void
-e_text_event_processor_class_init (ETextEventProcessorClass *klass)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass*) klass;
-
- parent_class = gtk_type_class (gtk_object_get_type ());
-
- e_tep_signals[E_TEP_EVENT] =
- gtk_signal_new ("command",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETextEventProcessorClass, command),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
-
- gtk_object_class_add_signals (object_class, e_tep_signals, E_TEP_LAST_SIGNAL);
-
- klass->event = NULL;
- klass->command = NULL;
-}
-
-static void
-e_text_event_processor_init (ETextEventProcessor *tep)
-{
-}
-
-gint
-e_text_event_processor_handle_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event)
-{
- if (E_TEXT_EVENT_PROCESSOR_CLASS(GTK_OBJECT(tep)->klass)->event) {
- return E_TEXT_EVENT_PROCESSOR_CLASS(GTK_OBJECT(tep)->klass)->event(tep, event);
- } else {
- return 0;
- }
-}
diff --git a/widgets/e-text-event-processor.h b/widgets/e-text-event-processor.h
deleted file mode 100644
index 1fc79f3f70..0000000000
--- a/widgets/e-text-event-processor.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_TEXT_EVENT_PROCESSOR_H__
-#define __E_TEXT_EVENT_PROCESSOR_H__
-
-#include <gnome.h>
-#include "e-text-event-processor-types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* ETextEventProcessor - Turns events on a text widget into commands.
- *
- */
-
-#define E_TEXT_EVENT_PROCESSOR_TYPE (e_text_event_processor_get_type ())
-#define E_TEXT_EVENT_PROCESSOR(obj) (GTK_CHECK_CAST ((obj), E_TEXT_EVENT_PROCESSOR_TYPE, ETextEventProcessor))
-#define E_TEXT_EVENT_PROCESSOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TEXT_EVENT_PROCESSOR_TYPE, ETextEventProcessorClass))
-#define E_IS_TEXT_EVENT_PROCESSOR(obj) (GTK_CHECK_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_TYPE))
-#define E_IS_TEXT_EVENT_PROCESSOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_TYPE))
-
-
-typedef struct _ETextEventProcessor ETextEventProcessor;
-typedef struct _ETextEventProcessorClass ETextEventProcessorClass;
-
-struct _ETextEventProcessor
-{
- GtkObject parent;
-
- /* object specific fields */
-
-};
-
-struct _ETextEventProcessorClass
-{
- GtkObjectClass parent_class;
-
- /* signals */
- void (* command) (ETextEventProcessor *tep, ETextEventProcessorCommand *command);
-
- /* virtual functions */
- gint (* event) (ETextEventProcessor *tep, ETextEventProcessorEvent *event);
-};
-
-
-GtkType e_text_event_processor_get_type (void);
-gint e_text_event_processor_handle_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_TEXT_EVENT_PROCESSOR_H__ */
diff --git a/widgets/e-text.c b/widgets/e-text.c
deleted file mode 100644
index bfff8e251a..0000000000
--- a/widgets/e-text.c
+++ /dev/null
@@ -1,2391 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* EText - Text item for evolution.
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Chris Lahey <clahey@umich.edu>
- *
- * A majority of code taken from:
- *
- * Text item type for GnomeCanvas widget
- *
- * GnomeCanvas is basically a port of the Tk toolkit's most excellent
- * canvas widget. Tk is copyrighted by the Regents of the University
- * of California, Sun Microsystems, and other parties.
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx> */
-
-#include <config.h>
-#include <math.h>
-#include <ctype.h>
-#include "e-text.h"
-#include <gdk/gdkx.h> /* for BlackPixel */
-#include <libart_lgpl/art_affine.h>
-#include <libart_lgpl/art_rgb.h>
-#include <libart_lgpl/art_rgb_bitmap_affine.h>
-#include <gtk/gtkinvisible.h>
-
-#include "e-text-event-processor-emacs-like.h"
-
-enum {
- E_TEXT_RESIZE,
- E_TEXT_CHANGE,
- E_TEXT_LAST_SIGNAL
-};
-
-static guint e_text_signals[E_TEXT_LAST_SIGNAL] = { 0 };
-
-
-
-/* This defines a line of text */
-struct line {
- char *text; /* Line's text, it is a pointer into the text->text string */
- int length; /* Line's length in characters */
- int width; /* Line's width in pixels */
- int ellipsis_length; /* Length before adding ellipsis */
-};
-
-
-
-/* Object argument IDs */
-enum {
- ARG_0,
- ARG_TEXT,
- ARG_X,
- ARG_Y,
- ARG_FONT,
- ARG_FONTSET,
- ARG_FONT_GDK,
- ARG_ANCHOR,
- ARG_JUSTIFICATION,
- ARG_CLIP_WIDTH,
- ARG_CLIP_HEIGHT,
- ARG_CLIP,
- ARG_X_OFFSET,
- ARG_Y_OFFSET,
- ARG_FILL_COLOR,
- ARG_FILL_COLOR_GDK,
- ARG_FILL_COLOR_RGBA,
- ARG_FILL_STIPPLE,
- ARG_TEXT_WIDTH,
- ARG_TEXT_HEIGHT,
- ARG_EDITABLE,
- ARG_USE_ELLIPSIS,
- ARG_ELLIPSIS
-};
-
-
-enum {
- E_SELECTION_PRIMARY,
- E_SELECTION_CLIPBOARD
-};
-enum {
- TARGET_STRING,
- TARGET_TEXT,
- TARGET_COMPOUND_TEXT
-};
-
-static void e_text_class_init (ETextClass *class);
-static void e_text_init (EText *text);
-static void e_text_destroy (GtkObject *object);
-static void e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static void e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-
-static void e_text_update (GnomeCanvasItem *item, double *affine,
- ArtSVP *clip_path, int flags);
-static void e_text_realize (GnomeCanvasItem *item);
-static void e_text_unrealize (GnomeCanvasItem *item);
-static void e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height);
-static double e_text_point (GnomeCanvasItem *item, double x, double y, int cx, int cy,
- GnomeCanvasItem **actual_item);
-static void e_text_bounds (GnomeCanvasItem *item,
- double *x1, double *y1, double *x2, double *y2);
-static void e_text_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf);
-static gint e_text_event (GnomeCanvasItem *item, GdkEvent *event);
-
-static void e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gpointer data);
-
-static guint32 e_text_get_event_time (EText *text);
-
-static void e_text_get_selection(EText *text, GdkAtom selection, guint32 time);
-static void e_text_supply_selection (EText *text, guint time, GdkAtom selection, guchar *data, gint length);
-
-static GtkWidget *e_text_get_invisible(EText *text);
-static void _selection_clear_event (GtkInvisible *invisible,
- GdkEventSelection *event,
- EText *text);
-static void _selection_get (GtkInvisible *invisible,
- GtkSelectionData *selection_data,
- guint info,
- guint time_stamp,
- EText *text);
-static void _selection_received (GtkInvisible *invisible,
- GtkSelectionData *selection_data,
- guint time,
- EText *text);
-
-static ETextSuckFont *e_suck_font (GdkFont *font);
-static void e_suck_font_free (ETextSuckFont *suckfont);
-
-
-static GnomeCanvasItemClass *parent_class;
-static GdkAtom clipboard_atom = GDK_NONE;
-
-
-
-/**
- * e_text_get_type:
- * @void:
- *
- * Registers the &EText class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the &EText class.
- **/
-GtkType
-e_text_get_type (void)
-{
- static GtkType text_type = 0;
-
- if (!text_type) {
- GtkTypeInfo text_info = {
- "EText",
- sizeof (EText),
- sizeof (ETextClass),
- (GtkClassInitFunc) e_text_class_init,
- (GtkObjectInitFunc) e_text_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- text_type = gtk_type_unique (gnome_canvas_item_get_type (), &text_info);
- }
-
- return text_type;
-}
-
-/* Class initialization function for the text item */
-static void
-e_text_class_init (ETextClass *klass)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass *) klass;
- item_class = (GnomeCanvasItemClass *) klass;
-
- parent_class = gtk_type_class (gnome_canvas_item_get_type ());
-
- e_text_signals[E_TEXT_RESIZE] =
- gtk_signal_new ("resize",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETextClass, resize),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
-
- e_text_signals[E_TEXT_CHANGE] =
- gtk_signal_new ("change",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETextClass, change),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
-
- gtk_object_class_add_signals (object_class, e_text_signals, E_TEXT_LAST_SIGNAL);
-
- gtk_object_add_arg_type ("EText::text",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TEXT);
- gtk_object_add_arg_type ("EText::x",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_X);
- gtk_object_add_arg_type ("EText::y",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_Y);
- gtk_object_add_arg_type ("EText::font",
- GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FONT);
- gtk_object_add_arg_type ("EText::fontset",
- GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FONTSET);
- gtk_object_add_arg_type ("EText::font_gdk",
- GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_FONT_GDK);
- gtk_object_add_arg_type ("EText::anchor",
- GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_ANCHOR);
- gtk_object_add_arg_type ("EText::justification",
- GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_JUSTIFICATION);
- gtk_object_add_arg_type ("EText::clip_width",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_CLIP_WIDTH);
- gtk_object_add_arg_type ("EText::clip_height",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_CLIP_HEIGHT);
- gtk_object_add_arg_type ("EText::clip",
- GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_CLIP);
- gtk_object_add_arg_type ("EText::x_offset",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_X_OFFSET);
- gtk_object_add_arg_type ("EText::y_offset",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_Y_OFFSET);
- gtk_object_add_arg_type ("EText::fill_color",
- GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FILL_COLOR);
- gtk_object_add_arg_type ("EText::fill_color_gdk",
- GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_FILL_COLOR_GDK);
- gtk_object_add_arg_type ("EText::fill_color_rgba",
- GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_FILL_COLOR_RGBA);
- gtk_object_add_arg_type ("EText::fill_stipple",
- GTK_TYPE_GDK_WINDOW, GTK_ARG_READWRITE, ARG_FILL_STIPPLE);
- gtk_object_add_arg_type ("EText::text_width",
- GTK_TYPE_DOUBLE, GTK_ARG_READABLE, ARG_TEXT_WIDTH);
- gtk_object_add_arg_type ("EText::text_height",
- GTK_TYPE_DOUBLE, GTK_ARG_READABLE, ARG_TEXT_HEIGHT);
- gtk_object_add_arg_type ("EText::editable",
- GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EDITABLE);
- gtk_object_add_arg_type ("EText::use_ellipsis",
- GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_USE_ELLIPSIS);
- gtk_object_add_arg_type ("EText::ellipsis",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ELLIPSIS);
-
- if (!clipboard_atom)
- clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
-
-
-
- klass->resize = NULL;
- klass->change = NULL;
-
- object_class->destroy = e_text_destroy;
- object_class->set_arg = e_text_set_arg;
- object_class->get_arg = e_text_get_arg;
-
- item_class->update = e_text_update;
- item_class->realize = e_text_realize;
- item_class->unrealize = e_text_unrealize;
- item_class->draw = e_text_draw;
- item_class->point = e_text_point;
- item_class->bounds = e_text_bounds;
- item_class->render = e_text_render;
- item_class->event = e_text_event;
-}
-
-/* Object initialization function for the text item */
-static void
-e_text_init (EText *text)
-{
- text->x = 0.0;
- text->y = 0.0;
- text->anchor = GTK_ANCHOR_CENTER;
- text->justification = GTK_JUSTIFY_LEFT;
- text->clip_width = 0.0;
- text->clip_height = 0.0;
- text->xofs = 0.0;
- text->yofs = 0.0;
-
- text->ellipsis = NULL;
- text->use_ellipsis = FALSE;
- text->ellipsis_width = 0;
-
- text->editable = FALSE;
- text->editing = FALSE;
- text->xofs_edit = 0;
-
- text->selection_start = 0;
- text->selection_end = 0;
- text->select_by_word = FALSE;
-
- text->timeout_id = 0;
- text->timer = NULL;
-
- text->lastx = 0;
- text->lasty = 0;
- text->last_state = 0;
-
- text->scroll_start = 0;
- text->show_cursor = TRUE;
- text->button_down = FALSE;
-
- text->tep = NULL;
-
- text->has_selection = FALSE;
-
- text->invisible = NULL;
- text->primary_selection = NULL;
- text->primary_length = 0;
- text->clipboard_selection = NULL;
- text->clipboard_length = 0;
-
- text->pointer_in = FALSE;
- text->default_cursor_shown = TRUE;
-}
-
-/* Destroy handler for the text item */
-static void
-e_text_destroy (GtkObject *object)
-{
- EText *text;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNOME_IS_CANVAS_TEXT (object));
-
- text = E_TEXT (object);
-
- if (text->text)
- g_free (text->text);
-
- if (text->tep)
- gtk_object_unref (GTK_OBJECT(text->tep));
-
- if (text->invisible)
- gtk_object_unref (GTK_OBJECT(text->invisible));
-
- if (text->lines)
- g_free (text->lines);
-
- if (text->font)
- gdk_font_unref (text->font);
-
- if (text->suckfont)
- e_suck_font_free (text->suckfont);
-
- if (text->stipple)
- gdk_bitmap_unref (text->stipple);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-static void
-get_bounds_item_relative (EText *text, double *px1, double *py1, double *px2, double *py2)
-{
- GnomeCanvasItem *item;
- double x, y;
- double clip_x, clip_y;
- int old_height;
-
- item = GNOME_CANVAS_ITEM (text);
-
- x = text->x;
- y = text->y;
-
- clip_x = x;
- clip_y = y;
-
- /* Calculate text dimensions */
-
- old_height = text->height;
-
- if (text->text && text->font)
- text->height = (text->font->ascent + text->font->descent) * text->num_lines;
- else
- text->height = 0;
-
- if (old_height != text->height)
- gtk_signal_emit_by_name (GTK_OBJECT (text), "resize");
-
- /* Anchor text */
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- x -= text->max_width / 2;
- clip_x -= text->clip_width / 2;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- x -= text->max_width;
- clip_x -= text->clip_width;
- break;
- }
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- y -= text->height / 2;
- clip_y -= text->clip_height / 2;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- y -= text->height;
- clip_y -= text->clip_height;
- break;
- }
-
- /* Bounds */
-
- if (text->clip) {
- /* maybe do bbox intersection here? */
- *px1 = clip_x;
- *py1 = clip_y;
- *px2 = clip_x + text->clip_width;
- *py2 = clip_y + text->clip_height;
- } else {
- *px1 = x;
- *py1 = y;
- *px2 = x + text->max_width;
- *py2 = y + text->height;
- }
-}
-
-static void
-get_bounds (EText *text, double *px1, double *py1, double *px2, double *py2)
-{
- GnomeCanvasItem *item;
- double wx, wy;
- int old_height;
-
- item = GNOME_CANVAS_ITEM (text);
-
- /* Get canvas pixel coordinates for text position */
-
- wx = text->x;
- wy = text->y;
- gnome_canvas_item_i2w (item, &wx, &wy);
- gnome_canvas_w2c (item->canvas, wx + text->xofs, wy + text->yofs, &text->cx, &text->cy);
-
- /* Get canvas pixel coordinates for clip rectangle position */
-
- gnome_canvas_w2c (item->canvas, wx, wy, &text->clip_cx, &text->clip_cy);
- text->clip_cwidth = text->clip_width * item->canvas->pixels_per_unit;
- text->clip_cheight = text->clip_height * item->canvas->pixels_per_unit;
-
- /* Calculate text dimensions */
-
- old_height = text->height;
-
- if (text->text && text->font)
- text->height = (text->font->ascent + text->font->descent) * text->num_lines;
- else
- text->height = 0;
-
- if (old_height != text->height)
- gtk_signal_emit_by_name (GTK_OBJECT (text), "resize");
-
- /* Anchor text */
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- text->cx -= text->max_width / 2;
- text->clip_cx -= text->clip_cwidth / 2;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- text->cx -= text->max_width;
- text->clip_cx -= text->clip_cwidth;
- break;
- }
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- text->cy -= text->height / 2;
- text->clip_cy -= text->clip_cheight / 2;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- text->cy -= text->height;
- text->clip_cy -= text->clip_cheight;
- break;
- }
-
- /* Bounds */
-
- if (text->clip) {
- *px1 = text->clip_cx;
- *py1 = text->clip_cy;
- *px2 = text->clip_cx + text->clip_cwidth;
- *py2 = text->clip_cy + text->clip_cheight;
- } else {
- *px1 = text->cx;
- *py1 = text->cy;
- *px2 = text->cx + text->max_width;
- *py2 = text->cy + text->height;
- }
-}
-
-/* Recalculates the bounding box of the text item. The bounding box is defined
- * by the text's extents if the clip rectangle is disabled. If it is enabled,
- * the bounding box is defined by the clip rectangle itself.
- */
-static void
-recalc_bounds (EText *text)
-{
- GnomeCanvasItem *item;
-
- item = GNOME_CANVAS_ITEM (text);
-
- get_bounds (text, &item->x1, &item->y1, &item->x2, &item->y2);
-
- gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
-}
-
-static void
-calc_ellipsis (EText *text)
-{
- if (text->font)
- text->ellipsis_width =
- gdk_text_width (text->font,
- text->ellipsis ? text->ellipsis : "...",
- text->ellipsis ? strlen (text->ellipsis) : 3);
-}
-
-/* Calculates the line widths (in pixels) of the text's splitted lines */
-static void
-calc_line_widths (EText *text)
-{
- struct line *lines;
- int i;
- int j;
-
- lines = text->lines;
- text->max_width = 0;
-
- if (!lines)
- return;
-
- for (i = 0; i < text->num_lines; i++) {
- if (lines->length != 0) {
- if (text->font) {
- lines->width = gdk_text_width (text->font,
- lines->text, lines->length);
- lines->ellipsis_length = 0;
- } else {
- lines->width = 0;
- }
-
- if (text->clip &&
- text->use_ellipsis &&
- ! text->editing &&
- lines->width > text->clip_width) {
- if (text->font) {
- lines->ellipsis_length = 0;
- for (j = 0; j < lines->length; j++ ) {
- if (gdk_text_width (text->font, lines->text, j) + text->ellipsis_width <= text->clip_width)
- lines->ellipsis_length = j;
- else
- break;
- }
- }
- else
- lines->ellipsis_length = 0;
- lines->width = gdk_text_width (text->font, lines->text, lines->ellipsis_length) +
- text->ellipsis_width;
- }
- else
- lines->ellipsis_length = lines->length;
-
- if (lines->width > text->max_width)
- text->max_width = lines->width;
- }
-
- lines++;
- }
-}
-
-/* Splits the text of the text item into lines */
-static void
-split_into_lines (EText *text)
-{
- char *p;
- struct line *lines;
- int len;
-
- /* Free old array of lines */
-
- if (text->lines)
- g_free (text->lines);
-
- text->lines = NULL;
- text->num_lines = 0;
-
- if (!text->text)
- return;
-
- /* First, count the number of lines */
-
- for (p = text->text; *p; p++)
- if (*p == '\n')
- text->num_lines++;
-
- text->num_lines++;
-
- /* Allocate array of lines and calculate split positions */
-
- text->lines = lines = g_new0 (struct line, text->num_lines);
- len = 0;
-
- for (p = text->text; *p; p++) {
- if (len == 0)
- lines->text = p;
- if (*p == '\n') {
- lines->length = len;
- lines++;
- len = 0;
- } else
- len++;
- }
-
- if (len == 0)
- lines->text = p;
- lines->length = len;
-
- calc_line_widths (text);
-}
-
-/* Convenience function to set the text's GC's foreground color */
-static void
-set_text_gc_foreground (EText *text)
-{
- GdkColor c;
-
- if (!text->gc)
- return;
-
- c.pixel = text->pixel;
- gdk_gc_set_foreground (text->gc, &c);
-}
-
-/* Sets the stipple pattern for the text */
-static void
-set_stipple (EText *text, GdkBitmap *stipple, int reconfigure)
-{
- if (text->stipple && !reconfigure)
- gdk_bitmap_unref (text->stipple);
-
- text->stipple = stipple;
- if (stipple && !reconfigure)
- gdk_bitmap_ref (stipple);
-
- if (text->gc) {
- if (stipple) {
- gdk_gc_set_stipple (text->gc, stipple);
- gdk_gc_set_fill (text->gc, GDK_STIPPLED);
- } else
- gdk_gc_set_fill (text->gc, GDK_SOLID);
- }
-}
-
-/* Set_arg handler for the text item */
-static void
-e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EText *text;
- GdkColor color = { 0, 0, 0, 0, };
- GdkColor *pcolor;
- gboolean color_changed;
- int have_pixel;
-
- item = GNOME_CANVAS_ITEM (object);
- text = E_TEXT (object);
-
- color_changed = FALSE;
- have_pixel = FALSE;
-
- switch (arg_id) {
- case ARG_TEXT:
- if (text->text)
- g_free (text->text);
-
- text->text = g_strdup (GTK_VALUE_STRING (*arg));
- split_into_lines (text);
- recalc_bounds (text);
- break;
-
- case ARG_X:
- text->x = GTK_VALUE_DOUBLE (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_Y:
- text->y = GTK_VALUE_DOUBLE (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_FONT:
- if (text->font)
- gdk_font_unref (text->font);
-
- text->font = gdk_font_load (GTK_VALUE_STRING (*arg));
-
- if (item->canvas->aa) {
- if (text->suckfont)
- e_suck_font_free (text->suckfont);
-
- text->suckfont = e_suck_font (text->font);
- }
-
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_FONTSET:
- if (text->font)
- gdk_font_unref (text->font);
-
- text->font = gdk_fontset_load (GTK_VALUE_STRING (*arg));
-
- if (item->canvas->aa) {
- if (text->suckfont)
- e_suck_font_free (text->suckfont);
-
- text->suckfont = e_suck_font (text->font);
- }
-
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_FONT_GDK:
- if (text->font)
- gdk_font_unref (text->font);
-
- text->font = GTK_VALUE_BOXED (*arg);
- gdk_font_ref (text->font);
-
- if (item->canvas->aa) {
- if (text->suckfont)
- e_suck_font_free (text->suckfont);
-
- text->suckfont = e_suck_font (text->font);
- }
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_ANCHOR:
- text->anchor = GTK_VALUE_ENUM (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_JUSTIFICATION:
- text->justification = GTK_VALUE_ENUM (*arg);
- break;
-
- case ARG_CLIP_WIDTH:
- text->clip_width = fabs (GTK_VALUE_DOUBLE (*arg));
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_CLIP_HEIGHT:
- text->clip_height = fabs (GTK_VALUE_DOUBLE (*arg));
- recalc_bounds (text);
- break;
-
- case ARG_CLIP:
- text->clip = GTK_VALUE_BOOL (*arg);
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_X_OFFSET:
- text->xofs = GTK_VALUE_DOUBLE (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_Y_OFFSET:
- text->yofs = GTK_VALUE_DOUBLE (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_FILL_COLOR:
- if (GTK_VALUE_STRING (*arg))
- gdk_color_parse (GTK_VALUE_STRING (*arg), &color);
-
- text->rgba = ((color.red & 0xff00) << 16 |
- (color.green & 0xff00) << 8 |
- (color.blue & 0xff00) |
- 0xff);
- color_changed = TRUE;
- break;
-
- case ARG_FILL_COLOR_GDK:
- pcolor = GTK_VALUE_BOXED (*arg);
- if (pcolor) {
- color = *pcolor;
- gdk_color_context_query_color (item->canvas->cc, &color);
- have_pixel = TRUE;
- }
-
- text->rgba = ((color.red & 0xff00) << 16 |
- (color.green & 0xff00) << 8 |
- (color.blue & 0xff00) |
- 0xff);
- color_changed = TRUE;
- break;
-
- case ARG_FILL_COLOR_RGBA:
- text->rgba = GTK_VALUE_UINT (*arg);
- color_changed = TRUE;
- break;
-
- case ARG_FILL_STIPPLE:
- set_stipple (text, GTK_VALUE_BOXED (*arg), FALSE);
- break;
-
- case ARG_EDITABLE:
- text->editable = GTK_VALUE_BOOL (*arg);
- break;
-
- case ARG_USE_ELLIPSIS:
- text->use_ellipsis = GTK_VALUE_BOOL (*arg);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_ELLIPSIS:
- if (text->ellipsis)
- g_free (text->ellipsis);
-
- text->ellipsis = g_strdup (GTK_VALUE_STRING (*arg));
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- default:
- break;
- }
-
- if (color_changed) {
- if (have_pixel)
- text->pixel = color.pixel;
- else
- text->pixel = gnome_canvas_get_color_pixel (item->canvas, text->rgba);
-
- if (!item->canvas->aa)
- set_text_gc_foreground (text);
-
- gnome_canvas_item_request_update (item);
- }
-}
-
-/* Get_arg handler for the text item */
-static void
-e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- EText *text;
- GdkColor *color;
-
- text = E_TEXT (object);
-
- switch (arg_id) {
- case ARG_TEXT:
- GTK_VALUE_STRING (*arg) = g_strdup (text->text);
- break;
-
- case ARG_X:
- GTK_VALUE_DOUBLE (*arg) = text->x;
- break;
-
- case ARG_Y:
- GTK_VALUE_DOUBLE (*arg) = text->y;
- break;
-
- case ARG_FONT_GDK:
- GTK_VALUE_BOXED (*arg) = text->font;
- break;
-
- case ARG_ANCHOR:
- GTK_VALUE_ENUM (*arg) = text->anchor;
- break;
-
- case ARG_JUSTIFICATION:
- GTK_VALUE_ENUM (*arg) = text->justification;
- break;
-
- case ARG_CLIP_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = text->clip_width;
- break;
-
- case ARG_CLIP_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = text->clip_height;
- break;
-
- case ARG_CLIP:
- GTK_VALUE_BOOL (*arg) = text->clip;
- break;
-
- case ARG_X_OFFSET:
- GTK_VALUE_DOUBLE (*arg) = text->xofs;
- break;
-
- case ARG_Y_OFFSET:
- GTK_VALUE_DOUBLE (*arg) = text->yofs;
- break;
-
- case ARG_FILL_COLOR_GDK:
- color = g_new (GdkColor, 1);
- color->pixel = text->pixel;
- gdk_color_context_query_color (text->item.canvas->cc, color);
- GTK_VALUE_BOXED (*arg) = color;
- break;
-
- case ARG_FILL_COLOR_RGBA:
- GTK_VALUE_UINT (*arg) = text->rgba;
- break;
-
- case ARG_FILL_STIPPLE:
- GTK_VALUE_BOXED (*arg) = text->stipple;
- break;
-
- case ARG_TEXT_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = text->max_width / text->item.canvas->pixels_per_unit;
- break;
-
- case ARG_TEXT_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = text->height / text->item.canvas->pixels_per_unit;
- break;
-
- case ARG_EDITABLE:
- GTK_VALUE_BOOL (*arg) = text->editable;
- break;
-
- case ARG_USE_ELLIPSIS:
- GTK_VALUE_BOOL (*arg) = text->use_ellipsis;
- break;
-
- case ARG_ELLIPSIS:
- GTK_VALUE_STRING (*arg) = g_strdup (text->ellipsis);
- break;
-
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-/* Update handler for the text item */
-static void
-e_text_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- EText *text;
- double x1, y1, x2, y2;
- ArtDRect i_bbox, c_bbox;
- int i;
-
- text = E_TEXT (item);
-
- if (parent_class->update)
- (* parent_class->update) (item, affine, clip_path, flags);
-
- if (!item->canvas->aa) {
- set_text_gc_foreground (text);
- set_stipple (text, text->stipple, TRUE);
- get_bounds (text, &x1, &y1, &x2, &y2);
-
- gnome_canvas_update_bbox (item, x1, y1, x2, y2);
- } else {
- /* aa rendering */
- for (i = 0; i < 6; i++)
- text->affine[i] = affine[i];
- get_bounds_item_relative (text, &i_bbox.x0, &i_bbox.y0, &i_bbox.x1, &i_bbox.y1);
- art_drect_affine_transform (&c_bbox, &i_bbox, affine);
- gnome_canvas_update_bbox (item, c_bbox.x0, c_bbox.y0, c_bbox.x1, c_bbox.y1);
-
- }
-}
-
-/* Realize handler for the text item */
-static void
-e_text_realize (GnomeCanvasItem *item)
-{
- EText *text;
-
- text = E_TEXT (item);
-
- if (parent_class->realize)
- (* parent_class->realize) (item);
-
- text->gc = gdk_gc_new (item->canvas->layout.bin_window);
-
- text->i_cursor = gdk_cursor_new (GDK_XTERM);
- text->default_cursor = gdk_cursor_new (GDK_LEFT_PTR);
-}
-
-/* Unrealize handler for the text item */
-static void
-e_text_unrealize (GnomeCanvasItem *item)
-{
- EText *text;
-
- text = E_TEXT (item);
-
- gdk_gc_unref (text->gc);
- text->gc = NULL;
-
- gdk_cursor_destroy (text->i_cursor);
- gdk_cursor_destroy (text->default_cursor);
-
- if (parent_class->unrealize)
- (* parent_class->unrealize) (item);
-}
-
-/* Calculates the x position of the specified line of text, based on the text's justification */
-static double
-get_line_xpos_item_relative (EText *text, struct line *line)
-{
- double x;
-
- x = text->x;
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- x -= text->max_width / 2;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- x -= text->max_width;
- break;
- }
-
- switch (text->justification) {
- case GTK_JUSTIFY_RIGHT:
- x += text->max_width - line->width;
- break;
-
- case GTK_JUSTIFY_CENTER:
- x += (text->max_width - line->width) * 0.5;
- break;
-
- default:
- /* For GTK_JUSTIFY_LEFT, we don't have to do anything. We do not support
- * GTK_JUSTIFY_FILL, yet.
- */
- break;
- }
-
- return x;
-}
-
-/* Calculates the y position of the first line of text. */
-static double
-get_line_ypos_item_relative (EText *text)
-{
- double y;
-
- y = text->y;
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- y -= text->height / 2;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- y -= text->height;
- break;
- }
-
- return y;
-}
-
-/* Calculates the x position of the specified line of text, based on the text's justification */
-static int
-get_line_xpos (EText *text, struct line *line)
-{
- int x;
-
- x = text->cx;
-
- switch (text->justification) {
- case GTK_JUSTIFY_RIGHT:
- x += text->max_width - line->width;
- break;
-
- case GTK_JUSTIFY_CENTER:
- x += (text->max_width - line->width) / 2;
- break;
-
- default:
- /* For GTK_JUSTIFY_LEFT, we don't have to do anything. We do not support
- * GTK_JUSTIFY_FILL, yet.
- */
- break;
- }
-
- return x;
-}
-
-static void
-_get_tep(EText *text)
-{
- if (!text->tep) {
- text->tep = e_text_event_processor_emacs_like_new();
- gtk_object_ref (GTK_OBJECT (text->tep));
- gtk_object_sink (GTK_OBJECT (text->tep));
- gtk_signal_connect(GTK_OBJECT(text->tep),
- "command",
- GTK_SIGNAL_FUNC(e_text_command),
- (gpointer) text);
- }
-}
-
-/* Draw handler for the text item */
-static void
-e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height)
-{
- EText *text;
- GdkRectangle rect, *clip_rect;
- struct line *lines;
- int i;
- int xpos, ypos;
- int start_char, end_char;
- int sel_start, sel_end;
- GdkRectangle sel_rect;
- GdkGC *fg_gc;
- GnomeCanvas *canvas;
-
- text = E_TEXT (item);
- canvas = GNOME_CANVAS_ITEM(text)->canvas;
-
- fg_gc = GTK_WIDGET(canvas)->style->fg_gc[text->has_selection ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE];
-
- if (!text->text || !text->font)
- return;
-
- clip_rect = NULL;
- if (text->clip) {
- rect.x = text->clip_cx - x;
- rect.y = text->clip_cy - y;
- rect.width = text->clip_cwidth;
- rect.height = text->clip_cheight;
-
- gdk_gc_set_clip_rectangle (text->gc, &rect);
- gdk_gc_set_clip_rectangle (fg_gc, &rect);
- clip_rect = &rect;
- }
- lines = text->lines;
- ypos = text->cy + text->font->ascent;
-
- if (text->stipple)
- gnome_canvas_set_stipple_origin (item->canvas, text->gc);
-
- for (i = 0; i < text->num_lines; i++) {
- if (lines->length != 0) {
- xpos = get_line_xpos (text, lines);
- if (text->editing) {
- xpos -= text->xofs_edit;
- start_char = lines->text - text->text;
- end_char = start_char + lines->length;
- sel_start = text->selection_start;
- sel_end = text->selection_end;
- if (sel_start > sel_end ) {
- sel_start ^= sel_end;
- sel_end ^= sel_start;
- sel_start ^= sel_end;
- }
- if ( sel_start < start_char )
- sel_start = start_char;
- if ( sel_end > end_char )
- sel_end = end_char;
- if ( sel_start < sel_end ) {
- sel_rect.x = xpos - x + gdk_text_width (text->font,
- lines->text,
- sel_start - start_char);
- sel_rect.y = ypos - y - text->font->ascent;
- sel_rect.width = gdk_text_width (text->font,
- lines->text + sel_start - start_char,
- sel_end - sel_start);
- sel_rect.height = text->font->ascent + text->font->descent;
- gtk_paint_flat_box(GTK_WIDGET(item->canvas)->style,
- drawable,
- text->has_selection ?
- GTK_STATE_SELECTED :
- GTK_STATE_ACTIVE,
- GTK_SHADOW_NONE,
- clip_rect,
- GTK_WIDGET(item->canvas),
- "text",
- sel_rect.x,
- sel_rect.y,
- sel_rect.width,
- sel_rect.height);
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x,
- ypos - y,
- lines->text,
- sel_start - start_char);
- gdk_draw_text (drawable,
- text->font,
- fg_gc,
- xpos - x + gdk_text_width (text->font,
- lines->text,
- sel_start - start_char),
- ypos - y,
- lines->text + sel_start - start_char,
- sel_end - sel_start);
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x + gdk_text_width (text->font,
- lines->text,
- sel_end - start_char),
- ypos - y,
- lines->text + sel_end - start_char,
- end_char - sel_end);
- } else {
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x,
- ypos - y,
- lines->text,
- lines->length);
- }
- if (text->selection_start == text->selection_end &&
- text->selection_start >= start_char &&
- text->selection_start <= end_char &&
- text->show_cursor) {
- gdk_draw_rectangle (drawable,
- text->gc,
- TRUE,
- xpos - x + gdk_text_width (text->font,
- lines->text,
- sel_start - start_char),
- ypos - y - text->font->ascent,
- 1,
- text->font->ascent + text->font->descent);
- }
- } else {
- if ( text->clip && text->use_ellipsis && lines->ellipsis_length < lines->length) {
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x,
- ypos - y,
- lines->text,
- lines->ellipsis_length);
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x +
- lines->width - text->ellipsis_width,
- ypos - y,
- text->ellipsis ? text->ellipsis : "...",
- text->ellipsis ? strlen (text->ellipsis) : 3);
- } else
-
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x,
- ypos - y,
- lines->text,
- lines->length);
- }
- }
-
- ypos += text->font->ascent + text->font->descent;
- lines++;
- }
-
- if (text->clip) {
- gdk_gc_set_clip_rectangle (text->gc, NULL);
- gdk_gc_set_clip_rectangle (fg_gc, NULL);
- }
-}
-
-/* Render handler for the text item */
-static void
-e_text_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf)
-{
- EText *text;
- guint32 fg_color;
- double xpos, ypos;
- struct line *lines;
- int i, j;
- double affine[6];
- ETextSuckFont *suckfont;
- int dx, dy;
- ArtPoint start_i, start_c;
-
- text = E_TEXT (item);
-
- if (!text->text || !text->font || !text->suckfont)
- return;
-
- suckfont = text->suckfont;
-
- fg_color = text->rgba;
-
- gnome_canvas_buf_ensure_buf (buf);
-
- lines = text->lines;
- start_i.y = get_line_ypos_item_relative (text);
-
- art_affine_scale (affine, item->canvas->pixels_per_unit, item->canvas->pixels_per_unit);
- for (i = 0; i < 6; i++)
- affine[i] = text->affine[i];
-
- for (i = 0; i < text->num_lines; i++) {
- if (lines->length != 0) {
- start_i.x = get_line_xpos_item_relative (text, lines);
- art_affine_point (&start_c, &start_i, text->affine);
- xpos = start_c.x;
- ypos = start_c.y;
-
- for (j = 0; j < lines->length; j++) {
- ETextSuckChar *ch;
-
- ch = &suckfont->chars[(unsigned char)((lines->text)[j])];
-
- affine[4] = xpos;
- affine[5] = ypos;
- art_rgb_bitmap_affine (
- buf->buf,
- buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1,
- buf->buf_rowstride,
- suckfont->bitmap + (ch->bitmap_offset >> 3),
- ch->width,
- suckfont->bitmap_height,
- suckfont->bitmap_width >> 3,
- fg_color,
- affine,
- ART_FILTER_NEAREST, NULL);
-
- dx = ch->left_sb + ch->width + ch->right_sb;
- xpos += dx * affine[0];
- ypos += dx * affine[1];
- }
- }
-
- dy = text->font->ascent + text->font->descent;
- start_i.y += dy;
- lines++;
- }
-
- buf->is_bg = 0;
-}
-
-/* Point handler for the text item */
-static double
-e_text_point (GnomeCanvasItem *item, double x, double y,
- int cx, int cy, GnomeCanvasItem **actual_item)
-{
- EText *text;
- int i;
- struct line *lines;
- int x1, y1, x2, y2;
- int font_height;
- int dx, dy;
- double dist, best;
-
- text = E_TEXT (item);
-
- *actual_item = item;
-
- /* The idea is to build bounding rectangles for each of the lines of
- * text (clipped by the clipping rectangle, if it is activated) and see
- * whether the point is inside any of these. If it is, we are done.
- * Otherwise, calculate the distance to the nearest rectangle.
- */
-
- if (text->font)
- font_height = text->font->ascent + text->font->descent;
- else
- font_height = 0;
-
- best = 1.0e36;
-
- lines = text->lines;
-
- for (i = 0; i < text->num_lines; i++) {
- /* Compute the coordinates of rectangle for the current line,
- * clipping if appropriate.
- */
-
- x1 = get_line_xpos (text, lines);
- y1 = text->cy + i * font_height;
- x2 = x1 + lines->width;
- y2 = y1 + font_height;
-
- if (text->clip) {
- if (x1 < text->clip_cx)
- x1 = text->clip_cx;
-
- if (y1 < text->clip_cy)
- y1 = text->clip_cy;
-
- if (x2 > (text->clip_cx + text->clip_width))
- x2 = text->clip_cx + text->clip_width;
-
- if (y2 > (text->clip_cy + text->clip_height))
- y2 = text->clip_cy + text->clip_height;
-
- if ((x1 >= x2) || (y1 >= y2))
- continue;
- }
-
- /* Calculate distance from point to rectangle */
-
- if (cx < x1)
- dx = x1 - cx;
- else if (cx >= x2)
- dx = cx - x2 + 1;
- else
- dx = 0;
-
- if (cy < y1)
- dy = y1 - cy;
- else if (cy >= y2)
- dy = cy - y2 + 1;
- else
- dy = 0;
-
- if ((dx == 0) && (dy == 0))
- return 0.0;
-
- dist = sqrt (dx * dx + dy * dy);
- if (dist < best)
- best = dist;
-
- /* Next! */
-
- lines++;
- }
-
- return best / item->canvas->pixels_per_unit;
-}
-
-/* Bounds handler for the text item */
-static void
-e_text_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
-{
- EText *text;
- double width, height;
-
- text = E_TEXT (item);
-
- *x1 = text->x;
- *y1 = text->y;
-
- if (text->clip) {
- width = text->clip_width;
- height = text->clip_height;
- } else {
- width = text->max_width / item->canvas->pixels_per_unit;
- height = text->height / item->canvas->pixels_per_unit;
- }
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- *x1 -= width / 2.0;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- *x1 -= width;
- break;
- }
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- *y1 -= height / 2.0;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- *y1 -= height;
- break;
- }
-
- *x2 = *x1 + width;
- *y2 = *y1 + height;
-}
-
-static void
-_get_xy_from_position (EText *text, gint position, gint *xp, gint *yp)
-{
- if (xp || yp) {
- struct line *lines;
- int x, y;
- int j;
- x = get_line_xpos (text, lines);
- y = text->cy;
- for (j = 0, lines = text->lines; j < text->num_lines; lines++, j++) {
- if (lines->text > text->text + position)
- break;
- y += text->font->ascent + text->font->descent;
- }
- lines --;
- y -= text->font->descent;
-
- x += gdk_text_width (text->font,
- lines->text,
- position - (lines->text - text->text));
- x -= text->xofs_edit;
- if (xp)
- *xp = x;
- if (yp)
- *yp = y;
- }
-}
-
-static gint
-_get_position_from_xy (EText *text, gint x, gint y)
-{
- int i, j;
- int ypos = text->cy;
- int xpos;
- struct line *lines;
- j = 0;
- while (y > ypos) {
- ypos += text->font->ascent + text->font->descent;
- j ++;
- }
- j--;
- if (j >= text->num_lines)
- j = text->num_lines - 1;
- if (j < 0)
- j = 0;
- i = 0;
- lines = text->lines;
- lines += j;
- x += text->xofs_edit;
- xpos = get_line_xpos (text, lines);
- for(i = 0; i < lines->length; i++) {
- int charwidth = gdk_text_width(text->font,
- lines->text + i,
- 1);
- xpos += charwidth / 2;
- if (xpos > x) {
- break;
- }
- xpos += (charwidth + 1) / 2;
- }
- return lines->text + i - text->text;
-}
-
-#define SCROLL_WAIT_TIME 30000
-
-static gboolean
-_blink_scroll_timeout (gpointer data)
-{
- EText *text = E_TEXT(data);
- gulong current_time;
- gboolean scroll = FALSE;
- gboolean redraw = FALSE;
-
- g_timer_elapsed(text->timer, &current_time);
-
- if (text->scroll_start + SCROLL_WAIT_TIME > 1000000) {
- if (current_time > text->scroll_start - (1000000 - SCROLL_WAIT_TIME) &&
- current_time < text->scroll_start)
- scroll = TRUE;
- } else {
- if (current_time > text->scroll_start + SCROLL_WAIT_TIME ||
- current_time < text->scroll_start)
- scroll = TRUE;
- }
- if (scroll && text->button_down) {
- if (text->lastx - text->clip_cx > text->clip_cwidth &&
- text->xofs_edit < text->max_width - text->clip_cwidth) {
- text->xofs_edit += 4;
- if (text->xofs_edit > text->max_width - text->clip_cwidth + 1)
- text->xofs_edit = text->max_width - text->clip_cwidth + 1;
- redraw = TRUE;
- }
- if (text->lastx - text->clip_cx < 0 &&
- text->xofs_edit > 0) {
- text->xofs_edit -= 4;
- if (text->xofs_edit < 0)
- text->xofs_edit = 0;
- redraw = TRUE;
- }
- if (redraw) {
- ETextEventProcessorEvent e_tep_event;
- e_tep_event.type = GDK_MOTION_NOTIFY;
- e_tep_event.motion.state = text->last_state;
- e_tep_event.motion.time = 0;
- e_tep_event.motion.position = _get_position_from_xy(text, text->lastx, text->lasty);
- _get_tep(text);
- e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
- text->scroll_start = current_time;
- }
- }
-
- if (!((current_time / 500000) % 2)) {
- if (!text->show_cursor)
- redraw = TRUE;
- text->show_cursor = TRUE;
- } else {
- if (text->show_cursor)
- redraw = TRUE;
- text->show_cursor = FALSE;
- }
- if (redraw)
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text));
- return TRUE;
-}
-
-static gint
-e_text_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EText *text = E_TEXT(item);
- ETextEventProcessorEvent e_tep_event;
-
- gint return_val = 0;
-
- e_tep_event.type = event->type;
- switch (event->type) {
- case GDK_FOCUS_CHANGE:
- if (text->editable) {
- GdkEventFocus *focus_event;
- focus_event = (GdkEventFocus *) event;
- if (focus_event->in) {
- if(!text->editing) {
- text->editing = TRUE;
- if ( text->pointer_in ) {
- if ( text->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->i_cursor);
- text->default_cursor_shown = FALSE;
- }
- }
- text->selection_start = 0;
- text->selection_end = 0;
- text->select_by_word = FALSE;
- text->xofs_edit = 0;
- if (text->timeout_id == 0)
- text->timeout_id = g_timeout_add(10, _blink_scroll_timeout, text);
- text->timer = g_timer_new();
- g_timer_elapsed(text->timer, &(text->scroll_start));
- g_timer_start(text->timer);
- }
- } else {
- text->editing = FALSE;
- if ( ! text->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->default_cursor);
- text->default_cursor_shown = TRUE;
- }
- if (text->timeout_id) {
- g_source_remove(text->timeout_id);
- text->timeout_id = 0;
- }
- if (text->timer) {
- g_timer_stop(text->timer);
- g_timer_destroy(text->timer);
- text->timer = NULL;
- }
- }
- calc_line_widths (text);
- }
- return_val = 0;
- break;
- case GDK_KEY_PRESS: /* Fall Through */
- case GDK_KEY_RELEASE:
- if (text->editing) {
- GdkEventKey key = event->key;
- e_tep_event.key.time = key.time;
- e_tep_event.key.state = key.state;
- e_tep_event.key.keyval = key.keyval;
- e_tep_event.key.length = key.length;
- e_tep_event.key.string = key.string;
- _get_tep(text);
- return e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
- }
- else
- return 0;
- break;
- case GDK_BUTTON_PRESS: /* Fall Through */
- case GDK_BUTTON_RELEASE:
- if (text->editing) {
- GdkEventButton button = event->button;
- e_tep_event.button.time = button.time;
- e_tep_event.button.state = button.state;
- e_tep_event.button.button = button.button;
- e_tep_event.button.position = _get_position_from_xy(text, button.x, button.y);
- _get_tep(text);
- return_val = e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
- if (event->button.button == 1) {
- if (event->type == GDK_BUTTON_PRESS)
- text->button_down = TRUE;
- else
- text->button_down = FALSE;
- }
- text->lastx = button.x;
- text->lasty = button.y;
- text->last_state = button.state;
- } else if (text->editable && event->type == GDK_BUTTON_RELEASE && event->button.button == 1) {
- gnome_canvas_item_grab_focus (item);
- return 1;
- }
- break;
- case GDK_MOTION_NOTIFY:
- if (text->editing) {
- GdkEventMotion motion = event->motion;
- e_tep_event.motion.time = motion.time;
- e_tep_event.motion.state = motion.state;
- e_tep_event.motion.position = _get_position_from_xy(text, motion.x, motion.y);
- _get_tep(text);
- return_val = e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
- text->lastx = motion.x;
- text->lasty = motion.y;
- text->last_state = motion.state;
- }
- break;
- case GDK_ENTER_NOTIFY:
- text->pointer_in = TRUE;
- if (text->editing) {
- if ( text->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->i_cursor);
- text->default_cursor_shown = FALSE;
- }
- }
- break;
- case GDK_LEAVE_NOTIFY:
- text->pointer_in = FALSE;
- if (text->editing) {
- if ( ! text->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->default_cursor);
- text->default_cursor_shown = TRUE;
- }
- }
- break;
- default:
- break;
- }
- if (return_val)
- return return_val;
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->event)
- return GNOME_CANVAS_ITEM_CLASS(parent_class)->event(item, event);
- else
- return 0;
-}
-
-static int
-_get_position(EText *text, ETextEventProcessorCommand *command)
-{
- int i;
- int length;
- int x, y;
-
- switch (command->position) {
-
- case E_TEP_VALUE:
- return command->value;
-
- case E_TEP_SELECTION:
- return text->selection_end;
-
- case E_TEP_START_OF_BUFFER:
- return 0;
- case E_TEP_END_OF_BUFFER:
- return strlen(text->text);
-
- case E_TEP_START_OF_LINE:
- for (i = text->selection_end - 2; i > 0; i--)
- if (text->text[i] == '\n') {
- i++;
- break;
- }
- return i;
- case E_TEP_END_OF_LINE:
- length = strlen(text->text);
- for (i = text->selection_end + 1; i < length; i++)
- if (text->text[i] == '\n') {
- break;
- }
- if (i > length)
- i = length;
- return i;
-
- case E_TEP_FORWARD_CHARACTER:
- length = strlen(text->text);
- i = text->selection_end + 1;
- if (i > length)
- i = length;
- return i;
- case E_TEP_BACKWARD_CHARACTER:
- i = text->selection_end - 1;
- if (i < 0)
- i = 0;
- return i;
-
- case E_TEP_FORWARD_WORD:
- length = strlen(text->text);
- for (i = text->selection_end + 1; i < length; i++)
- if (isspace(text->text[i])) {
- break;
- }
- if (i > length)
- i = length;
- return i;
- case E_TEP_BACKWARD_WORD:
- for (i = text->selection_end - 2; i > 0; i--)
- if (isspace(text->text[i])) {
- i++;
- break;
- }
- if (i < 0)
- i = 0;
- return i;
-
- case E_TEP_FORWARD_LINE:
- _get_xy_from_position(text, text->selection_end, &x, &y);
- y += text->font->ascent + text->font->descent;
- return _get_position_from_xy(text, x, y);
- case E_TEP_BACKWARD_LINE:
- _get_xy_from_position(text, text->selection_end, &x, &y);
- y -= text->font->ascent + text->font->descent;
- return _get_position_from_xy(text, x, y);
-
- case E_TEP_FORWARD_PARAGRAPH:
- case E_TEP_BACKWARD_PARAGRAPH:
-
- case E_TEP_FORWARD_PAGE:
- case E_TEP_BACKWARD_PAGE:
- return text->selection_end;
- default:
- return text->selection_end;
- }
-}
-
-static void
-_delete_selection(EText *text)
-{
- gint length = strlen(text->text);
- if (text->selection_end == text->selection_start)
- return;
- if (text->selection_end < text->selection_start) {
- text->selection_end ^= text->selection_start;
- text->selection_start ^= text->selection_end;
- text->selection_end ^= text->selection_start;
- }
- memmove( text->text + text->selection_start,
- text->text + text->selection_end,
- length - text->selection_end + 1 );
- length -= text->selection_end - text->selection_start;
- text->selection_end = text->selection_start;
-}
-
-static void
-_insert(EText *text, char *string, int value)
-{
- if (value > 0) {
- char *temp;
- gint length = strlen(text->text);
- temp = g_new(gchar, length + value + 1);
- strncpy(temp, text->text, text->selection_start);
- strncpy(temp + text->selection_start, string, value);
- strcpy(temp + text->selection_start + value, text->text + text->selection_start);
- g_free(text->text);
- text->text = temp;
- text->selection_start += value;
- text->selection_end = text->selection_start;
- }
-}
-
-static void
-e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gpointer data)
-{
- EText *text = E_TEXT(data);
- int sel_start, sel_end;
- switch (command->action) {
- case E_TEP_MOVE:
- text->selection_start = _get_position(text, command);
- text->selection_end = text->selection_start;
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_SELECT:
- text->selection_end = _get_position(text, command);
- sel_start = MIN(text->selection_start, text->selection_end);
- sel_end = MAX(text->selection_start, text->selection_end);
- if (sel_start != sel_end) {
- e_text_supply_selection (text, command->time, GDK_SELECTION_PRIMARY, text->text + sel_start, sel_end - sel_start);
- } else if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_DELETE:
- if (text->selection_end == text->selection_start) {
- text->selection_end = _get_position(text, command);
- }
- _delete_selection(text);
- split_into_lines (text);
- recalc_bounds (text);
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
-
- case E_TEP_INSERT:
- if (text->selection_end != text->selection_start) {
- _delete_selection(text);
- }
- _insert(text, command->string, command->value);
- split_into_lines (text);
- recalc_bounds (text);
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_COPY:
- sel_start = MIN(text->selection_start, text->selection_end);
- sel_end = MAX(text->selection_start, text->selection_end);
- if (sel_start != sel_end) {
- e_text_supply_selection (text, command->time, clipboard_atom, text->text + sel_start, sel_end - sel_start);
- }
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_PASTE:
- e_text_get_selection (text, clipboard_atom, command->time);
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_GET_SELECTION:
- e_text_get_selection (text, GDK_SELECTION_PRIMARY, command->time);
- break;
- case E_TEP_ACTIVATE:
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_SET_SELECT_BY_WORD:
- text->select_by_word = command->value;
- break;
- case E_TEP_GRAB:
- gnome_canvas_item_grab (GNOME_CANVAS_ITEM(text),
- GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
- text->i_cursor,
- command->time);
- break;
- case E_TEP_UNGRAB:
- gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM(text), command->time);
- break;
- case E_TEP_NOP:
- break;
- }
-
- if (!text->button_down) {
- int x;
- int i;
- struct line *lines = text->lines;
- for (lines = text->lines, i = 0; i < text->num_lines ; i++, lines ++) {
- if (lines->text - text->text > text->selection_end) {
- break;
- }
- }
- lines --;
- x = gdk_text_width(text->font,
- lines->text,
- text->selection_end - (lines->text - text->text));
-
-
- if (x < text->xofs_edit) {
- text->xofs_edit = x;
- }
-
- if (2 + x - text->clip_width > text->xofs_edit) {
- text->xofs_edit = 2 + x - text->clip_width;
- }
- }
-
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text));
-}
-
-static void _invisible_destroy (GtkInvisible *invisible,
- EText *text)
-{
- text->invisible = NULL;
-}
-
-static GtkWidget *e_text_get_invisible(EText *text)
-{
- GtkWidget *invisible;
- if (text->invisible) {
- invisible = text->invisible;
- } else {
- invisible = gtk_invisible_new();
- text->invisible = invisible;
-
- gtk_selection_add_target (invisible,
- GDK_SELECTION_PRIMARY,
- GDK_SELECTION_TYPE_STRING,
- E_SELECTION_PRIMARY);
- gtk_selection_add_target (invisible,
- clipboard_atom,
- GDK_SELECTION_TYPE_STRING,
- E_SELECTION_CLIPBOARD);
-
- gtk_signal_connect (GTK_OBJECT(invisible), "selection_get",
- GTK_SIGNAL_FUNC (_selection_get),
- text);
- gtk_signal_connect (GTK_OBJECT(invisible), "selection_clear_event",
- GTK_SIGNAL_FUNC (_selection_clear_event),
- text);
- gtk_signal_connect (GTK_OBJECT(invisible), "selection_received",
- GTK_SIGNAL_FUNC (_selection_received),
- text);
-
- gtk_signal_connect (GTK_OBJECT(invisible), "destroy",
- GTK_SIGNAL_FUNC (_invisible_destroy),
- text);
- }
- return invisible;
-}
-
-static void
-_selection_clear_event (GtkInvisible *invisible,
- GdkEventSelection *event,
- EText *text)
-{
- if (event->selection == GDK_SELECTION_PRIMARY) {
- g_free (text->primary_selection);
- text->primary_selection = NULL;
- text->primary_length = 0;
-
- text->has_selection = FALSE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text));
-
- } else if (event->selection == clipboard_atom) {
- g_free (text->clipboard_selection);
- text->clipboard_selection = NULL;
- text->clipboard_length = 0;
- }
-}
-
-static void
-_selection_get (GtkInvisible *invisible,
- GtkSelectionData *selection_data,
- guint info,
- guint time_stamp,
- EText *text)
-{
- switch (info) {
- case E_SELECTION_PRIMARY:
- gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING,
- 8, text->primary_selection, text->primary_length);
- break;
- case E_SELECTION_CLIPBOARD:
- gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING,
- 8, text->clipboard_selection, text->clipboard_length);
- break;
- }
-}
-
-static void
-_selection_received (GtkInvisible *invisible,
- GtkSelectionData *selection_data,
- guint time,
- EText *text)
-{
- if (selection_data->length < 0 || selection_data->type != GDK_SELECTION_TYPE_STRING) {
- return;
- } else {
- ETextEventProcessorCommand command;
- command.action = E_TEP_INSERT;
- command.position = E_TEP_SELECTION;
- command.string = selection_data->data;
- command.value = selection_data->length;
- command.time = time;
- e_text_command(text->tep, &command, text);
- }
-}
-
-static void e_text_supply_selection (EText *text, guint time, GdkAtom selection, guchar *data, gint length)
-{
- gboolean successful;
- GtkWidget *invisible;
-
- invisible = e_text_get_invisible(text);
-
- if (selection == GDK_SELECTION_PRIMARY ) {
- if (text->primary_selection) {
- g_free (text->primary_selection);
- }
- text->primary_selection = g_strndup(data, length);
- text->primary_length = length;
- } else if (selection == clipboard_atom) {
- if (text->clipboard_selection) {
- g_free (text->clipboard_selection);
- }
- text->clipboard_selection = g_strndup(data, length);
- text->clipboard_length = length;
- }
-
- successful = gtk_selection_owner_set (invisible,
- selection,
- time);
-
- if (selection == GDK_SELECTION_PRIMARY)
- text->has_selection = successful;
-}
-
-static void
-e_text_get_selection(EText *text, GdkAtom selection, guint32 time)
-{
- GtkWidget *invisible;
- invisible = e_text_get_invisible(text);
- gtk_selection_convert(invisible,
- selection,
- GDK_SELECTION_TYPE_STRING,
- time);
-}
-
-#if 0
-static void
-e_text_real_copy_clipboard (EText *text)
-{
- guint32 time;
- gint selection_start_pos;
- gint selection_end_pos;
-
- g_return_if_fail (text != NULL);
- g_return_if_fail (E_IS_TEXT (text));
-
- time = gtk_text_get_event_time (text);
- selection_start_pos = MIN (text->selection_start, text->selection_end);
- selection_end_pos = MAX (text->selection_start, text->selection_end);
-
- if (selection_start_pos != selection_end_pos)
- {
- if (gtk_selection_owner_set (GTK_WIDGET (text->canvas),
- clipboard_atom,
- time))
- text->clipboard_text = "";
- }
-}
-
-static void
-e_text_real_paste_clipboard (EText *text)
-{
- guint32 time;
-
- g_return_if_fail (text != NULL);
- g_return_if_fail (E_IS_TEXT (text));
-
- time = e_text_get_event_time (text);
- if (text->editable)
- gtk_selection_convert (GTK_WIDGET(text->widget),
- clipboard_atom,
- gdk_atom_intern ("COMPOUND_TEXT", FALSE), time);
-}
-#endif
-
-/* Get the timestamp of the current event. Actually, the only thing
- * we really care about below is the key event
- */
-static guint32
-e_text_get_event_time (EText *text)
-{
- GdkEvent *event;
- guint32 tm = GDK_CURRENT_TIME;
-
- event = gtk_get_current_event();
-
- if (event)
- switch (event->type)
- {
- case GDK_MOTION_NOTIFY:
- tm = event->motion.time; break;
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- tm = event->button.time; break;
- case GDK_KEY_PRESS:
- case GDK_KEY_RELEASE:
- tm = event->key.time; break;
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY:
- tm = event->crossing.time; break;
- case GDK_PROPERTY_NOTIFY:
- tm = event->property.time; break;
- case GDK_SELECTION_CLEAR:
- case GDK_SELECTION_REQUEST:
- case GDK_SELECTION_NOTIFY:
- tm = event->selection.time; break;
- case GDK_PROXIMITY_IN:
- case GDK_PROXIMITY_OUT:
- tm = event->proximity.time; break;
- default: /* use current time */
- break;
- }
- gdk_event_free(event);
-
- return tm;
-}
-
-
-
-/* Routines for sucking fonts from the X server */
-
-static ETextSuckFont *
-e_suck_font (GdkFont *font)
-{
- ETextSuckFont *suckfont;
- int i;
- int x, y;
- char text[1];
- int lbearing, rbearing, ch_width, ascent, descent;
- GdkPixmap *pixmap;
- GdkColor black, white;
- GdkImage *image;
- GdkGC *gc;
- guchar *line;
- int width, height;
- int black_pixel, pixel;
-
- if (!font)
- return NULL;
-
- suckfont = g_new (ETextSuckFont, 1);
-
- height = font->ascent + font->descent;
- x = 0;
- for (i = 0; i < 256; i++) {
- text[0] = i;
- gdk_text_extents (font, text, 1,
- &lbearing, &rbearing, &ch_width, &ascent, &descent);
- suckfont->chars[i].left_sb = lbearing;
- suckfont->chars[i].right_sb = ch_width - rbearing;
- suckfont->chars[i].width = rbearing - lbearing;
- suckfont->chars[i].ascent = ascent;
- suckfont->chars[i].descent = descent;
- suckfont->chars[i].bitmap_offset = x;
- x += (ch_width + 31) & -32;
- }
-
- width = x;
-
- suckfont->bitmap_width = width;
- suckfont->bitmap_height = height;
- suckfont->ascent = font->ascent;
-
- pixmap = gdk_pixmap_new (NULL, suckfont->bitmap_width,
- suckfont->bitmap_height, 1);
- gc = gdk_gc_new (pixmap);
- gdk_gc_set_font (gc, font);
-
- black_pixel = BlackPixel (gdk_display, DefaultScreen (gdk_display));
- black.pixel = black_pixel;
- white.pixel = WhitePixel (gdk_display, DefaultScreen (gdk_display));
- gdk_gc_set_foreground (gc, &white);
- gdk_draw_rectangle (pixmap, gc, 1, 0, 0, width, height);
-
- gdk_gc_set_foreground (gc, &black);
- for (i = 0; i < 256; i++) {
- text[0] = i;
- gdk_draw_text (pixmap, font, gc,
- suckfont->chars[i].bitmap_offset - suckfont->chars[i].left_sb,
- font->ascent,
- text, 1);
- }
-
- /* The handling of the image leaves me with distinct unease. But this
- * is more or less copied out of gimp/app/text_tool.c, so it _ought_ to
- * work. -RLL
- */
-
- image = gdk_image_get (pixmap, 0, 0, width, height);
- suckfont->bitmap = g_malloc0 ((width >> 3) * height);
-
- line = suckfont->bitmap;
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- pixel = gdk_image_get_pixel (image, x, y);
- if (pixel == black_pixel)
- line[x >> 3] |= 128 >> (x & 7);
- }
- line += width >> 3;
- }
-
- gdk_image_destroy (image);
-
- /* free the pixmap */
- gdk_pixmap_unref (pixmap);
-
- /* free the gc */
- gdk_gc_destroy (gc);
-
- return suckfont;
-}
-
-static void
-e_suck_font_free (ETextSuckFont *suckfont)
-{
- g_free (suckfont->bitmap);
- g_free (suckfont);
-}
diff --git a/widgets/e-text.h b/widgets/e-text.h
deleted file mode 100644
index f4f43a156b..0000000000
--- a/widgets/e-text.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* EText - Text item for evolution.
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Chris Lahey <clahey@umich.edu>
- *
- * A majority of code taken from:
- *
- * Text item type for GnomeCanvas widget
- *
- * GnomeCanvas is basically a port of the Tk toolkit's most excellent
- * canvas widget. Tk is copyrighted by the Regents of the University
- * of California, Sun Microsystems, and other parties.
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx> */
-
-#ifndef E_TEXT_H
-#define E_TEXT_H
-
-#include <gnome.h>
-#include "e-text-event-processor.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-/* Text item for the canvas. Text items are positioned by an anchor point and an anchor direction.
- *
- * A clipping rectangle may be specified for the text. The rectangle is anchored at the text's anchor
- * point, and is specified by clipping width and height parameters. If the clipping rectangle is
- * enabled, it will clip the text.
- *
- * In addition, x and y offset values may be specified. These specify an offset from the anchor
- * position. If used in conjunction with the clipping rectangle, these could be used to implement
- * simple scrolling of the text within the clipping rectangle.
- *
- * The following object arguments are available:
- *
- * name type read/write description
- * ------------------------------------------------------------------------------------------
- * text string RW The string of the text label
- * x double RW X coordinate of anchor point
- * y double RW Y coordinate of anchor point
- * font string W X logical font descriptor
- * fontset string W X logical fontset descriptor
- * font_gdk GdkFont* RW Pointer to a GdkFont
- * anchor GtkAnchorType RW Anchor side for the text
- * justification GtkJustification RW Justification for multiline text
- * fill_color string W X color specification for text
- * fill_color_gdk GdkColor* RW Pointer to an allocated GdkColor
- * fill_stipple GdkBitmap* RW Stipple pattern for filling the text
- * clip_width double RW Width of clip rectangle
- * clip_height double RW Height of clip rectangle
- * clip boolean RW Use clipping rectangle?
- * x_offset double RW Horizontal offset distance from anchor position
- * y_offset double RW Vertical offset distance from anchor position
- * text_width double R Used to query the width of the rendered text
- * text_height double R Used to query the rendered height of the text
- *
- * These are currently ignored in the AA version:
- * editable boolean RW Can this item be edited
- * use_ellipsis boolean RW Whether to use ellipsises if text gets cut off. Meaningless if clip == false.
- * ellipsis string RW The characters to use as ellipsis. NULL = "...".
- *
- * These are not implemented yet:
- * line_wrap boolean RW Line wrap when not editing.
- * line_wrap_on_edit boolean RW Switch to line wrap when editing.
- * background boolean RW Draw a background rectangle.
- * background_on_edit boolean RW Draw a background when editing.
- */
-
-#define E_TYPE_TEXT (e_text_get_type ())
-#define E_TEXT(obj) (GTK_CHECK_CAST ((obj), E_TYPE_TEXT, EText))
-#define E_TEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_TEXT, ETextClass))
-#define E_IS_TEXT(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_TEXT))
-#define E_IS_TEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_TEXT))
-
-
-typedef struct _EText EText;
-typedef struct _ETextClass ETextClass;
-typedef struct _ETextSuckFont ETextSuckFont;
-typedef struct _ETextSuckChar ETextSuckChar;
-
-struct _ETextSuckChar {
- int left_sb;
- int right_sb;
- int width;
- int ascent;
- int descent;
- int bitmap_offset; /* in pixels */
-};
-
-struct _ETextSuckFont {
- guchar *bitmap;
- gint bitmap_width;
- gint bitmap_height;
- gint ascent;
- ETextSuckChar chars[256];
-};
-
-struct _EText {
- GnomeCanvasItem item;
-
- char *text; /* Text to display */
- gpointer lines; /* Text split into lines (private field) */
- int num_lines; /* Number of lines of text */
-
- double x, y; /* Position at anchor */
- GdkFont *font; /* Font for text */
- GtkAnchorType anchor; /* Anchor side for text */
- GtkJustification justification; /* Justification for text */
-
- double clip_width; /* Width of optional clip rectangle */
- double clip_height; /* Height of optional clip rectangle */
-
- double xofs, yofs; /* Text offset distance from anchor position */
-
- gulong pixel; /* Fill color */
- GdkBitmap *stipple; /* Stipple for text */
- GdkGC *gc; /* GC for drawing text */
-
- int cx, cy; /* Top-left canvas coordinates for text */
- int clip_cx, clip_cy; /* Top-left canvas coordinates for clip rectangle */
- int clip_cwidth, clip_cheight; /* Size of clip rectangle in pixels */
- int max_width; /* Maximum width of text lines */
- int height; /* Rendered text height in pixels */
-
- guint clip : 1; /* Use clip rectangle? */
-
- /* Antialiased specific stuff follows */
- ETextSuckFont *suckfont; /* Sucked font */
- guint32 rgba; /* RGBA color for text */
- double affine[6]; /* The item -> canvas affine */
-
- char *ellipsis; /* The ellipsis characters. NULL = "...". */
- double ellipsis_width; /* The width of the ellipsis. */
- gboolean use_ellipsis; /* Whether to use the ellipsis. */
-
- gboolean editable; /* Item is editable */
- gboolean editing; /* Item is currently being edited */
-
- int xofs_edit; /* Offset because of editing */
-
- /* This needs to be reworked a bit once we get line wrapping. */
- int selection_start; /* Start of selection */
- int selection_end; /* End of selection */
- gboolean select_by_word; /* Current selection is by word */
-
- /* This section is for drag scrolling and blinking cursor. */
- gint timeout_id; /* Current timeout id for scrolling */
- GTimer *timer; /* Timer for blinking cursor and scrolling */
-
- gint lastx, lasty; /* Last x and y motion events */
- gint last_state; /* Last state */
- gulong scroll_start; /* Starting time for scroll (microseconds) */
-
- gint show_cursor; /* Is cursor currently shown */
- gboolean button_down; /* Is mouse button 1 down */
-
- ETextEventProcessor *tep; /* Text Event Processor */
-
- GtkWidget *invisible; /* For selection handling */
- gboolean has_selection; /* TRUE if we have the selection */
- gchar *primary_selection; /* Primary selection text */
- gint primary_length; /* Primary selection text length */
- gchar *clipboard_selection; /* Clipboard selection text */
- gint clipboard_length; /* Clipboard selection text length*/
-
- guint pointer_in : 1;
- guint default_cursor_shown : 1;
-
- GdkCursor *default_cursor;
- GdkCursor *i_cursor;
-};
-
-struct _ETextClass {
- GnomeCanvasItemClass parent_class;
-
- void (* resize) (EText *text);
- void (* change) (EText *text);
-};
-
-
-/* Standard Gtk function */
-GtkType e_text_get_type (void);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/widgets/e-text/e-text-event-processor-emacs-like.c b/widgets/e-text/e-text-event-processor-emacs-like.c
deleted file mode 100644
index 41bcd0c31d..0000000000
--- a/widgets/e-text/e-text-event-processor-emacs-like.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include "e-text-event-processor-emacs-like.h"
-static void e_text_event_processor_emacs_like_init (ETextEventProcessorEmacsLike *card);
-static void e_text_event_processor_emacs_like_class_init (ETextEventProcessorEmacsLikeClass *klass);
-static gint e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event);
-
-static ETextEventProcessorClass *parent_class = NULL;
-
-/* The arguments we take */
-enum {
- ARG_0
-};
-
-static const ETextEventProcessorCommand control_keys[26] =
-{
- { E_TEP_START_OF_LINE, E_TEP_MOVE, 0, "" }, /* a */
- { E_TEP_BACKWARD_CHARACTER, E_TEP_MOVE, 0, "" }, /* b */
- { E_TEP_SELECTION, E_TEP_COPY, 0, "" }, /* c */
- { E_TEP_FORWARD_CHARACTER, E_TEP_DELETE, 0, "" }, /* d */
- { E_TEP_END_OF_LINE, E_TEP_MOVE, 0, "" }, /* e */
- { E_TEP_FORWARD_CHARACTER, E_TEP_MOVE, 0, "" }, /* f */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* g */
- { E_TEP_BACKWARD_CHARACTER, E_TEP_DELETE, 0, "" }, /* h */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* i */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* j */
- { E_TEP_END_OF_LINE, E_TEP_DELETE, 0, "" }, /* k */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* l */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* m */
- { E_TEP_FORWARD_LINE, E_TEP_MOVE, 0, "" }, /* n */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* o */
- { E_TEP_BACKWARD_LINE, E_TEP_MOVE, 0, "" }, /* p */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* q */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* r */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* s */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* t */
- { E_TEP_START_OF_LINE, E_TEP_DELETE, 0, "" }, /* u */
- { E_TEP_SELECTION, E_TEP_PASTE, 0, "" }, /* v */
- { E_TEP_BACKWARD_WORD, E_TEP_DELETE, 0, "" }, /* w */
- { E_TEP_SELECTION, E_TEP_DELETE, 0, "" }, /* x */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* y */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" } /* z */
-};
-
-static const ETextEventProcessorCommand alt_keys[26] =
-{
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* a */
- { E_TEP_BACKWARD_WORD, E_TEP_MOVE, 0, "" }, /* b */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* c */
- { E_TEP_FORWARD_WORD, E_TEP_DELETE, 0, "" }, /* d */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* e */
- { E_TEP_FORWARD_WORD, E_TEP_MOVE, 0, "" }, /* f */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* g */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* h */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* i */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* j */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* k */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* l */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* m */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* n */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* o */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* p */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* q */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* r */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* s */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* t */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* u */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* v */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* w */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* x */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* y */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" } /* z */
-
-};
-
-GtkType
-e_text_event_processor_emacs_like_get_type (void)
-{
- static GtkType text_event_processor_emacs_like_type = 0;
-
- if (!text_event_processor_emacs_like_type)
- {
- static const GtkTypeInfo text_event_processor_emacs_like_info =
- {
- "ETextEventProcessorEmacsLike",
- sizeof (ETextEventProcessorEmacsLike),
- sizeof (ETextEventProcessorEmacsLikeClass),
- (GtkClassInitFunc) e_text_event_processor_emacs_like_class_init,
- (GtkObjectInitFunc) e_text_event_processor_emacs_like_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- text_event_processor_emacs_like_type = gtk_type_unique (e_text_event_processor_get_type (), &text_event_processor_emacs_like_info);
- }
-
- return text_event_processor_emacs_like_type;
-}
-
-static void
-e_text_event_processor_emacs_like_class_init (ETextEventProcessorEmacsLikeClass *klass)
-{
- GtkObjectClass *object_class;
- ETextEventProcessorClass *processor_class;
-
- object_class = (GtkObjectClass*) klass;
- processor_class = (ETextEventProcessorClass*) klass;
-
- parent_class = gtk_type_class (e_text_event_processor_get_type ());
-
- processor_class->event = e_text_event_processor_emacs_like_event;
-}
-
-static void
-e_text_event_processor_emacs_like_init (ETextEventProcessorEmacsLike *tep)
-{
-}
-
-static gint
-e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event)
-{
- ETextEventProcessorCommand command;
- ETextEventProcessorEmacsLike *tep_el = E_TEXT_EVENT_PROCESSOR_EMACS_LIKE(tep);
- command.action = E_TEP_NOP;
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if (event->button.button == 1) {
- command.action = E_TEP_GRAB;
- command.time = event->button.time;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
- if (event->button.state & GDK_SHIFT_MASK)
- command.action = E_TEP_SELECT;
- else
- command.action = E_TEP_MOVE;
- command.position = E_TEP_VALUE;
- command.value = event->button.position;
- command.time = event->button.time;
- tep_el->mouse_down = TRUE;
- }
- break;
- case GDK_BUTTON_RELEASE:
- if (event->button.button == 1) {
- command.action = E_TEP_UNGRAB;
- command.time = event->button.time;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
- command.time = event->button.time;
- tep_el->mouse_down = FALSE;
- } else if (event->button.button == 2) {
- command.action = E_TEP_MOVE;
- command.position = E_TEP_VALUE;
- command.value = event->button.position;
- command.time = event->button.time;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
-
- command.action = E_TEP_GET_SELECTION;
- command.position = E_TEP_SELECTION;
- command.value = 0;
- command.time = event->button.time;
- }
- break;
- case GDK_MOTION_NOTIFY:
- if (tep_el->mouse_down) {
- command.action = E_TEP_SELECT;
- command.position = E_TEP_VALUE;
- command.time = event->motion.time;
- command.value = event->motion.position;
- }
- break;
- case GDK_KEY_PRESS:
- {
- ETextEventProcessorEventKey key = event->key;
- command.time = event->key.time;
- if (key.state & GDK_SHIFT_MASK)
- command.action = E_TEP_SELECT;
- else
- command.action = E_TEP_MOVE;
- switch(key.keyval) {
- case GDK_Home:
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_START_OF_BUFFER;
- else
- command.position = E_TEP_START_OF_LINE;
- break;
- case GDK_End:
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_END_OF_BUFFER;
- else
- command.position = E_TEP_END_OF_LINE;
- break;
- case GDK_Page_Up: command.position = E_TEP_BACKWARD_PAGE; break;
- case GDK_Page_Down: command.position = E_TEP_FORWARD_PAGE; break;
- /* CUA has Ctrl-Up/Ctrl-Down as paragraph up down */
- case GDK_Up: command.position = E_TEP_BACKWARD_LINE; break;
- case GDK_Down: command.position = E_TEP_FORWARD_LINE; break;
- case GDK_Left:
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_BACKWARD_WORD;
- else
- command.position = E_TEP_BACKWARD_CHARACTER;
- break;
- case GDK_Right:
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_FORWARD_WORD;
- else
- command.position = E_TEP_FORWARD_CHARACTER;
- break;
-
- case GDK_BackSpace:
- command.action = E_TEP_DELETE;
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_BACKWARD_WORD;
- else
- command.position = E_TEP_BACKWARD_CHARACTER;
- break;
- case GDK_Clear:
- command.action = E_TEP_DELETE;
- command.position = E_TEP_END_OF_LINE;
- break;
- case GDK_Insert:
- if (key.state & GDK_SHIFT_MASK) {
- command.action = E_TEP_PASTE;
- command.position = E_TEP_SELECTION;
- } else if (key.state & GDK_CONTROL_MASK) {
- command.action = E_TEP_COPY;
- command.position = E_TEP_SELECTION;
- } else {
- /* gtk_toggle_insert(text) -- IMPLEMENT */
- }
- break;
- case GDK_Delete:
- if (key.state & GDK_CONTROL_MASK){
- command.action = E_TEP_DELETE;
- command.position = E_TEP_FORWARD_WORD;
- } else if (key.state & GDK_SHIFT_MASK) {
- command.action = E_TEP_COPY;
- command.position = E_TEP_SELECTION;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
-
- command.action = E_TEP_DELETE;
- command.position = E_TEP_SELECTION;
- } else {
- command.action = E_TEP_DELETE;
- command.position = E_TEP_FORWARD_CHARACTER;
- }
- break;
- case GDK_Tab:
- /* Don't insert literally */
- command.action = E_TEP_NOP;
- command.position = E_TEP_SELECTION;
- break;
- case GDK_Return:
- if (key.state & GDK_CONTROL_MASK) {
- command.action = E_TEP_ACTIVATE;
- command.position = E_TEP_SELECTION;
- } else {
- command.action = E_TEP_INSERT;
- command.position = E_TEP_SELECTION;
- command.value = 1;
- command.string = "\n";
- }
- break;
- case GDK_Escape:
- /* Don't insert literally */
- command.action = E_TEP_NOP;
- command.position = E_TEP_SELECTION;
- break;
-
- default:
- if (key.state & GDK_CONTROL_MASK) {
- if ((key.keyval >= 'A') && (key.keyval <= 'Z'))
- key.keyval -= 'A' - 'a';
-
- if ((key.keyval >= 'a') && (key.keyval <= 'z')) {
- command.position = control_keys[(int) (key.keyval - 'a')].position;
- if (control_keys[(int) (key.keyval - 'a')].action != E_TEP_MOVE)
- command.action = control_keys[(int) (key.keyval - 'a')].action;
- command.value = control_keys[(int) (key.keyval - 'a')].value;
- command.string = control_keys[(int) (key.keyval - 'a')].string;
- }
-
- if (key.keyval == 'x') {
- command.action = E_TEP_COPY;
- command.position = E_TEP_SELECTION;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
-
- command.action = E_TEP_DELETE;
- command.position = E_TEP_SELECTION;
- }
-
- break;
- } else if (key.state & GDK_MOD1_MASK) {
- if ((key.keyval >= 'A') && (key.keyval <= 'Z'))
- key.keyval -= 'A' - 'a';
-
- if ((key.keyval >= 'a') && (key.keyval <= 'z')) {
- command.position = alt_keys[(int) (key.keyval - 'a')].position;
- if (alt_keys[(int) (key.keyval - 'a')].action != E_TEP_MOVE)
- command.action = alt_keys[(int) (key.keyval - 'a')].action;
- command.value = alt_keys[(int) (key.keyval - 'a')].value;
- command.string = alt_keys[(int) (key.keyval - 'a')].string;
- }
- } else if (key.length > 0) {
- command.action = E_TEP_INSERT;
- command.position = E_TEP_SELECTION;
- command.value = strlen(key.string);
- command.string = key.string;
-
- } else {
- command.action = E_TEP_NOP;
- }
- }
- break;
- case GDK_KEY_RELEASE:
- command.time = event->key.time;
- command.action = E_TEP_NOP;
- break;
- default:
- command.action = E_TEP_NOP;
- break;
- }
- }
- if (command.action != E_TEP_NOP) {
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
- return 1;
- }
- else
- return 0;
-}
-
-ETextEventProcessor *
-e_text_event_processor_emacs_like_new (void)
-{
- ETextEventProcessorEmacsLike *retval = gtk_type_new (e_text_event_processor_emacs_like_get_type ());
- return E_TEXT_EVENT_PROCESSOR (retval);
-}
-
diff --git a/widgets/e-text/e-text-event-processor-emacs-like.h b/widgets/e-text/e-text-event-processor-emacs-like.h
deleted file mode 100644
index 651bb552b3..0000000000
--- a/widgets/e-text/e-text-event-processor-emacs-like.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor-emacs-like.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__
-#define __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__
-
-#include <gnome.h>
-#include "e-text-event-processor.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* ETextEventProcessorEmacsLike - Turns events on a text widget into commands. Uses an emacs-ish interface.
- *
- */
-
-#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE (e_text_event_processor_emacs_like_get_type ())
-#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE(obj) (GTK_CHECK_CAST ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE, ETextEventProcessorEmacsLike))
-#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE, ETextEventProcessorEmacsLikeClass))
-#define E_IS_TEXT_EVENT_PROCESSOR_EMACS_LIKE(obj) (GTK_CHECK_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE))
-#define E_IS_TEXT_EVENT_PROCESSOR_EMACS_LIKE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE))
-
-
-typedef struct _ETextEventProcessorEmacsLike ETextEventProcessorEmacsLike;
-typedef struct _ETextEventProcessorEmacsLikeClass ETextEventProcessorEmacsLikeClass;
-
-struct _ETextEventProcessorEmacsLike
-{
- ETextEventProcessor parent;
-
- /* object specific fields */
- gboolean mouse_down;
-};
-
-struct _ETextEventProcessorEmacsLikeClass
-{
- ETextEventProcessorClass parent_class;
-};
-
-
-GtkType e_text_event_processor_emacs_like_get_type (void);
-ETextEventProcessor *e_text_event_processor_emacs_like_new (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__ */
diff --git a/widgets/e-text/e-text-event-processor-types.h b/widgets/e-text/e-text-event-processor-types.h
deleted file mode 100644
index 32a39bf0c0..0000000000
--- a/widgets/e-text/e-text-event-processor-types.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __E_TEXT_EVENT_PROCESSOR_TYPES_H__
-#define __E_TEXT_EVENT_PROCESSOR_TYPES_H__
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#include <gdk/gdktypes.h>
-
-typedef enum _ETextEventProcessorCommandPosition ETextEventProcessorCommandPosition;
-typedef enum _ETextEventProcessorCommandAction ETextEventProcessorCommandAction;
-typedef struct _ETextEventProcessorCommand ETextEventProcessorCommand;
-
-typedef union _ETextEventProcessorEvent ETextEventProcessorEvent;
-typedef struct _ETextEventProcessorEventButton ETextEventProcessorEventButton;
-typedef struct _ETextEventProcessorEventKey ETextEventProcessorEventKey;
-typedef struct _ETextEventProcessorEventMotion ETextEventProcessorEventMotion;
-
-enum _ETextEventProcessorCommandPosition {
- E_TEP_VALUE,
- E_TEP_SELECTION,
-
- E_TEP_START_OF_BUFFER,
- E_TEP_END_OF_BUFFER,
-
- E_TEP_START_OF_LINE,
- E_TEP_END_OF_LINE,
-
- E_TEP_FORWARD_CHARACTER,
- E_TEP_BACKWARD_CHARACTER,
-
- E_TEP_FORWARD_WORD,
- E_TEP_BACKWARD_WORD,
-
- E_TEP_FORWARD_LINE,
- E_TEP_BACKWARD_LINE,
-
- E_TEP_FORWARD_PARAGRAPH,
- E_TEP_BACKWARD_PARAGRAPH,
-
- E_TEP_FORWARD_PAGE,
- E_TEP_BACKWARD_PAGE
-};
-
-enum _ETextEventProcessorCommandAction {
- E_TEP_MOVE,
- E_TEP_SELECT,
- E_TEP_DELETE,
- E_TEP_INSERT,
-
- E_TEP_COPY,
- E_TEP_PASTE,
- E_TEP_GET_SELECTION,
- E_TEP_SET_SELECT_BY_WORD,
- E_TEP_ACTIVATE,
-
- E_TEP_GRAB,
- E_TEP_UNGRAB,
-
- E_TEP_NOP
-};
-
-struct _ETextEventProcessorCommand {
- ETextEventProcessorCommandPosition position;
- ETextEventProcessorCommandAction action;
- int value;
- char *string;
- guint32 time;
-};
-
-struct _ETextEventProcessorEventButton {
- GdkEventType type;
- guint32 time;
- guint state;
- guint button;
- gint position;
-};
-
-struct _ETextEventProcessorEventKey {
- GdkEventType type;
- guint32 time;
- guint state;
- guint keyval;
- gint length;
- gchar *string;
-};
-
-struct _ETextEventProcessorEventMotion {
- GdkEventType type;
- guint32 time;
- guint state;
- gint position;
-};
-
-union _ETextEventProcessorEvent {
- GdkEventType type;
- ETextEventProcessorEventButton button;
- ETextEventProcessorEventKey key;
- ETextEventProcessorEventMotion motion;
-};
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_TEXT_EVENT_PROCESSOR_TYPES_H__ */
diff --git a/widgets/e-text/e-text-event-processor.c b/widgets/e-text/e-text-event-processor.c
deleted file mode 100644
index 47f028ca62..0000000000
--- a/widgets/e-text/e-text-event-processor.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include "e-text-event-processor.h"
-static void e_text_event_processor_init (ETextEventProcessor *card);
-static void e_text_event_processor_class_init (ETextEventProcessorClass *klass);
-
-static GtkObjectClass *parent_class = NULL;
-
-/* The arguments we take */
-enum {
- ARG_0
-};
-
-enum {
- E_TEP_EVENT,
- E_TEP_LAST_SIGNAL
-};
-
-static guint e_tep_signals[E_TEP_LAST_SIGNAL] = { 0 };
-
-GtkType
-e_text_event_processor_get_type (void)
-{
- static GtkType text_event_processor_type = 0;
-
- if (!text_event_processor_type)
- {
- static const GtkTypeInfo text_event_processor_info =
- {
- "ETextEventProcessor",
- sizeof (ETextEventProcessor),
- sizeof (ETextEventProcessorClass),
- (GtkClassInitFunc) e_text_event_processor_class_init,
- (GtkObjectInitFunc) e_text_event_processor_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- text_event_processor_type = gtk_type_unique (gtk_object_get_type (), &text_event_processor_info);
- }
-
- return text_event_processor_type;
-}
-
-static void
-e_text_event_processor_class_init (ETextEventProcessorClass *klass)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass*) klass;
-
- parent_class = gtk_type_class (gtk_object_get_type ());
-
- e_tep_signals[E_TEP_EVENT] =
- gtk_signal_new ("command",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETextEventProcessorClass, command),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
-
- gtk_object_class_add_signals (object_class, e_tep_signals, E_TEP_LAST_SIGNAL);
-
- klass->event = NULL;
- klass->command = NULL;
-}
-
-static void
-e_text_event_processor_init (ETextEventProcessor *tep)
-{
-}
-
-gint
-e_text_event_processor_handle_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event)
-{
- if (E_TEXT_EVENT_PROCESSOR_CLASS(GTK_OBJECT(tep)->klass)->event) {
- return E_TEXT_EVENT_PROCESSOR_CLASS(GTK_OBJECT(tep)->klass)->event(tep, event);
- } else {
- return 0;
- }
-}
diff --git a/widgets/e-text/e-text-event-processor.h b/widgets/e-text/e-text-event-processor.h
deleted file mode 100644
index 1fc79f3f70..0000000000
--- a/widgets/e-text/e-text-event-processor.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_TEXT_EVENT_PROCESSOR_H__
-#define __E_TEXT_EVENT_PROCESSOR_H__
-
-#include <gnome.h>
-#include "e-text-event-processor-types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* ETextEventProcessor - Turns events on a text widget into commands.
- *
- */
-
-#define E_TEXT_EVENT_PROCESSOR_TYPE (e_text_event_processor_get_type ())
-#define E_TEXT_EVENT_PROCESSOR(obj) (GTK_CHECK_CAST ((obj), E_TEXT_EVENT_PROCESSOR_TYPE, ETextEventProcessor))
-#define E_TEXT_EVENT_PROCESSOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TEXT_EVENT_PROCESSOR_TYPE, ETextEventProcessorClass))
-#define E_IS_TEXT_EVENT_PROCESSOR(obj) (GTK_CHECK_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_TYPE))
-#define E_IS_TEXT_EVENT_PROCESSOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_TYPE))
-
-
-typedef struct _ETextEventProcessor ETextEventProcessor;
-typedef struct _ETextEventProcessorClass ETextEventProcessorClass;
-
-struct _ETextEventProcessor
-{
- GtkObject parent;
-
- /* object specific fields */
-
-};
-
-struct _ETextEventProcessorClass
-{
- GtkObjectClass parent_class;
-
- /* signals */
- void (* command) (ETextEventProcessor *tep, ETextEventProcessorCommand *command);
-
- /* virtual functions */
- gint (* event) (ETextEventProcessor *tep, ETextEventProcessorEvent *event);
-};
-
-
-GtkType e_text_event_processor_get_type (void);
-gint e_text_event_processor_handle_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_TEXT_EVENT_PROCESSOR_H__ */
diff --git a/widgets/e-text/e-text.c b/widgets/e-text/e-text.c
deleted file mode 100644
index bfff8e251a..0000000000
--- a/widgets/e-text/e-text.c
+++ /dev/null
@@ -1,2391 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* EText - Text item for evolution.
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Chris Lahey <clahey@umich.edu>
- *
- * A majority of code taken from:
- *
- * Text item type for GnomeCanvas widget
- *
- * GnomeCanvas is basically a port of the Tk toolkit's most excellent
- * canvas widget. Tk is copyrighted by the Regents of the University
- * of California, Sun Microsystems, and other parties.
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx> */
-
-#include <config.h>
-#include <math.h>
-#include <ctype.h>
-#include "e-text.h"
-#include <gdk/gdkx.h> /* for BlackPixel */
-#include <libart_lgpl/art_affine.h>
-#include <libart_lgpl/art_rgb.h>
-#include <libart_lgpl/art_rgb_bitmap_affine.h>
-#include <gtk/gtkinvisible.h>
-
-#include "e-text-event-processor-emacs-like.h"
-
-enum {
- E_TEXT_RESIZE,
- E_TEXT_CHANGE,
- E_TEXT_LAST_SIGNAL
-};
-
-static guint e_text_signals[E_TEXT_LAST_SIGNAL] = { 0 };
-
-
-
-/* This defines a line of text */
-struct line {
- char *text; /* Line's text, it is a pointer into the text->text string */
- int length; /* Line's length in characters */
- int width; /* Line's width in pixels */
- int ellipsis_length; /* Length before adding ellipsis */
-};
-
-
-
-/* Object argument IDs */
-enum {
- ARG_0,
- ARG_TEXT,
- ARG_X,
- ARG_Y,
- ARG_FONT,
- ARG_FONTSET,
- ARG_FONT_GDK,
- ARG_ANCHOR,
- ARG_JUSTIFICATION,
- ARG_CLIP_WIDTH,
- ARG_CLIP_HEIGHT,
- ARG_CLIP,
- ARG_X_OFFSET,
- ARG_Y_OFFSET,
- ARG_FILL_COLOR,
- ARG_FILL_COLOR_GDK,
- ARG_FILL_COLOR_RGBA,
- ARG_FILL_STIPPLE,
- ARG_TEXT_WIDTH,
- ARG_TEXT_HEIGHT,
- ARG_EDITABLE,
- ARG_USE_ELLIPSIS,
- ARG_ELLIPSIS
-};
-
-
-enum {
- E_SELECTION_PRIMARY,
- E_SELECTION_CLIPBOARD
-};
-enum {
- TARGET_STRING,
- TARGET_TEXT,
- TARGET_COMPOUND_TEXT
-};
-
-static void e_text_class_init (ETextClass *class);
-static void e_text_init (EText *text);
-static void e_text_destroy (GtkObject *object);
-static void e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static void e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-
-static void e_text_update (GnomeCanvasItem *item, double *affine,
- ArtSVP *clip_path, int flags);
-static void e_text_realize (GnomeCanvasItem *item);
-static void e_text_unrealize (GnomeCanvasItem *item);
-static void e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height);
-static double e_text_point (GnomeCanvasItem *item, double x, double y, int cx, int cy,
- GnomeCanvasItem **actual_item);
-static void e_text_bounds (GnomeCanvasItem *item,
- double *x1, double *y1, double *x2, double *y2);
-static void e_text_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf);
-static gint e_text_event (GnomeCanvasItem *item, GdkEvent *event);
-
-static void e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gpointer data);
-
-static guint32 e_text_get_event_time (EText *text);
-
-static void e_text_get_selection(EText *text, GdkAtom selection, guint32 time);
-static void e_text_supply_selection (EText *text, guint time, GdkAtom selection, guchar *data, gint length);
-
-static GtkWidget *e_text_get_invisible(EText *text);
-static void _selection_clear_event (GtkInvisible *invisible,
- GdkEventSelection *event,
- EText *text);
-static void _selection_get (GtkInvisible *invisible,
- GtkSelectionData *selection_data,
- guint info,
- guint time_stamp,
- EText *text);
-static void _selection_received (GtkInvisible *invisible,
- GtkSelectionData *selection_data,
- guint time,
- EText *text);
-
-static ETextSuckFont *e_suck_font (GdkFont *font);
-static void e_suck_font_free (ETextSuckFont *suckfont);
-
-
-static GnomeCanvasItemClass *parent_class;
-static GdkAtom clipboard_atom = GDK_NONE;
-
-
-
-/**
- * e_text_get_type:
- * @void:
- *
- * Registers the &EText class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the &EText class.
- **/
-GtkType
-e_text_get_type (void)
-{
- static GtkType text_type = 0;
-
- if (!text_type) {
- GtkTypeInfo text_info = {
- "EText",
- sizeof (EText),
- sizeof (ETextClass),
- (GtkClassInitFunc) e_text_class_init,
- (GtkObjectInitFunc) e_text_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- text_type = gtk_type_unique (gnome_canvas_item_get_type (), &text_info);
- }
-
- return text_type;
-}
-
-/* Class initialization function for the text item */
-static void
-e_text_class_init (ETextClass *klass)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass *) klass;
- item_class = (GnomeCanvasItemClass *) klass;
-
- parent_class = gtk_type_class (gnome_canvas_item_get_type ());
-
- e_text_signals[E_TEXT_RESIZE] =
- gtk_signal_new ("resize",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETextClass, resize),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
-
- e_text_signals[E_TEXT_CHANGE] =
- gtk_signal_new ("change",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETextClass, change),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
-
- gtk_object_class_add_signals (object_class, e_text_signals, E_TEXT_LAST_SIGNAL);
-
- gtk_object_add_arg_type ("EText::text",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TEXT);
- gtk_object_add_arg_type ("EText::x",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_X);
- gtk_object_add_arg_type ("EText::y",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_Y);
- gtk_object_add_arg_type ("EText::font",
- GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FONT);
- gtk_object_add_arg_type ("EText::fontset",
- GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FONTSET);
- gtk_object_add_arg_type ("EText::font_gdk",
- GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_FONT_GDK);
- gtk_object_add_arg_type ("EText::anchor",
- GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_ANCHOR);
- gtk_object_add_arg_type ("EText::justification",
- GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_JUSTIFICATION);
- gtk_object_add_arg_type ("EText::clip_width",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_CLIP_WIDTH);
- gtk_object_add_arg_type ("EText::clip_height",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_CLIP_HEIGHT);
- gtk_object_add_arg_type ("EText::clip",
- GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_CLIP);
- gtk_object_add_arg_type ("EText::x_offset",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_X_OFFSET);
- gtk_object_add_arg_type ("EText::y_offset",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_Y_OFFSET);
- gtk_object_add_arg_type ("EText::fill_color",
- GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FILL_COLOR);
- gtk_object_add_arg_type ("EText::fill_color_gdk",
- GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_FILL_COLOR_GDK);
- gtk_object_add_arg_type ("EText::fill_color_rgba",
- GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_FILL_COLOR_RGBA);
- gtk_object_add_arg_type ("EText::fill_stipple",
- GTK_TYPE_GDK_WINDOW, GTK_ARG_READWRITE, ARG_FILL_STIPPLE);
- gtk_object_add_arg_type ("EText::text_width",
- GTK_TYPE_DOUBLE, GTK_ARG_READABLE, ARG_TEXT_WIDTH);
- gtk_object_add_arg_type ("EText::text_height",
- GTK_TYPE_DOUBLE, GTK_ARG_READABLE, ARG_TEXT_HEIGHT);
- gtk_object_add_arg_type ("EText::editable",
- GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EDITABLE);
- gtk_object_add_arg_type ("EText::use_ellipsis",
- GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_USE_ELLIPSIS);
- gtk_object_add_arg_type ("EText::ellipsis",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ELLIPSIS);
-
- if (!clipboard_atom)
- clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
-
-
-
- klass->resize = NULL;
- klass->change = NULL;
-
- object_class->destroy = e_text_destroy;
- object_class->set_arg = e_text_set_arg;
- object_class->get_arg = e_text_get_arg;
-
- item_class->update = e_text_update;
- item_class->realize = e_text_realize;
- item_class->unrealize = e_text_unrealize;
- item_class->draw = e_text_draw;
- item_class->point = e_text_point;
- item_class->bounds = e_text_bounds;
- item_class->render = e_text_render;
- item_class->event = e_text_event;
-}
-
-/* Object initialization function for the text item */
-static void
-e_text_init (EText *text)
-{
- text->x = 0.0;
- text->y = 0.0;
- text->anchor = GTK_ANCHOR_CENTER;
- text->justification = GTK_JUSTIFY_LEFT;
- text->clip_width = 0.0;
- text->clip_height = 0.0;
- text->xofs = 0.0;
- text->yofs = 0.0;
-
- text->ellipsis = NULL;
- text->use_ellipsis = FALSE;
- text->ellipsis_width = 0;
-
- text->editable = FALSE;
- text->editing = FALSE;
- text->xofs_edit = 0;
-
- text->selection_start = 0;
- text->selection_end = 0;
- text->select_by_word = FALSE;
-
- text->timeout_id = 0;
- text->timer = NULL;
-
- text->lastx = 0;
- text->lasty = 0;
- text->last_state = 0;
-
- text->scroll_start = 0;
- text->show_cursor = TRUE;
- text->button_down = FALSE;
-
- text->tep = NULL;
-
- text->has_selection = FALSE;
-
- text->invisible = NULL;
- text->primary_selection = NULL;
- text->primary_length = 0;
- text->clipboard_selection = NULL;
- text->clipboard_length = 0;
-
- text->pointer_in = FALSE;
- text->default_cursor_shown = TRUE;
-}
-
-/* Destroy handler for the text item */
-static void
-e_text_destroy (GtkObject *object)
-{
- EText *text;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNOME_IS_CANVAS_TEXT (object));
-
- text = E_TEXT (object);
-
- if (text->text)
- g_free (text->text);
-
- if (text->tep)
- gtk_object_unref (GTK_OBJECT(text->tep));
-
- if (text->invisible)
- gtk_object_unref (GTK_OBJECT(text->invisible));
-
- if (text->lines)
- g_free (text->lines);
-
- if (text->font)
- gdk_font_unref (text->font);
-
- if (text->suckfont)
- e_suck_font_free (text->suckfont);
-
- if (text->stipple)
- gdk_bitmap_unref (text->stipple);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-static void
-get_bounds_item_relative (EText *text, double *px1, double *py1, double *px2, double *py2)
-{
- GnomeCanvasItem *item;
- double x, y;
- double clip_x, clip_y;
- int old_height;
-
- item = GNOME_CANVAS_ITEM (text);
-
- x = text->x;
- y = text->y;
-
- clip_x = x;
- clip_y = y;
-
- /* Calculate text dimensions */
-
- old_height = text->height;
-
- if (text->text && text->font)
- text->height = (text->font->ascent + text->font->descent) * text->num_lines;
- else
- text->height = 0;
-
- if (old_height != text->height)
- gtk_signal_emit_by_name (GTK_OBJECT (text), "resize");
-
- /* Anchor text */
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- x -= text->max_width / 2;
- clip_x -= text->clip_width / 2;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- x -= text->max_width;
- clip_x -= text->clip_width;
- break;
- }
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- y -= text->height / 2;
- clip_y -= text->clip_height / 2;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- y -= text->height;
- clip_y -= text->clip_height;
- break;
- }
-
- /* Bounds */
-
- if (text->clip) {
- /* maybe do bbox intersection here? */
- *px1 = clip_x;
- *py1 = clip_y;
- *px2 = clip_x + text->clip_width;
- *py2 = clip_y + text->clip_height;
- } else {
- *px1 = x;
- *py1 = y;
- *px2 = x + text->max_width;
- *py2 = y + text->height;
- }
-}
-
-static void
-get_bounds (EText *text, double *px1, double *py1, double *px2, double *py2)
-{
- GnomeCanvasItem *item;
- double wx, wy;
- int old_height;
-
- item = GNOME_CANVAS_ITEM (text);
-
- /* Get canvas pixel coordinates for text position */
-
- wx = text->x;
- wy = text->y;
- gnome_canvas_item_i2w (item, &wx, &wy);
- gnome_canvas_w2c (item->canvas, wx + text->xofs, wy + text->yofs, &text->cx, &text->cy);
-
- /* Get canvas pixel coordinates for clip rectangle position */
-
- gnome_canvas_w2c (item->canvas, wx, wy, &text->clip_cx, &text->clip_cy);
- text->clip_cwidth = text->clip_width * item->canvas->pixels_per_unit;
- text->clip_cheight = text->clip_height * item->canvas->pixels_per_unit;
-
- /* Calculate text dimensions */
-
- old_height = text->height;
-
- if (text->text && text->font)
- text->height = (text->font->ascent + text->font->descent) * text->num_lines;
- else
- text->height = 0;
-
- if (old_height != text->height)
- gtk_signal_emit_by_name (GTK_OBJECT (text), "resize");
-
- /* Anchor text */
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- text->cx -= text->max_width / 2;
- text->clip_cx -= text->clip_cwidth / 2;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- text->cx -= text->max_width;
- text->clip_cx -= text->clip_cwidth;
- break;
- }
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- text->cy -= text->height / 2;
- text->clip_cy -= text->clip_cheight / 2;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- text->cy -= text->height;
- text->clip_cy -= text->clip_cheight;
- break;
- }
-
- /* Bounds */
-
- if (text->clip) {
- *px1 = text->clip_cx;
- *py1 = text->clip_cy;
- *px2 = text->clip_cx + text->clip_cwidth;
- *py2 = text->clip_cy + text->clip_cheight;
- } else {
- *px1 = text->cx;
- *py1 = text->cy;
- *px2 = text->cx + text->max_width;
- *py2 = text->cy + text->height;
- }
-}
-
-/* Recalculates the bounding box of the text item. The bounding box is defined
- * by the text's extents if the clip rectangle is disabled. If it is enabled,
- * the bounding box is defined by the clip rectangle itself.
- */
-static void
-recalc_bounds (EText *text)
-{
- GnomeCanvasItem *item;
-
- item = GNOME_CANVAS_ITEM (text);
-
- get_bounds (text, &item->x1, &item->y1, &item->x2, &item->y2);
-
- gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
-}
-
-static void
-calc_ellipsis (EText *text)
-{
- if (text->font)
- text->ellipsis_width =
- gdk_text_width (text->font,
- text->ellipsis ? text->ellipsis : "...",
- text->ellipsis ? strlen (text->ellipsis) : 3);
-}
-
-/* Calculates the line widths (in pixels) of the text's splitted lines */
-static void
-calc_line_widths (EText *text)
-{
- struct line *lines;
- int i;
- int j;
-
- lines = text->lines;
- text->max_width = 0;
-
- if (!lines)
- return;
-
- for (i = 0; i < text->num_lines; i++) {
- if (lines->length != 0) {
- if (text->font) {
- lines->width = gdk_text_width (text->font,
- lines->text, lines->length);
- lines->ellipsis_length = 0;
- } else {
- lines->width = 0;
- }
-
- if (text->clip &&
- text->use_ellipsis &&
- ! text->editing &&
- lines->width > text->clip_width) {
- if (text->font) {
- lines->ellipsis_length = 0;
- for (j = 0; j < lines->length; j++ ) {
- if (gdk_text_width (text->font, lines->text, j) + text->ellipsis_width <= text->clip_width)
- lines->ellipsis_length = j;
- else
- break;
- }
- }
- else
- lines->ellipsis_length = 0;
- lines->width = gdk_text_width (text->font, lines->text, lines->ellipsis_length) +
- text->ellipsis_width;
- }
- else
- lines->ellipsis_length = lines->length;
-
- if (lines->width > text->max_width)
- text->max_width = lines->width;
- }
-
- lines++;
- }
-}
-
-/* Splits the text of the text item into lines */
-static void
-split_into_lines (EText *text)
-{
- char *p;
- struct line *lines;
- int len;
-
- /* Free old array of lines */
-
- if (text->lines)
- g_free (text->lines);
-
- text->lines = NULL;
- text->num_lines = 0;
-
- if (!text->text)
- return;
-
- /* First, count the number of lines */
-
- for (p = text->text; *p; p++)
- if (*p == '\n')
- text->num_lines++;
-
- text->num_lines++;
-
- /* Allocate array of lines and calculate split positions */
-
- text->lines = lines = g_new0 (struct line, text->num_lines);
- len = 0;
-
- for (p = text->text; *p; p++) {
- if (len == 0)
- lines->text = p;
- if (*p == '\n') {
- lines->length = len;
- lines++;
- len = 0;
- } else
- len++;
- }
-
- if (len == 0)
- lines->text = p;
- lines->length = len;
-
- calc_line_widths (text);
-}
-
-/* Convenience function to set the text's GC's foreground color */
-static void
-set_text_gc_foreground (EText *text)
-{
- GdkColor c;
-
- if (!text->gc)
- return;
-
- c.pixel = text->pixel;
- gdk_gc_set_foreground (text->gc, &c);
-}
-
-/* Sets the stipple pattern for the text */
-static void
-set_stipple (EText *text, GdkBitmap *stipple, int reconfigure)
-{
- if (text->stipple && !reconfigure)
- gdk_bitmap_unref (text->stipple);
-
- text->stipple = stipple;
- if (stipple && !reconfigure)
- gdk_bitmap_ref (stipple);
-
- if (text->gc) {
- if (stipple) {
- gdk_gc_set_stipple (text->gc, stipple);
- gdk_gc_set_fill (text->gc, GDK_STIPPLED);
- } else
- gdk_gc_set_fill (text->gc, GDK_SOLID);
- }
-}
-
-/* Set_arg handler for the text item */
-static void
-e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EText *text;
- GdkColor color = { 0, 0, 0, 0, };
- GdkColor *pcolor;
- gboolean color_changed;
- int have_pixel;
-
- item = GNOME_CANVAS_ITEM (object);
- text = E_TEXT (object);
-
- color_changed = FALSE;
- have_pixel = FALSE;
-
- switch (arg_id) {
- case ARG_TEXT:
- if (text->text)
- g_free (text->text);
-
- text->text = g_strdup (GTK_VALUE_STRING (*arg));
- split_into_lines (text);
- recalc_bounds (text);
- break;
-
- case ARG_X:
- text->x = GTK_VALUE_DOUBLE (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_Y:
- text->y = GTK_VALUE_DOUBLE (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_FONT:
- if (text->font)
- gdk_font_unref (text->font);
-
- text->font = gdk_font_load (GTK_VALUE_STRING (*arg));
-
- if (item->canvas->aa) {
- if (text->suckfont)
- e_suck_font_free (text->suckfont);
-
- text->suckfont = e_suck_font (text->font);
- }
-
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_FONTSET:
- if (text->font)
- gdk_font_unref (text->font);
-
- text->font = gdk_fontset_load (GTK_VALUE_STRING (*arg));
-
- if (item->canvas->aa) {
- if (text->suckfont)
- e_suck_font_free (text->suckfont);
-
- text->suckfont = e_suck_font (text->font);
- }
-
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_FONT_GDK:
- if (text->font)
- gdk_font_unref (text->font);
-
- text->font = GTK_VALUE_BOXED (*arg);
- gdk_font_ref (text->font);
-
- if (item->canvas->aa) {
- if (text->suckfont)
- e_suck_font_free (text->suckfont);
-
- text->suckfont = e_suck_font (text->font);
- }
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_ANCHOR:
- text->anchor = GTK_VALUE_ENUM (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_JUSTIFICATION:
- text->justification = GTK_VALUE_ENUM (*arg);
- break;
-
- case ARG_CLIP_WIDTH:
- text->clip_width = fabs (GTK_VALUE_DOUBLE (*arg));
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_CLIP_HEIGHT:
- text->clip_height = fabs (GTK_VALUE_DOUBLE (*arg));
- recalc_bounds (text);
- break;
-
- case ARG_CLIP:
- text->clip = GTK_VALUE_BOOL (*arg);
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_X_OFFSET:
- text->xofs = GTK_VALUE_DOUBLE (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_Y_OFFSET:
- text->yofs = GTK_VALUE_DOUBLE (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_FILL_COLOR:
- if (GTK_VALUE_STRING (*arg))
- gdk_color_parse (GTK_VALUE_STRING (*arg), &color);
-
- text->rgba = ((color.red & 0xff00) << 16 |
- (color.green & 0xff00) << 8 |
- (color.blue & 0xff00) |
- 0xff);
- color_changed = TRUE;
- break;
-
- case ARG_FILL_COLOR_GDK:
- pcolor = GTK_VALUE_BOXED (*arg);
- if (pcolor) {
- color = *pcolor;
- gdk_color_context_query_color (item->canvas->cc, &color);
- have_pixel = TRUE;
- }
-
- text->rgba = ((color.red & 0xff00) << 16 |
- (color.green & 0xff00) << 8 |
- (color.blue & 0xff00) |
- 0xff);
- color_changed = TRUE;
- break;
-
- case ARG_FILL_COLOR_RGBA:
- text->rgba = GTK_VALUE_UINT (*arg);
- color_changed = TRUE;
- break;
-
- case ARG_FILL_STIPPLE:
- set_stipple (text, GTK_VALUE_BOXED (*arg), FALSE);
- break;
-
- case ARG_EDITABLE:
- text->editable = GTK_VALUE_BOOL (*arg);
- break;
-
- case ARG_USE_ELLIPSIS:
- text->use_ellipsis = GTK_VALUE_BOOL (*arg);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_ELLIPSIS:
- if (text->ellipsis)
- g_free (text->ellipsis);
-
- text->ellipsis = g_strdup (GTK_VALUE_STRING (*arg));
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- default:
- break;
- }
-
- if (color_changed) {
- if (have_pixel)
- text->pixel = color.pixel;
- else
- text->pixel = gnome_canvas_get_color_pixel (item->canvas, text->rgba);
-
- if (!item->canvas->aa)
- set_text_gc_foreground (text);
-
- gnome_canvas_item_request_update (item);
- }
-}
-
-/* Get_arg handler for the text item */
-static void
-e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- EText *text;
- GdkColor *color;
-
- text = E_TEXT (object);
-
- switch (arg_id) {
- case ARG_TEXT:
- GTK_VALUE_STRING (*arg) = g_strdup (text->text);
- break;
-
- case ARG_X:
- GTK_VALUE_DOUBLE (*arg) = text->x;
- break;
-
- case ARG_Y:
- GTK_VALUE_DOUBLE (*arg) = text->y;
- break;
-
- case ARG_FONT_GDK:
- GTK_VALUE_BOXED (*arg) = text->font;
- break;
-
- case ARG_ANCHOR:
- GTK_VALUE_ENUM (*arg) = text->anchor;
- break;
-
- case ARG_JUSTIFICATION:
- GTK_VALUE_ENUM (*arg) = text->justification;
- break;
-
- case ARG_CLIP_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = text->clip_width;
- break;
-
- case ARG_CLIP_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = text->clip_height;
- break;
-
- case ARG_CLIP:
- GTK_VALUE_BOOL (*arg) = text->clip;
- break;
-
- case ARG_X_OFFSET:
- GTK_VALUE_DOUBLE (*arg) = text->xofs;
- break;
-
- case ARG_Y_OFFSET:
- GTK_VALUE_DOUBLE (*arg) = text->yofs;
- break;
-
- case ARG_FILL_COLOR_GDK:
- color = g_new (GdkColor, 1);
- color->pixel = text->pixel;
- gdk_color_context_query_color (text->item.canvas->cc, color);
- GTK_VALUE_BOXED (*arg) = color;
- break;
-
- case ARG_FILL_COLOR_RGBA:
- GTK_VALUE_UINT (*arg) = text->rgba;
- break;
-
- case ARG_FILL_STIPPLE:
- GTK_VALUE_BOXED (*arg) = text->stipple;
- break;
-
- case ARG_TEXT_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = text->max_width / text->item.canvas->pixels_per_unit;
- break;
-
- case ARG_TEXT_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = text->height / text->item.canvas->pixels_per_unit;
- break;
-
- case ARG_EDITABLE:
- GTK_VALUE_BOOL (*arg) = text->editable;
- break;
-
- case ARG_USE_ELLIPSIS:
- GTK_VALUE_BOOL (*arg) = text->use_ellipsis;
- break;
-
- case ARG_ELLIPSIS:
- GTK_VALUE_STRING (*arg) = g_strdup (text->ellipsis);
- break;
-
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-/* Update handler for the text item */
-static void
-e_text_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- EText *text;
- double x1, y1, x2, y2;
- ArtDRect i_bbox, c_bbox;
- int i;
-
- text = E_TEXT (item);
-
- if (parent_class->update)
- (* parent_class->update) (item, affine, clip_path, flags);
-
- if (!item->canvas->aa) {
- set_text_gc_foreground (text);
- set_stipple (text, text->stipple, TRUE);
- get_bounds (text, &x1, &y1, &x2, &y2);
-
- gnome_canvas_update_bbox (item, x1, y1, x2, y2);
- } else {
- /* aa rendering */
- for (i = 0; i < 6; i++)
- text->affine[i] = affine[i];
- get_bounds_item_relative (text, &i_bbox.x0, &i_bbox.y0, &i_bbox.x1, &i_bbox.y1);
- art_drect_affine_transform (&c_bbox, &i_bbox, affine);
- gnome_canvas_update_bbox (item, c_bbox.x0, c_bbox.y0, c_bbox.x1, c_bbox.y1);
-
- }
-}
-
-/* Realize handler for the text item */
-static void
-e_text_realize (GnomeCanvasItem *item)
-{
- EText *text;
-
- text = E_TEXT (item);
-
- if (parent_class->realize)
- (* parent_class->realize) (item);
-
- text->gc = gdk_gc_new (item->canvas->layout.bin_window);
-
- text->i_cursor = gdk_cursor_new (GDK_XTERM);
- text->default_cursor = gdk_cursor_new (GDK_LEFT_PTR);
-}
-
-/* Unrealize handler for the text item */
-static void
-e_text_unrealize (GnomeCanvasItem *item)
-{
- EText *text;
-
- text = E_TEXT (item);
-
- gdk_gc_unref (text->gc);
- text->gc = NULL;
-
- gdk_cursor_destroy (text->i_cursor);
- gdk_cursor_destroy (text->default_cursor);
-
- if (parent_class->unrealize)
- (* parent_class->unrealize) (item);
-}
-
-/* Calculates the x position of the specified line of text, based on the text's justification */
-static double
-get_line_xpos_item_relative (EText *text, struct line *line)
-{
- double x;
-
- x = text->x;
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- x -= text->max_width / 2;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- x -= text->max_width;
- break;
- }
-
- switch (text->justification) {
- case GTK_JUSTIFY_RIGHT:
- x += text->max_width - line->width;
- break;
-
- case GTK_JUSTIFY_CENTER:
- x += (text->max_width - line->width) * 0.5;
- break;
-
- default:
- /* For GTK_JUSTIFY_LEFT, we don't have to do anything. We do not support
- * GTK_JUSTIFY_FILL, yet.
- */
- break;
- }
-
- return x;
-}
-
-/* Calculates the y position of the first line of text. */
-static double
-get_line_ypos_item_relative (EText *text)
-{
- double y;
-
- y = text->y;
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- y -= text->height / 2;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- y -= text->height;
- break;
- }
-
- return y;
-}
-
-/* Calculates the x position of the specified line of text, based on the text's justification */
-static int
-get_line_xpos (EText *text, struct line *line)
-{
- int x;
-
- x = text->cx;
-
- switch (text->justification) {
- case GTK_JUSTIFY_RIGHT:
- x += text->max_width - line->width;
- break;
-
- case GTK_JUSTIFY_CENTER:
- x += (text->max_width - line->width) / 2;
- break;
-
- default:
- /* For GTK_JUSTIFY_LEFT, we don't have to do anything. We do not support
- * GTK_JUSTIFY_FILL, yet.
- */
- break;
- }
-
- return x;
-}
-
-static void
-_get_tep(EText *text)
-{
- if (!text->tep) {
- text->tep = e_text_event_processor_emacs_like_new();
- gtk_object_ref (GTK_OBJECT (text->tep));
- gtk_object_sink (GTK_OBJECT (text->tep));
- gtk_signal_connect(GTK_OBJECT(text->tep),
- "command",
- GTK_SIGNAL_FUNC(e_text_command),
- (gpointer) text);
- }
-}
-
-/* Draw handler for the text item */
-static void
-e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height)
-{
- EText *text;
- GdkRectangle rect, *clip_rect;
- struct line *lines;
- int i;
- int xpos, ypos;
- int start_char, end_char;
- int sel_start, sel_end;
- GdkRectangle sel_rect;
- GdkGC *fg_gc;
- GnomeCanvas *canvas;
-
- text = E_TEXT (item);
- canvas = GNOME_CANVAS_ITEM(text)->canvas;
-
- fg_gc = GTK_WIDGET(canvas)->style->fg_gc[text->has_selection ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE];
-
- if (!text->text || !text->font)
- return;
-
- clip_rect = NULL;
- if (text->clip) {
- rect.x = text->clip_cx - x;
- rect.y = text->clip_cy - y;
- rect.width = text->clip_cwidth;
- rect.height = text->clip_cheight;
-
- gdk_gc_set_clip_rectangle (text->gc, &rect);
- gdk_gc_set_clip_rectangle (fg_gc, &rect);
- clip_rect = &rect;
- }
- lines = text->lines;
- ypos = text->cy + text->font->ascent;
-
- if (text->stipple)
- gnome_canvas_set_stipple_origin (item->canvas, text->gc);
-
- for (i = 0; i < text->num_lines; i++) {
- if (lines->length != 0) {
- xpos = get_line_xpos (text, lines);
- if (text->editing) {
- xpos -= text->xofs_edit;
- start_char = lines->text - text->text;
- end_char = start_char + lines->length;
- sel_start = text->selection_start;
- sel_end = text->selection_end;
- if (sel_start > sel_end ) {
- sel_start ^= sel_end;
- sel_end ^= sel_start;
- sel_start ^= sel_end;
- }
- if ( sel_start < start_char )
- sel_start = start_char;
- if ( sel_end > end_char )
- sel_end = end_char;
- if ( sel_start < sel_end ) {
- sel_rect.x = xpos - x + gdk_text_width (text->font,
- lines->text,
- sel_start - start_char);
- sel_rect.y = ypos - y - text->font->ascent;
- sel_rect.width = gdk_text_width (text->font,
- lines->text + sel_start - start_char,
- sel_end - sel_start);
- sel_rect.height = text->font->ascent + text->font->descent;
- gtk_paint_flat_box(GTK_WIDGET(item->canvas)->style,
- drawable,
- text->has_selection ?
- GTK_STATE_SELECTED :
- GTK_STATE_ACTIVE,
- GTK_SHADOW_NONE,
- clip_rect,
- GTK_WIDGET(item->canvas),
- "text",
- sel_rect.x,
- sel_rect.y,
- sel_rect.width,
- sel_rect.height);
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x,
- ypos - y,
- lines->text,
- sel_start - start_char);
- gdk_draw_text (drawable,
- text->font,
- fg_gc,
- xpos - x + gdk_text_width (text->font,
- lines->text,
- sel_start - start_char),
- ypos - y,
- lines->text + sel_start - start_char,
- sel_end - sel_start);
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x + gdk_text_width (text->font,
- lines->text,
- sel_end - start_char),
- ypos - y,
- lines->text + sel_end - start_char,
- end_char - sel_end);
- } else {
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x,
- ypos - y,
- lines->text,
- lines->length);
- }
- if (text->selection_start == text->selection_end &&
- text->selection_start >= start_char &&
- text->selection_start <= end_char &&
- text->show_cursor) {
- gdk_draw_rectangle (drawable,
- text->gc,
- TRUE,
- xpos - x + gdk_text_width (text->font,
- lines->text,
- sel_start - start_char),
- ypos - y - text->font->ascent,
- 1,
- text->font->ascent + text->font->descent);
- }
- } else {
- if ( text->clip && text->use_ellipsis && lines->ellipsis_length < lines->length) {
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x,
- ypos - y,
- lines->text,
- lines->ellipsis_length);
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x +
- lines->width - text->ellipsis_width,
- ypos - y,
- text->ellipsis ? text->ellipsis : "...",
- text->ellipsis ? strlen (text->ellipsis) : 3);
- } else
-
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x,
- ypos - y,
- lines->text,
- lines->length);
- }
- }
-
- ypos += text->font->ascent + text->font->descent;
- lines++;
- }
-
- if (text->clip) {
- gdk_gc_set_clip_rectangle (text->gc, NULL);
- gdk_gc_set_clip_rectangle (fg_gc, NULL);
- }
-}
-
-/* Render handler for the text item */
-static void
-e_text_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf)
-{
- EText *text;
- guint32 fg_color;
- double xpos, ypos;
- struct line *lines;
- int i, j;
- double affine[6];
- ETextSuckFont *suckfont;
- int dx, dy;
- ArtPoint start_i, start_c;
-
- text = E_TEXT (item);
-
- if (!text->text || !text->font || !text->suckfont)
- return;
-
- suckfont = text->suckfont;
-
- fg_color = text->rgba;
-
- gnome_canvas_buf_ensure_buf (buf);
-
- lines = text->lines;
- start_i.y = get_line_ypos_item_relative (text);
-
- art_affine_scale (affine, item->canvas->pixels_per_unit, item->canvas->pixels_per_unit);
- for (i = 0; i < 6; i++)
- affine[i] = text->affine[i];
-
- for (i = 0; i < text->num_lines; i++) {
- if (lines->length != 0) {
- start_i.x = get_line_xpos_item_relative (text, lines);
- art_affine_point (&start_c, &start_i, text->affine);
- xpos = start_c.x;
- ypos = start_c.y;
-
- for (j = 0; j < lines->length; j++) {
- ETextSuckChar *ch;
-
- ch = &suckfont->chars[(unsigned char)((lines->text)[j])];
-
- affine[4] = xpos;
- affine[5] = ypos;
- art_rgb_bitmap_affine (
- buf->buf,
- buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1,
- buf->buf_rowstride,
- suckfont->bitmap + (ch->bitmap_offset >> 3),
- ch->width,
- suckfont->bitmap_height,
- suckfont->bitmap_width >> 3,
- fg_color,
- affine,
- ART_FILTER_NEAREST, NULL);
-
- dx = ch->left_sb + ch->width + ch->right_sb;
- xpos += dx * affine[0];
- ypos += dx * affine[1];
- }
- }
-
- dy = text->font->ascent + text->font->descent;
- start_i.y += dy;
- lines++;
- }
-
- buf->is_bg = 0;
-}
-
-/* Point handler for the text item */
-static double
-e_text_point (GnomeCanvasItem *item, double x, double y,
- int cx, int cy, GnomeCanvasItem **actual_item)
-{
- EText *text;
- int i;
- struct line *lines;
- int x1, y1, x2, y2;
- int font_height;
- int dx, dy;
- double dist, best;
-
- text = E_TEXT (item);
-
- *actual_item = item;
-
- /* The idea is to build bounding rectangles for each of the lines of
- * text (clipped by the clipping rectangle, if it is activated) and see
- * whether the point is inside any of these. If it is, we are done.
- * Otherwise, calculate the distance to the nearest rectangle.
- */
-
- if (text->font)
- font_height = text->font->ascent + text->font->descent;
- else
- font_height = 0;
-
- best = 1.0e36;
-
- lines = text->lines;
-
- for (i = 0; i < text->num_lines; i++) {
- /* Compute the coordinates of rectangle for the current line,
- * clipping if appropriate.
- */
-
- x1 = get_line_xpos (text, lines);
- y1 = text->cy + i * font_height;
- x2 = x1 + lines->width;
- y2 = y1 + font_height;
-
- if (text->clip) {
- if (x1 < text->clip_cx)
- x1 = text->clip_cx;
-
- if (y1 < text->clip_cy)
- y1 = text->clip_cy;
-
- if (x2 > (text->clip_cx + text->clip_width))
- x2 = text->clip_cx + text->clip_width;
-
- if (y2 > (text->clip_cy + text->clip_height))
- y2 = text->clip_cy + text->clip_height;
-
- if ((x1 >= x2) || (y1 >= y2))
- continue;
- }
-
- /* Calculate distance from point to rectangle */
-
- if (cx < x1)
- dx = x1 - cx;
- else if (cx >= x2)
- dx = cx - x2 + 1;
- else
- dx = 0;
-
- if (cy < y1)
- dy = y1 - cy;
- else if (cy >= y2)
- dy = cy - y2 + 1;
- else
- dy = 0;
-
- if ((dx == 0) && (dy == 0))
- return 0.0;
-
- dist = sqrt (dx * dx + dy * dy);
- if (dist < best)
- best = dist;
-
- /* Next! */
-
- lines++;
- }
-
- return best / item->canvas->pixels_per_unit;
-}
-
-/* Bounds handler for the text item */
-static void
-e_text_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
-{
- EText *text;
- double width, height;
-
- text = E_TEXT (item);
-
- *x1 = text->x;
- *y1 = text->y;
-
- if (text->clip) {
- width = text->clip_width;
- height = text->clip_height;
- } else {
- width = text->max_width / item->canvas->pixels_per_unit;
- height = text->height / item->canvas->pixels_per_unit;
- }
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- *x1 -= width / 2.0;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- *x1 -= width;
- break;
- }
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- *y1 -= height / 2.0;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- *y1 -= height;
- break;
- }
-
- *x2 = *x1 + width;
- *y2 = *y1 + height;
-}
-
-static void
-_get_xy_from_position (EText *text, gint position, gint *xp, gint *yp)
-{
- if (xp || yp) {
- struct line *lines;
- int x, y;
- int j;
- x = get_line_xpos (text, lines);
- y = text->cy;
- for (j = 0, lines = text->lines; j < text->num_lines; lines++, j++) {
- if (lines->text > text->text + position)
- break;
- y += text->font->ascent + text->font->descent;
- }
- lines --;
- y -= text->font->descent;
-
- x += gdk_text_width (text->font,
- lines->text,
- position - (lines->text - text->text));
- x -= text->xofs_edit;
- if (xp)
- *xp = x;
- if (yp)
- *yp = y;
- }
-}
-
-static gint
-_get_position_from_xy (EText *text, gint x, gint y)
-{
- int i, j;
- int ypos = text->cy;
- int xpos;
- struct line *lines;
- j = 0;
- while (y > ypos) {
- ypos += text->font->ascent + text->font->descent;
- j ++;
- }
- j--;
- if (j >= text->num_lines)
- j = text->num_lines - 1;
- if (j < 0)
- j = 0;
- i = 0;
- lines = text->lines;
- lines += j;
- x += text->xofs_edit;
- xpos = get_line_xpos (text, lines);
- for(i = 0; i < lines->length; i++) {
- int charwidth = gdk_text_width(text->font,
- lines->text + i,
- 1);
- xpos += charwidth / 2;
- if (xpos > x) {
- break;
- }
- xpos += (charwidth + 1) / 2;
- }
- return lines->text + i - text->text;
-}
-
-#define SCROLL_WAIT_TIME 30000
-
-static gboolean
-_blink_scroll_timeout (gpointer data)
-{
- EText *text = E_TEXT(data);
- gulong current_time;
- gboolean scroll = FALSE;
- gboolean redraw = FALSE;
-
- g_timer_elapsed(text->timer, &current_time);
-
- if (text->scroll_start + SCROLL_WAIT_TIME > 1000000) {
- if (current_time > text->scroll_start - (1000000 - SCROLL_WAIT_TIME) &&
- current_time < text->scroll_start)
- scroll = TRUE;
- } else {
- if (current_time > text->scroll_start + SCROLL_WAIT_TIME ||
- current_time < text->scroll_start)
- scroll = TRUE;
- }
- if (scroll && text->button_down) {
- if (text->lastx - text->clip_cx > text->clip_cwidth &&
- text->xofs_edit < text->max_width - text->clip_cwidth) {
- text->xofs_edit += 4;
- if (text->xofs_edit > text->max_width - text->clip_cwidth + 1)
- text->xofs_edit = text->max_width - text->clip_cwidth + 1;
- redraw = TRUE;
- }
- if (text->lastx - text->clip_cx < 0 &&
- text->xofs_edit > 0) {
- text->xofs_edit -= 4;
- if (text->xofs_edit < 0)
- text->xofs_edit = 0;
- redraw = TRUE;
- }
- if (redraw) {
- ETextEventProcessorEvent e_tep_event;
- e_tep_event.type = GDK_MOTION_NOTIFY;
- e_tep_event.motion.state = text->last_state;
- e_tep_event.motion.time = 0;
- e_tep_event.motion.position = _get_position_from_xy(text, text->lastx, text->lasty);
- _get_tep(text);
- e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
- text->scroll_start = current_time;
- }
- }
-
- if (!((current_time / 500000) % 2)) {
- if (!text->show_cursor)
- redraw = TRUE;
- text->show_cursor = TRUE;
- } else {
- if (text->show_cursor)
- redraw = TRUE;
- text->show_cursor = FALSE;
- }
- if (redraw)
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text));
- return TRUE;
-}
-
-static gint
-e_text_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EText *text = E_TEXT(item);
- ETextEventProcessorEvent e_tep_event;
-
- gint return_val = 0;
-
- e_tep_event.type = event->type;
- switch (event->type) {
- case GDK_FOCUS_CHANGE:
- if (text->editable) {
- GdkEventFocus *focus_event;
- focus_event = (GdkEventFocus *) event;
- if (focus_event->in) {
- if(!text->editing) {
- text->editing = TRUE;
- if ( text->pointer_in ) {
- if ( text->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->i_cursor);
- text->default_cursor_shown = FALSE;
- }
- }
- text->selection_start = 0;
- text->selection_end = 0;
- text->select_by_word = FALSE;
- text->xofs_edit = 0;
- if (text->timeout_id == 0)
- text->timeout_id = g_timeout_add(10, _blink_scroll_timeout, text);
- text->timer = g_timer_new();
- g_timer_elapsed(text->timer, &(text->scroll_start));
- g_timer_start(text->timer);
- }
- } else {
- text->editing = FALSE;
- if ( ! text->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->default_cursor);
- text->default_cursor_shown = TRUE;
- }
- if (text->timeout_id) {
- g_source_remove(text->timeout_id);
- text->timeout_id = 0;
- }
- if (text->timer) {
- g_timer_stop(text->timer);
- g_timer_destroy(text->timer);
- text->timer = NULL;
- }
- }
- calc_line_widths (text);
- }
- return_val = 0;
- break;
- case GDK_KEY_PRESS: /* Fall Through */
- case GDK_KEY_RELEASE:
- if (text->editing) {
- GdkEventKey key = event->key;
- e_tep_event.key.time = key.time;
- e_tep_event.key.state = key.state;
- e_tep_event.key.keyval = key.keyval;
- e_tep_event.key.length = key.length;
- e_tep_event.key.string = key.string;
- _get_tep(text);
- return e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
- }
- else
- return 0;
- break;
- case GDK_BUTTON_PRESS: /* Fall Through */
- case GDK_BUTTON_RELEASE:
- if (text->editing) {
- GdkEventButton button = event->button;
- e_tep_event.button.time = button.time;
- e_tep_event.button.state = button.state;
- e_tep_event.button.button = button.button;
- e_tep_event.button.position = _get_position_from_xy(text, button.x, button.y);
- _get_tep(text);
- return_val = e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
- if (event->button.button == 1) {
- if (event->type == GDK_BUTTON_PRESS)
- text->button_down = TRUE;
- else
- text->button_down = FALSE;
- }
- text->lastx = button.x;
- text->lasty = button.y;
- text->last_state = button.state;
- } else if (text->editable && event->type == GDK_BUTTON_RELEASE && event->button.button == 1) {
- gnome_canvas_item_grab_focus (item);
- return 1;
- }
- break;
- case GDK_MOTION_NOTIFY:
- if (text->editing) {
- GdkEventMotion motion = event->motion;
- e_tep_event.motion.time = motion.time;
- e_tep_event.motion.state = motion.state;
- e_tep_event.motion.position = _get_position_from_xy(text, motion.x, motion.y);
- _get_tep(text);
- return_val = e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
- text->lastx = motion.x;
- text->lasty = motion.y;
- text->last_state = motion.state;
- }
- break;
- case GDK_ENTER_NOTIFY:
- text->pointer_in = TRUE;
- if (text->editing) {
- if ( text->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->i_cursor);
- text->default_cursor_shown = FALSE;
- }
- }
- break;
- case GDK_LEAVE_NOTIFY:
- text->pointer_in = FALSE;
- if (text->editing) {
- if ( ! text->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->default_cursor);
- text->default_cursor_shown = TRUE;
- }
- }
- break;
- default:
- break;
- }
- if (return_val)
- return return_val;
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->event)
- return GNOME_CANVAS_ITEM_CLASS(parent_class)->event(item, event);
- else
- return 0;
-}
-
-static int
-_get_position(EText *text, ETextEventProcessorCommand *command)
-{
- int i;
- int length;
- int x, y;
-
- switch (command->position) {
-
- case E_TEP_VALUE:
- return command->value;
-
- case E_TEP_SELECTION:
- return text->selection_end;
-
- case E_TEP_START_OF_BUFFER:
- return 0;
- case E_TEP_END_OF_BUFFER:
- return strlen(text->text);
-
- case E_TEP_START_OF_LINE:
- for (i = text->selection_end - 2; i > 0; i--)
- if (text->text[i] == '\n') {
- i++;
- break;
- }
- return i;
- case E_TEP_END_OF_LINE:
- length = strlen(text->text);
- for (i = text->selection_end + 1; i < length; i++)
- if (text->text[i] == '\n') {
- break;
- }
- if (i > length)
- i = length;
- return i;
-
- case E_TEP_FORWARD_CHARACTER:
- length = strlen(text->text);
- i = text->selection_end + 1;
- if (i > length)
- i = length;
- return i;
- case E_TEP_BACKWARD_CHARACTER:
- i = text->selection_end - 1;
- if (i < 0)
- i = 0;
- return i;
-
- case E_TEP_FORWARD_WORD:
- length = strlen(text->text);
- for (i = text->selection_end + 1; i < length; i++)
- if (isspace(text->text[i])) {
- break;
- }
- if (i > length)
- i = length;
- return i;
- case E_TEP_BACKWARD_WORD:
- for (i = text->selection_end - 2; i > 0; i--)
- if (isspace(text->text[i])) {
- i++;
- break;
- }
- if (i < 0)
- i = 0;
- return i;
-
- case E_TEP_FORWARD_LINE:
- _get_xy_from_position(text, text->selection_end, &x, &y);
- y += text->font->ascent + text->font->descent;
- return _get_position_from_xy(text, x, y);
- case E_TEP_BACKWARD_LINE:
- _get_xy_from_position(text, text->selection_end, &x, &y);
- y -= text->font->ascent + text->font->descent;
- return _get_position_from_xy(text, x, y);
-
- case E_TEP_FORWARD_PARAGRAPH:
- case E_TEP_BACKWARD_PARAGRAPH:
-
- case E_TEP_FORWARD_PAGE:
- case E_TEP_BACKWARD_PAGE:
- return text->selection_end;
- default:
- return text->selection_end;
- }
-}
-
-static void
-_delete_selection(EText *text)
-{
- gint length = strlen(text->text);
- if (text->selection_end == text->selection_start)
- return;
- if (text->selection_end < text->selection_start) {
- text->selection_end ^= text->selection_start;
- text->selection_start ^= text->selection_end;
- text->selection_end ^= text->selection_start;
- }
- memmove( text->text + text->selection_start,
- text->text + text->selection_end,
- length - text->selection_end + 1 );
- length -= text->selection_end - text->selection_start;
- text->selection_end = text->selection_start;
-}
-
-static void
-_insert(EText *text, char *string, int value)
-{
- if (value > 0) {
- char *temp;
- gint length = strlen(text->text);
- temp = g_new(gchar, length + value + 1);
- strncpy(temp, text->text, text->selection_start);
- strncpy(temp + text->selection_start, string, value);
- strcpy(temp + text->selection_start + value, text->text + text->selection_start);
- g_free(text->text);
- text->text = temp;
- text->selection_start += value;
- text->selection_end = text->selection_start;
- }
-}
-
-static void
-e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gpointer data)
-{
- EText *text = E_TEXT(data);
- int sel_start, sel_end;
- switch (command->action) {
- case E_TEP_MOVE:
- text->selection_start = _get_position(text, command);
- text->selection_end = text->selection_start;
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_SELECT:
- text->selection_end = _get_position(text, command);
- sel_start = MIN(text->selection_start, text->selection_end);
- sel_end = MAX(text->selection_start, text->selection_end);
- if (sel_start != sel_end) {
- e_text_supply_selection (text, command->time, GDK_SELECTION_PRIMARY, text->text + sel_start, sel_end - sel_start);
- } else if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_DELETE:
- if (text->selection_end == text->selection_start) {
- text->selection_end = _get_position(text, command);
- }
- _delete_selection(text);
- split_into_lines (text);
- recalc_bounds (text);
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
-
- case E_TEP_INSERT:
- if (text->selection_end != text->selection_start) {
- _delete_selection(text);
- }
- _insert(text, command->string, command->value);
- split_into_lines (text);
- recalc_bounds (text);
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_COPY:
- sel_start = MIN(text->selection_start, text->selection_end);
- sel_end = MAX(text->selection_start, text->selection_end);
- if (sel_start != sel_end) {
- e_text_supply_selection (text, command->time, clipboard_atom, text->text + sel_start, sel_end - sel_start);
- }
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_PASTE:
- e_text_get_selection (text, clipboard_atom, command->time);
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_GET_SELECTION:
- e_text_get_selection (text, GDK_SELECTION_PRIMARY, command->time);
- break;
- case E_TEP_ACTIVATE:
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_SET_SELECT_BY_WORD:
- text->select_by_word = command->value;
- break;
- case E_TEP_GRAB:
- gnome_canvas_item_grab (GNOME_CANVAS_ITEM(text),
- GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
- text->i_cursor,
- command->time);
- break;
- case E_TEP_UNGRAB:
- gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM(text), command->time);
- break;
- case E_TEP_NOP:
- break;
- }
-
- if (!text->button_down) {
- int x;
- int i;
- struct line *lines = text->lines;
- for (lines = text->lines, i = 0; i < text->num_lines ; i++, lines ++) {
- if (lines->text - text->text > text->selection_end) {
- break;
- }
- }
- lines --;
- x = gdk_text_width(text->font,
- lines->text,
- text->selection_end - (lines->text - text->text));
-
-
- if (x < text->xofs_edit) {
- text->xofs_edit = x;
- }
-
- if (2 + x - text->clip_width > text->xofs_edit) {
- text->xofs_edit = 2 + x - text->clip_width;
- }
- }
-
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text));
-}
-
-static void _invisible_destroy (GtkInvisible *invisible,
- EText *text)
-{
- text->invisible = NULL;
-}
-
-static GtkWidget *e_text_get_invisible(EText *text)
-{
- GtkWidget *invisible;
- if (text->invisible) {
- invisible = text->invisible;
- } else {
- invisible = gtk_invisible_new();
- text->invisible = invisible;
-
- gtk_selection_add_target (invisible,
- GDK_SELECTION_PRIMARY,
- GDK_SELECTION_TYPE_STRING,
- E_SELECTION_PRIMARY);
- gtk_selection_add_target (invisible,
- clipboard_atom,
- GDK_SELECTION_TYPE_STRING,
- E_SELECTION_CLIPBOARD);
-
- gtk_signal_connect (GTK_OBJECT(invisible), "selection_get",
- GTK_SIGNAL_FUNC (_selection_get),
- text);
- gtk_signal_connect (GTK_OBJECT(invisible), "selection_clear_event",
- GTK_SIGNAL_FUNC (_selection_clear_event),
- text);
- gtk_signal_connect (GTK_OBJECT(invisible), "selection_received",
- GTK_SIGNAL_FUNC (_selection_received),
- text);
-
- gtk_signal_connect (GTK_OBJECT(invisible), "destroy",
- GTK_SIGNAL_FUNC (_invisible_destroy),
- text);
- }
- return invisible;
-}
-
-static void
-_selection_clear_event (GtkInvisible *invisible,
- GdkEventSelection *event,
- EText *text)
-{
- if (event->selection == GDK_SELECTION_PRIMARY) {
- g_free (text->primary_selection);
- text->primary_selection = NULL;
- text->primary_length = 0;
-
- text->has_selection = FALSE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text));
-
- } else if (event->selection == clipboard_atom) {
- g_free (text->clipboard_selection);
- text->clipboard_selection = NULL;
- text->clipboard_length = 0;
- }
-}
-
-static void
-_selection_get (GtkInvisible *invisible,
- GtkSelectionData *selection_data,
- guint info,
- guint time_stamp,
- EText *text)
-{
- switch (info) {
- case E_SELECTION_PRIMARY:
- gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING,
- 8, text->primary_selection, text->primary_length);
- break;
- case E_SELECTION_CLIPBOARD:
- gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING,
- 8, text->clipboard_selection, text->clipboard_length);
- break;
- }
-}
-
-static void
-_selection_received (GtkInvisible *invisible,
- GtkSelectionData *selection_data,
- guint time,
- EText *text)
-{
- if (selection_data->length < 0 || selection_data->type != GDK_SELECTION_TYPE_STRING) {
- return;
- } else {
- ETextEventProcessorCommand command;
- command.action = E_TEP_INSERT;
- command.position = E_TEP_SELECTION;
- command.string = selection_data->data;
- command.value = selection_data->length;
- command.time = time;
- e_text_command(text->tep, &command, text);
- }
-}
-
-static void e_text_supply_selection (EText *text, guint time, GdkAtom selection, guchar *data, gint length)
-{
- gboolean successful;
- GtkWidget *invisible;
-
- invisible = e_text_get_invisible(text);
-
- if (selection == GDK_SELECTION_PRIMARY ) {
- if (text->primary_selection) {
- g_free (text->primary_selection);
- }
- text->primary_selection = g_strndup(data, length);
- text->primary_length = length;
- } else if (selection == clipboard_atom) {
- if (text->clipboard_selection) {
- g_free (text->clipboard_selection);
- }
- text->clipboard_selection = g_strndup(data, length);
- text->clipboard_length = length;
- }
-
- successful = gtk_selection_owner_set (invisible,
- selection,
- time);
-
- if (selection == GDK_SELECTION_PRIMARY)
- text->has_selection = successful;
-}
-
-static void
-e_text_get_selection(EText *text, GdkAtom selection, guint32 time)
-{
- GtkWidget *invisible;
- invisible = e_text_get_invisible(text);
- gtk_selection_convert(invisible,
- selection,
- GDK_SELECTION_TYPE_STRING,
- time);
-}
-
-#if 0
-static void
-e_text_real_copy_clipboard (EText *text)
-{
- guint32 time;
- gint selection_start_pos;
- gint selection_end_pos;
-
- g_return_if_fail (text != NULL);
- g_return_if_fail (E_IS_TEXT (text));
-
- time = gtk_text_get_event_time (text);
- selection_start_pos = MIN (text->selection_start, text->selection_end);
- selection_end_pos = MAX (text->selection_start, text->selection_end);
-
- if (selection_start_pos != selection_end_pos)
- {
- if (gtk_selection_owner_set (GTK_WIDGET (text->canvas),
- clipboard_atom,
- time))
- text->clipboard_text = "";
- }
-}
-
-static void
-e_text_real_paste_clipboard (EText *text)
-{
- guint32 time;
-
- g_return_if_fail (text != NULL);
- g_return_if_fail (E_IS_TEXT (text));
-
- time = e_text_get_event_time (text);
- if (text->editable)
- gtk_selection_convert (GTK_WIDGET(text->widget),
- clipboard_atom,
- gdk_atom_intern ("COMPOUND_TEXT", FALSE), time);
-}
-#endif
-
-/* Get the timestamp of the current event. Actually, the only thing
- * we really care about below is the key event
- */
-static guint32
-e_text_get_event_time (EText *text)
-{
- GdkEvent *event;
- guint32 tm = GDK_CURRENT_TIME;
-
- event = gtk_get_current_event();
-
- if (event)
- switch (event->type)
- {
- case GDK_MOTION_NOTIFY:
- tm = event->motion.time; break;
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- tm = event->button.time; break;
- case GDK_KEY_PRESS:
- case GDK_KEY_RELEASE:
- tm = event->key.time; break;
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY:
- tm = event->crossing.time; break;
- case GDK_PROPERTY_NOTIFY:
- tm = event->property.time; break;
- case GDK_SELECTION_CLEAR:
- case GDK_SELECTION_REQUEST:
- case GDK_SELECTION_NOTIFY:
- tm = event->selection.time; break;
- case GDK_PROXIMITY_IN:
- case GDK_PROXIMITY_OUT:
- tm = event->proximity.time; break;
- default: /* use current time */
- break;
- }
- gdk_event_free(event);
-
- return tm;
-}
-
-
-
-/* Routines for sucking fonts from the X server */
-
-static ETextSuckFont *
-e_suck_font (GdkFont *font)
-{
- ETextSuckFont *suckfont;
- int i;
- int x, y;
- char text[1];
- int lbearing, rbearing, ch_width, ascent, descent;
- GdkPixmap *pixmap;
- GdkColor black, white;
- GdkImage *image;
- GdkGC *gc;
- guchar *line;
- int width, height;
- int black_pixel, pixel;
-
- if (!font)
- return NULL;
-
- suckfont = g_new (ETextSuckFont, 1);
-
- height = font->ascent + font->descent;
- x = 0;
- for (i = 0; i < 256; i++) {
- text[0] = i;
- gdk_text_extents (font, text, 1,
- &lbearing, &rbearing, &ch_width, &ascent, &descent);
- suckfont->chars[i].left_sb = lbearing;
- suckfont->chars[i].right_sb = ch_width - rbearing;
- suckfont->chars[i].width = rbearing - lbearing;
- suckfont->chars[i].ascent = ascent;
- suckfont->chars[i].descent = descent;
- suckfont->chars[i].bitmap_offset = x;
- x += (ch_width + 31) & -32;
- }
-
- width = x;
-
- suckfont->bitmap_width = width;
- suckfont->bitmap_height = height;
- suckfont->ascent = font->ascent;
-
- pixmap = gdk_pixmap_new (NULL, suckfont->bitmap_width,
- suckfont->bitmap_height, 1);
- gc = gdk_gc_new (pixmap);
- gdk_gc_set_font (gc, font);
-
- black_pixel = BlackPixel (gdk_display, DefaultScreen (gdk_display));
- black.pixel = black_pixel;
- white.pixel = WhitePixel (gdk_display, DefaultScreen (gdk_display));
- gdk_gc_set_foreground (gc, &white);
- gdk_draw_rectangle (pixmap, gc, 1, 0, 0, width, height);
-
- gdk_gc_set_foreground (gc, &black);
- for (i = 0; i < 256; i++) {
- text[0] = i;
- gdk_draw_text (pixmap, font, gc,
- suckfont->chars[i].bitmap_offset - suckfont->chars[i].left_sb,
- font->ascent,
- text, 1);
- }
-
- /* The handling of the image leaves me with distinct unease. But this
- * is more or less copied out of gimp/app/text_tool.c, so it _ought_ to
- * work. -RLL
- */
-
- image = gdk_image_get (pixmap, 0, 0, width, height);
- suckfont->bitmap = g_malloc0 ((width >> 3) * height);
-
- line = suckfont->bitmap;
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- pixel = gdk_image_get_pixel (image, x, y);
- if (pixel == black_pixel)
- line[x >> 3] |= 128 >> (x & 7);
- }
- line += width >> 3;
- }
-
- gdk_image_destroy (image);
-
- /* free the pixmap */
- gdk_pixmap_unref (pixmap);
-
- /* free the gc */
- gdk_gc_destroy (gc);
-
- return suckfont;
-}
-
-static void
-e_suck_font_free (ETextSuckFont *suckfont)
-{
- g_free (suckfont->bitmap);
- g_free (suckfont);
-}
diff --git a/widgets/e-text/e-text.h b/widgets/e-text/e-text.h
deleted file mode 100644
index f4f43a156b..0000000000
--- a/widgets/e-text/e-text.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* EText - Text item for evolution.
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Chris Lahey <clahey@umich.edu>
- *
- * A majority of code taken from:
- *
- * Text item type for GnomeCanvas widget
- *
- * GnomeCanvas is basically a port of the Tk toolkit's most excellent
- * canvas widget. Tk is copyrighted by the Regents of the University
- * of California, Sun Microsystems, and other parties.
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx> */
-
-#ifndef E_TEXT_H
-#define E_TEXT_H
-
-#include <gnome.h>
-#include "e-text-event-processor.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-/* Text item for the canvas. Text items are positioned by an anchor point and an anchor direction.
- *
- * A clipping rectangle may be specified for the text. The rectangle is anchored at the text's anchor
- * point, and is specified by clipping width and height parameters. If the clipping rectangle is
- * enabled, it will clip the text.
- *
- * In addition, x and y offset values may be specified. These specify an offset from the anchor
- * position. If used in conjunction with the clipping rectangle, these could be used to implement
- * simple scrolling of the text within the clipping rectangle.
- *
- * The following object arguments are available:
- *
- * name type read/write description
- * ------------------------------------------------------------------------------------------
- * text string RW The string of the text label
- * x double RW X coordinate of anchor point
- * y double RW Y coordinate of anchor point
- * font string W X logical font descriptor
- * fontset string W X logical fontset descriptor
- * font_gdk GdkFont* RW Pointer to a GdkFont
- * anchor GtkAnchorType RW Anchor side for the text
- * justification GtkJustification RW Justification for multiline text
- * fill_color string W X color specification for text
- * fill_color_gdk GdkColor* RW Pointer to an allocated GdkColor
- * fill_stipple GdkBitmap* RW Stipple pattern for filling the text
- * clip_width double RW Width of clip rectangle
- * clip_height double RW Height of clip rectangle
- * clip boolean RW Use clipping rectangle?
- * x_offset double RW Horizontal offset distance from anchor position
- * y_offset double RW Vertical offset distance from anchor position
- * text_width double R Used to query the width of the rendered text
- * text_height double R Used to query the rendered height of the text
- *
- * These are currently ignored in the AA version:
- * editable boolean RW Can this item be edited
- * use_ellipsis boolean RW Whether to use ellipsises if text gets cut off. Meaningless if clip == false.
- * ellipsis string RW The characters to use as ellipsis. NULL = "...".
- *
- * These are not implemented yet:
- * line_wrap boolean RW Line wrap when not editing.
- * line_wrap_on_edit boolean RW Switch to line wrap when editing.
- * background boolean RW Draw a background rectangle.
- * background_on_edit boolean RW Draw a background when editing.
- */
-
-#define E_TYPE_TEXT (e_text_get_type ())
-#define E_TEXT(obj) (GTK_CHECK_CAST ((obj), E_TYPE_TEXT, EText))
-#define E_TEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_TEXT, ETextClass))
-#define E_IS_TEXT(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_TEXT))
-#define E_IS_TEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_TEXT))
-
-
-typedef struct _EText EText;
-typedef struct _ETextClass ETextClass;
-typedef struct _ETextSuckFont ETextSuckFont;
-typedef struct _ETextSuckChar ETextSuckChar;
-
-struct _ETextSuckChar {
- int left_sb;
- int right_sb;
- int width;
- int ascent;
- int descent;
- int bitmap_offset; /* in pixels */
-};
-
-struct _ETextSuckFont {
- guchar *bitmap;
- gint bitmap_width;
- gint bitmap_height;
- gint ascent;
- ETextSuckChar chars[256];
-};
-
-struct _EText {
- GnomeCanvasItem item;
-
- char *text; /* Text to display */
- gpointer lines; /* Text split into lines (private field) */
- int num_lines; /* Number of lines of text */
-
- double x, y; /* Position at anchor */
- GdkFont *font; /* Font for text */
- GtkAnchorType anchor; /* Anchor side for text */
- GtkJustification justification; /* Justification for text */
-
- double clip_width; /* Width of optional clip rectangle */
- double clip_height; /* Height of optional clip rectangle */
-
- double xofs, yofs; /* Text offset distance from anchor position */
-
- gulong pixel; /* Fill color */
- GdkBitmap *stipple; /* Stipple for text */
- GdkGC *gc; /* GC for drawing text */
-
- int cx, cy; /* Top-left canvas coordinates for text */
- int clip_cx, clip_cy; /* Top-left canvas coordinates for clip rectangle */
- int clip_cwidth, clip_cheight; /* Size of clip rectangle in pixels */
- int max_width; /* Maximum width of text lines */
- int height; /* Rendered text height in pixels */
-
- guint clip : 1; /* Use clip rectangle? */
-
- /* Antialiased specific stuff follows */
- ETextSuckFont *suckfont; /* Sucked font */
- guint32 rgba; /* RGBA color for text */
- double affine[6]; /* The item -> canvas affine */
-
- char *ellipsis; /* The ellipsis characters. NULL = "...". */
- double ellipsis_width; /* The width of the ellipsis. */
- gboolean use_ellipsis; /* Whether to use the ellipsis. */
-
- gboolean editable; /* Item is editable */
- gboolean editing; /* Item is currently being edited */
-
- int xofs_edit; /* Offset because of editing */
-
- /* This needs to be reworked a bit once we get line wrapping. */
- int selection_start; /* Start of selection */
- int selection_end; /* End of selection */
- gboolean select_by_word; /* Current selection is by word */
-
- /* This section is for drag scrolling and blinking cursor. */
- gint timeout_id; /* Current timeout id for scrolling */
- GTimer *timer; /* Timer for blinking cursor and scrolling */
-
- gint lastx, lasty; /* Last x and y motion events */
- gint last_state; /* Last state */
- gulong scroll_start; /* Starting time for scroll (microseconds) */
-
- gint show_cursor; /* Is cursor currently shown */
- gboolean button_down; /* Is mouse button 1 down */
-
- ETextEventProcessor *tep; /* Text Event Processor */
-
- GtkWidget *invisible; /* For selection handling */
- gboolean has_selection; /* TRUE if we have the selection */
- gchar *primary_selection; /* Primary selection text */
- gint primary_length; /* Primary selection text length */
- gchar *clipboard_selection; /* Clipboard selection text */
- gint clipboard_length; /* Clipboard selection text length*/
-
- guint pointer_in : 1;
- guint default_cursor_shown : 1;
-
- GdkCursor *default_cursor;
- GdkCursor *i_cursor;
-};
-
-struct _ETextClass {
- GnomeCanvasItemClass parent_class;
-
- void (* resize) (EText *text);
- void (* change) (EText *text);
-};
-
-
-/* Standard Gtk function */
-GtkType e_text_get_type (void);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/widgets/meeting-time-sel/.cvsignore b/widgets/meeting-time-sel/.cvsignore
deleted file mode 100644
index 21ce3ebb95..0000000000
--- a/widgets/meeting-time-sel/.cvsignore
+++ /dev/null
@@ -1,7 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-*.lo
-*.la
-test-meeting-time-selector
diff --git a/widgets/meeting-time-sel/LICENSE b/widgets/meeting-time-sel/LICENSE
deleted file mode 100644
index 9babf4395f..0000000000
--- a/widgets/meeting-time-sel/LICENSE
+++ /dev/null
@@ -1 +0,0 @@
-This code is licensed under the terms of the GNU GPL
diff --git a/widgets/meeting-time-sel/Makefile.am b/widgets/meeting-time-sel/Makefile.am
deleted file mode 100644
index fdf6e90b67..0000000000
--- a/widgets/meeting-time-sel/Makefile.am
+++ /dev/null
@@ -1,30 +0,0 @@
-
-INCLUDES = \
- $(GNOME_INCLUDEDIR)
-
-noinst_LIBRARIES = \
- libevolutionmtsel.a
-
-libevolutionmtsel_a_SOURCES = \
- e-meeting-time-sel.c \
- e-meeting-time-sel.h \
- e-meeting-time-sel-item.c \
- e-meeting-time-sel-item.h \
- e-meeting-time-sel-list-item.c \
- e-meeting-time-sel-list-item.h
-
-noinst_PROGRAMS = \
- test-meeting-time-selector
-
-test_meeting_time_selector_SOURCES = \
- test-meeting-time-sel.c
-
-test_meeting_time_selector_LDADD = \
- libevolutionmtsel.a
-
-test_meeting_time_selector_LDFLAGS = `gnome-config --libs gnomeui`
-
-EXTRA_DIST = \
- e-meeting-time-sel-mail.xpm \
- e-meeting-time-sel-no-mail.xpm
-
diff --git a/widgets/meeting-time-sel/e-meeting-time-sel-item.c b/widgets/meeting-time-sel/e-meeting-time-sel-item.c
deleted file mode 100644
index cb716d6f08..0000000000
--- a/widgets/meeting-time-sel/e-meeting-time-sel-item.c
+++ /dev/null
@@ -1,924 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * EMeetingTimeSelectorItem - A GnomeCanvasItem which is used for both the main
- * display canvas and the top display (with the dates, times & All Attendees).
- * I didn't make these separate GnomeCanvasItems since they share a lot of
- * code.
- */
-
-#include <config.h>
-#include <time.h>
-#include "e-meeting-time-sel-item.h"
-#include "e-meeting-time-sel.h"
-
-/* Initially the grid lines were drawn at the bottom of cells, but this didn't
- line up well with the GtkEntry widgets, which in the default theme draw a
- black shadow line across the top. So I've switched our code to draw the
- lines across the top of cells. */
-#define E_MEETING_TIME_SELECTOR_DRAW_GRID_LINES_AT_BOTTOM 0
-
-static void e_meeting_time_selector_item_class_init (EMeetingTimeSelectorItemClass *mts_item_class);
-static void e_meeting_time_selector_item_init (EMeetingTimeSelectorItem *mts_item);
-static void e_meeting_time_selector_item_destroy (GtkObject *object);
-
-static void e_meeting_time_selector_item_set_arg (GtkObject *o, GtkArg *arg,
- guint arg_id);
-static void e_meeting_time_selector_item_realize (GnomeCanvasItem *item);
-static void e_meeting_time_selector_item_unrealize (GnomeCanvasItem *item);
-static void e_meeting_time_selector_item_update (GnomeCanvasItem *item,
- double *affine,
- ArtSVP *clip_path, int flags);
-static void e_meeting_time_selector_item_draw (GnomeCanvasItem *item,
- GdkDrawable *drawable,
- int x, int y,
- int width, int height);
-static double e_meeting_time_selector_item_point (GnomeCanvasItem *item,
- double x, double y,
- int cx, int cy,
- GnomeCanvasItem **actual_item);
-static gint e_meeting_time_selector_item_event (GnomeCanvasItem *item,
- GdkEvent *event);
-static gint e_meeting_time_selector_item_button_press (EMeetingTimeSelectorItem *mts_item,
- GdkEvent *event);
-static gint e_meeting_time_selector_item_button_release (EMeetingTimeSelectorItem *mts_item,
- GdkEvent *event);
-static gint e_meeting_time_selector_item_motion_notify (EMeetingTimeSelectorItem *mts_item,
- GdkEvent *event);
-
-static void e_meeting_time_selector_item_paint_day_top (EMeetingTimeSelectorItem *mts_item,
- GdkDrawable *drawable,
- GDate *date,
- int x, int scroll_y,
- int width, int height);
-static void e_meeting_time_selector_item_paint_all_attendees_busy_periods (EMeetingTimeSelectorItem *mts_item, GdkDrawable *drawable, GDate *date, int x, int y, int width, int height);
-static void e_meeting_time_selector_item_paint_day (EMeetingTimeSelectorItem *mts_item,
- GdkDrawable *drawable,
- GDate *date,
- int x, int scroll_y,
- int width, int height);
-static void e_meeting_time_selector_item_paint_busy_periods (EMeetingTimeSelectorItem *mts_item, GdkDrawable *drawable, GDate *date, int x, int scroll_y, int width, int height);
-static gint e_meeting_time_selector_item_find_first_busy_period (EMeetingTimeSelectorItem *mts_item, GDate *date, gint row);
-static void e_meeting_time_selector_item_paint_attendee_busy_periods (EMeetingTimeSelectorItem *mts_item, GdkDrawable *drawable, int row, int x, int y, int width, int first_period, EMeetingTimeSelectorBusyType busy_type);
-
-static EMeetingTimeSelectorPosition e_meeting_time_selector_item_get_drag_position (EMeetingTimeSelectorItem *mts_item, gint x, gint y);
-
-static GnomeCanvasItemClass *parent_class;
-
-/* The arguments we take */
-enum {
- ARG_0,
- ARG_MEETING_TIME_SELECTOR
-};
-
-
-GtkType
-e_meeting_time_selector_item_get_type (void)
-{
- static GtkType e_meeting_time_selector_item_type = 0;
-
- if (!e_meeting_time_selector_item_type) {
- GtkTypeInfo e_meeting_time_selector_item_info = {
- "EMeetingTimeSelectorItem",
- sizeof (EMeetingTimeSelectorItem),
- sizeof (EMeetingTimeSelectorItemClass),
- (GtkClassInitFunc) e_meeting_time_selector_item_class_init,
- (GtkObjectInitFunc) e_meeting_time_selector_item_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- e_meeting_time_selector_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_meeting_time_selector_item_info);
- }
-
- return e_meeting_time_selector_item_type;
-}
-
-
-static void
-e_meeting_time_selector_item_class_init (EMeetingTimeSelectorItemClass *mts_item_class)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- parent_class = gtk_type_class (gnome_canvas_item_get_type());
-
- object_class = (GtkObjectClass *) mts_item_class;
- item_class = (GnomeCanvasItemClass *) mts_item_class;
-
- gtk_object_add_arg_type ("EMeetingTimeSelectorItem::meeting_time_selector",
- GTK_TYPE_POINTER, GTK_ARG_WRITABLE,
- ARG_MEETING_TIME_SELECTOR);
-
- object_class->destroy = e_meeting_time_selector_item_destroy;
- object_class->set_arg = e_meeting_time_selector_item_set_arg;
-
- /* GnomeCanvasItem method overrides */
- item_class->realize = e_meeting_time_selector_item_realize;
- item_class->unrealize = e_meeting_time_selector_item_unrealize;
- item_class->update = e_meeting_time_selector_item_update;
- item_class->draw = e_meeting_time_selector_item_draw;
- item_class->point = e_meeting_time_selector_item_point;
- item_class->event = e_meeting_time_selector_item_event;
-}
-
-
-static void
-e_meeting_time_selector_item_init (EMeetingTimeSelectorItem *mts_item)
-{
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (mts_item);
-
- mts_item->mts = NULL;
-
- mts_item->main_gc = NULL;
-
- /* Create the cursors. */
- mts_item->normal_cursor = gdk_cursor_new (GDK_TOP_LEFT_ARROW);
- mts_item->resize_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
- mts_item->last_cursor_set = NULL;
-
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = 0;
- item->y2 = 0;
-}
-
-
-static void
-e_meeting_time_selector_item_destroy (GtkObject *object)
-{
- EMeetingTimeSelectorItem *mts_item;
-
- mts_item = E_MEETING_TIME_SELECTOR_ITEM (object);
-
- gdk_cursor_destroy (mts_item->normal_cursor);
- gdk_cursor_destroy (mts_item->resize_cursor);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (*GTK_OBJECT_CLASS (parent_class)->destroy)(object);
-}
-
-
-static void
-e_meeting_time_selector_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EMeetingTimeSelectorItem *mts_item;
-
- item = GNOME_CANVAS_ITEM (o);
- mts_item = E_MEETING_TIME_SELECTOR_ITEM (o);
-
- switch (arg_id){
- case ARG_MEETING_TIME_SELECTOR:
- mts_item->mts = GTK_VALUE_POINTER (*arg);
- break;
- }
-}
-
-
-static void
-e_meeting_time_selector_item_realize (GnomeCanvasItem *item)
-{
- GnomeCanvas *canvas;
- GdkWindow *window;
- EMeetingTimeSelectorItem *mts_item;
-
- if (GNOME_CANVAS_ITEM_CLASS (parent_class)->realize)
- (*GNOME_CANVAS_ITEM_CLASS (parent_class)->realize)(item);
-
- mts_item = E_MEETING_TIME_SELECTOR_ITEM (item);
-
- canvas = item->canvas;
- window = GTK_WIDGET (canvas)->window;
-
- mts_item->main_gc = gdk_gc_new (window);
-}
-
-
-static void
-e_meeting_time_selector_item_unrealize (GnomeCanvasItem *item)
-{
- EMeetingTimeSelectorItem *mts_item;
-
- mts_item = E_MEETING_TIME_SELECTOR_ITEM (item);
-
- gdk_gc_unref (mts_item->main_gc);
- mts_item->main_gc = NULL;
-
- if (GNOME_CANVAS_ITEM_CLASS (parent_class)->unrealize)
- (*GNOME_CANVAS_ITEM_CLASS (parent_class)->unrealize)(item);
-}
-
-
-static void
-e_meeting_time_selector_item_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update)
- (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags);
-
- /* The grid covers the entire canvas area. */
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = INT_MAX;
- item->y2 = INT_MAX;
-}
-
-
-/*
- * DRAWING ROUTINES - functions to paint the canvas item.
- */
-
-static void
-e_meeting_time_selector_item_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height)
-{
- EMeetingTimeSelector *mts;
- EMeetingTimeSelectorItem *mts_item;
- EMeetingTimeSelectorAttendee *attendee;
- gint day_x, meeting_start_x, meeting_end_x, bar_y, bar_height;
- gint row, row_y;
- GDate date, last_date, current_date;
- gboolean is_display_top, show_meeting_time;
- GdkGC *gc;
-
- mts_item = E_MEETING_TIME_SELECTOR_ITEM (item);
- mts = mts_item->mts;
- g_return_if_fail (mts != NULL);
- gc = mts_item->main_gc;
-
- is_display_top = (GTK_WIDGET (item->canvas) == mts->display_top)
- ? TRUE : FALSE;
-
- /* Calculate the first and last visible days and positions. */
- e_meeting_time_selector_calculate_day_and_position (mts, x,
- &date, &day_x);
- e_meeting_time_selector_calculate_day_and_position (mts, x + width,
- &last_date, NULL);
-
- /* For the top display draw the 'All Attendees' row background. */
- if (is_display_top) {
- gdk_gc_set_foreground (gc, &mts->all_attendees_bg_color);
- gdk_draw_rectangle (drawable, gc, TRUE,
- 0, mts->row_height * 2 - y,
- width, mts->row_height);
- } else {
- gdk_gc_set_foreground (gc, &mts->bg_color);
- gdk_draw_rectangle (drawable, gc, TRUE, 0, 0, width, height);
- }
-
- /* Calculate the x coordinates of the meeting time. */
- show_meeting_time = e_meeting_time_selector_get_meeting_time_positions (mts, &meeting_start_x, &meeting_end_x);
-
- /* Draw the meeting time background. */
- if (show_meeting_time
- && (meeting_end_x - 1 >= x) && (meeting_start_x + 1 < x + width)
- && (meeting_end_x - meeting_start_x > 2)) {
- gdk_gc_set_foreground (gc, &mts->meeting_time_bg_color);
- if (is_display_top)
- gdk_draw_rectangle (drawable, gc, TRUE,
- meeting_start_x + 1 - x, mts->row_height * 2 - y,
- meeting_end_x - meeting_start_x - 2, height);
- else
- gdk_draw_rectangle (drawable, gc, TRUE,
- meeting_start_x + 1 - x, 0,
- meeting_end_x - meeting_start_x - 2, height);
- }
-
- /* For the main display draw the stipple background for attendee's
- that have no calendar information. */
- if (!is_display_top) {
- gdk_gc_set_foreground (gc, &mts->grid_color);
- gdk_gc_set_background (gc, &mts->stipple_bg_color);
- gdk_gc_set_stipple (gc, mts->stipple);
- gnome_canvas_set_stipple_origin (item->canvas, gc);
- gdk_gc_set_fill (gc, GDK_OPAQUE_STIPPLED);
- row = y / mts->row_height;
- row_y = row * mts->row_height - y;
- while (row < mts->attendees->len && row_y < height) {
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
- if (!attendee->has_calendar_info) {
- gdk_draw_rectangle (drawable, gc, TRUE,
- 0, row_y,
- width, mts->row_height);
- }
- row++;
- row_y += mts->row_height;
- }
- gdk_gc_set_fill (gc, GDK_SOLID);
- }
-
- /* Now paint the visible days one by one. */
- current_date = date;
- for (;;) {
- /* Currently we use the same GnomeCanvasItem class for the
- top display and the main display. We may use separate
- classes in future if necessary. */
- if (is_display_top)
- e_meeting_time_selector_item_paint_day_top (mts_item, drawable, &current_date, day_x, y, width, height);
- else
- e_meeting_time_selector_item_paint_day (mts_item, drawable, &current_date, day_x, y, width, height);
-
- day_x += mts_item->mts->day_width;
- if (g_date_compare (&current_date, &last_date) == 0)
- break;
- g_date_add_days (&current_date, 1);
- }
-
- /* Draw the busy periods. */
- if (is_display_top)
- e_meeting_time_selector_item_paint_all_attendees_busy_periods (mts_item, drawable, &date, x, y, width, height);
- else
- e_meeting_time_selector_item_paint_busy_periods (mts_item, drawable, &date, x, y, width, height);
-
-
- /* Draw the currently-selected meeting time vertical bars. */
- if (show_meeting_time) {
- if (is_display_top) {
- bar_y = mts->row_height * 2 - y;
- bar_height = mts->row_height;
- } else {
- bar_y = 0;
- bar_height = height;
- }
-
- gdk_gc_set_foreground (gc, &mts->grid_color);
-
- if ((meeting_start_x + 2 >= x)
- && (meeting_start_x - 2 < x + width)) {
- gdk_draw_rectangle (drawable, gc, TRUE,
- meeting_start_x - 2 - x, bar_y,
- 5, bar_height);
- }
-
- if ((meeting_end_x + 2 >= x)
- && (meeting_end_x - 2 < x + width)) {
- gdk_draw_rectangle (drawable, gc, TRUE,
- meeting_end_x - 2 - x, bar_y,
- 5, bar_height);
- }
- }
-}
-
-
-static void
-e_meeting_time_selector_item_paint_day_top (EMeetingTimeSelectorItem *mts_item,
- GdkDrawable *drawable, GDate *date,
- int x, int scroll_y,
- int width, int height)
-{
- EMeetingTimeSelector *mts;
- GdkGC *gc;
- GdkFont *font;
- gint y, grid_x;
- gchar buffer[128];
- gint hour, hour_x, hour_y;
- GdkRectangle clip_rect;
-
- mts = mts_item->mts;
- gc = mts_item->main_gc;
-
- gdk_gc_set_foreground (gc, &mts->grid_color);
-
- /* Draw the horizontal lines. */
- y = mts->row_height - 1 - scroll_y;
- gdk_draw_line (drawable, gc, x, y, x + mts->day_width - 1, y);
- gdk_gc_set_foreground (gc, &mts->grid_shadow_color);
- gdk_draw_line (drawable, gc, x, y + 1, x + mts->day_width - 1, y + 1);
- gdk_gc_set_foreground (gc, &mts->grid_color);
- y += mts->row_height;
- gdk_draw_line (drawable, gc, x, y, x + mts->day_width - 1, y);
- y += mts->row_height;
- gdk_draw_line (drawable, gc, x, y, x + mts->day_width - 1, y);
-
-
- /* Draw the vertical grid lines. */
- for (grid_x = mts->col_width - 1;
- grid_x < mts->day_width - mts->col_width;
- grid_x += mts->col_width) {
- gdk_draw_line (drawable, gc,
- x + grid_x, mts->row_height * 2 - 4,
- x + grid_x, height);
- }
- grid_x = mts->day_width - 2;
- gdk_draw_line (drawable, gc, x + grid_x, 0, x + grid_x, height);
- grid_x++;
- gdk_draw_line (drawable, gc, x + grid_x, 0, x + grid_x, height);
-
- /* Draw the date. Set a clipping rectangle so we don't draw over the
- next day. */
- font = GTK_WIDGET (mts)->style->font;
- if (mts->date_format == E_MEETING_TIME_SELECTOR_DATE_FULL)
- g_date_strftime (buffer, 128, "%A, %B %d, %Y", date);
- else if (mts->date_format == E_MEETING_TIME_SELECTOR_DATE_ABBREVIATED_DAY)
- g_date_strftime (buffer, 128, "%a %x", date);
- else
- g_date_strftime (buffer, 128, "%x", date);
- clip_rect.x = x;
- clip_rect.y = -scroll_y;
- clip_rect.width = mts->day_width - 2;
- clip_rect.height = mts->row_height - 2;
- gdk_gc_set_clip_rectangle (gc, &clip_rect);
- gdk_draw_string (drawable, font, gc,
- x + 4, 4 + font->ascent - scroll_y, buffer);
- gdk_gc_set_clip_rectangle (gc, NULL);
-
- /* Draw the hours. */
- hour = mts->first_hour_shown + (mts->zoomed_out ? 3 : 1);
- hour_x = x + mts->col_width;
- hour_y = mts->row_height + 4 + font->ascent - scroll_y;
- while (hour < mts->last_hour_shown) {
- gdk_draw_string (drawable, font, gc,
- hour_x - (mts->hour_widths[hour] / 2),
- hour_y, EMeetingTimeSelectorHours[hour]);
-
- hour += mts->zoomed_out ? 3 : 1;
- hour_x += mts->col_width;
- }
-}
-
-
-/* This paints the colored bars representing busy periods for the combined
- list of attendees. For now we just paint the bars for each attendee of
- each other. If we want to speed it up we could optimise it later. */
-static void
-e_meeting_time_selector_item_paint_all_attendees_busy_periods (EMeetingTimeSelectorItem *mts_item, GdkDrawable *drawable, GDate *date, int x, int scroll_y, int width, int height)
-{
- EMeetingTimeSelector *mts;
- EMeetingTimeSelectorBusyType busy_type;
- gint row, y;
- GdkGC *gc;
- gint *first_periods;
-
- mts = mts_item->mts;
- gc = mts_item->main_gc;
-
- /* Calculate the y coordinate to paint the row at in the drawable. */
- y = 2 * mts->row_height - scroll_y - 1;
-
- /* Get the first visible busy periods for all the attendees. */
- first_periods = g_new (gint, mts->attendees->len);
- for (row = 0; row < mts->attendees->len; row++) {
- first_periods[row] = e_meeting_time_selector_item_find_first_busy_period (mts_item, date, row);
- }
-
- for (busy_type = 0;
- busy_type < E_MEETING_TIME_SELECTOR_BUSY_LAST;
- busy_type++) {
- gdk_gc_set_foreground (gc, &mts->busy_colors[busy_type]);
- for (row = 0; row < mts->attendees->len; row++) {
- if (first_periods[row] == -1)
- continue;
- e_meeting_time_selector_item_paint_attendee_busy_periods (mts_item, drawable, x, y, width, row, first_periods[row], busy_type);
- }
- }
-
- g_free (first_periods);
-}
-
-
-static void
-e_meeting_time_selector_item_paint_day (EMeetingTimeSelectorItem *mts_item,
- GdkDrawable *drawable, GDate *date,
- int x, int scroll_y,
- int width, int height)
-{
- EMeetingTimeSelector *mts;
- GdkGC *gc;
- gint grid_x, grid_y, attendee_index, unused_y;
-
- mts = mts_item->mts;
- gc = mts_item->main_gc;
-
- /* Draw the grid lines. The grid lines around unused rows are drawn in
- a different color. */
-
- /* Draw the horizontal grid lines. */
- attendee_index = scroll_y / mts->row_height;
-#if E_MEETING_TIME_SELECTOR_DRAW_GRID_LINES_AT_BOTTOM
- for (grid_y = mts->row_height - 1 - (scroll_y % mts->row_height);
-#else
- for (grid_y = - (scroll_y % mts->row_height);
-#endif
- grid_y < height;
- grid_y += mts->row_height)
- {
- if (attendee_index < mts->attendees->len) {
- gdk_gc_set_foreground (gc, &mts->grid_color);
- gdk_draw_line (drawable, gc, 0, grid_y,
- width, grid_y);
- } else {
- gdk_gc_set_foreground (gc, &mts->grid_unused_color);
- gdk_draw_line (drawable, gc, 0, grid_y,
- width, grid_y);
- }
- attendee_index++;
- }
-
- /* Draw the vertical grid lines. */
- unused_y = (mts->attendees->len * mts->row_height) - scroll_y;
- if (unused_y >= 0) {
- gdk_gc_set_foreground (gc, &mts->grid_color);
- for (grid_x = mts->col_width - 1;
- grid_x < mts->day_width - mts->col_width;
- grid_x += mts->col_width)
- {
- gdk_draw_line (drawable, gc,
- x + grid_x, 0,
- x + grid_x, unused_y - 1);
- }
- gdk_draw_rectangle (drawable, gc, TRUE,
- x + mts->day_width - 2, 0,
- 2, unused_y);
- }
-
- if (unused_y < height) {
- gdk_gc_set_foreground (gc, &mts->grid_unused_color);
- for (grid_x = mts->col_width - 1;
- grid_x < mts->day_width - mts->col_width;
- grid_x += mts->col_width)
- {
- gdk_draw_line (drawable, gc,
- x + grid_x, unused_y,
- x + grid_x, height);
- }
- gdk_draw_rectangle (drawable, gc, TRUE,
- x + mts->day_width - 2, unused_y,
- 2, height - unused_y);
- }
-
-
-}
-
-
-/* This paints the colored bars representing busy periods for the individual
- attendees. */
-static void
-e_meeting_time_selector_item_paint_busy_periods (EMeetingTimeSelectorItem *mts_item, GdkDrawable *drawable, GDate *date, int x, int scroll_y, int width, int height)
-{
- EMeetingTimeSelector *mts;
- EMeetingTimeSelectorBusyType busy_type;
- gint row, y, first_period;
- GdkGC *gc;
-
- mts = mts_item->mts;
- gc = mts_item->main_gc;
-
- /* Calculate the first visible attendee row. */
- row = scroll_y / mts->row_height;
-
- /* Calculate the y coordinate to paint the row at in the drawable. */
- y = row * mts->row_height - scroll_y;
-
- /* Step through the attendees painting the busy periods. */
- while (y < height && row < mts->attendees->len) {
-
- /* Find the first visible busy period. */
- first_period = e_meeting_time_selector_item_find_first_busy_period (mts_item, date, row);
- if (first_period != -1) {
- /* Paint the different types of busy periods, in
- reverse order of precedence, so the highest
- precedences are displayed. */
- for (busy_type = 0;
- busy_type < E_MEETING_TIME_SELECTOR_BUSY_LAST;
- busy_type++) {
- gdk_gc_set_foreground (gc, &mts->busy_colors[busy_type]);
- e_meeting_time_selector_item_paint_attendee_busy_periods (mts_item, drawable, x, y, width, row, first_period, busy_type);
- }
- }
- y += mts->row_height;
- row++;
- }
-}
-
-
-/* This subtracts the attendees longest_period_in_days from the given date,
- and does a binary search of the attendee's busy periods array to find the
- first one which could possible end on the given day or later.
- If none are found it returns -1. */
-static gint
-e_meeting_time_selector_item_find_first_busy_period (EMeetingTimeSelectorItem *mts_item, GDate *date, gint row)
-{
- EMeetingTimeSelector *mts;
- EMeetingTimeSelectorAttendee *attendee;
- EMeetingTimeSelectorPeriod *period;
- gint period_num;
-
- mts = mts_item->mts;
-
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
-
- period_num = e_meeting_time_selector_find_first_busy_period (mts, attendee, date);
- if (period_num == -1)
- return -1;
-
- /* Check if the period starts after the end of the current canvas
- scroll area. */
- period = &g_array_index (attendee->busy_periods,
- EMeetingTimeSelectorPeriod, period_num);
- if (g_date_compare (&mts->last_date_shown, &period->start.date) < 0)
- return -1;
-
- return period_num;
-}
-
-
-/* This paints the visible busy periods for one attendee which are of a certain
- busy type, e.g out of office. It is passed the index of the first visible
- busy period of the attendee and continues until it runs off the screen. */
-static void
-e_meeting_time_selector_item_paint_attendee_busy_periods (EMeetingTimeSelectorItem *mts_item, GdkDrawable *drawable, int x, int y, int width, int row, int first_period, EMeetingTimeSelectorBusyType busy_type)
-{
- EMeetingTimeSelector *mts;
- EMeetingTimeSelectorAttendee *attendee;
- EMeetingTimeSelectorPeriod *period;
- GdkGC *gc;
- gint period_num, x1, x2, x2_within_day, x2_within_col;
-
- mts = mts_item->mts;
- gc = mts_item->main_gc;
-
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
-
- for (period_num = first_period;
- period_num < attendee->busy_periods->len;
- period_num++) {
- period = &g_array_index (attendee->busy_periods,
- EMeetingTimeSelectorPeriod, period_num);
-
- if (period->busy_type != busy_type)
- continue;
-
- /* Convert the period start and end times to x coordinates. */
- x1 = e_meeting_time_selector_calculate_time_position (mts, &period->start);
- /* If the period is off the right of the area being drawn, we
- are finished. */
- if (x1 >= x + width)
- return;
-
- x2 = e_meeting_time_selector_calculate_time_position (mts, &period->end);
- /* If the period is off the left edge of the area skip it. */
- if (x2 <= x)
- continue;
-
- /* We paint from x1 to x2 - 1, so that for example a time
- from 5:00-6:00 is distinct from 6:00-7:00.
- We never finish on a grid line separating days, and we only
- ever paint on a normal vertical grid line if the period is
- only 1 pixel wide. */
- x2_within_day = x2 % mts->day_width;
- if (x2_within_day == 0) {
- x2 -= 2;
- } else if (x2_within_day == mts->day_width - 1) {
- x2 -= 1;
- } else {
- x2_within_col = x2_within_day % mts->col_width;
- if (x2_within_col == 0 && x2 > x1 + 1)
- x2 -= 1;
- }
-
- /* Paint the rectangle. We leave a gap of 2 pixels at the
- top and bottom, remembering that the grid is painted along
- the top/bottom line of each row. */
- if (x2 - x1 > 0) {
-#if E_MEETING_TIME_SELECTOR_DRAW_GRID_LINES_AT_BOTTOM
- gdk_draw_rectangle (drawable, gc, TRUE,
- x1 - x, y + 2,
- x2 - x1, mts->row_height - 5);
-#else
- gdk_draw_rectangle (drawable, gc, TRUE,
- x1 - x, y + 3,
- x2 - x1, mts->row_height - 5);
-#endif
- }
- }
-}
-
-
-/*
- * CANVAS ITEM ROUTINES - functions to be a GnomeCanvasItem.
- */
-
-/* This is supposed to return the nearest item the the point and the distance.
- Since we are the only item we just return ourself and 0 for the distance.
- This is needed so that we get button/motion events. */
-static double
-e_meeting_time_selector_item_point (GnomeCanvasItem *item, double x, double y,
- int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- *actual_item = item;
- return 0.0;
-}
-
-
-static gint
-e_meeting_time_selector_item_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EMeetingTimeSelectorItem *mts_item;
-
- mts_item = E_MEETING_TIME_SELECTOR_ITEM (item);
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- return e_meeting_time_selector_item_button_press (mts_item,
- event);
- case GDK_BUTTON_RELEASE:
- return e_meeting_time_selector_item_button_release (mts_item,
- event);
- case GDK_MOTION_NOTIFY:
- return e_meeting_time_selector_item_motion_notify (mts_item,
- event);
- default:
- break;
- }
-
- return FALSE;
-}
-
-
-/* This handles all button press events for the item. If the cursor is over
- one of the meeting time vertical bars we start a drag. If not we set the
- meeting time to the nearest half-hour interval.
- Note that GnomeCanvas converts the event coords to world coords,
- i.e. relative to the entire canvas scroll area. */
-static gint
-e_meeting_time_selector_item_button_press (EMeetingTimeSelectorItem *mts_item,
- GdkEvent *event)
-{
- EMeetingTimeSelector *mts;
- EMeetingTimeSelectorTime start_time, end_time;
- EMeetingTimeSelectorPosition position;
- GDate *start_date, *end_date;
- gint x, y;
-
- mts = mts_item->mts;
- x = (gint) event->button.x;
- y = (gint) event->button.y;
-
- /* Check if we are starting a drag of the vertical meeting time bars.*/
- position = e_meeting_time_selector_item_get_drag_position (mts_item,
- x, y);
- if (position != E_MEETING_TIME_SELECTOR_POS_NONE) {
- if (gnome_canvas_item_grab (GNOME_CANVAS_ITEM (mts_item),
- GDK_POINTER_MOTION_MASK
- | GDK_BUTTON_RELEASE_MASK,
- mts_item->resize_cursor,
- event->button.time) == 0 /*Success*/) {
- mts->dragging_position = position;
- return TRUE;
- }
- }
-
- /* Convert the x coordinate into a EMeetingTimeSelectorTime. */
- e_meeting_time_selector_calculate_time (mts, x, &start_time);
- start_date = &start_time.date;
- end_date = &end_time.date;
-
- /* Find the nearest half-hour or hour interval, depending on whether
- zoomed_out is set. */
- if (mts->zoomed_out) {
- start_time.minute = 0;
- end_time = start_time;
- end_time.hour += 1;
- } else {
- start_time.minute -= start_time.minute % 30;
- end_time = start_time;
- end_time.minute += 30;
- }
-
- /* Fix any overflows. */
- e_meeting_time_selector_fix_time_overflows (&end_time);
-
- /* Set the new meeting time. */
- e_meeting_time_selector_set_meeting_time (mts_item->mts,
- g_date_year (start_date),
- g_date_month (start_date),
- g_date_day (start_date),
- start_time.hour,
- start_time.minute,
- g_date_year (end_date),
- g_date_month (end_date),
- g_date_day (end_date),
- end_time.hour,
- end_time.minute);
-
-
- return FALSE;
-}
-
-
-/* This handles all button release events for the item. If we were dragging,
- we finish the drag. */
-static gint
-e_meeting_time_selector_item_button_release (EMeetingTimeSelectorItem *mts_item,
- GdkEvent *event)
-{
- EMeetingTimeSelector *mts;
-
- mts = mts_item->mts;
-
- /* Reset any drag. */
- if (mts->dragging_position != E_MEETING_TIME_SELECTOR_POS_NONE) {
- mts->dragging_position = E_MEETING_TIME_SELECTOR_POS_NONE;
- e_meeting_time_selector_remove_timeout (mts);
- gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM (mts_item),
- event->button.time);
- }
-
- return FALSE;
-}
-
-
-/* This handles all motion notify events for the item. If button1 is pressed
- we check if a drag is in progress. If not, we set the cursor if we are over
- the meeting time vertical bars. Note that GnomeCanvas doesn't use motion
- hints, which may affect performance. */
-static gint
-e_meeting_time_selector_item_motion_notify (EMeetingTimeSelectorItem *mts_item,
- GdkEvent *event)
-{
- EMeetingTimeSelector *mts;
- EMeetingTimeSelectorPosition position;
- GdkCursor *cursor;
- gint x, y;
-
- mts = mts_item->mts;
- x = (gint) event->motion.x;
- y = (gint) event->motion.y;
-
- if (mts->dragging_position != E_MEETING_TIME_SELECTOR_POS_NONE) {
- e_meeting_time_selector_drag_meeting_time (mts, x);
- return TRUE;
- }
-
- position = e_meeting_time_selector_item_get_drag_position (mts_item,
- x, y);
-
- /* Determine which cursor should be used. */
- if (position == E_MEETING_TIME_SELECTOR_POS_NONE)
- cursor = mts_item->normal_cursor;
- else
- cursor = mts_item->resize_cursor;
-
- /* Only set the cursor if it is different to the last one we set. */
- if (mts_item->last_cursor_set != cursor) {
- mts_item->last_cursor_set = cursor;
- gdk_window_set_cursor (GTK_WIDGET (GNOME_CANVAS_ITEM (mts_item)->canvas)->window, cursor);
- }
-
- return FALSE;
-}
-
-
-static EMeetingTimeSelectorPosition
-e_meeting_time_selector_item_get_drag_position (EMeetingTimeSelectorItem *mts_item,
- gint x, gint y)
-{
- EMeetingTimeSelector *mts;
- gboolean is_display_top;
- gint meeting_start_x, meeting_end_x;
-
- mts = mts_item->mts;
-
- is_display_top = (GTK_WIDGET (GNOME_CANVAS_ITEM (mts_item)->canvas) == mts->display_top) ? TRUE : FALSE;
-
- if (is_display_top && y < mts->row_height * 2)
- return E_MEETING_TIME_SELECTOR_POS_NONE;
-
- if (!e_meeting_time_selector_get_meeting_time_positions (mts, &meeting_start_x, &meeting_end_x))
- return E_MEETING_TIME_SELECTOR_POS_NONE;
-
- if (x >= meeting_end_x - 2 && x <= meeting_end_x + 2)
- return E_MEETING_TIME_SELECTOR_POS_END;
-
- if (x >= meeting_start_x - 2 && x <= meeting_start_x + 2)
- return E_MEETING_TIME_SELECTOR_POS_START;
-
- return E_MEETING_TIME_SELECTOR_POS_NONE;
-}
-
diff --git a/widgets/meeting-time-sel/e-meeting-time-sel-item.h b/widgets/meeting-time-sel/e-meeting-time-sel-item.h
deleted file mode 100644
index c2bd2872ce..0000000000
--- a/widgets/meeting-time-sel/e-meeting-time-sel-item.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * MeetingTimeSelectorItem - A GnomeCanvasItem which is used for both the main
- * display canvas and the top display (with the dates, times & All Attendees).
- * I didn't make these separate GnomeCanvasItems since they share a lot of
- * code.
- */
-
-#ifndef _E_MEETING_TIME_SELECTOR_ITEM_H_
-#define _E_MEETING_TIME_SELECTOR_ITEM_H_
-
-#include "e-meeting-time-sel.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-#define E_MEETING_TIME_SELECTOR_ITEM(obj) (GTK_CHECK_CAST((obj), e_meeting_time_selector_item_get_type (), EMeetingTimeSelectorItem))
-#define E_MEETING_TIME_SELECTOR_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), e_meeting_time_selector_item_get_type (), EMeetingTimeSelectorItemClass))
-#define IS_E_MEETING_TIME_SELECTOR_ITEM(o) (GTK_CHECK_TYPE((o), e_meeting_time_selector_item_get_type ()))
-
-
-typedef struct _EMeetingTimeSelectorItem EMeetingTimeSelectorItem;
-typedef struct _EMeetingTimeSelectorItemClass EMeetingTimeSelectorItemClass;
-
-struct _EMeetingTimeSelectorItem
-{
- GnomeCanvasItem canvas_item;
-
- /* The parent EMeetingTimeSelector widget. */
- EMeetingTimeSelector *mts;
-
- /* This GC is used for most of the drawing. The fg/bg colors are
- changed for each bit. */
- GdkGC *main_gc;
-
- /* The normal & resize cursors. */
- GdkCursor *normal_cursor;
- GdkCursor *resize_cursor;
-
- /* This remembers the last cursor set on the window. */
- GdkCursor *last_cursor_set;
-};
-
-
-struct _EMeetingTimeSelectorItemClass
-{
- GnomeCanvasItemClass parent_class;
-};
-
-GtkType e_meeting_time_selector_item_get_type (void);
-
-
-#endif /* _E_MEETING_TIME_SELECTOR_ITEM_H_ */
diff --git a/widgets/meeting-time-sel/e-meeting-time-sel-list-item.c b/widgets/meeting-time-sel/e-meeting-time-sel-list-item.c
deleted file mode 100644
index ac4b7b9009..0000000000
--- a/widgets/meeting-time-sel/e-meeting-time-sel-list-item.c
+++ /dev/null
@@ -1,303 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * EMeetingTimeSelectorListItem - A GnomeCanvasItem covering the entire attendee
- * list. It just draws the grid lines between the rows and after the icon
- * column. It probably won't be needed when we switch to Miguel's new editable
- * GtkList-like widget.
- */
-
-#include <config.h>
-#include <time.h>
-#include "e-meeting-time-sel-list-item.h"
-#include "e-meeting-time-sel.h"
-
-/* This is the size of our icons. */
-#define E_MEETING_TIME_SELECTOR_ICON_WIDTH 19
-#define E_MEETING_TIME_SELECTOR_ICON_HEIGHT 16
-
-#include "e-meeting-time-sel-mail.xpm"
-#include "e-meeting-time-sel-no-mail.xpm"
-
-static void e_meeting_time_selector_list_item_class_init (EMeetingTimeSelectorListItemClass *mtsl_item_class);
-static void e_meeting_time_selector_list_item_init (EMeetingTimeSelectorListItem *mtsl_item);
-static void e_meeting_time_selector_list_item_destroy (GtkObject *object);
-
-static void e_meeting_time_selector_list_item_set_arg (GtkObject *o, GtkArg *arg,
- guint arg_id);
-static void e_meeting_time_selector_list_item_realize (GnomeCanvasItem *item);
-static void e_meeting_time_selector_list_item_unrealize (GnomeCanvasItem *item);
-static void e_meeting_time_selector_list_item_update (GnomeCanvasItem *item,
- double *affine,
- ArtSVP *clip_path, int flags);
-static void e_meeting_time_selector_list_item_draw (GnomeCanvasItem *item,
- GdkDrawable *drawable,
- int x, int y,
- int width, int height);
-static double e_meeting_time_selector_list_item_point (GnomeCanvasItem *item,
- double x, double y,
- int cx, int cy,
- GnomeCanvasItem **actual_item);
-
-
-static GnomeCanvasItemClass *e_meeting_time_selector_list_item_parent_class;
-
-/* The arguments we take */
-enum {
- ARG_0,
- ARG_MEETING_TIME_SELECTOR
-};
-
-
-GtkType
-e_meeting_time_selector_list_item_get_type (void)
-{
- static GtkType e_meeting_time_selector_list_item_type = 0;
-
- if (!e_meeting_time_selector_list_item_type) {
- GtkTypeInfo e_meeting_time_selector_list_item_info = {
- "EMeetingTimeSelectorListItem",
- sizeof (EMeetingTimeSelectorListItem),
- sizeof (EMeetingTimeSelectorListItemClass),
- (GtkClassInitFunc) e_meeting_time_selector_list_item_class_init,
- (GtkObjectInitFunc) e_meeting_time_selector_list_item_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- e_meeting_time_selector_list_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_meeting_time_selector_list_item_info);
- }
-
- return e_meeting_time_selector_list_item_type;
-}
-
-
-static void
-e_meeting_time_selector_list_item_class_init (EMeetingTimeSelectorListItemClass *mtsl_item_class)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- e_meeting_time_selector_list_item_parent_class = gtk_type_class (gnome_canvas_item_get_type());
-
- object_class = (GtkObjectClass *) mtsl_item_class;
- item_class = (GnomeCanvasItemClass *) mtsl_item_class;
-
- gtk_object_add_arg_type ("EMeetingTimeSelectorListItem::meeting_time_selector",
- GTK_TYPE_POINTER, GTK_ARG_WRITABLE,
- ARG_MEETING_TIME_SELECTOR);
-
- object_class->destroy = e_meeting_time_selector_list_item_destroy;
- object_class->set_arg = e_meeting_time_selector_list_item_set_arg;
-
- /* GnomeCanvasItem method overrides */
- item_class->realize = e_meeting_time_selector_list_item_realize;
- item_class->unrealize = e_meeting_time_selector_list_item_unrealize;
- item_class->update = e_meeting_time_selector_list_item_update;
- item_class->draw = e_meeting_time_selector_list_item_draw;
- item_class->point = e_meeting_time_selector_list_item_point;
-#if 0
- item_class->event = e_meeting_time_selector_list_item_event;
-#endif
-}
-
-
-static void
-e_meeting_time_selector_list_item_init (EMeetingTimeSelectorListItem *mtsl_item)
-{
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (mtsl_item);
- GdkColormap *colormap;
-
- mtsl_item->mts = NULL;
-
- colormap = gtk_widget_get_default_colormap ();
- mtsl_item->mail_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mtsl_item->mail_icon_mask, NULL, e_meeting_time_sel_mail_xpm);
- mtsl_item->no_mail_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mtsl_item->no_mail_icon_mask, NULL, e_meeting_time_sel_no_mail_xpm);
-
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = 0;
- item->y2 = 0;
-}
-
-
-static void
-e_meeting_time_selector_list_item_destroy (GtkObject *object)
-{
- EMeetingTimeSelectorListItem *mtsl_item;
-
- mtsl_item = E_MEETING_TIME_SELECTOR_LIST_ITEM (object);
-
- gdk_pixmap_unref (mtsl_item->mail_icon);
- gdk_pixmap_unref (mtsl_item->no_mail_icon);
- gdk_bitmap_unref (mtsl_item->mail_icon_mask);
- gdk_bitmap_unref (mtsl_item->mail_icon_mask);
-
- if (GTK_OBJECT_CLASS (e_meeting_time_selector_list_item_parent_class)->destroy)
- (*GTK_OBJECT_CLASS (e_meeting_time_selector_list_item_parent_class)->destroy)(object);
-}
-
-
-static void
-e_meeting_time_selector_list_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EMeetingTimeSelectorListItem *mtsl_item;
-
- item = GNOME_CANVAS_ITEM (o);
- mtsl_item = E_MEETING_TIME_SELECTOR_LIST_ITEM (o);
-
- switch (arg_id){
- case ARG_MEETING_TIME_SELECTOR:
- mtsl_item->mts = GTK_VALUE_POINTER (*arg);
- break;
- }
-}
-
-
-static void
-e_meeting_time_selector_list_item_realize (GnomeCanvasItem *item)
-{
- GnomeCanvas *canvas;
- GdkWindow *window;
- EMeetingTimeSelectorListItem *mtsl_item;
-
- if (GNOME_CANVAS_ITEM_CLASS (e_meeting_time_selector_list_item_parent_class)->realize)
- (*GNOME_CANVAS_ITEM_CLASS (e_meeting_time_selector_list_item_parent_class)->realize)(item);
-
- mtsl_item = E_MEETING_TIME_SELECTOR_LIST_ITEM (item);
-
- canvas = item->canvas;
- window = GTK_WIDGET (canvas)->window;
-
- mtsl_item->main_gc = gdk_gc_new (window);
-}
-
-
-static void
-e_meeting_time_selector_list_item_unrealize (GnomeCanvasItem *item)
-{
- EMeetingTimeSelectorListItem *mtsl_item;
-
- mtsl_item = E_MEETING_TIME_SELECTOR_LIST_ITEM (item);
-
- gdk_gc_unref (mtsl_item->main_gc);
- mtsl_item->main_gc = NULL;
-
- if (GNOME_CANVAS_ITEM_CLASS (e_meeting_time_selector_list_item_parent_class)->unrealize)
- (*GNOME_CANVAS_ITEM_CLASS (e_meeting_time_selector_list_item_parent_class)->unrealize)(item);
-}
-
-
-static void
-e_meeting_time_selector_list_item_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- if (GNOME_CANVAS_ITEM_CLASS (e_meeting_time_selector_list_item_parent_class)->update)
- (* GNOME_CANVAS_ITEM_CLASS (e_meeting_time_selector_list_item_parent_class)->update) (item, affine, clip_path, flags);
-
- /* The item covers the entire canvas area. */
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = INT_MAX;
- item->y2 = INT_MAX;
-}
-
-
-/*
- * DRAWING ROUTINES - functions to paint the canvas item.
- */
-
-static void
-e_meeting_time_selector_list_item_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height)
-{
- EMeetingTimeSelectorListItem *mtsl_item;
- EMeetingTimeSelector *mts;
- EMeetingTimeSelectorAttendee *attendee;
- GdkGC *gc;
- gint row, row_y, icon_x, icon_y;
- GdkPixmap *pixmap;
- GdkBitmap *mask;
-
- mtsl_item = E_MEETING_TIME_SELECTOR_LIST_ITEM (item);
- mts = mtsl_item->mts;
- gc = mtsl_item->main_gc;
-
- gdk_gc_set_foreground (gc, &mts->attendee_list_bg_color);
- gdk_draw_rectangle (drawable, gc, TRUE, 0, 0, width, height);
-
- gdk_gc_set_foreground (gc, &mts->grid_unused_color);
- gdk_draw_line (drawable, gc, 24 - x, 0, 24 - x, height);
-
- /* Draw the grid line across the top of the row. */
- row = y / mts->row_height;
- row_y = row * mts->row_height - y;
- while (row_y < height) {
- gdk_draw_line (drawable, gc, 0, row_y, width, row_y);
- row_y += mts->row_height;
- }
-
- row = y / mts->row_height;
- row_y = row * mts->row_height - y;
- icon_x = (E_MEETING_TIME_SELECTOR_ICON_COLUMN_WIDTH - E_MEETING_TIME_SELECTOR_ICON_WIDTH + 1) / 2 - x;
- icon_y = row_y + (mts->row_height - E_MEETING_TIME_SELECTOR_ICON_HEIGHT + 1) / 2;
- while (row < mts->attendees->len && row_y < height) {
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
-
- gdk_gc_set_clip_origin (gc, icon_x, icon_y);
-
- if (attendee->send_meeting_to) {
- pixmap = mtsl_item->mail_icon;
- mask = mtsl_item->mail_icon_mask;
- } else {
- pixmap = mtsl_item->no_mail_icon;
- mask = mtsl_item->no_mail_icon_mask;
- }
-
- gdk_gc_set_clip_mask (gc, mask);
- gdk_draw_pixmap (drawable, gc, pixmap, 0, 0,
- icon_x, icon_y, 24, 24);
-
- row++;
- row_y += mts->row_height;
- icon_y += mts->row_height;
- }
- gdk_gc_set_clip_mask (gc, NULL);
-}
-
-
-/* This is supposed to return the nearest item the the point and the distance.
- Since we cover the entire canvas we just return ourself and 0 for the
- distance. This is needed so that we get button/motion events. */
-static double
-e_meeting_time_selector_list_item_point (GnomeCanvasItem *item,
- double x, double y,
- int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- *actual_item = item;
- return 0.0;
-}
diff --git a/widgets/meeting-time-sel/e-meeting-time-sel-list-item.h b/widgets/meeting-time-sel/e-meeting-time-sel-list-item.h
deleted file mode 100644
index 9ef295ebb2..0000000000
--- a/widgets/meeting-time-sel/e-meeting-time-sel-list-item.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * MeetingTimeSelectorListItem - A GnomeCanvasItem covering the entire attendee
- * list. It just draws the grid lines between the rows and after the icon
- * column. It probably won't be needed when we switch to Miguel's new editable
- * GtkList-like widget.
- */
-
-#ifndef _E_MEETING_TIME_SELECTOR_LIST_ITEM_H_
-#define _E_MEETING_TIME_SELECTOR_LIST_ITEM_H_
-
-#include "e-meeting-time-sel.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-#define E_MEETING_TIME_SELECTOR_LIST_ITEM(obj) (GTK_CHECK_CAST((obj), e_meeting_time_selector_list_item_get_type (), EMeetingTimeSelectorListItem))
-#define E_MEETING_TIME_SELECTOR_LIST_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), e_meeting_time_selector_list_item_get_type (), EMeetingTimeSelectorListItemClass))
-#define IS_E_MEETING_TIME_SELECTOR_LIST_ITEM(o) (GTK_CHECK_TYPE((o), e_meeting_time_selector_list_item_get_type ()))
-
-
-typedef struct _EMeetingTimeSelectorListItem EMeetingTimeSelectorListItem;
-typedef struct _EMeetingTimeSelectorListItemClass EMeetingTimeSelectorListItemClass;
-
-struct _EMeetingTimeSelectorListItem
-{
- GnomeCanvasItem canvas_item;
-
- /* The parent EMeetingTimeSelector widget. */
- EMeetingTimeSelector *mts;
-
- /* This GC is used for most of the drawing. The fg/bg colors are
- changed for each bit. */
- GdkGC *main_gc;
-
- GdkPixmap *mail_icon, *no_mail_icon;
- GdkBitmap *mail_icon_mask, *no_mail_icon_mask;
-};
-
-
-struct _EMeetingTimeSelectorListItemClass
-{
- GnomeCanvasItemClass parent_class;
-};
-
-GtkType e_meeting_time_selector_list_item_get_type (void);
-
-
-#endif /* _E_MEETING_TIME_SELECTOR_LIST_ITEM_H_ */
diff --git a/widgets/meeting-time-sel/e-meeting-time-sel-mail.xpm b/widgets/meeting-time-sel/e-meeting-time-sel-mail.xpm
deleted file mode 100644
index 5a03c7ea8a..0000000000
--- a/widgets/meeting-time-sel/e-meeting-time-sel-mail.xpm
+++ /dev/null
@@ -1,135 +0,0 @@
-/* XPM */
-static char * e_meeting_time_sel_mail_xpm[] = {
-"19 16 116 2",
-" c None",
-". c #000000",
-"+ c #7B7B78",
-"@ c #C7C7C3",
-"# c #F1F0EB",
-"$ c #BFBFBC",
-"% c #5F5E5E",
-"& c #E3E3DF",
-"* c #F3F3EF",
-"= c #F2F2EE",
-"- c #F1F1EC",
-"; c #F0EFEB",
-"> c #D2D2CD",
-", c #969592",
-"' c #616060",
-") c #B5B5B4",
-"! c #F8F8F6",
-"~ c #F7F7F5",
-"{ c #F6F6F3",
-"] c #F5F5F2",
-"^ c #F4F4F0",
-"/ c #F2F1ED",
-"( c #F1F0EC",
-"_ c #F0EFEA",
-": c #EFEEE9",
-"< c #4F4F4D",
-"[ c #BDBCB8",
-"} c #A7A6A3",
-"| c #C6C6C4",
-"1 c #7C7C7B",
-"2 c #525251",
-"3 c #DBDBD9",
-"4 c #F5F4F1",
-"5 c #F4F3F0",
-"6 c #F3F2EE",
-"7 c #999894",
-"8 c #62625F",
-"9 c #BCBCB6",
-"0 c #EBE9E3",
-"a c #838381",
-"b c #D7D6D4",
-"c c #A8A8A6",
-"d c #515150",
-"e c #7E7D7C",
-"f c #DAD9D5",
-"g c #EFEEE8",
-"h c #EEEDE7",
-"i c #4F4E4C",
-"j c #BCBBB6",
-"k c #EBE9E2",
-"l c #EAE8E1",
-"m c #F6F5F2",
-"n c #F4F3EF",
-"o c #B5B4B1",
-"p c #9B9A97",
-"q c #646361",
-"r c #92918E",
-"s c #EEEDE8",
-"t c #EDECE6",
-"u c #4E4E4C",
-"v c #797976",
-"w c #797874",
-"x c #E9E8E1",
-"y c #E8E7DF",
-"z c #B4B3AF",
-"A c #D0D0CD",
-"B c #F2F2ED",
-"C c #BFBEBA",
-"D c #BEBDB9",
-"E c #7A7A77",
-"F c #979691",
-"G c #EAE9E2",
-"H c #959590",
-"I c #787773",
-"J c #B8B7B0",
-"K c #E6E4DC",
-"L c #A9A9A6",
-"M c #626260",
-"N c #ECEBE4",
-"O c #EBEAE3",
-"P c #E9E7E0",
-"Q c #E8E6DF",
-"R c #E7E5DD",
-"S c #777671",
-"T c #93918C",
-"U c #BEBDB8",
-"V c #989793",
-"W c #ECEAE4",
-"X c #E8E6DE",
-"Y c #E6E4DB",
-"Z c #E4E3DA",
-"` c #75746F",
-" . c #91908A",
-".. c #EEECE7",
-"+. c #62615F",
-"@. c #EBEAE4",
-"#. c #E7E6DE",
-"$. c #E6E5DC",
-"%. c #E5E4DB",
-"&. c #E4E2DA",
-"*. c #CCCBC4",
-"=. c #A3A29D",
-"-. c #B6B5B2",
-";. c #BCBCB7",
-">. c #CDCCC6",
-",. c #959490",
-"'. c #ECEBE5",
-"). c #61615E",
-"!. c #E9E8E0",
-"~. c #CECDC7",
-"{. c #797875",
-"]. c #969590",
-"^. c #CFCEC8",
-"/. c #AEADA8",
-"(. c #585754",
-"_. c #7B7A76",
-" . . . . ",
-" . . . . . + @ # $ . ",
-" . . . . . % $ & * = - ; > , . ",
-". ' ) ! ~ { ] ^ * / ( _ : < [ } . ",
-". | 1 2 3 4 5 6 / # _ : 7 8 9 0 . ",
-". a b c d e f / # _ g h i j k l . ",
-" . m 4 n o p q r s t u v w x y z . ",
-" . A * B ( ; C D E u F G H I J K . ",
-" . L / ( _ : M t N O l P Q R S T . ",
-" . # _ g U V W 0 l P X R Y Z ` .. ",
-" . ; g ..+.@.G x y #.$.%.&.*.=.. . ",
-" . -.t ;.F G x y #.K >.,.. . . ",
-" . '.).G !.Q ~.H . . . ",
-" . {.].^./.. . . ",
-" . (._.. . ",
-" . . "};
diff --git a/widgets/meeting-time-sel/e-meeting-time-sel-no-mail.xpm b/widgets/meeting-time-sel/e-meeting-time-sel-no-mail.xpm
deleted file mode 100644
index 747202b3e2..0000000000
--- a/widgets/meeting-time-sel/e-meeting-time-sel-no-mail.xpm
+++ /dev/null
@@ -1,123 +0,0 @@
-/* XPM */
-static char * e_meeting_time_sel_no_mail_xpm[] = {
-"19 16 104 2",
-" c None",
-". c #000000",
-"+ c #7B7B78",
-"@ c #C7C7C3",
-"# c #F1F0EB",
-"$ c #BFBFBC",
-"% c #5F5E5E",
-"& c #E3E3DF",
-"* c #F3F3EF",
-"= c #F2F2EE",
-"- c #F1F1EC",
-"; c #F0EFEB",
-"> c #D2D2CD",
-", c #969592",
-"' c #616060",
-") c #B5B5B4",
-"! c #F8F8F6",
-"~ c #F7F7F5",
-"{ c #F6F6F3",
-"] c #F5F5F2",
-"^ c #F4F4F0",
-"/ c #F2F1ED",
-"( c #F1F0EC",
-"_ c #F0EFEA",
-": c #EFEEE9",
-"< c #4F4F4D",
-"[ c #BDBCB8",
-"} c #A7A6A3",
-"| c #C6C6C4",
-"1 c #7C7C7B",
-"2 c #525251",
-"3 c #DBDBD9",
-"4 c #F5F4F1",
-"5 c #F4F3F0",
-"6 c #F3F2EE",
-"7 c #999894",
-"8 c #62625F",
-"9 c #BCBCB6",
-"0 c #EBE9E3",
-"a c #838381",
-"b c #D7D6D4",
-"c c #A8A8A6",
-"d c #515150",
-"e c #7E7D7C",
-"f c #DAD9D5",
-"g c #D16069",
-"h c #EEEDE7",
-"i c #4F4E4C",
-"j c #BCBBB6",
-"k c #F6F5F2",
-"l c #F4F3EF",
-"m c #B5B4B1",
-"n c #9B9A97",
-"o c #646361",
-"p c #92918E",
-"q c #9F3C44",
-"r c #797976",
-"s c #B5444E",
-"t c #B4B3AF",
-"u c #D0D0CD",
-"v c #F2F2ED",
-"w c #BFBEBA",
-"x c #BEBDB9",
-"y c #BB565F",
-"z c #812F36",
-"A c #E6E4DC",
-"B c #A9A9A6",
-"C c #626260",
-"D c #EDECE6",
-"E c #ECEBE4",
-"F c #BB555D",
-"G c #90353D",
-"H c #777671",
-"I c #93918C",
-"J c #EFEEE8",
-"K c #BEBDB8",
-"L c #989793",
-"M c #ECEAE4",
-"N c #E6E4DB",
-"O c #E4E3DA",
-"P c #75746F",
-"Q c #91908A",
-"R c #EEECE7",
-"S c #62615F",
-"T c #EBEAE4",
-"U c #EAE9E2",
-"V c #BD5A62",
-"W c #E4E2DA",
-"X c #CCCBC4",
-"Y c #A3A29D",
-"Z c #B6B5B2",
-"` c #BCBCB7",
-" . c #979691",
-".. c #BC5760",
-"+. c #A13C45",
-"@. c #ECEBE5",
-"#. c #61615E",
-"$. c #C0636B",
-"%. c #A83F48",
-"&. c #797875",
-"*. c #969590",
-"=. c #CFCEC8",
-"-. c #585754",
-";. c #7B7A76",
-" . . . . ",
-" . . . . . + @ # $ . ",
-" . . . . . % $ & * = - ; > , . ",
-". ' ) ! ~ { ] ^ * / ( _ : < [ } . ",
-". | 1 2 3 4 5 6 / # _ : 7 8 9 0 . ",
-". a b c d e f / # g g h i j g g . ",
-" . k 4 l m n o p g q g r g s g t . ",
-" . u * v ( ; w x g s g g y z g A . ",
-" . B / ( _ : C D E g s F G g H I . ",
-" . # _ J K L M 0 g s s g N O P Q . ",
-" . ; J R S T U g V s s g W X Y . . ",
-" . Z D ` .U g ..G g g +.g . . ",
-" . @.#.U g $.G g . g %.g ",
-" . &.*.=.g g g . g g ",
-" . -.;.. . ",
-" . . "};
diff --git a/widgets/meeting-time-sel/e-meeting-time-sel.c b/widgets/meeting-time-sel/e-meeting-time-sel.c
deleted file mode 100644
index 86f81cc80e..0000000000
--- a/widgets/meeting-time-sel/e-meeting-time-sel.c
+++ /dev/null
@@ -1,3065 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#include <config.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <gtk/gtkalignment.h>
-#include <gtk/gtkarrow.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkdrawingarea.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkhscrollbar.h>
-#include <gtk/gtkhseparator.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkradiomenuitem.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkvscrollbar.h>
-#include <libgnomeui/gnome-dateedit.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnomeui/gnome-canvas-widget.h>
-
-#include "e-meeting-time-sel.h"
-#include "e-meeting-time-sel-item.h"
-#include "e-meeting-time-sel-list-item.h"
-
-/* An array of hour strings, "0:00" .. "23:00". */
-const gchar *EMeetingTimeSelectorHours[24] = {
- "0:00", "1:00", "2:00", "3:00", "4:00", "5:00", "6:00", "7:00",
- "8:00", "9:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00",
- "16:00", "17:00", "18:00", "19:00", "20:00", "21:00", "22:00", "23:00"
-};
-
-/* The number of days shown in the entire canvas. */
-#define E_MEETING_TIME_SELECTOR_DAYS_SHOWN 365
-
-#define E_MEETING_TIME_SELECTOR_ENTRY_INNER_BORDER 2
-
-/* This is the number of pixels between the mouse has to move before the
- scroll speed is incremented. */
-#define E_MEETING_TIME_SELECTOR_SCROLL_INCREMENT_WIDTH 10
-
-/* This is the maximum scrolling speed. */
-#define E_MEETING_TIME_SELECTOR_MAX_SCROLL_SPEED 4
-
-
-static void e_meeting_time_selector_class_init (EMeetingTimeSelectorClass * klass);
-static void e_meeting_time_selector_init (EMeetingTimeSelector * mts);
-static void e_meeting_time_selector_destroy (GtkObject *object);
-static void e_meeting_time_selector_alloc_named_color (EMeetingTimeSelector * mts,
- const char *name, GdkColor *c);
-static void e_meeting_time_selector_add_key_color (EMeetingTimeSelector * mts,
- GtkWidget *hbox,
- gchar *label_text,
- GdkColor *color);
-static gint e_meeting_time_selector_expose_key_color (GtkWidget *darea,
- GdkEventExpose *event,
- GdkColor *color);
-static gint e_meeting_time_selector_expose_title_bar (GtkWidget *darea,
- GdkEventExpose *event,
- gpointer data);
-static void e_meeting_time_selector_options_menu_detacher (GtkWidget *widget,
- GtkMenu *menu);
-static void e_meeting_time_selector_autopick_menu_detacher (GtkWidget *widget,
- GtkMenu *menu);
-static void e_meeting_time_selector_realize (GtkWidget *widget);
-static void e_meeting_time_selector_unrealize (GtkWidget *widget);
-static void e_meeting_time_selector_style_set (GtkWidget *widget,
- GtkStyle *previous_style);
-static gint e_meeting_time_selector_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
-static void e_meeting_time_selector_hadjustment_changed (GtkAdjustment *adjustment,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_vadjustment_changed (GtkAdjustment *adjustment,
- EMeetingTimeSelector *mts);
-
-static void e_meeting_time_selector_on_canvas_realized (GtkWidget *widget,
- EMeetingTimeSelector *mts);
-
-static gint e_meeting_time_selector_compare_period_starts (const void *arg1,
- const void *arg2);
-#if 0
-static gint e_meeting_time_selector_compare_periods (const void *arg1,
- const void *arg2);
-#endif
-static gint e_meeting_time_selector_compare_times (EMeetingTimeSelectorTime *time1,
- EMeetingTimeSelectorTime *time2);
-static void e_meeting_time_selector_on_options_button_clicked (GtkWidget *button,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_options_menu_position_callback (GtkMenu *menu,
- gint *x,
- gint *y,
- gpointer user_data);
-static void e_meeting_time_selector_on_zoomed_out_toggled (GtkWidget *button,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_on_working_hours_toggled (GtkWidget *button,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_on_invite_others_button_clicked (GtkWidget *button,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_on_update_free_busy (GtkWidget *button,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_on_autopick_button_clicked (GtkWidget *button,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_autopick_menu_position_callback (GtkMenu *menu,
- gint *x,
- gint *y,
- gpointer user_data);
-static void e_meeting_time_selector_on_autopick_option_toggled (GtkWidget *button,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_on_prev_button_clicked (GtkWidget *button,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_on_next_button_clicked (GtkWidget *button,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_autopick (EMeetingTimeSelector *mts,
- gboolean forward);
-static void e_meeting_time_selector_calculate_time_difference (EMeetingTimeSelectorTime *start,
- EMeetingTimeSelectorTime *end,
- gint *days,
- gint *hours,
- gint *minutes);
-static void e_meeting_time_selector_find_nearest_interval (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorTime *start_time,
- EMeetingTimeSelectorTime *end_time,
- gint days, gint hours, gint mins);
-static void e_meeting_time_selector_find_nearest_interval_backward (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorTime *start_time,
- EMeetingTimeSelectorTime *end_time,
- gint days, gint hours, gint mins);
-static void e_meeting_time_selector_adjust_time (EMeetingTimeSelectorTime *mtstime,
- gint days, gint hours, gint minutes);
-static EMeetingTimeSelectorPeriod* e_meeting_time_selector_find_time_clash (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorAttendee *attendee,
- EMeetingTimeSelectorTime *start_time,
- EMeetingTimeSelectorTime *end_time);
-
-
-static void e_meeting_time_selector_recalc_grid (EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_save_position (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorTime *mtstime);
-static void e_meeting_time_selector_restore_position (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorTime *mtstime);
-static void e_meeting_time_selector_on_start_time_changed (GtkWidget *widget,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_on_end_time_changed (GtkWidget *widget,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_update_date_popup_menus (EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_on_attendees_list_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_on_canvas_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation,
- EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_update_main_canvas_scroll_region (EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_update_attendees_list_scroll_region (EMeetingTimeSelector *mts);
-static gboolean e_meeting_time_selector_timeout_handler (gpointer data);
-static void e_meeting_time_selector_update_start_date_edit (EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_update_end_date_edit (EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_ensure_meeting_time_shown (EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_update_dates_shown (EMeetingTimeSelector *mts);
-
-static void e_meeting_time_selector_update_attendees_list_positions (EMeetingTimeSelector *mts);
-
-static GtkTableClass *e_meeting_time_selector_parent_class;
-
-
-GtkType
-e_meeting_time_selector_get_type (void)
-{
- static guint e_meeting_time_selector_type = 0;
-
- if (!e_meeting_time_selector_type) {
- GtkTypeInfo e_meeting_time_selector_info =
- {
- "EMeetingTimeSelector",
- sizeof (EMeetingTimeSelector),
- sizeof (EMeetingTimeSelectorClass),
- (GtkClassInitFunc) e_meeting_time_selector_class_init,
- (GtkObjectInitFunc) e_meeting_time_selector_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- e_meeting_time_selector_type = gtk_type_unique (GTK_TYPE_TABLE,
- &e_meeting_time_selector_info);
- }
- return e_meeting_time_selector_type;
-}
-
-
-static void
-e_meeting_time_selector_class_init (EMeetingTimeSelectorClass * klass)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- e_meeting_time_selector_parent_class = gtk_type_class (gtk_table_get_type());
-
- object_class = (GtkObjectClass *) klass;
- widget_class = (GtkWidgetClass *) klass;
-
- object_class->destroy = e_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->expose_event = e_meeting_time_selector_expose_event;
-}
-
-
-static void
-e_meeting_time_selector_init (EMeetingTimeSelector * mts)
-{
- GtkWidget *hbox, *separator, *button, *label, *table;
- GtkWidget *alignment, *child_hbox, *arrow, *menuitem;
- GSList *group;
- GdkVisual *visual;
- GdkColormap *colormap;
- guint accel_key;
- GtkAccelGroup *menu_accel_group;
- time_t meeting_start_time;
- struct tm *meeting_start_tm;
- guchar stipple_bits[] = {
- 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
- };
-
- mts->accel_group = gtk_accel_group_new ();
-
- mts->attendees = g_array_new (FALSE, FALSE,
- sizeof (EMeetingTimeSelectorAttendee));
-
- mts->working_hours_only = TRUE;
- mts->day_start_hour = 9;
- mts->day_start_minute = 0;
- mts->day_end_hour = 18;
- mts->day_end_minute = 0;
- mts->zoomed_out = FALSE;
- mts->dragging_position = E_MEETING_TIME_SELECTOR_POS_NONE;
-
- /* The default meeting time is the nearest half-hour interval in the
- future, in working hours. */
- meeting_start_time = time (NULL);
- g_date_clear (&mts->meeting_start_time.date, 1);
- g_date_set_time (&mts->meeting_start_time.date, meeting_start_time);
- meeting_start_tm = localtime (&meeting_start_time);
- mts->meeting_start_time.hour = meeting_start_tm->tm_hour;
- mts->meeting_start_time.minute = meeting_start_tm->tm_min;
-
- e_meeting_time_selector_find_nearest_interval (mts, &mts->meeting_start_time,
- &mts->meeting_end_time,
- 0, 0, 30);
-
- e_meeting_time_selector_update_dates_shown (mts);
-
- mts->meeting_positions_valid = FALSE;
-
- mts->row_height = 30;
- mts->col_width = 50;
- mts->day_width = 50 * 24 + 1;
-
- mts->auto_scroll_timeout_id = 0;
-
-
- mts->attendees_title_bar_vbox = gtk_vbox_new (FALSE, 2);
- /* Add some horizontal padding for the shadow around the display. */
- gtk_table_attach (GTK_TABLE (mts),
- mts->attendees_title_bar_vbox,
- 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 2, 0);
- gtk_widget_show (mts->attendees_title_bar_vbox);
-
- mts->attendees_title_bar = gtk_drawing_area_new ();
- gtk_box_pack_end (GTK_BOX (mts->attendees_title_bar_vbox),
- mts->attendees_title_bar, FALSE, FALSE, 0);
- gtk_widget_show (mts->attendees_title_bar);
- gtk_signal_connect (GTK_OBJECT (mts->attendees_title_bar),
- "expose_event",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_expose_title_bar), mts);
-
- mts->attendees_list = gnome_canvas_new ();
- /* Add some horizontal padding for the shadow around the display. */
- gtk_table_attach (GTK_TABLE (mts), mts->attendees_list,
- 0, 1, 1, 2,
- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 0);
- gtk_widget_show (mts->attendees_list);
- gtk_signal_connect (GTK_OBJECT (mts->attendees_list), "realize",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_canvas_realized), mts);
- gtk_signal_connect (GTK_OBJECT (mts->attendees_list), "size_allocate",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_attendees_list_size_allocate), mts);
-
- /* Create the item in the list canvas. */
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (mts->attendees_list)->root),
- e_meeting_time_selector_list_item_get_type (),
- "EMeetingTimeSelectorListItem::meeting_time_selector", mts,
- NULL);
-
- mts->display_top = gnome_canvas_new ();
- gnome_canvas_set_scroll_region (GNOME_CANVAS (mts->display_top),
- 0, 0,
- mts->day_width * E_MEETING_TIME_SELECTOR_DAYS_SHOWN,
- mts->row_height * 3);
- /* Add some horizontal padding for the shadow around the display. */
- gtk_table_attach (GTK_TABLE (mts), mts->display_top,
- 1, 4, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 0);
- gtk_widget_show (mts->display_top);
- gtk_signal_connect (GTK_OBJECT (mts->display_top), "realize",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_canvas_realized), mts);
-
- mts->display_main = gnome_canvas_new ();
- e_meeting_time_selector_update_main_canvas_scroll_region (mts);
- /* Add some horizontal padding for the shadow around the display. */
- gtk_table_attach (GTK_TABLE (mts), mts->display_main,
- 1, 4, 1, 2,
- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 0);
- gtk_widget_show (mts->display_main);
- gtk_signal_connect (GTK_OBJECT (mts->display_main), "realize",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_canvas_realized), mts);
- gtk_signal_connect (GTK_OBJECT (mts->display_main), "size_allocate",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_canvas_size_allocate), mts);
-
- mts->hscrollbar = gtk_hscrollbar_new (GTK_LAYOUT (mts->display_main)->hadjustment);
- gtk_table_attach (GTK_TABLE (mts), mts->hscrollbar,
- 1, 4, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0);
- gtk_widget_show (mts->hscrollbar);
-
- mts->vscrollbar = gtk_vscrollbar_new (GTK_LAYOUT (mts->display_main)->vadjustment);
- gtk_table_attach (GTK_TABLE (mts), mts->vscrollbar,
- 4, 5, 1, 2, 0, GTK_EXPAND | GTK_FILL, 0, 0);
- gtk_widget_show (mts->vscrollbar);
-
- /* Create the item in the top canvas. */
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (mts->display_top)->root),
- e_meeting_time_selector_item_get_type (),
- "EMeetingTimeSelectorItem::meeting_time_selector", mts,
- NULL);
-
- /* Create the item in the main canvas. */
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (mts->display_main)->root),
- e_meeting_time_selector_item_get_type (),
- "EMeetingTimeSelectorItem::meeting_time_selector", mts,
- NULL);
-
- /* Create the hbox containing the color key. */
- hbox = gtk_hbox_new (FALSE, 2);
- gtk_table_attach (GTK_TABLE (mts), hbox,
- 1, 4, 3, 4, GTK_FILL, 0, 0, 8);
- gtk_widget_show (hbox);
-
- e_meeting_time_selector_add_key_color (mts, hbox, _("Tentative"), &mts->busy_colors[E_MEETING_TIME_SELECTOR_BUSY_TENTATIVE]);
- e_meeting_time_selector_add_key_color (mts, hbox, _("Busy"), &mts->busy_colors[E_MEETING_TIME_SELECTOR_BUSY_BUSY]);
- e_meeting_time_selector_add_key_color (mts, hbox, _("Out of Office"), &mts->busy_colors[E_MEETING_TIME_SELECTOR_BUSY_OUT_OF_OFFICE]);
- e_meeting_time_selector_add_key_color (mts, hbox, _("No Information"),
- NULL);
-
- separator = gtk_hseparator_new ();
- gtk_table_attach (GTK_TABLE (mts), separator,
- 0, 5, 4, 5, GTK_FILL, 0, 0, 0);
- gtk_widget_show (separator);
-
- /* Create the Invite Others & Options buttons on the left. */
- hbox = gtk_hbox_new (FALSE, 4);
- gtk_table_attach (GTK_TABLE (mts), hbox,
- 0, 1, 3, 4, GTK_FILL, 0, 0, 0);
- gtk_widget_show (hbox);
-
- button = gtk_button_new_with_label ("");
- accel_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (button)->child),
- _("_Invite Others..."));
- gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- gtk_widget_show (button);
- gtk_widget_add_accelerator (button, "clicked", mts->accel_group,
- accel_key, GDK_MOD1_MASK, 0);
- gtk_signal_connect (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_invite_others_button_clicked), mts);
-
- mts->options_button = gtk_button_new ();
- gtk_box_pack_start (GTK_BOX (hbox), mts->options_button, TRUE, TRUE, 0);
- gtk_widget_show (mts->options_button);
-
- gtk_signal_connect (GTK_OBJECT (mts->options_button), "clicked",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_options_button_clicked), mts);
-
- child_hbox = gtk_hbox_new (FALSE, 2);
- gtk_container_add (GTK_CONTAINER (mts->options_button), child_hbox);
- gtk_widget_show (child_hbox);
-
- label = gtk_label_new ("");
- accel_key = gtk_label_parse_uline (GTK_LABEL (label), _("_Options"));
- gtk_box_pack_start (GTK_BOX (child_hbox), label, TRUE, TRUE, 0);
- gtk_widget_show (label);
- gtk_widget_add_accelerator (mts->options_button, "clicked", mts->accel_group,
- accel_key, GDK_MOD1_MASK, 0);
-
- arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
- gtk_box_pack_start (GTK_BOX (child_hbox), arrow, FALSE, FALSE, 2);
- gtk_widget_show (arrow);
-
- /* Create the Options menu. */
- mts->options_menu = gtk_menu_new ();
- gtk_menu_attach_to_widget (GTK_MENU (mts->options_menu), mts->options_button,
- e_meeting_time_selector_options_menu_detacher);
- menu_accel_group = gtk_menu_ensure_uline_accel_group (GTK_MENU (mts->options_menu));
-
- menuitem = gtk_check_menu_item_new_with_label ("");
- accel_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menuitem)->child), _("Show _Only Working Hours"));
- gtk_menu_append (GTK_MENU (mts->options_menu), menuitem);
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem),
- mts->working_hours_only);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, 0, 0);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, GDK_MOD1_MASK, 0);
- gtk_signal_connect (GTK_OBJECT (menuitem), "toggled",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_working_hours_toggled), mts);
- gtk_widget_show (menuitem);
-
- menuitem = gtk_check_menu_item_new_with_label ("");
- accel_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menuitem)->child), _("Show _Zoomed Out"));
- gtk_menu_append (GTK_MENU (mts->options_menu), menuitem);
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem),
- mts->zoomed_out);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, 0, 0);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, GDK_MOD1_MASK, 0);
- gtk_signal_connect (GTK_OBJECT (menuitem), "toggled",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_zoomed_out_toggled), mts);
- gtk_widget_show (menuitem);
-
- menuitem = gtk_menu_item_new ();
- gtk_menu_append (GTK_MENU (mts->options_menu), menuitem);
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("");
- accel_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menuitem)->child), _("_Update Free/Busy"));
- gtk_menu_append (GTK_MENU (mts->options_menu), menuitem);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, 0, 0);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, GDK_MOD1_MASK, 0);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_update_free_busy), mts);
- gtk_widget_show (menuitem);
-
- /* Create the 3 AutoPick buttons on the left. */
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_table_attach (GTK_TABLE (mts), hbox,
- 0, 1, 5, 6, GTK_FILL, 0, 0, 0);
- gtk_widget_show (hbox);
-
- button = gtk_button_new_with_label ("");
- accel_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (button)->child),
- _("_<<"));
- gtk_widget_add_accelerator (button, "clicked", mts->accel_group,
- accel_key, GDK_MOD1_MASK | GDK_SHIFT_MASK, 0);
- gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- gtk_widget_show (button);
- gtk_signal_connect (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_prev_button_clicked), mts);
-
- mts->autopick_button = gtk_button_new ();
- gtk_box_pack_start (GTK_BOX (hbox), mts->autopick_button, TRUE, TRUE, 0);
- gtk_widget_show (mts->autopick_button);
-
- child_hbox = gtk_hbox_new (FALSE, 2);
- gtk_container_add (GTK_CONTAINER (mts->autopick_button), child_hbox);
- gtk_widget_show (child_hbox);
-
- label = gtk_label_new ("");
- accel_key = gtk_label_parse_uline (GTK_LABEL (label), _("_Autopick"));
- gtk_box_pack_start (GTK_BOX (child_hbox), label, TRUE, TRUE, 0);
- gtk_widget_show (label);
- gtk_widget_add_accelerator (mts->autopick_button, "clicked", mts->accel_group,
- accel_key, GDK_MOD1_MASK, 0);
- gtk_signal_connect (GTK_OBJECT (mts->autopick_button), "clicked",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_autopick_button_clicked), mts);
-
- arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
- gtk_box_pack_start (GTK_BOX (child_hbox), arrow, FALSE, FALSE, 2);
- gtk_widget_show (arrow);
-
- button = gtk_button_new_with_label ("");
- accel_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (button)->child),
- _(">_>"));
- gtk_widget_add_accelerator (button, "clicked", mts->accel_group,
- accel_key, GDK_MOD1_MASK | GDK_SHIFT_MASK, 0);
- gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- gtk_widget_show (button);
- gtk_signal_connect (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_next_button_clicked), mts);
-
- /* Create the Autopick menu. */
- mts->autopick_menu = gtk_menu_new ();
- gtk_menu_attach_to_widget (GTK_MENU (mts->autopick_menu), mts->autopick_button,
- e_meeting_time_selector_autopick_menu_detacher);
- menu_accel_group = gtk_menu_ensure_uline_accel_group (GTK_MENU (mts->autopick_menu));
-
- menuitem = gtk_radio_menu_item_new_with_label (NULL, "");
- mts->autopick_all_item = menuitem;
- group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
- accel_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menuitem)->child), _("_All People and Resources"));
- gtk_menu_append (GTK_MENU (mts->autopick_menu), menuitem);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, 0, 0);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, GDK_MOD1_MASK, 0);
- gtk_signal_connect (GTK_OBJECT (menuitem), "toggled",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_autopick_option_toggled), mts);
- gtk_widget_show (menuitem);
-
- menuitem = gtk_radio_menu_item_new_with_label (group, "");
- mts->autopick_all_people_one_resource_item = menuitem;
- group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
- accel_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menuitem)->child), _("All _People and One Resource"));
- gtk_menu_append (GTK_MENU (mts->autopick_menu), menuitem);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, 0, 0);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, GDK_MOD1_MASK, 0);
- gtk_signal_connect (GTK_OBJECT (menuitem), "toggled",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_autopick_option_toggled), mts);
- gtk_widget_show (menuitem);
-
- menuitem = gtk_radio_menu_item_new_with_label (group, "");
- mts->autopick_required_people_item = menuitem;
- group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
- accel_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menuitem)->child), _("_Required People"));
- gtk_menu_append (GTK_MENU (mts->autopick_menu), menuitem);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, 0, 0);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, GDK_MOD1_MASK, 0);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_autopick_option_toggled), mts);
- gtk_widget_show (menuitem);
-
- menuitem = gtk_radio_menu_item_new_with_label (group, "");
- mts->autopick_required_people_one_resource_item = menuitem;
- group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
- accel_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menuitem)->child), _("Required People and _One Resource"));
- gtk_menu_append (GTK_MENU (mts->autopick_menu), menuitem);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, 0, 0);
- gtk_widget_add_accelerator (menuitem, "activate", menu_accel_group,
- accel_key, GDK_MOD1_MASK, 0);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_autopick_option_toggled), mts);
- gtk_widget_show (menuitem);
-
- /* Create the date entry fields on the right. */
- alignment = gtk_alignment_new (0.5, 0.5, 0, 0);
- gtk_table_attach (GTK_TABLE (mts), alignment,
- 1, 4, 5, 6, GTK_FILL, 0, 0, 0);
- gtk_widget_show (alignment);
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 4);
- gtk_container_add (GTK_CONTAINER (alignment), table);
- gtk_widget_show (table);
-
- label = gtk_label_new ("");
- accel_key = gtk_label_parse_uline (GTK_LABEL (label),
- _("Meeting _start time:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (table), label,
- 0, 1, 0, 1, GTK_FILL, 0, 4, 0);
- gtk_widget_show (label);
-
- mts->start_date_edit = gnome_date_edit_new (0, TRUE, TRUE);
- /* I don't like the 'Calendar' label. */
- gtk_widget_hide (GNOME_DATE_EDIT (mts->start_date_edit)->cal_label);
- gtk_table_attach (GTK_TABLE (table), mts->start_date_edit,
- 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
- gtk_widget_show (mts->start_date_edit);
- gtk_signal_connect (GTK_OBJECT (mts->start_date_edit), "date_changed",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_start_time_changed), mts);
- gtk_signal_connect (GTK_OBJECT (mts->start_date_edit), "time_changed",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_start_time_changed), mts);
- gtk_signal_connect (GTK_OBJECT (GNOME_DATE_EDIT (mts->start_date_edit)->date_entry), "activate", GTK_SIGNAL_FUNC (e_meeting_time_selector_on_start_time_changed), mts);
- gtk_signal_connect (GTK_OBJECT (GNOME_DATE_EDIT (mts->start_date_edit)->time_entry), "activate", GTK_SIGNAL_FUNC (e_meeting_time_selector_on_start_time_changed), mts);
- gtk_widget_add_accelerator (GNOME_DATE_EDIT (mts->start_date_edit)->date_entry,
- "grab_focus", mts->accel_group,
- accel_key, GDK_MOD1_MASK, 0);
-
- label = gtk_label_new ("");
- accel_key = gtk_label_parse_uline (GTK_LABEL (label),
- _("Meeting _end time:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (table), label,
- 0, 1, 1, 2, GTK_FILL, 0, 4, 0);
- gtk_widget_show (label);
-
- mts->end_date_edit = gnome_date_edit_new (0, TRUE, TRUE);
- gtk_widget_hide (GNOME_DATE_EDIT (mts->end_date_edit)->cal_label);
- gtk_table_attach (GTK_TABLE (table), mts->end_date_edit,
- 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
- gtk_widget_show (mts->end_date_edit);
- gtk_signal_connect (GTK_OBJECT (mts->end_date_edit), "date_changed",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_end_time_changed), mts);
- gtk_signal_connect (GTK_OBJECT (mts->end_date_edit), "time_changed",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_on_end_time_changed), mts);
- gtk_signal_connect (GTK_OBJECT (GNOME_DATE_EDIT (mts->end_date_edit)->date_entry), "activate", GTK_SIGNAL_FUNC (e_meeting_time_selector_on_end_time_changed), mts);
- gtk_signal_connect (GTK_OBJECT (GNOME_DATE_EDIT (mts->end_date_edit)->time_entry), "activate", GTK_SIGNAL_FUNC (e_meeting_time_selector_on_end_time_changed), mts);
- gtk_widget_add_accelerator (GNOME_DATE_EDIT (mts->end_date_edit)->date_entry,
- "grab_focus", mts->accel_group,
- accel_key, GDK_MOD1_MASK, 0);
-
- gtk_table_set_col_spacing (GTK_TABLE (mts), 0, 4);
- gtk_table_set_row_spacing (GTK_TABLE (mts), 4, 12);
-
- /* Allocate the colors. */
- visual = gtk_widget_get_visual (GTK_WIDGET (mts));
- colormap = gtk_widget_get_colormap (GTK_WIDGET (mts));
- mts->color_context = gdk_color_context_new (visual, colormap);
- e_meeting_time_selector_alloc_named_color (mts, "gray75", &mts->bg_color);
- e_meeting_time_selector_alloc_named_color (mts, "gray50", &mts->all_attendees_bg_color);
- gdk_color_black (colormap, &mts->grid_color);
- gdk_color_white (colormap, &mts->grid_shadow_color);
- e_meeting_time_selector_alloc_named_color (mts, "gray50", &mts->grid_unused_color);
- gdk_color_white (colormap, &mts->meeting_time_bg_color);
- gdk_color_white (colormap, &mts->stipple_bg_color);
- gdk_color_white (colormap, &mts->attendee_list_bg_color);
-
- e_meeting_time_selector_alloc_named_color (mts, "LightSkyBlue2", &mts->busy_colors[E_MEETING_TIME_SELECTOR_BUSY_TENTATIVE]);
- e_meeting_time_selector_alloc_named_color (mts, "blue", &mts->busy_colors[E_MEETING_TIME_SELECTOR_BUSY_BUSY]);
- e_meeting_time_selector_alloc_named_color (mts, "HotPink3", &mts->busy_colors[E_MEETING_TIME_SELECTOR_BUSY_OUT_OF_OFFICE]);
-
- /* Create the stipple, for attendees with no data. */
- mts->stipple = gdk_bitmap_create_from_data (NULL, (gchar*)stipple_bits,
- 8, 8);
-
- /* Connect handlers to the adjustments in the main canvas, so we can
- scroll the other 2 canvases. */
- gtk_signal_connect (GTK_OBJECT (GTK_LAYOUT (mts->display_main)->hadjustment), "value_changed", GTK_SIGNAL_FUNC (e_meeting_time_selector_hadjustment_changed), mts);
- gtk_signal_connect (GTK_OBJECT (GTK_LAYOUT (mts->display_main)->vadjustment), "value_changed", GTK_SIGNAL_FUNC (e_meeting_time_selector_vadjustment_changed), mts);
-
- e_meeting_time_selector_recalc_grid (mts);
- e_meeting_time_selector_ensure_meeting_time_shown (mts);
- e_meeting_time_selector_update_start_date_edit (mts);
- e_meeting_time_selector_update_end_date_edit (mts);
- e_meeting_time_selector_update_date_popup_menus (mts);
-}
-
-
-/* This adds a color to the color key beneath the main display. If color is
- NULL, it displays the No Info stipple instead. */
-static void
-e_meeting_time_selector_add_key_color (EMeetingTimeSelector * mts,
- GtkWidget *hbox,
- gchar *label_text, GdkColor *color)
-{
- GtkWidget *child_hbox, *darea, *label;
-
- child_hbox = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (hbox), child_hbox, TRUE, TRUE, 0);
- gtk_widget_show (child_hbox);
-
- darea = gtk_drawing_area_new ();
- gtk_box_pack_start (GTK_BOX (child_hbox), darea, FALSE, FALSE, 0);
- gtk_object_set_user_data (GTK_OBJECT (darea), mts);
- gtk_widget_set_usize (darea, 14, 14);
- gtk_widget_show (darea);
-
- label = gtk_label_new (label_text);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (child_hbox), label, TRUE, TRUE, 0);
- gtk_widget_show (label);
-
- gtk_signal_connect (GTK_OBJECT (darea), "expose_event",
- GTK_SIGNAL_FUNC (e_meeting_time_selector_expose_key_color),
- color);
-}
-
-
-static gint
-e_meeting_time_selector_expose_title_bar (GtkWidget *widget,
- GdkEventExpose *event,
- gpointer data)
-{
- EMeetingTimeSelector * mts;
- GdkFont *font;
-
- mts = E_MEETING_TIME_SELECTOR (data);
-
- gtk_draw_shadow (widget->style, widget->window, GTK_STATE_NORMAL,
- GTK_SHADOW_OUT, 0, 0,
- E_MEETING_TIME_SELECTOR_ICON_COLUMN_WIDTH + 1,
- widget->allocation.height);
- gtk_draw_shadow (widget->style, widget->window, GTK_STATE_NORMAL,
- GTK_SHADOW_OUT,
- E_MEETING_TIME_SELECTOR_ICON_COLUMN_WIDTH + 1, 0,
- widget->allocation.width - E_MEETING_TIME_SELECTOR_ICON_COLUMN_WIDTH - 1,
- widget->allocation.height);
-
- font = widget->style->font;
- gdk_draw_string (widget->window, font,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- E_MEETING_TIME_SELECTOR_ICON_COLUMN_WIDTH + 4,
- 4 + font->ascent, _("All Attendees"));
-
- return FALSE;
-}
-
-
-static gint
-e_meeting_time_selector_expose_key_color (GtkWidget *darea,
- GdkEventExpose *event,
- GdkColor *color)
-{
- EMeetingTimeSelector * mts;
- GdkGC *gc;
- gint width, height;
-
- mts = gtk_object_get_user_data (GTK_OBJECT (darea));
- gc = mts->color_key_gc;
- width = darea->allocation.width;
- height = darea->allocation.height;
-
- gtk_draw_shadow (darea->style, darea->window, GTK_STATE_NORMAL,
- GTK_SHADOW_IN, 0, 0, width, height);
-
- if (color) {
- gdk_gc_set_foreground (gc, color);
- gdk_draw_rectangle (darea->window, gc, TRUE, 1, 1,
- width - 2, height - 2);
- } else {
- gdk_gc_set_foreground (gc, &mts->grid_color);
- gdk_gc_set_background (gc, &mts->stipple_bg_color);
- gdk_gc_set_stipple (gc, mts->stipple);
- gdk_gc_set_fill (gc, GDK_OPAQUE_STIPPLED);
- gdk_draw_rectangle (darea->window, gc, TRUE, 1, 1,
- width - 2, height - 2);
- gdk_gc_set_fill (gc, GDK_SOLID);
- }
-
- return TRUE;
-}
-
-
-static void
-e_meeting_time_selector_alloc_named_color (EMeetingTimeSelector * mts,
- const char *name, GdkColor *c)
-{
- int failed;
-
- g_return_if_fail (name != NULL);
- g_return_if_fail (c != NULL);
-
- gdk_color_parse (name, c);
- c->pixel = 0;
- c->pixel = gdk_color_context_get_pixel (mts->color_context,
- c->red, c->green, c->blue,
- &failed);
- if (failed)
- g_warning ("Failed to allocate color: %s\n", name);
-}
-
-
-static void
-e_meeting_time_selector_options_menu_detacher (GtkWidget *widget,
- GtkMenu *menu)
-{
- EMeetingTimeSelector *mts;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (widget));
-
- mts = E_MEETING_TIME_SELECTOR (widget);
- g_return_if_fail (mts->options_menu == (GtkWidget*) menu);
-
- mts->options_menu = NULL;
-}
-
-
-static void
-e_meeting_time_selector_autopick_menu_detacher (GtkWidget *widget,
- GtkMenu *menu)
-{
- EMeetingTimeSelector *mts;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (widget));
-
- mts = E_MEETING_TIME_SELECTOR (widget);
- g_return_if_fail (mts->autopick_menu == (GtkWidget*) menu);
-
- mts->autopick_menu = NULL;
-}
-
-
-GtkWidget *
-e_meeting_time_selector_new (void)
-{
- GtkWidget *mts;
-
- mts = GTK_WIDGET (gtk_type_new (e_meeting_time_selector_get_type ()));
-
- return mts;
-}
-
-
-static void
-e_meeting_time_selector_destroy (GtkObject *object)
-{
- EMeetingTimeSelector *mts;
- EMeetingTimeSelectorAttendee *attendee;
- gint row;
-
- mts = E_MEETING_TIME_SELECTOR (object);
-
- e_meeting_time_selector_remove_timeout (mts);
-
- gdk_color_context_free (mts->color_context);
- gdk_bitmap_unref (mts->stipple);
-
- for (row = 0; row < mts->attendees->len; row++) {
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
- g_free (attendee->name);
- g_array_free (attendee->busy_periods, TRUE);
- }
-
- g_array_free (mts->attendees, TRUE);
-
- 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_realize (GtkWidget *widget)
-{
- EMeetingTimeSelector *mts;
-
- if (GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->realize)
- (*GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->realize)(widget);
-
- mts = E_MEETING_TIME_SELECTOR (widget);
-
- mts->color_key_gc = gdk_gc_new (widget->window);
-}
-
-
-static void
-e_meeting_time_selector_unrealize (GtkWidget *widget)
-{
- EMeetingTimeSelector *mts;
-
- mts = E_MEETING_TIME_SELECTOR (widget);
-
- gdk_gc_unref (mts->color_key_gc);
- mts->color_key_gc = NULL;
-
- if (GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->unrealize)
- (*GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->unrealize)(widget);
-}
-
-
-static void
-e_meeting_time_selector_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
-{
- EMeetingTimeSelector *mts;
- EMeetingTimeSelectorTime saved_time;
- GdkFont *font;
- gint hour, max_hour_width;
-
- if (GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->style_set)
- (*GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->style_set)(widget, previous_style);
-
- mts = E_MEETING_TIME_SELECTOR (widget);
- font = widget->style->font;
-
- /* Calculate the widths of the hour strings in the style's font. */
- max_hour_width = 0;
- for (hour = 0; hour < 24; hour++) {
- mts->hour_widths[hour] = gdk_string_width (font, EMeetingTimeSelectorHours[hour]);
- max_hour_width = MAX (max_hour_width, mts->hour_widths[hour]);
- }
-
- /* The row height really depends on the requested height of the
- GtkEntry widgets in the list on the left, so we really need to
- call size_request on them, AFTER their style has been set. */
- /* FIXME: This uses the default style ythickness of 2, though it won't
- be needed when we switch to Miguel's new editable GtkCList widget
- so I won't worry about it. */
- mts->row_height = font->ascent + font->descent
- + E_MEETING_TIME_SELECTOR_ENTRY_INNER_BORDER * 2
- + 2 * 2;
- mts->col_width = max_hour_width + 4;
-
- e_meeting_time_selector_save_position (mts, &saved_time);
- e_meeting_time_selector_recalc_grid (mts);
- e_meeting_time_selector_restore_position (mts, &saved_time);
-
- gtk_widget_set_usize (mts->display_top, -1, mts->row_height * 3);
- gtk_widget_set_usize (mts->attendees_title_bar, -1, mts->row_height);
-
- GTK_LAYOUT (mts->display_main)->hadjustment->step_increment = mts->col_width;
- GTK_LAYOUT (mts->display_main)->vadjustment->step_increment = mts->row_height;
-}
-
-
-/* This draws a shadow around the top display and main display. */
-static gint
-e_meeting_time_selector_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
-{
- EMeetingTimeSelector *mts;
- gint x, y, w, h;
-
- mts = E_MEETING_TIME_SELECTOR (widget);
-
- /* Draw the shadow around the attendees title bar and list. */
- x = mts->attendees_title_bar->allocation.x - 2;
- y = mts->attendees_title_bar->allocation.y - 2;
- w = mts->attendees_title_bar->allocation.width + 4;
- h = mts->attendees_title_bar->allocation.height + mts->attendees_list->allocation.height + 4;
-
- gtk_draw_shadow (widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_IN, x, y, w, h);
-
- /* Draw the shadow around the graphical displays. */
- x = mts->display_top->allocation.x - 2;
- y = mts->display_top->allocation.y - 2;
- w = mts->display_top->allocation.width + 4;
- h = mts->display_top->allocation.height + mts->display_main->allocation.height + 4;
-
- gtk_draw_shadow (widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_IN, x, y, w, h);
-
- if (GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->expose_event)
- (*GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->expose_event)(widget, event);
-
- return FALSE;
-}
-
-
-/* When the main canvas scrolls, we scroll the other canvases. */
-static void
-e_meeting_time_selector_hadjustment_changed (GtkAdjustment *adjustment,
- EMeetingTimeSelector *mts)
-{
- GtkAdjustment *adj;
-
- adj = GTK_LAYOUT (mts->display_top)->hadjustment;
- if (adj->value != adjustment->value) {
- adj->value = adjustment->value;
- gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");
- }
-}
-
-
-static void
-e_meeting_time_selector_vadjustment_changed (GtkAdjustment *adjustment,
- EMeetingTimeSelector *mts)
-{
- GtkAdjustment *adj;
-
- adj = GTK_LAYOUT (mts->attendees_list)->vadjustment;
- if (adj->value != adjustment->value) {
- adj->value = adjustment->value;
- gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");
- }
-}
-
-
-void
-e_meeting_time_selector_get_meeting_time (EMeetingTimeSelector *mts,
- gint *start_year,
- gint *start_month,
- gint *start_day,
- gint *start_hour,
- gint *start_minute,
- gint *end_year,
- gint *end_month,
- gint *end_day,
- gint *end_hour,
- gint *end_minute)
-{
- *start_year = g_date_year (&mts->meeting_start_time.date);
- *start_month = g_date_month (&mts->meeting_start_time.date);
- *start_day = g_date_day (&mts->meeting_start_time.date);
- *start_hour = mts->meeting_start_time.hour;
- *start_minute = mts->meeting_start_time.minute;
-
- *end_year = g_date_year (&mts->meeting_end_time.date);
- *end_month = g_date_month (&mts->meeting_end_time.date);
- *end_day = g_date_day (&mts->meeting_end_time.date);
- *end_hour = mts->meeting_end_time.hour;
- *end_minute = mts->meeting_end_time.minute;
-}
-
-
-gboolean
-e_meeting_time_selector_set_meeting_time (EMeetingTimeSelector *mts,
- gint start_year,
- gint start_month,
- gint start_day,
- gint start_hour,
- gint start_minute,
- gint end_year,
- gint end_month,
- gint end_day,
- gint end_hour,
- gint end_minute)
-{
- g_return_val_if_fail (IS_E_MEETING_TIME_SELECTOR (mts), FALSE);
-
- /* Check the dates are valid. */
- if (!g_date_valid_dmy (start_day, start_month, start_year)
- || !g_date_valid_dmy (end_day, end_month, end_year)
- || start_hour < 0 || start_hour > 23
- || end_hour < 0 || end_hour > 23
- || start_minute < 0 || start_minute > 59
- || end_minute < 0 || end_minute > 59)
- return FALSE;
-
- g_date_set_dmy (&mts->meeting_start_time.date, start_day, start_month,
- start_year);
- mts->meeting_start_time.hour = start_hour;
- mts->meeting_start_time.minute = start_minute;
- g_date_set_dmy (&mts->meeting_end_time.date, end_day, end_month,
- end_year);
- mts->meeting_end_time.hour = end_hour;
- mts->meeting_end_time.minute = end_minute;
-
- mts->meeting_positions_valid = FALSE;
-
- gtk_widget_queue_draw (mts->display_top);
- gtk_widget_queue_draw (mts->display_main);
-
- /* Set the times in the GnomeDateEdit widgets. */
- e_meeting_time_selector_update_start_date_edit (mts);
- e_meeting_time_selector_update_end_date_edit (mts);
-
- return TRUE;
-}
-
-
-void
-e_meeting_time_selector_set_working_hours_only (EMeetingTimeSelector *mts,
- gboolean working_hours_only)
-{
- EMeetingTimeSelectorTime saved_time;
-
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
-
- if (mts->working_hours_only == working_hours_only)
- return;
-
- mts->working_hours_only = working_hours_only;
-
- e_meeting_time_selector_save_position (mts, &saved_time);
- e_meeting_time_selector_recalc_grid (mts);
- e_meeting_time_selector_restore_position (mts, &saved_time);
-
- gtk_widget_queue_draw (mts->display_top);
- gtk_widget_queue_draw (mts->display_main);
- e_meeting_time_selector_update_date_popup_menus (mts);
-}
-
-
-void
-e_meeting_time_selector_set_working_hours (EMeetingTimeSelector *mts,
- gint day_start_hour,
- gint day_start_minute,
- gint day_end_hour,
- gint day_end_minute)
-{
- EMeetingTimeSelectorTime saved_time;
-
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
-
- if (mts->day_start_hour == day_start_hour
- && mts->day_start_minute == day_start_minute
- && mts->day_end_hour == day_end_hour
- && mts->day_end_minute == day_end_minute)
- return;
-
- mts->day_start_hour = day_start_hour;
- mts->day_start_minute = day_start_minute;
- mts->day_end_hour = day_end_hour;
- mts->day_end_minute = day_end_minute;
-
- e_meeting_time_selector_save_position (mts, &saved_time);
- e_meeting_time_selector_recalc_grid (mts);
- e_meeting_time_selector_restore_position (mts, &saved_time);
-
- gtk_widget_queue_draw (mts->display_top);
- gtk_widget_queue_draw (mts->display_main);
- e_meeting_time_selector_update_date_popup_menus (mts);
-}
-
-
-void
-e_meeting_time_selector_set_zoomed_out (EMeetingTimeSelector *mts,
- gboolean zoomed_out)
-{
- EMeetingTimeSelectorTime saved_time;
-
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
-
- if (mts->zoomed_out == zoomed_out)
- return;
-
- mts->zoomed_out = zoomed_out;
-
- e_meeting_time_selector_save_position (mts, &saved_time);
- e_meeting_time_selector_recalc_grid (mts);
- e_meeting_time_selector_restore_position (mts, &saved_time);
-
- gtk_widget_queue_draw (mts->display_top);
- gtk_widget_queue_draw (mts->display_main);
-}
-
-
-EMeetingTimeSelectorAutopickOption
-e_meeting_time_selector_get_autopick_option (EMeetingTimeSelector *mts)
-{
- if (GTK_CHECK_MENU_ITEM (mts->autopick_all_item)->active)
- return E_MEETING_TIME_SELECTOR_ALL_PEOPLE_AND_RESOURCES;
- if (GTK_CHECK_MENU_ITEM (mts->autopick_all_people_one_resource_item)->active)
- return E_MEETING_TIME_SELECTOR_ALL_PEOPLE_AND_ONE_RESOURCE;
- if (GTK_CHECK_MENU_ITEM (mts->autopick_required_people_item)->active)
- return E_MEETING_TIME_SELECTOR_REQUIRED_PEOPLE;
- return E_MEETING_TIME_SELECTOR_REQUIRED_PEOPLE_AND_ONE_RESOURCE;
-}
-
-
-void
-e_meeting_time_selector_set_autopick_option (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorAutopickOption autopick_option)
-{
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
-
- switch (autopick_option) {
- case E_MEETING_TIME_SELECTOR_ALL_PEOPLE_AND_RESOURCES:
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mts->autopick_all_item), TRUE);
- break;
- case E_MEETING_TIME_SELECTOR_ALL_PEOPLE_AND_ONE_RESOURCE:
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mts->autopick_all_people_one_resource_item), TRUE);
- break;
- case E_MEETING_TIME_SELECTOR_REQUIRED_PEOPLE:
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mts->autopick_required_people_item), TRUE);
- break;
- case E_MEETING_TIME_SELECTOR_REQUIRED_PEOPLE_AND_ONE_RESOURCE:
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mts->autopick_required_people_one_resource_item), TRUE);
- break;
- }
-}
-
-
-/* Adds an attendee to the list, returning the row. The data is meant for
- something like an address book id, though if the user edits the name this
- will become invalid. We'll probably have to handle address book lookup
- ourself. */
-gint
-e_meeting_time_selector_attendee_add (EMeetingTimeSelector *mts,
- gchar *attendee_name,
- gpointer data)
-{
- EMeetingTimeSelectorAttendee attendee;
- GtkWidget *entry;
- gint list_width, item_width;
-
- g_return_val_if_fail (IS_E_MEETING_TIME_SELECTOR (mts), -1);
- g_return_val_if_fail (attendee_name != NULL, -1);
-
- attendee.name = g_strdup (attendee_name);
- attendee.type = E_MEETING_TIME_SELECTOR_REQUIRED_PERSON;
- attendee.has_calendar_info = FALSE;
- attendee.send_meeting_to = TRUE;
- attendee.busy_periods = g_array_new (FALSE, FALSE,
- sizeof (EMeetingTimeSelectorPeriod));
- attendee.busy_periods_sorted = TRUE;
- attendee.longest_period_in_days = 0;
- attendee.data = data;
-
- /* Add to the list on the left. */
- entry = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY (entry), attendee_name);
- gtk_widget_show (entry);
- list_width = GTK_WIDGET (mts->attendees_list)->allocation.width;
- item_width = MAX (1, list_width - E_MEETING_TIME_SELECTOR_ICON_COLUMN_WIDTH);
- attendee.text_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (mts->attendees_list)->root),
- gnome_canvas_widget_get_type (),
- "GnomeCanvasWidget::widget", entry,
- "GnomeCanvasWidget::size_pixels", TRUE,
- "GnomeCanvasWidget::x", (gdouble) E_MEETING_TIME_SELECTOR_ICON_COLUMN_WIDTH,
- "GnomeCanvasWidget::y", (gdouble) (mts->attendees->len * mts->row_height),
- "GnomeCanvasWidget::width", (gdouble) item_width,
- "GnomeCanvasWidget::height", (gdouble) mts->row_height,
- NULL);
- gnome_canvas_item_hide (attendee.text_item);
-
- g_array_append_val (mts->attendees, attendee);
-
- /* Update the scroll region. */
- e_meeting_time_selector_update_attendees_list_scroll_region (mts);
- e_meeting_time_selector_update_main_canvas_scroll_region (mts);
-
- /* Redraw the canvases. */
- gtk_widget_queue_draw (mts->display_top);
- gtk_widget_queue_draw (mts->display_main);
-
-
- return mts->attendees->len - 1;
-}
-
-
-gint
-e_meeting_time_selector_attendee_find_by_name (EMeetingTimeSelector *mts,
- gchar *attendee_name,
- gint start_row)
-{
- EMeetingTimeSelectorAttendee *attendee;
- gint row;
-
- g_return_val_if_fail (IS_E_MEETING_TIME_SELECTOR (mts), -1);
- g_return_val_if_fail (start_row >= 0, -1);
- g_return_val_if_fail (start_row < mts->attendees->len, -1);
-
- for (row = start_row; row < mts->attendees->len; row++) {
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
- if (!strcmp (attendee->name, attendee_name))
- return row;
- }
-
- return -1;
-}
-
-
-gint
-e_meeting_time_selector_attendee_find_by_data (EMeetingTimeSelector *mts,
- gpointer data,
- gint start_row)
-{
- EMeetingTimeSelectorAttendee *attendee;
- gint row;
-
- g_return_val_if_fail (IS_E_MEETING_TIME_SELECTOR (mts), -1);
- g_return_val_if_fail (start_row >= 0, -1);
- g_return_val_if_fail (start_row < mts->attendees->len, -1);
-
- for (row = start_row; row < mts->attendees->len; row++) {
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
- if (attendee->data == data)
- return row;
- }
-
- return -1;
-}
-
-
-void
-e_meeting_time_selector_attendee_remove (EMeetingTimeSelector *mts,
- gint row)
-{
- EMeetingTimeSelectorAttendee *attendee;
-
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
- g_return_if_fail (row >= 0);
- g_return_if_fail (row < mts->attendees->len);
-
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
-
- g_free (attendee->name);
- g_array_free (attendee->busy_periods, TRUE);
-
- /* Destroy the GtkEntry in the list. */
- gtk_object_destroy (GTK_OBJECT (attendee->text_item));
-
- g_array_remove_index (mts->attendees, row);
-
- /* Update the positions of all the other GtkEntry widgets. */
- e_meeting_time_selector_update_attendees_list_positions (mts);
-
- e_meeting_time_selector_update_attendees_list_scroll_region (mts);
- e_meeting_time_selector_update_main_canvas_scroll_region (mts);
- gtk_widget_queue_draw (mts->display_top);
- gtk_widget_queue_draw (mts->display_main);
-}
-
-
-void
-e_meeting_time_selector_attendee_set_type (EMeetingTimeSelector *mts,
- gint row,
- EMeetingTimeSelectorAttendeeType type)
-{
- EMeetingTimeSelectorAttendee *attendee;
-
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
- g_return_if_fail (row >= 0);
- g_return_if_fail (row < mts->attendees->len);
-
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
- attendee->type = type;
-}
-
-
-void
-e_meeting_time_selector_attendee_set_has_calendar_info (EMeetingTimeSelector *mts,
- gint row,
- gboolean has_calendar_info)
-{
- EMeetingTimeSelectorAttendee *attendee;
-
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
- g_return_if_fail (row >= 0);
- g_return_if_fail (row < mts->attendees->len);
-
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
- attendee->has_calendar_info = has_calendar_info;
-}
-
-
-void
-e_meeting_time_selector_attendee_set_send_meeting_to (EMeetingTimeSelector *mts,
- gint row,
- gboolean send_meeting_to)
-{
- EMeetingTimeSelectorAttendee *attendee;
-
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
- g_return_if_fail (row >= 0);
- g_return_if_fail (row < mts->attendees->len);
-
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
- attendee->send_meeting_to = send_meeting_to;
-}
-
-
-/* Clears all busy times for the given attendee. */
-void
-e_meeting_time_selector_attendee_clear_busy_periods (EMeetingTimeSelector *mts,
- gint row)
-{
- EMeetingTimeSelectorAttendee *attendee;
-
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
- g_return_if_fail (row >= 0);
- g_return_if_fail (row < mts->attendees->len);
-
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
-
- g_array_set_size (attendee->busy_periods, 0);
- attendee->busy_periods_sorted = TRUE;
- attendee->longest_period_in_days = 0;
-}
-
-
-/* Adds one busy time for the given attendee. It returns FALSE if the date
- or time is invalid. Months and days count from 1. */
-gboolean
-e_meeting_time_selector_attendee_add_busy_period (EMeetingTimeSelector *mts,
- gint row,
- gint start_year,
- gint start_month,
- gint start_day,
- gint start_hour,
- gint start_minute,
- gint end_year,
- gint end_month,
- gint end_day,
- gint end_hour,
- gint end_minute,
- EMeetingTimeSelectorBusyType busy_type)
-{
- EMeetingTimeSelectorAttendee *attendee;
- EMeetingTimeSelectorPeriod period;
- gint period_in_days;
-
- g_return_val_if_fail (IS_E_MEETING_TIME_SELECTOR (mts), FALSE);
- g_return_val_if_fail (row >= 0, FALSE);
- g_return_val_if_fail (row < mts->attendees->len, FALSE);
- g_return_val_if_fail (busy_type >= 0, FALSE);
- g_return_val_if_fail (busy_type < E_MEETING_TIME_SELECTOR_BUSY_LAST, FALSE);
-
- /* Check the dates are valid. */
- if (!g_date_valid_dmy (start_day, start_month, start_year))
- return FALSE;
- if (!g_date_valid_dmy (end_day, end_month, end_year))
- return FALSE;
- if (start_hour < 0 || start_hour > 23)
- return FALSE;
- if (end_hour < 0 || end_hour > 23)
- return FALSE;
- if (start_minute < 0 || start_minute > 59)
- return FALSE;
- if (end_minute < 0 || end_minute > 59)
- return FALSE;
-
- g_date_clear (&period.start.date, 1);
- g_date_clear (&period.end.date, 1);
- g_date_set_dmy (&period.start.date, start_day, start_month, start_year);
- g_date_set_dmy (&period.end.date, end_day, end_month, end_year);
- period.start.hour = start_hour;
- period.start.minute = start_minute;
- period.end.hour = end_hour;
- period.end.minute = end_minute;
- period.busy_type = busy_type;
-
- /* Check that the start time is before or equal to the end time. */
- if (e_meeting_time_selector_compare_times (&period.start, &period.end) > 0)
- return FALSE;
-
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
- g_array_append_val (attendee->busy_periods, period);
- attendee->has_calendar_info = TRUE;
- attendee->busy_periods_sorted = FALSE;
-
- period_in_days = g_date_julian (&period.end.date) - g_date_julian (&period.start.date) + 1;
- attendee->longest_period_in_days = MAX (attendee->longest_period_in_days, period_in_days);
-
- return TRUE;
-}
-
-
-void
-e_meeting_time_selector_attendee_ensure_periods_sorted (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorAttendee *attendee)
-{
- if (attendee->busy_periods_sorted)
- return;
-
- qsort (attendee->busy_periods->data, attendee->busy_periods->len,
- sizeof (EMeetingTimeSelectorPeriod),
- e_meeting_time_selector_compare_period_starts);
- attendee->busy_periods_sorted = TRUE;
-}
-
-
-/* This compares two time periods, using their end times. */
-static gint
-e_meeting_time_selector_compare_period_starts (const void *arg1,
- const void *arg2)
-{
- EMeetingTimeSelectorPeriod *period1, *period2;
-
- period1 = (EMeetingTimeSelectorPeriod *) arg1;
- period2 = (EMeetingTimeSelectorPeriod *) arg2;
-
- return e_meeting_time_selector_compare_times (&period1->start,
- &period2->start);
-}
-
-
-/* This compares two time periods, using start and end times, mainly to see if
- they overlap at all. If they overlap it returns 0. Or -1 if arg1 < arg2.
- Or 1 if arg1 > arg2. */
-/* Currently unused. */
-#if 0
-static gint
-e_meeting_time_selector_compare_periods (const void *arg1,
- const void *arg2)
-{
- EMeetingTimeSelectorPeriod *period1, *period2;
-
- period1 = (EMeetingTimeSelectorPeriod *) arg1;
- period2 = (EMeetingTimeSelectorPeriod *) arg2;
-
- /* If period 2 starts after period 1 ends, return 1. */
- if (e_meeting_time_selector_compare_times (&period2->start, &period1->end) >= 0)
- return 1;
-
- /* If period 1 starts after period 2 ends, return -1. */
- if (e_meeting_time_selector_compare_times (&period1->start, &period2->end) >= 0)
- return -1;
-
- /* They must overlap so return 0. */
- return 0;
-}
-#endif
-
-
-static gint
-e_meeting_time_selector_compare_times (EMeetingTimeSelectorTime *time1,
- EMeetingTimeSelectorTime *time2)
-{
- gint day_comparison;
-
- day_comparison = g_date_compare (&time1->date,
- &time2->date);
- if (day_comparison != 0)
- return day_comparison;
-
- if (time1->hour < time2->hour)
- return -1;
- if (time1->hour > time2->hour)
- return 1;
-
- if (time1->minute < time2->minute)
- return -1;
- if (time1->minute > time2->minute)
- return 1;
-
- /* The start times are exactly the same. */
- return 0;
-}
-
-
-/*
- * DEBUGGING ROUTINES - functions to output various bits of data.
- */
-
-#ifdef E_MEETING_TIME_SELECTOR_DEBUG
-
-/* Debugging function to dump information on all attendees. */
-void
-e_meeting_time_selector_dump (EMeetingTimeSelector *mts)
-{
- EMeetingTimeSelectorAttendee *attendee;
- EMeetingTimeSelectorPeriod *period;
- gint row, period_num;
- gchar buffer[128];
-
- g_return_if_fail (IS_E_MEETING_TIME_SELECTOR (mts));
-
- g_print ("\n\nAttendee Information:\n");
-
- for (row = 0; row < mts->attendees->len; row++) {
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
- g_print ("Attendee: %s\n", attendee->name);
- g_print (" Longest Busy Period: %i days\n",
- attendee->longest_period_in_days);
-
- e_meeting_time_selector_attendee_ensure_periods_sorted (mts, attendee);
-#if 1
- for (period_num = 0;
- period_num < attendee->busy_periods->len;
- period_num++) {
- period = &g_array_index (attendee->busy_periods,
- EMeetingTimeSelectorPeriod,
- period_num);
-
- g_date_strftime (buffer, 128, "%A, %B %d, %Y",
- &period->start.date);
- g_print (" Start: %s %i:%02i\n", buffer,
- period->start.hour, period->start.minute);
-
- g_date_strftime (buffer, 128, "%A, %B %d, %Y",
- &period->end.date);
- g_print (" End : %s %i:%02i\n", buffer,
- period->end.hour, period->end.minute);
- }
-#endif
- }
-
-}
-
-
-/* This formats a EMeetingTimeSelectorTime in a string and returns it.
- Note that it uses a static buffer. */
-gchar*
-e_meeting_time_selector_dump_time (EMeetingTimeSelectorTime *mtstime)
-{
- static gchar buffer[128];
-
- gchar buffer2[128];
-
- g_date_strftime (buffer, 128, "%A, %B %d, %Y", &mtstime->date);
- sprintf (buffer2, " at %i:%02i", (gint) mtstime->hour,
- (gint) mtstime->minute);
- strcat (buffer, buffer2);
-
- return buffer;
-}
-
-
-/* This formats a GDate in a string and returns it.
- Note that it uses a static buffer. */
-gchar*
-e_meeting_time_selector_dump_date (GDate *date)
-{
- static gchar buffer[128];
-
- g_date_strftime (buffer, 128, "%A, %B %d, %Y", date);
- return buffer;
-}
-
-#endif /* E_MEETING_TIME_SELECTOR_DEBUG */
-
-
-static void
-e_meeting_time_selector_on_invite_others_button_clicked (GtkWidget *button,
- EMeetingTimeSelector *mts)
-{
-
-
-}
-
-
-static void
-e_meeting_time_selector_on_options_button_clicked (GtkWidget *button,
- EMeetingTimeSelector *mts)
-{
- gtk_menu_popup (GTK_MENU (mts->options_menu), NULL, NULL,
- e_meeting_time_selector_options_menu_position_callback,
- mts, 1, GDK_CURRENT_TIME);
-}
-
-
-static void
-e_meeting_time_selector_options_menu_position_callback (GtkMenu *menu,
- gint *x,
- gint *y,
- gpointer user_data)
-{
- EMeetingTimeSelector *mts;
- GtkRequisition menu_requisition;
- gint max_x, max_y;
-
- mts = E_MEETING_TIME_SELECTOR (user_data);
-
- /* Calculate our preferred position. */
- gdk_window_get_origin (mts->options_button->window, x, y);
- *y += mts->options_button->allocation.height;
-
- /* Now make sure we are on the screen. */
- gtk_widget_size_request (mts->options_menu, &menu_requisition);
- max_x = MAX (0, gdk_screen_width () - menu_requisition.width);
- max_y = MAX (0, gdk_screen_height () - menu_requisition.height);
- *x = CLAMP (*x, 0, max_x);
- *y = CLAMP (*y, 0, max_y);
-}
-
-
-static void
-e_meeting_time_selector_on_update_free_busy (GtkWidget *button,
- EMeetingTimeSelector *mts)
-{
-
- /* Make sure the menu pops down, which doesn't happen by default if
- keyboard accelerators are used. */
- if (GTK_WIDGET_VISIBLE (mts->options_menu))
- gtk_menu_popdown (GTK_MENU (mts->options_menu));
-}
-
-
-static void
-e_meeting_time_selector_on_autopick_button_clicked (GtkWidget *button,
- EMeetingTimeSelector *mts)
-{
- gtk_menu_popup (GTK_MENU (mts->autopick_menu), NULL, NULL,
- e_meeting_time_selector_autopick_menu_position_callback,
- mts, 1, GDK_CURRENT_TIME);
-}
-
-
-static void
-e_meeting_time_selector_autopick_menu_position_callback (GtkMenu *menu,
- gint *x,
- gint *y,
- gpointer user_data)
-{
- EMeetingTimeSelector *mts;
- GtkRequisition menu_requisition;
- gint max_x, max_y;
-
- mts = E_MEETING_TIME_SELECTOR (user_data);
-
- /* Calculate our preferred position. */
- gdk_window_get_origin (mts->autopick_button->window, x, y);
- *y += mts->autopick_button->allocation.height;
-
- /* Now make sure we are on the screen. */
- gtk_widget_size_request (mts->autopick_menu, &menu_requisition);
- max_x = MAX (0, gdk_screen_width () - menu_requisition.width);
- max_y = MAX (0, gdk_screen_height () - menu_requisition.height);
- *x = CLAMP (*x, 0, max_x);
- *y = CLAMP (*y, 0, max_y);
-}
-
-
-static void
-e_meeting_time_selector_on_autopick_option_toggled (GtkWidget *button,
- EMeetingTimeSelector *mts)
-{
- /* Make sure the menu pops down, which doesn't happen by default if
- keyboard accelerators are used. */
- if (GTK_WIDGET_VISIBLE (mts->autopick_menu))
- gtk_menu_popdown (GTK_MENU (mts->autopick_menu));
-}
-
-
-static void
-e_meeting_time_selector_on_prev_button_clicked (GtkWidget *button,
- EMeetingTimeSelector *mts)
-{
- e_meeting_time_selector_autopick (mts, FALSE);
-}
-
-
-static void
-e_meeting_time_selector_on_next_button_clicked (GtkWidget *button,
- EMeetingTimeSelector *mts)
-{
- e_meeting_time_selector_autopick (mts, TRUE);
-}
-
-
-/* This tries to find the previous or next meeting time for which all
- attendees will be available. */
-static void
-e_meeting_time_selector_autopick (EMeetingTimeSelector *mts,
- gboolean forward)
-{
- EMeetingTimeSelectorTime start_time, end_time, *resource_free;
- EMeetingTimeSelectorAttendee *attendee;
- EMeetingTimeSelectorPeriod *period;
- EMeetingTimeSelectorAutopickOption autopick_option;
- gint duration_days, duration_hours, duration_minutes, row;
- gboolean meeting_time_ok, skip_optional = FALSE;
- gboolean need_one_resource = FALSE, found_resource;
-
- /* Get the current meeting duration in days + hours + minutes. */
- e_meeting_time_selector_calculate_time_difference (&mts->meeting_start_time, &mts->meeting_end_time, &duration_days, &duration_hours, &duration_minutes);
-
- /* Find the first appropriate start time. */
- start_time = mts->meeting_start_time;
- if (forward)
- e_meeting_time_selector_find_nearest_interval (mts, &start_time, &end_time, duration_days, duration_hours, duration_minutes);
- else
- e_meeting_time_selector_find_nearest_interval_backward (mts, &start_time, &end_time, duration_days, duration_hours, duration_minutes);
-
- /* Determine if we can skip optional people and if we only need one
- resource based on the autopick option. */
- autopick_option = e_meeting_time_selector_get_autopick_option (mts);
- if (autopick_option == E_MEETING_TIME_SELECTOR_REQUIRED_PEOPLE
- || autopick_option == E_MEETING_TIME_SELECTOR_REQUIRED_PEOPLE_AND_ONE_RESOURCE)
- skip_optional = TRUE;
- if (autopick_option == E_MEETING_TIME_SELECTOR_ALL_PEOPLE_AND_ONE_RESOURCE
- || autopick_option == E_MEETING_TIME_SELECTOR_REQUIRED_PEOPLE_AND_ONE_RESOURCE)
- need_one_resource = TRUE;
-
- /* Keep moving forward or backward until we find a possible meeting
- time. */
- for (;;) {
- meeting_time_ok = TRUE;
- found_resource = FALSE;
- resource_free = NULL;
-
- /* Step through each attendee, checking if the meeting time
- intersects one of the attendees busy periods. */
- for (row = 0; row < mts->attendees->len; row++) {
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee,
- row);
-
- /* Skip optional people if they don't matter. */
- if (skip_optional && attendee->type == E_MEETING_TIME_SELECTOR_OPTIONAL_PERSON)
- continue;
-
- period = e_meeting_time_selector_find_time_clash (mts, attendee, &start_time, &end_time);
-
- if (need_one_resource && attendee->type == E_MEETING_TIME_SELECTOR_RESOURCE) {
- if (period) {
- /* We want to remember the closest
- prev/next time that one resource is
- available, in case we don't find any
- free resources. */
- if (forward) {
- if (!resource_free || e_meeting_time_selector_compare_times (resource_free, &period->end) > 0)
- resource_free = &period->end;
- } else {
- if (!resource_free || e_meeting_time_selector_compare_times (resource_free, &period->start) < 0)
- resource_free = &period->start;
- }
-
- } else {
- found_resource = TRUE;
- }
- } else if (period) {
- /* Skip the period which clashed. */
- if (forward) {
- start_time = period->end;
- } else {
- start_time = period->start;
- e_meeting_time_selector_adjust_time (&start_time, -duration_days, -duration_hours, -duration_minutes);
- }
- meeting_time_ok = FALSE;
- break;
- }
- }
-
- /* Check that we found one resource if necessary. If not, skip
- to the closest time that a resource is free. Note that if
- there are no resources, resource_free will never get set,
- so we assume the meeting time is OK. */
- if (meeting_time_ok && need_one_resource && !found_resource
- && resource_free) {
- if (forward) {
- start_time = *resource_free;
- } else {
- start_time = *resource_free;
- e_meeting_time_selector_adjust_time (&start_time, -duration_days, -duration_hours, -duration_minutes);
- }
- meeting_time_ok = FALSE;
- }
-
- if (meeting_time_ok) {
- mts->meeting_start_time = start_time;
- mts->meeting_end_time = end_time;
- mts->meeting_positions_valid = FALSE;
- gtk_widget_queue_draw (mts->display_top);
- gtk_widget_queue_draw (mts->display_main);
-
- /* Make sure the time is shown. */
- e_meeting_time_selector_ensure_meeting_time_shown (mts);
-
- /* Set the times in the GnomeDateEdit widgets. */
- e_meeting_time_selector_update_start_date_edit (mts);
- e_meeting_time_selector_update_end_date_edit (mts);
- return;
- }
-
- /* Move forward to the next possible interval. */
- if (forward)
- e_meeting_time_selector_find_nearest_interval (mts, &start_time, &end_time, duration_days, duration_hours, duration_minutes);
- else
- e_meeting_time_selector_find_nearest_interval_backward (mts, &start_time, &end_time, duration_days, duration_hours, duration_minutes);
- }
-}
-
-
-static void
-e_meeting_time_selector_calculate_time_difference (EMeetingTimeSelectorTime *start,
- EMeetingTimeSelectorTime *end,
- gint *days,
- gint *hours,
- gint *minutes)
-{
- *days = g_date_julian (&end->date) - g_date_julian (&start->date);
- *hours = end->hour - start->hour;
- *minutes = end->minute - start->minute;
- if (*minutes < 0) {
- *minutes += 60;
- *hours = *hours - 1;
- }
- if (*hours < 0) {
- *hours += 24;
- *days = *days - 1;
- }
-}
-
-
-/* This moves the given time forward to the next suitable start of a meeting.
- If zoomed_out is set, this means every hour. If not every half-hour. */
-static void
-e_meeting_time_selector_find_nearest_interval (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorTime *start_time,
- EMeetingTimeSelectorTime *end_time,
- gint days, gint hours, gint mins)
-{
- gint minutes_shown;
- gboolean set_to_start_of_working_day = FALSE;
-
- if (mts->zoomed_out) {
- start_time->hour++;
- start_time->minute = 0;
- } else {
- start_time->minute += 30;
- start_time->minute -= start_time->minute % 30;
- }
- e_meeting_time_selector_fix_time_overflows (start_time);
-
- *end_time = *start_time;
- e_meeting_time_selector_adjust_time (end_time, days, hours, mins);
-
- /* Check if the interval is less than a day as seen in the display.
- If it isn't we don't worry about the working day. */
- if (!mts->working_hours_only || days > 0)
- return;
- minutes_shown = (mts->day_end_hour - mts->day_start_hour) * 60;
- minutes_shown += mts->day_end_minute - mts->day_start_minute;
- if (hours * 60 + mins > minutes_shown)
- return;
-
- /* If the meeting time finishes past the end of the working day, move
- onto the start of the next working day. If the meeting time starts
- before the working day, move it on as well. */
- if (start_time->hour > mts->day_end_hour
- || (start_time->hour == mts->day_end_hour
- && start_time->minute > mts->day_end_minute)
- || end_time->hour > mts->day_end_hour
- || (end_time->hour == mts->day_end_hour
- && end_time->minute > mts->day_end_minute)) {
- g_date_add_days (&start_time->date, 1);
- set_to_start_of_working_day = TRUE;
- } else if (start_time->hour < mts->day_start_hour
- || (start_time->hour == mts->day_start_hour
- && start_time->minute < mts->day_start_minute)) {
- set_to_start_of_working_day = TRUE;
- }
-
- if (set_to_start_of_working_day) {
- start_time->hour = mts->day_start_hour;
- start_time->minute = mts->day_start_minute;
-
- if (mts->zoomed_out) {
- if (start_time->minute > 0) {
- start_time->hour++;
- start_time->minute = 0;
- }
- } else {
- start_time->minute += 29;
- start_time->minute -= start_time->minute % 30;
- }
- e_meeting_time_selector_fix_time_overflows (start_time);
-
- *end_time = *start_time;
- e_meeting_time_selector_adjust_time (end_time, days, hours, mins);
- }
-}
-
-
-/* This moves the given time backward to the next suitable start of a meeting.
- If zoomed_out is set, this means every hour. If not every half-hour. */
-static void
-e_meeting_time_selector_find_nearest_interval_backward (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorTime *start_time,
- EMeetingTimeSelectorTime *end_time,
- gint days, gint hours, gint mins)
-{
- gint new_hour, minutes_shown;
- gboolean set_to_end_of_working_day = FALSE;
-
- new_hour = start_time->hour;
- if (mts->zoomed_out) {
- if (start_time->minute == 0)
- new_hour--;
- start_time->minute = 0;
- } else {
- if (start_time->minute == 0) {
- start_time->minute = 30;
- new_hour--;
- } else if (start_time->minute <= 30)
- start_time->minute = 0;
- else
- start_time->minute = 30;
- }
- if (new_hour < 0) {
- new_hour += 24;
- g_date_subtract_days (&start_time->date, 1);
- }
- start_time->hour = new_hour;
-
- *end_time = *start_time;
- e_meeting_time_selector_adjust_time (end_time, days, hours, mins);
-
- /* Check if the interval is less than a day as seen in the display.
- If it isn't we don't worry about the working day. */
- if (!mts->working_hours_only || days > 0)
- return;
- minutes_shown = (mts->day_end_hour - mts->day_start_hour) * 60;
- minutes_shown += mts->day_end_minute - mts->day_start_minute;
- if (hours * 60 + mins > minutes_shown)
- return;
-
- /* If the meeting time finishes past the end of the working day, move
- back to the end of the working day. If the meeting time starts
- before the working day, move it back to the end of the previous
- working day. */
- if (start_time->hour > mts->day_end_hour
- || (start_time->hour == mts->day_end_hour
- && start_time->minute > mts->day_end_minute)
- || end_time->hour > mts->day_end_hour
- || (end_time->hour == mts->day_end_hour
- && end_time->minute > mts->day_end_minute)) {
- set_to_end_of_working_day = TRUE;
- } else if (start_time->hour < mts->day_start_hour
- || (start_time->hour == mts->day_start_hour
- && start_time->minute < mts->day_start_minute)) {
- g_date_subtract_days (&end_time->date, 1);
- set_to_end_of_working_day = TRUE;
- }
-
- if (set_to_end_of_working_day) {
- end_time->hour = mts->day_end_hour;
- end_time->minute = mts->day_end_minute;
- *start_time = *end_time;
- e_meeting_time_selector_adjust_time (start_time, -days, -hours, -mins);
-
- if (mts->zoomed_out) {
- start_time->minute = 0;
- } else {
- start_time->minute -= start_time->minute % 30;
- }
-
- *end_time = *start_time;
- e_meeting_time_selector_adjust_time (end_time, days, hours, mins);
- }
-}
-
-
-/* This adds on the given days, hours & minutes to a EMeetingTimeSelectorTime.
- It is used to calculate the end of a period given a start & duration.
- Days, hours & minutes can be negative, to move backwards, but they should
- be within normal ranges, e.g. hours should be between -23 and 23. */
-static void
-e_meeting_time_selector_adjust_time (EMeetingTimeSelectorTime *mtstime,
- gint days, gint hours, gint minutes)
-{
- gint new_hours, new_minutes;
-
- /* We have to handle negative values for hous and minutes here, since
- EMeetingTimeSelectorTime uses guint8s to store them. */
- new_minutes = mtstime->minute + minutes;
- if (new_minutes < 0) {
- new_minutes += 60;
- hours -= 1;
- }
-
- new_hours = mtstime->hour + hours;
- if (new_hours < 0) {
- new_hours += 24;
- days -= 1;
- }
-
- g_date_add_days (&mtstime->date, days);
- mtstime->hour = new_hours;
- mtstime->minute = new_minutes;
-
- e_meeting_time_selector_fix_time_overflows (mtstime);
-}
-
-
-/* This looks for any busy period of the given attendee which clashes with
- the start and end time. It uses a binary search. */
-static EMeetingTimeSelectorPeriod*
-e_meeting_time_selector_find_time_clash (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorAttendee *attendee,
- EMeetingTimeSelectorTime *start_time,
- EMeetingTimeSelectorTime *end_time)
-{
- EMeetingTimeSelectorPeriod *period;
- gint period_num;
-
- period_num = e_meeting_time_selector_find_first_busy_period (mts, attendee, &start_time->date);
-
- if (period_num == -1)
- return NULL;
-
- /* Step forward through the busy periods until we find a clash or we
- go past the end_time. */
- while (period_num < attendee->busy_periods->len) {
- period = &g_array_index (attendee->busy_periods,
- EMeetingTimeSelectorPeriod,
- period_num);
-
- /* If the period starts at or after the end time, there is no
- clash and we are finished. The busy periods are sorted by
- their start times, so all the rest will be later. */
- if (e_meeting_time_selector_compare_times (&period->start,
- end_time) >= 0)
- return NULL;
-
- /* If the period ends after the start time, we have found a
- clash. From the above test we already know the busy period
- isn't completely after the meeting time. */
- if (e_meeting_time_selector_compare_times (&period->end,
- start_time) > 0) {
- return period;
- }
-
- period_num++;
- }
-
- return NULL;
-}
-
-
-/* This subtracts the attendees longest_period_in_days from the given date,
- and does a binary search of the attendee's busy periods array to find the
- first one which could possible end on the given day or later.
- If none are found it returns -1. */
-gint
-e_meeting_time_selector_find_first_busy_period (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorAttendee *attendee,
- GDate *date)
-{
- EMeetingTimeSelectorPeriod *period;
- gint lower, upper, middle, cmp = 0;
- GDate tmp_date;
-
- /* Make sure the busy periods have been sorted. */
- e_meeting_time_selector_attendee_ensure_periods_sorted (mts, attendee);
-
- /* Calculate the first day which could have a busy period which
- continues onto our given date. */
- tmp_date = *date;
- g_date_subtract_days (&tmp_date, attendee->longest_period_in_days);
-
- /* We want the first busy period which starts on tmp_date. */
- lower = 0;
- upper = attendee->busy_periods->len;
-
- if (upper == 0)
- return -1;
-
- while (lower < upper) {
- middle = (lower + upper) >> 1;
-
- period = &g_array_index (attendee->busy_periods,
- EMeetingTimeSelectorPeriod, middle);
-
- cmp = g_date_compare (&tmp_date, &period->start.date);
-
- if (cmp == 0)
- break;
- else if (cmp < 0)
- upper = middle;
- else
- lower = middle + 1;
- }
-
- /* There may be several busy periods on the same day so we step
- backwards to the first one. */
- if (cmp == 0) {
- while (middle > 0) {
- period = &g_array_index (attendee->busy_periods,
- EMeetingTimeSelectorPeriod, middle - 1);
- if (g_date_compare (&tmp_date, &period->start.date) != 0)
- break;
- middle--;
- }
- } else if (cmp > 0) {
- /* This means we couldn't find a period on the given day, and
- the last one we looked at was before it, so if there are
- any more periods after this one we return it. */
- middle++;
- if (attendee->busy_periods->len <= middle)
- return -1;
- }
-
- return middle;
-}
-
-
-static void
-e_meeting_time_selector_on_zoomed_out_toggled (GtkWidget *menuitem,
- EMeetingTimeSelector *mts)
-{
- /* Make sure the menu pops down, which doesn't happen by default if
- keyboard accelerators are used. */
- if (GTK_WIDGET_VISIBLE (mts->options_menu))
- gtk_menu_popdown (GTK_MENU (mts->options_menu));
-
- e_meeting_time_selector_set_zoomed_out (mts, GTK_CHECK_MENU_ITEM (menuitem)->active);
-}
-
-
-static void
-e_meeting_time_selector_on_working_hours_toggled (GtkWidget *menuitem,
- EMeetingTimeSelector *mts)
-{
- /* Make sure the menu pops down, which doesn't happen by default if
- keyboard accelerators are used. */
- if (GTK_WIDGET_VISIBLE (mts->options_menu))
- gtk_menu_popdown (GTK_MENU (mts->options_menu));
-
- e_meeting_time_selector_set_working_hours_only (mts, GTK_CHECK_MENU_ITEM (menuitem)->active);
-}
-
-
-/* This recalculates day_width, first_hour_shown and last_hour_shown. */
-static void
-e_meeting_time_selector_recalc_grid (EMeetingTimeSelector *mts)
-{
- if (mts->working_hours_only) {
- mts->first_hour_shown = mts->day_start_hour;
- mts->last_hour_shown = mts->day_end_hour;
- if (mts->day_end_minute != 0)
- mts->last_hour_shown += 1;
- } else {
- mts->first_hour_shown = 0;
- mts->last_hour_shown = 24;
- }
-
- /* In the brief view we use the nearest hours divisible by 3. */
- if (mts->zoomed_out) {
- mts->first_hour_shown -= mts->first_hour_shown % 3;
- mts->last_hour_shown += 2;
- mts->last_hour_shown -= mts->last_hour_shown % 3;
- }
-
- mts->day_width = mts->col_width * (mts->last_hour_shown - mts->first_hour_shown);
- if (mts->zoomed_out)
- mts->day_width /= 3;
-
- /* Add one pixel for the extra vertical grid line. */
- mts->day_width++;
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (mts->display_top),
- 0, 0,
- mts->day_width * E_MEETING_TIME_SELECTOR_DAYS_SHOWN,
- mts->row_height * 3);
- e_meeting_time_selector_update_main_canvas_scroll_region (mts);
-
- e_meeting_time_selector_recalc_date_format (mts);
- mts->meeting_positions_valid = FALSE;
-}
-
-
-/* This saves the first visible time in the given EMeetingTimeSelectorTime. */
-static void
-e_meeting_time_selector_save_position (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorTime *mtstime)
-{
- gint scroll_x, scroll_y;
-
- gnome_canvas_get_scroll_offsets (GNOME_CANVAS (mts->display_main),
- &scroll_x, &scroll_y);
- e_meeting_time_selector_calculate_time (mts, scroll_x, mtstime);
-}
-
-
-/* This restores a saved position. */
-static void
-e_meeting_time_selector_restore_position (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorTime *mtstime)
-{
- gint scroll_x, scroll_y, new_scroll_x;
-
- new_scroll_x = e_meeting_time_selector_calculate_time_position (mts,
- mtstime);
- gnome_canvas_get_scroll_offsets (GNOME_CANVAS (mts->display_main),
- &scroll_x, &scroll_y);
- gnome_canvas_scroll_to (GNOME_CANVAS (mts->display_main),
- new_scroll_x, scroll_y);
-}
-
-
-/* This returns the x pixel coords of the meeting time in the entire scroll
- region. It recalculates them if they have been marked as invalid.
- If it returns FALSE then no meeting time is set or the meeting time is
- not visible in the current scroll area. */
-gboolean
-e_meeting_time_selector_get_meeting_time_positions (EMeetingTimeSelector *mts,
- gint *start_x,
- gint *end_x)
-{
- if (mts->meeting_positions_valid) {
- if (mts->meeting_positions_in_scroll_area) {
- *start_x = mts->meeting_start_x;
- *end_x = mts->meeting_end_x;
- return TRUE;
- } else {
- return FALSE;
- }
- }
-
- mts->meeting_positions_valid = TRUE;
-
- /* Check if the days aren't in our current range. */
- if (g_date_compare (&mts->meeting_start_time.date, &mts->last_date_shown) > 0
- || g_date_compare (&mts->meeting_end_time.date, &mts->first_date_shown) < 0) {
- mts->meeting_positions_in_scroll_area = FALSE;
- return FALSE;
- }
-
- mts->meeting_positions_in_scroll_area = TRUE;
- *start_x = mts->meeting_start_x = e_meeting_time_selector_calculate_time_position (mts, &mts->meeting_start_time);
- *end_x = mts->meeting_end_x = e_meeting_time_selector_calculate_time_position (mts, &mts->meeting_end_time);
-
- return TRUE;
-}
-
-
-/* This recalculates the date format to used, by computing the width of the
- longest date strings in the widget's font and seeing if they fit. */
-static void
-e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
-{
- GDate date;
- gint max_date_width, base_width, max_weekday_width, max_month_width;
- gint weekday, month;
- gchar buffer[128];
- GdkFont *font;
-
- font = GTK_WIDGET (mts)->style->font;
-
- /* Check if we will be able to display the full date strings. */
- mts->date_format = E_MEETING_TIME_SELECTOR_DATE_SHORT;
- g_date_clear (&date, 1);
- g_date_set_dmy (&date, 20, 1, 2000);
-
- /* Calculate the maximum date width we can fit into the display. */
- max_date_width = mts->day_width - 2;
-
- /* First compute the width of the date string without the day or
- month names. */
- g_date_strftime (buffer, 128, ", %d, %Y", &date);
- base_width = gdk_string_width (font, buffer);
-
- /* If that doesn't fit just return. We have to use the short format.
- If that doesn't fit it will just be clipped. */
- if (gdk_string_width (font, buffer) > max_date_width)
- return;
-
- /* Now find the biggest weekday name. We start on any day and just
- go through seven days. */
- max_weekday_width = 0;
- for (weekday = 1; weekday <= 7; weekday++) {
- g_date_strftime (buffer, 128, "%A", &date);
- max_weekday_width = MAX (max_weekday_width,
- gdk_string_width (font, buffer));
- g_date_add_days (&date, 1);
- }
-
- /* Now find the biggest month name. */
- max_month_width = 0;
- for (month = 1; month <= 12; month++) {
- g_date_set_month (&date, month);
- g_date_strftime (buffer, 128, "%B", &date);
- max_month_width = MAX (max_month_width,
- gdk_string_width (font, buffer));
- }
-
- /* See if we can use the full date. */
- if (base_width + max_month_width + max_weekday_width <= max_date_width) {
- mts->date_format = E_MEETING_TIME_SELECTOR_DATE_FULL;
- return;
- }
-
- /* Now try it with abbreviated weekday names. */
- g_date_strftime (buffer, 128, " %x", &date);
- base_width = gdk_string_width (font, buffer);
-
- max_weekday_width = 0;
- for (weekday = 1; weekday <= 7; weekday++) {
- g_date_strftime (buffer, 128, "%a", &date);
- max_weekday_width = MAX (max_weekday_width,
- gdk_string_width (font, buffer));
- g_date_add_days (&date, 1);
- }
-
- if (base_width + max_weekday_width <= max_date_width)
- mts->date_format = E_MEETING_TIME_SELECTOR_DATE_ABBREVIATED_DAY;
-}
-
-
-/* Turn off the background of the canvas windows. This reduces flicker
- considerably when scrolling. (Why isn't it in GnomeCanvas?). */
-static void
-e_meeting_time_selector_on_canvas_realized (GtkWidget *widget,
- EMeetingTimeSelector *mts)
-{
- gdk_window_set_back_pixmap (GTK_LAYOUT (widget)->bin_window,
- NULL, FALSE);
-}
-
-
-/* This is called when the meeting start time GnomeDateEdit is changed,
- either via the "date_changed". "time_changed" or "activate" signals on one
- of the GtkEntry widgets. So don't use the widget parameter since it may be
- one of the child GtkEntry widgets. */
-static void
-e_meeting_time_selector_on_start_time_changed (GtkWidget *widget,
- EMeetingTimeSelector *mts)
-{
- gint duration_days, duration_hours, duration_minutes;
- EMeetingTimeSelectorTime mtstime;
- time_t newtime;
- struct tm *newtime_tm;
-
- newtime = gnome_date_edit_get_date (GNOME_DATE_EDIT (mts->start_date_edit));
- newtime_tm = localtime (&newtime);
- g_date_clear (&mtstime.date, 1);
- g_date_set_time (&mtstime.date, newtime);
- mtstime.hour = newtime_tm->tm_hour;
- mtstime.minute = newtime_tm->tm_min;
-
- /* If the time hasn't changed, just return. */
- if (e_meeting_time_selector_compare_times (&mtstime, &mts->meeting_start_time) == 0)
- return;
-
- /* Calculate the current meeting duration. */
- e_meeting_time_selector_calculate_time_difference (&mts->meeting_start_time, &mts->meeting_end_time, &duration_days, &duration_hours, &duration_minutes);
-
- /* Set the new start time. */
- mts->meeting_start_time = mtstime;
-
- /* Update the end time so the meeting duration stays the same. */
- mts->meeting_end_time = mts->meeting_start_time;
- e_meeting_time_selector_adjust_time (&mts->meeting_end_time, duration_days, duration_hours, duration_minutes);
- e_meeting_time_selector_update_end_date_edit (mts);
-
- mts->meeting_positions_valid = FALSE;
- e_meeting_time_selector_ensure_meeting_time_shown (mts);
- gtk_widget_queue_draw (mts->display_top);
- gtk_widget_queue_draw (mts->display_main);
-}
-
-
-/* This is called when the meeting end time GnomeDateEdit is changed,
- either via the "date_changed", "time_changed" or "activate" signals on one
- of the GtkEntry widgets. So don't use the widget parameter since it may be
- one of the child GtkEntry widgets. */
-static void
-e_meeting_time_selector_on_end_time_changed (GtkWidget *widget,
- EMeetingTimeSelector *mts)
-{
- EMeetingTimeSelectorTime mtstime;
- time_t newtime;
- struct tm *newtime_tm;
-
- newtime = gnome_date_edit_get_date (GNOME_DATE_EDIT (mts->end_date_edit));
- newtime_tm = localtime (&newtime);
- g_date_clear (&mtstime.date, 1);
- g_date_set_time (&mtstime.date, newtime);
- mtstime.hour = newtime_tm->tm_hour;
- mtstime.minute = newtime_tm->tm_min;
-
- /* If the time hasn't changed, just return. */
- if (e_meeting_time_selector_compare_times (&mtstime, &mts->meeting_end_time) == 0)
- return;
-
- /* Set the new end time. */
- mts->meeting_end_time = mtstime;
-
- /* If the start time is after the end time, set it to the same time. */
- if (e_meeting_time_selector_compare_times (&mtstime, &mts->meeting_start_time) < 0) {
- /* We set it first, before updating the widget, so the signal
- handler will just return. */
- mts->meeting_start_time = mtstime;
- e_meeting_time_selector_update_start_date_edit (mts);
- }
-
- mts->meeting_positions_valid = FALSE;
- e_meeting_time_selector_ensure_meeting_time_shown (mts);
- gtk_widget_queue_draw (mts->display_top);
- gtk_widget_queue_draw (mts->display_main);
-}
-
-
-/* This updates the ranges shown in the GnomeDateEdit popup menus, according
- to working_hours_only etc. */
-static void
-e_meeting_time_selector_update_date_popup_menus (EMeetingTimeSelector *mts)
-{
- GnomeDateEdit *start_edit, *end_edit;
- gint low_hour, high_hour;
-
- start_edit = GNOME_DATE_EDIT (mts->start_date_edit);
- end_edit = GNOME_DATE_EDIT (mts->end_date_edit);
-
- if (mts->working_hours_only) {
- low_hour = mts->day_start_hour;
- high_hour = mts->day_end_hour;
- } else {
- low_hour = 0;
- high_hour = 23;
- }
-
- gnome_date_edit_set_popup_range (start_edit, low_hour, high_hour);
- gnome_date_edit_set_popup_range (end_edit, low_hour, high_hour);
-}
-
-
-static void
-e_meeting_time_selector_on_canvas_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation,
- EMeetingTimeSelector *mts)
-{
- e_meeting_time_selector_update_main_canvas_scroll_region (mts);
-
- e_meeting_time_selector_ensure_meeting_time_shown (mts);
-}
-
-
-static void
-e_meeting_time_selector_on_attendees_list_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation,
- EMeetingTimeSelector *mts)
-{
- e_meeting_time_selector_update_attendees_list_scroll_region (mts);
- e_meeting_time_selector_update_attendees_list_positions (mts);
-}
-
-
-/* This updates the list canvas scroll region according to the number of
- attendees. If the total height needed is less than the height of the canvas,
- we must use the height of the canvas, or it causes problems. */
-static void
-e_meeting_time_selector_update_attendees_list_scroll_region (EMeetingTimeSelector *mts)
-{
- gint height, canvas_width, canvas_height;
-
- height = mts->row_height * mts->attendees->len;
- canvas_width = GTK_WIDGET (mts->attendees_list)->allocation.width;
- canvas_height = GTK_WIDGET (mts->attendees_list)->allocation.height;
-
- height = MAX (height, canvas_height);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (mts->attendees_list),
- 0, 0,
- canvas_width,
- height);
-}
-
-
-/* This updates the canvas scroll regions according to the number of attendees.
- If the total height needed is less than the height of the canvas, we must
- use the height of the canvas, or it causes problems. */
-static void
-e_meeting_time_selector_update_main_canvas_scroll_region (EMeetingTimeSelector *mts)
-{
- gint height, canvas_height, list_width;
-
- height = mts->row_height * mts->attendees->len;
- canvas_height = GTK_WIDGET (mts->display_main)->allocation.height;
- list_width = GTK_WIDGET (mts->attendees_list)->allocation.width;
-
- height = MAX (height, canvas_height);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (mts->attendees_list),
- 0, 0,
- list_width,
- height);
- gnome_canvas_set_scroll_region (GNOME_CANVAS (mts->display_main),
- 0, 0,
- mts->day_width * E_MEETING_TIME_SELECTOR_DAYS_SHOWN,
- height);
-}
-
-
-/* This changes the meeting time based on the given x coordinate and whether
- we are dragging the start or end bar. It returns the new position, which
- will be swapped if the start bar is dragged past the end bar or vice versa.
- It make sure the meeting time is never dragged outside the visible canvas
- area. */
-void
-e_meeting_time_selector_drag_meeting_time (EMeetingTimeSelector *mts,
- gint x)
-{
- EMeetingTimeSelectorTime first_time, last_time, drag_time, *time_to_set;
- gint scroll_x, scroll_y, canvas_width;
- gboolean set_both_times = FALSE;
-
- /* Get the x coords of visible part of the canvas. */
- gnome_canvas_get_scroll_offsets (GNOME_CANVAS (mts->display_main),
- &scroll_x, &scroll_y);
- canvas_width = mts->display_main->allocation.width;
-
- /* Save the x coordinate for the timeout handler. */
- mts->last_drag_x = (x < scroll_x) ? x - scroll_x
- : x - scroll_x - canvas_width + 1;
-
- /* Check if the mouse is off the edge of the canvas. */
- if (x < scroll_x || x > scroll_x + canvas_width) {
- /* If we haven't added a timeout function, add one. */
- if (mts->auto_scroll_timeout_id == 0) {
- mts->auto_scroll_timeout_id = g_timeout_add (60, e_meeting_time_selector_timeout_handler, mts);
- mts->scroll_count = 0;
-
- /* Call the handler to start scrolling now. */
- e_meeting_time_selector_timeout_handler (mts);
- return;
- }
- } else {
- e_meeting_time_selector_remove_timeout (mts);
- }
-
- /* Calculate the minimum & maximum times we can use, based on the
- scroll offsets and whether zoomed_out is set. */
- e_meeting_time_selector_calculate_time (mts, scroll_x, &first_time);
- e_meeting_time_selector_calculate_time (mts, scroll_x + canvas_width - 1,
- &last_time);
- if (mts->zoomed_out) {
- if (first_time.minute > 30)
- first_time.hour++;
- first_time.minute = 0;
- last_time.minute = 0;
- } else {
- first_time.minute += 15;
- first_time.minute -= first_time.minute % 30;
- last_time.minute -= last_time.minute % 30;
- }
- e_meeting_time_selector_fix_time_overflows (&first_time);
- e_meeting_time_selector_fix_time_overflows (&last_time);
-
- /* Calculate the time from x coordinate. */
- e_meeting_time_selector_calculate_time (mts, x, &drag_time);
-
- /* Calculate the nearest half-hour or hour, depending on whether
- zoomed_out is set. */
- if (mts->zoomed_out) {
- if (drag_time.minute > 30)
- drag_time.hour++;
- drag_time.minute = 0;
- } else {
- drag_time.minute += 15;
- drag_time.minute -= drag_time.minute % 30;
- }
- e_meeting_time_selector_fix_time_overflows (&drag_time);
-
- /* Now make sure we are between first_time & last_time. */
- if (e_meeting_time_selector_compare_times (&drag_time, &first_time) < 0)
- drag_time = first_time;
- if (e_meeting_time_selector_compare_times (&drag_time, &last_time) > 0)
- drag_time = last_time;
-
- /* Set the meeting start or end time to drag_time. */
- if (mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_START)
- time_to_set = &mts->meeting_start_time;
- else
- time_to_set = &mts->meeting_end_time;
-
- /* If the time is unchanged, just return. */
- if (e_meeting_time_selector_compare_times (time_to_set, &drag_time) == 0)
- return;
-
- *time_to_set = drag_time;
-
- /* Check if the start time and end time need to be switched. */
- if (e_meeting_time_selector_compare_times (&mts->meeting_start_time,
- &mts->meeting_end_time) > 0) {
- drag_time = mts->meeting_start_time;
- mts->meeting_start_time = mts->meeting_end_time;
- mts->meeting_end_time = drag_time;
-
- if (mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_START)
- mts->dragging_position = E_MEETING_TIME_SELECTOR_POS_END;
- else
- mts->dragging_position = E_MEETING_TIME_SELECTOR_POS_START;
-
- set_both_times = TRUE;
- }
-
- /* Mark the calculated positions as invalid. */
- mts->meeting_positions_valid = FALSE;
-
- /* Redraw the canvases. */
- gtk_widget_queue_draw (mts->display_top);
- gtk_widget_queue_draw (mts->display_main);
-
- /* Set the times in the GnomeDateEdit widgets. */
- if (set_both_times
- || mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_START)
- e_meeting_time_selector_update_start_date_edit (mts);
-
- if (set_both_times
- || mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_END)
- e_meeting_time_selector_update_end_date_edit (mts);
-}
-
-
-/* This is the timeout function which handles auto-scrolling when the user is
- dragging one of the meeting time vertical bars outside the left or right
- edge of the canvas. */
-static gboolean
-e_meeting_time_selector_timeout_handler (gpointer data)
-{
- EMeetingTimeSelector *mts;
- EMeetingTimeSelectorTime drag_time, *time_to_set;
- gint scroll_x, max_scroll_x, scroll_y, canvas_width;
- gint scroll_speed, scroll_offset;
- gboolean set_both_times = FALSE;
-
- mts = E_MEETING_TIME_SELECTOR (data);
-
- GDK_THREADS_ENTER ();
-
- /* Return if we don't need to scroll yet. */
- if (mts->scroll_count-- > 0) {
- GDK_THREADS_LEAVE ();
- return TRUE;
- }
-
- /* Get the x coords of visible part of the canvas. */
- gnome_canvas_get_scroll_offsets (GNOME_CANVAS (mts->display_main),
- &scroll_x, &scroll_y);
- canvas_width = mts->display_main->allocation.width;
-
- /* Calculate the scroll delay, between 0 and MAX_SCROLL_SPEED. */
- scroll_speed = abs (mts->last_drag_x / E_MEETING_TIME_SELECTOR_SCROLL_INCREMENT_WIDTH);
- scroll_speed = MIN (scroll_speed,
- E_MEETING_TIME_SELECTOR_MAX_SCROLL_SPEED);
-
- /* Reset the scroll count. */
- mts->scroll_count = E_MEETING_TIME_SELECTOR_MAX_SCROLL_SPEED - scroll_speed;
-
- /* Calculate how much we need to scroll. */
- if (mts->last_drag_x >= 0)
- scroll_offset = mts->col_width;
- else
- scroll_offset = -mts->col_width;
-
- scroll_x += scroll_offset;
- max_scroll_x = (mts->day_width * E_MEETING_TIME_SELECTOR_DAYS_SHOWN)
- - canvas_width;
- scroll_x = CLAMP (scroll_x, 0, max_scroll_x);
-
- /* Calculate the minimum or maximum visible time in the canvas, which
- we will now set the dragged time to. */
- if (scroll_offset > 0) {
- e_meeting_time_selector_calculate_time (mts,
- scroll_x + canvas_width - 1,
- &drag_time);
- if (mts->zoomed_out) {
- drag_time.minute = 0;
- } else {
- drag_time.minute -= drag_time.minute % 30;
- }
- } else {
- e_meeting_time_selector_calculate_time (mts, scroll_x,
- &drag_time);
- if (mts->zoomed_out) {
- if (drag_time.minute > 30)
- drag_time.hour++;
- drag_time.minute = 0;
- } else {
- drag_time.minute += 15;
- drag_time.minute -= drag_time.minute % 30;
- }
- }
- e_meeting_time_selector_fix_time_overflows (&drag_time);
-
- /* Set the meeting start or end time to drag_time. */
- if (mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_START)
- time_to_set = &mts->meeting_start_time;
- else
- time_to_set = &mts->meeting_end_time;
-
- /* If the time is unchanged, just return. */
- if (e_meeting_time_selector_compare_times (time_to_set, &drag_time) == 0) {
- GDK_THREADS_LEAVE ();
- return TRUE;
- }
-
- *time_to_set = drag_time;
-
- /* Check if the start time and end time need to be switched. */
- if (e_meeting_time_selector_compare_times (&mts->meeting_start_time, &mts->meeting_end_time) > 0) {
- drag_time = mts->meeting_start_time;
- mts->meeting_start_time = mts->meeting_end_time;
- mts->meeting_end_time = drag_time;
-
- if (mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_START)
- mts->dragging_position = E_MEETING_TIME_SELECTOR_POS_END;
- else
- mts->dragging_position = E_MEETING_TIME_SELECTOR_POS_START;
-
- set_both_times = TRUE;
- }
-
- /* Mark the calculated positions as invalid. */
- mts->meeting_positions_valid = FALSE;
-
- /* Set the times in the GnomeDateEdit widgets. */
- if (set_both_times
- || mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_START)
- e_meeting_time_selector_update_start_date_edit (mts);
-
- if (set_both_times
- || mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_END)
- e_meeting_time_selector_update_end_date_edit (mts);
-
- /* Redraw the canvases. We freeze and thaw the layouts so that they
- get redrawn completely. Otherwise the pixels get scrolled left or
- right which is not good for us (since our vertical bars have been
- moved) and causes flicker. */
- gtk_layout_freeze (GTK_LAYOUT (mts->display_main));
- gtk_layout_freeze (GTK_LAYOUT (mts->display_top));
- gnome_canvas_scroll_to (GNOME_CANVAS (mts->display_main),
- scroll_x, scroll_y);
- gnome_canvas_scroll_to (GNOME_CANVAS (mts->display_top),
- scroll_x, scroll_y);
- gtk_layout_thaw (GTK_LAYOUT (mts->display_main));
- gtk_layout_thaw (GTK_LAYOUT (mts->display_top));
-
- GDK_THREADS_LEAVE ();
- return TRUE;
-}
-
-
-/* This removes our auto-scroll timeout function, if we have one installed. */
-void
-e_meeting_time_selector_remove_timeout (EMeetingTimeSelector *mts)
-{
- if (mts->auto_scroll_timeout_id) {
- g_source_remove (mts->auto_scroll_timeout_id);
- mts->auto_scroll_timeout_id = 0;
- }
-}
-
-
-/* This updates the GnomeDateEdit widget displaying the meeting start time. */
-static void
-e_meeting_time_selector_update_start_date_edit (EMeetingTimeSelector *mts)
-{
- struct tm start_tm;
- time_t start_time_t;
-
- g_date_to_struct_tm (&mts->meeting_start_time.date, &start_tm);
- start_tm.tm_hour = mts->meeting_start_time.hour;
- start_tm.tm_min = mts->meeting_start_time.minute;
- start_time_t = mktime (&start_tm);
- gnome_date_edit_set_time (GNOME_DATE_EDIT (mts->start_date_edit),
- start_time_t);
-}
-
-
-/* This updates the GnomeDateEdit widget displaying the meeting end time. */
-static void
-e_meeting_time_selector_update_end_date_edit (EMeetingTimeSelector *mts)
-{
- struct tm end_tm;
- time_t end_time_t;
-
- g_date_to_struct_tm (&mts->meeting_end_time.date, &end_tm);
- end_tm.tm_hour = mts->meeting_end_time.hour;
- end_tm.tm_min = mts->meeting_end_time.minute;
- end_time_t = mktime (&end_tm);
- gnome_date_edit_set_time (GNOME_DATE_EDIT (mts->end_date_edit),
- end_time_t);
-}
-
-
-/* This ensures that the meeting time is shown on screen, by scrolling the
- canvas and possibly by changing the range of dates shown in the canvas. */
-static void
-e_meeting_time_selector_ensure_meeting_time_shown (EMeetingTimeSelector *mts)
-{
- gint start_x, end_x, scroll_x, scroll_y, canvas_width;
- gint new_scroll_x;
- gboolean fits_in_canvas;
-
- /* Check if we need to change the range of dates shown. */
- if (g_date_compare (&mts->meeting_start_time.date,
- &mts->first_date_shown) < 0
- || g_date_compare (&mts->meeting_end_time.date,
- &mts->last_date_shown) > 0) {
- e_meeting_time_selector_update_dates_shown (mts);
- gtk_widget_queue_draw (mts->display_top);
- gtk_widget_queue_draw (mts->display_main);
- }
-
- /* If all of the meeting time is visible, just return. */
- e_meeting_time_selector_get_meeting_time_positions (mts, &start_x,
- &end_x);
- gnome_canvas_get_scroll_offsets (GNOME_CANVAS (mts->display_main),
- &scroll_x, &scroll_y);
- canvas_width = mts->display_main->allocation.width;
- if (start_x > scroll_x && end_x <= scroll_x + canvas_width)
- return;
-
- fits_in_canvas = end_x - start_x < canvas_width ? TRUE : FALSE;
-
- /* If the meeting is not entirely visible, either center it if it is
- smaller than the canvas, or show the start of it if it is big. */
- if (fits_in_canvas) {
- new_scroll_x = (start_x + end_x - canvas_width) / 2;
- } else {
- new_scroll_x = start_x;
- }
- gnome_canvas_scroll_to (GNOME_CANVAS (mts->display_main),
- new_scroll_x, scroll_y);
-}
-
-
-/* This updates the range of dates shown in the canvas, to make sure that the
- currently selected meeting time is in the range. */
-static void
-e_meeting_time_selector_update_dates_shown (EMeetingTimeSelector *mts)
-{
- mts->first_date_shown = mts->meeting_start_time.date;
- g_date_subtract_days (&mts->first_date_shown, 60);
-
- mts->last_date_shown = mts->first_date_shown;
- g_date_add_days (&mts->last_date_shown, E_MEETING_TIME_SELECTOR_DAYS_SHOWN - 1);
-}
-
-
-/* This checks if the time's hour is over 24 or its minute is over 60 and if
- so it updates the day/hour appropriately. Note that hours and minutes are
- stored in guint8's so they can't overflow by much. */
-void
-e_meeting_time_selector_fix_time_overflows (EMeetingTimeSelectorTime *mtstime)
-{
- gint hours_to_add, days_to_add;
-
- hours_to_add = mtstime->minute / 60;
- if (hours_to_add > 0) {
- mtstime->minute -= hours_to_add * 60;
- mtstime->hour += hours_to_add;
- }
-
- days_to_add = mtstime->hour / 24;
- if (days_to_add > 0) {
- mtstime->hour -= days_to_add * 24;
- g_date_add_days (&mtstime->date, days_to_add);
- }
-}
-
-
-static void
-e_meeting_time_selector_update_attendees_list_positions (EMeetingTimeSelector *mts)
-{
- EMeetingTimeSelectorAttendee *attendee;
- gint list_width, item_width;
- gint row;
-
- list_width = GTK_WIDGET (mts->attendees_list)->allocation.width;
- item_width = MAX (1, list_width - E_MEETING_TIME_SELECTOR_ICON_COLUMN_WIDTH);
- for (row = 0; row < mts->attendees->len; row++) {
- attendee = &g_array_index (mts->attendees,
- EMeetingTimeSelectorAttendee, row);
-
- gnome_canvas_item_set (attendee->text_item,
- "GnomeCanvasWidget::y", (gdouble) (row * mts->row_height),
- "GnomeCanvasWidget::width", (gdouble) item_width,
- "GnomeCanvasWidget::height", (gdouble) (mts->row_height),
- NULL);
-
- gnome_canvas_item_show (attendee->text_item);
- }
-
-}
-
-
-/*
- * CONVERSION ROUTINES - functions to convert between different coordinate
- * spaces and dates.
- */
-
-/* This takes an x pixel coordinate within the entire canvas scroll region and
- returns the date in which it falls. If day_position is not NULL it also
- returns the x coordinate within the date, relative to the visible part of
- the canvas. It is used when painting the days in the item_draw function.
- Note that it must handle negative x coordinates in case we are dragging off
- the edge of the canvas. */
-void
-e_meeting_time_selector_calculate_day_and_position (EMeetingTimeSelector *mts,
- gint x,
- GDate *date,
- gint *day_position)
-{
- gint days_from_first_shown;
-
- *date = mts->first_date_shown;
-
- if (x >= 0) {
- days_from_first_shown = x / mts->day_width;
- g_date_add_days (date, days_from_first_shown);
- if (day_position)
- *day_position = - x % mts->day_width;
- } else {
- days_from_first_shown = -x / mts->day_width + 1;
- g_date_subtract_days (date, days_from_first_shown);
- if (day_position)
- *day_position = -mts->day_width - x % mts->day_width;
- }
-}
-
-
-/* This takes an x pixel coordinate within a day, and converts it to hours
- and minutes, depending on working_hours_only and zoomed_out. */
-void
-e_meeting_time_selector_convert_day_position_to_hours_and_mins (EMeetingTimeSelector *mts, gint day_position, guint8 *hours, guint8 *minutes)
-{
- if (mts->zoomed_out)
- day_position *= 3;
-
- /* Calculate the hours & minutes from the first displayed. */
- *hours = day_position / mts->col_width;
- *minutes = (day_position % mts->col_width) * 60 / mts->col_width;
-
- /* Now add on the first hour shown. */
- *hours += mts->first_hour_shown;
-}
-
-
-/* This takes an x pixel coordinate within the entire canvas scroll region and
- returns the time in which it falls. Note that it won't be extremely
- accurate since hours may only be a few pixels wide in the display.
- With zoomed_out set each pixel may represent 5 minutes or more, depending
- on how small the font is. */
-void
-e_meeting_time_selector_calculate_time (EMeetingTimeSelector *mts,
- gint x,
- EMeetingTimeSelectorTime *time)
-{
- gint day_position;
-
- /* First get the day and the x position within the day. */
- e_meeting_time_selector_calculate_day_and_position (mts, x, &time->date,
- NULL);
-
- /* Now convert the day_position into an hour and minute. */
- if (x >= 0)
- day_position = x % mts->day_width;
- else
- day_position = mts->day_width + x % mts->day_width;
-
- e_meeting_time_selector_convert_day_position_to_hours_and_mins (mts, day_position, &time->hour, &time->minute);
-}
-
-
-/* This takes a EMeetingTimeSelectorTime and calculates the x pixel coordinate
- within the entire canvas scroll region. It is used to draw the selected
- meeting time and all the busy periods. */
-gint
-e_meeting_time_selector_calculate_time_position (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorTime *mtstime)
-{
- gint x, date_offset, day_offset;
-
- /* Calculate the number of days since the first date shown in the
- entire canvas scroll region. */
- date_offset = g_date_julian (&mtstime->date) - g_date_julian (&mts->first_date_shown);
-
- /* Calculate the x pixel coordinate of the start of the day. */
- x = date_offset * mts->day_width;
-
- /* Add on the hours and minutes, depending on whether zoomed_out and
- working_hours_only are set. */
- day_offset = (mtstime->hour - mts->first_hour_shown) * 60
- + mtstime->minute;
- /* The day width includes an extra vertical grid line so subtract 1. */
- day_offset *= (mts->day_width - 1);
- day_offset /= (mts->last_hour_shown - mts->first_hour_shown) * 60;
-
- /* Clamp the day_offset in case the time isn't actually visible. */
- x += CLAMP (day_offset, 0, mts->day_width);
-
- return x;
-}
-
-
diff --git a/widgets/meeting-time-sel/e-meeting-time-sel.h b/widgets/meeting-time-sel/e-meeting-time-sel.h
deleted file mode 100644
index 6df15fe54c..0000000000
--- a/widgets/meeting-time-sel/e-meeting-time-sel.h
+++ /dev/null
@@ -1,496 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-#ifndef _E_MEETING_TIME_SELECTOR_H_
-#define _E_MEETING_TIME_SELECTOR_H_
-
-#include <gtk/gtktable.h>
-#include <libgnomeui/gnome-canvas.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*
- * 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.
- */
-
-/* Define this to include the debugging functions. */
-#undef E_MEETING_TIME_SELECTOR_DEBUG
-
-/* This is the width of the icon column in the attendees list. */
-#define E_MEETING_TIME_SELECTOR_ICON_COLUMN_WIDTH 24
-
-
-/* These specify the type of attendee. Either a person or a resource (e.g. a
- meeting room). These are used for the Autopick options, where the user can
- ask for a time when, for example, all people and one resource are free.
- The default is E_MEETING_TIME_SELECTOR_REQUIRED_PERSON. */
-typedef enum
-{
- E_MEETING_TIME_SELECTOR_REQUIRED_PERSON,
- E_MEETING_TIME_SELECTOR_OPTIONAL_PERSON,
- E_MEETING_TIME_SELECTOR_RESOURCE
-} EMeetingTimeSelectorAttendeeType;
-
-
-/* These are used to specify whether an attendee is free or busy at a
- particular time. We'll probably replace this with a global calendar type.
- These should be ordered in increasing order of preference. Higher precedence
- busy periods will be painted over lower precedence ones. These are also
- used as for loop counters, so they should start at 0 and be ordered. */
-typedef enum
-{
- E_MEETING_TIME_SELECTOR_BUSY_TENTATIVE = 0,
- E_MEETING_TIME_SELECTOR_BUSY_OUT_OF_OFFICE = 1,
- E_MEETING_TIME_SELECTOR_BUSY_BUSY = 2,
-
- E_MEETING_TIME_SELECTOR_BUSY_LAST = 3
-} EMeetingTimeSelectorBusyType;
-
-
-/* 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
- format used is determined in e_meeting_time_selector_style_set(), once we
- know the font being used. */
-typedef enum
-{
- E_MEETING_TIME_SELECTOR_DATE_FULL,
- E_MEETING_TIME_SELECTOR_DATE_ABBREVIATED_DAY,
- E_MEETING_TIME_SELECTOR_DATE_SHORT
-} EMeetingTimeSelectorDateFormat;
-
-
-/* This is used to specify a position regarding the vertical bars around the
- current meeting time, so we know which one is being dragged. */
-typedef enum
-{
- E_MEETING_TIME_SELECTOR_POS_NONE,
- E_MEETING_TIME_SELECTOR_POS_START,
- E_MEETING_TIME_SELECTOR_POS_END
-} EMeetingTimeSelectorPosition;
-
-
-/* This is used to specify the autopick option, which determines how we choose
- the previous/next appropriate meeting time. */
-typedef enum
-{
- E_MEETING_TIME_SELECTOR_ALL_PEOPLE_AND_RESOURCES,
- E_MEETING_TIME_SELECTOR_ALL_PEOPLE_AND_ONE_RESOURCE,
- E_MEETING_TIME_SELECTOR_REQUIRED_PEOPLE,
- E_MEETING_TIME_SELECTOR_REQUIRED_PEOPLE_AND_ONE_RESOURCE
-} EMeetingTimeSelectorAutopickOption;
-
-
-/* This is our representation of a time. We use a GDate to store the day,
- and guint8s for the hours and minutes. */
-typedef struct _EMeetingTimeSelectorTime EMeetingTimeSelectorTime;
-struct _EMeetingTimeSelectorTime
-{
- GDate date;
- guint8 hour;
- guint8 minute;
-};
-
-
-/* This represents a busy period. */
-typedef struct _EMeetingTimeSelectorPeriod EMeetingTimeSelectorPeriod;
-struct _EMeetingTimeSelectorPeriod
-{
- EMeetingTimeSelectorTime start;
- EMeetingTimeSelectorTime end;
- EMeetingTimeSelectorBusyType busy_type;
-};
-
-
-/* This contains information on one attendee. */
-typedef struct _EMeetingTimeSelectorAttendee EMeetingTimeSelectorAttendee;
-struct _EMeetingTimeSelectorAttendee
-{
- gchar *name;
-
- /* The type of attendee, e.g. a person or a resource. */
- EMeetingTimeSelectorAttendeeType type;
-
- /* This is TRUE if the attendee has calendar information available.
- It is set to TRUE when a busy period is added, but can also be set
- to TRUE explicitly to indicate that the attendee has calendar
- information available, but no current busy periods. If it is FALSE
- then a diagonal stipple pattern is used to fill the entire row in
- the main graphical display. */
- gboolean has_calendar_info;
-
- /* This is TRUE if the meeting request is sent to this attendee. */
- gboolean send_meeting_to;
-
- /* This is an array of EMeetingTimeSelectorPeriod elements. When it is
- updated busy_periods_sorted is set to FALSE, and if a function
- needs them sorted, it should call this to re-sort them if needed:
- e_meeting_time_selector_attendee_ensure_periods_sorted(). Note that
- they are sorted by the start times. */
- GArray *busy_periods;
- gboolean busy_periods_sorted;
-
- /* This holds the length of the longest busy period in days, rounded
- up. It is used to determine where to start looking in the
- busy_periods array. If we didn't use this we'd have to go through
- most of the busy_periods array every time we wanted to paint part
- of the display. */
- gint longest_period_in_days;
-
- /* This is the canvas text item where the name is edited. */
- GnomeCanvasItem *text_item;
-
- /* This is supposed to be something like an address book id. */
- gpointer data;
-};
-
-/* An array of hour strings, "0:00" .. "23:00". */
-extern const gchar *EMeetingTimeSelectorHours[24];
-
-
-#define E_MEETING_TIME_SELECTOR(obj) GTK_CHECK_CAST (obj, e_meeting_time_selector_get_type (), EMeetingTimeSelector)
-#define E_MEETING_TIME_SELECTOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_meeting_time_selector_get_type (), EMeetingTimeSelectorClass)
-#define IS_E_MEETING_TIME_SELECTOR(obj) GTK_CHECK_TYPE (obj, e_meeting_time_selector_get_type ())
-
-
-typedef struct _EMeetingTimeSelector EMeetingTimeSelector;
-typedef struct _EMeetingTimeSelectorClass EMeetingTimeSelectorClass;
-
-struct _EMeetingTimeSelector
-{
- /* We subclass a GtkTable which makes it easy to add extra widgets
- if neccesary. */
- GtkTable table;
-
- /*
- * User Interface stuff - widgets, colors etc.
- */
-
- /* This contains our keyboard accelerators, which need to be added to
- the toplevel window. */
- GtkAccelGroup *accel_group;
-
- /* The vbox in the top-left corner, containing the 'All Attendees'
- title bar packed at the end. Extra widgets can be added here
- with PACK_START if necessary. */
- GtkWidget *attendees_title_bar_vbox;
-
- /* The 'All Attendees' title bar above the list of attendees. */
- GtkWidget *attendees_title_bar;
-
- /* The list of attendees. */
- GtkWidget *attendees_list;
-
- /* The canvas displaying the dates, times, and the summary
- 'All Attendees' free/busy display. */
- GtkWidget *display_top;
-
- /* The canvas containing the free/busy displays of individual
- attendees. This is separate from display_top since it also scrolls
- vertically. */
- GtkWidget *display_main;
-
- /* This is the 'Options' button & menu. */
- GtkWidget *options_button;
- GtkWidget *options_menu;
-
- /* This is the 'Autopick' button, menu & radio menu items. */
- GtkWidget *autopick_button;
- GtkWidget *autopick_menu;
- GtkWidget *autopick_all_item;
- GtkWidget *autopick_all_people_one_resource_item;
- GtkWidget *autopick_required_people_item;
- GtkWidget *autopick_required_people_one_resource_item;
-
- /* The horizontal scrollbar which scrolls display_top & display_main.*/
- GtkWidget *hscrollbar;
-
- /* The vertical scrollbar which scrolls attendees & display_main. */
- GtkWidget *vscrollbar;
-
- /* The 2 GnomeDateEdit widgets for the meeting start & end times. */
- GtkWidget *start_date_edit;
- GtkWidget *end_date_edit;
-
- /* Colors. */
- GdkColorContext *color_context;
- GdkColor bg_color;
- GdkColor all_attendees_bg_color;
- GdkColor meeting_time_bg_color;
- GdkColor stipple_bg_color;
- GdkColor attendee_list_bg_color;
- GdkColor grid_color;
- GdkColor grid_shadow_color;
- GdkColor grid_unused_color;
- GdkColor busy_colors[E_MEETING_TIME_SELECTOR_BUSY_LAST];
-
- /* The stipple used for attendees with no data. */
- GdkPixmap *stipple;
-
- /* GC for drawing the color key. */
- GdkGC *color_key_gc;
-
- /* Width of the hours strings (e.g. "1:00") in the current font. */
- gint hour_widths[24];
-
- /* Whether we are using the full, abbreviated or short date format. */
- EMeetingTimeSelectorDateFormat date_format;
-
-
- /*
- * Attendee Data.
- */
-
- /* This is an array of EMeetingTimeSelectorAttendee elements. */
- GArray *attendees;
-
-
- /*
- * Option Settings.
- */
-
- /* If this is TRUE we only show hours between day_start_hour and
- day_end_hour, defaults to TRUE (9am-6pm). */
- gboolean working_hours_only;
- gint day_start_hour;
- gint day_start_minute;
- gint day_end_hour;
- gint day_end_minute;
-
- /* If TRUE, view is compressed, with one cell for every 3 hours rather
- than every hour. Defaults to FALSE. */
- gboolean zoomed_out;
-
-
- /*
- * Internal Data.
- */
-
- /* These are the first & last dates shown in the current scroll area.
- We show E_MEETING_TIME_SELECTOR_DAYS_SHOWN days at a time. */
- GDate first_date_shown;
- GDate last_date_shown;
-
- /* This is the current selection of the meeting time. */
- EMeetingTimeSelectorTime meeting_start_time;
- EMeetingTimeSelectorTime meeting_end_time;
-
- /* These are the x pixel coordinates in the entire scroll region of
- the start and end times. Set to meeting_positions_valid to FALSE to
- invalidate. They will then be recomputed when needed. Always access
- with e_meeting_time_selector_get_meeting_time_positions(). */
- gint meeting_positions_valid;
- gint meeting_positions_in_scroll_area;
- gint meeting_start_x;
- gint meeting_end_x;
-
- /* These are the width and height of the cells, including the grid
- lines which are displayed on the right and top or bottom of cells.*/
- gint row_height;
- gint col_width;
-
- /* This is the width of a day in the display, which depends on
- col_width, working_hours_only and zoomed_out. */
- gint day_width;
-
- /* These are the first and last hour of each day we display, depending
- on working_hours_only and zoomed_out. */
- gint first_hour_shown;
- gint last_hour_shown;
-
- /* The id of the source function for auto-scroll timeouts. */
- guint auto_scroll_timeout_id;
-
- /* This specifies if we are dragging one of the vertical bars around
- the meeting time. */
- EMeetingTimeSelectorPosition dragging_position;
-
- /* The last x coordinate of the mouse, relative to either the left or
- right edge of the canvas. Used in the auto_scroll_timeout function
- to determine which way to scroll and how fast. */
- gint last_drag_x;
-
- /* This is used to determine the delay between scrolls. */
- gint scroll_count;
-};
-
-
-struct _EMeetingTimeSelectorClass
-{
- GtkTableClass parent_class;
-};
-
-
-/*
- * PUBLIC INTERFACE - note that this interface will probably change, when I
- * know where the data is coming from. This is mainly just for testing for now.
- */
-
-GtkType e_meeting_time_selector_get_type (void);
-GtkWidget* e_meeting_time_selector_new (void);
-
-/* This returns the currently selected meeting time.
- Note that months are 1-12 and days are 1-31. The start time is guaranteed to
- be before or equal to the end time. You may want to check if they are equal
- if that if it is a problem. */
-void e_meeting_time_selector_get_meeting_time (EMeetingTimeSelector *mts,
- gint *start_year,
- gint *start_month,
- gint *start_day,
- gint *start_hour,
- gint *start_minute,
- gint *end_year,
- gint *end_month,
- gint *end_day,
- gint *end_hour,
- gint *end_minute);
-
-/* This sets the meeting time, returning TRUE if it is valid. */
-gboolean e_meeting_time_selector_set_meeting_time (EMeetingTimeSelector *mts,
- gint start_year,
- gint start_month,
- gint start_day,
- gint start_hour,
- gint start_minute,
- gint end_year,
- gint end_month,
- gint end_day,
- gint end_hour,
- gint end_minute);
-
-void e_meeting_time_selector_set_working_hours_only (EMeetingTimeSelector *mts,
- gboolean working_hours_only);
-void e_meeting_time_selector_set_working_hours (EMeetingTimeSelector *mts,
- gint day_start_hour,
- gint day_start_minute,
- gint day_end_hour,
- gint day_end_minute);
-
-void e_meeting_time_selector_set_zoomed_out (EMeetingTimeSelector *mts,
- gboolean zoomed_out);
-
-EMeetingTimeSelectorAutopickOption e_meeting_time_selector_get_autopick_option (EMeetingTimeSelector *mts);
-void e_meeting_time_selector_set_autopick_option (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorAutopickOption autopick_option);
-
-/* Adds an attendee to the list, returning the row. The data is meant for
- something like an address book id, though if the user edits the name this
- will become invalid. We'll probably have to handle address book lookup
- ourself. */
-gint e_meeting_time_selector_attendee_add (EMeetingTimeSelector *mts,
- gchar *attendee_name,
- gpointer data);
-gint e_meeting_time_selector_attendee_find_by_name (EMeetingTimeSelector *mts,
- gchar *attendee_name,
- gint start_row);
-gint e_meeting_time_selector_attendee_find_by_data (EMeetingTimeSelector *mts,
- gpointer data,
- gint start_row);
-void e_meeting_time_selector_attendee_remove (EMeetingTimeSelector *mts,
- gint row);
-
-void e_meeting_time_selector_attendee_set_type (EMeetingTimeSelector *mts,
- gint row,
- EMeetingTimeSelectorAttendeeType type);
-void e_meeting_time_selector_attendee_set_has_calendar_info (EMeetingTimeSelector *mts,
- gint row,
- gboolean has_calendar_info);
-void e_meeting_time_selector_attendee_set_send_meeting_to (EMeetingTimeSelector *mts,
- gint row,
- gboolean send_meeting_to);
-
-/* Clears all busy times for the given attendee. */
-void e_meeting_time_selector_attendee_clear_busy_periods (EMeetingTimeSelector *mts,
- gint row);
-/* Adds one busy time for the given attendee. */
-gboolean e_meeting_time_selector_attendee_add_busy_period (EMeetingTimeSelector *mts,
- gint row,
- gint start_year,
- gint start_month,
- gint start_day,
- gint start_hour,
- gint start_minute,
- gint end_year,
- gint end_month,
- gint end_day,
- gint end_hour,
- gint end_minute,
- EMeetingTimeSelectorBusyType busy_type);
-
-
-
-/*
- * INTERNAL ROUTINES - functions to communicate with the canvas items within
- * the EMeetingTimeSelector.
- */
-
-/* This returns the x pixel coordinates of the meeting start and end times,
- in the entire canvas scroll area. If it returns FALSE, then the meeting
- time isn't in the current scroll area (which shouldn't really happen). */
-gboolean e_meeting_time_selector_get_meeting_time_positions (EMeetingTimeSelector *mts,
- gint *start_x,
- gint *end_x);
-
-void e_meeting_time_selector_drag_meeting_time (EMeetingTimeSelector *mts,
- gint x);
-
-void e_meeting_time_selector_remove_timeout (EMeetingTimeSelector *mts);
-
-void e_meeting_time_selector_fix_time_overflows (EMeetingTimeSelectorTime *mtstime);
-
-gint e_meeting_time_selector_find_first_busy_period (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorAttendee *attendee,
- GDate *date);
-
-/* Makes sure the busy periods are sorted, so we can do binary searches. */
-void e_meeting_time_selector_attendee_ensure_periods_sorted (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorAttendee *attendee);
-
-void e_meeting_time_selector_calculate_day_and_position (EMeetingTimeSelector *mts,
- gint x,
- GDate *date,
- gint *day_position);
-void e_meeting_time_selector_convert_day_position_to_hours_and_mins (EMeetingTimeSelector *mts, gint day_position, guint8 *hours, guint8 *minutes);
-void e_meeting_time_selector_calculate_time (EMeetingTimeSelector *mts,
- gint x,
- EMeetingTimeSelectorTime *time);
-gint e_meeting_time_selector_calculate_time_position (EMeetingTimeSelector *mts,
- EMeetingTimeSelectorTime *mtstime);
-
-/* Debugging function to dump information on all attendees. */
-#ifdef E_MEETING_TIME_SELECTOR_DEBUG
-void e_meeting_time_selector_dump (EMeetingTimeSelector *mts);
-gchar* e_meeting_time_selector_dump_time (EMeetingTimeSelectorTime *mtstime);
-gchar* e_meeting_time_selector_dump_date (GDate *date);
-#endif /* E_MEETING_TIME_SELECTOR_DEBUG */
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_MEETING_TIME_SELECTOR_H_ */
diff --git a/widgets/meeting-time-sel/test-meeting-time-sel.c b/widgets/meeting-time-sel/test-meeting-time-sel.c
deleted file mode 100644
index debe4e8f40..0000000000
--- a/widgets/meeting-time-sel/test-meeting-time-sel.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#include <config.h>
-#include <gnome.h>
-#include "e-meeting-time-sel.h"
-
-void add_random_attendee_test_data (EMeetingTimeSelector *mts);
-void add_simple_attendee_test_data (EMeetingTimeSelector *mts);
-gint get_random_int (gint max);
-
-int
-main (int argc, char *argv[])
-{
- GtkWidget *window, *mts;
- gint i;
-
- gnome_init ("test-meeting-time-selector", "0.1", argc, argv);
-
- gtk_widget_push_visual (gdk_imlib_get_visual ());
- gtk_widget_push_colormap (gdk_imlib_get_colormap ());
-
- window = gnome_dialog_new ("Plan a Meeting", "Make Meeting",
- GNOME_STOCK_BUTTON_CLOSE, NULL);
- gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
- gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE);
-
- mts = e_meeting_time_selector_new ();
- gtk_container_add (GTK_CONTAINER (GNOME_DIALOG (window)->vbox), mts);
- gtk_window_add_accel_group (GTK_WINDOW (window),
- E_MEETING_TIME_SELECTOR (mts)->accel_group);
- gtk_widget_show (mts);
-
- gtk_widget_pop_visual ();
- gtk_widget_pop_colormap ();
-
- i = 0;
-#if 1
- for (i = 0; i < 20; i++) {
- add_random_attendee_test_data (E_MEETING_TIME_SELECTOR (mts));
- }
-#else
- for (i = 0; i < 1; i++) {
- add_simple_attendee_test_data (E_MEETING_TIME_SELECTOR (mts));
- }
-#endif
-
-#if 0
- e_meeting_time_selector_dump (E_MEETING_TIME_SELECTOR (mts));
-#endif
-
- gnome_dialog_run (GNOME_DIALOG (window));
-
- gtk_main ();
- return 0;
-}
-
-
-/* Adds an attendee and a lot of random busy periods. The periods start 60
- days before the current date and extend over 365 days, to match the range
- that EMeetingTimeSelector currently displays. We generate a time_t and an
- interval and then convert them into a struct tm which provides everything
- we need. */
-void
-add_random_attendee_test_data (EMeetingTimeSelector *mts)
-{
- gchar buffer[128], *name;
- gint row, num_periods, busy_period, random_num, duration;
- EMeetingTimeSelectorAttendeeType type;
- EMeetingTimeSelectorBusyType busy_type;
- time_t range_start;
- time_t period_start;
- time_t period_end;
- struct tm *tmp_tm;
- struct tm tm1;
- struct tm tm2;
-
- /* Determine the type of attendee. */
- random_num = get_random_int (10);
- if (random_num < 4) {
- type = E_MEETING_TIME_SELECTOR_REQUIRED_PERSON;
- name = "Req. Attendee";
- } else if (random_num < 7) {
- type = E_MEETING_TIME_SELECTOR_OPTIONAL_PERSON;
- name = "Opt. Attendee";
- } else {
- type = E_MEETING_TIME_SELECTOR_RESOURCE;
- name = "Resource";
- }
-
- sprintf (buffer, "%s %i", name, mts->attendees->len + 1);
- row = e_meeting_time_selector_attendee_add (mts, buffer, NULL);
- e_meeting_time_selector_attendee_set_type (mts, row, type);
-
- /* Don't send the meeting request to some attendees. */
- if (get_random_int (10) <= 2)
- e_meeting_time_selector_attendee_set_send_meeting_to (mts, row,
- FALSE);
-
- /* Some attendees have no calendar information. */
- if (get_random_int (10) == 2)
- return;
-
- range_start = time (NULL) - 61 * 24 * 60 * 60;
- num_periods = get_random_int (1000);
-#if 0
- g_print ("num_periods: %i\n", num_periods);
-#endif
- for (busy_period = 0; busy_period < num_periods; busy_period++) {
-
- period_start = range_start + get_random_int (365 * 24 * 60 * 60);
-
- /* Make busy periods mainly 30 mins to a few hours, with a
- couple of week/fortnight periods as well. */
- random_num = get_random_int (10000);
- if (random_num < 2000)
- duration = 30;
- else if (random_num < 5000)
- duration = 60;
- else if (random_num < 7500)
- duration = 90;
- else if (random_num < 9995)
- duration = 120;
- else if (random_num < 9998)
- duration = 60 * 24 * 7;
- else
- duration = 60 * 24 * 14;
-#if 0
- g_print ("random_num: %i, duration: %i\n",
- random_num, duration);
-#endif
- period_end = period_start + duration * 60;
-
- tmp_tm = localtime (&period_start);
- tm1 = *tmp_tm;
- tmp_tm = localtime (&period_end);
- tm2 = *tmp_tm;
-
- /* A hack to avoid daylight-saving time problems. */
- if (tm2.tm_hour == tm1.tm_hour && tm2.tm_min < tm1.tm_min)
- tm2.tm_hour++;
-
- busy_type = get_random_int (E_MEETING_TIME_SELECTOR_BUSY_LAST);
-
- if (!e_meeting_time_selector_attendee_add_busy_period (mts, row, tm1.tm_year + 1900, tm1.tm_mon + 1, tm1.tm_mday, tm1.tm_hour, tm1.tm_min, tm2.tm_year + 1900, tm2.tm_mon + 1, tm2.tm_mday, tm2.tm_hour, tm2.tm_min, busy_type))
- {
- g_print ("Invalid busy period %i/%i/%i %i:%i to %i/%i/%i %i:%i\n", tm1.tm_year + 1900, tm1.tm_mon + 1, tm1.tm_mday, tm1.tm_hour, tm1.tm_min, tm2.tm_year + 1900, tm2.tm_mon + 1, tm2.tm_mday, tm2.tm_hour, tm2.tm_min);
- g_print ("random_num: %i, duration: %i\n",
- random_num, duration);
- }
- }
-}
-
-
-/* Returns a random integer between 0 and max - 1. */
-gint
-get_random_int (gint max)
-{
- gint random_num;
-
- random_num = (int) (max * (rand () / (RAND_MAX + 1.0)));
-#if 0
- g_print ("Random num (%i): %i\n", max, random_num);
-#endif
- return random_num;
-}
-
-
-void
-add_simple_attendee_test_data (EMeetingTimeSelector *mts)
-{
- gint row;
-
- row = e_meeting_time_selector_attendee_add (mts, "John Smith", NULL);
- if (!e_meeting_time_selector_attendee_add_busy_period (mts, row,
- 1999, 11, 7, 14, 30,
- 1999, 11, 7, 16, 30,
- E_MEETING_TIME_SELECTOR_BUSY_BUSY))
- g_warning ("Invalid busy period");
-
- e_meeting_time_selector_attendee_add_busy_period (mts, row,
- 1999, 11, 7, 10, 30,
- 1999, 11, 7, 11, 30,
- E_MEETING_TIME_SELECTOR_BUSY_OUT_OF_OFFICE);
- e_meeting_time_selector_attendee_add_busy_period (mts, row,
- 1999, 11, 4, 10, 30,
- 1999, 11, 7, 11, 30,
- E_MEETING_TIME_SELECTOR_BUSY_BUSY);
- row = e_meeting_time_selector_attendee_add (mts, "Dave Jones", NULL);
- e_meeting_time_selector_attendee_add_busy_period (mts, row,
- 1999, 11, 7, 15, 30,
- 1999, 11, 7, 18, 30,
- E_MEETING_TIME_SELECTOR_BUSY_TENTATIVE);
- e_meeting_time_selector_attendee_add_busy_period (mts, row,
- 1999, 11, 7, 11, 00,
- 1999, 11, 7, 12, 00,
- E_MEETING_TIME_SELECTOR_BUSY_BUSY);
-
- row = e_meeting_time_selector_attendee_add (mts, "Andrew Carlisle", NULL);
- e_meeting_time_selector_attendee_set_send_meeting_to (mts, row, FALSE);
-
- row = e_meeting_time_selector_attendee_add (mts, "Michael Cain", NULL);
- e_meeting_time_selector_attendee_add_busy_period (mts, row,
- 1999, 11, 7, 15, 30,
- 1999, 11, 7, 18, 30,
- E_MEETING_TIME_SELECTOR_BUSY_TENTATIVE);
- e_meeting_time_selector_attendee_add_busy_period (mts, row,
- 1999, 11, 7, 12, 30,
- 1999, 11, 7, 13, 30,
- E_MEETING_TIME_SELECTOR_BUSY_OUT_OF_OFFICE);
- e_meeting_time_selector_attendee_add_busy_period (mts, row,
- 1999, 11, 7, 11, 00,
- 1999, 11, 7, 12, 00,
- E_MEETING_TIME_SELECTOR_BUSY_TENTATIVE);
-}
diff --git a/widgets/misc/e-canvas-utils.c b/widgets/misc/e-canvas-utils.c
deleted file mode 100644
index 2b50248124..0000000000
--- a/widgets/misc/e-canvas-utils.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-canvas-utils.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "e-canvas-utils.h"
-
-void
-e_canvas_item_move_absolute (GnomeCanvasItem *item, double dx, double dy)
-{
- double translate[6];
-
- g_return_if_fail (item != NULL);
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
-
- art_affine_translate (translate, dx, dy);
-
- gnome_canvas_item_affine_absolute (item, translate);
-}
diff --git a/widgets/misc/e-canvas-utils.h b/widgets/misc/e-canvas-utils.h
deleted file mode 100644
index 13ec43117c..0000000000
--- a/widgets/misc/e-canvas-utils.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-canvas-utils.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-void e_canvas_item_move_absolute (GnomeCanvasItem *item, double dx, double dy);
diff --git a/widgets/misc/e-canvas.c b/widgets/misc/e-canvas.c
deleted file mode 100644
index 850e438386..0000000000
--- a/widgets/misc/e-canvas.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-canvas.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include "e-canvas.h"
-static void e_canvas_init (ECanvas *card);
-static void e_canvas_class_init (ECanvasClass *klass);
-static gint e_canvas_key (GtkWidget *widget,
- GdkEventKey *event);
-
-static gint e_canvas_focus_in (GtkWidget *widget,
- GdkEventFocus *event);
-static gint e_canvas_focus_out (GtkWidget *widget,
- GdkEventFocus *event);
-
-static int emit_event (GnomeCanvas *canvas, GdkEvent *event);
-
-static GnomeCanvasClass *parent_class = NULL;
-
-GtkType
-e_canvas_get_type (void)
-{
- static GtkType canvas_type = 0;
-
- if (!canvas_type)
- {
- static const GtkTypeInfo canvas_info =
- {
- "ECanvas",
- sizeof (ECanvas),
- sizeof (ECanvasClass),
- (GtkClassInitFunc) e_canvas_class_init,
- (GtkObjectInitFunc) e_canvas_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- canvas_type = gtk_type_unique (gnome_canvas_get_type (), &canvas_info);
- }
-
- return canvas_type;
-}
-
-static void
-e_canvas_class_init (ECanvasClass *klass)
-{
- GtkObjectClass *object_class;
- GnomeCanvasClass *canvas_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass*) klass;
- canvas_class = (GnomeCanvasClass *) klass;
- widget_class = (GtkWidgetClass *) klass;
-
- parent_class = gtk_type_class (gnome_canvas_get_type ());
-
- widget_class->key_press_event = e_canvas_key;
- widget_class->key_release_event = e_canvas_key;
- widget_class->focus_in_event = e_canvas_focus_in;
- widget_class->focus_out_event = e_canvas_focus_out;
-}
-
-static void
-e_canvas_init (ECanvas *canvas)
-{
-}
-
-GtkWidget *
-e_canvas_new()
-{
- return GTK_WIDGET (gtk_type_new (e_canvas_get_type ()));
-}
-
-
-/* Returns whether the item is an inferior of or is equal to the parent. */
-static int
-is_descendant (GnomeCanvasItem *item, GnomeCanvasItem *parent)
-{
- for (; item; item = item->parent)
- if (item == parent)
- return TRUE;
-
- return FALSE;
-}
-
-/* Emits an event for an item in the canvas, be it the current item, grabbed
- * item, or focused item, as appropriate.
- */
-static int
-emit_event (GnomeCanvas *canvas, GdkEvent *event)
-{
- GdkEvent ev;
- gint finished;
- GnomeCanvasItem *item;
- GnomeCanvasItem *parent;
- guint mask;
-
- /* Perform checks for grabbed items */
-
- if (canvas->grabbed_item && !is_descendant (canvas->current_item, canvas->grabbed_item))
- return FALSE;
-
- if (canvas->grabbed_item) {
- switch (event->type) {
- case GDK_ENTER_NOTIFY:
- mask = GDK_ENTER_NOTIFY_MASK;
- break;
-
- case GDK_LEAVE_NOTIFY:
- mask = GDK_LEAVE_NOTIFY_MASK;
- break;
-
- case GDK_MOTION_NOTIFY:
- mask = GDK_POINTER_MOTION_MASK;
- break;
-
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- mask = GDK_BUTTON_PRESS_MASK;
- break;
-
- case GDK_BUTTON_RELEASE:
- mask = GDK_BUTTON_RELEASE_MASK;
- break;
-
- case GDK_KEY_PRESS:
- mask = GDK_KEY_PRESS_MASK;
- break;
-
- case GDK_KEY_RELEASE:
- mask = GDK_KEY_RELEASE_MASK;
- break;
-
- default:
- mask = 0;
- break;
- }
-
- if (!(mask & canvas->grabbed_event_mask))
- return FALSE;
- }
-
- /* Convert to world coordinates -- we have two cases because of diferent
- * offsets of the fields in the event structures.
- */
-
- ev = *event;
-
- switch (ev.type) {
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY:
- gnome_canvas_window_to_world (canvas,
- ev.crossing.x, ev.crossing.y,
- &ev.crossing.x, &ev.crossing.y);
- break;
-
- case GDK_MOTION_NOTIFY:
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- gnome_canvas_window_to_world (canvas,
- ev.motion.x, ev.motion.y,
- &ev.motion.x, &ev.motion.y);
- break;
-
- default:
- break;
- }
-
- /* Choose where we send the event */
-
- item = canvas->current_item;
-
- if (canvas->focused_item
- && ((event->type == GDK_KEY_PRESS) || (event->type == GDK_KEY_RELEASE) || (event->type == GDK_FOCUS_CHANGE)))
- item = canvas->focused_item;
-
- /* The event is propagated up the hierarchy (for if someone connected to
- * a group instead of a leaf event), and emission is stopped if a
- * handler returns TRUE, just like for GtkWidget events.
- */
-
- finished = FALSE;
-
- while (item && !finished) {
- gtk_object_ref (GTK_OBJECT (item));
-
- gtk_signal_emit_by_name (GTK_OBJECT (item), "event",
- &ev,
- &finished);
-
- if (GTK_OBJECT_DESTROYED (item))
- finished = TRUE;
-
- parent = item->parent;
- gtk_object_unref (GTK_OBJECT (item));
-
- item = parent;
- }
-
- return finished;
-}
-
-/* Key event handler for the canvas */
-static gint
-e_canvas_key (GtkWidget *widget, GdkEventKey *event)
-{
- GnomeCanvas *canvas;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNOME_IS_CANVAS (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- canvas = GNOME_CANVAS (widget);
-
- return emit_event (canvas, (GdkEvent *) event);
-}
-
-
-/**
- * e_canvas_item_grab_focus:
- * @item: A canvas item.
- *
- * Makes the specified item take the keyboard focus, so all keyboard events will
- * be sent to it. If the canvas widget itself did not have the focus, it grabs
- * it as well.
- **/
-void
-e_canvas_item_grab_focus (GnomeCanvasItem *item)
-{
- GnomeCanvasItem *focused_item;
- GdkEvent ev;
-
- g_return_if_fail (item != NULL);
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
- g_return_if_fail (GTK_WIDGET_CAN_FOCUS (GTK_WIDGET (item->canvas)));
-
- focused_item = item->canvas->focused_item;
-
- if (focused_item) {
- ev.focus_change.type = GDK_FOCUS_CHANGE;
- ev.focus_change.window = GTK_LAYOUT (item->canvas)->bin_window;
- ev.focus_change.send_event = FALSE;
- ev.focus_change.in = FALSE;
-
- emit_event (item->canvas, &ev);
- }
-
- item->canvas->focused_item = item;
- gtk_widget_grab_focus (GTK_WIDGET (item->canvas));
-}
-
-/* Focus in handler for the canvas */
-static gint
-e_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event)
-{
- GnomeCanvas *canvas;
-
- canvas = GNOME_CANVAS (widget);
-
- if (canvas->focused_item)
- return emit_event (canvas, (GdkEvent *) event);
- else
- return FALSE;
-}
-
-/* Focus out handler for the canvas */
-static gint
-e_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event)
-{
- GnomeCanvas *canvas;
-
- canvas = GNOME_CANVAS (widget);
-
- if (canvas->focused_item)
- return emit_event (canvas, (GdkEvent *) event);
- else
- return FALSE;
-}
diff --git a/widgets/misc/e-canvas.h b/widgets/misc/e-canvas.h
deleted file mode 100644
index 0ece5ae3b4..0000000000
--- a/widgets/misc/e-canvas.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-canvas.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_CANVAS_H__
-#define __E_CANVAS_H__
-
-#include <gnome.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* ECanvas - A class derived from canvas for the purpose of adding
- * evolution specific canvas hacks.
- */
-
-#define E_CANVAS_TYPE (e_canvas_get_type ())
-#define E_CANVAS(obj) (GTK_CHECK_CAST ((obj), E_CANVAS_TYPE, ECanvas))
-#define E_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CANVAS_TYPE, ECanvasClass))
-#define E_IS_CANVAS(obj) (GTK_CHECK_TYPE ((obj), E_CANVAS_TYPE))
-#define E_IS_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CANVAS_TYPE))
-
-
-typedef struct _ECanvas ECanvas;
-typedef struct _ECanvasClass ECanvasClass;
-
-struct _ECanvas
-{
- GnomeCanvas parent;
-
- /* item specific fields */
-};
-
-struct _ECanvasClass
-{
- GnomeCanvasClass parent_class;
-};
-
-
-GtkType e_canvas_get_type (void);
-GtkWidget *e_canvas_new (void);
-
-/* Used to send all of the keystroke events to a specific item as well as
- * GDK_FOCUS_CHANGE events.
- */
-void e_canvas_item_grab_focus (GnomeCanvasItem *item);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_CANVAS_H__ */
diff --git a/widgets/misc/e-colors.c b/widgets/misc/e-colors.c
deleted file mode 100644
index 3f1de73784..0000000000
--- a/widgets/misc/e-colors.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * color.c: Color allocation on the Gnumeric spreadsheet
- *
- * Author:
- * Miguel de Icaza (miguel@kernel.org)
- *
- * We keep our own color context, as the color allocation might take place
- * before any of our Canvases are realized.
- */
-#include <config.h>
-#include <gnome.h>
-#include "color.h"
-
-static int color_inited;
-static GdkColorContext *gnumeric_color_context;
-
-/* Public colors: shared by all of our items in Gnumeric */
-GdkColor gs_white, gs_black, gs_light_gray, gs_dark_gray, gs_red;
-
-int
-color_alloc (gushort red, gushort green, gushort blue)
-{
- int failed;
-
- if (!color_inited)
- color_init ();
-
- return gdk_color_context_get_pixel (gnumeric_color_context,
- red, green, blue, &failed);
-}
-
-void
-color_alloc_gdk (GdkColor *c)
-{
- int failed;
-
- g_return_if_fail (c != NULL);
-
- c->pixel = gdk_color_context_get_pixel (gnumeric_color_context, c->red, c->green, c->blue, &failed);
-}
-
-void
-color_alloc_name (const char *name, GdkColor *c)
-{
- int failed;
-
- g_return_if_fail (name != NULL);
- g_return_if_fail (c != NULL);
-
- gdk_color_parse (name, c);
- c->pixel = 0;
- c->pixel = gdk_color_context_get_pixel (gnumeric_color_context, c->red, c->green, c->blue, &failed);
-}
-
-void
-color_init (void)
-{
- GdkColormap *colormap = gtk_widget_get_default_colormap ();
-
- /* Initialize the color context */
- gnumeric_color_context = gdk_color_context_new (
- gtk_widget_get_default_visual (), colormap);
-
- /* Allocate the default colors */
- gdk_color_white (colormap, &gs_white);
- gdk_color_black (colormap, &gs_black);
-
- color_alloc_name ("gray78", &gs_light_gray);
- color_alloc_name ("gray20", &gs_dark_gray);
- color_alloc_name ("red", &gs_red);
-
- color_inited = 1;
-}
diff --git a/widgets/misc/e-colors.h b/widgets/misc/e-colors.h
deleted file mode 100644
index b2755a5c6a..0000000000
--- a/widgets/misc/e-colors.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef GNUMERIC_COLOR_H
-#define GNUMERIC_COLOR_H
-
-void color_init (void);
-
-/* Return the pixel value for the given red, green and blue */
-int color_alloc (gushort red, gushort green, gushort blue);
-void color_alloc_name (const char *name, GdkColor *color);
-void color_alloc_gdk (GdkColor *color);
-
-/* Colors used by any GnumericSheet item */
-extern GdkColor gs_white, gs_light_gray, gs_dark_gray, gs_black, gs_red;
-
-#endif /* GNUMERIC_COLOR_H */
diff --git a/widgets/misc/e-cursors.c b/widgets/misc/e-cursors.c
deleted file mode 100644
index 597c3c1787..0000000000
--- a/widgets/misc/e-cursors.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef GNUMERIC_CURSORS_H
-#define GNUMERIC_CURSORS_H
-
-typedef enum {
- GNUMERIC_CURSOR_FAT_CROSS,
- GNUMERIC_CURSOR_THIN_CROSS,
- GNUMERIC_CURSOR_ARROW,
- GNUMERIC_CURSOR_MOVE,
- GNUMERIC_CURSOR_ZOOM_IN,
- GNUMERIC_CURSOR_ZOOM_OUT,
- GNUMERIC_CURSOR_SIZE_X,
- GNUMERIC_CURSOR_SIZE_Y,
- GNUMERIC_CURSOR_SIZE_TL,
- GNUMERIC_CURSOR_SIZE_TR,
- GNUMERIC_CURSOR_PRESS,
- GNUMERIC_CURSOR_HAND_OPEN,
- GNUMERIC_CURSOR_HAND_CLOSED,
- GNUMERIC_CURSOR_NUM_CURSORS
-} CursorType;
-
-void cursors_init (void);
-void cursors_shutdown (void);
-
-#define cursor_set(win, c) \
-G_STMT_START { \
- if (win) \
- gdk_window_set_cursor (win, cursor_get (c)); \
-} G_STMT_END
-
-#define cursor_set_widget(w, c) \
-G_STMT_START { \
- if (GTK_WIDGET (w)->window) \
- gdk_window_set_cursor (GTK_WIDGET (w)->window, cursor_get (c)); \
-} G_STMT_END
-
-GdkCursor *cursor_get (CursorType type);
-
-#endif /* GNUMERIC_CURSORS_H */
diff --git a/widgets/misc/e-cursors.h b/widgets/misc/e-cursors.h
deleted file mode 100644
index 597c3c1787..0000000000
--- a/widgets/misc/e-cursors.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef GNUMERIC_CURSORS_H
-#define GNUMERIC_CURSORS_H
-
-typedef enum {
- GNUMERIC_CURSOR_FAT_CROSS,
- GNUMERIC_CURSOR_THIN_CROSS,
- GNUMERIC_CURSOR_ARROW,
- GNUMERIC_CURSOR_MOVE,
- GNUMERIC_CURSOR_ZOOM_IN,
- GNUMERIC_CURSOR_ZOOM_OUT,
- GNUMERIC_CURSOR_SIZE_X,
- GNUMERIC_CURSOR_SIZE_Y,
- GNUMERIC_CURSOR_SIZE_TL,
- GNUMERIC_CURSOR_SIZE_TR,
- GNUMERIC_CURSOR_PRESS,
- GNUMERIC_CURSOR_HAND_OPEN,
- GNUMERIC_CURSOR_HAND_CLOSED,
- GNUMERIC_CURSOR_NUM_CURSORS
-} CursorType;
-
-void cursors_init (void);
-void cursors_shutdown (void);
-
-#define cursor_set(win, c) \
-G_STMT_START { \
- if (win) \
- gdk_window_set_cursor (win, cursor_get (c)); \
-} G_STMT_END
-
-#define cursor_set_widget(w, c) \
-G_STMT_START { \
- if (GTK_WIDGET (w)->window) \
- gdk_window_set_cursor (GTK_WIDGET (w)->window, cursor_get (c)); \
-} G_STMT_END
-
-GdkCursor *cursor_get (CursorType type);
-
-#endif /* GNUMERIC_CURSORS_H */
diff --git a/widgets/misc/e-gui-utils.c b/widgets/misc/e-gui-utils.c
deleted file mode 100644
index 7d9f4d49d9..0000000000
--- a/widgets/misc/e-gui-utils.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * GUI utility functions
- *
- * Author:
- * Miguel de Icaza (miguel@helixcode.com)
- *
- * (C) 1999 Miguel de Icaza
- * (C) 2000 Helix Code, Inc.
- */
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include <libgnomeui/gnome-messagebox.h>
-#include <libgnomeui/gnome-stock.h>
-#include "e-gui-utils.h"
-
-void
-e_notice (GtkWindow *window, const char *type, const char *str)
-{
- GtkWidget *dialog;
-
- dialog = gnome_message_box_new (str, type, GNOME_STOCK_BUTTON_OK, NULL);
-
- if (window)
- gnome_dialog_set_parent (GNOME_DIALOG (dialog), window);
-
- gnome_dialog_run (GNOME_DIALOG (dialog));
-}
-
-static void
-kill_popup_menu (GtkWidget *widget, GtkMenu *menu)
-{
- g_return_if_fail (menu != NULL);
- g_return_if_fail (GTK_IS_MENU (menu));
-
- gtk_object_unref (GTK_OBJECT (menu));
-}
-
-void
-e_auto_kill_popup_menu_on_hide (GtkMenu *menu)
-{
- g_return_if_fail (menu != NULL);
- g_return_if_fail (GTK_IS_MENU (menu));
-
- gtk_signal_connect (GTK_OBJECT (menu), "hide",
- GTK_SIGNAL_FUNC (kill_popup_menu), menu);
-}
-
-void
-e_popup_menu (GtkMenu *menu, GdkEventButton *event)
-{
- g_return_if_fail (menu != NULL);
- g_return_if_fail (GTK_IS_MENU (menu));
-
- e_auto_kill_popup_menu_on_hide (menu);
- gtk_menu_popup (menu, NULL, NULL, 0, NULL, event->button, event->time);
-}
-
-
diff --git a/widgets/misc/e-gui-utils.h b/widgets/misc/e-gui-utils.h
deleted file mode 100644
index 95b8f0b5a1..0000000000
--- a/widgets/misc/e-gui-utils.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef E_GUI_UTILS_H
-#define E_GUI_UTILS_H
-
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkwindow.h>
-
-void e_popup_menu (GtkMenu *menu, GdkEventButton *event);
-void e_auto_kill_popup_menu_on_hide (GtkMenu *menu);
-void e_notice (GtkWindow *window, const char *type, const char *str);
-
-
-#endif /* E_GUI_UTILS_H */
diff --git a/widgets/misc/e-reflow.c b/widgets/misc/e-reflow.c
deleted file mode 100644
index c1022f8f78..0000000000
--- a/widgets/misc/e-reflow.c
+++ /dev/null
@@ -1,787 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-reflow.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include <math.h>
-#include "e-reflow.h"
-#include "e-canvas-utils.h"
-static void e_reflow_init (EReflow *card);
-static void e_reflow_class_init (EReflowClass *klass);
-static void e_reflow_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
-static void e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static gboolean e_reflow_event (GnomeCanvasItem *item, GdkEvent *event);
-static void e_reflow_realize (GnomeCanvasItem *item);
-static void e_reflow_unrealize (GnomeCanvasItem *item);
-static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height);
-static void e_reflow_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags);
-static double e_reflow_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, GnomeCanvasItem **actual_item);
-
-static void _update_reflow ( EReflow *reflow );
-static void _resize( GtkObject *object, gpointer data );
-static void _queue_reflow(EReflow *e_reflow);
-
-#define E_REFLOW_DIVIDER_WIDTH 2
-#define E_REFLOW_BORDER_WIDTH 7
-#define E_REFLOW_FULL_GUTTER (E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH * 2)
-
-static GnomeCanvasGroupClass *parent_class = NULL;
-
-enum {
- E_REFLOW_RESIZE,
- E_REFLOW_LAST_SIGNAL
-};
-
-static guint e_reflow_signals[E_REFLOW_LAST_SIGNAL] = { 0 };
-
-/* The arguments we take */
-enum {
- ARG_0,
- ARG_MINIMUM_WIDTH,
- ARG_WIDTH,
- ARG_HEIGHT
-};
-
-GtkType
-e_reflow_get_type (void)
-{
- static GtkType reflow_type = 0;
-
- if (!reflow_type)
- {
- static const GtkTypeInfo reflow_info =
- {
- "EReflow",
- sizeof (EReflow),
- sizeof (EReflowClass),
- (GtkClassInitFunc) e_reflow_class_init,
- (GtkObjectInitFunc) e_reflow_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- reflow_type = gtk_type_unique (gnome_canvas_group_get_type (), &reflow_info);
- }
-
- return reflow_type;
-}
-
-static void
-e_reflow_class_init (EReflowClass *klass)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass*) klass;
- item_class = (GnomeCanvasItemClass *) klass;
-
- parent_class = gtk_type_class (gnome_canvas_group_get_type ());
-
- e_reflow_signals[E_REFLOW_RESIZE] =
- gtk_signal_new ("resize",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EReflowClass, resize),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, e_reflow_signals, E_REFLOW_LAST_SIGNAL);
-
- gtk_object_add_arg_type ("EReflow::minimum_width", GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE, ARG_MINIMUM_WIDTH);
- gtk_object_add_arg_type ("EReflow::width", GTK_TYPE_DOUBLE,
- GTK_ARG_READABLE, ARG_WIDTH);
- gtk_object_add_arg_type ("EReflow::height", GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE, ARG_HEIGHT);
-
- object_class->set_arg = e_reflow_set_arg;
- object_class->get_arg = e_reflow_get_arg;
- /* object_class->destroy = e_reflow_destroy; */
-
- /* GnomeCanvasItem method overrides */
- item_class->event = e_reflow_event;
- item_class->realize = e_reflow_realize;
- item_class->unrealize = e_reflow_unrealize;
- item_class->draw = e_reflow_draw;
- item_class->update = e_reflow_update;
- item_class->point = e_reflow_point;
-}
-
-static void
-e_reflow_init (EReflow *reflow)
-{
- /* reflow->card = NULL;*/
- reflow->items = NULL;
- reflow->columns = NULL;
- reflow->column_width = 150;
-
- reflow->minimum_width = 10;
- reflow->width = 10;
- reflow->height = 10;
- reflow->idle = 0;
-
- reflow->column_drag = FALSE;
-
- reflow->need_height_update = FALSE;
- reflow->need_column_resize = FALSE;
-
- reflow->default_cursor_shown = TRUE;
- reflow->arrow_cursor = NULL;
- reflow->default_cursor = NULL;
-}
-
-static void
-e_reflow_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EReflow *e_reflow;
-
- item = GNOME_CANVAS_ITEM (o);
- e_reflow = E_REFLOW (o);
-
- switch (arg_id){
- case ARG_HEIGHT:
- e_reflow->height = GTK_VALUE_DOUBLE (*arg);
- _queue_reflow(e_reflow);
- break;
- case ARG_MINIMUM_WIDTH:
- e_reflow->minimum_width = GTK_VALUE_DOUBLE (*arg);
- _queue_reflow(e_reflow);
- break;
- }
-}
-
-static void
-e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- EReflow *e_reflow;
-
- e_reflow = E_REFLOW (object);
-
- switch (arg_id) {
- case ARG_MINIMUM_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = e_reflow->minimum_width;
- break;
- case ARG_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = e_reflow->width;
- break;
- case ARG_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = e_reflow->height;
- break;
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-static void
-e_reflow_realize (GnomeCanvasItem *item)
-{
- EReflow *e_reflow;
- GnomeCanvasGroup *group;
- GList *list;
- GtkAdjustment *adjustment;
-
- e_reflow = E_REFLOW (item);
- group = GNOME_CANVAS_GROUP( item );
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize)
- (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item);
-
- e_reflow->arrow_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
- e_reflow->default_cursor = gdk_cursor_new (GDK_LEFT_PTR);
-
- for(list = e_reflow->items; list; list = g_list_next(list)) {
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM(list->data);
- gtk_signal_connect(GTK_OBJECT(item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_reflow);
- gnome_canvas_item_set(item,
- "width", (double) e_reflow->column_width,
- NULL);
- }
-
- _queue_reflow( e_reflow );
-
- adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- adjustment->step_increment = (e_reflow->column_width + E_REFLOW_FULL_GUTTER) / 2;
- adjustment->page_increment = adjustment->page_size - adjustment->step_increment;
- gtk_adjustment_changed(adjustment);
-
- if (!item->canvas->aa) {
- }
-}
-
-static void
-e_reflow_unrealize (GnomeCanvasItem *item)
-{
- EReflow *e_reflow;
-
- e_reflow = E_REFLOW (item);
-
- if (!item->canvas->aa)
- {
- }
-
- gdk_cursor_destroy (e_reflow->arrow_cursor);
- gdk_cursor_destroy (e_reflow->default_cursor);
-
- g_list_free (e_reflow->items);
- g_list_free (e_reflow->columns);
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize)
- (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item);
-}
-
-static gint
-e_reflow_pick_line (EReflow *e_reflow, double x)
-{
- x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- x /= e_reflow->column_width + E_REFLOW_FULL_GUTTER;
- return x;
-}
-
-static gboolean
-e_reflow_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EReflow *e_reflow;
-
- e_reflow = E_REFLOW (item);
-
- switch( event->type )
- {
- case GDK_KEY_PRESS:
- if (event->key.keyval == GDK_Tab ||
- event->key.keyval == GDK_KP_Tab ||
- event->key.keyval == GDK_ISO_Left_Tab) {
- GList *list;
- for (list = e_reflow->items; list; list = list->next) {
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data);
- gboolean has_focus;
- gtk_object_get(GTK_OBJECT(item),
- "has_focus", &has_focus,
- NULL);
- if (has_focus) {
- if (event->key.state & GDK_SHIFT_MASK)
- list = list->prev;
- else
- list = list->next;
- if (list) {
- item = GNOME_CANVAS_ITEM(list->data);
- gnome_canvas_item_set(item,
- "has_focus", TRUE,
- NULL);
- return 1;
- } else {
- return 0;
- }
- }
- }
- }
- break;
- case GDK_BUTTON_PRESS:
- switch(event->button.button)
- {
- case 1:
- {
- GdkEventButton *button = (GdkEventButton *) event;
- double n_x;
- n_x = button->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( button->y >= E_REFLOW_BORDER_WIDTH && button->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) {
- e_reflow->which_column_dragged = e_reflow_pick_line(e_reflow, button->x);
- e_reflow->start_x = e_reflow->which_column_dragged * (e_reflow->column_width + E_REFLOW_FULL_GUTTER) - E_REFLOW_DIVIDER_WIDTH / 2;
- e_reflow->temp_column_width = e_reflow->column_width;
- e_reflow->column_drag = TRUE;
-
- gnome_canvas_item_grab (item,
- GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
- e_reflow->arrow_cursor,
- button->time);
-
- e_reflow->previous_temp_column_width = -1;
- e_reflow->need_column_resize = TRUE;
- gnome_canvas_item_request_update(item);
- return TRUE;
- }
- }
- break;
- case 4:
- {
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- gdouble new_value = adjustment->value;
- new_value -= adjustment->step_increment;
- gtk_adjustment_set_value(adjustment, new_value);
- }
- break;
- case 5:
- {
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- gdouble new_value = adjustment->value;
- new_value += adjustment->step_increment;
- if ( new_value > adjustment->upper - adjustment->page_size )
- new_value = adjustment->upper - adjustment->page_size;
- gtk_adjustment_set_value(adjustment, new_value);
- }
- break;
- }
- break;
- case GDK_BUTTON_RELEASE:
- if (e_reflow->column_drag) {
- gdouble old_width = e_reflow->column_width;
- GdkEventButton *button = (GdkEventButton *) event;
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- e_reflow->temp_column_width = e_reflow->column_width +
- (button->x - e_reflow->start_x)/(e_reflow->which_column_dragged - e_reflow_pick_line(e_reflow, adjustment->value));
- if ( e_reflow->temp_column_width < 50 )
- e_reflow->temp_column_width = 50;
- e_reflow->column_drag = FALSE;
- if ( old_width != e_reflow->temp_column_width ) {
- gtk_adjustment_set_value(adjustment, adjustment->value + e_reflow_pick_line(e_reflow, adjustment->value) * (e_reflow->temp_column_width - e_reflow->column_width));
- e_reflow->column_width = e_reflow->temp_column_width;
- adjustment->step_increment = (e_reflow->column_width + E_REFLOW_FULL_GUTTER) / 2;
- adjustment->page_increment = adjustment->page_size - adjustment->step_increment;
- gtk_adjustment_changed(adjustment);
- _queue_reflow(e_reflow);
- } else {
- e_reflow->need_column_resize = TRUE;
- gnome_canvas_item_request_update(item);
- }
- gnome_canvas_item_ungrab (item, button->time);
- return TRUE;
- }
- break;
- case GDK_MOTION_NOTIFY:
- if (e_reflow->column_drag) {
- double old_width = e_reflow->temp_column_width;
- GdkEventMotion *motion = (GdkEventMotion *) event;
- GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas));
- e_reflow->temp_column_width = e_reflow->column_width +
- (motion->x - e_reflow->start_x)/(e_reflow->which_column_dragged - e_reflow_pick_line(e_reflow, adjustment->value));
- if (e_reflow->temp_column_width < 50)
- e_reflow->temp_column_width = 50;
- if (old_width != e_reflow->temp_column_width) {
- e_reflow->need_column_resize = TRUE;
- gnome_canvas_item_request_update(item);
- }
- return TRUE;
- } else {
- GdkEventMotion *motion = (GdkEventMotion *) event;
- double n_x;
- n_x = motion->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( motion->y >= E_REFLOW_BORDER_WIDTH && motion->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) {
- if ( e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->arrow_cursor);
- e_reflow->default_cursor_shown = FALSE;
- }
- } else
- if ( ! e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->default_cursor);
- e_reflow->default_cursor_shown = TRUE;
- }
-
- }
- break;
- case GDK_ENTER_NOTIFY:
- if (!e_reflow->column_drag) {
- GdkEventCrossing *crossing = (GdkEventCrossing *) event;
- double n_x;
- n_x = crossing->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( crossing->y >= E_REFLOW_BORDER_WIDTH && crossing->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) {
- if ( e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->arrow_cursor);
- e_reflow->default_cursor_shown = FALSE;
- }
- }
- }
- break;
- case GDK_LEAVE_NOTIFY:
- if (!e_reflow->column_drag) {
- GdkEventCrossing *crossing = (GdkEventCrossing *) event;
- double n_x;
- n_x = crossing->x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if ( !( crossing->y >= E_REFLOW_BORDER_WIDTH && crossing->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) ) {
- if ( ! e_reflow->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->default_cursor);
- e_reflow->default_cursor_shown = TRUE;
- }
- }
- }
- break;
- default:
- break;
- }
-
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event)
- return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event);
- else
- return 0;
-}
-
-void
-e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item)
-{
- e_reflow->items = g_list_append(e_reflow->items, item);
- if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) {
- gtk_signal_connect(GTK_OBJECT(item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_reflow);
- gnome_canvas_item_set(item,
- "width", (double) e_reflow->column_width,
- NULL);
- _queue_reflow(e_reflow);
- }
-
-}
-
-static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height)
-{
- int x_rect, y_rect, width_rect, height_rect;
- gdouble running_width;
- EReflow *e_reflow = E_REFLOW(item);
- int i;
- double column_width;
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->draw)
- GNOME_CANVAS_ITEM_CLASS(parent_class)->draw (item, drawable, x, y, width, height);
- column_width = e_reflow->column_width;
- running_width = E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- x_rect = running_width;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- /* Compute first column to draw. */
- i = x;
- i /= column_width + E_REFLOW_FULL_GUTTER;
- running_width += i * (column_width + E_REFLOW_FULL_GUTTER);
-
- for ( ; i < e_reflow->column_count; i++) {
- if ( running_width > x + width )
- break;
- x_rect = running_width;
- gtk_paint_flat_box(GTK_WIDGET(item->canvas)->style,
- drawable,
- GTK_STATE_ACTIVE,
- GTK_SHADOW_NONE,
- NULL,
- GTK_WIDGET(item->canvas),
- "reflow",
- x_rect - x,
- y_rect - y,
- width_rect,
- height_rect);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- if (e_reflow->column_drag) {
- int start_line = e_reflow_pick_line(e_reflow,
- gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas))->value);
- i = x - start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width = start_line * (column_width + E_REFLOW_FULL_GUTTER);
- column_width = e_reflow->temp_column_width;
- running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER);
- i += start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- x_rect = running_width;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- /* Compute first column to draw. */
- i /= column_width + E_REFLOW_FULL_GUTTER;
- running_width += i * (column_width + E_REFLOW_FULL_GUTTER);
-
- for ( ; i < e_reflow->column_count; i++) {
- if ( running_width > x + width )
- break;
- x_rect = running_width;
- gdk_draw_rectangle(drawable,
- GTK_WIDGET(item->canvas)->style->fg_gc[GTK_STATE_NORMAL],
- TRUE,
- x_rect - x,
- y_rect - y,
- width_rect - 1,
- height_rect - 1);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- }
-}
-
-static void
-e_reflow_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags)
-{
- EReflow *e_reflow;
- double x0, x1, y0, y1;
-
- e_reflow = E_REFLOW (item);
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->update)
- GNOME_CANVAS_ITEM_CLASS(parent_class)->update (item, affine, clip_path, flags);
-
- x0 = item->x1;
- y0 = item->y1;
- x1 = item->x2;
- y1 = item->y2;
- if ( x1 < x0 + e_reflow->width )
- x1 = x0 + e_reflow->width;
- if ( y1 < y0 + e_reflow->height )
- y1 = y0 + e_reflow->height;
- item->x2 = x1;
- item->y2 = y1;
-
- if (e_reflow->need_height_update) {
- x0 = item->x1;
- y0 = item->y1;
- x1 = item->x2;
- y1 = item->y2;
- if ( x0 > 0 )
- x0 = 0;
- if ( y0 > 0 )
- y0 = 0;
- if ( x1 < E_REFLOW(item)->width )
- x1 = E_REFLOW(item)->width;
- if ( x1 < E_REFLOW(item)->height )
- x1 = E_REFLOW(item)->height;
-
- gnome_canvas_request_redraw(item->canvas, x0, y0, x1, y1);
- e_reflow->need_height_update = FALSE;
- } else if (e_reflow->need_column_resize) {
- int x_rect, y_rect, width_rect, height_rect;
- int start_line = e_reflow_pick_line(e_reflow,
- gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas))->value);
- gdouble running_width;
- int i;
- double column_width;
-
- if ( e_reflow->previous_temp_column_width != -1 ) {
- running_width = start_line * (e_reflow->column_width + E_REFLOW_FULL_GUTTER);
- column_width = e_reflow->previous_temp_column_width;
- running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- for ( i = 0; i < e_reflow->column_count; i++) {
- x_rect = running_width;
- gnome_canvas_request_redraw(item->canvas, x_rect, y_rect, x_rect + width_rect, y_rect + height_rect);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- }
-
- if ( e_reflow->temp_column_width != -1 ) {
- running_width = start_line * (e_reflow->column_width + E_REFLOW_FULL_GUTTER);
- column_width = e_reflow->temp_column_width;
- running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER);
- running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- y_rect = E_REFLOW_BORDER_WIDTH;
- width_rect = E_REFLOW_DIVIDER_WIDTH;
- height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2);
-
- for ( i = 0; i < e_reflow->column_count; i++) {
- x_rect = running_width;
- gnome_canvas_request_redraw(item->canvas, x_rect, y_rect, x_rect + width_rect, y_rect + height_rect);
- running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
- }
- }
-
- e_reflow->previous_temp_column_width = e_reflow->temp_column_width;
- e_reflow->need_column_resize = FALSE;
- }
-}
-
-static double
-e_reflow_point (GnomeCanvasItem *item,
- double x, double y, int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- EReflow *e_reflow = E_REFLOW(item);
- double distance = 1;
-
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->point)
- distance = GNOME_CANVAS_ITEM_CLASS(parent_class)->point (item, x, y, cx, cy, actual_item);
- if (*actual_item)
- return 0;
-
- *actual_item = item;
- return 0;
-#if 0
- if (y >= E_REFLOW_BORDER_WIDTH && y <= e_reflow->height - E_REFLOW_BORDER_WIDTH) {
- float n_x;
- n_x = x;
- n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH;
- n_x = fmod(n_x, (e_reflow->column_width + E_REFLOW_FULL_GUTTER));
- if (n_x < E_REFLOW_FULL_GUTTER) {
- *actual_item = item;
- return 0;
- }
- }
- return distance;
-#endif
-}
-
-static void
-_reflow( EReflow *e_reflow )
-{
- gdouble running_height;
- GList *list;
- double item_height;
-
- if (e_reflow->columns) {
- g_list_free (e_reflow->columns);
- e_reflow->columns = NULL;
- }
-
- e_reflow->column_count = 0;
-
- if (e_reflow->items == NULL) {
- e_reflow->columns = NULL;
- e_reflow->column_count = 1;
- return;
- }
-
- list = e_reflow->items;
-
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
- running_height = E_REFLOW_BORDER_WIDTH + item_height + E_REFLOW_BORDER_WIDTH;
- e_reflow->columns = g_list_append (e_reflow->columns, list);
- e_reflow->column_count = 1;
-
- list = g_list_next(list);
-
- for ( ; list; list = g_list_next(list)) {
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
- if (running_height + item_height + E_REFLOW_BORDER_WIDTH > e_reflow->height) {
- running_height = E_REFLOW_BORDER_WIDTH + item_height + E_REFLOW_BORDER_WIDTH;
- e_reflow->columns = g_list_append (e_reflow->columns, list);
- e_reflow->column_count ++;
- } else {
- running_height += item_height + E_REFLOW_BORDER_WIDTH;
- }
- }
-}
-
-static void
-_update_reflow( EReflow *e_reflow )
-{
- if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) {
-
- gdouble old_width;
- gdouble running_width;
-
- _reflow (e_reflow);
-
- old_width = e_reflow->width;
-
- running_width = E_REFLOW_BORDER_WIDTH;
-
- if (e_reflow->items == NULL) {
- } else {
- GList *list;
- GList *next_column;
- gdouble item_height;
- gdouble running_height;
-
- running_height = E_REFLOW_BORDER_WIDTH;
-
- list = e_reflow->items;
- gtk_object_set (GTK_OBJECT(list->data),
- "width", e_reflow->column_width,
- NULL);
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
- e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data),
- (double) running_width,
- (double) running_height);
- running_height += item_height + E_REFLOW_BORDER_WIDTH;
- next_column = g_list_next(e_reflow->columns);
- list = g_list_next(list);
-
- for( ; list; list = g_list_next(list)) {
- gtk_object_set (GTK_OBJECT(list->data),
- "width", e_reflow->column_width,
- NULL);
- gtk_object_get (GTK_OBJECT(list->data),
- "height", &item_height,
- NULL);
-
- if (next_column && (next_column->data == list)) {
- next_column = g_list_next (next_column);
- running_height = E_REFLOW_BORDER_WIDTH;
- running_width += e_reflow->column_width + E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH;
- }
- e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data),
- (double) running_width,
- (double) running_height);
-
- running_height += item_height + E_REFLOW_BORDER_WIDTH;
- }
-
- }
- e_reflow->width = running_width + e_reflow->column_width + E_REFLOW_BORDER_WIDTH;
- if ( e_reflow->width < e_reflow->minimum_width )
- e_reflow->width = e_reflow->minimum_width;
- if (old_width != e_reflow->width)
- gtk_signal_emit_by_name (GTK_OBJECT (e_reflow), "resize");
- }
-}
-
-
-static gboolean
-_idle_reflow(gpointer data)
-{
- EReflow *e_reflow = E_REFLOW(data);
- _update_reflow(e_reflow);
- e_reflow->need_height_update = TRUE;
- gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(e_reflow));
- e_reflow->idle = 0;
- return FALSE;
-}
-
-static void
-_queue_reflow(EReflow *e_reflow)
-{
- if (e_reflow->idle == 0)
- e_reflow->idle = g_idle_add(_idle_reflow, e_reflow);
-}
-
-static void
-_resize( GtkObject *object, gpointer data )
-{
- _queue_reflow(E_REFLOW(data));
-}
diff --git a/widgets/misc/e-reflow.h b/widgets/misc/e-reflow.h
deleted file mode 100644
index 3a731474cb..0000000000
--- a/widgets/misc/e-reflow.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-reflow.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_REFLOW_H__
-#define __E_REFLOW_H__
-
-#include <gnome.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* EReflow - A canvas item container.
- *
- * The following arguments are available:
- *
- * name type read/write description
- * --------------------------------------------------------------------------------
- * minimum_width double RW minimum width of the reflow. width >= minimum_width
- * width double R width of the reflow
- * height double RW height of the reflow
- */
-
-#define E_REFLOW_TYPE (e_reflow_get_type ())
-#define E_REFLOW(obj) (GTK_CHECK_CAST ((obj), E_REFLOW_TYPE, EReflow))
-#define E_REFLOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_REFLOW_TYPE, EReflowClass))
-#define E_IS_REFLOW(obj) (GTK_CHECK_TYPE ((obj), E_REFLOW_TYPE))
-#define E_IS_REFLOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_REFLOW_TYPE))
-
-
-typedef struct _EReflow EReflow;
-typedef struct _EReflowClass EReflowClass;
-
-struct _EReflow
-{
- GnomeCanvasGroup parent;
-
- /* item specific fields */
- /* EBook *book; */
-
- GList *items; /* Of type GnomeCanvasItem */
- GList *columns; /* Of type GList pointing to type GnomeCanvasItem (points into items) */
- gint column_count; /* Number of columnns */
-
- double minimum_width;
- double width;
- double height;
-
- double column_width;
-
- int idle;
-
- /* These are all for when the column is being dragged. */
- gboolean column_drag;
- gdouble start_x;
- gint which_column_dragged;
- double temp_column_width;
- double previous_temp_column_width;
-
- guint need_height_update : 1;
- guint need_column_resize : 1;
-
- guint default_cursor_shown : 1;
- GdkCursor *arrow_cursor;
- GdkCursor *default_cursor;
-};
-
-struct _EReflowClass
-{
- GnomeCanvasGroupClass parent_class;
-
- void (* resize) (EReflow *reflow);
-};
-
-/* To be added to a reflow, an item must have the arguments "x", "y",
- and "width" as Read/Write arguments and "height" as a Read Only
- argument. It must also have a "resize" signal. */
-void e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item);
-GtkType e_reflow_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_REFLOW_H__ */
diff --git a/widgets/misc/pixmaps/cursor_cross.xpm b/widgets/misc/pixmaps/cursor_cross.xpm
deleted file mode 100644
index cf9d0aca33..0000000000
--- a/widgets/misc/pixmaps/cursor_cross.xpm
+++ /dev/null
@@ -1,38 +0,0 @@
-/* XPM */
-static char * cursor_cross_xpm[] = {
-"32 32 3 1",
-" c None",
-". c #000000",
-"+ c #FFFFFF",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ....... ",
-" .+++++.. ",
-" .+++++.. ",
-" .+++++.. ",
-" .+++++.. ",
-" ......+++++...... ",
-" .+++++++++++++++.. ",
-" .+++++++++++++++.. ",
-" .+++++++++++++++.. ",
-" .+++++++++++++++.. ",
-" .+++++++++++++++.. ",
-" ......+++++....... ",
-" .....+++++....... ",
-" .+++++.. ",
-" .+++++.. ",
-" .+++++.. ",
-" ........ ",
-" ....... ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" "};
diff --git a/widgets/misc/pixmaps/cursor_hand_closed.xpm b/widgets/misc/pixmaps/cursor_hand_closed.xpm
deleted file mode 100644
index 61a6de4b88..0000000000
--- a/widgets/misc/pixmaps/cursor_hand_closed.xpm
+++ /dev/null
@@ -1,38 +0,0 @@
-/* XPM */
-static char * cursor_hand_closed_xpm[] = {
-"32 32 3 1",
-" c None",
-". c #000000",
-"+ c #FFFFFF",
-" ",
-" ",
-" ",
-" ",
-" ",
-" .. ",
-" ..++... ",
-" .+++++++.. ",
-" .+++++++++. ",
-" ...+++++++++. ",
-" .++.+++++++++. ",
-" .++++++++++++. ",
-" .+++++++++++. ",
-" .++++++++++. ",
-" .+++++++++. ",
-" .+++++++. ",
-" .++++++. ",
-" .++++++. ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" "};
diff --git a/widgets/misc/pixmaps/cursor_hand_open.xpm b/widgets/misc/pixmaps/cursor_hand_open.xpm
deleted file mode 100644
index 048acc8054..0000000000
--- a/widgets/misc/pixmaps/cursor_hand_open.xpm
+++ /dev/null
@@ -1,38 +0,0 @@
-/* XPM */
-static char * cursor_hand_open_xpm[] = {
-"32 32 3 1",
-" c None",
-". c #000000",
-"+ c #FFFFFF",
-" ",
-" ",
-" .. ",
-" .. .++... ",
-" .++..++.++. ",
-" .++..++.++. . ",
-" .++.++.++..+. ",
-" .++.++.++.++. ",
-" .. .+++++++.++. ",
-" .++..++++++++++. ",
-" .+++.+++++++++. ",
-" .++++++++++++. ",
-" .+++++++++++. ",
-" .++++++++++. ",
-" .+++++++++. ",
-" .+++++++. ",
-" .++++++. ",
-" .++++++. ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" "};
diff --git a/widgets/misc/pixmaps/cursor_zoom_in.xpm b/widgets/misc/pixmaps/cursor_zoom_in.xpm
deleted file mode 100644
index 1caf9e3e2a..0000000000
--- a/widgets/misc/pixmaps/cursor_zoom_in.xpm
+++ /dev/null
@@ -1,37 +0,0 @@
-/* XPM */
-static char * cursor_zoom_in_xpm[] = {
-"32 32 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ...... ",
-" .. .. ",
-" .. .. ",
-" . . ",
-" . ... . ",
-" . ... . ",
-" . ....... . ",
-" . ....... . ",
-" . ... . ",
-" . ... .. ",
-" .. . . ",
-" .. . . . ",
-" ........ . . ",
-" ..... . . . ",
-" . . . ",
-" . . . ",
-" . . . ",
-" . . . ",
-" . . ",
-" . . ",
-" .. ",
-" ",
-" ",
-" ",
-" ",
-" "};
diff --git a/widgets/misc/pixmaps/cursor_zoom_out.xpm b/widgets/misc/pixmaps/cursor_zoom_out.xpm
deleted file mode 100644
index af1b698521..0000000000
--- a/widgets/misc/pixmaps/cursor_zoom_out.xpm
+++ /dev/null
@@ -1,37 +0,0 @@
-/* XPM */
-static char * cursor_zoom_out_xpm[] = {
-"32 32 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ...... ",
-" .. .. ",
-" .. .. ",
-" . . ",
-" . . ",
-" . . ",
-" . ....... . ",
-" . ....... . ",
-" . . ",
-" . .. ",
-" .. . . ",
-" .. . . . ",
-" ........ . . ",
-" ..... . . . ",
-" . . . ",
-" . . . ",
-" . . . ",
-" . . . ",
-" . . ",
-" . . ",
-" .. ",
-" ",
-" ",
-" ",
-" ",
-" "};
diff --git a/widgets/shortcut-bar/.cvsignore b/widgets/shortcut-bar/.cvsignore
deleted file mode 100644
index 41439d256d..0000000000
--- a/widgets/shortcut-bar/.cvsignore
+++ /dev/null
@@ -1,7 +0,0 @@
-*.o
-libshortcut-bar.a
-Makefile
-Makefile.in
-.deps
-.libs
-test-shortcut-bar
diff --git a/widgets/shortcut-bar/LICENSE b/widgets/shortcut-bar/LICENSE
deleted file mode 100644
index f58649ad9b..0000000000
--- a/widgets/shortcut-bar/LICENSE
+++ /dev/null
@@ -1 +0,0 @@
-This code is licensed under the terms of the GNU GPL \ No newline at end of file
diff --git a/widgets/shortcut-bar/Makefile.am b/widgets/shortcut-bar/Makefile.am
deleted file mode 100644
index ac81f2e2e6..0000000000
--- a/widgets/shortcut-bar/Makefile.am
+++ /dev/null
@@ -1,33 +0,0 @@
-
-noinst_LIBRARIES = libshortcut-bar.a
-noinst_PROGRAMS = test-shortcut-bar
-
-INCLUDES = \
- -DEVOLUTION_VERSION=\""$(VERSION)"\" \
- $(EXTRA_GNOME_CFLAGS)
-
-libshortcut_bar_a_SOURCES = \
- e-clipped-label.c \
- e-clipped-label.h \
- e-group-bar.c \
- e-group-bar.h \
- e-icon-bar-bg-item.c \
- e-icon-bar-bg-item.h \
- e-icon-bar-text-item.c \
- e-icon-bar-text-item.h \
- e-icon-bar.c \
- e-icon-bar.h \
- e-shortcut-bar.c \
- e-shortcut-bar.h \
- e-vscrolled-bar.c \
- e-vscrolled-bar.h
-
-test_shortcut_bar_SOURCES = \
- test-shortcut-bar.c
-
-test_shortcut_bar_LDADD = \
- ./libshortcut-bar.a \
- $(EXTRA_GNOME_LIBS)
-
-test_shortcut_bar_LDFLAGS = \
- `gnome-config --libs gdk_pixbuf gnomecanvaspixbuf`
diff --git a/widgets/shortcut-bar/e-clipped-label.c b/widgets/shortcut-bar/e-clipped-label.c
deleted file mode 100644
index 0b595f6063..0000000000
--- a/widgets/shortcut-bar/e-clipped-label.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * This is similar to GtkLabel but clips itself and displays '...' if it
- * can't fit inside its allocated area. The intended use is for inside buttons
- * that are a fixed size. The GtkLabel would normally display only the middle
- * part of the text, which doesn't look very good. This only supports one line
- * of text (so no wrapping/justification), without underlined characters.
- */
-
-#include <math.h>
-
-#include <gdk/gdki18n.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnome/gnome-i18n.h>
-
-#include "e-clipped-label.h"
-
-
-static void e_clipped_label_class_init (EClippedLabelClass *class);
-static void e_clipped_label_init (EClippedLabel *label);
-static void e_clipped_label_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void e_clipped_label_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gint e_clipped_label_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static void e_clipped_label_recalc_chars_displayed (EClippedLabel *label);
-
-
-static GtkMiscClass *parent_class;
-
-/* This is the string to draw when the label is clipped, e.g. '...'. */
-static gchar *e_clipped_label_ellipsis;
-
-/* Flags used in chars_displayed field. Must be negative. */
-#define E_CLIPPED_LABEL_NEED_RECALC -1
-#define E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL -2
-
-
-GtkType
-e_clipped_label_get_type (void)
-{
- static GtkType e_clipped_label_type = 0;
-
- if (!e_clipped_label_type){
- GtkTypeInfo e_clipped_label_info = {
- "EClippedLabel",
- sizeof (EClippedLabel),
- sizeof (EClippedLabelClass),
- (GtkClassInitFunc) e_clipped_label_class_init,
- (GtkObjectInitFunc) e_clipped_label_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- parent_class = gtk_type_class (GTK_TYPE_MISC);
- e_clipped_label_type = gtk_type_unique (GTK_TYPE_MISC,
- &e_clipped_label_info);
- }
-
- return e_clipped_label_type;
-}
-
-
-static void
-e_clipped_label_class_init (EClippedLabelClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
-
- /* Method override */
- widget_class->size_request = e_clipped_label_size_request;
- widget_class->size_allocate = e_clipped_label_size_allocate;
- widget_class->expose_event = e_clipped_label_expose;
-
- e_clipped_label_ellipsis = _("...");
-}
-
-
-static void
-e_clipped_label_init (EClippedLabel *label)
-{
- GTK_WIDGET_SET_FLAGS (label, GTK_NO_WINDOW);
-
- label->label = NULL;
- label->label_wc = NULL;
- label->chars_displayed = E_CLIPPED_LABEL_NEED_RECALC;
-}
-
-
-/**
- * e_clipped_label_new:
- *
- * @text: The label text.
- * @Returns: A new #EClippedLabel.
- *
- * Creates a new #EClippedLabel with the given text.
- **/
-GtkWidget *
-e_clipped_label_new (const gchar *text)
-{
- GtkWidget *label;
-
- label = GTK_WIDGET (gtk_type_new (e_clipped_label_get_type ()));
-
- if (text && *text)
- e_clipped_label_set_text (E_CLIPPED_LABEL (label), text);
-
- return label;
-}
-
-
-static void
-e_clipped_label_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- EClippedLabel *label;
- GdkFont *font;
-
- g_return_if_fail (E_IS_CLIPPED_LABEL (widget));
- g_return_if_fail (requisition != NULL);
-
- label = E_CLIPPED_LABEL (widget);
- font = widget->style->font;
-
- requisition->width = 0;
- requisition->height = font->ascent + font->descent
- + 2 * GTK_MISC (widget)->ypad;
-}
-
-
-static void
-e_clipped_label_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- EClippedLabel *label;
-
- label = E_CLIPPED_LABEL (widget);
-
- widget->allocation = *allocation;
-
- /* Flag that we need to recalculate how many characters to display. */
- label->chars_displayed = E_CLIPPED_LABEL_NEED_RECALC;
-}
-
-
-static gint
-e_clipped_label_expose (GtkWidget *widget,
- GdkEventExpose *event)
-{
- EClippedLabel *label;
- GtkMisc *misc;
- gint x, y;
- GdkFont *font;
- gchar *tmp_str, tmp_ch;
-
- g_return_val_if_fail (E_IS_CLIPPED_LABEL (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- label = E_CLIPPED_LABEL (widget);
- misc = GTK_MISC (widget);
- font = widget->style->font;
-
- /* If the label isn't visible or has no text, just return. */
- if (!GTK_WIDGET_VISIBLE (widget) || !GTK_WIDGET_MAPPED (widget)
- || !label->label || (*label->label == '\0'))
- return TRUE;
-
- /* Recalculate the number of characters displayed, if necessary. */
- if (label->chars_displayed == E_CLIPPED_LABEL_NEED_RECALC)
- e_clipped_label_recalc_chars_displayed (label);
-
- /*
- * GC Clipping
- */
- gdk_gc_set_clip_rectangle (widget->style->white_gc,
- &event->area);
- gdk_gc_set_clip_rectangle (widget->style->fg_gc[widget->state],
- &event->area);
-
- y = floor (widget->allocation.y + (gint)misc->ypad
- + (((gint)widget->allocation.height - 2 * (gint)misc->ypad
- - (gint)font->ascent - font->descent)
- * misc->yalign) + 0.5) + font->ascent;
-
- if (label->chars_displayed == E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL) {
- x = floor (widget->allocation.x + (gint)misc->xpad
- + (((gint)widget->allocation.width -
- (gint)label->label_width - 2 * (gint)misc->xpad)
- * misc->xalign) + 0.5);
-
- gtk_paint_string (widget->style, widget->window, widget->state,
- &event->area, widget, "label",
- x, y, label->label);
- } else {
- x = widget->allocation.x + (gint)misc->xpad;
-
- tmp_ch = label->label_wc[label->chars_displayed];
- label->label_wc[label->chars_displayed] = '\0';
- tmp_str = gdk_wcstombs (label->label_wc);
- if (tmp_str) {
- gtk_paint_string (widget->style, widget->window,
- widget->state, &event->area,
- widget, "label",
- x, y, tmp_str);
- g_free (tmp_str);
- }
- label->label_wc[label->chars_displayed] = tmp_ch;
-
- x = widget->allocation.x + (gint)misc->xpad
- + label->ellipsis_x;
- gtk_paint_string (widget->style, widget->window, widget->state,
- &event->area, widget, "label",
- x, y, e_clipped_label_ellipsis);
- }
-
- gdk_gc_set_clip_mask (widget->style->white_gc, NULL);
- gdk_gc_set_clip_mask (widget->style->fg_gc[widget->state], NULL);
-
- return TRUE;
-}
-
-
-/**
- * e_clipped_label_get_text:
- *
- * @label: An #EClippedLabel.
- * @Return: The label text.
- *
- * Returns the label text, or NULL.
- **/
-gchar*
-e_clipped_label_get_text (EClippedLabel *label)
-{
- g_return_val_if_fail (E_IS_CLIPPED_LABEL (label), NULL);
-
- return label->label;
-}
-
-
-/**
- * e_clipped_label_set_text:
- *
- * @label: An #EClippedLabel.
- * @text: The new label text.
- *
- * Sets the label text.
- **/
-void
-e_clipped_label_set_text (EClippedLabel *label,
- const gchar *text)
-{
- gint len;
-
- g_return_if_fail (E_IS_CLIPPED_LABEL (label));
-
- if (label->label != text || !label->label || !text
- || strcmp (label->label, text)) {
- g_free (label->label);
- g_free (label->label_wc);
- label->label = NULL;
- label->label_wc = NULL;
-
- if (text) {
- label->label = g_strdup (text);
- len = strlen (text);
- label->label_wc = g_new (GdkWChar, len + 1);
- label->wc_len = gdk_mbstowcs (label->label_wc,
- label->label, len + 1);
- label->label_wc[label->wc_len] = '\0';
- }
-
- /* Reset the number of characters displayed, so it is
- recalculated when needed. */
- label->chars_displayed = E_CLIPPED_LABEL_NEED_RECALC;
-
- /* We don't queue a resize, since the label should not affect
- the widget size, but we queue a draw. */
- gtk_widget_queue_draw (GTK_WIDGET (label));
- }
-}
-
-
-static void
-e_clipped_label_recalc_chars_displayed (EClippedLabel *label)
-{
- GdkFont *font;
- gint max_width, width, ch, last_width;
-
- font = GTK_WIDGET (label)->style->font;
-
- max_width = GTK_WIDGET (label)->allocation.width
- - 2 * GTK_MISC (label)->xpad;
-
- if (!label->label) {
- label->chars_displayed = 0;
- return;
- }
-
- /* See if the entire label fits in the allocated width. */
- label->label_width = gdk_string_width (font, label->label);
- if (label->label_width <= max_width) {
- label->chars_displayed = E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL;
- return;
- }
-
- /* Calculate the width of the ellipsis string. */
- max_width -= gdk_string_measure (font, e_clipped_label_ellipsis);
-
- if (max_width <= 0) {
- label->chars_displayed = 0;
- label->ellipsis_x = 0;
- return;
- }
-
- /* Step through the wide-char label, adding on the widths of the
- characters, until we can't fit any more in. */
- width = last_width = 0;
- for (ch = 0; ch < label->wc_len; ch++) {
- width += gdk_char_width_wc (font, label->label_wc[ch]);
-
- if (width > max_width) {
- label->chars_displayed = ch;
- label->ellipsis_x = last_width;
- return;
- }
-
- last_width = width;
- }
-
- g_warning ("Clipped label width not exceeded as expected");
- label->chars_displayed = E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL;
-}
-
diff --git a/widgets/shortcut-bar/e-clipped-label.h b/widgets/shortcut-bar/e-clipped-label.h
deleted file mode 100644
index b94d261c11..0000000000
--- a/widgets/shortcut-bar/e-clipped-label.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * This is similar to GtkLabel but clips itself and displays '...' if it
- * can't fit inside its allocated area. The intended use is for inside buttons
- * that are a fixed size. The GtkLabel would normally display only the middle
- * part of the text, which doesn't look very good. This only supports one line
- * of text (so no wrapping/justification), without underlined characters.
- */
-#ifndef _E_CLIPPED_LABEL_H_
-#define _E_CLIPPED_LABEL_H_
-
-#include <gtk/gtkmisc.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#define E_CLIPPED_LABEL(obj) GTK_CHECK_CAST (obj, e_clipped_label_get_type (), EClippedLabel)
-#define E_CLIPPED_LABEL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_clipped_label_get_type (), EClippedLabelClass)
-#define E_IS_CLIPPED_LABEL(obj) GTK_CHECK_TYPE (obj, e_clipped_label_get_type ())
-
-
-typedef struct _EClippedLabel EClippedLabel;
-typedef struct _EClippedLabelClass EClippedLabelClass;
-
-struct _EClippedLabel
-{
- GtkMisc misc;
-
- gchar *label;
- GdkWChar *label_wc;
-
- /* This is the number of wide characters in the label. */
- gint wc_len;
-
- /* This is the width of the entire label string, in pixels. */
- gint label_width;
-
- /* This is the number of characters we can fit in, or
- E_CLIPPED_LABEL_NEED_RECALC if it needs to be recalculated, or
- E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL to show the entire label. */
- gint chars_displayed;
-
- /* This is the x position to display the ellipsis string, e.g. '...',
- relative to the start of the label. */
- gint ellipsis_x;
-};
-
-struct _EClippedLabelClass
-{
- GtkMiscClass parent_class;
-};
-
-
-GtkType e_clipped_label_get_type (void);
-GtkWidget* e_clipped_label_new (const gchar *text);
-
-gchar* e_clipped_label_get_text (EClippedLabel *label);
-void e_clipped_label_set_text (EClippedLabel *label,
- const gchar *text);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_CLIPPED_LABEL_H_ */
diff --git a/widgets/shortcut-bar/e-group-bar.c b/widgets/shortcut-bar/e-group-bar.c
deleted file mode 100644
index 603aa6f78f..0000000000
--- a/widgets/shortcut-bar/e-group-bar.c
+++ /dev/null
@@ -1,1498 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * ShortcutBar displays a vertical bar with a number of Groups, each of which
- * contains any number of icons. It is used on the left of the main application
- * window so users can easily access items such as folders and files.
- */
-
-#include <math.h>
-
-#include <gnome.h>
-
-#include "e-group-bar.h"
-
-#define E_GROUP_BAR_SCROLL_TIMEOUT 10
-#define E_GROUP_BAR_MIN_STEP_SIZE 4
-
-#define E_GROUP_BAR_AUTO_SHOW_TIMEOUT 300
-
-
-static void e_group_bar_class_init (EGroupBarClass *class);
-static void e_group_bar_init (EGroupBar *group_bar);
-static void e_group_bar_destroy (GtkObject *object);
-static void e_group_bar_realize (GtkWidget *widget);
-static void e_group_bar_unrealize (GtkWidget *widget);
-static void e_group_bar_map (GtkWidget *widget);
-static void e_group_bar_unmap (GtkWidget *widget);
-static void e_group_bar_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void e_group_bar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gint e_group_bar_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static void e_group_bar_draw (GtkWidget *widget,
- GdkRectangle *area);
-static void e_group_bar_add (GtkContainer *container,
- GtkWidget *widget);
-static void e_group_bar_remove (GtkContainer *container,
- GtkWidget *widget);
-static void e_group_bar_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-
-static void e_group_bar_create_group_button_window (EGroupBar *group_bar,
- gint group_num);
-static void e_group_bar_create_group_child_window (EGroupBar *group_bar,
- gint group_num);
-static gint e_group_bar_get_group_button_position (EGroupBar *group_bar,
- gint group_num);
-static gint e_group_bar_sum_button_heights (EGroupBar *group_bar,
- gint first,
- gint last);
-static gint e_group_bar_get_child_height (EGroupBar *group_bar);
-static gint e_group_bar_get_group_child_position (EGroupBar *group_bar,
- gint group_num);
-
-static void e_group_bar_on_button_clicked (GtkWidget *group_button,
- EGroupBar *group_bar);
-static gint e_group_bar_find_button (EGroupBar *group_bar,
- GtkWidget *group_button);
-static void e_group_bar_start_animation (EGroupBar *group_bar,
- gint group_num);
-static gboolean e_group_bar_timeout_handler (gpointer data);
-static gint e_group_bar_get_increment (EGroupBar *group_bar,
- gint window_y,
- gint window_target_y);
-static gboolean e_group_bar_on_button_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- EGroupBar *group_bar);
-static void e_group_bar_on_button_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time,
- EGroupBar *group_bar);
-static gboolean e_group_bar_auto_show (gpointer data);
-static void e_group_bar_stop_all_animation (EGroupBar *group_bar);
-
-
-static GtkContainerClass *parent_class;
-
-
-GtkType
-e_group_bar_get_type (void)
-{
- static GtkType e_group_bar_type = 0;
-
- if (!e_group_bar_type){
- GtkTypeInfo e_group_bar_info = {
- "EGroupBar",
- sizeof (EGroupBar),
- sizeof (EGroupBarClass),
- (GtkClassInitFunc) e_group_bar_class_init,
- (GtkObjectInitFunc) e_group_bar_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
- e_group_bar_type = gtk_type_unique (GTK_TYPE_CONTAINER,
- &e_group_bar_info);
- }
-
- return e_group_bar_type;
-}
-
-
-static void
-e_group_bar_class_init (EGroupBarClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- container_class = (GtkContainerClass *) class;
-
- /* Method override */
- object_class->destroy = e_group_bar_destroy;
-
- widget_class->realize = e_group_bar_realize;
- widget_class->unrealize = e_group_bar_unrealize;
- widget_class->map = e_group_bar_map;
- widget_class->unmap = e_group_bar_unmap;
- widget_class->size_request = e_group_bar_size_request;
- widget_class->size_allocate = e_group_bar_size_allocate;
- widget_class->expose_event = e_group_bar_expose;
- widget_class->draw = e_group_bar_draw;
-
- container_class->add = e_group_bar_add;
- container_class->remove = e_group_bar_remove;
- container_class->forall = e_group_bar_forall;
-}
-
-
-static void
-e_group_bar_init (EGroupBar *group_bar)
-{
-
- GTK_WIDGET_UNSET_FLAGS (group_bar, GTK_NO_WINDOW);
-
- /* We don't want child resizes to propagate up to the parent. */
- gtk_container_set_resize_mode (GTK_CONTAINER (group_bar),
- GTK_RESIZE_QUEUE);
-
- group_bar->children = g_array_new (FALSE, FALSE,
- sizeof (EGroupBarChild));
-
- group_bar->current_group_num = -1;
- group_bar->buttons_homogeneous = TRUE;
- group_bar->max_button_height = 0;
- group_bar->animation_timeout_id = 0;
-}
-
-
-/**
- * e_group_bar_new:
- * @Returns: a new #EGroupBar.
- *
- * Creates a new #EGroupBar.
- **/
-GtkWidget *
-e_group_bar_new (void)
-{
- GtkWidget *group_bar;
-
- group_bar = GTK_WIDGET (gtk_type_new (e_group_bar_get_type ()));
-
- return group_bar;
-}
-
-
-static void
-e_group_bar_destroy (GtkObject *object)
-{
- EGroupBar *group_bar;
-
- group_bar = E_GROUP_BAR (object);
-
- e_group_bar_stop_all_animation (group_bar);
-
- /* The parent GtkContainer class will automatically destroy all the
- child widgets, but it calls gtk_container_foreach() so we must not
- destroy our children array until after. */
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-
- g_array_free (group_bar->children, TRUE);
-}
-
-
-static void
-e_group_bar_realize (GtkWidget *widget)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- GdkWindowAttr attributes;
- gint attributes_mask;
- gint border_width, group_num;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (widget));
-
- group_bar = E_GROUP_BAR (widget);
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- border_width = GTK_CONTAINER (group_bar)->border_width;
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - 2 * border_width;
- attributes.height = widget->allocation.height - 2 * border_width;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_EXPOSURE_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y
- | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window,
- GTK_STATE_NORMAL);
-
- gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
-
- /* Create windows for all the buttons & group canvases. */
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- e_group_bar_create_group_button_window (group_bar, group_num);
- e_group_bar_create_group_child_window (group_bar, group_num);
- }
-}
-
-
-static void
-e_group_bar_unrealize (GtkWidget *widget)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (widget));
-
- group_bar = E_GROUP_BAR (widget);
-
- /* Destroy the windows for all the buttons & group canvases. */
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->button_window) {
- gdk_window_set_user_data (group->button_window, NULL);
- gdk_window_destroy (group->button_window);
- group->button_window = NULL;
- }
- if (group->child_window) {
- gdk_window_set_user_data (group->child_window, NULL);
- gdk_window_destroy (group->child_window);
- group->child_window = NULL;
- }
- }
-
- if (GTK_WIDGET_CLASS (parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
-}
-
-
-static void
-e_group_bar_map (GtkWidget *widget)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (widget));
-
- group_bar = E_GROUP_BAR (widget);
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
- /* We do this in reverse order, and lower all the child windows, so
- the stacking order ends up correct. */
- for (group_num = group_bar->children->len - 1;
- group_num >= 0;
- group_num--) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->button_window) {
- gdk_window_show (group->button_window);
- }
-
- if (group->button
- && GTK_WIDGET_VISIBLE (group->button)
- && !GTK_WIDGET_MAPPED (group->button)) {
- gtk_widget_map (group->button);
- }
-
- if (group->child_window) {
- gdk_window_show (group->child_window);
- gdk_window_lower (group->child_window);
- }
-
- if (group->child
- && GTK_WIDGET_VISIBLE (group->child)
- && !GTK_WIDGET_MAPPED (group->child))
- gtk_widget_map (group->child);
- }
-
- gdk_window_show (widget->window);
-}
-
-
-static void
-e_group_bar_unmap (GtkWidget *widget)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (widget));
-
- group_bar = E_GROUP_BAR (widget);
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->button_window) {
- gdk_window_hide (group->button_window);
- }
-
- if (group->button
- && GTK_WIDGET_MAPPED (group->button))
- gtk_widget_unmap (group->button);
-
- if (group->child_window) {
- gdk_window_hide (group->child_window);
- }
-
- if (group->child
- && GTK_WIDGET_MAPPED (group->child))
- gtk_widget_unmap (group->child);
- }
-
- gdk_window_hide (widget->window);
-}
-
-
-static void
-e_group_bar_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num, max_child_height;
- GtkRequisition child_requisition;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (widget));
- g_return_if_fail (requisition != NULL);
-
- group_bar = E_GROUP_BAR (widget);
-
- /* We set the requisition width to the largest requested width of the
- child widgets. The requisition height is set to the sum of all the
- button heights plus the height of the largest child. */
- requisition->width = 0;
- requisition->height = 0;
-
- /* We have to call size_request on all children, even though we don't
- use the results, since some widgets like GtkLabel depend on it. */
- group_bar->max_button_height = 0;
- max_child_height = 0;
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->button) {
- gtk_widget_size_request (group->button,
- &child_requisition);
- group->button_height = child_requisition.height;
- } else {
- group->button_height = 0;
- }
-
- group_bar->max_button_height = MAX (group_bar->max_button_height, group->button_height);
- requisition->height += child_requisition.height;
-
- if (group->child) {
- gtk_widget_size_request (group->child,
- &child_requisition);
- max_child_height = MAX (max_child_height,
- child_requisition.height);
- requisition->width = MAX (requisition->width,
- child_requisition.width);
- }
- }
-
- requisition->height += max_child_height;
-
- /* Add on the standard container border widths. */
- requisition->width += GTK_CONTAINER (widget)->border_width * 2;
- requisition->height += GTK_CONTAINER (widget)->border_width * 2;
-}
-
-
-static void
-e_group_bar_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num, border_width, width, height, child_height, y;
- GtkAllocation button_allocation, child_allocation;
-
- group_bar = E_GROUP_BAR (widget);
-
- /* All child & button windows and widgets use the same width as the
- group bar minus the border width. */
- border_width = GTK_CONTAINER (widget)->border_width;
- width = allocation->width - border_width * 2;
- height = allocation->height - border_width * 2;
-
- widget->allocation = *allocation;
- if (GTK_WIDGET_REALIZED (widget))
- gdk_window_move_resize (widget->window,
- allocation->x + border_width,
- allocation->y + border_width,
- width, height);
-
- /* All the child widgets use the same height. */
- child_height = e_group_bar_get_child_height (group_bar);
-
- /* The buttons are always in the top-left of the button windows, and
- all have the same width. The height is calculated for each group. */
- button_allocation.x = 0;
- button_allocation.y = 0;
- button_allocation.width = width;
-
- /* The child widgets are always in the top-left of the child windows,
- and all have the same width and height. */
- child_allocation.x = 0;
- child_allocation.y = 0;
- child_allocation.width = width;
- child_allocation.height = child_height;
-
- /* Step through the groups, placing the windows as necessary, and
- allocating the areas for the child widgets. Note that if a button
- or child window is in the middle of an animation, we just resize it
- and update the target position, and let the animation continue. */
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- /* Calculate the y position of the button, which depends on
- the currently selected group and the button heights. */
- y = e_group_bar_get_group_button_position (group_bar, group_num);
- button_allocation.height = group_bar->buttons_homogeneous ? group_bar->max_button_height : group->button_height;
-
- if (GTK_WIDGET_REALIZED (group->button)) {
- if (group->button_window_in_animation) {
- gdk_window_resize (group->button_window,
- width, button_allocation.height);
- group->button_window_target_y = y;
- } else {
- gdk_window_move_resize (group->button_window,
- 0, y, width, button_allocation.height);
- }
- }
- gtk_widget_size_allocate (group->button, &button_allocation);
-
- if (GTK_WIDGET_REALIZED (group->child)) {
- if (group->child_window_in_animation) {
- gdk_window_resize (group->child_window,
- width, child_height);
- group->child_window_target_y = y + button_allocation.height;
- } else {
- gdk_window_move_resize (group->child_window,
- 0, y + button_allocation.height,
- width, child_height);
- }
- }
- gtk_widget_size_allocate (group->child, &child_allocation);
- }
-}
-
-
-static gint
-e_group_bar_expose (GtkWidget *widget,
- GdkEventExpose *event)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- GdkEventExpose child_event;
- gint group_num;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (E_IS_GROUP_BAR (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (GTK_WIDGET_DRAWABLE (widget)) {
- group_bar = E_GROUP_BAR (widget);
-
- child_event = *event;
-
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (event->window == group->button_window
- && GTK_WIDGET_DRAWABLE (group->button)
- && GTK_WIDGET_NO_WINDOW (group->button)
- && gtk_widget_intersect (group->button, &event->area, &child_event.area))
- gtk_widget_event (group->button, (GdkEvent*) &child_event);
-
- if (event->window == group->child_window
- && GTK_WIDGET_DRAWABLE (group->child)
- && GTK_WIDGET_NO_WINDOW (group->child)
- && gtk_widget_intersect (group->child, &event->area, &child_event.area))
- gtk_widget_event (group->child, (GdkEvent*) &child_event);
- }
- }
-
- return FALSE;
-}
-
-
-static void
-e_group_bar_draw (GtkWidget *widget,
- GdkRectangle *area)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num;
-#if 0
- GdkRectangle child_area;
-#endif
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (widget));
-
- g_print ("In e_group_bar_draw %i,%i %ix%i\n", area->x, area->y,
- area->width, area->height);
-
- if (GTK_WIDGET_DRAWABLE (widget)) {
- group_bar = E_GROUP_BAR (widget);
-
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- /* FIXME */
-#if 0
- if (GTK_WIDGET_DRAWABLE (child->widget) &&
- gtk_widget_intersect (child->widget, area, &child_area))
- gtk_widget_draw (child->widget, &child_area);
-#endif
- }
- }
-}
-
-
-static void
-e_group_bar_add (GtkContainer *container,
- GtkWidget *widget)
-{
- EGroupBar *group_bar;
- GtkWidget *button;
- gchar buffer[32];
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (container));
- g_return_if_fail (widget != NULL);
-
- g_snprintf (buffer, sizeof (buffer), _("Group %i"),
- group_bar->children->len + 1);
- button = gtk_button_new_with_label (buffer);
- gtk_widget_show (button);
-
- e_group_bar_add_group (group_bar, widget, button, -1);
-}
-
-
-static void
-e_group_bar_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- EGroupBar *group_bar;
- gint group_num;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (container));
- g_return_if_fail (widget != NULL);
-
- group_bar = E_GROUP_BAR (container);
-
- group_num = e_group_bar_get_group_num (group_bar, widget);
- e_group_bar_remove_group (group_bar, group_num);
-}
-
-
-static void
-e_group_bar_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num;
- GList *tmp_list;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (container));
- g_return_if_fail (callback != NULL);
-
- group_bar = E_GROUP_BAR (container);
-
- /* Note that drag-and-drop does not check the Z-order of widgets, so
- we have to iterate through them from top to bottom, or it will
- not work properly. We also have to use temporary lists so widgets
- can be safely destroyed while iterating. */
-
- if (include_internals) {
- tmp_list = NULL;
- for (group_num = group_bar->children->len - 1;
- group_num >= 0;
- group_num--) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->button)
- tmp_list = g_list_prepend (tmp_list,
- group->button);
- }
-
- g_list_foreach (tmp_list, (GFunc) callback, callback_data);
- g_list_free (tmp_list);
- }
-
- tmp_list = NULL;
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->child)
- tmp_list = g_list_prepend (tmp_list, group->child);
- }
- g_list_foreach (tmp_list, (GFunc) callback, callback_data);
- g_list_free (tmp_list);
-}
-
-
-static void
-e_group_bar_create_group_button_window (EGroupBar *group_bar,
- gint group_num)
-{
- EGroupBarChild *group;
- GtkWidget *widget;
- GdkWindowAttr attributes;
- gint attributes_mask;
- gint y, height, border_width;
-
- widget = GTK_WIDGET (group_bar);
-
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- y = e_group_bar_get_group_button_position (group_bar, group_num);
- height = group_bar->buttons_homogeneous ? group_bar->max_button_height
- : group->button_height;
- border_width = GTK_CONTAINER (group_bar)->border_width;
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = 0;
- attributes.y = y;
- attributes.width = widget->allocation.width - 2 * border_width;
- attributes.height = height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_EXPOSURE_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y
- | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- group->button_window = gdk_window_new (widget->window, &attributes,
- attributes_mask);
- gdk_window_set_user_data (group->button_window, widget);
-
- gtk_widget_set_parent_window (group->button,
- group->button_window);
- gdk_window_set_back_pixmap (group->button_window, NULL, TRUE);
-}
-
-
-static void
-e_group_bar_create_group_child_window (EGroupBar *group_bar,
- gint group_num)
-{
- EGroupBarChild *group;
- GtkWidget *widget;
- GdkWindowAttr attributes;
- gint attributes_mask;
- gint y, height, border_width;
-
- widget = GTK_WIDGET (group_bar);
-
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- y = e_group_bar_get_group_button_position (group_bar, group_num);
- y += group_bar->buttons_homogeneous ? group_bar->max_button_height
- : group->button_height;
- height = e_group_bar_get_child_height (group_bar);
- border_width = GTK_CONTAINER (group_bar)->border_width;
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = 0;
- attributes.y = y;
- attributes.width = widget->allocation.width - 2 * border_width;
- attributes.height = height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_EXPOSURE_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y
- | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- group->child_window = gdk_window_new (widget->window, &attributes,
- attributes_mask);
- gdk_window_set_user_data (group->child_window, widget);
-
- gtk_widget_set_parent_window (GTK_WIDGET (group->child),
- group->child_window);
- gdk_window_set_back_pixmap (group->child_window, NULL, TRUE);
-}
-
-
-/* This returns the y position of a group's button within the EGroupBar window.
- */
-static gint
-e_group_bar_get_group_button_position (EGroupBar *group_bar,
- gint group_num)
-{
- gint border_width, window_height, y;
-
- border_width = GTK_CONTAINER (group_bar)->border_width;
- window_height = GTK_WIDGET (group_bar)->allocation.height - 2 * border_width;
-
- if (group_num <= group_bar->current_group_num)
- y = e_group_bar_sum_button_heights (group_bar, 0, group_num - 1);
- else
- y = window_height - e_group_bar_sum_button_heights (group_bar, group_num, group_bar->children->len - 1);
-
- return y;
-}
-
-
-/* This returns the sum of all the buttons from first to last inclusive. */
-static gint
-e_group_bar_sum_button_heights (EGroupBar *group_bar, gint first, gint last)
-{
- EGroupBarChild *group;
- gint height, group_num;
-
- height = 0;
-
- if (group_bar->buttons_homogeneous)
- return (last - first + 1) * group_bar->max_button_height;
-
- for (group_num = first; group_num <= last; group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- height += group->button_height;
- }
-
- return height;
-}
-
-
-static gint
-e_group_bar_get_group_child_position (EGroupBar *group_bar,
- gint group_num)
-{
- EGroupBarChild *group;
- gint y;
-
- y = e_group_bar_get_group_button_position (group_bar, group_num);
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- y += group_bar->buttons_homogeneous ? group_bar->max_button_height
- : group->button_height;
-
- return y;
-}
-
-
-static gint
-e_group_bar_get_child_height (EGroupBar *group_bar)
-{
- EGroupBarChild *group;
- gint group_num;
-
- /* Start with the allocated height of the EGroupBar, less the border.*/
- group_bar->child_height = GTK_WIDGET (group_bar)->allocation.height;
- group_bar->child_height -= 2 * GTK_CONTAINER (group_bar)->border_width;
-
- /* Now subtract the heights of all the buttons. */
- if (group_bar->buttons_homogeneous) {
- group_bar->child_height -= group_bar->children->len * group_bar->max_button_height;
- } else {
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- group_bar->child_height -= group->button_height;
- }
- }
-
- return group_bar->child_height;
-}
-
-
-/*
- * Insertion, reordering and deletion of items.
- */
-
-/**
- * e_group_bar_add_group:
- * @group_bar: an #EGroupBar.
- * @child: the child widget to add.
- * @button: the button used to show the child widget.
- * @position: the new group's position, or -1 to place it last.
- * @Returns: the position of the new group.
- *
- * Adds a new group to a #EGroupBar at the given position.
- **/
-gint
-e_group_bar_add_group (EGroupBar *group_bar,
- GtkWidget *child,
- GtkWidget *button,
- gint position)
-{
- EGroupBarChild *group, empty_group, *tmp_group;
- gint group_num, tmp_group_num;
-
- g_return_val_if_fail (group_bar != NULL, -1);
- g_return_val_if_fail (E_IS_GROUP_BAR (group_bar), -1);
- g_return_val_if_fail (child != NULL, -1);
- g_return_val_if_fail (button != NULL, -1);
- g_return_val_if_fail (GTK_IS_BUTTON (button), -1);
-
- /* Append an empty group to the children array and get a pointer to
- it, so we can use it like a normal group. */
- group_num = group_bar->children->len;
- g_array_append_val (group_bar->children, empty_group);
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- /* Initialize the group. */
- group->button = button;
- group->button_window = NULL;
- group->child = child;
- group->child_window = NULL;
- group->button_window_in_animation = FALSE;
- group->child_window_in_animation = FALSE;
- group->button_window_target_y = 0;
- group->child_window_target_y = 0;
-
- /* If we don't have a current group, set it to the first one. */
- if (group_bar->current_group_num == -1)
- group_bar->current_group_num = 0;
-
- /* If the EGroupBar widget is realize, we need to create the child
- windows to put the button & child in. */
- if (GTK_WIDGET_REALIZED (group_bar)) {
- e_group_bar_create_group_button_window (group_bar, group_num);
- e_group_bar_create_group_child_window (group_bar, group_num);
-
- /* We need to lower all the child windows of the previous
- groups, in reverse order, to keep the stacking order
- correct. */
- for (tmp_group_num = group_num - 1;
- tmp_group_num >= 0;
- tmp_group_num--) {
- tmp_group = &g_array_index (group_bar->children,
- EGroupBarChild,
- tmp_group_num);
- gdk_window_lower (group->child_window);
- }
- }
-
- gtk_widget_set_parent (group->button, GTK_WIDGET (group_bar));
- gtk_widget_set_parent (group->child, GTK_WIDGET (group_bar));
-
- if (GTK_WIDGET_REALIZED (group_bar)) {
- gtk_widget_realize (group->button);
- gtk_widget_realize (group->child);
- }
-
- if (GTK_WIDGET_VISIBLE (group_bar)
- && GTK_WIDGET_MAPPED (group_bar)) {
- if (group->button
- && GTK_WIDGET_VISIBLE (group->button)
- && !GTK_WIDGET_MAPPED (group->button)) {
- gtk_widget_map (group->button);
- gtk_widget_queue_resize (group->button);
- }
- if (group->child
- && GTK_WIDGET_VISIBLE (group->child)
- && !GTK_WIDGET_MAPPED (group->child)) {
- gtk_widget_map (group->child);
- gtk_widget_queue_resize (group->child);
- }
- }
-
- gtk_signal_connect (GTK_OBJECT (group->button), "clicked",
- GTK_SIGNAL_FUNC (e_group_bar_on_button_clicked),
- group_bar);
-
- gtk_signal_connect (GTK_OBJECT (group->button), "drag_motion",
- GTK_SIGNAL_FUNC (e_group_bar_on_button_drag_motion),
- group_bar);
- gtk_signal_connect (GTK_OBJECT (group->button), "drag_leave",
- GTK_SIGNAL_FUNC (e_group_bar_on_button_drag_leave),
- group_bar);
-
- return group_num;
-}
-
-
-/**
- * e_group_bar_reorder_group:
- * @group_bar: an #EGroupBar.
- * @group_num: the index of the group to move.
- * @new_position: the new position of the group.
- *
- * Moves a group to a new position within the #EGroupBar.
- **/
-void
-e_group_bar_reorder_group (EGroupBar *group_bar,
- gint group_num,
- gint new_position)
-{
- g_return_if_fail (E_IS_GROUP_BAR (group_bar));
-
-}
-
-
-/**
- * e_group_bar_remove_group:
- * @group_bar: an #EGroupBar.
- * @group_num: the index of the group to remove.
- *
- * Removes a group from an #EGroupBar.
- **/
-void
-e_group_bar_remove_group (EGroupBar *group_bar,
- gint group_num)
-{
- EGroupBarChild *group;
-
- g_return_if_fail (E_IS_GROUP_BAR (group_bar));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < group_bar->children->len);
-
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- /* Stop any animation. */
- e_group_bar_stop_all_animation (group_bar);
-
- gtk_widget_unparent (group->child);
- if (group->button)
- gtk_widget_unparent (group->button);
-
- if (group->button_window) {
- gdk_window_set_user_data (group->button_window, NULL);
- gdk_window_destroy (group->button_window);
- }
- if (group->child_window) {
- gdk_window_set_user_data (group->child_window, NULL);
- gdk_window_destroy (group->child_window);
- }
-
- g_array_remove_index (group_bar->children, group_num);
-
- /* Make sure the current group is valid. */
- if (group_bar->current_group_num >= group_bar->children->len)
- group_bar->current_group_num = group_bar->children->len - 1;
-
- gtk_widget_queue_resize (GTK_WIDGET (group_bar));
-}
-
-
-/*
- * Getting & setting the current group.
- */
-
-/**
- * e_group_bar_get_current_group_num:
- * @group_bar: an #EGroupBar.
- * @Returns: the index of the group currently displayed.
- *
- * Returns the index of the group currently displayed.
- **/
-gint
-e_group_bar_get_current_group_num (EGroupBar *group_bar)
-{
- g_return_val_if_fail (E_IS_GROUP_BAR (group_bar), -1);
-
- return group_bar->current_group_num;
-}
-
-
-/**
- * e_group_bar_set_current_group_num:
- * @group_bar: an #EGroupBar.
- * @Returns: the index of the group to display.
- *
- * Sets the group to display.
- **/
-/* FIXME: animate option? May want to set group without animation. */
-void
-e_group_bar_set_current_group_num (EGroupBar *group_bar,
- gint group_num)
-{
- g_return_if_fail (E_IS_GROUP_BAR (group_bar));
-
- /* If that already is the current group, just return. */
- if (group_bar->current_group_num == group_num)
- return;
-
- /* FIXME: Set the target positions of the old current group and the
- new current group, map the new group's child window, and create the
- animation timeout, if we haven't already got one. */
-
- group_bar->current_group_num = group_num;
-
-}
-
-
-/*
- * Getting groups and group numbers.
- */
-
-/**
- * e_group_bar_get_nth_group:
- * @group_bar: an #EGroupBar.
- * @group_num: the index of the group to get.
- * @Returns: the child widget at the given index.
- *
- * Returns the child widget at the given index.
- **/
-GtkWidget*
-e_group_bar_get_nth_group (EGroupBar *group_bar,
- gint group_num)
-{
- EGroupBarChild *group;
-
- g_return_val_if_fail (E_IS_GROUP_BAR (group_bar), NULL);
- g_return_val_if_fail (group_num >= 0, NULL);
- g_return_val_if_fail (group_num < group_bar->children->len, NULL);
-
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- return group->child;
-}
-
-
-/**
- * e_group_bar_get_group_num:
- * @group_bar: an #EGroupBar.
- * @child: the child widget to find.
- * @Returns: the index of the group containing the given widget.
- *
- * Returns the index of the group containing the given child widget.
- **/
-gint
-e_group_bar_get_group_num (EGroupBar *group_bar,
- GtkWidget *child)
-{
- EGroupBarChild *group;
- gint group_num;
-
- g_return_val_if_fail (E_IS_GROUP_BAR (group_bar), -1);
- g_return_val_if_fail (child != NULL, -1);
-
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->child == child)
- return group_num;
- }
-
- return -1;
-}
-
-
-/**
- * e_group_bar_set_group_button_label:
- * @group_bar: an #EGroupBar.
- * @group_num: the index of the group.
- * @label: the label widget to place in the group's button.
- *
- * Sets the label widget for the given group's button, replacing any existing
- * widget in the button.
- **/
-void
-e_group_bar_set_group_button_label (EGroupBar *group_bar,
- gint group_num,
- GtkWidget *label)
-{
- EGroupBarChild *group;
- GtkWidget *button_child;
-
- g_return_if_fail (E_IS_GROUP_BAR (group_bar));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < group_bar->children->len);
-
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- button_child = GTK_BIN (group->button)->child;
- if (button_child) {
- gtk_container_remove (GTK_CONTAINER (group->button),
- button_child);
- }
-
- if (label)
- gtk_container_add (GTK_CONTAINER (group->button), label);
-}
-
-
-/*
- * Getting & setting the EGroupBar options.
- */
-
-/**
- * e_group_bar_get_buttons_homogeneous:
- * @group_bar: an #EGroupBar.
- * @Returns: TRUE if the buttons are homoegeneous.
- *
- * Returns TRUE if the buttons are homogeneous (i.e. all have the same height).
- **/
-gboolean
-e_group_bar_get_buttons_homogeneous (EGroupBar *group_bar)
-{
- g_return_val_if_fail (E_IS_GROUP_BAR (group_bar), TRUE);
-
- return group_bar->buttons_homogeneous;
-}
-
-
-/**
- * e_group_bar_set_buttons_homogeneous:
- * @group_bar: an #EGroupBar.
- * @homogeneous: TRUE if the buttons should be homoegeneous.
- *
- * Specifies whether the buttons should be homogeneous. When set to TRUE all
- * the group buttons will be set to the same height (equal to the largest
- * requested height). When set to FALSE the buttons will use their own
- * individual requested heights.
- **/
-void
-e_group_bar_set_buttons_homogeneous (EGroupBar *group_bar,
- gboolean homogeneous)
-{
- g_return_if_fail (E_IS_GROUP_BAR (group_bar));
-
- /* Just return if the setting hasn't changed. */
- if (group_bar->buttons_homogeneous == homogeneous)
- return;
-
- group_bar->buttons_homogeneous = homogeneous;
-
- /* Update the position & sizes of the buttons. */
- gtk_widget_queue_resize (GTK_WIDGET (group_bar));
-}
-
-
-static void
-e_group_bar_on_button_clicked (GtkWidget *group_button,
- EGroupBar *group_bar)
-{
- gint group_num;
-
- /* Determine which group button was clicked. */
- group_num = e_group_bar_find_button (group_bar, group_button);
-
- if (group_num != -1)
- e_group_bar_start_animation (group_bar, group_num);
-}
-
-
-/* This returns the group containing the given button, or -1 if not found. */
-static gint
-e_group_bar_find_button (EGroupBar *group_bar,
- GtkWidget *group_button)
-{
- EGroupBarChild *group;
- gint group_num;
-
- /* Determine which group button was clicked. */
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- if (group->button == group_button)
- return group_num;
- }
-
- return -1;
-}
-
-
-static void
-e_group_bar_start_animation (EGroupBar *group_bar,
- gint group_num)
-{
- EGroupBarChild *group, *old_group;
- gint old_group_num, step;
-
- old_group_num = group_bar->current_group_num;
-
- /* Return if it is already the current group. */
- if (old_group_num == group_num)
- return;
-
- group_bar->current_group_num = group_num;
-
- /* Calculate the target y position of the new current group button
- and child, and map the child. */
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- group->button_window_target_y = e_group_bar_get_group_button_position (group_bar, group_num);
- group->button_window_in_animation = TRUE;
-
- group->child_window_target_y = e_group_bar_get_group_child_position (group_bar, group_num);
- group->child_window_in_animation = TRUE;
-
- /* Calculate the target y position of the current group button and
- child. */
- old_group = &g_array_index (group_bar->children,
- EGroupBarChild, old_group_num);
- old_group->button_window_target_y = e_group_bar_get_group_button_position (group_bar, old_group_num);
- old_group->button_window_in_animation = TRUE;
-
- old_group->child_window_target_y = e_group_bar_get_group_child_position (group_bar, old_group_num);
- old_group->child_window_in_animation = TRUE;
-
- /* We also need to animate the buttons in between the old group and the
- new group. */
- step = (old_group_num < group_num) ? 1 : -1;
- old_group_num += step;
- while (old_group_num != group_num) {
- old_group = &g_array_index (group_bar->children,
- EGroupBarChild, old_group_num);
- old_group->button_window_target_y = e_group_bar_get_group_button_position (group_bar, old_group_num);
- old_group->button_window_in_animation = TRUE;
-
- old_group->child_window_target_y = e_group_bar_get_group_child_position (group_bar, old_group_num);
- old_group->child_window_in_animation = TRUE;
-
- old_group_num += step;
- }
-
- /* Add a timeout handler if we haven't already got one. */
- if (group_bar->animation_timeout_id == 0) {
- group_bar->animation_timeout_id = g_timeout_add (E_GROUP_BAR_SCROLL_TIMEOUT, e_group_bar_timeout_handler, group_bar);
- }
-}
-
-
-static gboolean
-e_group_bar_timeout_handler (gpointer data)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num, button_window_y, child_window_y;
- gboolean finished = TRUE;
-
- g_return_val_if_fail (E_IS_GROUP_BAR (data), FALSE);
-
- group_bar = E_GROUP_BAR (data);
-
- GDK_THREADS_ENTER ();
-
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->button_window_in_animation) {
- gdk_window_get_position (group->button_window, NULL,
- &button_window_y);
- button_window_y += e_group_bar_get_increment (group_bar, button_window_y, group->button_window_target_y);
- if (button_window_y == group->button_window_target_y)
- group->button_window_in_animation = FALSE;
- else
- finished = FALSE;
- gdk_window_move (group->button_window,
- 0, button_window_y);
- }
- if (group->child_window_in_animation) {
- gdk_window_get_position (group->child_window, NULL,
- &child_window_y);
- child_window_y += e_group_bar_get_increment (group_bar, child_window_y, group->child_window_target_y);
- if (child_window_y == group->child_window_target_y)
- group->child_window_in_animation = FALSE;
- else
- finished = FALSE;
- gdk_window_move (group->child_window,
- 0, child_window_y);
- }
-
- }
-
- if (finished)
- group_bar->animation_timeout_id = 0;
-
- GDK_THREADS_LEAVE ();
-
- return !finished;
-}
-
-
-static gint
-e_group_bar_get_increment (EGroupBar *group_bar,
- gint window_y,
- gint window_target_y)
-{
- gdouble percentage;
- gint distance, total_distance, step;
-
- total_distance = group_bar->child_height;
- distance = MIN (abs (window_target_y - window_y), total_distance);
-
- /* Convert the distance into an angle between -PI/2 and PI/2, so we can
- then do a cosine of it. */
- percentage = cos (M_PI * ((gdouble)distance / (gdouble)total_distance) - M_PI / 2);
-
- /* Now multiply by our maximum step size to get the step size. */
- step = percentage * total_distance / 6;
-
- /* Add it to the minimum step size, but don't go too far. */
- step = step + E_GROUP_BAR_MIN_STEP_SIZE;
- step = MIN (step, distance);
-
- if (window_target_y > window_y)
- return step;
- else
- return -step;
-}
-
-
-static gboolean
-e_group_bar_on_button_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- EGroupBar *group_bar)
-{
- gint group_num;
-
- if (!group_bar->auto_show_timeout_id) {
- group_num = e_group_bar_find_button (group_bar, widget);
- if (group_num != -1) {
- group_bar->auto_show_timeout_id = gtk_timeout_add (E_GROUP_BAR_AUTO_SHOW_TIMEOUT, e_group_bar_auto_show, group_bar);
- group_bar->auto_show_group_num = group_num;
- }
- }
- return TRUE;
-}
-
-
-static void
-e_group_bar_on_button_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time,
- EGroupBar *group_bar)
-{
- if (group_bar->auto_show_timeout_id) {
- gtk_timeout_remove (group_bar->auto_show_timeout_id);
- group_bar->auto_show_timeout_id = 0;
- }
-}
-
-
-static gboolean
-e_group_bar_auto_show (gpointer data)
-{
- EGroupBar *group_bar;
-
- g_return_val_if_fail (E_IS_GROUP_BAR (data), FALSE);
-
- group_bar = E_GROUP_BAR (data);
-
- GDK_THREADS_ENTER ();
-
- e_group_bar_start_animation (group_bar,
- group_bar->auto_show_group_num);
-
- group_bar->auto_show_timeout_id = 0;
-
- GDK_THREADS_LEAVE ();
-
- return FALSE;
-}
-
-
-/* This removes all timeouts and sets all 'in_animation' flags to FALSE. */
-static void
-e_group_bar_stop_all_animation (EGroupBar *group_bar)
-{
- EGroupBarChild *group;
- gint group_num;
-
- if (group_bar->animation_timeout_id) {
- g_source_remove (group_bar->animation_timeout_id);
- group_bar->animation_timeout_id = 0;
- }
- if (group_bar->auto_show_timeout_id) {
- g_source_remove (group_bar->auto_show_timeout_id);
- group_bar->auto_show_timeout_id = 0;
- }
-
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- group->button_window_in_animation = FALSE;
- group->child_window_in_animation = FALSE;
- }
-}
-
diff --git a/widgets/shortcut-bar/e-group-bar.h b/widgets/shortcut-bar/e-group-bar.h
deleted file mode 100644
index 9a6f83b461..0000000000
--- a/widgets/shortcut-bar/e-group-bar.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-#ifndef _E_GROUP_BAR_H_
-#define _E_GROUP_BAR_H_
-
-#include <gtk/gtkcontainer.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*
- * EGroupBar displays a vertical bar with a number of Groups, which are viewed
- * one at a time by selecting the Group's button. When a different Group is
- * selected, it slides into view, and the old Group slides out.
- * It is typically used on the left of the main application window so users
- * can easily access particular features.
- *
- * It is implemented like GtkNotebook, i.e. the main widgets are the children
- * of the EGroupBar and the button widgets are treated specially like the
- * GtkNotebook tab labels.
- */
-
-/* This contains information on one item. */
-typedef struct _EGroupBarChild EGroupBarChild;
-struct _EGroupBarChild
-{
- /* This is the button used to select the group, and the window we use
- to move it around easily. */
- GtkWidget *button;
- GdkWindow *button_window;
- gint button_height;
-
- /* This is the child widget, which can be any widget added by the
- application, and the window we use to move it around easily. */
- GtkWidget *child;
- GdkWindow *child_window;
-
- /* These are TRUE if we are currently animating the windows. */
- gboolean button_window_in_animation;
- gboolean child_window_in_animation;
-
- /* These are the target y positions that the windows should eventually
- move to, used for animation. If we get a size_allocate we just
- update these and the animation can continue as normal.
- When a child window reaches its target position, it is unmapped if
- if it is not the current group (i.e. it has slid off screen). */
- gint button_window_target_y;
- gint child_window_target_y;
-};
-
-
-#define E_GROUP_BAR(obj) GTK_CHECK_CAST (obj, e_group_bar_get_type (), EGroupBar)
-#define E_GROUP_BAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_group_bar_get_type (), EGroupBarClass)
-#define E_IS_GROUP_BAR(obj) GTK_CHECK_TYPE (obj, e_group_bar_get_type ())
-
-
-typedef struct _EGroupBar EGroupBar;
-typedef struct _EGroupBarClass EGroupBarClass;
-
-struct _EGroupBar
-{
- GtkContainer container;
-
- /* This is an array of EGroupBarChild elements. */
- GArray *children;
-
- /* This is the group currently shown. */
- gint current_group_num;
-
- /* This is TRUE if all the buttons are allocated the same height. */
- gboolean buttons_homogeneous;
-
- /* This is the biggest requested height of all the buttons, which we
- use for all buttons when buttons_homogeneous is set. */
- gint max_button_height;
-
- /* This is the height of all the child windows & widgets. */
- gint child_height;
-
- /* The id of the source function for animation timeouts. If this is
- not 0 then we are in the middle of an animation. */
- guint animation_timeout_id;
-
- /* The id of the source function for automatically showing groups when
- the user drags over the group button, and the group to show. */
- guint auto_show_timeout_id;
- gint auto_show_group_num;
-};
-
-struct _EGroupBarClass
-{
- GtkContainerClass parent_class;
-};
-
-
-GtkType e_group_bar_get_type (void);
-GtkWidget* e_group_bar_new (void);
-
-/*
- * Insertion, reordering and deletion of items.
- */
-
-/* Adds a new group at the given position. If position is -1 it adds it as
- the last group. It returns the group number. */
-gint e_group_bar_add_group (EGroupBar *group_bar,
- GtkWidget *child,
- GtkWidget *button,
- gint position);
-void e_group_bar_reorder_group (EGroupBar *group_bar,
- gint group_num,
- gint new_position);
-void e_group_bar_remove_group (EGroupBar *group_bar,
- gint group_num);
-
-/*
- * Getting & setting the current group.
- */
-gint e_group_bar_get_current_group_num (EGroupBar *group_bar);
-void e_group_bar_set_current_group_num (EGroupBar *group_bar,
- gint group_num);
-
-/*
- * Getting groups and group numbers.
- */
-GtkWidget* e_group_bar_get_nth_group (EGroupBar *group_bar,
- gint group_num);
-gint e_group_bar_get_group_num (EGroupBar *group_bar,
- GtkWidget *child);
-
-/*
- * Setting the group button label.
- */
-void e_group_bar_set_group_button_label (EGroupBar *group_bar,
- gint group_num,
- GtkWidget *label);
-
-/*
- * Getting & setting the EGroupBar options.
- */
-gboolean e_group_bar_get_buttons_homogeneous (EGroupBar *group_bar);
-void e_group_bar_set_buttons_homogeneous (EGroupBar *group_bar,
- gboolean homogeneous);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_GROUP_BAR_H_ */
diff --git a/widgets/shortcut-bar/e-icon-bar-bg-item.c b/widgets/shortcut-bar/e-icon-bar-bg-item.c
deleted file mode 100644
index 1bdb7a308d..0000000000
--- a/widgets/shortcut-bar/e-icon-bar-bg-item.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * EIconBarBgItem - A GnomeCanvasItem which covers the entire EIconBar.
- * It paints the rectangles around items when the mouse moves over them, and
- * the lines between items when dragging.
- */
-
-#include "e-icon-bar-bg-item.h"
-#include "e-icon-bar.h"
-
-/* This is the size of the border around the icons, for the shadow. */
-#define E_ICON_BAR_LARGE_ICON_SHADOW_BORDER 2
-#define E_ICON_BAR_SMALL_ICON_SHADOW_BORDER 2
-
-/* These are for the horzontal bar when dragging. */
-#define E_ICON_BAR_BG_ITEM_BAR_HEIGHT 1
-#define E_ICON_BAR_BG_ITEM_BAR_OFFSET 2
-#define E_ICON_BAR_BG_ITEM_LARGE_ARROW_HEIGHT 8
-#define E_ICON_BAR_BG_ITEM_SMALL_ARROW_HEIGHT 4
-
-static void e_icon_bar_bg_item_class_init (EIconBarBgItemClass *class);
-static void e_icon_bar_bg_item_init (EIconBarBgItem *ibitem);
-
-static void e_icon_bar_bg_item_set_arg (GtkObject *o, GtkArg *arg,
- guint arg_id);
-static void e_icon_bar_bg_item_update (GnomeCanvasItem *item,
- double *affine,
- ArtSVP *clip_path, int flags);
-static void e_icon_bar_bg_item_draw (GnomeCanvasItem *item,
- GdkDrawable *drawable,
- int x, int y,
- int width, int height);
-static double e_icon_bar_bg_item_point (GnomeCanvasItem *item,
- double x, double y,
- int cx, int cy,
- GnomeCanvasItem **actual_item);
-static gint e_icon_bar_bg_item_event (GnomeCanvasItem *item,
- GdkEvent *event);
-static gint e_icon_bar_bg_item_button_press (EIconBarBgItem *ibitem,
- GdkEvent *event);
-static gint e_icon_bar_bg_item_button_release (EIconBarBgItem *ibitem,
- GdkEvent *event);
-static gint e_icon_bar_bg_item_motion_notify (EIconBarBgItem *ibitem,
- GdkEvent *event);
-
-static GnomeCanvasItemClass *parent_class;
-
-/* The arguments we take */
-enum {
- ARG_0,
- ARG_ICON_BAR
-};
-
-
-GtkType
-e_icon_bar_bg_item_get_type (void)
-{
- static GtkType e_icon_bar_bg_item_type = 0;
-
- if (!e_icon_bar_bg_item_type) {
- GtkTypeInfo e_icon_bar_bg_item_info = {
- "EIconBarBgItem",
- sizeof (EIconBarBgItem),
- sizeof (EIconBarBgItemClass),
- (GtkClassInitFunc) e_icon_bar_bg_item_class_init,
- (GtkObjectInitFunc) e_icon_bar_bg_item_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- e_icon_bar_bg_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_icon_bar_bg_item_info);
- }
-
- return e_icon_bar_bg_item_type;
-}
-
-
-static void
-e_icon_bar_bg_item_class_init (EIconBarBgItemClass *class)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- parent_class = gtk_type_class (gnome_canvas_item_get_type());
-
- object_class = (GtkObjectClass *) class;
- item_class = (GnomeCanvasItemClass *) class;
-
- gtk_object_add_arg_type ("EIconBarBgItem::icon_bar",
- GTK_TYPE_POINTER, GTK_ARG_WRITABLE,
- ARG_ICON_BAR);
-
- object_class->set_arg = e_icon_bar_bg_item_set_arg;
-
- /* GnomeCanvasItem method overrides */
- item_class->update = e_icon_bar_bg_item_update;
- item_class->draw = e_icon_bar_bg_item_draw;
- item_class->point = e_icon_bar_bg_item_point;
- item_class->event = e_icon_bar_bg_item_event;
-}
-
-
-static void
-e_icon_bar_bg_item_init (EIconBarBgItem *ibitem)
-{
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (ibitem);
-
- ibitem->icon_bar = NULL;
-
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = 0;
- item->y2 = 0;
-}
-
-
-static void
-e_icon_bar_bg_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EIconBarBgItem *ibitem;
-
- item = GNOME_CANVAS_ITEM (o);
- ibitem = E_ICON_BAR_BG_ITEM (o);
-
- switch (arg_id){
- case ARG_ICON_BAR:
- ibitem->icon_bar = GTK_VALUE_POINTER (*arg);
- break;
- }
-}
-
-
-static void
-e_icon_bar_bg_item_update (GnomeCanvasItem *item,
- double *affine,
- ArtSVP *clip_path,
- int flags)
-{
- if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update)
- (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags);
-
- /* The grid covers the entire canvas area. */
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = INT_MAX;
- item->y2 = INT_MAX;
-}
-
-
-/*
- * DRAWING ROUTINES - functions to paint the canvas item.
- */
-
-static void
-e_icon_bar_bg_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
- int x, int y, int width, int height)
-{
- EIconBar *icon_bar;
- EIconBarItem *item;
- EIconBarBgItem *ibitem;
- GtkStyle *style;
- GdkGC *gc;
- GtkShadowType shadow;
- gint item_num, border, bar_x, bar_y, bar_w, i, arrow_height;
-
- ibitem = E_ICON_BAR_BG_ITEM (canvas_item);
- icon_bar = ibitem->icon_bar;
- g_return_if_fail (icon_bar != NULL);
- style = GTK_WIDGET (icon_bar)->style;
-
- /* Draw the highlight around the current highlight item. */
- item_num = -1;
- if (icon_bar->editing_item_num == -1) {
- if (icon_bar->pressed_item_num != -1) {
- item_num = icon_bar->pressed_item_num;
- if (icon_bar->pressed_item_num == icon_bar->mouse_over_item_num)
- shadow = GTK_SHADOW_IN;
- else
- shadow = GTK_SHADOW_OUT;
- } else if (icon_bar->mouse_over_item_num != -1) {
- item_num = icon_bar->mouse_over_item_num;
- shadow = GTK_SHADOW_OUT;
- }
- }
-
- if (item_num != -1) {
- item = &g_array_index (icon_bar->items, EIconBarItem,
- item_num);
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS)
- border = E_ICON_BAR_LARGE_ICON_SHADOW_BORDER;
- else
- border = E_ICON_BAR_SMALL_ICON_SHADOW_BORDER;
-
- gtk_draw_shadow (style, drawable, GTK_STATE_NORMAL, shadow,
- icon_bar->icon_x - border - x,
- item->icon_y - border - y,
- icon_bar->icon_w + border * 2 - 1,
- icon_bar->icon_h + border * 2 - 1);
- }
-
- /* Draw the bar between items when dragging, if needed. */
- if (icon_bar->in_drag && icon_bar->dragging_before_item_num != -1) {
- if (icon_bar->dragging_before_item_num < icon_bar->items->len) {
- item = &g_array_index (icon_bar->items, EIconBarItem,
- icon_bar->dragging_before_item_num);
- bar_y = 0;
- } else {
- /* We need to draw the bar after the last item. */
- item = &g_array_index (icon_bar->items, EIconBarItem,
- icon_bar->items->len - 1);
- bar_y = item->item_height + icon_bar->spacing;
- }
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- bar_y += item->icon_y;
- } else {
- bar_y += MIN (item->icon_y, item->text_y);
- }
- bar_y -= y + icon_bar->spacing / 2;
-
- bar_x = E_ICON_BAR_BG_ITEM_BAR_OFFSET - x;
- bar_w = GTK_WIDGET (icon_bar)->allocation.width - 2 * E_ICON_BAR_BG_ITEM_BAR_OFFSET - 1;
-
- gc = GTK_WIDGET (icon_bar)->style->fg_gc[GTK_STATE_NORMAL];
-
- /* Draw the horizontal bar. */
- gdk_draw_rectangle (drawable, gc, TRUE,
- bar_x, bar_y,
- bar_w, E_ICON_BAR_BG_ITEM_BAR_HEIGHT);
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS)
- arrow_height = E_ICON_BAR_BG_ITEM_LARGE_ARROW_HEIGHT / 2;
- else
- arrow_height = E_ICON_BAR_BG_ITEM_SMALL_ARROW_HEIGHT / 2;
-
- /* Draw the arrows at the end of the lines. We use
- gdk_draw_line() to draw a series of vertical lines, since
- gdk_draw_polygon() produces odd results. */
- i = 0;
- while (arrow_height > 0) {
- gdk_draw_line (drawable, gc,
- bar_x + i,
- bar_y - arrow_height,
- bar_x + i,
- bar_y + arrow_height);
- gdk_draw_line (drawable, gc,
- bar_x + bar_w - i - 1,
- bar_y - arrow_height,
- bar_x + bar_w - i - 1,
- bar_y + arrow_height);
- arrow_height--;
- i++;
- }
- }
-}
-
-
-/* This is supposed to return the nearest item the the point and the distance.
- Since we are the only item we just return ourself and 0 for the distance.
- This is needed so that we get button/motion events. */
-static double
-e_icon_bar_bg_item_point (GnomeCanvasItem *item, double x, double y,
- int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- *actual_item = item;
- return 0.0;
-}
-
-
-static gint
-e_icon_bar_bg_item_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EIconBarBgItem *ibitem;
-
- ibitem = E_ICON_BAR_BG_ITEM (item);
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- return e_icon_bar_bg_item_button_press (ibitem, event);
- case GDK_BUTTON_RELEASE:
- return e_icon_bar_bg_item_button_release (ibitem, event);
- case GDK_MOTION_NOTIFY:
- return e_icon_bar_bg_item_motion_notify (ibitem, event);
- default:
- break;
- }
-
- return FALSE;
-}
-
-
-static gint
-e_icon_bar_bg_item_button_press (EIconBarBgItem *ibitem,
- GdkEvent *event)
-{
- gint item_num;
-
- item_num = e_icon_bar_find_item_at_position (ibitem->icon_bar,
- event->button.x,
- event->button.y,
- NULL);
- e_icon_bar_item_pressed (ibitem->icon_bar, item_num, event);
- return TRUE;
-}
-
-
-static gint
-e_icon_bar_bg_item_button_release (EIconBarBgItem *ibitem,
- GdkEvent *event)
-{
- gint item_num;
-
- item_num = e_icon_bar_find_item_at_position (ibitem->icon_bar,
- event->button.x,
- event->button.y,
- NULL);
- e_icon_bar_item_released (ibitem->icon_bar, item_num, event);
- return TRUE;
-}
-
-
-static gint
-e_icon_bar_bg_item_motion_notify (EIconBarBgItem *ibitem,
- GdkEvent *event)
-{
- gint item_num;
-
- item_num = e_icon_bar_find_item_at_position (ibitem->icon_bar,
- event->motion.x,
- event->motion.y,
- NULL);
- e_icon_bar_item_motion (ibitem->icon_bar, item_num, event);
- return TRUE;
-}
diff --git a/widgets/shortcut-bar/e-icon-bar-bg-item.h b/widgets/shortcut-bar/e-icon-bar-bg-item.h
deleted file mode 100644
index ae25e987d7..0000000000
--- a/widgets/shortcut-bar/e-icon-bar-bg-item.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * EIconBarBgItem - A GnomeCanvasItem which covers the entire EIconBar.
- * It paints the rectangles around items when the mouse moves over them, and
- * the lines between items when dragging.
- */
-
-#ifndef _E_ICON_BAR_BG_ITEM_H_
-#define _E_ICON_BAR_BG_ITEM_H_
-
-#include <libgnomeui/gnome-canvas.h>
-
-#include "e-icon-bar.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-#define E_ICON_BAR_BG_ITEM(obj) (GTK_CHECK_CAST((obj), e_icon_bar_bg_item_get_type (), EIconBarBgItem))
-#define E_ICON_BAR_BG_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), e_icon_bar_bg_item_get_type (), EIconBarBgItemClass))
-#define E_IS_ICON_BAR_BG_ITEM(o) (GTK_CHECK_TYPE((o), e_icon_bar_bg_item_get_type ()))
-
-
-typedef struct _EIconBarBgItem EIconBarBgItem;
-typedef struct _EIconBarBgItemClass EIconBarBgItemClass;
-
-struct _EIconBarBgItem
-{
- GnomeCanvasItem canvas_item;
-
- /* The parent EIconBar widget. */
- EIconBar *icon_bar;
-};
-
-
-struct _EIconBarBgItemClass
-{
- GnomeCanvasItemClass parent_class;
-};
-
-GtkType e_icon_bar_bg_item_get_type (void);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_ICON_BAR_BG_ITEM_H_ */
diff --git a/widgets/shortcut-bar/e-icon-bar-text-item.c b/widgets/shortcut-bar/e-icon-bar-text-item.c
deleted file mode 100644
index 5548c630b3..0000000000
--- a/widgets/shortcut-bar/e-icon-bar-text-item.c
+++ /dev/null
@@ -1,1696 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * Based on gnome-icon-text-item: an editable text block with word wrapping
- * for the GNOME canvas.
- *
- * Copyright (C) 1998, 1999 The Free Software Foundation
- *
- * Authors: Miguel de Icaza <miguel@gnu.org>
- * Federico Mena <federico@gimp.org>
- */
-
-/*
- * EIconBarTextItem - An editable canvas text item for the EIconBar.
- */
-
-#include <math.h>
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkwindow.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnome/gnome-i18n.h>
-
-#include "e-icon-bar-text-item.h"
-
-
-/* Margins used to display the information */
-#define MARGIN_X 2
-#define MARGIN_Y 2
-
-/* Default fontset to be used if the user specified fontset is not found */
-#define DEFAULT_FONT_NAME "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*," \
- "-*-*-medium-r-normal--10-*-*-*-*-*-*-*,*"
-
-/* Separators for text layout */
-#define DEFAULT_SEPARATORS " \t-.[]#"
-
-/* This is the string to draw when the text is clipped, e.g. '...'. */
-static gchar *e_icon_bar_text_item_ellipsis;
-
-/* Aliases to minimize screen use in my laptop */
-#define ITI(x) E_ICON_BAR_TEXT_ITEM (x)
-#define ITI_CLASS(x) E_ICON_BAR_TEXT_ITEM_CLASS (x)
-#define IS_ITI(x) E_IS_ICON_BAR_TEXT_ITEM (x)
-
-
-typedef EIconBarTextItem Iti;
-
-/* Private part of the EIconBarTextItem structure */
-typedef struct {
- /* Font */
- GdkFont *font;
-
- /* Hack: create an offscreen window and place an entry inside it */
- GtkEntry *entry;
- GtkWidget *entry_top;
-
- /* Whether the user pressed the mouse while the item was unselected */
- guint unselected_click : 1;
-
- /* Whether we need to update the position */
- guint need_pos_update : 1;
-
- /* Whether we need to update the font */
- guint need_font_update : 1;
-
- /* Whether we need to update the text */
- guint need_text_update : 1;
-
- /* Whether we need to update because the editing/selected state changed */
- guint need_state_update : 1;
-} ItiPrivate;
-
-typedef struct _EIconBarTextItemInfoRow EIconBarTextItemInfoRow;
-
-struct _EIconBarTextItemInfoRow {
- gchar *text;
- gint width;
- GdkWChar *text_wc; /* text in wide characters */
- gint text_length; /* number of characters */
-};
-
-struct _EIconBarTextItemInfo {
- GList *rows;
- GdkFont *font;
- gint width;
- gint height;
- gint baseline_skip;
-};
-
-static GnomeCanvasItemClass *parent_class;
-
-enum {
- ARG_0,
- ARG_XALIGN,
- ARG_JUSTIFY,
- ARG_MAX_LINES,
- ARG_SHOW_ELLIPSIS
-};
-
-enum {
- TEXT_CHANGED,
- HEIGHT_CHANGED,
- WIDTH_CHANGED,
- EDITING_STARTED,
- EDITING_STOPPED,
- SELECTION_STARTED,
- SELECTION_STOPPED,
- LAST_SIGNAL
-};
-
-static guint iti_signals [LAST_SIGNAL] = { 0 };
-
-static GdkFont *default_font;
-
-static void e_icon_bar_text_item_free_info (EIconBarTextItemInfo *ti);
-static EIconBarTextItemInfo *e_icon_bar_text_item_layout_text (EIconBarTextItem *iti, GdkFont *font, const gchar *text, const gchar *separators, gint max_width, gboolean confine);
-static void e_icon_bar_text_item_paint_text (EIconBarTextItem *iti,
- EIconBarTextItemInfo *ti,
- GdkDrawable *drawable,
- GdkGC *gc,
- gint x,
- gint y,
- GtkJustification just);
-
-
-/* Stops the editing state of an icon text item */
-static void
-iti_stop_editing (Iti *iti)
-{
- ItiPrivate *priv;
-
- priv = iti->priv;
-
- iti->editing = FALSE;
-
- gtk_widget_destroy (priv->entry_top);
- priv->entry = NULL;
- priv->entry_top = NULL;
-
- priv->need_state_update = TRUE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));
-
- gtk_signal_emit (GTK_OBJECT (iti), iti_signals[EDITING_STOPPED]);
-}
-
-/* Lays out the text in an icon item */
-static void
-layout_text (Iti *iti)
-{
- ItiPrivate *priv;
- char *text;
- int old_width, old_height;
- int width, height;
-
- priv = iti->priv;
-
- /* Save old size */
-
- if (iti->ti) {
- old_width = iti->ti->width + 2 * MARGIN_X;
- old_height = iti->ti->height + 2 * MARGIN_Y;
-
- e_icon_bar_text_item_free_info (iti->ti);
- } else {
- old_width = 2 * MARGIN_X;
- old_height = 2 * MARGIN_Y;
- }
-
- /* Change the text layout */
-
- if (iti->editing)
- text = gtk_entry_get_text (priv->entry);
- else
- text = iti->text;
-
- iti->ti = e_icon_bar_text_item_layout_text (iti, priv->font,
- text,
- DEFAULT_SEPARATORS,
- iti->width - 2 * MARGIN_X,
- TRUE);
-
- /* Check the sizes and see if we need to emit any signals */
-
- width = iti->ti->width + 2 * MARGIN_X;
- height = iti->ti->height + 2 * MARGIN_Y;
-
- if (width != old_width)
- gtk_signal_emit (GTK_OBJECT (iti), iti_signals[WIDTH_CHANGED]);
-
- if (height != old_height)
- gtk_signal_emit (GTK_OBJECT (iti), iti_signals[HEIGHT_CHANGED]);
-}
-
-/* Accepts the text in the off-screen entry of an icon text item */
-static void
-iti_edition_accept (Iti *iti)
-{
- ItiPrivate *priv;
- gboolean accept;
-
- priv = iti->priv;
- accept = TRUE;
-
- gtk_signal_emit (GTK_OBJECT (iti), iti_signals [TEXT_CHANGED], &accept);
-
- if (iti->editing){
- if (accept) {
- if (iti->is_text_allocated)
- g_free (iti->text);
-
- iti->text = g_strdup (gtk_entry_get_text (priv->entry));
- iti->is_text_allocated = 1;
- }
-
- iti_stop_editing (iti);
- }
-
- priv->need_text_update = TRUE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));
-}
-
-/* Callback used when the off-screen entry of an icon text item is activated.
- * When this happens, we have to accept edition.
- */
-static void
-iti_entry_activate (GtkWidget *entry, Iti *iti)
-{
- iti_edition_accept (iti);
-}
-
-/* Starts the editing state of an icon text item */
-static void
-iti_start_editing (Iti *iti)
-{
- ItiPrivate *priv;
-
- priv = iti->priv;
-
- if (iti->editing)
- return;
-
- /* Trick: The actual edition of the entry takes place in a GtkEntry
- * which is placed offscreen. That way we get all of the advantages
- * from GtkEntry without duplicating code. Yes, this is a hack.
- */
- priv->entry = (GtkEntry *) gtk_entry_new ();
- gtk_entry_set_text (priv->entry, iti->text);
- gtk_signal_connect (GTK_OBJECT (priv->entry), "activate",
- GTK_SIGNAL_FUNC (iti_entry_activate), iti);
-
- priv->entry_top = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_container_add (GTK_CONTAINER (priv->entry_top), GTK_WIDGET (priv->entry));
- gtk_widget_set_uposition (priv->entry_top, 20000, 20000);
- gtk_widget_show_all (priv->entry_top);
-
- gtk_editable_select_region (GTK_EDITABLE (priv->entry), 0, -1);
-
- iti->editing = TRUE;
-
- priv->need_text_update = TRUE;
- priv->need_state_update = TRUE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));
-
- gtk_signal_emit (GTK_OBJECT (iti), iti_signals[EDITING_STARTED]);
-}
-
-/* Destroy method handler for the icon text item */
-static void
-iti_destroy (GtkObject *object)
-{
- Iti *iti;
- ItiPrivate *priv;
- GnomeCanvasItem *item;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_ITI (object));
-
- iti = ITI (object);
- priv = iti->priv;
- item = GNOME_CANVAS_ITEM (object);
-
- /* FIXME: stop selection and editing */
-
- /* Queue redraw of bounding box */
-
- gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2);
-
- /* Free everything */
-
- if (iti->fontname)
- g_free (iti->fontname);
-
- if (iti->text && iti->is_text_allocated)
- g_free (iti->text);
-
- if (iti->ti)
- e_icon_bar_text_item_free_info (iti->ti);
-
- if (priv->font)
- gdk_font_unref (priv->font);
-
- if (priv->entry_top)
- gtk_widget_destroy (priv->entry_top);
-
- g_free (priv);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-/* set_arg handler for the icon text item */
-static void
-iti_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- Iti *iti;
- GnomeCanvasItem *item;
- ItiPrivate *priv;
- gfloat xalign;
- gint max_lines;
- gboolean show_ellipsis;
- GtkJustification justification;
-
- iti = ITI (object);
- item = GNOME_CANVAS_ITEM (object);
- priv = iti->priv;
-
- switch (arg_id) {
- case ARG_XALIGN:
- xalign = GTK_VALUE_FLOAT (*arg);
- if (iti->xalign != xalign) {
- iti->xalign = xalign;
- priv->need_pos_update = TRUE;
- gnome_canvas_item_request_update (item);
- }
- break;
- case ARG_JUSTIFY:
- justification = GTK_VALUE_ENUM (*arg);
- if (iti->justification != justification) {
- iti->justification = justification;
- priv->need_text_update = TRUE;
- gnome_canvas_item_request_update (item);
- }
- break;
- case ARG_MAX_LINES:
- max_lines = GTK_VALUE_INT (*arg);
- if (iti->max_lines != max_lines) {
- iti->max_lines = max_lines;
- priv->need_text_update = TRUE;
- gnome_canvas_item_request_update (item);
- }
- break;
- case ARG_SHOW_ELLIPSIS:
- show_ellipsis = GTK_VALUE_BOOL (*arg);
- if (iti->show_ellipsis != show_ellipsis) {
- iti->show_ellipsis = show_ellipsis;
- priv->need_text_update = TRUE;
- gnome_canvas_item_request_update (item);
- }
- break;
- default:
- break;
- }
-}
-
-static void
-iti_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- Iti *iti;
- ItiPrivate *priv;
-
- iti = ITI (object);
- priv = iti->priv;
-
- switch (arg_id) {
- case ARG_XALIGN:
- GTK_VALUE_FLOAT (*arg) = iti->xalign;
- break;
- case ARG_JUSTIFY:
- GTK_VALUE_ENUM (*arg) = iti->justification;
- break;
- case ARG_MAX_LINES:
- GTK_VALUE_INT (*arg) = iti->max_lines;
- break;
- case ARG_SHOW_ELLIPSIS:
- GTK_VALUE_BOOL (*arg) = iti->show_ellipsis;
- break;
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-/* Loads the default font for icon text items if necessary */
-static GdkFont *
-get_default_font (void)
-{
- if (!default_font) {
- /* FIXME: this is never unref-ed */
- default_font = gdk_fontset_load (DEFAULT_FONT_NAME);
- g_assert (default_font != NULL);
- }
-
- return gdk_font_ref (default_font);
-}
-
-/* Recomputes the bounding box of an icon text item */
-static void
-recompute_bounding_box (Iti *iti)
-{
- GnomeCanvasItem *item;
- double affine[6];
- ArtPoint p, q;
- int x1, y1, x2, y2;
- int width, height;
-
- item = GNOME_CANVAS_ITEM (iti);
-
- /* Compute width, height, position */
-
- width = iti->ti->width + 2 * MARGIN_X;
- height = iti->ti->height + 2 * MARGIN_Y;
-
- x1 = iti->x + (iti->width - width) * iti->xalign;
- y1 = iti->y;
- x2 = x1 + width;
- y2 = y1 + height;
-
- /* Translate to world coordinates */
-
- gnome_canvas_item_i2w_affine (item, affine);
-
- p.x = x1;
- p.y = y1;
- art_affine_point (&q, &p, affine);
- item->x1 = q.x;
- item->y1 = q.y;
-
- p.x = x2;
- p.y = y2;
- art_affine_point (&q, &p, affine);
- item->x2 = q.x;
- item->y2 = q.y;
-}
-
-/* Update method for the icon text item */
-static void
-iti_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- Iti *iti;
- ItiPrivate *priv;
-
- iti = ITI (item);
- priv = iti->priv;
-
- if (parent_class->update)
- (* parent_class->update) (item, affine, clip_path, flags);
-
- /* If necessary, queue a redraw of the old bounding box */
-
- if ((flags & GNOME_CANVAS_UPDATE_VISIBILITY)
- || (flags & GNOME_CANVAS_UPDATE_AFFINE)
- || priv->need_pos_update
- || priv->need_font_update
- || priv->need_text_update)
- gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2);
-
- if (priv->need_text_update)
- layout_text (iti);
-
- /* Compute new bounds */
-
- if (priv->need_pos_update
- || priv->need_font_update
- || priv->need_text_update)
- recompute_bounding_box (iti);
-
- /* Queue redraw */
-
- gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2);
-
- priv->need_pos_update = FALSE;
- priv->need_font_update = FALSE;
- priv->need_text_update = FALSE;
- priv->need_state_update = FALSE;
-}
-
-/* Draw the icon text item's text when it is being edited */
-static void
-iti_paint_text (Iti *iti, GdkDrawable *drawable, int x, int y)
-{
- ItiPrivate *priv;
- EIconBarTextItemInfoRow *row;
- EIconBarTextItemInfo *ti;
- GtkStyle *style;
- GdkGC *fg_gc, *bg_gc;
- GdkGC *gc, *bgc, *sgc, *bsgc;
- GList *item;
- int xpos, len;
-
- priv = iti->priv;
- style = GTK_WIDGET (GNOME_CANVAS_ITEM (iti)->canvas)->style;
-
- ti = iti->ti;
- len = 0;
- y += ti->font->ascent;
-
- /*
- * Pointers to all of the GCs we use
- */
- gc = style->black_gc;
- bgc = style->white_gc;
- sgc = style->fg_gc [GTK_STATE_SELECTED];
- bsgc = style->bg_gc [GTK_STATE_SELECTED];
-
- for (item = ti->rows; item; item = item->next, len += (row ? row->text_length : 0)) {
- GdkWChar *text_wc;
- int text_length;
- int cursor, offset, i;
- int sel_start, sel_end;
-
- row = item->data;
-
- if (!row) {
- y += ti->baseline_skip;
- continue;
- }
-
- text_wc = row->text_wc;
- text_length = row->text_length;
-
- switch (iti->justification) {
- case GTK_JUSTIFY_LEFT:
- xpos = 0;
- break;
-
- case GTK_JUSTIFY_RIGHT:
- xpos = ti->width - row->width;
- break;
-
- case GTK_JUSTIFY_CENTER:
- xpos = (ti->width - row->width) / 2;
- break;
-
- default:
- /* Anyone care to implement GTK_JUSTIFY_FILL? */
- g_warning ("Justification type %d not supported. Using left-justification.",
- (int) iti->justification);
- xpos = 0;
- }
-
- sel_start = GTK_EDITABLE (priv->entry)->selection_start_pos - len;
- sel_end = GTK_EDITABLE (priv->entry)->selection_end_pos - len;
- offset = 0;
- cursor = GTK_EDITABLE (priv->entry)->current_pos - len;
-
- for (i = 0; *text_wc; text_wc++, i++) {
- int size, px;
-
- size = gdk_text_width_wc (ti->font, text_wc, 1);
-
- if (i >= sel_start && i < sel_end) {
- fg_gc = sgc;
- bg_gc = bsgc;
- } else {
- fg_gc = gc;
- bg_gc = bgc;
- }
-
- px = x + xpos + offset;
- gdk_draw_rectangle (drawable,
- bg_gc,
- TRUE,
- px,
- y - ti->font->ascent,
- size, ti->baseline_skip);
-
- gdk_draw_text_wc (drawable,
- ti->font,
- fg_gc,
- px, y,
- text_wc, 1);
-
- if (cursor == i)
- gdk_draw_line (drawable,
- gc,
- px - 1,
- y - ti->font->ascent,
- px - 1,
- y + ti->font->descent - 1);
-
- offset += size;
- }
-
- if (cursor == i) {
- int px = x + xpos + offset;
-
- gdk_draw_line (drawable,
- gc,
- px - 1,
- y - ti->font->ascent,
- px - 1,
- y + ti->font->descent - 1);
- }
-
- y += ti->baseline_skip;
- }
-}
-
-/* Draw method handler for the icon text item */
-static void
-iti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height)
-{
- Iti *iti;
- GtkStyle *style;
- int w, h;
- int xofs, yofs;
-
- iti = ITI (item);
-
- if (iti->ti) {
- w = iti->ti->width + 2 * MARGIN_X;
- h = iti->ti->height + 2 * MARGIN_Y;
- } else {
- w = 2 * MARGIN_X;
- h = 2 * MARGIN_Y;
- }
-
- xofs = item->x1 - x;
- yofs = item->y1 - y;
-
- style = GTK_WIDGET (item->canvas)->style;
-
- if (iti->selected && !iti->editing)
- gdk_draw_rectangle (drawable,
- style->bg_gc[GTK_STATE_SELECTED],
- TRUE,
- xofs, yofs,
- w, h);
-
- if (iti->editing) {
- gdk_draw_rectangle (drawable,
- style->white_gc,
- TRUE,
- xofs + 1, yofs + 1,
- w - 2, h - 2);
- gdk_draw_rectangle (drawable,
- style->black_gc,
- FALSE,
- xofs, yofs,
- w - 1, h - 1);
-
- iti_paint_text (iti, drawable, xofs + MARGIN_X, yofs + MARGIN_Y);
- } else
- e_icon_bar_text_item_paint_text (iti, iti->ti,
- drawable,
- style->fg_gc[(iti->selected
- ? GTK_STATE_SELECTED
- : GTK_STATE_NORMAL)],
- xofs + MARGIN_X,
- yofs + MARGIN_Y,
- iti->justification);
-}
-
-/* Point method handler for the icon text item */
-static double
-iti_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, GnomeCanvasItem **actual_item)
-{
- double dx, dy;
-
- *actual_item = item;
-
- if (cx < item->x1)
- dx = item->x1 - cx;
- else if (cx > item->x2)
- dx = cx - item->x2;
- else
- dx = 0.0;
-
- if (cy < item->y1)
- dy = item->y1 - cy;
- else if (cy > item->y2)
- dy = cy - item->y2;
- else
- dy = 0.0;
-
- return sqrt (dx * dx + dy * dy);
-}
-
-/* Given X, Y, a mouse position, return a valid index inside the edited text */
-static int
-iti_idx_from_x_y (Iti *iti, int x, int y)
-{
- ItiPrivate *priv;
- EIconBarTextItemInfoRow *row;
- int lines;
- int line, col, i, idx;
- GList *l;
-
- priv = iti->priv;
-
- if (iti->ti->rows == NULL)
- return 0;
-
- lines = g_list_length (iti->ti->rows);
- line = y / iti->ti->baseline_skip;
-
- if (line < 0)
- line = 0;
- else if (lines < line + 1)
- line = lines - 1;
-
- /* Compute the base index for this line */
- for (l = iti->ti->rows, idx = i = 0; i < line; l = l->next, i++) {
- row = l->data;
- idx += row->text_length;
- }
-
- row = g_list_nth (iti->ti->rows, line)->data;
- col = 0;
- if (row != NULL) {
- int first_char;
- int last_char;
-
- first_char = (iti->ti->width - row->width) / 2;
- last_char = first_char + row->width;
-
- if (x < first_char) {
- /* nothing */
- } else if (x > last_char) {
- col = row->text_length;
- } else {
- GdkWChar *s = row->text_wc;
- int pos = first_char;
-
- while (pos < last_char) {
- pos += gdk_text_width_wc (iti->ti->font, s, 1);
- if (pos > x)
- break;
- col++;
- s++;
- }
- }
- }
-
- idx += col;
-
- g_assert (idx <= priv->entry->text_size);
-
- return idx;
-}
-
-/* Starts the selection state in the icon text item */
-static void
-iti_start_selecting (Iti *iti, int idx, guint32 event_time)
-{
- ItiPrivate *priv;
- GtkEditable *e;
- GdkCursor *ibeam;
-
- priv = iti->priv;
- e = GTK_EDITABLE (priv->entry);
-
- gtk_editable_select_region (e, idx, idx);
- gtk_editable_set_position (e, idx);
- ibeam = gdk_cursor_new (GDK_XTERM);
- gnome_canvas_item_grab (GNOME_CANVAS_ITEM (iti),
- GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_MASK,
- ibeam, event_time);
- gdk_cursor_destroy (ibeam);
-
- gtk_editable_select_region (e, idx, idx);
- e->current_pos = e->selection_start_pos;
- e->has_selection = TRUE;
- iti->selecting = TRUE;
-
- priv->need_state_update = TRUE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));
-
- gtk_signal_emit (GTK_OBJECT (iti), iti_signals[SELECTION_STARTED]);
-}
-
-/* Stops the selection state in the icon text item */
-static void
-iti_stop_selecting (Iti *iti, guint32 event_time)
-{
- ItiPrivate *priv;
- GnomeCanvasItem *item;
- GtkEditable *e;
-
- priv = iti->priv;
- item = GNOME_CANVAS_ITEM (iti);
- e = GTK_EDITABLE (priv->entry);
-
- gnome_canvas_item_ungrab (item, event_time);
- e->has_selection = FALSE;
- iti->selecting = FALSE;
-
- priv->need_state_update = TRUE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));
- gtk_signal_emit (GTK_OBJECT (iti), iti_signals[SELECTION_STOPPED]);
-}
-
-/* Handles selection range changes on the icon text item */
-static void
-iti_selection_motion (Iti *iti, int idx)
-{
- ItiPrivate *priv;
- GtkEditable *e;
-
- priv = iti->priv;
- e = GTK_EDITABLE (priv->entry);
-
- if (idx < e->current_pos) {
- e->selection_start_pos = idx;
- e->selection_end_pos = e->current_pos;
- } else {
- e->selection_start_pos = e->current_pos;
- e->selection_end_pos = idx;
- }
-
- priv->need_state_update = TRUE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));
-}
-
-/* Event handler for icon text items */
-static gint
-iti_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- Iti *iti;
- ItiPrivate *priv;
- int idx;
- double x, y;
-
- iti = ITI (item);
- priv = iti->priv;
-
- switch (event->type) {
- case GDK_KEY_PRESS:
- if (!iti->editing)
- break;
-
- if (event->key.keyval == GDK_Escape)
- iti_stop_editing (iti);
- else
- gtk_widget_event (GTK_WIDGET (priv->entry), event);
-
- priv->need_text_update = TRUE;
- gnome_canvas_item_request_update (item);
- return TRUE;
-
- case GDK_BUTTON_PRESS:
- if (!iti->editing)
- break;
-
- if (iti->editing && event->button.button == 1) {
- x = event->button.x - (item->x1 + MARGIN_X);
- y = event->button.y - (item->y1 + MARGIN_Y);
- idx = iti_idx_from_x_y (iti, x, y);
-
- iti_start_selecting (iti, idx, event->button.time);
- }
-
- return TRUE;
-
- case GDK_MOTION_NOTIFY:
- if (!iti->selecting)
- break;
-
- x = event->motion.x - (item->x1 + MARGIN_X);
- y = event->motion.y - (item->y1 + MARGIN_Y);
- idx = iti_idx_from_x_y (iti, x, y);
- iti_selection_motion (iti, idx);
- return TRUE;
-
- case GDK_BUTTON_RELEASE:
- if (iti->selecting && event->button.button == 1)
- iti_stop_selecting (iti, event->button.time);
- else
- break;
-
- return TRUE;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-/* Bounds method handler for the icon text item */
-static void
-iti_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
-{
- Iti *iti;
- ItiPrivate *priv;
- int width, height;
-
- iti = ITI (item);
- priv = iti->priv;
-
- if (priv->need_text_update) {
- layout_text (iti);
- priv->need_text_update = FALSE;
- }
-
- if (iti->ti) {
- width = iti->ti->width + 2 * MARGIN_X;
- height = iti->ti->height + 2 * MARGIN_Y;
- } else {
- width = 2 * MARGIN_X;
- height = 2 * MARGIN_Y;
- }
-
- *x1 = iti->x + (iti->width - width) * iti->xalign;
- *y1 = iti->y;
- *x2 = *x1 + width;
- *y2 = *y1 + height;
-}
-
-/* Class initialization function for the icon text item */
-static void
-iti_class_init (EIconBarTextItemClass *text_item_class)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass *) text_item_class;
- item_class = (GnomeCanvasItemClass *) text_item_class;
-
- parent_class = gtk_type_class (gnome_canvas_item_get_type ());
-
- gtk_object_add_arg_type ("EIconBarTextItem::xalign", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_XALIGN);
- gtk_object_add_arg_type ("EIconBarTextItem::justify", GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_JUSTIFY);
- gtk_object_add_arg_type ("EIconBarTextItem::max_lines", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_MAX_LINES);
- gtk_object_add_arg_type ("EIconBarTextItem::show_ellipsis", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_SHOW_ELLIPSIS);
-
- iti_signals [TEXT_CHANGED] =
- gtk_signal_new (
- "text_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EIconBarTextItemClass, text_changed),
- gtk_marshal_BOOL__NONE,
- GTK_TYPE_BOOL, 0);
-
- iti_signals [HEIGHT_CHANGED] =
- gtk_signal_new (
- "height_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EIconBarTextItemClass, height_changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- iti_signals [WIDTH_CHANGED] =
- gtk_signal_new (
- "width_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EIconBarTextItemClass, width_changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- iti_signals[EDITING_STARTED] =
- gtk_signal_new (
- "editing_started",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EIconBarTextItemClass, editing_started),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- iti_signals[EDITING_STOPPED] =
- gtk_signal_new (
- "editing_stopped",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EIconBarTextItemClass, editing_stopped),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- iti_signals[SELECTION_STARTED] =
- gtk_signal_new (
- "selection_started",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EIconBarTextItemClass, selection_started),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- iti_signals[SELECTION_STOPPED] =
- gtk_signal_new (
- "selection_stopped",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EIconBarTextItemClass, selection_stopped),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, iti_signals, LAST_SIGNAL);
-
- object_class->destroy = iti_destroy;
- object_class->get_arg = iti_get_arg;
- object_class->set_arg = iti_set_arg;
-
- item_class->update = iti_update;
- item_class->draw = iti_draw;
- item_class->point = iti_point;
- item_class->bounds = iti_bounds;
- item_class->event = iti_event;
-
- e_icon_bar_text_item_ellipsis = _("...");
-}
-
-/* Object initialization function for the icon text item */
-static void
-iti_init (EIconBarTextItem *iti)
-{
- ItiPrivate *priv;
-
- priv = g_new0 (ItiPrivate, 1);
- iti->priv = priv;
-
- iti->xalign = 0.5;
- iti->justification = GTK_JUSTIFY_CENTER;
- iti->max_lines = -1;
- iti->show_ellipsis = TRUE;
-}
-
-/**
- * e_icon_bar_text_item_configure:
- * @iti: An #EIconBarTextItem.
- * @x: X position in which to place the item.
- * @y: Y position in which to place the item.
- * @width: Maximum width allowed for this item, to be used for word wrapping.
- * @fontname: Name of the fontset that should be used to display the text.
- * @text: Text that is going to be displayed.
- * @is_static: Whether @text points to a static string or not.
- *
- * This routine is used to configure an #EIconBarTextItem.
- *
- * @x and @y specify the coordinates where the item is placed in the canvas.
- * The @x coordinate should be the leftmost position that the item can
- * assume at any one time, that is, the left margin of the column in which the
- * icon is to be placed. The @y coordinate specifies the top of the item.
- *
- * @width is the maximum width allowed for this icon text item. The coordinates
- * define the upper-left corner of an item with maximum width; this may
- * actually be outside the bounding box of the item if the text is narrower
- * than the maximum width.
- *
- * If @is_static is true, it means that there is no need for the item to
- * allocate memory for the string (it is a guarantee that the text is allocated
- * by the caller and it will not be deallocated during the lifetime of this
- * item). This is an optimization to reduce memory usage for large icon sets.
- */
-void
-e_icon_bar_text_item_configure (EIconBarTextItem *iti, int x, int y,
- int width, const char *fontname,
- const char *text,
- gboolean is_static)
-{
- ItiPrivate *priv;
-
- g_return_if_fail (iti != NULL);
- g_return_if_fail (IS_ITI (iti));
- g_return_if_fail (width > 2 * MARGIN_X);
- g_return_if_fail (text != NULL);
-
- priv = iti->priv;
-
- iti->x = x;
- iti->y = y;
- iti->width = width;
-
- if (iti->text && iti->is_text_allocated)
- g_free (iti->text);
-
- iti->is_text_allocated = !is_static;
-
- /* This cast is to shut up the compiler */
- if (is_static)
- iti->text = (char *) text;
- else
- iti->text = g_strdup (text);
-
- if (iti->fontname)
- g_free (iti->fontname);
-
- iti->fontname = g_strdup (fontname ? fontname : DEFAULT_FONT_NAME);
-
- if (priv->font)
- gdk_font_unref (priv->font);
-
- priv->font = NULL;
- if (fontname)
- priv->font = gdk_fontset_load (iti->fontname);
- if (!priv->font)
- priv->font = get_default_font ();
-
- /* Request update */
-
- priv->need_pos_update = TRUE;
- priv->need_font_update = TRUE;
- priv->need_text_update = TRUE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));
-}
-
-/**
- * e_icon_bar_text_item_set_width:
- * @iti: An #EIconBarTextItem.
- * @width: Maximum width allowed for this item, to be used for word wrapping.
- *
- * This routine is used to set the maximum width of an #EIconBarTextItem.
- */
-void
-e_icon_bar_text_item_set_width (EIconBarTextItem *iti, int width)
-{
- ItiPrivate *priv;
-
- g_return_if_fail (iti != NULL);
- g_return_if_fail (IS_ITI (iti));
- g_return_if_fail (width > 2 * MARGIN_X);
-
- priv = iti->priv;
-
- if (iti->width == width)
- return;
-
- iti->width = width;
-
- /* Request update */
- priv->need_text_update = TRUE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));
-}
-
-/**
- * e_icon_bar_text_item_setxy:
- * @iti: An #EIconBarTextItem.
- * @x: X position.
- * @y: Y position.
- *
- * Sets the coordinates at which the #EIconBarTextItem should be placed.
- *
- * See also: e_icon_bar_text_item_configure().
- */
-void
-e_icon_bar_text_item_setxy (EIconBarTextItem *iti, int x, int y)
-{
- ItiPrivate *priv;
-
- g_return_if_fail (iti != NULL);
- g_return_if_fail (IS_ITI (iti));
-
- priv = iti->priv;
-
- iti->x = x;
- iti->y = y;
-
- priv->need_pos_update = TRUE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));
-}
-
-/**
- * e_icon_bar_text_item_select:
- * @iti: An #EIconBarTextItem.
- * @sel: Whether the item should be displayed as selected.
- *
- * This function is used to control whether an icon text item is displayed as
- * selected or not. Mouse events are ignored by the item when it is unselected;
- * when the user clicks on a selected icon text item, it will start the text
- * editing process.
- */
-void
-e_icon_bar_text_item_select (EIconBarTextItem *iti, int sel)
-{
- ItiPrivate *priv;
-
- g_return_if_fail (iti != NULL);
- g_return_if_fail (IS_ITI (iti));
-
- priv = iti->priv;
-
- if (!iti->selected == !sel)
- return;
-
- iti->selected = sel ? TRUE : FALSE;
-
- if (!iti->selected && iti->editing)
- iti_edition_accept (iti);
-
- priv->need_state_update = TRUE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));
-}
-
-/**
- * e_icon_bar_text_item_get_text:
- * @iti: An #EIconBarTextItem.
- *
- * Returns the current text. The client should not free this string, as it is
- * internal to the #EIconBarTextItem.
- */
-char *
-e_icon_bar_text_item_get_text (EIconBarTextItem *iti)
-{
- ItiPrivate *priv;
-
- g_return_val_if_fail (iti != NULL, NULL);
- g_return_val_if_fail (IS_ITI (iti), NULL);
-
- priv = iti->priv;
-
- if (iti->editing)
- return gtk_entry_get_text (priv->entry);
- else
- return iti->text;
-}
-
-
-/**
- * e_icon_bar_text_item_set_text:
- * @iti: An #EIconBarTextItem.
- * @text: Text that is going to be displayed.
- * @is_static: Whether @text points to a static string or not.
- *
- * If @is_static is true, it means that there is no need for the item to
- * allocate memory for the string (it is a guarantee that the text is allocated
- * by the caller and it will not be deallocated during the lifetime of this
- * item). This is an optimization to reduce memory usage for large icon sets.
- */
-void
-e_icon_bar_text_item_set_text (EIconBarTextItem *iti, const char *text,
- gboolean is_static)
-{
- ItiPrivate *priv;
-
- g_return_if_fail (iti != NULL);
- g_return_if_fail (IS_ITI (iti));
- g_return_if_fail (text != NULL);
-
- priv = iti->priv;
-
- if (iti->text && iti->is_text_allocated)
- g_free (iti->text);
-
- iti->is_text_allocated = !is_static;
-
- /* This cast is to shut up the compiler */
- if (is_static)
- iti->text = (char *) text;
- else
- iti->text = g_strdup (text);
-
- /* Request update */
-
- priv->need_text_update = TRUE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));
-}
-
-
-/**
- * e_icon_bar_text_item_start_editing:
- * @iti: An #EIconBarTextItem.
- *
- * Starts the editing state of an #EIconBarTextItem.
- **/
-void
-e_icon_bar_text_item_start_editing (EIconBarTextItem *iti)
-{
- g_return_if_fail (iti != NULL);
- g_return_if_fail (IS_ITI (iti));
-
- if (iti->editing)
- return;
-
- iti->selected = TRUE; /* Ensure that we are selected */
- gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (iti));
- iti_start_editing (iti);
-}
-
-/**
- * e_icon_bar_text_item_stop_editing:
- * @iti: An #EIconBarTextItem.
- * @accept: Whether to accept the current text or to discard it.
- *
- * Terminates the editing state of an icon text item. The @accept argument
- * controls whether the item's current text should be accepted or discarded.
- * If it is discarded, then the icon's original text will be restored.
- **/
-void
-e_icon_bar_text_item_stop_editing (EIconBarTextItem *iti,
- gboolean accept)
-{
- g_return_if_fail (iti != NULL);
- g_return_if_fail (IS_ITI (iti));
-
- if (!iti->editing)
- return;
-
- if (accept)
- iti_edition_accept (iti);
- else
- iti_stop_editing (iti);
-}
-
-
-/**
- * e_icon_bar_text_item_get_type:
- *
- * Registers the &EIconBarTextItem class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: the type ID of the #EIconBarTextItem class.
- **/
-GtkType
-e_icon_bar_text_item_get_type (void)
-{
- static GtkType iti_type = 0;
-
- if (!iti_type) {
- static const GtkTypeInfo iti_info = {
- "EIconBarTextItem",
- sizeof (EIconBarTextItem),
- sizeof (EIconBarTextItemClass),
- (GtkClassInitFunc) iti_class_init,
- (GtkObjectInitFunc) iti_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- iti_type = gtk_type_unique (gnome_canvas_item_get_type (), &iti_info);
- }
-
- return iti_type;
-}
-
-
-static void
-free_row (gpointer data, gpointer user_data)
-{
- EIconBarTextItemInfoRow *row;
-
- if (data) {
- row = data;
- g_free (row->text);
- g_free (row->text_wc);
- g_free (row);
- }
-}
-
-/*
- * e_icon_bar_text_item_free_info:
- * @ti: An icon text info structure.
- *
- * Frees a &EIconBarTextItemInfo structure. You should call this instead of
- * freeing the structure yourself.
- */
-static void
-e_icon_bar_text_item_free_info (EIconBarTextItemInfo *ti)
-{
- g_list_foreach (ti->rows, free_row, NULL);
- g_list_free (ti->rows);
- g_free (ti);
-}
-
-/*
- * e_icon_bar_text_item_layout_text:
- * @font: Name of the font that will be used to render the text.
- * @text: Text to be formatted.
- * @separators: Separators used for word wrapping, can be NULL.
- * @max_width: Width in pixels to be used for word wrapping.
- * @confine: Whether it is mandatory to wrap at @max_width.
- *
- * Creates a new &EIconBarTextItemInfo structure by wrapping the specified
- * text. If non-NULL, the @separators argument defines a set of characters
- * to be used as word delimiters for performing word wrapping. If it is
- * NULL, then only spaces will be used as word delimiters.
- *
- * The @max_width argument is used to specify the width at which word
- * wrapping will be performed. If there is a very long word that does not
- * fit in a single line, the @confine argument can be used to specify
- * whether the word should be unconditionally split to fit or whether
- * the maximum width should be increased as necessary.
- *
- * Return value: A newly-created &EIconBarTextItemInfo structure.
- */
-static EIconBarTextItemInfo *
-e_icon_bar_text_item_layout_text (EIconBarTextItem *iti, GdkFont *font,
- const gchar *text, const gchar *separators,
- gint max_width, gboolean confine)
-{
- EIconBarTextItemInfo *ti;
- EIconBarTextItemInfoRow *row;
- GdkWChar *row_end;
- GdkWChar *s, *word_start, *word_end, *old_word_end;
- GdkWChar *sub_text;
- int i, w_len, w;
- GdkWChar *text_wc, *text_iter, *separators_wc;
- int text_len_wc, separators_len_wc;
- gboolean restrict_lines;
- int lines;
-
- g_return_val_if_fail (font != NULL, NULL);
- g_return_val_if_fail (text != NULL, NULL);
-
- if (!separators)
- separators = " ";
-
- text_wc = g_new (GdkWChar, strlen (text) + 1);
- text_len_wc = gdk_mbstowcs (text_wc, text, strlen (text));
- if (text_len_wc < 0) text_len_wc = 0;
- text_wc[text_len_wc] = 0;
-
- separators_wc = g_new (GdkWChar, strlen (separators) + 1);
- separators_len_wc = gdk_mbstowcs (separators_wc, separators, strlen (separators));
- if (separators_len_wc < 0) separators_len_wc = 0;
- separators_wc[separators_len_wc] = 0;
-
- ti = g_new (EIconBarTextItemInfo, 1);
-
- ti->rows = NULL;
- ti->font = font;
- ti->width = 0;
- ti->height = 0;
- ti->baseline_skip = font->ascent + font->descent;
-
- word_end = NULL;
-
- if (!iti->editing && iti->max_lines != -1)
- restrict_lines = TRUE;
- else
- restrict_lines = FALSE;
-
- text_iter = text_wc;
- lines = 0;
- while (*text_iter) {
- /* If we are restricting the height, and this is the last line,
- and we are displaying the ellipsis, then subtract the width
- of the ellipsis from our max_width. */
- if (restrict_lines && lines == iti->max_lines - 1
- && iti->show_ellipsis) {
- max_width -= gdk_string_measure (font, e_icon_bar_text_item_ellipsis);
- }
-
- for (row_end = text_iter; *row_end != 0 && *row_end != '\n'; row_end++);
-
- /* Accumulate words from this row until they don't fit in the max_width */
-
- s = text_iter;
-
- while (s < row_end) {
- word_start = s;
- old_word_end = word_end;
- for (word_end = word_start; *word_end; word_end++) {
- GdkWChar *p;
- for (p = separators_wc; *p; p++) {
- if (*word_end == *p)
- goto found;
- }
- }
- found:
- if (word_end < row_end)
- word_end++;
-
- if (gdk_text_width_wc (font, text_iter, word_end - text_iter) > max_width) {
- if (word_start == text_iter
- || (restrict_lines
- && lines == iti->max_lines - 1)) {
- if (confine) {
- /* We must force-split the word. Look for a proper
- * place to do it.
- */
-
- w_len = word_end - text_iter;
-
- for (i = 1; i < w_len; i++) {
- w = gdk_text_width_wc (font, text_iter, i);
- if (w > max_width) {
- if (i == 1)
- /* Shit, not even a single character fits */
- max_width = w;
- else
- break;
- }
- }
-
- /* Create sub-row with the chars that fit */
-
- sub_text = g_new (GdkWChar, i);
- memcpy (sub_text, text_iter, (i - 1) * sizeof (GdkWChar));
- sub_text[i - 1] = 0;
-
- row = g_new (EIconBarTextItemInfoRow, 1);
- row->text_wc = sub_text;
- row->text_length = i - 1;
- row->width = gdk_text_width_wc (font, sub_text, i - 1);
- row->text = gdk_wcstombs(sub_text);
- if (row->text == NULL)
- row->text = g_strdup("");
-
- ti->rows = g_list_append (ti->rows, row);
-
- if (row->width > ti->width)
- ti->width = row->width;
-
- ti->height += ti->baseline_skip;
-
- /* Bump the text pointer */
-
- text_iter += i - 1;
- s = text_iter;
-
- lines++;
- if (restrict_lines
- && lines >= iti->max_lines)
- break;
-
- continue;
- } else
- max_width = gdk_text_width_wc (font, word_start, word_end - word_start);
-
- continue; /* Retry split */
- } else {
- word_end = old_word_end; /* Restore to region that does fit */
- break; /* Stop the loop because we found something that doesn't fit */
- }
- }
-
- s = word_end;
- }
-
- if (restrict_lines && lines >= iti->max_lines)
- break;
-
- /* Append row */
-
- if (text_iter == row_end) {
- /* We are on a newline, so append an empty row */
-
- ti->rows = g_list_append (ti->rows, NULL);
- ti->height += ti->baseline_skip;
-
- /* Next! */
-
- text_iter = row_end + 1;
-
- lines++;
- if (restrict_lines && lines >= iti->max_lines)
- break;
-
- } else {
- /* Create subrow and append it to the list */
-
- int sub_len;
- sub_len = word_end - text_iter;
-
- sub_text = g_new (GdkWChar, sub_len + 1);
- memcpy (sub_text, text_iter, sub_len * sizeof (GdkWChar));
- sub_text[sub_len] = 0;
-
- row = g_new (EIconBarTextItemInfoRow, 1);
- row->text_wc = sub_text;
- row->text_length = sub_len;
- row->width = gdk_text_width_wc (font, sub_text, sub_len);
- row->text = gdk_wcstombs(sub_text);
- if (row->text == NULL)
- row->text = g_strdup("");
-
- ti->rows = g_list_append (ti->rows, row);
-
- if (row->width > ti->width)
- ti->width = row->width;
-
- ti->height += ti->baseline_skip;
-
- /* Next! */
-
- text_iter = word_end;
-
- lines++;
- if (restrict_lines && lines >= iti->max_lines)
- break;
- }
- }
-
- /* Check if we've had to clip the text. */
- iti->is_clipped = *text_iter ? TRUE : FALSE;
-
- g_free (text_wc);
- g_free (separators_wc);
- return ti;
-}
-
-/*
- * e_icon_bar_text_item_paint_text:
- * @ti: An icon text info structure.
- * @drawable: Target drawable.
- * @gc: GC used to render the string.
- * @x: Left coordinate for text.
- * @y: Upper coordinate for text.
- * @just: Justification for text.
- *
- * Paints the formatted text in the icon text info structure onto a drawable.
- * This is just a sample implementation; applications can choose to use other
- * rendering functions.
- */
-static void
-e_icon_bar_text_item_paint_text (EIconBarTextItem *iti,
- EIconBarTextItemInfo *ti,
- GdkDrawable *drawable, GdkGC *gc,
- gint x, gint y, GtkJustification just)
-{
- GList *item;
- EIconBarTextItemInfoRow *row;
- int xpos, line, width;
- gboolean show_ellipsis;
-
- g_return_if_fail (ti != NULL);
- g_return_if_fail (drawable != NULL);
- g_return_if_fail (gc != NULL);
-
- y += ti->font->ascent;
-
- for (item = ti->rows, line = 1; item; item = item->next, line++) {
-
- if (item->data) {
- row = item->data;
- width = row->width;
- }
-
- /* If this is the last line, and the text has been clipped,
- and show_ellipsis is TRUE, display '...' */
- if (line == iti->max_lines && iti->is_clipped) {
- show_ellipsis = TRUE;
- width += gdk_string_measure (ti->font, e_icon_bar_text_item_ellipsis);
- } else {
- show_ellipsis = FALSE;
- }
-
- switch (just) {
- case GTK_JUSTIFY_LEFT:
- xpos = 0;
- break;
-
- case GTK_JUSTIFY_RIGHT:
- xpos = ti->width - width;
- break;
-
- case GTK_JUSTIFY_CENTER:
- xpos = (ti->width - width) / 2;
- break;
-
- default:
- /* Anyone care to implement GTK_JUSTIFY_FILL? */
- g_warning ("Justification type %d not supported. Using left-justification.",
- (int) just);
- xpos = 0;
- }
-
- if (item->data)
- gdk_draw_text_wc (drawable, ti->font, gc, x + xpos, y, row->text_wc, row->text_length);
-
- if (show_ellipsis)
- gdk_draw_string (drawable, ti->font, gc,
- x + xpos + row->width, y,
- e_icon_bar_text_item_ellipsis);
-
- y += ti->baseline_skip;
- }
-}
diff --git a/widgets/shortcut-bar/e-icon-bar-text-item.h b/widgets/shortcut-bar/e-icon-bar-text-item.h
deleted file mode 100644
index 7c0380c87b..0000000000
--- a/widgets/shortcut-bar/e-icon-bar-text-item.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * Based on gnome-icon-text-item: an editable text block with word wrapping
- * for the GNOME canvas.
- *
- * Copyright (C) 1998, 1999 The Free Software Foundation
- *
- * Authors: Miguel de Icaza <miguel@gnu.org>
- * Federico Mena <federico@gimp.org>
- */
-
-/*
- * EIconBarTextItem - An editable canvas text item for the EIconBar.
- */
-
-#ifndef _E_ICON_BAR_TEXT_ITEM_H_
-#define _E_ICON_BAR_TEXT_ITEM_H_
-
-#include <gtk/gtkentry.h>
-#include <libgnomeui/gnome-canvas.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-#define E_ICON_BAR_TEXT_ITEM(obj) (GTK_CHECK_CAST((obj), \
- e_icon_bar_text_item_get_type (), EIconBarTextItem))
-#define E_ICON_BAR_TEXT_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\
- e_icon_bar_text_item_get_type ()))
-#define E_IS_ICON_BAR_TEXT_ITEM(o) (GTK_CHECK_TYPE((o), \
- e_icon_bar_text_item_get_type ()))
-
-typedef struct _EIconBarTextItemInfo EIconBarTextItemInfo;
-
-typedef struct {
- GnomeCanvasItem canvas_item;
-
- /* Size and maximum allowed width */
- int x, y;
- int width;
-
- /* Font name */
- char *fontname;
-
- /* Private data */
- gpointer priv; /* was GtkEntry *entry */
-
- /* Actual text */
- char *text;
-
- /* Text layout information */
- EIconBarTextItemInfo *ti;
-
- /* Whether the text is being edited */
- unsigned int editing : 1;
-
- /* Whether the text item is selected */
- unsigned int selected : 1;
-
- /* Whether the user is select-dragging a block of text */
- unsigned int selecting : 1;
-
- /* Whether the text is editable */
- unsigned int is_editable : 1;
-
- /* Whether the text is allocated by us (FALSE if allocated by the client) */
- unsigned int is_text_allocated : 1;
-
-
- /* The horizontal alignment of the text (default 0.5). */
- gfloat xalign;
-
- /* The justification of the text (default is centered). */
- GtkJustification justification;
-
- /* The max number of lines of text shown, or -1 for all (default). */
- gint max_lines;
-
- /* If '...' is displayed if the text doesn't all fit (default TRUE). */
- gboolean show_ellipsis;
-
- /* This is TRUE if we couldn't fit all the text in. */
- gboolean is_clipped;
-} EIconBarTextItem;
-
-typedef struct {
- GnomeCanvasItemClass parent_class;
-
- /* Signals we emit */
- int (* text_changed) (EIconBarTextItem *iti);
- void (* height_changed) (EIconBarTextItem *iti);
- void (* width_changed) (EIconBarTextItem *iti);
- void (* editing_started) (EIconBarTextItem *iti);
- void (* editing_stopped) (EIconBarTextItem *iti);
- void (* selection_started) (EIconBarTextItem *iti);
- void (* selection_stopped) (EIconBarTextItem *iti);
-} EIconBarTextItemClass;
-
-GtkType e_icon_bar_text_item_get_type (void);
-
-void e_icon_bar_text_item_configure (EIconBarTextItem *iti,
- int x,
- int y,
- int width,
- const char *fontname,
- const char *text,
- gboolean is_static);
-
-void e_icon_bar_text_item_set_width (EIconBarTextItem *iti,
- int width);
-
-void e_icon_bar_text_item_setxy (EIconBarTextItem *iti,
- int x,
- int y);
-
-void e_icon_bar_text_item_select (EIconBarTextItem *iti,
- int sel);
-
-char* e_icon_bar_text_item_get_text (EIconBarTextItem *iti);
-void e_icon_bar_text_item_set_text (EIconBarTextItem *iti,
- const char *text,
- gboolean is_static);
-
-void e_icon_bar_text_item_start_editing (EIconBarTextItem *iti);
-void e_icon_bar_text_item_stop_editing (EIconBarTextItem *iti,
- gboolean accept);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_ICON_BAR_TEXT_ITEM_H_ */
-
diff --git a/widgets/shortcut-bar/e-icon-bar.c b/widgets/shortcut-bar/e-icon-bar.c
deleted file mode 100644
index e9643dc451..0000000000
--- a/widgets/shortcut-bar/e-icon-bar.c
+++ /dev/null
@@ -1,1450 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * EIconBar is a subclass of GnomeCanvas for displaying a vertical column of
- * icons and descriptions. It provides 2 views - large icons and small icons.
- */
-
-#include <gtk/gtkmain.h>
-#include <gtk/gtksignal.h>
-#include <gdk-pixbuf/gnome-canvas-pixbuf.h>
-#include "e-icon-bar.h"
-#include "e-icon-bar-bg-item.h"
-#include "e-icon-bar-text-item.h"
-
-/* These are the offsets of the icons & text in both views. Note that the
- shadow around icons is drawn in the space between items (as is the
- horizontal bar when dragging). */
-#define E_ICON_BAR_LARGE_ICON_SPACING 8 /* Spacing between items. */
-#define E_ICON_BAR_LARGE_ICON_WIDTH 48
-#define E_ICON_BAR_LARGE_ICON_HEIGHT 48
-#define E_ICON_BAR_LARGE_ICON_TEXT_X 4
-#define E_ICON_BAR_LARGE_ICON_TEXT_Y (E_ICON_BAR_LARGE_ICON_HEIGHT + 4)
-
-#define E_ICON_BAR_SMALL_ICON_SPACING 4 /* Spacing between items. */
-#define E_ICON_BAR_SMALL_ICON_WIDTH 24
-#define E_ICON_BAR_SMALL_ICON_HEIGHT 24
-#define E_ICON_BAR_SMALL_ICON_X 4
-#define E_ICON_BAR_SMALL_ICON_TEXT_X (E_ICON_BAR_SMALL_ICON_WIDTH + 4)
-
-/* The space we leave at the top or bottom of the bar when position an item
- while it is being edited. This is used since the EIconBar may be in a
- EScrolledBar which may show buttons at the top or bottom. */
-#define E_ICON_BAR_V_SPACE 22
-
-/* The number of pixels the mouse has to be moved with the button down before
- we start a drag. */
-#define E_ICON_BAR_DRAG_START_OFFSET 4
-
-/* This is the area at the top & bottom of the bar where we auto-scroll if the
- mouse goes into during a drag-and-drop operation. */
-#define E_ICON_BAR_DRAG_AUTO_SCROLL_OFFSET 16
-
-/* This is the time between each auto-scroll, when dragging. */
-#define E_ICON_BAR_SCROLL_TIMEOUT 30
-
-/* This is the number of timeouts we skip before we start scrolling. */
-#define E_ICON_BAR_SCROLL_DELAY 12
-
-
-static void e_icon_bar_class_init (EIconBarClass *class);
-static void e_icon_bar_init (EIconBar *icon_bar);
-static void e_icon_bar_destroy (GtkObject *object);
-static void e_icon_bar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gint e_icon_bar_leave_notify_event (GtkWidget *widget,
- GdkEventCrossing *event);
-static gint e_icon_bar_focus_in (GtkWidget *widget,
- GdkEventFocus *event);
-static gint e_icon_bar_focus_out (GtkWidget *widget,
- GdkEventFocus *event);
-static gint e_icon_bar_key_event (GtkWidget *widget, GdkEventKey *event);
-
-static gint e_icon_bar_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time);
-static void e_icon_bar_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time);
-static void e_icon_bar_set_dragging_before_item (EIconBar *icon_bar,
- gint before_item);
-static gboolean e_icon_bar_timeout_handler (gpointer data);
-
-static void e_icon_bar_recalc_common_positions (EIconBar *icon_bar);
-static gint e_icon_bar_recalc_item_positions (EIconBar *icon_bar);
-static void e_icon_bar_on_text_height_changed (GnomeCanvasItem *text_item,
- EIconBar *icon_bar);
-static gint e_icon_bar_find_item (EIconBar *icon_bar,
- GnomeCanvasItem *text_item);
-static gboolean e_icon_bar_on_item_event (GnomeCanvasItem *item,
- GdkEvent *event,
- EIconBar *icon_bar);
-
-static gboolean e_icon_bar_large_icons_intersects (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y);
-static gboolean e_icon_bar_large_icons_is_before (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y);
-static gboolean e_icon_bar_small_icons_intersects (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y);
-static gboolean e_icon_bar_small_icons_is_before (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y);
-static void e_icon_bar_on_text_item_editing_started (EIconBarTextItem *text_item,
- EIconBar *icon_bar);
-static void e_icon_bar_on_text_item_editing_stopped (EIconBarTextItem *text_item,
- EIconBar *icon_bar);
-static void e_icon_bar_ensure_edited_item_visible (EIconBar *icon_bar);
-static void e_icon_bar_update_highlight (EIconBar *icon_bar);
-
-enum
-{
- ITEM_SELECTED,
- ITEM_DRAGGED,
- LAST_SIGNAL
-};
-
-static guint e_icon_bar_signals[LAST_SIGNAL] = {0};
-
-static GnomeCanvasClass *parent_class;
-
-
-GtkType
-e_icon_bar_get_type (void)
-{
- static GtkType e_icon_bar_type = 0;
-
- if (!e_icon_bar_type){
- GtkTypeInfo e_icon_bar_info = {
- "EIconBar",
- sizeof (EIconBar),
- sizeof (EIconBarClass),
- (GtkClassInitFunc) e_icon_bar_class_init,
- (GtkObjectInitFunc) e_icon_bar_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- parent_class = gtk_type_class (gnome_canvas_get_type ());
- e_icon_bar_type = gtk_type_unique (gnome_canvas_get_type (),
- &e_icon_bar_info);
- }
-
- return e_icon_bar_type;
-}
-
-
-static void
-e_icon_bar_class_init (EIconBarClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
-
- e_icon_bar_signals[ITEM_SELECTED] =
- gtk_signal_new ("item_selected",
- GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
- GTK_SIGNAL_OFFSET (EIconBarClass,
- selected_item),
- gtk_marshal_NONE__POINTER_INT,
- GTK_TYPE_NONE, 2, GTK_TYPE_GDK_EVENT,
- GTK_TYPE_INT);
- e_icon_bar_signals[ITEM_DRAGGED] =
- gtk_signal_new ("item_dragged",
- GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
- GTK_SIGNAL_OFFSET (EIconBarClass,
- dragged_item),
- gtk_marshal_NONE__POINTER_INT,
- GTK_TYPE_NONE, 2, GTK_TYPE_GDK_EVENT,
- GTK_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, e_icon_bar_signals,
- LAST_SIGNAL);
-
- /* Method override */
- object_class->destroy = e_icon_bar_destroy;
-
- widget_class->size_allocate = e_icon_bar_size_allocate;
- widget_class->leave_notify_event = e_icon_bar_leave_notify_event;
- widget_class->focus_in_event = e_icon_bar_focus_in;
- widget_class->focus_out_event = e_icon_bar_focus_out;
- widget_class->key_press_event = e_icon_bar_key_event;
- widget_class->key_release_event = e_icon_bar_key_event;
- widget_class->drag_motion = e_icon_bar_drag_motion;
- widget_class->drag_leave = e_icon_bar_drag_leave;
-
- class->selected_item = NULL;
-}
-
-
-static void
-e_icon_bar_init (EIconBar *icon_bar)
-{
- icon_bar->view_type = E_ICON_BAR_LARGE_ICONS;
- icon_bar->items = g_array_new (FALSE, FALSE, sizeof (EIconBarItem));
- icon_bar->pressed_item_num = -1;
- icon_bar->mouse_over_item_num = -1;
- icon_bar->editing_item_num = -1;
- icon_bar->in_drag = FALSE;
- icon_bar->dragging_before_item_num = -1;
- icon_bar->icon_x = 0;
- icon_bar->icon_w = 0;
- icon_bar->icon_h = 0;
- icon_bar->text_x = 0;
- icon_bar->text_w = 5;
- icon_bar->auto_scroll_timeout_id = 0;
-
- /* Create the background item in the canvas, which handles selections
- and drag-and-drop. */
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (icon_bar)->root),
- e_icon_bar_bg_item_get_type (),
- "EIconBarBgItem::icon_bar", icon_bar,
- NULL);
-}
-
-
-/**
- * e_icon_bar_new:
- * @Returns: A new #EIconBar.
- *
- * Creates a new #EIconBar.
- **/
-GtkWidget *
-e_icon_bar_new (void)
-{
- GtkWidget *icon_bar;
-
- icon_bar = GTK_WIDGET (gtk_type_new (e_icon_bar_get_type ()));
-
- return icon_bar;
-}
-
-
-static void
-e_icon_bar_destroy (GtkObject *object)
-{
- EIconBar *icon_bar;
-
- icon_bar = E_ICON_BAR (object);
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-
- g_array_free (icon_bar->items, TRUE);
-
- if (icon_bar->auto_scroll_timeout_id != 0) {
- gtk_timeout_remove (icon_bar->auto_scroll_timeout_id);
- icon_bar->auto_scroll_timeout_id = 0;
- }
-}
-
-
-static void
-e_icon_bar_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- EIconBar *icon_bar;
- gint canvas_width, canvas_height, height;
-
- icon_bar = E_ICON_BAR (widget);
-
- GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
-
- canvas_width = GTK_WIDGET (icon_bar)->allocation.width;
- canvas_height = GTK_WIDGET (icon_bar)->allocation.height;
-
- /* Reset the y position and widths of all the items to the width of
- the canvas, and reset the button labels, so they fit. */
- e_icon_bar_recalc_common_positions (icon_bar);
- height = e_icon_bar_recalc_item_positions (icon_bar);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (widget),
- 0, 0, canvas_width,
- MAX (height, canvas_height - 1));
-
- /* If we are editing an item, make sure it is visible. */
- e_icon_bar_ensure_edited_item_visible (icon_bar);
-
- GTK_LAYOUT (widget)->vadjustment->step_increment = 16;
-
- e_icon_bar_update_highlight (icon_bar);
-}
-
-
-/* This sets all the item positions which are the same for all items in the
- group. */
-static void
-e_icon_bar_recalc_common_positions (EIconBar *icon_bar)
-{
- gint canvas_width;
-
- canvas_width = GTK_WIDGET (icon_bar)->allocation.width;
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- icon_bar->icon_x = (canvas_width - E_ICON_BAR_LARGE_ICON_WIDTH) / 2;
- icon_bar->icon_w = E_ICON_BAR_LARGE_ICON_WIDTH;
- icon_bar->icon_h = E_ICON_BAR_LARGE_ICON_HEIGHT;
-
- icon_bar->text_x = E_ICON_BAR_LARGE_ICON_TEXT_X;
- icon_bar->text_w = MAX (canvas_width - (E_ICON_BAR_LARGE_ICON_TEXT_X * 2), 5);
-
- icon_bar->spacing = E_ICON_BAR_LARGE_ICON_SPACING;
- } else {
- icon_bar->icon_x = E_ICON_BAR_SMALL_ICON_X;
- icon_bar->icon_w = E_ICON_BAR_SMALL_ICON_WIDTH;
- icon_bar->icon_h = E_ICON_BAR_SMALL_ICON_HEIGHT;
-
- icon_bar->text_x = E_ICON_BAR_SMALL_ICON_TEXT_X;
- icon_bar->text_w = MAX (canvas_width - E_ICON_BAR_SMALL_ICON_TEXT_X, 5);
-
- icon_bar->spacing = E_ICON_BAR_SMALL_ICON_SPACING;
- }
-}
-
-
-/* This recalculates the positions of all the items, according to the current
- view type and the height of the text items. */
-static gint
-e_icon_bar_recalc_item_positions (EIconBar *icon_bar)
-{
- EIconBarItem *item;
- gint y, item_num;
- gdouble x1, y1, x2, y2, xalign;
- GtkJustification justify;
- gint max_lines;
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- xalign = 0.5;
- justify = GTK_JUSTIFY_CENTER;
- max_lines = 2;
- } else {
- xalign = 0.0;
- justify = GTK_JUSTIFY_LEFT;
- max_lines = 1;
- }
-
- /* Now step through the items, setting the y positions. */
- y = icon_bar->spacing;
- for (item_num = 0; item_num < icon_bar->items->len; item_num++) {
- item = &g_array_index (icon_bar->items,
- EIconBarItem, item_num);
-
- e_icon_bar_text_item_set_width (E_ICON_BAR_TEXT_ITEM (item->text),
- icon_bar->text_w);
-
- /* Get the text item's height. */
- gnome_canvas_item_get_bounds (item->text, &x1, &y1, &x2, &y2);
- item->text_width = x2 - x1;
- item->text_height = y2 - y1;
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- item->icon_y = y;
- item->text_y = y + E_ICON_BAR_LARGE_ICON_TEXT_Y;
-
- item->item_height = E_ICON_BAR_LARGE_ICON_TEXT_Y
- + item->text_height;
- } else {
- item->item_height = MAX (item->text_height, E_ICON_BAR_SMALL_ICON_HEIGHT);
- item->icon_y = y + (item->item_height - E_ICON_BAR_SMALL_ICON_HEIGHT) / 2;
- item->text_y = y + (item->item_height - item->text_height) / 2;
- }
-
- e_icon_bar_text_item_setxy (E_ICON_BAR_TEXT_ITEM (item->text),
- icon_bar->text_x, item->text_y);
-
- /* We need to get the bounds again, in case it has moved. */
- gnome_canvas_item_get_bounds (item->text, &x1, &y1, &x2, &y2);
- item->text_x = x1;
-
- gnome_canvas_item_set (item->text,
- "EIconBarTextItem::xalign", xalign,
- "EIconBarTextItem::justify", justify,
- "EIconBarTextItem::max_lines", max_lines,
- NULL);
-
- gnome_canvas_item_set (item->image,
- "GnomeCanvasPixbuf::x", (gdouble)icon_bar->icon_x,
- "GnomeCanvasPixbuf::y", (gdouble)item->icon_y,
- "GnomeCanvasPixbuf::width", (gdouble)icon_bar->icon_w,
- "GnomeCanvasPixbuf::width_set", TRUE,
- "GnomeCanvasPixbuf::height", (gdouble)icon_bar->icon_h,
- "GnomeCanvasPixbuf::height_set", TRUE,
- NULL);
-
- y += item->item_height + icon_bar->spacing;
- }
-
- return y;
-}
-
-
-static gint
-e_icon_bar_leave_notify_event (GtkWidget *widget, GdkEventCrossing *event)
-{
- EIconBar *icon_bar;
-
- icon_bar = E_ICON_BAR (widget);
-
- GTK_WIDGET_CLASS (parent_class)->leave_notify_event (widget, event);
-
- /* Make sure no items are highlighted. */
- e_icon_bar_item_motion (icon_bar, -1, NULL);
-
- return FALSE;
-}
-
-
-static gint
-e_icon_bar_focus_in (GtkWidget *widget,
- GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (E_IS_ICON_BAR (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_CLASS (parent_class)->focus_in_event (widget, event);
- GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
- return FALSE;
-}
-
-
-static gint
-e_icon_bar_focus_out (GtkWidget *widget,
- GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (E_IS_ICON_BAR (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_CLASS (parent_class)->focus_out_event (widget, event);
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
- return FALSE;
-}
-
-
-/* Key event handler for the canvas.
- FIXME: GnomeCanvas bug workaround - I needed to override this to stop the
- canvas ignoring key events from other windows. */
-static gint
-e_icon_bar_key_event (GtkWidget *widget, GdkEventKey *event)
-{
- GnomeCanvas *canvas;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (E_IS_ICON_BAR (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- canvas = GNOME_CANVAS (widget);
-
- if (event->window != canvas->layout.bin_window) {
- /* We change the window in the event struct so the canvas
- doesn't ignore the event. Note that windows are ref-counted
- in the event struct. */
- if (event->window)
- gdk_window_unref (event->window);
- event->window = canvas->layout.bin_window;
- gdk_window_ref (event->window);
- }
-
- /* These both call the same function at present, but we'll do it
- properly just in case that changes. */
- if (event->type == GDK_KEY_PRESS)
- return (*GTK_WIDGET_CLASS (parent_class)->key_press_event)(widget, event);
- else
- return (*GTK_WIDGET_CLASS (parent_class)->key_release_event)(widget, event);
-}
-
-
-/**
- * e_icon_bar_set_view_type:
- * @icon_bar: An #EIconBar.
- * @view_type: The new view type, %E_ICON_BAR_LARGE_ICONS or
- * %E_ICON_BAR_SMALL_ICONS.
- *
- * Sets the view type of the #EIconBar.
- **/
-void
-e_icon_bar_set_view_type (EIconBar *icon_bar,
- EIconBarViewType view_type)
-{
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
-
- if (icon_bar->view_type == view_type)
- return;
-
- icon_bar->view_type = view_type;
-
- /* Queue a resize of the canvas, so everything is put in the right
- positions based on the new view type. */
- gtk_widget_queue_resize (GTK_WIDGET (icon_bar));
-}
-
-
-/**
- * e_icon_bar_add_item:
- * @icon_bar: An #EIconBar.
- * @image: the new item's icon.
- * @text: the new item's text.
- * @position: the position to place the new item, or -1 to place it last.
- *
- * Adds an item to the #EIconBar at the given position.
- **/
-gint
-e_icon_bar_add_item (EIconBar *icon_bar,
- GdkPixbuf *image,
- gchar *text,
- gint position)
-{
- EIconBarItem item;
- gfloat xalign;
- GtkJustification justify;
- gint max_lines, retval;
-
- g_return_val_if_fail (E_IS_ICON_BAR (icon_bar), -1);
- g_return_val_if_fail (text != NULL, -1);
- g_return_val_if_fail (position >= -1, -1);
- g_return_val_if_fail (position <= (gint)icon_bar->items->len, -1);
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- xalign = 0.5;
- justify = GTK_JUSTIFY_CENTER;
- max_lines = 2;
- } else {
- xalign = 0.0;
- justify = GTK_JUSTIFY_LEFT;
- max_lines = 1;
- }
-
- item.text = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (icon_bar)->root),
- e_icon_bar_text_item_get_type (),
- "EIconBarTextItem::xalign", xalign,
- "EIconBarTextItem::justify", justify,
- "EIconBarTextItem::max_lines", max_lines,
- NULL);
- e_icon_bar_text_item_configure (E_ICON_BAR_TEXT_ITEM (item.text),
- icon_bar->text_x, 0,
- icon_bar->text_w, NULL,
- text, FALSE);
- gtk_signal_connect (GTK_OBJECT (item.text), "height_changed",
- GTK_SIGNAL_FUNC (e_icon_bar_on_text_height_changed), icon_bar);
- gtk_signal_connect (GTK_OBJECT (item.text), "event",
- GTK_SIGNAL_FUNC (e_icon_bar_on_item_event),
- icon_bar);
- gtk_signal_connect (GTK_OBJECT (item.text), "editing_started",
- GTK_SIGNAL_FUNC (e_icon_bar_on_text_item_editing_started),
- icon_bar);
- gtk_signal_connect (GTK_OBJECT (item.text), "editing_stopped",
- GTK_SIGNAL_FUNC (e_icon_bar_on_text_item_editing_stopped),
- icon_bar);
-
- item.image = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (icon_bar)->root),
- gnome_canvas_pixbuf_get_type (),
- "GnomeCanvasPixbuf::pixbuf", image,
- "GnomeCanvasPixbuf::width", (gdouble) icon_bar->icon_w,
- "GnomeCanvasPixbuf::height", (gdouble) icon_bar->icon_h,
- NULL);
- gtk_signal_connect (GTK_OBJECT (item.image), "event",
- GTK_SIGNAL_FUNC (e_icon_bar_on_item_event),
- icon_bar);
-
- item.data = NULL;
- item.destroy = NULL;
-
- if (position == -1) {
- g_array_append_val (icon_bar->items, item);
- retval = icon_bar->items->len - 1;
- } else {
- g_array_insert_val (icon_bar->items, position, item);
- retval = position;
-
- /* FIXME: Should possibly update other indices. */
- if (icon_bar->dragged_item_num >= position)
- icon_bar->dragged_item_num++;
- }
-
- gtk_widget_queue_resize (GTK_WIDGET (icon_bar));
-
- return retval;
-}
-
-
-/**
- * e_icon_bar_reorder_item:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item to move.
- * @new_position: The new position of the item, which is used after the item
- * has been removed from its current position. If @new_position is -1, the item
- * is placed last.
- *
- * Moves an item to a new position within the #EIconBar.
- **/
-void
-e_icon_bar_reorder_item (EIconBar *icon_bar,
- gint item_num,
- gint new_position)
-{
- EIconBarItem tmp_item;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < icon_bar->items->len);
- g_return_if_fail (new_position >= -1);
- g_return_if_fail (new_position < icon_bar->items->len);
-
- tmp_item = g_array_index (icon_bar->items, EIconBarItem, item_num);
- g_array_remove_index (icon_bar->items, item_num);
-
- if (new_position == -1)
- g_array_append_val (icon_bar->items, tmp_item);
- else
- g_array_insert_val (icon_bar->items, new_position, tmp_item);
-
- gtk_widget_queue_resize (GTK_WIDGET (icon_bar));
-}
-
-
-/**
- * e_icon_bar_remove_item:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item to remove.
- *
- * Removes an item from the #EIconBar.
- **/
-void
-e_icon_bar_remove_item (EIconBar *icon_bar,
- gint item_num)
-{
- EIconBarItem *item;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < icon_bar->items->len);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
-
- if (item->destroy)
- item->destroy (item->data);
-
- gtk_object_destroy (GTK_OBJECT (item->text));
- gtk_object_destroy (GTK_OBJECT (item->image));
-
- g_array_remove_index (icon_bar->items, item_num);
-
- gtk_widget_queue_resize (GTK_WIDGET (icon_bar));
-}
-
-
-/**
- * e_icon_bar_get_item_image:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @Returns: The icon of the given item.
- *
- * Returns the icon used for the given item.
- **/
-GdkPixbuf *
-e_icon_bar_get_item_image (EIconBar *icon_bar,
- gint item_num)
-{
- EIconBarItem *item;
- GdkPixbuf *image = NULL;
-
- g_return_val_if_fail (E_IS_ICON_BAR (icon_bar), NULL);
- g_return_val_if_fail (item_num >= 0, NULL);
- g_return_val_if_fail (item_num < icon_bar->items->len, NULL);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
- gtk_object_get (GTK_OBJECT (item->image),
- "GnomeCanvasPixbuf::pixbuf", image,
- NULL);
- return image;
-}
-
-
-/**
- * e_icon_bar_set_item_image:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @image: The new icon to use for the given item.
- *
- * Sets the icon to use for the given item.
- **/
-void
-e_icon_bar_set_item_image (EIconBar *icon_bar,
- gint item_num,
- GdkPixbuf *image)
-{
- EIconBarItem *item;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < icon_bar->items->len);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
- gnome_canvas_item_set (item->image,
- "GnomeCanvasPixbuf::pixbuf", image,
- NULL);
-}
-
-
-/**
- * e_icon_bar_get_item_text:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @Returns: The text of the given item.
- *
- * Returns the text of the given item.
- **/
-gchar*
-e_icon_bar_get_item_text (EIconBar *icon_bar,
- gint item_num)
-{
- EIconBarItem *item;
-
- g_return_val_if_fail (E_IS_ICON_BAR (icon_bar), NULL);
- g_return_val_if_fail (item_num >= 0, NULL);
- g_return_val_if_fail (item_num < icon_bar->items->len, NULL);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
- return e_icon_bar_text_item_get_text (E_ICON_BAR_TEXT_ITEM (item->text));
-}
-
-
-/**
- * e_icon_bar_set_item_text:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @text: The new text for the given item.
- *
- * Sets the text of the given item.
- **/
-void
-e_icon_bar_set_item_text (EIconBar *icon_bar,
- gint item_num,
- gchar *text)
-{
- EIconBarItem *item;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < icon_bar->items->len);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
- e_icon_bar_text_item_set_text (E_ICON_BAR_TEXT_ITEM (item->text),
- text, FALSE);
-}
-
-
-/**
- * e_icon_bar_get_item_data:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @Returns: The user data associated with the given item.
- *
- * Returns the user data associated with the given item.
- **/
-gpointer
-e_icon_bar_get_item_data (EIconBar *icon_bar,
- gint item_num)
-{
- EIconBarItem *item;
-
- g_return_val_if_fail (E_IS_ICON_BAR (icon_bar), NULL);
- g_return_val_if_fail (item_num >= 0, NULL);
- g_return_val_if_fail (item_num < icon_bar->items->len, NULL);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
- return item->data;
-}
-
-
-/**
- * e_icon_bar_set_item_data:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @data: The user data to set for the given item.
- *
- * Sets the user data of the given item.
- **/
-void
-e_icon_bar_set_item_data (EIconBar *icon_bar,
- gint item_num,
- gpointer data)
-{
- e_icon_bar_set_item_data_full (icon_bar, item_num, data, NULL);
-}
-
-
-/**
- * e_icon_bar_set_item_data_full:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @data: The user data to set for the given item.
- * @destroy: The function to free @data when the item is destroyed.
- *
- * Sets the user data of the given item, and the function to free the data
- * when the item is destroyed.
- **/
-void
-e_icon_bar_set_item_data_full (EIconBar *icon_bar,
- gint item_num,
- gpointer data,
- GtkDestroyNotify destroy)
-{
- EIconBarItem *item;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < icon_bar->items->len);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
-
- if (item->destroy)
- item->destroy (item->data);
-
- item->data = data;
- item->destroy = destroy;
-}
-
-
-static void
-e_icon_bar_on_text_height_changed (GnomeCanvasItem *text_item,
- EIconBar *icon_bar)
-{
- gtk_widget_queue_resize (GTK_WIDGET (icon_bar));
-}
-
-
-/* This returns the index of the given item, or -1 if it isn't found. */
-static gint
-e_icon_bar_find_item (EIconBar *icon_bar,
- GnomeCanvasItem *canvas_item)
-{
- EIconBarItem *item;
- gint item_num;
-
- for (item_num = 0; item_num < icon_bar->items->len; item_num++) {
- item = &g_array_index (icon_bar->items,
- EIconBarItem, item_num);
-
- if (item->text == canvas_item || item->image == canvas_item) {
- return item_num;
- }
- }
-
- return -1;
-}
-
-
-/* When an item has a grab, it will get all events, so we need to use the
- position to find the real item. */
-static gboolean
-e_icon_bar_on_item_event (GnomeCanvasItem *item,
- GdkEvent *event,
- EIconBar *icon_bar)
-{
- gint item_num;
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- item_num = e_icon_bar_find_item_at_position (icon_bar,
- event->button.x,
- event->button.y,
- NULL);
- e_icon_bar_item_pressed (icon_bar, item_num, event);
- return TRUE;
- case GDK_BUTTON_RELEASE:
- item_num = e_icon_bar_find_item_at_position (icon_bar,
- event->button.x,
- event->button.y,
- NULL);
- e_icon_bar_item_released (icon_bar, item_num, event);
- return TRUE;
- case GDK_MOTION_NOTIFY:
- item_num = e_icon_bar_find_item_at_position (icon_bar,
- event->motion.x,
- event->motion.y,
- NULL);
- e_icon_bar_item_motion (icon_bar, item_num, event);
- return TRUE;
- default:
- break;
- }
-
- return FALSE;
-}
-
-
-void
-e_icon_bar_item_pressed (EIconBar *icon_bar,
- gint item_num,
- GdkEvent *event)
-{
- EIconBarItem *item;
- gint button;
-
- /* If we are editing an item, and a different item (or anywhere outside
- an item) is clicked, stop the edit. If the item being edited is
- clicked we just return, since the user may be selecting text. */
- if (icon_bar->editing_item_num != -1) {
- if (icon_bar->editing_item_num == item_num) {
- item = &g_array_index (icon_bar->items, EIconBarItem,
- icon_bar->editing_item_num);
- if (!GTK_WIDGET_HAS_FOCUS (item->text->canvas)
- || item->text->canvas->focused_item != item->text)
- gnome_canvas_item_grab_focus (item->text);
- } else {
- e_icon_bar_stop_editing_item (icon_bar, TRUE);
- }
-
- return;
- }
-
- button = event->button.button;
-
- if (button == 1 && item_num != -1) {
- icon_bar->pressed_item_num = item_num;
- icon_bar->pressed_x = event->button.x;
- icon_bar->pressed_y = event->button.y;
- gtk_widget_queue_draw (GTK_WIDGET (icon_bar));
- } else if (button == 3) {
- gtk_signal_emit (GTK_OBJECT (icon_bar),
- e_icon_bar_signals[ITEM_SELECTED],
- event, item_num);
- }
-}
-
-
-void
-e_icon_bar_item_released (EIconBar *icon_bar,
- gint item_num,
- GdkEvent *event)
-{
- gint button;
-
- /* If we are editing an item, just return. */
- if (icon_bar->editing_item_num != -1)
- return;
-
- button = event->button.button;
-
- if (button == 1) {
- if (icon_bar->pressed_item_num == icon_bar->mouse_over_item_num) {
- gtk_signal_emit (GTK_OBJECT (icon_bar),
- e_icon_bar_signals[ITEM_SELECTED],
- event, item_num);
- }
-
- icon_bar->pressed_item_num = -1;
- gtk_widget_queue_draw (GTK_WIDGET (icon_bar));
- }
-}
-
-
-void
-e_icon_bar_item_motion (EIconBar *icon_bar,
- gint item_num,
- GdkEvent *event)
-{
- gboolean need_redraw = TRUE;
-
- if (event && event->motion.state & GDK_BUTTON1_MASK
- && icon_bar->pressed_item_num != -1) {
- if (abs (event->motion.x - icon_bar->pressed_x) > E_ICON_BAR_DRAG_START_OFFSET
- || abs (event->motion.y - icon_bar->pressed_y) > E_ICON_BAR_DRAG_START_OFFSET) {
- icon_bar->dragged_item_num = icon_bar->pressed_item_num;
- gtk_signal_emit (GTK_OBJECT (icon_bar),
- e_icon_bar_signals[ITEM_DRAGGED],
- event, icon_bar->dragged_item_num);
-
- /* Don't show the button as pressed while dragging. */
- icon_bar->pressed_item_num = -1;
- gtk_widget_queue_draw (GTK_WIDGET (icon_bar));
- }
-
- return;
- }
-
- if (icon_bar->mouse_over_item_num == item_num)
- return;
-
- /* If we are editing an item, items aren't highlighted so we don't
- need a redraw. Also if an item is pressed, we only need a redraw if
- item_num or the old mouse_over_item_num is the pressed item. */
- if (icon_bar->editing_item_num != -1) {
- need_redraw = FALSE;
- } else if (icon_bar->pressed_item_num != -1) {
- if (icon_bar->pressed_item_num != item_num
- && icon_bar->pressed_item_num != icon_bar->mouse_over_item_num)
- need_redraw = FALSE;
- }
-
- icon_bar->mouse_over_item_num = item_num;
-
- if (need_redraw)
- gtk_widget_queue_draw (GTK_WIDGET (icon_bar));
-}
-
-
-/* This returns the index of the item at the given position on the EIconBar,
- or -1 if no item is found. If before_item is not NULL, it returns the
- item which the mouse is before, or -1 (for dragging). */
-gint
-e_icon_bar_find_item_at_position (EIconBar *icon_bar,
- gint x,
- gint y,
- gint *before_item)
-{
- EIconBarItem *item = NULL;
- gint item_num;
-
- if (before_item)
- *before_item = -1;
-
- for (item_num = 0; item_num < icon_bar->items->len; item_num++) {
- item = &g_array_index (icon_bar->items,
- EIconBarItem, item_num);
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- if (e_icon_bar_large_icons_intersects (icon_bar, item,
- x, y))
- return item_num;
-
- if (before_item
- && e_icon_bar_large_icons_is_before (icon_bar,
- item, x, y)) {
- *before_item = item_num;
- return -1;
- }
- } else {
- if (e_icon_bar_small_icons_intersects (icon_bar, item,
- x, y))
- return item_num;
-
- if (before_item
- && e_icon_bar_small_icons_is_before (icon_bar,
- item, x, y)) {
- *before_item = item_num;
- return -1;
- }
-
- }
-
- }
-
- /* If the mouse is below all the items, but inside the items' width,
- and before_item is not NULL, we set it to the number of items, so
- the dropped item would be added at the end. Note that this assumes
- that the item variable points to the last item in the EIconBar. */
- if (before_item) {
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- if (x < icon_bar->text_x
- || x >= icon_bar->text_x + icon_bar->text_w)
- return -1;
-
- if (item == NULL
- || y > item->icon_y + item->item_height)
- *before_item = icon_bar->items->len;
- } else {
- if (x < icon_bar->icon_x
- || x >= icon_bar->text_x + icon_bar->text_w)
- return -1;
-
- if (item == NULL) {
- *before_item = icon_bar->items->len;
- } else {
- gint max_y;
- max_y = MAX (item->icon_y + icon_bar->icon_h,
- item->text_y + item->text_height);
- if (y > max_y)
- *before_item = icon_bar->items->len;
- }
- }
- }
-
- return -1;
-}
-
-
-static gboolean
-e_icon_bar_large_icons_intersects (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y)
-{
- if (y < item->icon_y || y >= item->text_y + item->text_height)
- return FALSE;
-
- if (y < item->icon_y + icon_bar->icon_h) {
- if (x < icon_bar->icon_x
- || x >= icon_bar->icon_x + icon_bar->icon_w)
- return FALSE;
- } else {
- if (x < item->text_x
- || x >= item->text_x + item->text_width)
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-static gboolean
-e_icon_bar_large_icons_is_before (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y)
-{
- if (y < item->icon_y - icon_bar->spacing
- || y >= item->icon_y)
- return FALSE;
-
- if (x < icon_bar->text_x || x >= icon_bar->text_x + icon_bar->text_w)
- return FALSE;
-
- return TRUE;
-}
-
-
-static gboolean
-e_icon_bar_small_icons_intersects (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y)
-{
- gint min_y, max_y;
-
- min_y = MIN (item->icon_y, item->text_y);
- max_y = MAX (item->icon_y + icon_bar->icon_h,
- item->text_y + item->text_height);
-
- if (y < min_y || y >= max_y)
- return FALSE;
-
- if (x < icon_bar->icon_x || x >= item->text_x + item->text_width)
- return FALSE;
-
- return TRUE;
-}
-
-
-static gboolean
-e_icon_bar_small_icons_is_before (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y)
-{
- gint min_y, max_y;
-
- max_y = MIN (item->icon_y, item->text_y);
- min_y = max_y - icon_bar->spacing;
-
- if (y < min_y || y >= max_y)
- return FALSE;
-
- if (x < icon_bar->icon_x || x >= icon_bar->text_x + icon_bar->text_w)
- return FALSE;
-
- return TRUE;
-}
-
-
-/**
- * e_icon_bar_start_editing_item:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- *
- * Turns the item into an editable text field so the user can rename it.
- * Editing is stopped automatically when the user hits 'Return' or clicks
- * outside the item. It can also be stopped explicitly by calling
- * e_icon_bar_stop_editing_item().
- **/
-void
-e_icon_bar_start_editing_item (EIconBar *icon_bar,
- gint item_num)
-{
- EIconBarItem *item;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < icon_bar->items->len);
-
- item = &g_array_index (icon_bar->items,
- EIconBarItem, item_num);
-
- e_icon_bar_text_item_start_editing (E_ICON_BAR_TEXT_ITEM (item->text));
-}
-
-
-/**
- * e_icon_bar_stop_editing_item:
- * @icon_bar: An #EIconBar.
- * @accept: TRUE if the changes should be accepted, FALSE if the text should be
- * changed back to its state before the editing started.
- *
- * Stops the editing of the items, if any were being edited.
- **/
-void
-e_icon_bar_stop_editing_item (EIconBar *icon_bar,
- gboolean accept)
-{
- EIconBarItem *item;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
-
- if (icon_bar->editing_item_num != -1) {
- item = &g_array_index (icon_bar->items, EIconBarItem,
- icon_bar->editing_item_num);
- e_icon_bar_text_item_stop_editing (E_ICON_BAR_TEXT_ITEM (item->text), accept);
- }
-}
-
-
-static void
-e_icon_bar_on_text_item_editing_started (EIconBarTextItem *text_item,
- EIconBar *icon_bar)
-{
- gint item_num;
-
- item_num = e_icon_bar_find_item (icon_bar,
- GNOME_CANVAS_ITEM (text_item));
- g_return_if_fail (item_num != -1);
-
- /* Turn off any highlighted item. */
- e_icon_bar_item_motion (icon_bar, -1, NULL);
-
- icon_bar->editing_item_num = item_num;
-
- e_icon_bar_ensure_edited_item_visible (icon_bar);
-}
-
-
-static void
-e_icon_bar_on_text_item_editing_stopped (EIconBarTextItem *text_item,
- EIconBar *icon_bar)
-{
- gint item_num;
-
- item_num = e_icon_bar_find_item (icon_bar,
- GNOME_CANVAS_ITEM (text_item));
- g_return_if_fail (item_num != -1);
-
- e_icon_bar_text_item_select (text_item, FALSE);
-
- icon_bar->editing_item_num = -1;
-
- e_icon_bar_update_highlight (icon_bar);
-}
-
-
-static void
-e_icon_bar_ensure_edited_item_visible (EIconBar *icon_bar)
-{
- EIconBarItem *item;
- gint scroll_x, scroll_y, min_scroll_y, max_scroll_y, new_scroll_y;
-
- if (icon_bar->editing_item_num == -1)
- return;
-
- item = &g_array_index (icon_bar->items,
- EIconBarItem, icon_bar->editing_item_num);
- gnome_canvas_get_scroll_offsets (GNOME_CANVAS (icon_bar),
- &scroll_x, &scroll_y);
-
- /* The minimum scroll y position is with the text right on the bottom
- of the display. */
- min_scroll_y = item->text_y + item->text_height + E_ICON_BAR_V_SPACE
- - GTK_WIDGET (icon_bar)->allocation.height;
- /* The maximum scroll y position is with the text at the top. */
- max_scroll_y = item->text_y - E_ICON_BAR_V_SPACE;
-
- new_scroll_y = MAX (scroll_y, min_scroll_y);
- new_scroll_y = MIN (new_scroll_y, max_scroll_y);
-
- if (new_scroll_y != scroll_y)
- gnome_canvas_scroll_to (GNOME_CANVAS (icon_bar),
- scroll_x, new_scroll_y);
-}
-
-
-/* This gets the mouse position and updates the highlight if necessary.
- It is called after items are added/deleted/scrolled/edited. */
-static void
-e_icon_bar_update_highlight (EIconBar *icon_bar)
-{
- GtkWidget *widget;
- gint x, y, item_num;
-
- widget = GTK_WIDGET (icon_bar);
-
- if (!widget->window)
- return;
-
- gdk_window_get_pointer (widget->window, &x, &y, NULL);
-
- if (x < 0 || y < 0
- || x > widget->allocation.width || y > widget->allocation.height)
- return;
-
- item_num = e_icon_bar_find_item_at_position (icon_bar, x, y, NULL);
- e_icon_bar_item_motion (icon_bar, item_num, NULL);
-}
-
-
-static gint
-e_icon_bar_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
-{
- EIconBar *icon_bar;
- gint item_num, before_item, scroll_x, scroll_y;
-
- g_return_val_if_fail (E_IS_ICON_BAR (widget), FALSE);
-
- icon_bar = E_ICON_BAR (widget);
-
- icon_bar->in_drag = TRUE;
-
- /* Check if the mouse is over or between items, and if so highlight. */
- gnome_canvas_get_scroll_offsets (GNOME_CANVAS (icon_bar),
- &scroll_x, &scroll_y);
- item_num = e_icon_bar_find_item_at_position (icon_bar,
- x + scroll_x,
- y + scroll_y,
- &before_item);
- e_icon_bar_item_motion (icon_bar, item_num, NULL);
- e_icon_bar_set_dragging_before_item (icon_bar, before_item);
-
- /* Check if the mouse is at the top or bottom of the bar, and if it is
- scroll up/down. */
- if (y < E_ICON_BAR_DRAG_AUTO_SCROLL_OFFSET)
- icon_bar->scrolling_up = TRUE;
- else if (y >= widget->allocation.height - E_ICON_BAR_DRAG_AUTO_SCROLL_OFFSET)
- icon_bar->scrolling_up = FALSE;
- else {
- if (icon_bar->auto_scroll_timeout_id != 0) {
- gtk_timeout_remove (icon_bar->auto_scroll_timeout_id);
- icon_bar->auto_scroll_timeout_id = 0;
- }
- return FALSE;
- }
-
- if (icon_bar->auto_scroll_timeout_id == 0) {
- icon_bar->auto_scroll_timeout_id = g_timeout_add (E_ICON_BAR_SCROLL_TIMEOUT, e_icon_bar_timeout_handler, icon_bar);
- icon_bar->auto_scroll_delay = E_ICON_BAR_SCROLL_DELAY;
- }
-
- return FALSE;
-}
-
-
-static void
-e_icon_bar_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time)
-{
- EIconBar *icon_bar;
-
- g_return_if_fail (E_IS_ICON_BAR (widget));
-
- icon_bar = E_ICON_BAR (widget);
-
- icon_bar->in_drag = FALSE;
-
- if (icon_bar->auto_scroll_timeout_id != 0) {
- gtk_timeout_remove (icon_bar->auto_scroll_timeout_id);
- icon_bar->auto_scroll_timeout_id = 0;
- }
-
- if (icon_bar->mouse_over_item_num != -1) {
- icon_bar->mouse_over_item_num = -1;
- gtk_widget_queue_draw (GTK_WIDGET (icon_bar));
- }
-}
-
-
-static void
-e_icon_bar_set_dragging_before_item (EIconBar *icon_bar,
- gint before_item)
-{
- if (icon_bar->dragging_before_item_num == before_item)
- return;
-
- icon_bar->dragging_before_item_num = before_item;
-
- gtk_widget_queue_draw (GTK_WIDGET (icon_bar));
-}
-
-
-static gboolean
-e_icon_bar_timeout_handler (gpointer data)
-{
- EIconBar *icon_bar;
- gint scroll_x, scroll_y, new_scroll_y;
- GtkAdjustment *adj;
-
- g_return_val_if_fail (E_IS_ICON_BAR (data), FALSE);
-
- icon_bar = E_ICON_BAR (data);
-
- GDK_THREADS_ENTER ();
-
- if (icon_bar->auto_scroll_delay > 0) {
- icon_bar->auto_scroll_delay--;
- GDK_THREADS_LEAVE ();
- return TRUE;
- }
-
- gnome_canvas_get_scroll_offsets (GNOME_CANVAS (icon_bar),
- &scroll_x, &scroll_y);
-
- adj = GTK_LAYOUT (icon_bar)->vadjustment;
-
- if (icon_bar->scrolling_up)
- new_scroll_y = MAX (scroll_y - adj->step_increment, 0);
- else
- new_scroll_y = MIN (scroll_y + adj->step_increment,
- adj->upper - adj->page_size);
-
- if (new_scroll_y != scroll_y)
- gnome_canvas_scroll_to (GNOME_CANVAS (icon_bar),
- scroll_x, new_scroll_y);
-
- GDK_THREADS_LEAVE ();
- return TRUE;
-}
diff --git a/widgets/shortcut-bar/e-icon-bar.h b/widgets/shortcut-bar/e-icon-bar.h
deleted file mode 100644
index 65ab69f23f..0000000000
--- a/widgets/shortcut-bar/e-icon-bar.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-#ifndef _E_ICON_BAR_H_
-#define _E_ICON_BAR_H_
-
-#include <gdk_imlib.h>
-#include <libgnomeui/gnome-canvas.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*
- * EIconBar is a subclass of GnomeCanvas for displaying a vertical column of
- * icons and descriptions. It provides 2 views - large icons and small icons.
- */
-
-
-/* This contains information on one item. */
-typedef struct _EIconBarItem EIconBarItem;
-struct _EIconBarItem
-{
- GnomeCanvasItem *text;
- GnomeCanvasItem *image;
-
- /* This is user data attached to the item, e.g. a URL. */
- gpointer data;
- GtkDestroyNotify destroy;
-
- /* This is the height of the item. */
- gint item_height;
-
- /* This is the actual x, width and height of the text, rather than
- the maximum allowed area. */
- gint text_x;
- gint text_width;
- gint text_height;
-
- gint icon_y, text_y;
-};
-
-
-/* These are the view types. Defaults to LARGE_ICONS. */
-typedef enum
-{
- E_ICON_BAR_LARGE_ICONS,
- E_ICON_BAR_SMALL_ICONS
-} EIconBarViewType;
-
-
-#define E_ICON_BAR(obj) GTK_CHECK_CAST (obj, e_icon_bar_get_type (), EIconBar)
-#define E_ICON_BAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_icon_bar_get_type (), EIconBarClass)
-#define E_IS_ICON_BAR(obj) GTK_CHECK_TYPE (obj, e_icon_bar_get_type ())
-
-
-typedef struct _EIconBar EIconBar;
-typedef struct _EIconBarClass EIconBarClass;
-
-struct _EIconBar
-{
- GnomeCanvas canvas;
-
- /* This specifies if we are using large icons or small icons. */
- EIconBarViewType view_type;
-
- /* This is an array of EIconBarItem elements. */
- GArray *items;
-
- /* This is the index of the item which has been pressed, or -1.
- It will be shown as pressed in while the mouse is over it. */
- gint pressed_item_num;
-
- /* This is the coordinates of where the button was pressed. If the
- mouse moves a certain distance with the button still pressed, we
- start a drag. */
- gint pressed_x;
- gint pressed_y;
-
- /* This is the index of the item the mouse is currently over, or -1.
- It will be highlighted unless one of the items is pressed. */
- gint mouse_over_item_num;
-
- /* This is the item that we are currently editing, or -1. */
- gint editing_item_num;
-
- /* This is the index of the item which is being dragged, or -1.
- If the drag results in a move it will be deleted. */
- gint dragged_item_num;
-
- /* This is TRUE if we are dragging over this EIconBar. */
- gboolean in_drag;
-
- /* This is used in drag-and-drop to indicate the item which the mouse
- is currently before, e.g. if it is 1 then a dropped item would be
- inserted between items 0 and 1. It ranges from 0 to the number of
- items, or is -1 when the mouse is not dragging between items. */
- gint dragging_before_item_num;
-
- /* These are the common positions of all the items in the EIconBar. */
- gint icon_x, icon_w, icon_h, text_x, text_w, spacing;
-
- /* This is the source id of our auto-scroll timeout handler, used when
- in the middle of drag-and-drop operations. */
- gint auto_scroll_timeout_id;
- gint auto_scroll_delay;
- gboolean scrolling_up;
-};
-
-struct _EIconBarClass
-{
- GnomeCanvasClass parent_class;
-
- void (*selected_item) (EIconBar *icon_bar,
- GdkEvent *event,
- gint item_num);
- void (*dragged_item) (EIconBar *icon_bar,
- GdkEvent *event,
- gint item_num);
-};
-
-
-GtkType e_icon_bar_get_type (void);
-GtkWidget* e_icon_bar_new (void);
-
-/* Sets the view type. */
-void e_icon_bar_set_view_type (EIconBar *icon_bar,
- EIconBarViewType view_type);
-
-/* Adds a new item to a group at the given position. If position is -1 it is
- added at the end. It returns the index of the item. */
-gint e_icon_bar_add_item (EIconBar *icon_bar,
- GdkPixbuf *image,
- gchar *text,
- gint position);
-
-/* Reorders an item. Note that position refers to the new position to add the
- item after removing it from its current position. If position is -1 it is
- moved to the end of the bar. */
-void e_icon_bar_reorder_item (EIconBar *icon_bar,
- gint item_num,
- gint new_position);
-void e_icon_bar_remove_item (EIconBar *icon_bar,
- gint item_num);
-
-GdkPixbuf * e_icon_bar_get_item_image (EIconBar *icon_bar,
- gint item_num);
-void e_icon_bar_set_item_image (EIconBar *icon_bar,
- gint item_num,
- GdkPixbuf *image);
-
-gchar* e_icon_bar_get_item_text (EIconBar *icon_bar,
- gint item_num);
-void e_icon_bar_set_item_text (EIconBar *icon_bar,
- gint item_num,
- gchar *text);
-
-gpointer e_icon_bar_get_item_data (EIconBar *icon_bar,
- gint item_num);
-void e_icon_bar_set_item_data (EIconBar *icon_bar,
- gint item_num,
- gpointer data);
-void e_icon_bar_set_item_data_full (EIconBar *icon_bar,
- gint item_num,
- gpointer data,
- GtkDestroyNotify destroy);
-
-void e_icon_bar_start_editing_item (EIconBar *icon_bar,
- gint item_num);
-void e_icon_bar_stop_editing_item (EIconBar *icon_bar,
- gboolean accept);
-
-
-
-/*
- * INTERNAL FUNCTIONS - for use by EIconBarBgItem.
- */
-
-/* This returns the index of the item at the given position on the EIconBar,
- or -1 if no item is found. If before_item is not NULL, it returns the
- item which the mouse is before, or -1 (this is used for dragging). */
-gint e_icon_bar_find_item_at_position (EIconBar *icon_bar,
- gint x,
- gint y,
- gint *before_item);
-
-void e_icon_bar_item_pressed (EIconBar *icon_bar,
- gint item_num,
- GdkEvent *event);
-void e_icon_bar_item_released (EIconBar *icon_bar,
- gint item_num,
- GdkEvent *event);
-void e_icon_bar_item_motion (EIconBar *icon_bar,
- gint item_num,
- GdkEvent *event);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_ICON_BAR_H_ */
diff --git a/widgets/shortcut-bar/e-shortcut-bar.c b/widgets/shortcut-bar/e-shortcut-bar.c
deleted file mode 100644
index 842a8927f9..0000000000
--- a/widgets/shortcut-bar/e-shortcut-bar.c
+++ /dev/null
@@ -1,562 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * ShortcutBar displays a vertical bar with a number of Groups, each of which
- * contains any number of icons. It is used on the left of the main application
- * window so users can easily access items such as folders and files.
- */
-
-#include <string.h>
-#include <gnome.h>
-
-#include "e-shortcut-bar.h"
-#include "e-clipped-label.h"
-#include "e-vscrolled-bar.h"
-
-/* Drag and Drop stuff. */
-enum {
- TARGET_SHORTCUT
-};
-static GtkTargetEntry target_table[] = {
- { "E-SHORTCUT", 0, TARGET_SHORTCUT }
-};
-static guint n_targets = sizeof(target_table) / sizeof(target_table[0]);
-
-typedef struct _EShortcutBarBuiltinType EShortcutBarBuiltinType;
-struct _EShortcutBarBuiltinType {
- gchar *name;
- gchar *filename;
- GdkPixbuf *image;
-};
-
-EShortcutBarBuiltinType e_shortcut_bar_builtin_types[] = {
- { "folder:", "gnome-word.png", NULL },
- { "calendar:", "gnome-calendar.png", NULL },
- { "todo:", "gnome-cromagnon.png", NULL },
- { "contacts:", "gnome-ccthemes.png", NULL }
-};
-static gint e_shortcut_bar_num_builtin_types = sizeof (e_shortcut_bar_builtin_types) / sizeof (EShortcutBarBuiltinType);
-
-gboolean e_shortcut_bar_default_type_image_loaded = FALSE;
-GdkPixbuf *e_shortcut_bar_default_type_image = NULL;
-gchar *e_shortcut_bar_default_type_filename = "gnome-balsa2.png";
-
-static void e_shortcut_bar_class_init (EShortcutBarClass *class);
-static void e_shortcut_bar_init (EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_destroy (GtkObject *object);
-static void e_shortcut_bar_set_canvas_style (EShortcutBar *shortcut_bar,
- GtkWidget *canvas);
-static void e_shortcut_bar_item_selected (EIconBar *icon_bar,
- GdkEvent *event,
- gint item_num,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_item_dragged (EIconBar *icon_bar,
- GdkEvent *event,
- gint item_num,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_on_drag_data_get (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_on_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *data,
- guint info,
- guint time,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_on_drag_data_delete (GtkWidget *widget,
- GdkDragContext *context,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_stop_editing (GtkWidget *button,
- EShortcutBar *shortcut_bar);
-static GdkPixbuf* e_shortcut_bar_get_image_from_url (EShortcutBar *shortcut_bar,
- gchar *item_url);
-static GdkPixbuf* e_shortcut_bar_load_image (gchar *filename);
-
-
-enum
-{
- ITEM_SELECTED,
- LAST_SIGNAL
-};
-
-static guint e_shortcut_bar_signals[LAST_SIGNAL] = {0};
-
-static EGroupBarClass *parent_class;
-
-
-GtkType
-e_shortcut_bar_get_type (void)
-{
- static GtkType e_shortcut_bar_type = 0;
-
- if (!e_shortcut_bar_type){
- GtkTypeInfo e_shortcut_bar_info = {
- "EShortcutBar",
- sizeof (EShortcutBar),
- sizeof (EShortcutBarClass),
- (GtkClassInitFunc) e_shortcut_bar_class_init,
- (GtkObjectInitFunc) e_shortcut_bar_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- parent_class = gtk_type_class (e_group_bar_get_type ());
- e_shortcut_bar_type = gtk_type_unique (e_group_bar_get_type (),
- &e_shortcut_bar_info);
- }
-
- return e_shortcut_bar_type;
-}
-
-
-static void
-e_shortcut_bar_class_init (EShortcutBarClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
-
- e_shortcut_bar_signals[ITEM_SELECTED] =
- gtk_signal_new ("item_selected",
- GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
- GTK_SIGNAL_OFFSET (EShortcutBarClass,
- selected_item),
- gtk_marshal_NONE__POINTER_INT_INT,
- GTK_TYPE_NONE, 3, GTK_TYPE_GDK_EVENT,
- GTK_TYPE_INT, GTK_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, e_shortcut_bar_signals,
- LAST_SIGNAL);
-
- /* Method override */
- object_class->destroy = e_shortcut_bar_destroy;
-}
-
-
-static void
-e_shortcut_bar_init (EShortcutBar *shortcut_bar)
-{
- shortcut_bar->groups = g_array_new (FALSE, FALSE,
- sizeof (EShortcutBarGroup));
-}
-
-
-GtkWidget *
-e_shortcut_bar_new (void)
-{
- GtkWidget *shortcut_bar;
-
- shortcut_bar = GTK_WIDGET (gtk_type_new (e_shortcut_bar_get_type ()));
-
- return shortcut_bar;
-}
-
-
-static void
-e_shortcut_bar_destroy (GtkObject *object)
-{
- EShortcutBar *shortcut_bar;
-
- shortcut_bar = E_SHORTCUT_BAR (object);
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-
- g_array_free (shortcut_bar->groups, TRUE);
-}
-
-
-gint
-e_shortcut_bar_add_group (EShortcutBar *shortcut_bar, gchar *group_name)
-{
- EShortcutBarGroup *group, tmp_group;
- gint group_num;
- GtkWidget *button, *label;
-
- g_return_val_if_fail (E_IS_SHORTCUT_BAR (shortcut_bar), -1);
- g_return_val_if_fail (group_name != NULL, -1);
-
- group_num = shortcut_bar->groups->len;
- g_array_append_val (shortcut_bar->groups, tmp_group);
-
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
-
- group->vscrolled_bar = e_vscrolled_bar_new (NULL);
- gtk_widget_show (group->vscrolled_bar);
- gtk_signal_connect (GTK_OBJECT (E_VSCROLLED_BAR (group->vscrolled_bar)->up_button), "pressed", GTK_SIGNAL_FUNC (e_shortcut_bar_stop_editing), shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (E_VSCROLLED_BAR (group->vscrolled_bar)->down_button), "pressed", GTK_SIGNAL_FUNC (e_shortcut_bar_stop_editing), shortcut_bar);
-
- group->icon_bar = e_icon_bar_new ();
- gtk_widget_show (group->icon_bar);
- gtk_container_add (GTK_CONTAINER (group->vscrolled_bar),
- group->icon_bar);
- gtk_signal_connect (GTK_OBJECT (group->icon_bar), "item_selected",
- GTK_SIGNAL_FUNC (e_shortcut_bar_item_selected),
- shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (group->icon_bar), "item_dragged",
- GTK_SIGNAL_FUNC (e_shortcut_bar_item_dragged),
- shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (group->icon_bar), "drag_data_get",
- GTK_SIGNAL_FUNC (e_shortcut_bar_on_drag_data_get),
- shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (group->icon_bar), "drag_data_received",
- GTK_SIGNAL_FUNC (e_shortcut_bar_on_drag_data_received),
- shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (group->icon_bar), "drag_data_delete",
- GTK_SIGNAL_FUNC (e_shortcut_bar_on_drag_data_delete),
- shortcut_bar);
-
- e_shortcut_bar_set_canvas_style (shortcut_bar, group->icon_bar);
-
- button = gtk_button_new ();
- label = e_clipped_label_new (group_name);
- gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
- gtk_widget_show (label);
- gtk_container_add (GTK_CONTAINER (button), label);
- gtk_widget_show (button);
- gtk_signal_connect (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC (e_shortcut_bar_stop_editing),
- shortcut_bar);
-
- gtk_drag_dest_set (GTK_WIDGET (group->icon_bar),
- GTK_DEST_DEFAULT_ALL,
- target_table, n_targets,
- GDK_ACTION_COPY | GDK_ACTION_MOVE);
- gtk_drag_dest_set (GTK_WIDGET (button),
- GTK_DEST_DEFAULT_ALL,
- target_table, n_targets,
- GDK_ACTION_COPY | GDK_ACTION_MOVE);
-
- e_group_bar_add_group (E_GROUP_BAR (shortcut_bar),
- group->vscrolled_bar, button, -1);
-
-
- return group_num;
-}
-
-
-void
-e_shortcut_bar_remove_group (EShortcutBar *shortcut_bar,
- gint group_num)
-{
- e_group_bar_remove_group (E_GROUP_BAR (shortcut_bar), group_num);
- g_array_remove_index (shortcut_bar->groups, group_num);
-}
-
-
-gint
-e_shortcut_bar_add_item (EShortcutBar *shortcut_bar, gint group_num,
- gchar *item_url, gchar *item_name)
-{
- EShortcutBarGroup *group;
- GdkPixbuf *image;
- gint item_num;
-
- g_return_val_if_fail (E_IS_SHORTCUT_BAR (shortcut_bar), -1);
- g_return_val_if_fail (group_num >= 0, -1);
- g_return_val_if_fail (group_num < shortcut_bar->groups->len, -1);
- g_return_val_if_fail (item_url != NULL, -1);
- g_return_val_if_fail (item_name != NULL, -1);
-
- image = e_shortcut_bar_get_image_from_url (shortcut_bar, item_url);
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
-
- item_num = e_icon_bar_add_item (E_ICON_BAR (group->icon_bar),
- image, item_name, -1);
- e_icon_bar_set_item_data_full (E_ICON_BAR (group->icon_bar), item_num,
- g_strdup (item_url), g_free);
- return item_num;
-}
-
-
-void
-e_shortcut_bar_remove_item (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num)
-{
- EShortcutBarGroup *group;
-
- g_return_if_fail (E_IS_SHORTCUT_BAR (shortcut_bar));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < shortcut_bar->groups->len);
-
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
-
- e_icon_bar_remove_item (E_ICON_BAR (group->icon_bar), item_num);
-}
-
-
-static void
-e_shortcut_bar_set_canvas_style (EShortcutBar *shortcut_bar,
- GtkWidget *canvas)
-{
- GtkRcStyle *rc_style;
-
- rc_style = gtk_rc_style_new ();
-
- rc_style->color_flags[GTK_STATE_NORMAL] = GTK_RC_FG | GTK_RC_BG;
- rc_style->fg[GTK_STATE_NORMAL].red = 65535;
- rc_style->fg[GTK_STATE_NORMAL].green = 65535;
- rc_style->fg[GTK_STATE_NORMAL].blue = 65535;
-
- rc_style->bg[GTK_STATE_NORMAL].red = 32512;
- rc_style->bg[GTK_STATE_NORMAL].green = 32512;
- rc_style->bg[GTK_STATE_NORMAL].blue = 32512;
-
- gtk_widget_modify_style (GTK_WIDGET (canvas), rc_style);
- gtk_rc_style_unref (rc_style);
-}
-
-
-void
-e_shortcut_bar_set_view_type (EShortcutBar *shortcut_bar,
- gint group_num,
- EIconBarViewType view_type)
-{
- EShortcutBarGroup *group;
-
- g_return_if_fail (E_IS_SHORTCUT_BAR (shortcut_bar));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < shortcut_bar->groups->len);
-
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
-
- e_icon_bar_set_view_type (E_ICON_BAR (group->icon_bar), view_type);
-}
-
-
-static void
-e_shortcut_bar_item_selected (EIconBar *icon_bar,
- GdkEvent *event,
- gint item_num,
- EShortcutBar *shortcut_bar)
-{
- gint group_num;
-
- group_num = e_group_bar_get_group_num (E_GROUP_BAR (shortcut_bar),
- GTK_WIDGET (icon_bar)->parent);
-
- gtk_signal_emit (GTK_OBJECT (shortcut_bar),
- e_shortcut_bar_signals[ITEM_SELECTED],
- event, group_num, item_num);
-}
-
-
-static void
-e_shortcut_bar_item_dragged (EIconBar *icon_bar,
- GdkEvent *event,
- gint item_num,
- EShortcutBar *shortcut_bar)
-{
- GtkTargetList *target_list;
- gint group_num;
-
- group_num = e_group_bar_get_group_num (E_GROUP_BAR (shortcut_bar),
- GTK_WIDGET (icon_bar)->parent);
-
- /* FIXME: free somewhere - drag_end? */
- shortcut_bar->dragged_url = g_strdup (e_icon_bar_get_item_data (icon_bar, item_num));
- shortcut_bar->dragged_name = g_strdup (e_icon_bar_get_item_text (icon_bar, item_num));
-
- target_list = gtk_target_list_new (target_table, n_targets);
- gtk_drag_begin (GTK_WIDGET (icon_bar), target_list,
- GDK_ACTION_COPY | GDK_ACTION_MOVE,
- 1, event);
- gtk_target_list_unref (target_list);
-}
-
-
-static void
-e_shortcut_bar_on_drag_data_get (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- EShortcutBar *shortcut_bar)
-{
- gchar *data;
-
- if (info == TARGET_SHORTCUT) {
- data = g_strdup_printf ("%s%c%s", shortcut_bar->dragged_name,
- '\0', shortcut_bar->dragged_url);
- gtk_selection_data_set (selection_data, selection_data->target,
- 8, data,
- strlen (shortcut_bar->dragged_name)
- + strlen (shortcut_bar->dragged_url)
- + 2);
- g_free (data);
- }
-}
-
-
-static void
-e_shortcut_bar_on_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *data,
- guint info,
- guint time,
- EShortcutBar *shortcut_bar)
-{
- EShortcutBarGroup *group;
- gchar *item_name, *item_url;
- EIconBar *icon_bar;
- GdkPixbuf *image;
- gint group_num, item_num;
-
- icon_bar = E_ICON_BAR (widget);
-
- if ((data->length >= 0) && (data->format == 8)
- && icon_bar->dragging_before_item_num != -1) {
- item_name = data->data;
- item_url = item_name + strlen (item_name) + 1;
-
- image = e_shortcut_bar_get_image_from_url (shortcut_bar,
- item_url);
-
- group_num = e_group_bar_get_group_num (E_GROUP_BAR (shortcut_bar),
- GTK_WIDGET (icon_bar)->parent);
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
-
- item_num = e_icon_bar_add_item (E_ICON_BAR (group->icon_bar), image, item_name, icon_bar->dragging_before_item_num);
- e_icon_bar_set_item_data_full (E_ICON_BAR (group->icon_bar),
- item_num, g_strdup (item_url),
- g_free);
-
- gtk_drag_finish (context, TRUE, TRUE, time);
- return;
- }
-
- gtk_drag_finish (context, FALSE, FALSE, time);
-}
-
-
-static void
-e_shortcut_bar_on_drag_data_delete (GtkWidget *widget,
- GdkDragContext *context,
- EShortcutBar *shortcut_bar)
-{
- EIconBar *icon_bar;
-
- icon_bar = E_ICON_BAR (widget);
-
- e_icon_bar_remove_item (icon_bar, icon_bar->dragged_item_num);
-}
-
-
-void
-e_shortcut_bar_start_editing_item (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num)
-{
- EShortcutBarGroup *group;
-
- g_return_if_fail (E_IS_SHORTCUT_BAR (shortcut_bar));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < shortcut_bar->groups->len);
-
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
-
- e_icon_bar_start_editing_item (E_ICON_BAR (group->icon_bar), item_num);
-}
-
-
-/* We stop editing any item when a scroll button is pressed. */
-static void
-e_shortcut_bar_stop_editing (GtkWidget *button,
- EShortcutBar *shortcut_bar)
-{
- EShortcutBarGroup *group;
- gint group_num;
-
- for (group_num = 0;
- group_num < shortcut_bar->groups->len;
- group_num++) {
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
- e_icon_bar_stop_editing_item (E_ICON_BAR (group->icon_bar),
- TRUE);
- }
-}
-
-
-static GdkPixbuf *
-e_shortcut_bar_get_image_from_url (EShortcutBar *shortcut_bar,
- gchar *item_url)
-{
- gchar *method_terminator;
- gint method_len, i;
-
- method_terminator = strchr (item_url, ':');
- if (method_terminator) {
- method_len = method_terminator - item_url + 1;
-
- /* Check if it is a builtin type. */
- for (i = 0; i < e_shortcut_bar_num_builtin_types; i++) {
- if (!strncmp (item_url, e_shortcut_bar_builtin_types[i].name, method_len)) {
- if (!e_shortcut_bar_builtin_types[i].image)
- e_shortcut_bar_builtin_types[i].image = e_shortcut_bar_load_image (e_shortcut_bar_builtin_types[i].filename);
- return e_shortcut_bar_builtin_types[i].image;
- }
- }
- }
-
- if (!e_shortcut_bar_default_type_image_loaded) {
- e_shortcut_bar_default_type_image_loaded = TRUE;
- e_shortcut_bar_default_type_image = e_shortcut_bar_load_image (e_shortcut_bar_default_type_filename);
- }
- return e_shortcut_bar_default_type_image;
-}
-
-
-static GdkPixbuf *
-e_shortcut_bar_load_image (gchar *filename)
-{
- gchar *pathname;
- GdkPixbuf *image = NULL;
-
- pathname = gnome_pixmap_file (filename);
- if (pathname)
- image = gdk_pixbuf_new_from_file (pathname);
- else
- g_warning ("Couldn't find pixmap: %s", filename);
-
- return image;
-}
diff --git a/widgets/shortcut-bar/e-shortcut-bar.h b/widgets/shortcut-bar/e-shortcut-bar.h
deleted file mode 100644
index 1bbdfb6754..0000000000
--- a/widgets/shortcut-bar/e-shortcut-bar.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-#ifndef _E_SHORTCUT_BAR_H_
-#define _E_SHORTCUT_BAR_H_
-
-#include "e-group-bar.h"
-#include "e-icon-bar.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*
- * EShortcutBar displays a vertical bar with a number of Groups, each of which
- * contains any number of icons. It is used on the left of the main application
- * window so users can easily access items such as folders and files.
- */
-
-
-/* This contains information on one group. */
-typedef struct _EShortcutBarGroup EShortcutBarGroup;
-struct _EShortcutBarGroup
-{
- /* This is the EVScrolledBar which scrolls the group. */
- GtkWidget *vscrolled_bar;
-
- /* This is the icon bar containing the child items. */
- GtkWidget *icon_bar;
-};
-
-
-#define E_SHORTCUT_BAR(obj) GTK_CHECK_CAST (obj, e_shortcut_bar_get_type (), EShortcutBar)
-#define E_SHORTCUT_BAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_shortcut_bar_get_type (), EShortcutBarClass)
-#define E_IS_SHORTCUT_BAR(obj) GTK_CHECK_TYPE (obj, e_shortcut_bar_get_type ())
-
-
-typedef struct _EShortcutBar EShortcutBar;
-typedef struct _EShortcutBarClass EShortcutBarClass;
-
-struct _EShortcutBar
-{
- EGroupBar group_bar;
-
- /* This is an array of EShortcutBarGroup elements. */
- GArray *groups;
-
- gchar *dragged_url;
- gchar *dragged_name;
-};
-
-struct _EShortcutBarClass
-{
- EGroupBarClass parent_class;
-
- void (*selected_item) (EShortcutBar *shortcut_bar,
- GdkEvent *event,
- gint group_num,
- gint item_num);
-};
-
-
-GtkType e_shortcut_bar_get_type (void);
-GtkWidget* e_shortcut_bar_new (void);
-
-/* Adds a new group, returning the index. */
-gint e_shortcut_bar_add_group (EShortcutBar *shortcut_bar,
- gchar *group_name);
-void e_shortcut_bar_remove_group (EShortcutBar *shortcut_bar,
- gint group_num);
-
-/* Sets the view type for the group. */
-void e_shortcut_bar_set_view_type (EShortcutBar *shortcut_bar,
- gint group_num,
- EIconBarViewType view_type);
-
-/* Adds a new item to a group, returning the index within the group. */
-gint e_shortcut_bar_add_item (EShortcutBar *shortcut_bar,
- gint group_num,
- gchar *item_url,
- gchar *item_name);
-
-void e_shortcut_bar_start_editing_item (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num);
-void e_shortcut_bar_remove_item (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_SHORTCUT_BAR_H_ */
diff --git a/widgets/shortcut-bar/e-vscrolled-bar.c b/widgets/shortcut-bar/e-vscrolled-bar.c
deleted file mode 100644
index 5d5f0ab2e2..0000000000
--- a/widgets/shortcut-bar/e-vscrolled-bar.c
+++ /dev/null
@@ -1,652 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * EVScrolledBar is like GtkScrolledWindow but only scrolls the child widget
- * vertically. It is intended for scrolling narrow vertical bars.
- */
-
-#include <gtk/gtkarrow.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtksignal.h>
-
-#include "e-vscrolled-bar.h"
-
-/* These are the offsets of the up & down buttons from the right and top/bottom
- of the widget. */
-#define E_VSCROLLED_BAR_BUTTON_X_OFFSET 2
-#define E_VSCROLLED_BAR_BUTTON_Y_OFFSET 2
-
-/* This is the time between scrolls. */
-#define E_VSCROLLED_BAR_SCROLL_TIMEOUT 20
-
-static void e_vscrolled_bar_class_init (EVScrolledBarClass *class);
-static void e_vscrolled_bar_init (EVScrolledBar *vscrolled_bar);
-static void e_vscrolled_bar_destroy (GtkObject *object);
-static void e_vscrolled_bar_finalize (GtkObject *object);
-static void e_vscrolled_bar_map (GtkWidget *widget);
-static void e_vscrolled_bar_unmap (GtkWidget *widget);
-static void e_vscrolled_bar_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void e_vscrolled_bar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void e_vscrolled_bar_draw (GtkWidget *widget,
- GdkRectangle *area);
-static void e_vscrolled_bar_add (GtkContainer *container,
- GtkWidget *child);
-static void e_vscrolled_bar_remove (GtkContainer *container,
- GtkWidget *child);
-static void e_vscrolled_bar_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static void e_vscrolled_bar_adjustment_changed (GtkAdjustment *adjustment,
- gpointer data);
-static void e_vscrolled_bar_button_pressed (GtkWidget *button,
- EVScrolledBar *vscrolled_bar);
-static void e_vscrolled_bar_button_released (GtkWidget *button,
- EVScrolledBar *vscrolled_bar);
-static void e_vscrolled_bar_button_clicked (GtkWidget *button,
- EVScrolledBar *vscrolled_bar);
-static gboolean e_vscrolled_bar_timeout_handler (gpointer data);
-
-
-static GtkBinClass *parent_class;
-
-
-GtkType
-e_vscrolled_bar_get_type (void)
-{
- static GtkType e_vscrolled_bar_type = 0;
-
- if (!e_vscrolled_bar_type) {
- GtkTypeInfo e_vscrolled_bar_info = {
- "EVScrolledBar",
- sizeof (EVScrolledBar),
- sizeof (EVScrolledBarClass),
- (GtkClassInitFunc) e_vscrolled_bar_class_init,
- (GtkObjectInitFunc) e_vscrolled_bar_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- parent_class = gtk_type_class (GTK_TYPE_BIN);
- e_vscrolled_bar_type = gtk_type_unique (GTK_TYPE_BIN,
- &e_vscrolled_bar_info);
- }
-
- return e_vscrolled_bar_type;
-}
-
-
-static void
-e_vscrolled_bar_class_init (EVScrolledBarClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- container_class = (GtkContainerClass *) class;
-
- /* Method override */
- object_class->destroy = e_vscrolled_bar_destroy;
- object_class->finalize = e_vscrolled_bar_finalize;
-
- widget_class->map = e_vscrolled_bar_map;
- widget_class->unmap = e_vscrolled_bar_unmap;
- widget_class->size_request = e_vscrolled_bar_size_request;
- widget_class->size_allocate = e_vscrolled_bar_size_allocate;
- widget_class->draw = e_vscrolled_bar_draw;
-
- container_class->add = e_vscrolled_bar_add;
- container_class->remove = e_vscrolled_bar_remove;
- container_class->forall = e_vscrolled_bar_forall;
-}
-
-
-static void
-e_vscrolled_bar_init (EVScrolledBar *vscrolled_bar)
-{
- GtkWidget *arrow;
-
- GTK_WIDGET_SET_FLAGS (vscrolled_bar, GTK_NO_WINDOW);
-
- gtk_container_set_resize_mode (GTK_CONTAINER (vscrolled_bar),
- GTK_RESIZE_QUEUE);
-
- gtk_widget_push_composite_child ();
-
- vscrolled_bar->up_button = gtk_button_new ();
- gtk_widget_set_composite_name (vscrolled_bar->up_button,
- "up_button");
- gtk_widget_set_parent (vscrolled_bar->up_button,
- GTK_WIDGET (vscrolled_bar));
- arrow = gtk_arrow_new (GTK_ARROW_UP, GTK_SHADOW_OUT);
- gtk_misc_set_padding (GTK_MISC (arrow), 1, 1);
- gtk_widget_show (arrow);
- gtk_container_add (GTK_CONTAINER (vscrolled_bar->up_button), arrow);
- gtk_signal_connect_after (GTK_OBJECT (vscrolled_bar->up_button), "pressed", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_pressed), vscrolled_bar);
- gtk_signal_connect_after (GTK_OBJECT (vscrolled_bar->up_button), "released", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_released), vscrolled_bar);
- gtk_signal_connect (GTK_OBJECT (vscrolled_bar->up_button), "clicked", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_clicked), vscrolled_bar);
-
- vscrolled_bar->down_button = gtk_button_new ();
- gtk_widget_set_composite_name (vscrolled_bar->up_button,
- "down_button");
- gtk_widget_set_parent (vscrolled_bar->down_button,
- GTK_WIDGET (vscrolled_bar));
- arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
- gtk_misc_set_padding (GTK_MISC (arrow), 1, 1);
- gtk_widget_show (arrow);
- gtk_container_add (GTK_CONTAINER (vscrolled_bar->down_button), arrow);
- gtk_signal_connect_after (GTK_OBJECT (vscrolled_bar->down_button), "pressed", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_pressed), vscrolled_bar);
- gtk_signal_connect_after (GTK_OBJECT (vscrolled_bar->down_button), "released", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_released), vscrolled_bar);
- gtk_signal_connect (GTK_OBJECT (vscrolled_bar->down_button), "clicked", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_clicked), vscrolled_bar);
-
- gtk_widget_pop_composite_child ();
-
- vscrolled_bar->adjustment = NULL;
- vscrolled_bar->timeout_id = 0;
- vscrolled_bar->scrolling_up = FALSE;
- vscrolled_bar->min_distance = -1.0;
- vscrolled_bar->button_pressed = FALSE;
-}
-
-
-/**
- * e_vscrolled_bar_new:
- *
- * @adjustment: The #GtkAdjustment to use for scrolling, or NULL.
- * @Return: A new #EVScrolledBar.
- *
- * Creates a new #EVScrolledBar with the given adjustment.
- **/
-GtkWidget *
-e_vscrolled_bar_new (GtkAdjustment *adjustment)
-{
- GtkWidget *vscrolled_bar;
-
- vscrolled_bar = GTK_WIDGET (gtk_type_new (e_vscrolled_bar_get_type ()));
- e_vscrolled_bar_set_adjustment (E_VSCROLLED_BAR (vscrolled_bar),
- adjustment);
-
- return vscrolled_bar;
-}
-
-
-static void
-e_vscrolled_bar_destroy (GtkObject *object)
-{
- EVScrolledBar *vscrolled_bar;
-
- vscrolled_bar = E_VSCROLLED_BAR (object);
-
- if (vscrolled_bar->timeout_id) {
- g_source_remove (vscrolled_bar->timeout_id);
- vscrolled_bar->timeout_id = 0;
- }
-
- gtk_widget_unparent (vscrolled_bar->up_button);
- gtk_widget_unparent (vscrolled_bar->down_button);
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-
-static void
-e_vscrolled_bar_finalize (GtkObject *object)
-{
- EVScrolledBar *vscrolled_bar;
-
- vscrolled_bar = E_VSCROLLED_BAR (object);
-
- gtk_object_unref (GTK_OBJECT (vscrolled_bar->adjustment));
-
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-
-static void
-e_vscrolled_bar_map (GtkWidget *widget)
-{
- EVScrolledBar *vscrolled_bar;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (widget));
-
- vscrolled_bar = E_VSCROLLED_BAR (widget);
-
- /* chain parent class handler to map self and child */
- GTK_WIDGET_CLASS (parent_class)->map (widget);
-
- if (GTK_WIDGET_VISIBLE (vscrolled_bar->up_button) &&
- !GTK_WIDGET_MAPPED (vscrolled_bar->up_button))
- gtk_widget_map (vscrolled_bar->up_button);
-
- if (GTK_WIDGET_VISIBLE (vscrolled_bar->down_button) &&
- !GTK_WIDGET_MAPPED (vscrolled_bar->down_button))
- gtk_widget_map (vscrolled_bar->down_button);
-}
-
-
-static void
-e_vscrolled_bar_unmap (GtkWidget *widget)
-{
- EVScrolledBar *vscrolled_bar;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (widget));
-
- vscrolled_bar = E_VSCROLLED_BAR (widget);
-
- /* chain parent class handler to unmap self and child */
- GTK_WIDGET_CLASS (parent_class)->unmap (widget);
-
- if (GTK_WIDGET_MAPPED (vscrolled_bar->up_button))
- gtk_widget_unmap (vscrolled_bar->up_button);
-
- if (GTK_WIDGET_MAPPED (vscrolled_bar->down_button))
- gtk_widget_unmap (vscrolled_bar->down_button);
-}
-
-
-static void
-e_vscrolled_bar_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- EVScrolledBar *vscrolled_bar;
- GtkBin *bin;
- GtkRequisition child_requisition;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (widget));
- g_return_if_fail (requisition != NULL);
-
- vscrolled_bar = E_VSCROLLED_BAR (widget);
- bin = GTK_BIN (widget);
-
- requisition->width = 0;
- requisition->height = 0;
-
- /* We just return the requisition of the child widget, plus the
- border width. */
- if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) {
- gtk_widget_size_request (bin->child, &child_requisition);
- *requisition = child_requisition;
- }
-
- /* We remember the requested heights of the up & down buttons. */
- gtk_widget_size_request (vscrolled_bar->up_button,
- &child_requisition);
- vscrolled_bar->up_button_width = child_requisition.width;
- vscrolled_bar->up_button_height = child_requisition.height;
-
- gtk_widget_size_request (vscrolled_bar->down_button,
- &child_requisition);
- vscrolled_bar->down_button_width = child_requisition.width;
- vscrolled_bar->down_button_height = child_requisition.height;
-
- /* Add on the standard container border widths. */
- requisition->width += GTK_CONTAINER (widget)->border_width * 2;
- requisition->height += GTK_CONTAINER (widget)->border_width * 2;
-}
-
-
-static void
-e_vscrolled_bar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- EVScrolledBar *vscrolled_bar;
- GtkBin *bin;
- GtkAllocation button_allocation, child_allocation;
- gint border_width;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (widget));
- g_return_if_fail (allocation != NULL);
-
- vscrolled_bar = E_VSCROLLED_BAR (widget);
- bin = GTK_BIN (widget);
-
- widget->allocation = *allocation;
-
- border_width = GTK_CONTAINER (widget)->border_width;
-
- child_allocation.x = border_width;
- child_allocation.y = border_width;
- child_allocation.width = allocation->width - 2 * border_width;
- child_allocation.height = allocation->height - 2 * border_width;
- gtk_widget_size_allocate (bin->child, &child_allocation);
-
- button_allocation.x = allocation->width - border_width
- - vscrolled_bar->up_button_width
- - E_VSCROLLED_BAR_BUTTON_X_OFFSET;
- button_allocation.y = border_width + E_VSCROLLED_BAR_BUTTON_Y_OFFSET;
- button_allocation.width = vscrolled_bar->up_button_width;
- button_allocation.height = vscrolled_bar->up_button_height;
- gtk_widget_size_allocate (vscrolled_bar->up_button,
- &button_allocation);
-
- button_allocation.x = allocation->width - border_width
- - vscrolled_bar->down_button_width
- - E_VSCROLLED_BAR_BUTTON_X_OFFSET;
- button_allocation.y = allocation->height - border_width
- - vscrolled_bar->down_button_height
- - E_VSCROLLED_BAR_BUTTON_Y_OFFSET;
- button_allocation.width = vscrolled_bar->down_button_width;
- button_allocation.height = vscrolled_bar->down_button_height;
- gtk_widget_size_allocate (vscrolled_bar->down_button,
- &button_allocation);
-}
-
-
-static void
-e_vscrolled_bar_draw (GtkWidget *widget,
- GdkRectangle *area)
-{
- EVScrolledBar *vscrolled_bar;
- GtkBin *bin;
- GdkRectangle child_area;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (widget));
- g_return_if_fail (area != NULL);
-
- vscrolled_bar = E_VSCROLLED_BAR (widget);
- bin = GTK_BIN (widget);
-
- if (bin->child && GTK_WIDGET_VISIBLE (bin->child) &&
- gtk_widget_intersect (bin->child, area, &child_area))
- gtk_widget_draw (bin->child, &child_area);
-
- if (GTK_WIDGET_VISIBLE (vscrolled_bar->up_button) &&
- gtk_widget_intersect (vscrolled_bar->up_button, area, &child_area))
- gtk_widget_draw (vscrolled_bar->up_button, &child_area);
-
- if (GTK_WIDGET_VISIBLE (vscrolled_bar->down_button) &&
- gtk_widget_intersect (vscrolled_bar->down_button, area, &child_area))
- gtk_widget_draw (vscrolled_bar->down_button, &child_area);
-}
-
-
-static void
-e_vscrolled_bar_add (GtkContainer *container,
- GtkWidget *child)
-{
- EVScrolledBar *vscrolled_bar;
- GtkBin *bin;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (container));
-
- vscrolled_bar = E_VSCROLLED_BAR (container);
- bin = GTK_BIN (container);
-
- g_return_if_fail (bin->child == NULL);
-
- bin->child = child;
- gtk_widget_set_parent (child, GTK_WIDGET (bin));
-
- gtk_widget_set_scroll_adjustments (child, NULL,
- vscrolled_bar->adjustment);
-
- if (GTK_WIDGET_REALIZED (child->parent))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child)) {
- if (GTK_WIDGET_MAPPED (child->parent))
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
-}
-
-
-static void
-e_vscrolled_bar_remove (GtkContainer *container,
- GtkWidget *child)
-{
- g_return_if_fail (container != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (container));
- g_return_if_fail (child != NULL);
- g_return_if_fail (GTK_BIN (container)->child == child);
-
- gtk_widget_set_scroll_adjustments (child, NULL, NULL);
-
- /* chain parent class handler to remove child */
- GTK_CONTAINER_CLASS (parent_class)->remove (container, child);
-}
-
-
-static void
-e_vscrolled_bar_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- g_return_if_fail (container != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (container));
- g_return_if_fail (callback != NULL);
-
- GTK_CONTAINER_CLASS (parent_class)->forall (container,
- include_internals,
- callback,
- callback_data);
- if (include_internals) {
- EVScrolledBar *vscrolled_bar;
-
- vscrolled_bar = E_VSCROLLED_BAR (container);
-
- if (vscrolled_bar->up_button)
- callback (vscrolled_bar->up_button, callback_data);
- if (vscrolled_bar->down_button)
- callback (vscrolled_bar->down_button, callback_data);
- }
-}
-
-
-/**
- * e_vscrolled_bar_get_adjustment:
- *
- * @vscrolled_bar: An #EVScrolledBar.
- * @Return: The #GtkAdjustment used for scrolling @vscrolled_bar.
- *
- * Returns the #GtkAdjustment used for scrolling the #EVscrolledBar.
- **/
-GtkAdjustment*
-e_vscrolled_bar_get_adjustment (EVScrolledBar *vscrolled_bar)
-{
- g_return_val_if_fail (vscrolled_bar != NULL, NULL);
- g_return_val_if_fail (E_IS_VSCROLLED_BAR (vscrolled_bar), NULL);
-
- return vscrolled_bar->adjustment;
-}
-
-
-/**
- * e_vscrolled_bar_set_adjustment:
- *
- * @vscrolled_bar: An #EVScrolledBar.
- * @adjustment: The #GtkAdjustment to use for scrolling @vscrolled_bar.
- *
- * Sets the #GtkAdjustment to use for scrolling the #EVscrolledBar.
- **/
-void
-e_vscrolled_bar_set_adjustment (EVScrolledBar *vscrolled_bar,
- GtkAdjustment *adjustment)
-{
- g_return_if_fail (vscrolled_bar != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (vscrolled_bar));
-
- if (adjustment)
- g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
- else
- adjustment = (GtkAdjustment*) gtk_object_new (GTK_TYPE_ADJUSTMENT, NULL);
-
- if (vscrolled_bar->adjustment == adjustment)
- return;
-
- if (vscrolled_bar->adjustment) {
- gtk_signal_disconnect_by_func (GTK_OBJECT (vscrolled_bar->adjustment),
- GTK_SIGNAL_FUNC (e_vscrolled_bar_adjustment_changed),
- vscrolled_bar);
- gtk_object_unref (GTK_OBJECT (vscrolled_bar->adjustment));
- }
-
- vscrolled_bar->adjustment = adjustment;
- gtk_object_ref (GTK_OBJECT (vscrolled_bar->adjustment));
- gtk_object_sink (GTK_OBJECT (vscrolled_bar->adjustment));
-
- /* I've used connect_after here to avoid a problem when using a
- GnomeCanvas as the child widget. When just using connect it would
- leave a blank space when one of the buttons is hidden. We want
- the GtkLayout to handle the scrolling before we hide any buttons. */
- gtk_signal_connect_after (GTK_OBJECT (adjustment), "changed",
- GTK_SIGNAL_FUNC (e_vscrolled_bar_adjustment_changed),
- vscrolled_bar);
- gtk_signal_connect_after (GTK_OBJECT (adjustment), "value_changed",
- GTK_SIGNAL_FUNC (e_vscrolled_bar_adjustment_changed),
- vscrolled_bar);
-
- e_vscrolled_bar_adjustment_changed (adjustment, vscrolled_bar);
-
- if (GTK_BIN (vscrolled_bar)->child)
- gtk_widget_set_scroll_adjustments (GTK_BIN (vscrolled_bar)->child, NULL, adjustment);
-}
-
-
-static void
-e_vscrolled_bar_adjustment_changed (GtkAdjustment *adjustment,
- gpointer data)
-{
- EVScrolledBar *vscrolled_bar;
-
- g_return_if_fail (adjustment != NULL);
- g_return_if_fail (data != NULL);
-
- vscrolled_bar = E_VSCROLLED_BAR (data);
-
- /* If the adjustment value is not 0, show the up button. */
- if (adjustment->value != 0)
- gtk_widget_show (vscrolled_bar->up_button);
- else
- gtk_widget_hide (vscrolled_bar->up_button);
-
- /* If the adjustment value is less than the maximum value, show the
- down button. */
- if (adjustment->value < adjustment->upper - adjustment->page_size)
- gtk_widget_show (vscrolled_bar->down_button);
- else
- gtk_widget_hide (vscrolled_bar->down_button);
-}
-
-
-static void
-e_vscrolled_bar_button_pressed (GtkWidget *button,
- EVScrolledBar *vscrolled_bar)
-{
- if (vscrolled_bar->timeout_id != 0)
- g_source_remove (vscrolled_bar->timeout_id);
-
- vscrolled_bar->timeout_id = g_timeout_add (E_VSCROLLED_BAR_SCROLL_TIMEOUT, e_vscrolled_bar_timeout_handler, vscrolled_bar);
- vscrolled_bar->scrolling_up = (button == vscrolled_bar->up_button) ? TRUE : FALSE;
- vscrolled_bar->min_distance = vscrolled_bar->adjustment->page_size / 4;
- vscrolled_bar->button_pressed = TRUE;
-
- e_vscrolled_bar_timeout_handler (vscrolled_bar);
-}
-
-
-static void
-e_vscrolled_bar_button_released (GtkWidget *button,
- EVScrolledBar *vscrolled_bar)
-{
- vscrolled_bar->button_pressed = FALSE;
-}
-
-
-/* This will be called when the user hits the space key to activate the button.
- It will also be called just before button_released() is called, but since
- we already handle that we simply return if the button is pressed. */
-static void
-e_vscrolled_bar_button_clicked (GtkWidget *button,
- EVScrolledBar *vscrolled_bar)
-{
- if (vscrolled_bar->button_pressed)
- return;
-
- /* We act as if the button is pressed and released immediately. */
- e_vscrolled_bar_button_pressed (button, vscrolled_bar);
- vscrolled_bar->button_pressed = FALSE;
-}
-
-
-static gboolean
-e_vscrolled_bar_timeout_handler (gpointer data)
-{
- EVScrolledBar *vscrolled_bar;
- GtkAdjustment *adjustment;
- gfloat new_value;
- gboolean retval = TRUE;
-
- vscrolled_bar = E_VSCROLLED_BAR (data);
- adjustment = vscrolled_bar->adjustment;
-
- GDK_THREADS_ENTER ();
-
- /* Check if the user has released the button and we have already
- scrolled the minimum distance. */
- if (vscrolled_bar->button_pressed == FALSE
- && vscrolled_bar->min_distance <= 0) {
- GDK_THREADS_LEAVE ();
- return FALSE;
- }
-
- vscrolled_bar->min_distance -= adjustment->step_increment;
-
- if (vscrolled_bar->scrolling_up) {
- new_value = adjustment->value - adjustment->step_increment;
- if (new_value <= adjustment->lower) {
- new_value = adjustment->lower;
- retval = FALSE;
- }
- } else {
- new_value = adjustment->value + adjustment->step_increment;
- if (new_value >= adjustment->upper - adjustment->page_size) {
- new_value = adjustment->upper - adjustment->page_size;
- retval = FALSE;
- }
- }
-
- if (adjustment->value != new_value) {
- adjustment->value = new_value;
- gtk_signal_emit_by_name (GTK_OBJECT (adjustment),
- "value_changed");
- }
-
- GDK_THREADS_LEAVE ();
- return retval;
-}
diff --git a/widgets/shortcut-bar/e-vscrolled-bar.h b/widgets/shortcut-bar/e-vscrolled-bar.h
deleted file mode 100644
index d3273e6685..0000000000
--- a/widgets/shortcut-bar/e-vscrolled-bar.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-#ifndef _E_VSCROLLED_BAR_H_
-#define _E_VSCROLLED_BAR_H_
-
-#include <gtk/gtkbin.h>
-#include <gtk/gtkadjustment.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*
- * EVScrolledBar is like GtkScrolledWindow but only scrolls the child widget
- * vertically. It is intended for scrolling narrow vertical bars.
- */
-
-
-#define E_VSCROLLED_BAR(obj) GTK_CHECK_CAST (obj, e_vscrolled_bar_get_type (), EVScrolledBar)
-#define E_VSCROLLED_BAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_vscrolled_bar_get_type (), EVScrolledBarClass)
-#define E_IS_VSCROLLED_BAR(obj) GTK_CHECK_TYPE (obj, e_vscrolled_bar_get_type ())
-
-
-typedef struct _EVScrolledBar EVScrolledBar;
-typedef struct _EVScrolledBarClass EVScrolledBarClass;
-
-struct _EVScrolledBar
-{
- GtkBin bin;
-
- GtkWidget *up_button;
- GtkWidget *down_button;
-
- GtkAdjustment *adjustment;
-
- gint up_button_width;
- gint up_button_height;
- gint down_button_width;
- gint down_button_height;
-
- /* The GTK+ event source ID of our timeout handler. */
- gint timeout_id;
-
- /* TRUE if we are scrolling up, FALSE if scrolling down. */
- gboolean scrolling_up;
-
- /* The minimum distance left to scroll. If the user just clicks a
- button we scroll a minimum amount. This is reduced after each
- scroll. */
- gfloat min_distance;
-
- /* TRUE if the button is still pressed. When the up/down button is
- released, this gets set to FALSE, and we scroll until the minimum
- distance falls below 0. */
- gboolean button_pressed;
-};
-
-struct _EVScrolledBarClass
-{
- GtkBinClass parent_class;
-};
-
-
-GtkType e_vscrolled_bar_get_type (void);
-GtkWidget* e_vscrolled_bar_new (GtkAdjustment *adjustment);
-
-GtkAdjustment* e_vscrolled_bar_get_adjustment (EVScrolledBar *vscrolled_bar);
-void e_vscrolled_bar_set_adjustment (EVScrolledBar *vscrolled_bar,
- GtkAdjustment *adjustment);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_VSCROLLED_BAR_H_ */
diff --git a/widgets/shortcut-bar/test-shortcut-bar.c b/widgets/shortcut-bar/test-shortcut-bar.c
deleted file mode 100644
index a86ec2a772..0000000000
--- a/widgets/shortcut-bar/test-shortcut-bar.c
+++ /dev/null
@@ -1,445 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@gtk.org>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * This tests the ShortcutBar widget.
- */
-
-#include <gnome.h>
-
-#include "e-shortcut-bar.h"
-
-#define NUM_SHORTCUT_TYPES 5
-gchar *shortcut_types[] = {
- "folder:", "file:", "calendar:", "todo:", "contacts:"
-};
-
-GtkWidget *main_label;
-
-static void quit (GtkWidget *window, GdkEvent *event, gpointer data);
-static void add_test_groups (EShortcutBar *shortcut_bar);
-static void add_test_group (EShortcutBar *shortcut_bar, gint i,
- gchar *group_name);
-static gint get_random_int (gint max);
-
-static void on_shortcut_bar_item_selected (EShortcutBar *shortcut_bar,
- GdkEvent *event,
- gint group_num,
- gint item_num);
-static void show_standard_popup (EShortcutBar *shortcut_bar,
- GdkEvent *event,
- gint group_num);
-static void show_context_popup (EShortcutBar *shortcut_bar,
- GdkEvent *event,
- gint group_num,
- gint item_num);
-
-static void set_large_icons (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar);
-static void set_small_icons (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar);
-static void remove_group (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar);
-
-static void rename_item (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar);
-static void remove_item (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar);
-
-int
-main (int argc, char *argv[])
-{
- GtkWidget *window, *hpaned, *shortcut_bar;
-
- gnome_init ("test-shortcut-bar", "0.1", argc, argv);
-
- gtk_widget_push_visual (gdk_rgb_get_visual ());
- gtk_widget_push_colormap (gdk_rgb_get_cmap ());
-
- window = gnome_app_new ("TestShortcutBar", "TestShortCutBar");
- gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
- gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE);
-
- gtk_signal_connect (GTK_OBJECT (window), "delete-event",
- GTK_SIGNAL_FUNC (quit), NULL);
-
- hpaned = gtk_hpaned_new ();
- gnome_app_set_contents (GNOME_APP (window), hpaned);
- gtk_widget_show (hpaned);
-
- shortcut_bar = e_shortcut_bar_new ();
- gtk_paned_pack1 (GTK_PANED (hpaned), shortcut_bar, FALSE, TRUE);
- gtk_widget_show (shortcut_bar);
-
-#if 0
- gtk_container_set_border_width (GTK_CONTAINER (shortcut_bar), 4);
-#endif
-
- gtk_paned_set_position (GTK_PANED (hpaned), 100);
- /*gtk_paned_set_gutter_size (GTK_PANED (hpaned), 12);*/
-
- main_label = gtk_label_new ("Main Application Window Goes Here");
- gtk_paned_pack2 (GTK_PANED (hpaned), main_label, TRUE, TRUE);
- gtk_widget_show (main_label);
-
-
- gtk_widget_pop_visual ();
- gtk_widget_pop_colormap ();
-
- add_test_groups (E_SHORTCUT_BAR (shortcut_bar));
-
- gtk_signal_connect (GTK_OBJECT (shortcut_bar), "item_selected",
- GTK_SIGNAL_FUNC (on_shortcut_bar_item_selected),
- NULL);
-
- gtk_widget_show (window);
- gtk_main ();
- return 0;
-}
-
-
-static void
-quit (GtkWidget *window, GdkEvent *event, gpointer data)
-{
- gtk_widget_destroy (window);
- gtk_exit (0);
-}
-
-
-static void
-add_test_groups (EShortcutBar *shortcut_bar)
-{
- add_test_group (shortcut_bar, 1, "Shortcuts");
- add_test_group (shortcut_bar, 2, "My Shortcuts");
- add_test_group (shortcut_bar, 3, "Longer Shortcuts");
- add_test_group (shortcut_bar, 4, "Very Long Shortcuts");
- add_test_group (shortcut_bar, 5, "Incredibly Long Shortcuts");
-}
-
-
-static void
-add_test_group (EShortcutBar *shortcut_bar, gint i, gchar *group_name)
-{
- gint group_num, item_num, num_items;
- gchar buffer[128];
- gint shortcut_type, j;
-
- group_num = e_shortcut_bar_add_group (E_SHORTCUT_BAR (shortcut_bar),
- group_name);
-
- if (group_num % 2)
- e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (shortcut_bar),
- group_num,
- E_ICON_BAR_SMALL_ICONS);
-
- num_items = get_random_int (5) + 3;
- for (j = 1; j <= num_items; j++) {
- if (j == 1)
- sprintf (buffer, "A very long shortcut with proper words so I can test the wrapping and ellipsis behaviour");
- else if (j == 2)
- sprintf (buffer, "A very long shortcut with averylongworkinthemiddlesoIcantestthewrappingandellipsisbehaviour");
- else
- sprintf (buffer, "Item %i:%i\n", i, j);
-
- shortcut_type = get_random_int (NUM_SHORTCUT_TYPES);
- item_num = e_shortcut_bar_add_item (E_SHORTCUT_BAR (shortcut_bar), group_num, shortcut_types[shortcut_type], buffer);
- }
-}
-
-
-/* Returns a random integer between 0 and max - 1. */
-static gint
-get_random_int (gint max)
-{
- gint random_num;
-
- random_num = (int) (max * (rand () / (RAND_MAX + 1.0)));
-#if 0
- g_print ("Random num (%i): %i\n", max, random_num);
-#endif
- return random_num;
-}
-
-
-static void
-on_shortcut_bar_item_selected (EShortcutBar *shortcut_bar,
- GdkEvent *event, gint group_num, gint item_num)
-{
- gchar buffer[256];
-
- if (event->button.button == 1) {
- sprintf (buffer, "Item Selected - %i:%i",
- group_num + 1, item_num + 1);
- gtk_label_set_text (GTK_LABEL (main_label), buffer);
- } else if (event->button.button == 3) {
- if (item_num == -1)
- show_standard_popup (shortcut_bar, event, group_num);
- else
- show_context_popup (shortcut_bar, event, group_num,
- item_num);
- }
-}
-
-
-static void
-show_standard_popup (EShortcutBar *shortcut_bar,
- GdkEvent *event,
- gint group_num)
-{
- GtkWidget *menu, *menuitem;
-
- /* We don't have any commands if there aren't any groups yet. */
- if (group_num == -1)
- return;
-
- menu = gtk_menu_new ();
-
- menuitem = gtk_menu_item_new_with_label ("Large Icons");
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (set_large_icons), shortcut_bar);
-
- menuitem = gtk_menu_item_new_with_label ("Small Icons");
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (set_small_icons), shortcut_bar);
-
- menuitem = gtk_menu_item_new ();
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("Add New Group");
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("Remove Group");
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (remove_group), shortcut_bar);
-
- menuitem = gtk_menu_item_new_with_label ("Rename Group");
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new ();
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("Add Shortcut...");
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new ();
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("Hide Shortcut Bar");
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- /* Save the group num so we can get it in the callbacks. */
- gtk_object_set_data (GTK_OBJECT (menu), "group_num",
- GINT_TO_POINTER (group_num));
-
- /* FIXME: Destroy menu when finished with it somehow? */
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
- event->button.button, event->button.time);
-}
-
-
-static void
-set_large_icons (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar)
-{
- GtkWidget *menu;
- gint group_num;
-
- menu = menuitem->parent;
- g_return_if_fail (GTK_IS_MENU (menu));
-
- group_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "group_num"));
-
- e_shortcut_bar_set_view_type (shortcut_bar, group_num,
- E_ICON_BAR_LARGE_ICONS);
-}
-
-
-static void
-set_small_icons (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar)
-{
- GtkWidget *menu;
- gint group_num;
-
- menu = menuitem->parent;
- g_return_if_fail (GTK_IS_MENU (menu));
-
- group_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "group_num"));
-
- e_shortcut_bar_set_view_type (shortcut_bar, group_num,
- E_ICON_BAR_SMALL_ICONS);
-}
-
-
-static void
-remove_group (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar)
-{
- GtkWidget *menu;
- gint group_num;
-
- menu = menuitem->parent;
- g_return_if_fail (GTK_IS_MENU (menu));
-
- group_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "group_num"));
-
- e_shortcut_bar_remove_group (shortcut_bar, group_num);
-}
-
-
-static void
-show_context_popup (EShortcutBar *shortcut_bar,
- GdkEvent *event,
- gint group_num,
- gint item_num)
-{
- GtkWidget *menu, *menuitem, *label, *pixmap;
-
- menu = gtk_menu_new ();
-
- menuitem = gtk_pixmap_menu_item_new ();
- label = gtk_label_new ("Open Folder");
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_container_add (GTK_CONTAINER (menuitem), label);
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
- pixmap = gnome_stock_pixmap_widget (menu, GNOME_STOCK_MENU_OPEN);
- if (pixmap) {
- gtk_widget_show(pixmap);
- gtk_pixmap_menu_item_set_pixmap (GTK_PIXMAP_MENU_ITEM (menuitem), pixmap);
- }
-
- menuitem = gtk_menu_item_new_with_label ("Open in New Window");
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("Advanced Find");
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new ();
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("Remove from Shortcut Bar");
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (remove_item), shortcut_bar);
-
- menuitem = gtk_menu_item_new_with_label ("Rename Shortcut");
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (rename_item), shortcut_bar);
-
- menuitem = gtk_menu_item_new ();
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("Properties");
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
-
- /* Save the group & item nums so we can get them in the callbacks. */
- gtk_object_set_data (GTK_OBJECT (menu), "group_num",
- GINT_TO_POINTER (group_num));
- gtk_object_set_data (GTK_OBJECT (menu), "item_num",
- GINT_TO_POINTER (item_num));
-
- /* FIXME: Destroy menu when finished with it somehow? */
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
- event->button.button, event->button.time);
-}
-
-
-static void
-rename_item (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar)
-{
- GtkWidget *menu;
- gint group_num, item_num;
-
- menu = menuitem->parent;
- g_return_if_fail (GTK_IS_MENU (menu));
-
- group_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "group_num"));
- item_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "item_num"));
-
- e_shortcut_bar_start_editing_item (shortcut_bar, group_num, item_num);
-}
-
-
-static void
-remove_item (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar)
-{
- GtkWidget *menu;
- gint group_num, item_num;
-
- menu = menuitem->parent;
- g_return_if_fail (GTK_IS_MENU (menu));
-
- group_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "group_num"));
- item_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "item_num"));
-
- e_shortcut_bar_remove_item (shortcut_bar, group_num, item_num);
-}
-
-
diff --git a/widgets/table/.cvsignore b/widgets/table/.cvsignore
deleted file mode 100644
index 0963d457d9..0000000000
--- a/widgets/table/.cvsignore
+++ /dev/null
@@ -1,7 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-*.lo
-*.la
-table-test
diff --git a/widgets/table/add-col.xpm b/widgets/table/add-col.xpm
deleted file mode 100644
index 9c5f314c8e..0000000000
--- a/widgets/table/add-col.xpm
+++ /dev/null
@@ -1,22 +0,0 @@
-/* XPM */
-static char * add_col_xpm[] = {
-"16 16 3 1",
-" c None",
-". c #000000",
-"+ c #FFFFFF",
-" ",
-" ",
-" ",
-" ",
-" .............. ",
-" .++++++++++++. ",
-" .++++++++++++. ",
-" ....+++....... ",
-" .+. ",
-" . ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" "};
diff --git a/widgets/table/check-empty.xpm b/widgets/table/check-empty.xpm
deleted file mode 100644
index 2dd873e137..0000000000
--- a/widgets/table/check-empty.xpm
+++ /dev/null
@@ -1,21 +0,0 @@
-/* XPM */
-static char * check_empty_xpm[] = {
-"16 16 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" ............ ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" ............ ",
-" ",
-" "};
diff --git a/widgets/table/check-filled.xpm b/widgets/table/check-filled.xpm
deleted file mode 100644
index 689d7a7967..0000000000
--- a/widgets/table/check-filled.xpm
+++ /dev/null
@@ -1,21 +0,0 @@
-/* XPM */
-static char * check_filled_xpm[] = {
-"16 16 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" ............ ",
-" . . ",
-" . . . ",
-" . .. . ",
-" . ... . ",
-" . . ... . ",
-" . .. ... . ",
-" . ..... . ",
-" . ... . ",
-" . . . ",
-" . . ",
-" ............ ",
-" ",
-" "};
diff --git a/widgets/table/e-cell-checkbox.c b/widgets/table/e-cell-checkbox.c
deleted file mode 100644
index 431c1663d1..0000000000
--- a/widgets/table/e-cell-checkbox.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * e-cell-checkbox.c: Checkbox cell renderer
- *
- * Author:
- * Miguel de Icaza (miguel@kernel.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include <gtk/gtkenums.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtksignal.h>
-#include <gdk/gdkkeysyms.h>
-#include <libgnomeui/gnome-canvas.h>
-#include "e-cell-checkbox.h"
-#include "e-util/e-util.h"
-#include "e-table-item.h"
-
-#include "check-empty.xpm"
-#include "check-filled.xpm"
-
-#define PARENT_TYPE e_cell_toggle_get_type()
-
-static GdkPixbuf *checks [2];
-
-static void
-e_cell_checkbox_class_init (GtkObjectClass *object_class)
-{
- checks [0] = gdk_pixbuf_new_from_xpm_data (check_empty_xpm);
- checks [1] = gdk_pixbuf_new_from_xpm_data (check_filled_xpm);
-}
-
-E_MAKE_TYPE(e_cell_checkbox, "ECellCheckbox", ECellCheckbox, e_cell_checkbox_class_init, NULL, PARENT_TYPE);
-
-ECell *
-e_cell_checkbox_new (void)
-{
- ECellCheckbox *eccb = gtk_type_new (e_cell_checkbox_get_type ());
-
- e_cell_toggle_construct (E_CELL_TOGGLE (eccb), 2, 2, checks);
-
- return (ECell *) eccb;
-}
diff --git a/widgets/table/e-cell-checkbox.h b/widgets/table/e-cell-checkbox.h
deleted file mode 100644
index 969e4a5edc..0000000000
--- a/widgets/table/e-cell-checkbox.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _E_CELL_CHECKBOX_H_
-#define _E_CELL_CHECKBOX_H_
-
-#include "e-cell-toggle.h"
-
-#define E_CELL_CHECKBOX_TYPE (e_cell_checkbox_get_type ())
-#define E_CELL_CHECKBOX(o) (GTK_CHECK_CAST ((o), E_CELL_CHECKBOX_TYPE, ECellCheckbox))
-#define E_CELL_CHECKBOX_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_CHECKBOX_TYPE, ECellCheckboxClass))
-#define E_IS_CELL_CHECKBOX(o) (GTK_CHECK_TYPE ((o), E_CELL_CHECKBOX_TYPE))
-#define E_IS_CELL_CHECKBOX_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_CHECKBOX_TYPE))
-
-typedef struct {
- ECellToggle parent;
-} ECellCheckbox;
-
-typedef struct {
- ECellToggleClass parent_class;
-} ECellCheckboxClass;
-
-GtkType e_cell_checkbox_get_type (void);
-ECell *e_cell_checkbox_new (void);
-
-#endif /* _E_CELL_CHECKBOX_H_ */
-
diff --git a/widgets/table/e-cell-string.c b/widgets/table/e-cell-string.c
deleted file mode 100644
index 992b1bd10e..0000000000
--- a/widgets/table/e-cell-string.c
+++ /dev/null
@@ -1,9 +0,0 @@
-ECell *
-e_cell_string_new (void)
-{
- ECell *ecell;
-
- ecell = gtk_type_new (ecell);
-
- return ecell;
-}
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
deleted file mode 100644
index fead3d4654..0000000000
--- a/widgets/table/e-cell-text.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * e-cell-text.c: Text cell renderer
- *
- * Author:
- * Miguel de Icaza (miguel@kernel.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include <gtk/gtkenums.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtksignal.h>
-#include <gdk/gdkkeysyms.h>
-#include <libgnomeui/gnome-canvas.h>
-#include <stdio.h>
-#include "e-cell-text.h"
-#include "e-util/e-util.h"
-#include "e-table-item.h"
-
-#define PARENT_TYPE e_cell_get_type()
-
-#define TEXT_PAD 2
-
-typedef struct {
- char *old_text;
- GtkWidget *entry_top;
- GtkEntry *entry;
-
- /*
- * Where the editing is taking place
- */
- int model_col, view_col, row;
-} CellEdit;
-
-typedef struct {
- ECellView cell_view;
- GdkGC *gc;
- GdkFont *font;
- GnomeCanvas *canvas;
-
- /*
- * During edition.
- */
- CellEdit *edit;
-} ECellTextView;
-
-static ECellClass *parent_class;
-
-static void
-ect_queue_redraw (ECellTextView *text_view, int view_col, int view_row)
-{
- e_table_item_redraw_range (
- text_view->cell_view.e_table_item_view,
- view_col, view_row, view_col, view_row);
-}
-
-/*
- * Accept the currently edited text
- */
-static void
-ect_accept_edits (ECellTextView *text_view)
-{
- const char *text = gtk_entry_get_text (text_view->edit->entry);
- CellEdit *edit = text_view->edit;
-
- e_table_model_set_value_at (text_view->cell_view.e_table_model, edit->model_col, edit->row, text);
-}
-
-/*
- * Shuts down the editing process
- */
-static void
-ect_stop_editing (ECellTextView *text_view)
-{
- CellEdit *edit = text_view->edit;
-
- g_free (edit->old_text);
- edit->old_text = NULL;
- gtk_widget_destroy (edit->entry_top);
- edit->entry_top = NULL;
- edit->entry = NULL;
-
- g_free (edit);
-
- text_view->edit = NULL;
-
- e_table_item_leave_edit (text_view->cell_view.e_table_item_view);
-}
-
-/*
- * Cancels the edits
- */
-static void
-ect_cancel_edit (ECellTextView *text_view)
-{
- ect_queue_redraw (text_view, text_view->edit->view_col, text_view->edit->row);
- ect_stop_editing (text_view);
-}
-
-/*
- * ECell::new_view method
- */
-static ECellView *
-ect_new_view (ECell *ecell, ETableModel *table_model, void *e_table_item_view)
-{
- ECellText *ect = E_CELL_TEXT (ecell);
- ECellTextView *text_view = g_new0 (ECellTextView, 1);
- GnomeCanvas *canvas = GNOME_CANVAS_ITEM (e_table_item_view)->canvas;
-
- text_view->cell_view.ecell = ecell;
- text_view->cell_view.e_table_model = table_model;
- text_view->cell_view.e_table_item_view = e_table_item_view;
-
- if (ect->font_name){
- GdkFont *f;
-
- f = gdk_fontset_load (ect->font_name);
- text_view->font = f;
- }
- if (!text_view->font){
- text_view->font = GTK_WIDGET (canvas)->style->font;
-
- gdk_font_ref (text_view->font);
- }
-
- text_view->canvas = canvas;
-
- return (ECellView *)text_view;
-}
-
-/*
- * ECell::kill_view method
- */
-static void
-ect_kill_view (ECellView *ecv)
-{
- ECellTextView *text_view = (ECellTextView *) ecv;
-
- gdk_font_unref (text_view->font);
- text_view->font = NULL;
-
- g_free (text_view);
-}
-
-/*
- * ECell::realize method
- */
-static void
-ect_realize (ECellView *ecell_view)
-{
- ECellTextView *text_view = (ECellTextView *) ecell_view;
-
- text_view->gc = gdk_gc_new (GTK_WIDGET (text_view->canvas)->window);
-}
-
-/*
- * ECell::unrealize method
- */
-static void
-ect_unrealize (ECellView *ecv)
-{
- ECellTextView *text_view = (ECellTextView *) ecv;
-
- gdk_gc_unref (text_view->gc);
- text_view->gc = NULL;
-}
-
-/*
- * ECell::draw method
- */
-static void
-ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
- int x1, int y1, int x2, int y2)
-{
- ECellText *ect = E_CELL_TEXT (ecell_view->ecell);
- ECellTextView *text_view = (ECellTextView *) ecell_view;
- GtkWidget *w = GTK_WIDGET (text_view->canvas);
- GdkRectangle rect;
- const char *str = e_table_model_value_at (ecell_view->e_table_model, model_col, row);
- GdkFont *font = text_view->font;
- const int height = font->ascent + font->descent;
- int xoff;
- gboolean edit_display = FALSE;
-
- /*
- * Figure if this cell is being edited
- */
- if (text_view->edit){
- CellEdit *edit = text_view->edit;
-
- if ((edit->view_col == view_col) && (edit->row == row))
- edit_display = TRUE;
- }
-
- /*
- * Be a nice citizen: clip to the region we are supposed to draw on
- */
- rect.x = x1;
- rect.y = y1;
- rect.width = x2 - x1;
- rect.height = y2 - y1;
- gdk_gc_set_clip_rectangle (text_view->gc, &rect);
-
- if (edit_display){
- CellEdit *edit = text_view->edit;
- const char *text = gtk_entry_get_text (edit->entry);
- GdkWChar *p, *text_wc = g_new (GdkWChar, strlen (text) + 1);
- int text_wc_len = gdk_mbstowcs (text_wc, text, strlen (text));
- const int cursor_pos = GTK_EDITABLE (edit->entry)->current_pos;
- const int left_len = gdk_text_width_wc (text_view->font, text_wc, cursor_pos);
-
- text_wc [text_wc_len] = 0;
- /*
- * Paint
- */
- gdk_gc_set_foreground (text_view->gc, &w->style->base [GTK_STATE_NORMAL]);
- gdk_draw_rectangle (drawable, text_view->gc, TRUE,
- rect.x, rect.y, rect.width, rect.height);
- gdk_gc_set_foreground (text_view->gc, &w->style->text [GTK_STATE_NORMAL]);
-
- {
- GdkGC *gc = text_view->gc;
- const int y = y2 - font->descent - ((y2-y1-height)/2);
- int px, i;
-
- /*
- * Border
- */
- x1 += 2;
- x2--;
-
- px = x1;
-
- /*
- * If the cursor is outside the visible range
- *
- * FIXME: we really want a better behaviour.
- */
- if ((px + left_len) > x2)
- px -= left_len - (x2-x1);
-
- /*
- * Draw
- */
- for (i = 0, p = text_wc; *p; p++, i++){
- gdk_draw_text_wc (
- drawable, font, gc, px, y, p, 1);
-
- if (i == cursor_pos){
- gdk_draw_line (
- drawable, gc,
- px, y - font->ascent,
- px, y + font->descent - 1);
- }
-
- px += gdk_text_width_wc (font, p, 1);
- }
-
- if (i == cursor_pos){
- gdk_draw_line (
- drawable, gc,
- px, y - font->ascent,
- px, y + font->descent - 1);
- }
- }
- g_free (text_wc);
- } else {
- /*
- * Regular cell
- */
- GdkColor *background, *foreground;
- int width;
-
- /*
- * Border
- */
- x1++;
- x2--;
-
- /*
- * Compute draw mode
- */
- switch (ect->justify){
- case GTK_JUSTIFY_LEFT:
- xoff = 1;
- break;
-
- case GTK_JUSTIFY_RIGHT:
- width = 1 + gdk_text_width (font, str, strlen (str));
- xoff = (x2 - x1) - width;
- break;
-
- case GTK_JUSTIFY_CENTER:
- xoff = ((x2 - x1) - gdk_text_width (font, str, strlen (str))) / 2;
- break;
- default:
- xoff = 0;
- g_warning ("Can not handle GTK_JUSTIFY_FILL");
- break;
- }
-
-
- if (selected){
- background = &w->style->bg [GTK_STATE_SELECTED];
- foreground = &w->style->text [GTK_STATE_SELECTED];
- } else {
- background = &w->style->base [GTK_STATE_NORMAL];
- foreground = &w->style->text [GTK_STATE_NORMAL];
- }
-
- gdk_gc_set_foreground (text_view->gc, background);
- gdk_draw_rectangle (drawable, text_view->gc, TRUE,
- rect.x, rect.y, rect.width, rect.height);
- gdk_gc_set_foreground (text_view->gc, foreground);
-
- gdk_draw_string (
- drawable, font, text_view->gc,
- x1 + xoff,
- y2 - font->descent - ((y2-y1-height)/2), str);
- }
-}
-
-/*
- * Selects the entire string
- */
-static void
-ect_edit_select_all (ECellTextView *text_view)
-{
- g_assert (text_view->edit);
-
- gtk_editable_select_region (GTK_EDITABLE (text_view->edit->entry), 0, -1);
-}
-
-/*
- * ECell::event method
- */
-static gint
-ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row)
-{
- ECellTextView *text_view = (ECellTextView *) ecell_view;
-
- switch (event->type){
- case GDK_BUTTON_PRESS:
- /*
- * Adjust for the border we use
- */
- event->button.x++;
-
- printf ("Button pressed at %g %g\n", event->button.x, event->button.y);
- if (text_view->edit){
- printf ("FIXME: Should handle click here\n");
- } else
- e_table_item_enter_edit (text_view->cell_view.e_table_item_view, view_col, row);
- break;
-
- case GDK_BUTTON_RELEASE:
- /*
- * Adjust for the border we use
- */
- event->button.x++;
- printf ("Button released at %g %g\n", event->button.x, event->button.y);
- return TRUE;
-
- case GDK_KEY_PRESS:
- if (event->key.keyval == GDK_Escape){
- ect_cancel_edit (text_view);
- return TRUE;
- }
-
- if (!text_view->edit){
- e_table_item_enter_edit (text_view->cell_view.e_table_item_view, view_col, row);
- ect_edit_select_all (text_view);
- }
-
- gtk_widget_event (GTK_WIDGET (text_view->edit->entry), event);
- ect_queue_redraw (text_view, view_col, row);
- break;
-
- case GDK_KEY_RELEASE:
- break;
-
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-/*
- * ECell::height method
- */
-static int
-ect_height (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- ECellTextView *text_view = (ECellTextView *) ecell_view;
-
- return (text_view->font->ascent + text_view->font->descent) + TEXT_PAD;
-}
-
-/*
- * Callback: invoked when the user pressed "enter" on the GtkEntry
- */
-static void
-ect_entry_activate (GtkEntry *entry, ECellTextView *text_view)
-{
- e_table_item_leave_edit (text_view->cell_view.e_table_item_view);
-}
-
-/*
- * ECellView::enter_edit method
- */
-static void *
-ect_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- ECellTextView *text_view = (ECellTextView *) ecell_view;
- const char *str = e_table_model_value_at (ecell_view->e_table_model, model_col, row);
- CellEdit *edit;
-
- edit = g_new (CellEdit, 1);
- text_view->edit = edit;
-
- edit->model_col = model_col;
- edit->view_col = view_col;
- edit->row = row;
-
- edit->entry = (GtkEntry *) gtk_entry_new ();
- gtk_entry_set_text (edit->entry, str);
- edit->old_text = g_strdup (str);
- gtk_signal_connect (GTK_OBJECT (edit->entry), "activate",
- GTK_SIGNAL_FUNC (ect_entry_activate), text_view);
-
- /*
- * The hack: create this window off-screen
- */
- edit->entry_top = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_container_add (GTK_CONTAINER (edit->entry_top), GTK_WIDGET (edit->entry));
- gtk_widget_set_uposition (edit->entry_top, 20000, 20000);
- gtk_widget_show_all (edit->entry_top);
-
- ect_queue_redraw (text_view, view_col, row);
-
- return NULL;
-}
-
-/*
- * ECellView::leave_edit method
- */
-static void
-ect_leave_edit (ECellView *ecell_view, int model_col, int view_col, int row, void *edit_context)
-{
- ECellTextView *text_view = (ECellTextView *) ecell_view;
-
- if (text_view->edit){
- ect_accept_edits (text_view);
- ect_stop_editing (text_view);
- } else {
- /*
- * We did invoke this leave edit internally
- */
- }
-}
-
-/*
- * GtkObject::destroy method
- */
-static void
-ect_destroy (GtkObject *object)
-{
- ECellText *ect = E_CELL_TEXT (object);
-
- g_free (ect->font_name);
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
-e_cell_text_class_init (GtkObjectClass *object_class)
-{
- ECellClass *ecc = (ECellClass *) object_class;
-
- object_class->destroy = ect_destroy;
-
- ecc->new_view = ect_new_view;
- ecc->kill_view = ect_kill_view;
- ecc->realize = ect_realize;
- ecc->unrealize = ect_unrealize;
- ecc->draw = ect_draw;
- ecc->event = ect_event;
- ecc->height = ect_height;
- ecc->enter_edit = ect_enter_edit;
- ecc->leave_edit = ect_leave_edit;
-
- parent_class = gtk_type_class (PARENT_TYPE);
-}
-
-E_MAKE_TYPE(e_cell_text, "ECellText", ECellText, e_cell_text_class_init, NULL, PARENT_TYPE);
-
-ECell *
-e_cell_text_new (ETableModel *etm, const char *fontname, GtkJustification justify)
-{
- ECellText *ect = gtk_type_new (e_cell_text_get_type ());
-
- ect->font_name = g_strdup (fontname);
- ect->justify = justify;
-
- return (ECell *) ect;
-}
diff --git a/widgets/table/e-cell-text.h b/widgets/table/e-cell-text.h
deleted file mode 100644
index de9629b97b..0000000000
--- a/widgets/table/e-cell-text.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef _E_CELL_TEXT_H_
-#define _E_CELL_TEXT_H_
-
-#include <libgnomeui/gnome-canvas.h>
-#include "e-cell.h"
-
-#define E_CELL_TEXT_TYPE (e_cell_text_get_type ())
-#define E_CELL_TEXT(o) (GTK_CHECK_CAST ((o), E_CELL_TEXT_TYPE, ECellText))
-#define E_CELL_TEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TEXT_TYPE, ECellTextClass))
-#define E_IS_CELL_TEXT(o) (GTK_CHECK_TYPE ((o), E_CELL_TEXT_TYPE))
-#define E_IS_CELL_TEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TEXT_TYPE))
-
-typedef struct {
- ECell parent;
-
- GtkJustification justify;
- char *font_name;
-} ECellText;
-
-typedef struct {
- ECellClass parent_class;
-} ECellTextClass;
-
-GtkType e_cell_text_get_type (void);
-ECell *e_cell_text_new (ETableModel *model, const char *fontname, GtkJustification justify);
-
-#endif /* _E_CELL_TEXT_H_ */
-
diff --git a/widgets/table/e-cell-toggle.c b/widgets/table/e-cell-toggle.c
deleted file mode 100644
index 679d04a0ca..0000000000
--- a/widgets/table/e-cell-toggle.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * e-cell-toggle.c: Multi-state image toggle cell object.
- *
- * Author:
- * Miguel de Icaza (miguel@kernel.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include <gtk/gtkenums.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtksignal.h>
-#include <gdk/gdkkeysyms.h>
-#include <libgnomeui/gnome-canvas.h>
-#include "e-cell-toggle.h"
-#include "e-util/e-util.h"
-#include "e-table-item.h"
-
-#define PARENT_TYPE e_cell_get_type()
-
-typedef struct {
- ECellView cell_view;
- GdkGC *gc;
- GnomeCanvas *canvas;
-} ECellToggleView;
-
-static ECellClass *parent_class;
-
-static void
-etog_queue_redraw (ECellToggleView *text_view, int view_col, int view_row)
-{
- e_table_item_redraw_range (
- text_view->cell_view.e_table_item_view,
- view_col, view_row, view_col, view_row);
-}
-
-/*
- * ECell::realize method
- */
-static ECellView *
-etog_new_view (ECell *ecell, ETableModel *table_model, void *e_table_item_view)
-{
- ECellToggleView *toggle_view = g_new0 (ECellToggleView, 1);
- ETableItem *eti = E_TABLE_ITEM (e_table_item_view);
- GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas;
-
- toggle_view->cell_view.ecell = ecell;
- toggle_view->cell_view.e_table_model = table_model;
- toggle_view->cell_view.e_table_item_view = e_table_item_view;
- toggle_view->canvas = canvas;
-
- return (ECellView *) toggle_view;
-}
-
-static void
-etog_kill_view (ECellView *ecell_view)
-{
- g_free (ecell_view);
-}
-
-static void
-etog_realize (ECellView *ecell_view)
-{
- ECellToggleView *toggle_view = (ECellToggleView *) ecell_view;
-
- toggle_view->gc = gdk_gc_new (GTK_WIDGET (toggle_view->canvas)->window);
-}
-
-/*
- * ECell::unrealize method
- */
-static void
-etog_unrealize (ECellView *ecv)
-{
- ECellToggleView *toggle_view = (ECellToggleView *) ecv;
-
- gdk_gc_unref (toggle_view->gc);
- toggle_view->gc = NULL;
-}
-
-/*
- * ECell::draw method
- */
-static void
-etog_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
- int x1, int y1, int x2, int y2)
-{
- ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell);
- ECellToggleView *toggle_view = (ECellToggleView *) ecell_view;
- GdkPixbuf *image;
- ArtPixBuf *art;
- int x, y, width, height;
- const int value = GPOINTER_TO_INT (
- e_table_model_value_at (ecell_view->e_table_model, model_col, row));
-
- if (value >= toggle->n_states){
- g_warning ("Value from the table model is %d, the states we support are [0..%d)\n",
- value, toggle->n_states);
- return;
- }
-
- /*
- * Paint the background
- */
- gdk_draw_rectangle (drawable, GTK_WIDGET (toggle_view->canvas)->style->white_gc, TRUE, x1, y1, x2 - x1, y2 - y1);
-
- image = toggle->images [value];
- art = image->art_pixbuf;
-
- if ((x2 - x1) < art->width){
- x = x1;
- width = x2 - x1;
- } else {
- x = x1 + ((x2 - x1) - art->width) / 2;
- width = art->width;
- }
-
- if ((y2 - y1) < art->height){
- y = y1;
- height = y2 - y1;
- } else {
- y = y1 + ((y2 - y1) - art->height) / 2;
- height = art->height;
- }
-
- width = y2 - y1;
-
- if (image->art_pixbuf->has_alpha){
- GdkColor background;
- guchar *buffer;
- int alpha, ix, iy;
-
- buffer = g_malloc (art->rowstride * art->height * 3);
-
- background.red = 255;
- background.green = 255;
- background.blue = 255;
-
- for (iy = 0; iy < art->height; iy++){
- unsigned char *dest;
- unsigned char *src;
-
- dest = buffer + (iy * art->rowstride);
- src = art->pixels + (iy * art->rowstride);
-
- for (ix = 0; ix < art->width; ix++){
- alpha = src [3];
- if (alpha == 0){
- *dest++ = background.red;
- *dest++ = background.green;
- *dest++ = background.blue;
- src += 3;
- } else if (alpha == 255){
- *dest++ = *src++;
- *dest++ = *src++;
- *dest++ = *src++;
- } else {
- *dest++ = (background.red + ((*src++ - background.red) * alpha + 0x80)) >> 8;
- *dest++ = (background.green + ((*src++ - background.green) * alpha + 0x80)) >> 8;
- *dest++ = (background.blue + ((*src++ - background.blue) * alpha + 0x80)) >> 8;
- }
- src++;
- }
- }
-
- gdk_draw_rgb_image_dithalign (
- drawable, toggle_view->gc, x, y, width, height,
- GDK_RGB_DITHER_NORMAL, buffer, art->rowstride, 0, 0);
-
- g_free (buffer);
- } else
- gdk_draw_rgb_image_dithalign (
- drawable, toggle_view->gc, x, y, width, height,
- GDK_RGB_DITHER_NORMAL, art->pixels, art->rowstride, 0, 0);
-}
-
-static void
-etog_set_value (ECellToggleView *toggle_view, int model_col, int view_col, int row, int value)
-{
- ECell *ecell = toggle_view->cell_view.ecell;
- ECellToggle *toggle = E_CELL_TOGGLE (ecell);
-
- if (value >= toggle->n_states)
- value = 0;
-
- e_table_model_set_value_at (toggle_view->cell_view.e_table_model,
- model_col, row, GINT_TO_POINTER (value));
- etog_queue_redraw (toggle_view, view_col, row);
-}
-
-/*
- * ECell::event method
- */
-static gint
-etog_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row)
-{
- ECellToggleView *toggle_view = (ECellToggleView *) ecell_view;
- void *_value = e_table_model_value_at (ecell_view->e_table_model, model_col, row);
- const int value = GPOINTER_TO_INT (_value);
-
- switch (event->type){
- case GDK_BUTTON_RELEASE:
- etog_set_value (toggle_view, model_col, view_col, row, value + 1);
- return TRUE;
-
- case GDK_KEY_PRESS:
- if (event->key.keyval == GDK_space){
- etog_set_value (toggle_view, model_col, view_col, row, value + 1);
- return TRUE;
- }
- return FALSE;
-
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-/*
- * ECell::height method
- */
-static int
-etog_height (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell);
-
- return toggle->height;
-}
-
-static void
-etog_destroy (GtkObject *object)
-{
- ECellToggle *etog = E_CELL_TOGGLE (object);
- int i;
-
- for (i = 0; i < etog->n_states; i++)
- gdk_pixbuf_unref (etog->images [i]);
-
- g_free (etog->images);
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
-e_cell_toggle_class_init (GtkObjectClass *object_class)
-{
- ECellClass *ecc = (ECellClass *) object_class;
-
- object_class->destroy = etog_destroy;
-
- ecc->new_view = etog_new_view;
- ecc->kill_view = etog_kill_view;
- ecc->realize = etog_realize;
- ecc->unrealize = etog_unrealize;
- ecc->draw = etog_draw;
- ecc->event = etog_event;
- ecc->height = etog_height;
-
- parent_class = gtk_type_class (PARENT_TYPE);
-}
-
-E_MAKE_TYPE(e_cell_toggle, "ECellToggle", ECellToggle, e_cell_toggle_class_init, NULL, PARENT_TYPE);
-
-void
-e_cell_toggle_construct (ECellToggle *etog, int border, int n_states, GdkPixbuf **images)
-{
- int max_height = 0;
- int i;
-
- etog->border = border;
- etog->n_states = n_states;
-
- etog->images = g_new (GdkPixbuf *, n_states);
-
- for (i = 0; i < n_states; i++){
- etog->images [i] = images [i];
- gdk_pixbuf_ref (images [i]);
-
- if (images [i]->art_pixbuf->height > max_height)
- max_height = images [i]->art_pixbuf->height;
- }
-
- etog->height = max_height;
-}
-
-ECell *
-e_cell_toggle_new (int border, int n_states, GdkPixbuf **images)
-{
- ECellToggle *etog = gtk_type_new (e_cell_toggle_get_type ());
-
- e_cell_toggle_construct (etog, border, n_states, images);
-
- return (ECell *) etog;
-}
-
-
diff --git a/widgets/table/e-cell-toggle.h b/widgets/table/e-cell-toggle.h
deleted file mode 100644
index d5773b454a..0000000000
--- a/widgets/table/e-cell-toggle.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef _E_CELL_TOGGLE_H_
-#define _E_CELL_TOGGLE_H_
-
-#include <libgnomeui/gnome-canvas.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include "e-cell.h"
-
-#define E_CELL_TOGGLE_TYPE (e_cell_toggle_get_type ())
-#define E_CELL_TOGGLE(o) (GTK_CHECK_CAST ((o), E_CELL_TOGGLE_TYPE, ECellToggle))
-#define E_CELL_TOGGLE_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TOGGLE_TYPE, ECellToggleClass))
-#define E_IS_CELL_TOGGLE(o) (GTK_CHECK_TYPE ((o), E_CELL_TOGGLE_TYPE))
-#define E_IS_CELL_TOGGLE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TOGGLE_TYPE))
-
-typedef struct {
- ECell parent;
-
- int border;
- int n_states;
- GdkPixbuf **images;
-
- int height;
-} ECellToggle;
-
-typedef struct {
- ECellClass parent_class;
-} ECellToggleClass;
-
-GtkType e_cell_toggle_get_type (void);
-ECell *e_cell_toggle_new (int border, int n_states, GdkPixbuf **images);
-void e_cell_toggle_construct (ECellToggle *etog, int border,
- int n_states, GdkPixbuf **images);
-
-#endif /* _E_CELL_TOGGLE_H_ */
-
-
diff --git a/widgets/table/e-cell.c b/widgets/table/e-cell.c
deleted file mode 100644
index f1345e8c6b..0000000000
--- a/widgets/table/e-cell.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * e-cell.c: base class for cell renderers in e-table
- *
- * Author:
- * Miguel de Icaza (miguel@kernel.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include "e-cell.h"
-#include "e-util/e-util.h"
-
-#define PARENT_TYPE gtk_object_get_type()
-
-static ECellView *
-ec_new_view (ECell *ecell, ETableModel *table_model, void *e_table_item_view)
-{
- return NULL;
-}
-
-static void
-ec_realize (ECellView *e_cell)
-{
-}
-
-static void
-ec_kill_view (ECellView *ecell_view)
-{
-}
-
-static void
-ec_unrealize (ECellView *e_cell)
-{
-}
-
-static void
-ec_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
- int x1, int y1, int x2, int y2)
-{
- g_error ("e-cell-draw invoked\n");
-}
-
-static gint
-ec_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row)
-{
- g_error ("e-cell-event invoked\n");
- return 0;
-}
-
-static gint
-ec_height (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- g_error ("e-cell-event invoked\n");
- return 0;
-}
-
-static void
-ec_focus (ECellView *ecell_view, int model_col, int view_col, int row, int x1, int y1, int x2, int y2)
-{
- ecell_view->focus_col = view_col;
- ecell_view->focus_row = row;
- ecell_view->focus_x1 = x1;
- ecell_view->focus_y1 = y1;
- ecell_view->focus_x2 = x2;
- ecell_view->focus_y2 = y2;
-}
-
-static void
-ec_unfocus (ECellView *ecell_view)
-{
- ecell_view->focus_col = -1;
- ecell_view->focus_row = -1;
- ecell_view->focus_x1 = -1;
- ecell_view->focus_y1 = -1;
- ecell_view->focus_x2 = -1;
- ecell_view->focus_y2 = -1;
-}
-
-static void *
-ec_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- return NULL;
-}
-
-static void
-ec_leave_edit (ECellView *ecell_view, int model_col, int view_col, int row, void *context)
-{
-}
-
-static void
-e_cell_class_init (GtkObjectClass *object_class)
-{
- ECellClass *ecc = (ECellClass *) object_class;
-
- ecc->realize = ec_realize;
- ecc->unrealize = ec_unrealize;
- ecc->new_view = ec_new_view;
- ecc->kill_view = ec_kill_view;
- ecc->draw = ec_draw;
- ecc->event = ec_event;
- ecc->focus = ec_focus;
- ecc->unfocus = ec_unfocus;
- ecc->height = ec_height;
- ecc->enter_edit = ec_enter_edit;
- ecc->leave_edit = ec_leave_edit;
-}
-
-static void
-e_cell_init (GtkObject *object)
-{
-}
-
-E_MAKE_TYPE(e_cell, "ECell", ECell, e_cell_class_init, e_cell_init, PARENT_TYPE);
-
-
-void
-e_cell_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row)
-{
- E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->event (
- ecell_view, event, model_col, view_col, row);
-}
-
-ECellView *
-e_cell_new_view (ECell *ecell, ETableModel *table_model, void *e_table_item_view)
-{
- return E_CELL_CLASS (GTK_OBJECT (ecell)->klass)->new_view (
- ecell, table_model, e_table_item_view);
-}
-
-void
-e_cell_view_realize (ECellView *ecell_view)
-{
- return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->realize (ecell_view);
-}
-
-void
-e_cell_kill_view (ECellView *ecell_view)
-{
- E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->kill_view (ecell_view);
-}
-
-void
-e_cell_unrealize (ECellView *ecell_view)
-{
- E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->unrealize (ecell_view);
-}
-
-void
-e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected, int x1, int y1, int x2, int y2)
-{
- E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->draw (
- ecell_view, drawable, model_col, view_col, row, selected, x1, y1, x2, y2);
-}
-
-int
-e_cell_height (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->height (
- ecell_view, model_col, view_col, row);
-}
-
-void *
-e_cell_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row)
-{
- return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->enter_edit (
- ecell_view, model_col, view_col, row);
-}
-
-void
-e_cell_leave_edit (ECellView *ecell_view, int model_col, int view_col, int row, void *edit_context)
-{
- E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->leave_edit (
- ecell_view, model_col, view_col, row, edit_context);
-}
diff --git a/widgets/table/e-cell.h b/widgets/table/e-cell.h
deleted file mode 100644
index 3c258689e4..0000000000
--- a/widgets/table/e-cell.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef _E_CELL_H_
-#define _E_CELL_H_
-
-#include <gdk/gdktypes.h>
-#include "e-table-model.h"
-
-#define E_CELL_TYPE (e_cell_get_type ())
-#define E_CELL(o) (GTK_CHECK_CAST ((o), E_CELL_TYPE, ECell))
-#define E_CELL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TYPE, ECellClass))
-#define E_IS_CELL(o) (GTK_CHECK_TYPE ((o), E_CELL_TYPE))
-#define E_IS_CELL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TYPE))
-
-typedef struct _ECell ECell;
-typedef struct _ECellView ECellView;
-
-struct _ECell {
- GtkObject object;
-};
-
-struct _ECellView {
- ECell *ecell;
- ETableModel *e_table_model;
- void *e_table_item_view;
-
- gint focus_x1, focus_y1, focus_x2, focus_y2;
- gint focus_col, focus_row;
-};
-
-#define E_CELL_IS_FOCUSED(ecell_view) (ecell_view->focus_x1 != -1)
-
-typedef struct {
- GtkObjectClass parent_class;
-
- ECellView *(*new_view) (ECell *ecell, ETableModel *table_model, void *e_table_item_view);
- void (*kill_view) (ECellView *ecell_view);
-
- void (*realize) (ECellView *ecell_view);
- void (*unrealize) (ECellView *ecell_view);
-
- void (*draw) (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row,
- gboolean selected, int x1, int y1, int x2, int y2);
- gint (*event) (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row);
- void (*focus) (ECellView *ecell_view, int model_col, int view_col,
- int row, int x1, int y1, int x2, int y2);
- void (*unfocus) (ECellView *ecell_view);
- int (*height) (ECellView *ecell_view, int model_col, int view_col, int row);
-
- void *(*enter_edit)(ECellView *ecell_view, int model_col, int view_col, int row);
- void (*leave_edit)(ECellView *ecell_view, int model_col, int view_col, int row, void *context);
-} ECellClass;
-
-GtkType e_cell_get_type (void);
-ECellView *e_cell_new_view (ECell *ecell, ETableModel *table_model, void *e_table_item_view);
-void e_cell_kill_view (ECellView *ecell_view);
-
-void e_cell_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row);
-
-void e_cell_realize (ECellView *ecell_view);
-void e_cell_unrealize (ECellView *ecell_view);
-
-void e_cell_draw (ECellView *ecell_view, GdkDrawable *dr,
- int model_col, int view_col, int row, gboolean selected,
- int x1, int y1, int x2, int y2);
-void e_cell_focus (ECellView *ecell_view, int model_col, int view_col, int row,
- int x1, int y1, int x2, int y2);
-void e_cell_unfocus (ECellView *ecell_view);
-int e_cell_height (ECellView *ecell_view, int model_col, int view_col, int row);
-
-void *e_cell_enter_edit(ECellView *ecell_view, int model_col, int view_col, int row);
-void e_cell_leave_edit(ECellView *ecell_view, int model_col, int view_col, int row, void *edit_context);
-
-#endif /* _E_CELL_H_ */
diff --git a/widgets/table/e-table-col-dnd.h b/widgets/table/e-table-col-dnd.h
deleted file mode 100644
index c1c26175c7..0000000000
--- a/widgets/table/e-table-col-dnd.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _E_TABLE_COL_DND_H_
-#define _E_TABLE_COL_DND_H_
-
-#define TARGET_ETABLE_COL_TYPE "application/x-etable-column-header"
-
-enum {
- TARGET_ETABLE_COL_HEADER
-};
-
-#endif /* _E_TABLE_COL_DND_H_ */
diff --git a/widgets/table/e-table-col.c b/widgets/table/e-table-col.c
deleted file mode 100644
index 6f475158a5..0000000000
--- a/widgets/table/e-table-col.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * E-table-col.c: ETableCol implementation
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include <gtk/gtkobject.h>
-#include <gtk/gtksignal.h>
-#include "e-table-col.h"
-#include "e-util/e-util.h"
-
-#define PARENT_TYPE (gtk_object_get_type ())
-
-static GtkObjectClass *parent_class;
-
-static void
-etc_destroy (GtkObject *object)
-{
- ETableCol *etc = E_TABLE_COL (object);
-
- g_free (etc->text);
-
- (*parent_class->destroy)(object);
-}
-
-static void
-e_table_col_class_init (GtkObjectClass *object_class)
-{
- parent_class = gtk_type_class (PARENT_TYPE);
- object_class->destroy = etc_destroy;
-}
-
-E_MAKE_TYPE(e_table_col, "ETableCol", ETableCol, e_table_col_class_init, NULL, PARENT_TYPE);
-
-ETableCol *
-e_table_col_new (int col_idx, const char *text, int width, int min_width,
- ECell *ecell, GCompareFunc compare, gboolean resizable)
-{
- ETableCol *etc;
-
- g_return_val_if_fail (width >= 0, NULL);
- g_return_val_if_fail (min_width >= 0, NULL);
- g_return_val_if_fail (width >= min_width, NULL);
- g_return_val_if_fail (compare != NULL, NULL);
-
- etc = gtk_type_new (E_TABLE_COL_TYPE);
-
- etc->col_idx = col_idx;
- etc->text = g_strdup (text);
- etc->width = width;
- etc->min_width = min_width;
- etc->ecell = ecell;
- etc->compare = compare;
-
- etc->selected = 0;
- etc->resizeable = resizable;
-
- return etc;
-}
-
-
diff --git a/widgets/table/e-table-col.h b/widgets/table/e-table-col.h
deleted file mode 100644
index 54f03ae237..0000000000
--- a/widgets/table/e-table-col.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef _E_TABLE_COL_H_
-#define _E_TABLE_COL_H_
-
-#include "e-cell.h"
-
-#define E_TABLE_COL_TYPE (e_table_col_get_type ())
-#define E_TABLE_COL(o) (GTK_CHECK_CAST ((o), E_TABLE_COL_TYPE, ETableCol))
-#define E_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_COL_TYPE, ETableColClass))
-#define E_IS_TABLE_COL(o) (GTK_CHECK_TYPE ((o), E_TABLE_COL_TYPE))
-#define E_IS_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_COL_TYPE))
-
-typedef struct _ETableCol ETableCol;
-
-/*
- * Information about a single column
- */
-struct _ETableCol {
- GtkObject base;
- char *text;
- short width;
- short min_width;
- short x;
- GCompareFunc compare;
- unsigned int selected:1;
- unsigned int resizeable:1;
- int col_idx;
-
- ECell *ecell;
-};
-
-typedef struct {
- GtkObjectClass parent_class;
-} ETableColClass;
-
-GtkType e_table_col_get_type (void);
-ETableCol *e_table_col_new (int col_idx, const char *text,
- int width, int min_width,
- ECell *ecell, GCompareFunc compare,
- gboolean resizable);
-void e_table_col_destroy (ETableCol *etc);
-
-
-#endif /* _E_TABLE_COL_H_ */
-
diff --git a/widgets/table/e-table-column-item.c b/widgets/table/e-table-column-item.c
deleted file mode 100644
index 0616327a93..0000000000
--- a/widgets/table/e-table-column-item.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * E-table-column-view.c: A canvas view of the TableColumn.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * Copyright 1999, Helix Code, Inc.
- */
-#include <config.h>
-#include "e-table-column.h"
-#include "e-table-column-view.h"
-
-#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type ()
-
-static GnomeCanvasItemClass *etci_parent_class;
-
-enum {
- ARG_0,
- ARG_TABLE_COLUMN
-};
-
-static void
-etci_destroy (GtkObject *object)
-{
- ETableColumnItem *etcv = E_TABLE_COLUMN_VIEW (object);
-
- gtk_object_unref (GTK_OBJECT (etcv));
-
- if (GTK_OBJECT_CLASS (etcv_parent_class)->destroy)
- (*GTK_OBJECT_CLASS (etcv_parent_class)->destroy) (object);
-}
-
-static void
-etci_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- if (GNOME_CANVAS_ITEM_CLASS(item_bar_parent_class)->update)
- (*GNOME_CANVAS_ITEM_CLASS(item_bar_parent_class)->update)(item, affine, clip_path, flags);
-
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = INT_MAX;
- item->y2 = INT_MAX;
- gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
-}
-
-static void
-etci_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- ETableColumnItem *etci;
- int v;
-
- item = GNOME_CANVAS_ITEM (o);
- etci = E_TABLE_COLUMN_ITEM (o);
-
- switch (arg_id){
- case ARG_TABLE_COLUMN:
- etci->etci = GTK_VALUE_POINTER (*arg);
- break;
- }
- etci_update (item, NULL, NULL, 0);
-}
-
-static void
-etci_realize (GnomeCanvasItem *item)
-{
- ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item);
- GdkWindow *window;
- GdkColor c;
-
- if (GNOME_CANVAS_ITEM_CLASS (etci_parent_class)-> realize)
- (*GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->realize)(item);
-
- window = GTK_WIDGET (item->canvas)->window;
-
- etci->gc = gdk_gc_new (window);
- gnome_canvas_get_color (item->canvas, "black", &c);
- gdk_gc_set_foreground (etci->gc, &c);
-
- etci->normal_cursor = gdk_cursor_new (GDK_ARROW);
-}
-
-static void
-etci_unrealize (GnomeCanvasItem *item)
-{
- ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item);
-
- gdk_gc_unref (etci->gc);
- etci->gc = NULL;
-
- gdk_cursor_destroy (etci->change_cursor);
- etci->change_cursor = NULL;
-
- gdk_cursor_destroy (etci->normal_cursor);
- etci->normal_cursor = NULL;
-
- if (GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->unrealize)
- (*GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->unrealize)(item);
-}
-
-static void
-etci_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x1, int y1, int width, int height)
-{
- ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item);
- GnomeCanvas *canvas = item->canvas;
- GdkGC *gc;
- const int cols = e_table_column_count (etci->etc);
- int x2 = x1 + width;
- int col, total;
-
- total = 0;
- for (col = 0; col < cols; col++){
- ETableCol *col = e_table_column_get_column (etci->etc, col);
- const int col_width = col->width;
-
- if (x1 > total + col_width)
- continue;
-
- if (x2 < total)
- return;
-
- gc = canvas->style->bg_gc [GTK_STATE_ACTIVE];
- gdk_draw_rectangle (drawble, gc, TRUE,
- gtk_draw_shadow (canvas->style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- x, y, width, height
- }
-}
-
-static double
-etci_point (GnomeCanvasItem *item, double x, double y, int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- *actual_item = *item;
- return 0.0;
-}
-
-static void
-etci_event (GnomeCanvasItem *item, GdkEvent *e)
-{
- switch (e->type){
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-static void
-etci_class_init (GtkObjectClass *object_class)
-{
- GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class;
-
- object_class->destroy = etci_destroy;
- object_class->set_arg = etci_set_arg;
-
- item_class->update = etci_update;
- item_class->realize = etci_realize;
- item_class->unrealize = etci_unrealize;
- item_class->draw = etci_draw;
- item_class->point = etci_point;
- item_class->event = etci_event;
-
- gtk_object_add_arg_type ("ETableColumnItem::ETableColumn", GTK_TYPE_POINTER,
- GTK_ARG_WRITABLE, ARG_TABLE_COLUMN);
-}
-
-static void
-etci_init (GnomeCanvasItem *item)
-{
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = 0;
- item->y2 = 0;
-}
-
-GtkType
-e_table_column_view_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableColumnItem",
- sizeof (ETableColumnItem),
- sizeof (ETableColumnItemClass),
- (GtkClassInitFunc) etci_class_init,
- (GtkObjectInitFunc) etci_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (PARENT_OBJECT_TYPE, &info);
- }
-
- return type;
-}
-
-
-
diff --git a/widgets/table/e-table-column-item.h b/widgets/table/e-table-column-item.h
deleted file mode 100644
index fd38681a73..0000000000
--- a/widgets/table/e-table-column-item.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _E_TABLE_COLUMN_VIEW_H
-#defein _E_TABLE_COLUMN_VIEW_H
-
-#include "e-table-column.h"
-
-typedef struct {
- GnomeCanvasItem parent;
- ETableColumn *etc;
-
- GdkGC *gc;
- GdkCursor *change_cursor, *normal_cursor;
-} ETableColumnView;
-
-typedef struct {
- GnomeCanvasItemClass parent_class;
-} ETableColumnViewClass;
-
-GtkType e_table_column_item_get_type (void);
-
-#endif /* _E_TABLE_COLUMN_VIEW_H */
diff --git a/widgets/table/e-table-column-model.h b/widgets/table/e-table-column-model.h
deleted file mode 100644
index 043dd783ca..0000000000
--- a/widgets/table/e-table-column-model.h
+++ /dev/null
@@ -1,5 +0,0 @@
-
-class ETableColumnModel {
- virtual void add_column (ETableCol *et) = 0;
- virtual ETableCol *get_column (int column);
- virtual
diff --git a/widgets/table/e-table-column.c b/widgets/table/e-table-column.c
deleted file mode 100644
index d17a285321..0000000000
--- a/widgets/table/e-table-column.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * e-table-column.c: TableColumn implementation
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include "e-table-column.h"
-
-enum {
- STRUCTURE_CHANGE,
- DIMENSION_CHANGE,
- LAST_SIGNAL
-};
-
-static guint etc_signals [LAST_SIGNAL] = { 0, };
-
-static GtkObjectClass *e_table_column_parent_class;
-
-static void
-e_table_column_destroy (GtkObject *object)
-{
- ETableColumn *etc = E_TABLE_COLUMN (object);
- const int cols = etc->col_count;
-
- /*
- * Destroy listeners
- */
- for (l = etc->listeners; l; l = l->next)
- g_free (l->data);
- g_slist_free (etc->listeners);
- etc->listeners = NULL;
-
- /*
- * Destroy columns
- */
- for (i = 0; i < cols; i++)
- e_table_column_remove (etc, i);
-
- if (e_table_column_parent_class->destroy)
- e_table_column_parent_class->destroy (object);
-}
-
-static void
-e_table_column_class_init (GtkObjectClass *object_class)
-{
- object_class->destroy = e_table_column_destroy;
-
- e_table_column_parent_class = (gtk_type_class (gtk_object_get_type ()));
-
- etc_signals [STRUCTURE_CHANGE] =
- gtk_signal_new ("structure_change",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableColumn, structure_change),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
- etc_signals [DIMENSION_CHANGE] =
- gtk_signal_new ("dimension_change",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableColumn, dimension_change),
- gtk_marshal_NONE__INT,
- GTK_TYPE_NONE, 1, GTK_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, etc_signals, LAST_SIGNAL);
-}
-
-GtkType
-e_table_column_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableColumn",
- sizeof (ETableColumn),
- sizeof (ETableColumnClass),
- (GtkClassInitFunc) e_table_column_class_init,
- (GtkObjectInitFunc) NULL,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (gtk_object_get_type (), &info);
- }
-
- return type;
-}
-
-static void
-etc_do_insert (ETableColumn *etc, int pos, ETableCol *val)
-{
- memcpy (&etc->columns [pos+1], &etc->columns [pos],
- sizeof (ETableCol *) * (etc->col_count - pos));
- etc->columns [pos] = val;
-}
-
-void
-e_table_column_add_column (ETableColumn *etc, ETableCol *tc, int pos)
-{
- ETableCol **new_ptr;
-
- g_return_if_fail (etc != NULL);
- g_return_if_fail (E_IS_TABLE_COLUMN (etc));
- g_return_if_fail (tc != NULL);
- g_return_if_fail (pos >= 0 && pos < etc->col_count);
-
- if (pos == -1)
- pos = etc->col_count;
- etc->columns = g_realloc (etc->columns, sizeof (ETableCol *) * (etc->col_count + 1));
- etc_do_insert (etc, pos, tc);
- etc->col_count++;
-
- gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]);
-}
-
-ETableCol *
-e_table_column_get_column (ETableColumn *etc, int column)
-{
- g_return_val_if_fail (etc != NULL, NULL);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), NULL);
-
- if (column < 0)
- return NULL;
-
- if (column >= etc->col_count)
- return NULL;
-
- return etc->columns [column];
-}
-
-int
-e_table_column_count (ETableColumn *etc)
-{
- g_return_val_if_fail (etc != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0);
-
- return etc->col_count;
-}
-
-int
-e_table_column_index (ETableColumn *etc, const char *identifier)
-{
- int i;
-
- g_return_val_if_fail (etc != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0);
- g_return_val_if_fail (identifier != NULL, 0);
-
- for (i = 0; i < etc->col_count; i++){
- ETableCol *tc = etc->columns [i];
-
- if (strcmp (i->id, identifier) == 0)
- return i;
- }
-
- return -1;
-}
-
-int
-e_table_column_get_index_at (ETableColumn *etc, int x_offset)
-{
- int i, total;
-
- g_return_val_if_fail (etc != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0);
- g_return_val_if_fail (identifier != NULL, 0);
-
- total = 0;
- for (i = 0; i < etc->col_count; i++){
- total += etc->columns [i]->width;
-
- if (x_offset < total)
- return i;
- }
-
- return -1;
-}
-
-ETableCol **
-e_table_column_get_columns (ETableColumn *etc)
-{
- ETableCol **ret;
- int i;
-
- g_return_val_if_fail (etc != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0);
-
- ret = g_new (ETableCol *, etc->col_count + 1);
- memcpy (ret, etc->columns, sizeof (ETableCol *) * etc->col_count);
- ret [etc->col_count] = NULL;
-
- return ret;
-}
-
-gboolean
-e_table_column_selection_ok (ETableColumn *etc)
-{
- g_return_val_if_fail (etc != NULL, FALSE);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), FALSE);
-
- return etc->selectable;
-}
-
-int
-ve_table_column_get_selected (ETableColumn *etc)
-{
- int i;
- int selected = 0;
-
- g_return_val_if_fail (etc != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0);
-
- for (i = 0; i < etc->col_count; i++){
- if (etc->columns [i]->selected)
- selected++;
- }
-
- return selected;
-}
-
-int
-e_table_column_total_width (ETableColumn *etc)
-{
- int total;
-
- g_return_val_if_fail (etc != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0);
-
- total = 0;
- for (i = 0; i < etc->col_count; i++)
- total += etc->columns [i].width;
-
- return total;
-}
-
-static void
-etc_do_remove (ETableColumn *etc, int idx)
-{
- memcpy (&etc->columns [idx], &etc->columns [idx+1],
- sizeof (ETableCol *) * etc->col_count - idx);
- etc->col_count--;
-}
-
-void
-e_table_column_move (ETableColumn *etc, int source_index, int target_index)
-{
- g_return_if_fail (etc != NULL);
- g_return_if_fail (E_IS_TABLE_COLUMN (etc));
- g_return_if_fail (source_index >= 0);
- g_return_if_fail (target_index >= 0);
- g_return_if_fail (source_index < etc->col_count);
- g_return_if_fail (target_index < etc->col_count);
-
- old = etc->columns [source_index];
- etc_do_remove (etc, source_index);
- etc_do_insert (etc, target_index, old);
- gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]);
-}
-
-void
-e_table_column_remove (ETableColumn *etc, int idx)
-{
- g_return_if_fail (etc != NULL);
- g_return_if_fail (E_IS_TABLE_COLUMN (etc));
- g_return_if_fail (idx >= 0);
- g_return_if_fail (idx < etc->col_count);
-
- etc_do_remove (etc, idx);
- gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]);
-}
-
-void
-e_table_column_set_selection (ETableColumn *etc, gboolean allow_selection);
-{
-}
-
-void
-e_table_column_set_size (ETableColumn *etc, int idx, int size)
-{
- g_return_if_fail (etc != NULL);
- g_return_if_fail (E_IS_TABLE_COLUMN (etc));
- g_return_if_fail (idx >= 0);
- g_return_if_fail (idx < etc->col_count);
- g_return_if_fail (size > 0);
-
- etc->columns [idx]->width = size;
- gtk_signal_emit (GTK_OBJECT (etc), etc_signals [SIZE_CHANGE], idx);
-}
diff --git a/widgets/table/e-table-group.c b/widgets/table/e-table-group.c
deleted file mode 100644
index 8783fbaa02..0000000000
--- a/widgets/table/e-table-group.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * E-Table-Group.c: Implements the grouping objects for elements on a table
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org()
- *
- * Copyright 1999, Helix Code, Inc.
- */
-
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include "e-table-group.h"
-#include "e-table-item.h"
-#include <libgnomeui/gnome-canvas-rect-ellipse.h>
-#include "e-util/e-util.h"
-
-#define TITLE_HEIGHT 16
-#define GROUP_INDENT 10
-
-#define PARENT_TYPE gnome_canvas_group_get_type ()
-
-static GnomeCanvasGroupClass *etg_parent_class;
-
-enum {
- HEIGHT_CHANGED,
- LAST_SIGNAL
-};
-
-static gint etg_signals [LAST_SIGNAL] = { 0, };
-
-static void
-etg_destroy (GtkObject *object)
-{
- ETableGroup *etg = E_TABLE_GROUP (object);
-
- GTK_OBJECT_CLASS (etg_parent_class)->destroy (object);
-}
-
-static void
-etg_dim (ETableGroup *etg, int *width, int *height)
-{
- GSList *l;
-
- *width = *height = 0;
-
- for (l = etg->children; l; l = l->next){
- GnomeCanvasItem *child = l->data;
-
- *height += child->y2 - child->y1;
- *width += child->x2 - child->x1;
- }
-
- if (!etg->transparent){
- *height += TITLE_HEIGHT;
- *width += GROUP_INDENT;
- }
-}
-
-void
-e_table_group_construct (GnomeCanvasGroup *parent, ETableGroup *etg,
- ETableCol *ecol, gboolean open,
- gboolean transparent)
-{
- gnome_canvas_item_constructv (GNOME_CANVAS_ITEM (etg), parent, 0, NULL);
-
- etg->ecol = ecol;
- etg->open = open;
- etg->transparent = transparent;
-
- etg_dim (etg, &etg->width, &etg->height);
-
- if (!etg->transparent)
- etg->rect = gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (etg),
- gnome_canvas_rect_get_type (),
- "fill_color", "gray",
- "outline_color", "gray20",
- "x1", 0.0,
- "y1", 0.0,
- "x2", (double) etg->width,
- "y2", (double) etg->height,
- NULL);
-
-#if 0
- /*
- * Reparent the child into our space.
- */
- gnome_canvas_item_reparent (child, GNOME_CANVAS_GROUP (etg));
-
- gnome_canvas_item_set (
- child,
- "x", (double) GROUP_INDENT,
- "y", (double) TITLE_HEIGHT,
- NULL);
-
- /*
- * Force dimension computation
- */
- GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->update (
- GNOME_CANVAS_ITEM (etg), NULL, NULL, GNOME_CANVAS_UPDATE_REQUESTED);
-#endif
-}
-
-GnomeCanvasItem *
-e_table_group_new (GnomeCanvasGroup *parent, ETableCol *ecol,
- gboolean open, gboolean transparent)
-{
- ETableGroup *etg;
-
- g_return_val_if_fail (parent != NULL, NULL);
- g_return_val_if_fail (ecol != NULL, NULL);
-
- etg = gtk_type_new (e_table_group_get_type ());
-
- e_table_group_construct (parent, etg, ecol, open, transparent);
-
- return GNOME_CANVAS_ITEM (etg);
-}
-
-static void
-etg_relayout (GnomeCanvasItem *eti, ETableGroup *etg)
-{
- GSList *l;
- int height = etg->transparent ? 0 : GROUP_INDENT;
- gboolean move = FALSE;
-
- printf ("Relaying out\n");
-
- for (l = etg->children; l->next; l = l->next){
- GnomeCanvasItem *child = l->data;
-
- height += child->y2 - child->y1;
-
- if (child == eti)
- move = TRUE;
-
- if (move){
- printf ("Moving item %p\n", child);
- gnome_canvas_item_set (
- child,
- "y", (double) height,
- NULL);
- }
- }
- if (height != etg->height){
- etg->height = height;
- gtk_signal_emit (GTK_OBJECT (etg), etg_signals [HEIGHT_CHANGED]);
- }
-}
-
-void
-e_table_group_add (ETableGroup *etg, GnomeCanvasItem *item)
-{
- double x1, y1, x2, y2;
-
- g_return_if_fail (etg != NULL);
- g_return_if_fail (item != NULL);
- g_return_if_fail (E_IS_TABLE_GROUP (etg));
- g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
-
- etg->children = g_slist_append (etg->children, item);
-
- GNOME_CANVAS_ITEM_CLASS (GTK_OBJECT (etg)->klass)->bounds (etg, &x1, &y1, &x2, &y2);
-
- if (GTK_OBJECT (etg)->flags & GNOME_CANVAS_ITEM_REALIZED){
- GSList *l;
- int height = etg->transparent ? 0 : TITLE_HEIGHT;
- int x = etg->transparent ? 0 : GROUP_INDENT;
-
- for (l = etg->children; l->next; l = l->next){
- GnomeCanvasItem *child = l->data;
-
- height += child->y2 - child->y1;
- }
-
- printf ("Positioning item %p at %d\n", item, height);
- gnome_canvas_item_set (
- item,
- "y", (double) height,
- "x", (double) x,
- NULL);
-
-
- if (E_IS_TABLE_ITEM (item)){
-
- printf ("Table item! ---------\n");
- gtk_signal_connect (GTK_OBJECT (item), "height_changed",
- GTK_SIGNAL_FUNC (etg_relayout), etg);
- }
- }
-}
-
-static void
-etg_realize (GnomeCanvasItem *item)
-{
- ETableGroup *etg = E_TABLE_GROUP (item);
- GSList *l;
- int height = 0;
-
- GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->realize (item);
-
- for (l = etg->children; l; l = l->next){
- GnomeCanvasItem *child = l->data;
-
- printf ("During realization for child %p -> %d\n", child, height);
- gnome_canvas_item_set (
- child,
- "y", (double) height,
- NULL);
-
- height += child->y2 - child->y1;
- }
-}
-
-static void
-etg_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- ETableGroup *etg = E_TABLE_GROUP (item);
-
- GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->update (item, affine, clip_path, flags);
-
- if (!etg->transparent){
- int current_width, current_height;
-
- etg_dim (etg, &current_width, &current_height);
-
- if ((current_height != etg->height) || (current_width != etg->width)){
- etg->width = current_width;
- etg->height = current_height;
-
- gnome_canvas_item_set (
- etg->rect,
- "x1", 0.0,
- "y1", 0.0,
- "x2", (double) etg->width,
- "y2", (double) etg->height,
- NULL);
- }
- }
-}
-
-static void
-etg_class_init (GtkObjectClass *object_class)
-{
- GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class;
-
- object_class->destroy = etg_destroy;
-
- item_class->realize = etg_realize;
- item_class->update = etg_update;
-
- etg_parent_class = gtk_type_class (PARENT_TYPE);
-
- etg_signals [HEIGHT_CHANGED] =
- gtk_signal_new ("height_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableGroupClass, height_changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, etg_signals, LAST_SIGNAL);
-
-}
-
-E_MAKE_TYPE (e_table_group, "ETableGroup", ETableGroup, etg_class_init, NULL, PARENT_TYPE);
-
-
-
diff --git a/widgets/table/e-table-group.h b/widgets/table/e-table-group.h
deleted file mode 100644
index 468d5dd794..0000000000
--- a/widgets/table/e-table-group.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef _E_TABLE_TREE_H_
-#define _E_TABLE_TREE_H_
-
-#include <libgnomeui/gnome-canvas.h>
-#include "e-table-model.h"
-#include "e-table-header.h"
-
-#define E_TABLE_GROUP_TYPE (e_table_group_get_type ())
-#define E_TABLE_GROUP(o) (GTK_CHECK_CAST ((o), E_TABLE_GROUP_TYPE, ETableGroup))
-#define E_TABLE_GROUP_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_GROUP_TYPE, ETableGroupClass))
-#define E_IS_TABLE_GROUP(o) (GTK_CHECK_TYPE ((o), E_TABLE_GROUP_TYPE))
-#define E_IS_TABLE_GROUP_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_GROUP_TYPE))
-
-typedef struct {
- GnomeCanvasGroup group;
-
- /*
- * The ETableCol used to group this set
- */
- ETableCol *ecol;
-
- /*
- * The canvas rectangle that contains the children
- */
- GnomeCanvasItem *rect;
-
- /*
- * Dimensions of the ETableGroup
- */
- int width, height;
-
- /*
- * State: the ETableGroup is open or closed
- */
- guint open:1;
-
- /*
- * Whether we should add indentation and open/close markers,
- * or if we just act as containers of subtables.
- */
- guint transparent:1;
-
- /*
- * List of GnomeCanvasItems we stack
- */
- GSList *children;
-} ETableGroup;
-
-typedef struct {
- GnomeCanvasGroupClass parent_class;
- void (*height_changed) (ETableGroup *etg);
-} ETableGroupClass;
-
-GnomeCanvasItem *e_table_group_new (GnomeCanvasGroup *parent, ETableCol *ecol,
- gboolean open, gboolean transparent);
-void e_table_group_construct (GnomeCanvasGroup *parent, ETableGroup *etg,
- ETableCol *ecol, gboolean open, gboolean transparent);
-
-void e_table_group_add (ETableGroup *etg, GnomeCanvasItem *child);
-
-GtkType e_table_group_get_type (void);
-
-#endif /* _E_TABLE_TREE_H_ */
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c
deleted file mode 100644
index 5f23f06fa3..0000000000
--- a/widgets/table/e-table-header-item.c
+++ /dev/null
@@ -1,793 +0,0 @@
-/*
- * E-table-column-view.c: A canvas item based view of the ETableColumn.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * Copyright 1999, Helix Code, Inc.
- */
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkdnd.h>
-#include <libgnomeui/gnome-canvas.h>
-#include <libgnomeui/gnome-canvas-util.h>
-#include <libgnomeui/gnome-canvas-polygon.h>
-#include <libgnomeui/gnome-canvas-rect-ellipse.h>
-#include "e-util/e-cursors.h"
-#include "e-table-header.h"
-#include "e-table-header-item.h"
-#include "e-table-col-dnd.h"
-
-#include "add-col.xpm"
-#include "remove-col.xpm"
-
-/* Padding above and below of the string in the header display */
-#define PADDING 4
-
-/* Defines the tolerance for proximity of the column division to the cursor position */
-#define TOLERANCE 2
-
-#define ETHI_RESIZING(x) ((x)->resize_col != -1)
-
-#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type ()
-
-#define ELEMENTS(x) (sizeof (x) / sizeof (x[0]))
-
-static GnomeCanvasItemClass *ethi_parent_class;
-
-/*
- * DnD icons
- */
-static GdkColormap *dnd_colormap;
-static GdkPixmap *remove_col_pixmap, *remove_col_mask;
-static GdkPixmap *add_col_pixmap, *add_col_mask;
-
-enum {
- ARG_0,
- ARG_TABLE_HEADER,
- ARG_TABLE_X,
- ARG_TABLE_Y,
- ARG_TABLE_FONTSET
-};
-
-static GtkTargetEntry ethi_drag_types [] = {
- { TARGET_ETABLE_COL_TYPE, 0, TARGET_ETABLE_COL_HEADER },
-};
-
-static GtkTargetEntry ethi_drop_types [] = {
- { TARGET_ETABLE_COL_TYPE, 0, TARGET_ETABLE_COL_HEADER },
-};
-
-static void
-ethi_destroy (GtkObject *object)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (object);
-
- gtk_object_unref (GTK_OBJECT (ethi->eth));
-
- if (GTK_OBJECT_CLASS (ethi_parent_class)->destroy)
- (*GTK_OBJECT_CLASS (ethi_parent_class)->destroy) (object);
-}
-
-static void
-ethi_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
-
- if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update)
- (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update)(item, affine, clip_path, flags);
-
- item->x1 = ethi->x1;
- item->y1 = ethi->y1;
- item->x2 = ethi->x1 + ethi->width;
- item->y2 = ethi->y1 + ethi->height;
-
- gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
-}
-
-static void
-ethi_font_load (ETableHeaderItem *ethi, char *font)
-{
- if (ethi->font)
- gdk_font_unref (ethi->font);
-
- ethi->font = gdk_fontset_load (font);
- if (ethi->font == NULL)
- ethi->font = gdk_font_load ("fixed");
-
- ethi->height = ethi->font->ascent + ethi->font->descent + PADDING;
-}
-
-static void
-ethi_drop_table_header (ETableHeaderItem *ethi)
-{
- GtkObject *header;
-
- if (!ethi->eth)
- return;
-
- header = GTK_OBJECT (ethi->eth);
- gtk_signal_disconnect (header, ethi->structure_change_id);
- gtk_signal_disconnect (header, ethi->dimension_change_id);
-
- gtk_object_unref (header);
- ethi->eth = NULL;
- ethi->width = 0;
-}
-
-static void
-structure_changed (ETableHeader *header, ETableHeaderItem *ethi)
-{
- ethi->width = e_table_header_total_width (header);
-
- ethi_update (GNOME_CANVAS_ITEM (ethi), NULL, NULL, 0);
-}
-
-static void
-dimension_changed (ETableHeader *header, int col, ETableHeaderItem *ethi)
-{
- ethi->width = e_table_header_total_width (header);
-
- ethi_update (GNOME_CANVAS_ITEM (ethi), NULL, NULL, 0);
-}
-
-static void
-ethi_add_table_header (ETableHeaderItem *ethi, ETableHeader *header)
-{
- ethi->eth = header;
- gtk_object_ref (GTK_OBJECT (ethi->eth));
- ethi->width = e_table_header_total_width (header);
-
- ethi->structure_change_id = gtk_signal_connect (
- GTK_OBJECT (header), "structure_change",
- GTK_SIGNAL_FUNC(structure_changed), ethi);
- ethi->dimension_change_id = gtk_signal_connect (
- GTK_OBJECT (header), "dimension_change",
- GTK_SIGNAL_FUNC(dimension_changed), ethi);
-}
-
-static void
-ethi_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- ETableHeaderItem *ethi;
-
- item = GNOME_CANVAS_ITEM (o);
- ethi = E_TABLE_HEADER_ITEM (o);
-
- switch (arg_id){
- case ARG_TABLE_HEADER:
- ethi_drop_table_header (ethi);
- ethi_add_table_header (ethi, GTK_VALUE_POINTER (*arg));
- break;
-
- case ARG_TABLE_X:
- ethi->x1 = GTK_VALUE_INT (*arg);
- break;
-
- case ARG_TABLE_Y:
- ethi->y1 = GTK_VALUE_INT (*arg);
- break;
-
- case ARG_TABLE_FONTSET:
- ethi_font_load (ethi, GTK_VALUE_STRING (*arg));
- break;
-
- }
- ethi_update (item, NULL, NULL, 0);
-}
-
-static int
-ethi_find_col_by_x (ETableHeaderItem *ethi, int x)
-{
- const int cols = e_table_header_count (ethi->eth);
- int x1 = ethi->x1;
- int col;
-
- if (x < x1)
- return -1;
-
- for (col = 0; col < cols; col++){
- ETableCol *ecol = e_table_header_get_column (ethi->eth, col);
-
- if ((x >= x1) && (x <= x1 + ecol->width))
- return col;
-
- x1 += ecol->width;
- }
- return -1;
-}
-
-static void
-ethi_remove_drop_marker (ETableHeaderItem *ethi)
-{
- if (ethi->drag_mark == -1)
- return;
-
- ethi->drag_mark = -1;
- gtk_object_destroy (GTK_OBJECT (ethi->drag_mark_item));
- ethi->drag_mark_item = NULL;
-}
-
-static void
-ethi_add_drop_marker (ETableHeaderItem *ethi, int col)
-{
- GnomeCanvasPoints *points;
- int x;
-
- if (ethi->drag_mark == col)
- return;
-
- if (ethi->drag_mark_item)
- gtk_object_destroy (GTK_OBJECT (ethi->drag_mark_item));
-
- ethi->drag_mark = col;
-
- ethi->drag_mark_item = gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (GNOME_CANVAS_ITEM (ethi)->canvas->root),
- gnome_canvas_group_get_type (),
- "x", 0,
- "y", 0,
- NULL);
-
- points = gnome_canvas_points_new (3);
-
- x = e_table_header_col_diff (ethi->eth, 0, col);
-
- points->coords [0] = ethi->x1 + x - 5;
- points->coords [1] = ethi->y1;
- points->coords [2] = points->coords [0] + 10;
- points->coords [3] = points->coords [1];
- points->coords [4] = ethi->x1 + x;
- points->coords [5] = ethi->y1 + 5;
-
- gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (ethi->drag_mark_item),
- gnome_canvas_polygon_get_type (),
- "points", points,
- "fill_color", "red",
- NULL);
-
- points->coords [0] --;
- points->coords [1] += ethi->height - 1;
- points->coords [3] = points->coords [1];
- points->coords [5] = points->coords [1] - 6;
-
- gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (ethi->drag_mark_item),
- gnome_canvas_polygon_get_type (),
- "points", points,
- "fill_color", "red",
- NULL);
-
- gnome_canvas_points_unref (points);
-}
-
-#define gray50_width 2
-#define gray50_height 2
-static char gray50_bits [] = {
- 0x02, 0x01, };
-
-static void
-ethi_add_destroy_marker (ETableHeaderItem *ethi)
-{
- double x1;
-
- if (ethi->remove_item)
- gtk_object_destroy (GTK_OBJECT (ethi->remove_item));
-
- if (!ethi->stipple)
- ethi->stipple = gdk_bitmap_create_from_data (NULL, gray50_bits, gray50_width, gray50_height);
-
- x1 = ethi->x1 + (double) e_table_header_col_diff (ethi->eth, 0, ethi->drag_col);
- ethi->remove_item = gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (GNOME_CANVAS_ITEM (ethi)->canvas->root),
- gnome_canvas_rect_get_type (),
- "x1", x1 + 1,
- "y1", (double) ethi->y1 + 1,
- "x2", (double) x1 + e_table_header_col_diff (ethi->eth, ethi->drag_col, ethi->drag_col+1) - 2,
- "y2", (double) ethi->y1 + ethi->height - 2,
- "fill_color", "red",
- "fill_stipple", ethi->stipple,
- NULL);
-}
-
-static void
-ethi_remove_destroy_marker (ETableHeaderItem *ethi)
-{
- if (!ethi->remove_item)
- return;
-
- gtk_object_destroy (GTK_OBJECT (ethi->remove_item));
- ethi->remove_item = NULL;
-}
-
-static gboolean
-ethi_drag_motion (GtkObject *canvas, GdkDragContext *context,
- gint x, gint y, guint time,
- ETableHeaderItem *ethi)
-{
-
- if ((x >= ethi->x1) && (x <= (ethi->x1 + ethi->width)) &&
- (y >= ethi->y1) && (y <= (ethi->y1 + ethi->height))){
- int col;
-
- col = ethi_find_col_by_x (ethi, x);
-
- if (col != -1){
- ethi_remove_destroy_marker (ethi);
- ethi_add_drop_marker (ethi, col);
- } else {
- ethi_remove_drop_marker (ethi);
- ethi_add_destroy_marker (ethi);
- }
- } else {
- ethi_remove_drop_marker (ethi);
- ethi_add_destroy_marker (ethi);
- }
-
- gdk_drag_status (context, context->suggested_action, time);
-
- return TRUE;
-}
-
-static void
-ethi_drag_end (GtkWidget *canvas, GdkDragContext *context, ETableHeaderItem *ethi)
-{
- ethi_remove_drop_marker (ethi);
- ethi_remove_destroy_marker (ethi);
- ethi->drag_col = -1;
-}
-
-static void
-ethi_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, ETableHeaderItem *ethi)
-{
- ethi_remove_drop_marker (ethi);
- ethi_add_destroy_marker (ethi);
-}
-
-static void
-ethi_realize (GnomeCanvasItem *item)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
- GdkWindow *window;
- GdkColor c;
-
- if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)-> realize)
- (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->realize)(item);
-
- window = GTK_WIDGET (item->canvas)->window;
-
- ethi->gc = gdk_gc_new (window);
- gnome_canvas_get_color (item->canvas, "black", &c);
- gdk_gc_set_foreground (ethi->gc, &c);
-
- ethi->normal_cursor = gdk_cursor_new (GDK_ARROW);
-
- if (!ethi->font)
- ethi_font_load (ethi, "fixed");
-
- /*
- * Now, configure DnD
- */
- gtk_drag_dest_set (GTK_WIDGET (item->canvas), GTK_DEST_DEFAULT_ALL,
- ethi_drop_types, ELEMENTS (ethi_drop_types),
- GDK_ACTION_MOVE);
-
- ethi->drag_motion_id = gtk_signal_connect (
- GTK_OBJECT (item->canvas), "drag_motion",
- GTK_SIGNAL_FUNC (ethi_drag_motion), ethi);
-
- ethi->drag_leave_id = gtk_signal_connect (
- GTK_OBJECT (item->canvas), "drag_leave",
- GTK_SIGNAL_FUNC (ethi_drag_leave), ethi);
-
- ethi->drag_end_id = gtk_signal_connect (
- GTK_OBJECT (item->canvas), "drag_end",
- GTK_SIGNAL_FUNC (ethi_drag_end), ethi);
-}
-
-static void
-ethi_unrealize (GnomeCanvasItem *item)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
-
- gdk_gc_unref (ethi->gc);
- ethi->gc = NULL;
-
- gdk_cursor_destroy (ethi->normal_cursor);
- ethi->normal_cursor = NULL;
-
- gtk_signal_disconnect (GTK_OBJECT (item->canvas), ethi->drag_motion_id);
- gtk_signal_disconnect (GTK_OBJECT (item->canvas), ethi->drag_end_id);
- gtk_signal_disconnect (GTK_OBJECT (item->canvas), ethi->drag_leave_id);
-
- if (ethi->stipple){
- gdk_bitmap_unref (ethi->stipple);
- ethi->stipple = NULL;
- }
-
- if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->unrealize)
- (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->unrealize)(item);
-}
-
-static void
-draw_button (ETableHeaderItem *ethi, ETableCol *col,
- GdkDrawable *drawable, GdkGC *gc, GtkStyle *style,
- int x, int y, int width, int height)
-{
- GdkRectangle clip;
- int xtra;
-
- gdk_draw_rectangle (
- drawable, gc, TRUE,
- x + 1, y + 1, width - 2, height -2);
-
- gtk_draw_shadow (
- style, drawable,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- x , y, width, height);
-
- clip.x = x + 2;
- clip.y = y + 2;
- clip.width = width - 4;
- clip.height = ethi->height;
-
- gdk_gc_set_clip_rectangle (ethi->gc, &clip);
-
- /* Center the thing */
- xtra = (clip.width - gdk_string_measure (ethi->font, col->text))/2;
-
- if (xtra < 0)
- xtra = 0;
-
- /* Skip over border */
- x += xtra + 2;
-
- gdk_draw_text (
- drawable, ethi->font,
- ethi->gc, x, y + ethi->height - PADDING,
- col->text, strlen (col->text));
-}
-
-static void
-ethi_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
- GnomeCanvas *canvas = item->canvas;
- GdkGC *gc;
- const int cols = e_table_header_count (ethi->eth);
- int x1, x2;
- int col;
-
-#if 0
- printf ("My coords are: %g %g %g %g\n",
- item->x1, item->y1, item->x2, item->y2);
-#endif
- x1 = x2 = ethi->x1;
- for (col = 0; col < cols; col++, x1 = x2){
- ETableCol *ecol = e_table_header_get_column (ethi->eth, col);
- int col_width;
-
- if (col == ethi->resize_col)
- col_width = ethi->resize_width;
- else
- col_width = ecol->width;
-
- x2 += col_width;
-
- if (x1 > (x + width))
- break;
-
- if (x2 < x)
- continue;
-
- gc = GTK_WIDGET (canvas)->style->bg_gc [GTK_STATE_ACTIVE];
-
- draw_button (ethi, ecol, drawable, gc,
- GTK_WIDGET (canvas)->style,
- x1 - x, ethi->y1 - y, col_width, ethi->height);
- }
-}
-
-static double
-ethi_point (GnomeCanvasItem *item, double x, double y, int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- *actual_item = item;
- return 0.0;
-}
-
-/*
- * is_pointer_on_division:
- *
- * Returns whether @pos is a column header division; If @the_total is not NULL,
- * then the actual position is returned here. If @return_ecol is not NULL,
- * then the ETableCol that actually contains this point is returned here
- */
-static gboolean
-is_pointer_on_division (ETableHeaderItem *ethi, int pos, int *the_total, int *return_col)
-{
- const int cols = e_table_header_count (ethi->eth);
- int col, total;
-
- total = 0;
- for (col = 0; col < cols; col++){
- ETableCol *ecol = e_table_header_get_column (ethi->eth, col);
-
- total += ecol->width;
-
- if ((total - TOLERANCE < pos ) && (pos < total + TOLERANCE)){
- if (return_col)
- *return_col = col;
- if (the_total)
- *the_total = total;
-
- return TRUE;
- }
-
- if (total > pos + TOLERANCE)
- return FALSE;
- }
-
- return FALSE;
-}
-
-#define convert(c,sx,sy,x,y) gnome_canvas_w2c (c,sx,sy,x,y)
-
-static void
-set_cursor (ETableHeaderItem *ethi, int pos)
-{
- GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas);
-
- /* We might be invoked before we are realized */
- if (!canvas->window)
- return;
-
- if (is_pointer_on_division (ethi, pos, NULL, NULL))
- e_cursor_set (canvas->window, E_CURSOR_SIZE_X);
- else
- e_cursor_set (canvas->window, E_CURSOR_ARROW);
-}
-
-static void
-ethi_request_redraw (ETableHeaderItem *ethi)
-{
- GnomeCanvas *canvas = GNOME_CANVAS_ITEM (ethi)->canvas;
-
- /*
- * request a redraw
- */
- gnome_canvas_request_redraw (
- canvas, ethi->x1, ethi->y1, ethi->x1 + ethi->width, ethi->x1 + ethi->height);
-}
-
-static void
-ethi_end_resize (ETableHeaderItem *ethi, int new_size)
-{
- e_table_header_set_size (ethi->eth, ethi->resize_col, new_size);
-
- ethi->resize_col = -1;
- ethi_request_redraw (ethi);
-}
-
-static gboolean
-ethi_maybe_start_drag (ETableHeaderItem *ethi, GdkEventMotion *event)
-{
- if (!ethi->maybe_drag)
- return FALSE;
-
- if (MAX (abs (ethi->click_x - event->x),
- abs (ethi->click_y - event->y)) <= 3)
- return FALSE;
-
- return TRUE;
-}
-
-static void
-ethi_start_drag (ETableHeaderItem *ethi, GdkEvent *event)
-{
- GtkWidget *widget = GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas);
- GtkTargetList *list;
- GdkDragContext *context;
-
- ethi->drag_col = ethi_find_col_by_x (ethi, event->motion.x);
- if (ethi->drag_col == -1)
- return;
-
- list = gtk_target_list_new (ethi_drag_types, ELEMENTS (ethi_drag_types));
- context = gtk_drag_begin (widget, list, GDK_ACTION_MOVE, 1, event);
- ethi->maybe_drag = FALSE;
-}
-
-/*
- * Handles the events on the ETableHeaderItem, particularly it handles resizing
- */
-static int
-ethi_event (GnomeCanvasItem *item, GdkEvent *e)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
- GnomeCanvas *canvas = item->canvas;
- const gboolean resizing = ETHI_RESIZING (ethi);
- int x, y, start, col;
-
- switch (e->type){
- case GDK_ENTER_NOTIFY:
- convert (canvas, e->crossing.x, e->crossing.y, &x, &y);
- set_cursor (ethi, x);
- break;
-
- case GDK_LEAVE_NOTIFY:
- e_cursor_set (GTK_WIDGET (canvas)->window, E_CURSOR_ARROW);
- break;
-
- case GDK_MOTION_NOTIFY:
- convert (canvas, e->motion.x, e->motion.y, &x, &y);
- if (resizing){
- int new_width;
-
- if (ethi->resize_guide == NULL){
- /* Quick hack until I actually bind the views */
- ethi->resize_guide = GINT_TO_POINTER (1);
- gnome_canvas_item_grab (item,
- GDK_POINTER_MOTION_MASK |
- GDK_BUTTON_RELEASE_MASK,
- e_cursor_get (E_CURSOR_SIZE_X),
- e->button.time);
- }
-
- new_width = x - ethi->resize_start_pos;
- if (new_width <= 0)
- break;
-
- if (new_width < ethi->resize_min_width)
- break;
-
- ethi_request_redraw (ethi);
-
- ethi->resize_width = new_width;
- e_table_header_set_size (ethi->eth, ethi->resize_col, ethi->resize_width);
-
- ethi_request_redraw (ethi);
- } else if (ethi_maybe_start_drag (ethi, &e->motion)){
- ethi_start_drag (ethi, e);
- } else
- set_cursor (ethi, x);
- break;
-
- case GDK_BUTTON_PRESS:
- convert (canvas, e->button.x, e->button.y, &x, &y);
-
- if (is_pointer_on_division (ethi, x, &start, &col)){
- ETableCol *ecol;
-
- /*
- * Record the important bits.
- *
- * By setting resize_pos to a non -1 value,
- * we know that we are being resized (used in the
- * other event handlers).
- */
- ecol = e_table_header_get_column (ethi->eth, col);
-
- if (!ecol->resizeable)
- break;
- ethi->resize_col = col;
- ethi->resize_width = ecol->width;
- ethi->resize_start_pos = start - ecol->width;
- ethi->resize_min_width = ecol->min_width;
- } else {
- if (e->button.button == 1){
- ethi->click_x = e->button.x;
- ethi->click_y = e->button.y;
- ethi->maybe_drag = TRUE;
- }
- }
- break;
-
- case GDK_2BUTTON_PRESS:
- if (!resizing)
- break;
-
- if (e->button.button != 1)
- break;
- break;
-
- case GDK_BUTTON_RELEASE: {
- gboolean needs_ungrab = FALSE;
-
- if (ethi->resize_col != -1){
- needs_ungrab = (ethi->resize_guide != NULL);
- ethi_end_resize (ethi, ethi->resize_width);
- }
- if (needs_ungrab)
- gnome_canvas_item_ungrab (item, e->button.time);
-
- ethi->maybe_drag = FALSE;
- break;
- }
-
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-static void
-ethi_class_init (GtkObjectClass *object_class)
-{
- GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class;
-
- ethi_parent_class = gtk_type_class (PARENT_OBJECT_TYPE);
-
- object_class->destroy = ethi_destroy;
- object_class->set_arg = ethi_set_arg;
-
- item_class->update = ethi_update;
- item_class->realize = ethi_realize;
- item_class->unrealize = ethi_unrealize;
- item_class->draw = ethi_draw;
- item_class->point = ethi_point;
- item_class->event = ethi_event;
-
- gtk_object_add_arg_type ("ETableHeaderItem::ETableHeader", GTK_TYPE_POINTER,
- GTK_ARG_WRITABLE, ARG_TABLE_HEADER);
- gtk_object_add_arg_type ("ETableHeaderItem::x", GTK_TYPE_INT,
- GTK_ARG_WRITABLE, ARG_TABLE_X);
- gtk_object_add_arg_type ("ETableHeaderItem::y", GTK_TYPE_INT,
- GTK_ARG_WRITABLE, ARG_TABLE_Y);
- gtk_object_add_arg_type ("ETableHeaderItem::fontset", GTK_TYPE_STRING,
- GTK_ARG_WRITABLE, ARG_TABLE_FONTSET);
-
- /*
- * Create our pixmaps for DnD
- */
- dnd_colormap = gtk_widget_get_default_colormap ();
- remove_col_pixmap = gdk_pixmap_colormap_create_from_xpm_d (
- NULL, dnd_colormap,
- &remove_col_mask, NULL, remove_col_xpm);
-
- add_col_pixmap = gdk_pixmap_colormap_create_from_xpm_d (
- NULL, dnd_colormap,
- &add_col_mask, NULL, add_col_xpm);
-}
-
-static void
-ethi_init (GnomeCanvasItem *item)
-{
- ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
-
- ethi->resize_col = -1;
-
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = 0;
- item->y2 = 0;
-
- ethi->drag_col = -1;
- ethi->drag_mark = -1;
-}
-
-GtkType
-e_table_header_item_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableHeaderItem",
- sizeof (ETableHeaderItem),
- sizeof (ETableHeaderItemClass),
- (GtkClassInitFunc) ethi_class_init,
- (GtkObjectInitFunc) ethi_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (PARENT_OBJECT_TYPE, &info);
- }
-
- return type;
-}
-
diff --git a/widgets/table/e-table-header-item.h b/widgets/table/e-table-header-item.h
deleted file mode 100644
index 5522d24fae..0000000000
--- a/widgets/table/e-table-header-item.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef _E_TABLE_HEADER_ITEM_H_
-#define _E_TABLE_HEADER_ITEM_H_
-
-#include <libgnomeui/gnome-canvas.h>
-#include "e-table-header.h"
-
-#define E_TABLE_HEADER_ITEM_TYPE (e_table_header_item_get_type ())
-#define E_TABLE_HEADER_ITEM(o) (GTK_CHECK_CAST ((o), E_TABLE_HEADER_ITEM_TYPE, ETableHeaderItem))
-#define E_TABLE_HEADER_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_HEADER_ITEM_TYPE, ETableHeaderItemClass))
-#define E_IS_TABLE_HEADER_ITEM(o) (GTK_CHECK_TYPE ((o), E_TABLE_HEADER_ITEM_TYPE))
-#define E_IS_TABLE_HEADER_ITEM_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_HEADER_ITEM_TYPE))
-
-typedef struct {
- GnomeCanvasItem parent;
- ETableHeader *eth;
-
- GdkGC *gc;
- GdkCursor *change_cursor, *normal_cursor;
-
- short x1, y1, height, width;
- GdkFont *font;
-
- /*
- * Used during resizing; Could be shorts
- */
- int resize_col;
- int resize_width;
- int resize_start_pos;
- int resize_min_width;
-
- GtkObject *resize_guide;
-
- /*
- * Ids
- */
- int structure_change_id, dimension_change_id;
-
- /*
- * For dragging columns
- */
- guint maybe_drag:1;
- guint dnd_ready:1;
- int click_x, click_y;
- int drag_col, drag_mark;
- guint drag_motion_id, drag_end_id, drag_leave_id;
- GnomeCanvasItem *drag_mark_item, *remove_item;
- GdkBitmap *stipple;
-} ETableHeaderItem;
-
-typedef struct {
- GnomeCanvasItemClass parent_class;
-} ETableHeaderItemClass;
-
-GtkType e_table_header_item_get_type (void);
-
-#endif /* _E_TABLE_HEADER_ITEM_H_ */
diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c
deleted file mode 100644
index 7c54bd936e..0000000000
--- a/widgets/table/e-table-header.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * E-table-col-head.c: TableColHead implementation
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc
- */
-#include <config.h>
-#include <gtk/gtkobject.h>
-#include <gtk/gtksignal.h>
-#include "e-table-header.h"
-
-enum {
- STRUCTURE_CHANGE,
- DIMENSION_CHANGE,
- LAST_SIGNAL
-};
-
-static guint eth_signals [LAST_SIGNAL] = { 0, };
-
-static GtkObjectClass *e_table_header_parent_class;
-
-static void
-e_table_header_destroy (GtkObject *object)
-{
- ETableHeader *eth = E_TABLE_HEADER (object);
- const int cols = eth->col_count;
- int i;
-
- /*
- * Destroy columns
- */
- for (i = 0; i < cols; i++){
- e_table_header_remove (eth, i);
- }
-
- if (e_table_header_parent_class->destroy)
- e_table_header_parent_class->destroy (object);
-}
-
-static void
-e_table_header_class_init (GtkObjectClass *object_class)
-{
- object_class->destroy = e_table_header_destroy;
-
- e_table_header_parent_class = (gtk_type_class (gtk_object_get_type ()));
-
- eth_signals [STRUCTURE_CHANGE] =
- gtk_signal_new ("structure_change",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableHeaderClass, structure_change),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
- eth_signals [DIMENSION_CHANGE] =
- gtk_signal_new ("dimension_change",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableHeaderClass, dimension_change),
- gtk_marshal_NONE__INT,
- GTK_TYPE_NONE, 1, GTK_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, eth_signals, LAST_SIGNAL);
-}
-
-GtkType
-e_table_header_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableHeader",
- sizeof (ETableHeader),
- sizeof (ETableHeaderClass),
- (GtkClassInitFunc) e_table_header_class_init,
- (GtkObjectInitFunc) NULL,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (gtk_object_get_type (), &info);
- }
-
- return type;
-}
-
-ETableHeader *
-e_table_header_new (void)
-{
- ETableHeader *eth;
-
- eth = gtk_type_new (e_table_header_get_type ());
-
- return eth;
-}
-
-static void
-eth_do_insert (ETableHeader *eth, int pos, ETableCol *val)
-{
- memcpy (&eth->columns [pos+1], &eth->columns [pos],
- sizeof (ETableCol *) * (eth->col_count - pos));
- eth->columns [pos] = val;
-}
-
-static void
-eth_update_offsets (ETableHeader *eth)
-{
- int i;
- int x = 0;
-
- for (i = 0; i < eth->col_count; i++){
- ETableCol *etc = eth->columns [i];
-
- etc->x = x;
- x += etc->width;
- }
-}
-
-void
-e_table_header_add_column (ETableHeader *eth, ETableCol *tc, int pos)
-{
- g_return_if_fail (eth != NULL);
- g_return_if_fail (E_IS_TABLE_HEADER (eth));
- g_return_if_fail (tc != NULL);
- g_return_if_fail (E_IS_TABLE_COL (tc));
- g_return_if_fail (pos >= -1 && pos <= eth->col_count);
-
- if (pos == -1)
- pos = eth->col_count;
- eth->columns = g_realloc (eth->columns, sizeof (ETableCol *) * (eth->col_count + 1));
-
- /*
- * We are the primary owners of the column
- */
- gtk_object_ref (GTK_OBJECT (tc));
- gtk_object_sink (GTK_OBJECT (tc));
-
- eth_do_insert (eth, pos, tc);
- eth->col_count++;
- eth_update_offsets (eth);
-
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
-}
-
-ETableCol *
-e_table_header_get_column (ETableHeader *eth, int column)
-{
- g_return_val_if_fail (eth != NULL, NULL);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), NULL);
-
- if (column < 0)
- return NULL;
-
- if (column >= eth->col_count)
- return NULL;
-
- return eth->columns [column];
-}
-
-int
-e_table_header_count (ETableHeader *eth)
-{
- g_return_val_if_fail (eth != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0);
-
- return eth->col_count;
-}
-
-int
-e_table_header_index (ETableHeader *eth, int col)
-{
- g_return_val_if_fail (eth != NULL, -1);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), -1);
- g_return_val_if_fail (col < eth->col_count, -1);
-
- return eth->columns [col]->col_idx;
-}
-
-int
-e_table_header_get_index_at (ETableHeader *eth, int x_offset)
-{
- int i, total;
-
- g_return_val_if_fail (eth != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0);
-
- total = 0;
- for (i = 0; i < eth->col_count; i++){
- total += eth->columns [i]->width;
-
- if (x_offset < total)
- return i;
- }
-
- return -1;
-}
-
-ETableCol **
-e_table_header_get_columns (ETableHeader *eth)
-{
- ETableCol **ret;
-
- g_return_val_if_fail (eth != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0);
-
- ret = g_new (ETableCol *, eth->col_count + 1);
- memcpy (ret, eth->columns, sizeof (ETableCol *) * eth->col_count);
- ret [eth->col_count] = NULL;
-
- return ret;
-}
-
-gboolean
-e_table_header_selection_ok (ETableHeader *eth)
-{
- g_return_val_if_fail (eth != NULL, FALSE);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), FALSE);
-
- return eth->selectable;
-}
-
-int
-e_table_header_get_selected (ETableHeader *eth)
-{
- int i;
- int selected = 0;
-
- g_return_val_if_fail (eth != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0);
-
- for (i = 0; i < eth->col_count; i++){
- if (eth->columns [i]->selected)
- selected++;
- }
-
- return selected;
-}
-
-int
-e_table_header_total_width (ETableHeader *eth)
-{
- int total, i;
-
- g_return_val_if_fail (eth != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0);
-
- total = 0;
- for (i = 0; i < eth->col_count; i++)
- total += eth->columns [i]->width;
-
- return total;
-}
-
-static void
-eth_do_remove (ETableHeader *eth, int idx, gboolean do_unref)
-{
- if (do_unref)
- gtk_object_unref (GTK_OBJECT (eth->columns [idx]));
-
- memcpy (&eth->columns [idx], &eth->columns [idx+1],
- sizeof (ETableCol *) * eth->col_count - idx);
- eth->col_count--;
-}
-
-void
-e_table_header_move (ETableHeader *eth, int source_index, int target_index)
-{
- ETableCol *old;
-
- g_return_if_fail (eth != NULL);
- g_return_if_fail (E_IS_TABLE_HEADER (eth));
- g_return_if_fail (source_index >= 0);
- g_return_if_fail (target_index >= 0);
- g_return_if_fail (source_index < eth->col_count);
- g_return_if_fail (target_index < eth->col_count);
-
- old = eth->columns [source_index];
- eth_do_remove (eth, source_index, FALSE);
- eth_do_insert (eth, target_index, old);
- eth_update_offsets (eth);
-
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
-}
-
-void
-e_table_header_remove (ETableHeader *eth, int idx)
-{
- g_return_if_fail (eth != NULL);
- g_return_if_fail (E_IS_TABLE_HEADER (eth));
- g_return_if_fail (idx >= 0);
- g_return_if_fail (idx < eth->col_count);
-
- eth_do_remove (eth, idx, TRUE);
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
-}
-
-void
-e_table_header_set_selection (ETableHeader *eth, gboolean allow_selection)
-{
-}
-
-void
-e_table_header_set_size (ETableHeader *eth, int idx, int size)
-{
- g_return_if_fail (eth != NULL);
- g_return_if_fail (E_IS_TABLE_HEADER (eth));
- g_return_if_fail (idx >= 0);
- g_return_if_fail (idx < eth->col_count);
- g_return_if_fail (size > 0);
-
- eth->columns [idx]->width = size;
- gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE], idx);
-}
-
-int
-e_table_header_col_diff (ETableHeader *eth, int start_col, int end_col)
-{
- int total, col;
-
- g_return_val_if_fail (eth != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0);
-
- {
- const int max_col = eth->col_count;
-
- total = 0;
- for (col = start_col; col < end_col; col++){
-
- if (col == max_col)
- break;
- total += eth->columns [col]->width;
- }
- }
-
- return total;
-}
diff --git a/widgets/table/e-table-header.h b/widgets/table/e-table-header.h
deleted file mode 100644
index 96e65fdc2f..0000000000
--- a/widgets/table/e-table-header.h
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef _E_TABLE_COLUMN_H_
-#define _E_TABLE_COLUMN_H_
-
-#include <gtk/gtkobject.h>
-#include <gdk/gdk.h>
-#include "e-table-col.h"
-
-typedef struct _ETableHeader ETableHeader;
-
-#define E_TABLE_HEADER_TYPE (e_table_header_get_type ())
-#define E_TABLE_HEADER(o) (GTK_CHECK_CAST ((o), E_TABLE_HEADER_TYPE, ETableHeader))
-#define E_TABLE_HEADER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_HEADER_TYPE, ETableHeaderClass))
-#define E_IS_TABLE_HEADER(o) (GTK_CHECK_TYPE ((o), E_TABLE_HEADER_TYPE))
-#define E_IS_TABLE_HEADER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_HEADER_TYPE))
-
-/*
- * A Columnar header.
- */
-struct _ETableHeader {
- GtkObject base;
-
- int col_count;
- ETableCol **columns;
- gboolean selectable;
-};
-
-typedef struct {
- GtkObjectClass parent_class;
-
- void (*structure_change) (ETableHeader *eth);
- void (*dimension_change) (ETableHeader *eth, int col);
-} ETableHeaderClass;
-
-GtkType e_table_header_get_type (void);
-ETableHeader *e_table_header_new (void);
-
-void e_table_header_add_column (ETableHeader *eth,
- ETableCol *tc, int pos);
-ETableCol * e_table_header_get_column (ETableHeader *eth,
- int column);
-int e_table_header_count (ETableHeader *eth);
-int e_table_header_index (ETableHeader *eth,
- int col);
-int e_table_header_get_index_at (ETableHeader *eth,
- int x_offset);
-ETableCol **e_table_header_get_columns (ETableHeader *eth);
-gboolean e_table_header_selection_ok (ETableHeader *eth);
-int e_table_header_get_selected (ETableHeader *eth);
-int e_table_header_total_width (ETableHeader *eth);
-void e_table_header_move (ETableHeader *eth,
- int source_index,
- int target_index);
-void e_table_header_remove (ETableHeader *eth, int idx);
-void e_table_header_set_size (ETableHeader *eth, int idx, int size);
-void e_table_header_set_selection (ETableHeader *eth,
- gboolean allow_selection);
-
-int e_table_header_col_diff (ETableHeader *eth,
- int start_col, int end_col);
-
-GList *e_table_header_get_selected_indexes(ETableHeader *eth);
-
-
-#endif /* _E_TABLE_HEADER_H_ */
-
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
deleted file mode 100644
index 33f0c18616..0000000000
--- a/widgets/table/e-table-item.c
+++ /dev/null
@@ -1,1316 +0,0 @@
-/*
- * E-table-item.c: A GnomeCanvasItem that is a view of an ETableModel.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * TODO:
- * Add a border to the thing, so that focusing works properly.
- *
- */
-#include <config.h>
-#include <stdio.h>
-#include <gtk/gtksignal.h>
-#include <gdk/gdkkeysyms.h>
-#include <math.h>
-#include "e-table-item.h"
-#include "e-cell.h"
-
-#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type ()
-
-#define FOCUSED_BORDER 2
-
-static GnomeCanvasItemClass *eti_parent_class;
-
-enum {
- ROW_SELECTION,
- HEIGHT_CHANGED,
- LAST_SIGNAL
-};
-
-static gint eti_signals [LAST_SIGNAL] = { 0, };
-
-enum {
- ARG_0,
- ARG_TABLE_HEADER,
- ARG_TABLE_MODEL,
- ARG_TABLE_X,
- ARG_TABLE_Y,
- ARG_TABLE_DRAW_GRID,
- ARG_TABLE_DRAW_FOCUS,
- ARG_MODE_SPREADSHEET,
- ARG_LENGHT_THRESHOLD
-};
-
-static gboolean
-eti_editing (ETableItem *eti)
-{
- if (eti->editing_col == -1)
- return FALSE;
- else
- return TRUE;
-}
-
-/*
- * During realization, we have to invoke the per-ecell realize routine
- * (On our current setup, we have one e-cell per column.
- *
- * We might want to optimize this to only realize the unique e-cells:
- * ie, a strings-only table, uses the same e-cell for every column, and
- * we might want to avoid realizing each e-cell.
- */
-static void
-eti_realize_cell_views (ETableItem *eti)
-{
- int i;
-
- for (i = 0; i < eti->n_cells; i++)
- e_cell_view_realize (eti->cell_views [i], eti);
- eti->cell_views_realized = 1;
-}
-
-static void eti_compute_height (ETableItem *eti);
-
-static void
-eti_attach_cell_views (ETableItem *eti)
-{
- int i;
-
- g_assert (eti->header);
- g_assert (eti->table_model);
-
- /*
- * Now realize the various ECells
- */
- eti->n_cells = eti->cols;
- eti->cell_views = g_new (ECellView *, eti->n_cells);
-
- for (i = 0; i < eti->n_cells; i++){
- ETableCol *col = e_table_header_get_column (eti->header, i);
-
- eti->cell_views [i] = e_cell_new_view (col->ecell, eti->table_model, eti);
- }
-
- eti_compute_height (eti);
-}
-
-/*
- * During unrealization: we invoke every e-cell (one per column in the current
- * setup) to dispose all X resources allocated
- */
-static void
-eti_unrealize_cell_views (ETableItem *eti)
-{
- int i;
-
- if (eti->cell_views_realized == 0)
- return;
-
- for (i = 0; i < eti->n_cells; i++)
- e_cell_unrealize (eti->cell_views [i]);
- eti->cell_views_realized = 0;
-}
-
-static void
-eti_detach_cell_views (ETableItem *eti)
-{
- int i;
-
- for (i = 0; i < eti->n_cells; i++){
- e_cell_kill_view (eti->cell_views [i]);
- eti->cell_views [i] = NULL;
- }
-
- g_free (eti->cell_views);
- eti->cell_views = NULL;
- eti->n_cells = 0;
-}
-
-static void
-eti_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
-{
- double i2c [6];
- ArtPoint c1, c2, i1, i2;
- ETableItem *eti = E_TABLE_ITEM (item);
-
- gnome_canvas_item_i2c_affine (item, i2c);
- i1.x = eti->x1;
- i1.y = eti->y1;
- i2.x = eti->x1 + eti->width;
- i2.y = eti->y1 + eti->height;
- art_affine_point (&c1, &i1, i2c);
- art_affine_point (&c2, &i2, i2c);
-
- item->x1 = c1.x;
- item->y1 = c1.y;
- item->x2 = c2.x;
- item->y2 = c2.y;
-}
-
-
-/*
- * GnomeCanvasItem::update method
- */
-static void
-eti_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)
- (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)(item, affine, clip_path, flags);
-
- eti_bounds (item, &item->x1, &item->y1, &item->x2, &item->y2);
- gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
-}
-
-/*
- * eti_remove_table_model:
- *
- * Invoked to release the table model associated with this ETableItem
- */
-static void
-eti_remove_table_model (ETableItem *eti)
-{
- if (!eti->table_model)
- return;
-
- gtk_signal_disconnect (GTK_OBJECT (eti->table_model),
- eti->table_model_change_id);
- gtk_signal_disconnect (GTK_OBJECT (eti->table_model),
- eti->table_model_row_change_id);
- gtk_object_unref (GTK_OBJECT (eti->table_model));
-
- eti->table_model_change_id = 0;
- eti->table_model_row_change_id = 0;
- eti->table_model = NULL;
-}
-
-/*
- * eti_remove_header_model:
- *
- * Invoked to release the header model associated with this ETableItem
- */
-static void
-eti_remove_header_model (ETableItem *eti)
-{
- if (!eti->header)
- return;
-
- gtk_signal_disconnect (GTK_OBJECT (eti->header),
- eti->header_structure_change_id);
- gtk_signal_disconnect (GTK_OBJECT (eti->header),
- eti->header_dim_change_id);
-
- if (eti->cell_views){
- eti_unrealize_cell_views (eti);
- eti_detach_cell_views (eti);
- }
- gtk_object_unref (GTK_OBJECT (eti->header));
-
-
- eti->header_structure_change_id = 0;
- eti->header_dim_change_id = 0;
- eti->header = NULL;
-}
-
-/*
- * eti_row_height:
- *
- * Returns the height used by row @row. This does not include the one-pixel
- * used as a separator between rows
- */
-static int
-eti_row_height (ETableItem *eti, int row)
-{
- const int cols = e_table_header_count (eti->header);
- int col;
- int h, max_h;
-
- g_assert (eti->cell_views);
-
- max_h = 0;
-
- for (col = 0; col < cols; col++){
- ETableCol *ecol = e_table_header_get_column (eti->header, col);
-
- h = e_cell_height (eti->cell_views [col], ecol->col_idx, col, row);
-
- if (h > max_h)
- max_h = h;
- }
- return max_h;
-}
-
-/*
- * eti_get_height:
- *
- * Returns the height of the ETableItem.
- *
- * The ETableItem might compute the whole height by asking every row its
- * size. There is a special mode (designed to work when there are too
- * many rows in the table that performing the previous step could take
- * too long) set by the ETableItem->length_threshold that would determine
- * when the height is computed by using the first row as the size for
- * every other row in the ETableItem.
- */
-static int
-eti_get_height (ETableItem *eti)
-{
- const int rows = eti->rows;
- int row;
- int height;
-
- if (rows == 0)
- return 0;
-
- if (eti->length_threshold != -1){
- if (rows > eti->length_threshold){
- height = (eti_row_height (eti, 0) + 1) * rows;
-
- /*
- * 1 pixel at the top
- */
- return height + 1;
- }
- }
-
- height = 1;
- for (row = 0; row < rows; row++)
- height += eti_row_height (eti, row) + 1;
-
- return height;
-}
-
-static void
-eti_compute_height (ETableItem *eti)
-{
- int new_height = eti_get_height (eti);
-
- if (new_height != eti->height){
- double x1, y1, x2, y2;
- printf ("Emitting!\n");
-
- eti->height = new_height;
- eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0);
-
- gtk_signal_emit (GTK_OBJECT (eti), eti_signals [HEIGHT_CHANGED]);
- }
-}
-
-/*
- * Callback routine: invoked when the ETableModel has suffered a change
- */
-static void
-eti_table_model_changed (ETableModel *table_model, ETableItem *eti)
-{
- eti->rows = e_table_model_row_count (eti->table_model);
-
- if (eti->cell_views)
- eti_compute_height (eti);
-
- eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0);
-}
-
-static void
-eti_item_region_redraw (ETableItem *eti, int x0, int y0, int x1, int y1)
-{
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti);
- ArtDRect rect;
- double i2c [6];
-
- rect.x0 = x0;
- rect.y0 = y0;
- rect.x1 = x1;
- rect.y1 = y1;
-
- gnome_canvas_item_i2c_affine (item, i2c);
- art_drect_affine_transform (&rect, &rect, i2c);
-
- gnome_canvas_request_redraw (item->canvas, rect.x0, rect.y0, rect.x1, rect.y1);
-}
-
-/*
- * eti_request_redraw:
- *
- * Queues a canvas redraw for the entire ETableItem.
- */
-static void
-eti_request_redraw (ETableItem *eti)
-{
- eti_item_region_redraw (eti, eti->x1, eti->y1, eti->x1 + eti->width + 1, eti->y1 + eti->height + 1);
-}
-
-/*
- * Computes the distance between @start_row and @end_row in pixels
- */
-static int
-eti_row_diff (ETableItem *eti, int start_row, int end_row)
-{
- int row, total;
-
- total = 0;
-
- for (row = start_row; row < end_row; row++)
- total += eti_row_height (eti, row) + 1;
-
- return total;
-}
-
-/*
- * eti_request_region_redraw:
- *
- * Request a canvas redraw on the range (start_col, start_row) to (end_col, end_row).
- * This is inclusive (ie, you can use: 0,0-0,0 to redraw the first cell).
- *
- * The @border argument is a number of pixels around the region that should also be queued
- * for redraw. This is typically used by the focus routines to queue a redraw for the
- * border as well.
- */
-static void
-eti_request_region_redraw (ETableItem *eti,
- int start_col, int start_row,
- int end_col, int end_row, int border)
-{
- int x1, y1, width, height;
-
- x1 = e_table_header_col_diff (eti->header, 0, start_col);
- y1 = eti_row_diff (eti, 0, start_row);
- width = e_table_header_col_diff (eti->header, start_col, end_col + 1);
- height = eti_row_diff (eti, start_row, end_row + 1);
-
- eti_item_region_redraw (eti, eti->x1 + x1 - border,
- eti->y1 + y1 - border,
- eti->x1 + x1 + width + 1 + border,
- eti->y1 + y1 + height + 1 + border);
-}
-
-static void
-eti_table_model_row_changed (ETableModel *table_model, int row, ETableItem *eti)
-{
- if (eti->renderers_can_change_size){
- eti_table_model_changed (table_model, eti);
- return;
- }
-
- eti_request_region_redraw (eti, 0, row, eti->cols, row, 0);
-}
-
-void
-e_table_item_redraw_range (ETableItem *eti,
- int start_col, int start_row,
- int end_col, int end_row)
-{
- int border;
-
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- if ((start_col == eti->focused_col) ||
- (end_col == eti->focused_col) ||
- (start_row == eti->focused_row) ||
- (end_row == eti->focused_row))
- border = 2;
- else
- border = 0;
-
- eti_request_region_redraw (eti, start_col, start_row, end_col, end_row, border);
-}
-
-static void
-eti_add_table_model (ETableItem *eti, ETableModel *table_model)
-{
- g_assert (eti->table_model == NULL);
-
- eti->table_model = table_model;
- gtk_object_ref (GTK_OBJECT (eti->table_model));
-
- eti->table_model_change_id = gtk_signal_connect (
- GTK_OBJECT (table_model), "model_changed",
- GTK_SIGNAL_FUNC (eti_table_model_changed), eti);
-
- eti->table_model_row_change_id = gtk_signal_connect (
- GTK_OBJECT (table_model), "model_row_changed",
- GTK_SIGNAL_FUNC (eti_table_model_row_changed), eti);
-
- if (eti->header){
- eti_detach_cell_views (eti);
- eti_attach_cell_views (eti);
- }
-
- eti_table_model_changed (table_model, eti);
-}
-
-static void
-eti_header_dim_changed (ETableHeader *eth, int col, ETableItem *eti)
-{
- eti_request_redraw (eti);
-
- eti->width = e_table_header_total_width (eti->header);
- eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0);
-
- eti_request_redraw (eti);
-}
-
-static void
-eti_header_structure_changed (ETableHeader *eth, ETableItem *eti)
-{
- eti_request_redraw (eti);
-
- eti->cols = e_table_header_count (eti->header);
- eti->width = e_table_header_total_width (eti->header);
-
- if (eti->cell_views){
- eti_unrealize_cell_views (eti);
- eti_detach_cell_views (eti);
- eti_attach_cell_views (eti);
- eti_realize_cell_views (eti);
- } else {
- if (eti->table_model){
- eti_detach_cell_views (eti);
- eti_attach_cell_views (eti);
- }
- }
-
- eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0);
-
- eti_request_redraw (eti);
-}
-
-static void
-eti_add_header_model (ETableItem *eti, ETableHeader *header)
-{
- g_assert (eti->header == NULL);
-
- eti->header = header;
- gtk_object_ref (GTK_OBJECT (header));
-
- eti_header_structure_changed (header, eti);
-
- eti->header_dim_change_id = gtk_signal_connect (
- GTK_OBJECT (header), "dimension_change",
- GTK_SIGNAL_FUNC (eti_header_dim_changed), eti);
-
- eti->header_structure_change_id = gtk_signal_connect (
- GTK_OBJECT (header), "structure_change",
- GTK_SIGNAL_FUNC (eti_header_structure_changed), eti);
-}
-
-/*
- * GtkObject::destroy method
- */
-static void
-eti_destroy (GtkObject *object)
-{
- ETableItem *eti = E_TABLE_ITEM (object);
-
- eti_remove_header_model (eti);
- eti_remove_table_model (eti);
-
- g_slist_free (eti->selection);
-
- if (GTK_OBJECT_CLASS (eti_parent_class)->destroy)
- (*GTK_OBJECT_CLASS (eti_parent_class)->destroy) (object);
-}
-
-static void
-eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- ETableItem *eti;
-
- item = GNOME_CANVAS_ITEM (o);
- eti = E_TABLE_ITEM (o);
-
- switch (arg_id){
- case ARG_TABLE_HEADER:
- eti_remove_header_model (eti);
- eti_add_header_model (eti, GTK_VALUE_POINTER (*arg));
- break;
-
- case ARG_TABLE_MODEL:
- eti_remove_table_model (eti);
- eti_add_table_model (eti, GTK_VALUE_POINTER (*arg));
- break;
-
- case ARG_TABLE_X:
- eti->x1 = GTK_VALUE_DOUBLE (*arg);
- break;
-
- case ARG_TABLE_Y:
- eti->y1 = GTK_VALUE_DOUBLE (*arg);
- break;
-
- case ARG_LENGHT_THRESHOLD:
- eti->length_threshold = GTK_VALUE_INT (*arg);
- break;
-
- case ARG_TABLE_DRAW_GRID:
- eti->draw_grid = GTK_VALUE_BOOL (*arg);
- break;
-
- case ARG_TABLE_DRAW_FOCUS:
- eti->draw_focus = GTK_VALUE_BOOL (*arg);
- break;
-
- case ARG_MODE_SPREADSHEET:
- eti->mode_spreadsheet = GTK_VALUE_BOOL (*arg);
- break;
- }
- eti_update (item, NULL, NULL, 0);
-}
-
-static void
-eti_init (GnomeCanvasItem *item)
-{
- ETableItem *eti = E_TABLE_ITEM (item);
-
- eti->focused_col = -1;
- eti->focused_row = -1;
- eti->editing_col = -1;
- eti->editing_row = -1;
- eti->height = 0;
-
- eti->length_threshold = -1;
- eti->renderers_can_change_size = 0;
-
- eti->selection_mode = GTK_SELECTION_SINGLE;
-}
-
-#define gray50_width 2
-#define gray50_height 2
-static const char gray50_bits[] = {
- 0x02, 0x01, };
-
-static void
-eti_realize (GnomeCanvasItem *item)
-{
- ETableItem *eti = E_TABLE_ITEM (item);
- GtkWidget *canvas_widget = GTK_WIDGET (item->canvas);
- GdkWindow *window;
-
- if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize)
- (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize)(item);
-
- /*
- * Gdk Resource allocation
- */
- window = canvas_widget->window;
-
- eti->fill_gc = canvas_widget->style->white_gc;
- gdk_gc_ref (canvas_widget->style->white_gc);
-
- eti->grid_gc = gdk_gc_new (window);
-#if 0
- /* This sets it to gray */
-/* gdk_gc_set_foreground (eti->grid_gc, &canvas_widget->style->bg [GTK_STATE_NORMAL]); */
-#else
- gdk_gc_set_foreground (eti->grid_gc, &canvas_widget->style->black);
-#endif
- eti->focus_gc = gdk_gc_new (window);
- gdk_gc_set_foreground (eti->focus_gc, &canvas_widget->style->bg [GTK_STATE_NORMAL]);
- gdk_gc_set_background (eti->focus_gc, &canvas_widget->style->fg [GTK_STATE_NORMAL]);
- eti->stipple = gdk_bitmap_create_from_data (NULL, gray50_bits, gray50_width, gray50_height);
- gdk_gc_set_ts_origin (eti->focus_gc, 0, 0);
- gdk_gc_set_stipple (eti->focus_gc, eti->stipple);
- gdk_gc_set_fill (eti->focus_gc, GDK_OPAQUE_STIPPLED);
-
- if (eti->cell_views == NULL)
- eti_attach_cell_views (eti);
-
- eti_realize_cell_views (eti);
-
- eti_compute_height (eti);
-
- eti_update (item, NULL, NULL, 0);
-}
-
-static void
-eti_unrealize (GnomeCanvasItem *item)
-{
- ETableItem *eti = E_TABLE_ITEM (item);
-
- gdk_gc_unref (eti->fill_gc);
- eti->fill_gc = NULL;
- gdk_gc_unref (eti->grid_gc);
- eti->grid_gc = NULL;
- gdk_gc_unref (eti->focus_gc);
- eti->focus_gc = NULL;
- gdk_bitmap_unref (eti->stipple);
- eti->stipple = NULL;
-
- eti_unrealize_cell_views (eti);
-
- eti->height = 0;
-
- if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->unrealize)
- (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->unrealize)(item);
-}
-
-static void
-eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height)
-{
- ETableItem *eti = E_TABLE_ITEM (item);
- const int rows = eti->rows;
- const int cols = eti->cols;
- int row, col, y1, y2;
- int first_col, last_col, x_offset;
- int first_row, last_row, y_offset, yd;
- int x1, x2;
- int f_x1, f_x2, f_y1, f_y2;
- gboolean f_found;
- double i2c [6];
- ArtPoint eti_base, eti_base_item;
-
- /*
- * Clear the background
- */
-#if 0
- gdk_draw_rectangle (
- drawable, eti->fill_gc, TRUE,
- eti->x1 - x, eti->y1 - y, eti->width, eti->height);
-#endif
-
- /*
- * Find out our real position after grouping
- */
- gnome_canvas_item_i2c_affine (item, i2c);
- eti_base_item.x = eti->x1;
- eti_base_item.y = eti->y1;
- art_affine_point (&eti_base, &eti_base_item, i2c);
-
- /*
- * First column to draw, last column to draw
- */
- first_col = -1;
- last_col = x_offset = 0;
- x1 = x2 = floor (eti_base.x);
- for (col = 0; col < cols; col++, x1 = x2){
- ETableCol *ecol = e_table_header_get_column (eti->header, col);
-
- x2 = x1 + ecol->width;
-
- if (x1 > (x + width))
- break;
- if (x2 < x)
- continue;
- if (first_col == -1){
- x_offset = x1 - x;
- first_col = col;
- }
- }
- last_col = col;
-
- /*
- * Nothing to paint
- */
- if (first_col == -1)
- return;
-
- /*
- * Compute row span.
- */
- first_row = -1;
- y_offset = 0;
- y1 = y2 = floor (eti_base.y) + 1;
- for (row = 0; row < rows; row++, y1 = y2){
-
- y2 += eti_row_height (eti, row) + 1;
-
- if (y1 > y + height)
- break;
-
- if (y2 < y)
- continue;
-
- if (first_row == -1){
- y_offset = y1 - y;
- first_row = row;
- }
- }
- last_row = row;
-
- if (first_row == -1)
- return;
-
- /*
- * Draw cells
- */
- yd = y_offset;
- f_x1 = f_x2 = f_y1 = f_y2 = -1;
- f_found = FALSE;
-
- if (eti->draw_grid && first_row == 0){
- gdk_draw_line (
- drawable, eti->grid_gc,
- eti_base.x - x, yd, eti_base.x + eti->width - x, yd);
- }
- yd++;
-
- for (row = first_row; row < last_row; row++){
- int xd, height;
- gboolean selected;
-
- height = eti_row_height (eti, row);
-
- xd = x_offset;
-/* printf ("paint: %d %d\n", yd, yd + height); */
-
- selected = g_slist_find (eti->selection, GINT_TO_POINTER (row)) != NULL;
-
- for (col = first_col; col < last_col; col++){
- ETableCol *ecol = e_table_header_get_column (eti->header, col);
- ECellView *ecell_view = eti->cell_views [col];
-
- e_cell_draw (ecell_view, drawable, ecol->col_idx, col, row, selected,
- xd, yd, xd + ecol->width, yd + height);
-
- if (col == eti->focused_col && row == eti->focused_row){
- f_x1 = xd;
- f_x2 = xd + ecol->width;
- f_y1 = yd;
- f_y2 = yd + height;
- f_found = TRUE;
- }
-
- xd += ecol->width;
- }
- yd += height;
-
- if (eti->draw_grid)
- gdk_draw_line (
- drawable, eti->grid_gc,
- eti_base.x - x, yd, eti_base.x + eti->width - x, yd);
- yd++;
- }
-
- if (eti->draw_grid){
- int xd = x_offset;
-
- for (col = first_col; col <= last_col; col++){
- ETableCol *ecol = e_table_header_get_column (eti->header, col);
-
- gdk_draw_line (
- drawable, eti->grid_gc,
- xd, y_offset, xd, yd - 1);
-
- /*
- * This looks wierd, but it is to draw the last line
- */
- if (ecol)
- xd += ecol->width;
- }
- }
-
- /*
- * Draw focus
- */
- if (f_found && eti->draw_focus){
-
- if (!eti_editing (eti))
- gdk_draw_rectangle (
- drawable, eti->focus_gc, FALSE,
- f_x1 + 1, f_y1, f_x2 - f_x1 - 2, f_y2 - f_y1 - 1);
- }
-}
-
-static double
-eti_point (GnomeCanvasItem *item, double x, double y, int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- *actual_item = item;
-
- return 0.0;
-}
-
-static gboolean
-find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, double *x1_res, double *y1_res)
-{
- const int cols = eti->cols;
- const int rows = eti->rows;
- gdouble x1, y1, x2, y2;
- int col, row;
-
- /* FIXME: this routine is inneficient, fix later */
-
- x -= eti->x1;
- y -= eti->y1;
-
- x1 = 0;
- for (col = 0; col < cols; col++, x1 = x2){
- ETableCol *ecol = e_table_header_get_column (eti->header, col);
-
- if (x < x1)
- return FALSE;
-
- x2 = x1 + ecol->width;
-
- if (x > x2)
- continue;
-
- *col_res = col;
- if (x1_res)
- *x1_res = x - x1;
- break;
- }
-
- y1 = y2 = 0;
- for (row = 0; row < rows; row++, y1 = y2){
- if (y < y1)
- return FALSE;
-
- y2 += eti_row_height (eti, row) + 1;
-
- if (y > y2)
- continue;
-
- *row_res = row;
- if (y1_res)
- *y1_res = y - y1;
- break;
- }
-
- return TRUE;
-}
-
-static void
-eti_cursor_move_left (ETableItem *eti)
-{
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->focused_col - 1, eti->focused_row);
-}
-
-static void
-eti_cursor_move_right (ETableItem *eti)
-{
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->focused_col + 1, eti->focused_row);
-}
-
-static void
-eti_cursor_move_up (ETableItem *eti)
-{
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->focused_col, eti->focused_row - 1);
-}
-
-static void
-eti_cursor_move_down (ETableItem *eti)
-{
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->focused_col, eti->focused_row + 1);
-}
-
-static int
-eti_event (GnomeCanvasItem *item, GdkEvent *e)
-{
- ETableItem *eti = E_TABLE_ITEM (item);
- ECellView *ecell_view;
- ETableCol *ecol;
-
- switch (e->type){
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- case GDK_2BUTTON_PRESS: {
- double x1, y1;
- int col, row;
-
- gnome_canvas_item_w2i (item, &e->button.x, &e->button.y);
-
- if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1))
- return TRUE;
-
- if (eti->focused_row == row && eti->focused_col == col){
-
- ecol = e_table_header_get_column (eti->header, col);
- ecell_view = eti->cell_views [col];
-
- /*
- * Adjust the event positions
- */
- e->button.x = x1;
- e->button.y = y1;
-
- e_cell_event (ecell_view, e, ecol->col_idx, col, row);
- } else {
- /*
- * Focus the cell, and select the row
- */
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, col, row);
- e_table_item_select_row (eti, row);
- }
- break;
- }
-
- case GDK_MOTION_NOTIFY: {
- int col, row;
- double x1, y1;
-
- gnome_canvas_item_w2i (item, &e->button.x, &e->button.y);
-
- if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1))
- return TRUE;
-
- if (eti->focused_row == row && eti->focused_col == col){
- ecol = e_table_header_get_column (eti->header, col);
- ecell_view = eti->cell_views [col];
-
- /*
- * Adjust the event positions
- */
- e->button.x -= (x1 + eti->x1);
- e->button.y -= (y1 + eti->y1);
-
- e_cell_event (ecell_view, e, ecol->col_idx, col, row);
- }
- break;
- }
-
- case GDK_KEY_PRESS:
- if (eti->focused_col == -1)
- return FALSE;
-
- switch (e->key.keyval){
- case GDK_Left:
- if (!eti->mode_spreadsheet && eti_editing (eti))
- break;
-
- if (eti->focused_col > 0)
- eti_cursor_move_left (eti);
-
- return TRUE;
-
- case GDK_Right:
- if (!eti->mode_spreadsheet && eti_editing (eti))
- break;
-
- if ((eti->focused_col + 1) < eti->cols)
- eti_cursor_move_right (eti);
- return TRUE;
-
- case GDK_Up:
- if (eti->focused_row > 0)
- eti_cursor_move_up (eti);
- return TRUE;
-
- case GDK_Down:
- if ((eti->focused_row + 1) < eti->rows)
- eti_cursor_move_down (eti);
-
- return TRUE;
-
- case GDK_Tab:
- if ((e->key.state & GDK_SHIFT_MASK) != 0){
- /* shift tab */
- if (eti->focused_col > 0)
- eti_cursor_move_left (eti);
- else if (eti->focused_row > 0){
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, eti->cols - 1, eti->focused_row - 1);
- } else {
- /* FIXME: request focus leave backward */
- }
- } else {
- if ((eti->focused_col + 1) < eti->cols)
- eti_cursor_move_right (eti);
- else if ((eti->focused_row + 1) < eti->rows){
- e_table_item_leave_edit (eti);
- e_table_item_focus (eti, 0, eti->rows - 1);
- } else {
- /* FIXME: request focus leave forward */
- }
- }
- break;
-
- default:
- if (!eti_editing (eti)){
- if ((e->key.state & (GDK_MOD1_MASK | GDK_CONTROL_MASK)) != 0)
- return 0;
-
- if (!(e->key.keyval >= 0x20 && e->key.keyval <= 0xff))
- return 0;
- }
- }
-
- ecol = e_table_header_get_column (eti->header, eti->focused_col);
- ecell_view = eti->cell_views [eti->focused_col];
- e_cell_event (ecell_view, e, ecol->col_idx, eti->focused_col, eti->focused_row);
- break;
-
- case GDK_KEY_RELEASE:
- if (eti->focused_col == -1)
- return FALSE;
-
- if (eti_editing (eti)){
- ecell_view = eti->cell_views [eti->editing_col];
- ecol = e_table_header_get_column (eti->header, eti->editing_col);
- e_cell_event (ecell_view, e, ecol->col_idx, eti->editing_col, eti->editing_row);
- }
- break;
-
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-/*
- * ETableItem::row_selection method
- */
-static void
-eti_row_selection (ETableItem *eti, int row, gboolean selected)
-{
- eti_request_region_redraw (eti, 0, row, eti->cols - 1, row, 0);
-
- if (selected)
- eti->selection = g_slist_prepend (eti->selection, GINT_TO_POINTER (row));
- else
- eti->selection = g_slist_remove (eti->selection, GINT_TO_POINTER (row));
-
-}
-
-static void
-eti_class_init (GtkObjectClass *object_class)
-{
- GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class;
- ETableItemClass *eti_class = (ETableItemClass *) object_class;
-
- eti_parent_class = gtk_type_class (PARENT_OBJECT_TYPE);
-
- object_class->destroy = eti_destroy;
- object_class->set_arg = eti_set_arg;
-
- item_class->update = eti_update;
- item_class->realize = eti_realize;
- item_class->unrealize = eti_unrealize;
- item_class->draw = eti_draw;
- item_class->point = eti_point;
- item_class->event = eti_event;
- item_class->bounds = eti_bounds;
-
- eti_class->row_selection = eti_row_selection;
-
- gtk_object_add_arg_type ("ETableItem::ETableHeader", GTK_TYPE_POINTER,
- GTK_ARG_WRITABLE, ARG_TABLE_HEADER);
- gtk_object_add_arg_type ("ETableItem::ETableModel", GTK_TYPE_POINTER,
- GTK_ARG_WRITABLE, ARG_TABLE_MODEL);
- gtk_object_add_arg_type ("ETableItem::x", GTK_TYPE_DOUBLE,
- GTK_ARG_WRITABLE, ARG_TABLE_X);
- gtk_object_add_arg_type ("ETableItem::y", GTK_TYPE_DOUBLE,
- GTK_ARG_WRITABLE, ARG_TABLE_Y);
- gtk_object_add_arg_type ("ETableItem::drawgrid", GTK_TYPE_BOOL,
- GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID);
- gtk_object_add_arg_type ("ETableItem::drawfocus", GTK_TYPE_BOOL,
- GTK_ARG_WRITABLE, ARG_TABLE_DRAW_FOCUS);
- gtk_object_add_arg_type ("ETableItem::spreadsheet", GTK_TYPE_BOOL,
- GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET);
-
- eti_signals [ROW_SELECTION] =
- gtk_signal_new ("row_selection",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableItemClass, row_selection),
- gtk_marshal_NONE__INT_INT,
- GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
-
- eti_signals [HEIGHT_CHANGED] =
- gtk_signal_new ("height_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableItemClass, height_changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, eti_signals, LAST_SIGNAL);
-
-}
-
-GtkType
-e_table_item_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableItem",
- sizeof (ETableItem),
- sizeof (ETableItemClass),
- (GtkClassInitFunc) eti_class_init,
- (GtkObjectInitFunc) eti_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (PARENT_OBJECT_TYPE, &info);
- }
-
- return type;
-}
-
-void
-e_table_item_focus (ETableItem *eti, int col, int row)
-{
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- if (eti->focused_col != -1)
- e_table_item_unfocus (eti);
-
- eti->focused_col = col;
- eti->focused_row = row;
-
- eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER);
-
- /*
- * make sure we have the Gtk Focus
- */
- gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (eti));
-}
-
-void
-e_table_item_unfocus (ETableItem *eti)
-{
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- if (eti->focused_row == -1)
- return;
-
- {
- const int col = eti->focused_col;
- const int row = eti->focused_row;
-
- eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER);
- }
- eti->focused_col = -1;
- eti->focused_row = -1;
-}
-
-const GSList *
-e_table_item_get_selection (ETableItem *eti)
-{
- g_return_val_if_fail (eti != NULL, NULL);
- g_return_val_if_fail (E_IS_TABLE_ITEM (eti), NULL);
-
- return eti->selection;
-}
-
-GtkSelectionMode
-e_table_item_get_selection_mode (ETableItem *eti)
-{
- g_return_val_if_fail (eti != NULL, GTK_SELECTION_SINGLE);
- g_return_val_if_fail (E_IS_TABLE_ITEM (eti), GTK_SELECTION_SINGLE);
-
- return eti->selection_mode;
-}
-
-void
-e_table_item_set_selection_mode (ETableItem *eti, GtkSelectionMode selection_mode)
-{
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- if (selection_mode == GTK_SELECTION_BROWSE ||
- selection_mode == GTK_SELECTION_EXTENDED){
- g_error ("GTK_SELECTION_BROWSE and GTK_SELECTION_EXTENDED are not implemented");
- }
-
- eti->selection_mode = selection_mode;
-}
-
-gboolean
-e_table_item_is_row_selected (ETableItem *eti, int row)
-{
- g_return_val_if_fail (eti != NULL, FALSE);
- g_return_val_if_fail (E_IS_TABLE_ITEM (eti), FALSE);
-
- if (g_slist_find (eti->selection, GINT_TO_POINTER (row)))
- return TRUE;
- else
- return FALSE;
-}
-
-void
-e_table_item_unselect_row (ETableItem *eti, int row)
-{
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- if (e_table_item_is_row_selected (eti, row)){
- gtk_signal_emit (
- GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
- row, 0);
- }
-}
-
-void
-e_table_item_select_row (ETableItem *eti, int row)
-{
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- switch (eti->selection_mode){
- case GTK_SELECTION_SINGLE:
- if (eti->selection){
- gtk_signal_emit (
- GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
- GPOINTER_TO_INT (eti->selection->data), 0);
- }
- g_slist_free (eti->selection);
- eti->selection = NULL;
-
- gtk_signal_emit (
- GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
- GINT_TO_POINTER (row), 1);
- break;
-
- case GTK_SELECTION_MULTIPLE:
- if (g_slist_find (eti->selection, GINT_TO_POINTER (row)))
- return;
- gtk_signal_emit (
- GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
- GINT_TO_POINTER (row), 1);
- break;
-
- default:
-
- }
-}
-
-void
-e_table_item_enter_edit (ETableItem *eti, int col, int row)
-{
- ETableCol *ecol;
-
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- eti->editing_col = col;
- eti->editing_row = row;
-
- ecol = e_table_header_get_column (eti->header, col);
- eti->edit_ctx = e_cell_enter_edit (eti->cell_views [col], ecol->col_idx, col, row);
-}
-
-void
-e_table_item_leave_edit (ETableItem *eti)
-{
- ETableCol *ecol;
-
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- if (!eti_editing (eti))
- return;
-
- ecol = e_table_header_get_column (eti->header, eti->editing_col);
- e_cell_leave_edit (
- eti->cell_views [eti->editing_col],
- ecol->col_idx, eti->editing_col,
- eti->editing_row, eti->edit_ctx);
- eti->editing_col = -1;
- eti->editing_row = -1;
- eti->edit_ctx = NULL;
-}
-
diff --git a/widgets/table/e-table-item.h b/widgets/table/e-table-item.h
deleted file mode 100644
index f19819f2fc..0000000000
--- a/widgets/table/e-table-item.h
+++ /dev/null
@@ -1,106 +0,0 @@
-#ifndef _E_TABLE_ITEM_H_
-#define _E_TABLE_ITEM_H_
-
-#include <libgnomeui/gnome-canvas.h>
-#include "e-table-model.h"
-#include "e-table-header.h"
-
-#define E_TABLE_ITEM_TYPE (e_table_item_get_type ())
-#define E_TABLE_ITEM(o) (GTK_CHECK_CAST ((o), E_TABLE_ITEM_TYPE, ETableItem))
-#define E_TABLE_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_ITEM_TYPE, ETableItemClass))
-#define E_IS_TABLE_ITEM(o) (GTK_CHECK_TYPE ((o), E_TABLE_ITEM_TYPE))
-#define E_IS_TABLE_ITEM_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_ITEM_TYPE))
-
-typedef struct {
- GnomeCanvasItem parent;
- ETableModel *table_model;
- ETableHeader *header;
-
- int x1, y1;
- int width, height;
-
- int cols, rows;
-
- /*
- * Ids for the signals we connect to
- */
- int header_dim_change_id;
- int header_structure_change_id;
- int table_model_change_id;
- int table_model_row_change_id;
-
- GdkGC *fill_gc;
- GdkGC *grid_gc;
- GdkGC *focus_gc;
- GdkBitmap *stipple;
-
- unsigned int draw_grid:1;
- unsigned int draw_focus:1;
- unsigned int mode_spreadsheet:1;
- unsigned int renderers_can_change_size:1;
- unsigned int cell_views_realized:1;
-
- int focused_col, focused_row;
-
- /*
- * Realized views, per column
- */
- ECellView **cell_views;
- int n_cells;
-
- /*
- * Lengh Threshold: above this, we stop computing correctly
- * the size
- */
- int length_threshold;
-
- GSList *selection;
- GtkSelectionMode selection_mode;
-
- /*
- * During edition
- */
- int editing_col, editing_row;
- void *edit_ctx;
-} ETableItem;
-
-typedef struct {
- GnomeCanvasItemClass parent_class;
-
- void (*row_selection) (ETableItem *eti, int row, gboolean selected);
- void (*height_changed) (ETableItem *eti);
-} ETableItemClass;
-
-GtkType e_table_item_get_type (void);
-
-/*
- * Focus
- */
-void e_table_item_focus (ETableItem *eti, int col, int row);
-void e_table_item_unfocus (ETableItem *eti);
-
-/*
- * Selection
- */
-void e_table_item_select_row (ETableItem *e_table_Item, int row);
-void e_table_item_unselect_row (ETableItem *e_table_Item, int row);
-
-/*
- * Handling the selection
- */
-const GSList*e_table_item_get_selection (ETableItem *e_table_Item);
-
-GtkSelectionMode e_table_item_get_selection_mode (ETableItem *e_table_Item);
-void e_table_item_set_selection_mode (ETableItem *e_table_Item,
- GtkSelectionMode selection_mode);
-gboolean e_table_item_is_row_selected (ETableItem *e_table_Item,
- int row);
-
-void e_table_item_leave_edit (ETableItem *eti);
-void e_table_item_enter_edit (ETableItem *eti, int col, int row);
-
-void e_table_item_redraw_range (ETableItem *eti,
- int start_col, int start_row,
- int end_col, int end_row);
-
-#endif /* _E_TABLE_ITEM_H_ */
diff --git a/widgets/table/e-table-model.c b/widgets/table/e-table-model.c
deleted file mode 100644
index 9e397710ef..0000000000
--- a/widgets/table/e-table-model.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * e-table-model.c: a Table Model
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc.
- */
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include "e-table-model.h"
-
-#define ETM_CLASS(e) ((ETableModelClass *)((GtkObject *)e)->klass)
-
-static GtkObjectClass *e_table_model_parent_class;
-
-enum {
- MODEL_CHANGED,
- MODEL_ROW_CHANGED,
- MODEL_CELL_CHANGED,
- ROW_SELECTION,
- LAST_SIGNAL
-};
-
-static guint e_table_model_signals [LAST_SIGNAL] = { 0, };
-
-int
-e_table_model_column_count (ETableModel *e_table_model)
-{
- g_return_val_if_fail (e_table_model != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), 0);
-
- return ETM_CLASS (e_table_model)->column_count (e_table_model);
-}
-
-
-int
-e_table_model_row_count (ETableModel *e_table_model)
-{
- g_return_val_if_fail (e_table_model != NULL, 0);
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), 0);
-
- return ETM_CLASS (e_table_model)->row_count (e_table_model);
-}
-
-void *
-e_table_model_value_at (ETableModel *e_table_model, int col, int row)
-{
- g_return_val_if_fail (e_table_model != NULL, NULL);
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), NULL);
-
- return ETM_CLASS (e_table_model)->value_at (e_table_model, col, row);
-}
-
-void
-e_table_model_set_value_at (ETableModel *e_table_model, int col, int row, const void *data)
-{
- g_return_if_fail (e_table_model != NULL);
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
-
- ETM_CLASS (e_table_model)->set_value_at (e_table_model, col, row, data);
-
- gtk_signal_emit (GTK_OBJECT (e_table_model),
- e_table_model_signals [MODEL_ROW_CHANGED], row);
- gtk_signal_emit (GTK_OBJECT (e_table_model),
- e_table_model_signals [MODEL_CELL_CHANGED], col, row);
-
- /*
- * Notice that "model_changed" is not emitted
- */
-}
-
-gboolean
-e_table_model_is_cell_editable (ETableModel *e_table_model, int col, int row)
-{
- g_return_val_if_fail (e_table_model != NULL, FALSE);
- g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), FALSE);
-
- return ETM_CLASS (e_table_model)->is_cell_editable (e_table_model, col, row);
-}
-
-static void
-e_table_model_destroy (GtkObject *object)
-{
- if (e_table_model_parent_class->destroy)
- (*e_table_model_parent_class->destroy)(object);
-}
-
-static void
-e_table_model_class_init (GtkObjectClass *object_class)
-{
- e_table_model_parent_class = gtk_type_class (gtk_object_get_type ());
-
- object_class->destroy = e_table_model_destroy;
-
- e_table_model_signals [MODEL_CHANGED] =
- gtk_signal_new ("model_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableModelClass, model_changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- e_table_model_signals [MODEL_ROW_CHANGED] =
- gtk_signal_new ("model_row_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableModelClass, model_row_changed),
- gtk_marshal_NONE__INT,
- GTK_TYPE_NONE, 1, GTK_TYPE_INT);
-
- e_table_model_signals [MODEL_CELL_CHANGED] =
- gtk_signal_new ("model_cell_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETableModelClass, model_cell_changed),
- gtk_marshal_NONE__INT_INT,
- GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, e_table_model_signals, LAST_SIGNAL);
-}
-
-GtkType
-e_table_model_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableModel",
- sizeof (ETableModel),
- sizeof (ETableModelClass),
- (GtkClassInitFunc) e_table_model_class_init,
- (GtkObjectInitFunc) NULL,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (gtk_object_get_type (), &info);
- }
-
- return type;
-}
-
-void
-e_table_model_changed (ETableModel *e_table_model)
-{
- g_return_if_fail (e_table_model != NULL);
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
-
- gtk_signal_emit (GTK_OBJECT (e_table_model),
- e_table_model_signals [MODEL_CHANGED]);
-}
-
-void
-e_table_model_row_changed (ETableModel *e_table_model, int row)
-{
- g_return_if_fail (e_table_model != NULL);
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
-
- gtk_signal_emit (GTK_OBJECT (e_table_model),
- e_table_model_signals [MODEL_ROW_CHANGED], row);
-}
-
-void
-e_table_model_cell_changed (ETableModel *e_table_model, int col, int row)
-{
- g_return_if_fail (e_table_model != NULL);
- g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
-
- gtk_signal_emit (GTK_OBJECT (e_table_model),
- e_table_model_signals [MODEL_CELL_CHANGED], col, row);
-}
-
-
diff --git a/widgets/table/e-table-model.h b/widgets/table/e-table-model.h
deleted file mode 100644
index 2d08f3744e..0000000000
--- a/widgets/table/e-table-model.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef _E_TABLE_MODEL_H_
-#define _E_TABLE_MODEL_H_
-
-#include <gtk/gtkobject.h>
-
-#define E_TABLE_MODEL_TYPE (e_table_model_get_type ())
-#define E_TABLE_MODEL(o) (GTK_CHECK_CAST ((o), E_TABLE_MODEL_TYPE, ETableModel))
-#define E_TABLE_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_MODEL_TYPE, ETableModelClass))
-#define E_IS_TABLE_MODEL(o) (GTK_CHECK_TYPE ((o), E_TABLE_MODEL_TYPE))
-#define E_IS_TABLE_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_MODEL_TYPE))
-
-typedef struct {
- GtkObject base;
-} ETableModel;
-
-typedef struct {
- GtkObjectClass parent_class;
-
- /*
- * Virtual methods
- */
- int (*column_count) (ETableModel *etm);
- int (*row_count) (ETableModel *etm);
- void *(*value_at) (ETableModel *etm, int col, int row);
- void (*set_value_at) (ETableModel *etm, int col, int row, const void *value);
- gboolean (*is_cell_editable) (ETableModel *etm, int col, int row);
-
- /*
- * Signals
- */
-
- /*
- * Major structural changes: model_changed
- * Changes only in a row: row_changed
- * Only changes in a cell: cell_changed
- */
- void (*model_changed) (ETableModel *etm);
- void (*model_row_changed) (ETableModel *etm, int row);
- void (*model_cell_changed) (ETableModel *etm, int col, int row);
-} ETableModelClass;
-
-GtkType e_table_model_get_type (void);
-
-int e_table_model_column_count (ETableModel *e_table_model);
-const char *e_table_model_column_name (ETableModel *e_table_model, int col);
-int e_table_model_row_count (ETableModel *e_table_model);
-void *e_table_model_value_at (ETableModel *e_table_model, int col, int row);
-void e_table_model_set_value_at (ETableModel *e_table_model, int col, int row, const void *data);
-gboolean e_table_model_is_cell_editable (ETableModel *e_table_model, int col, int row);
-
-/*
- * Routines for emitting signals on the e_table
- */
-void e_table_model_changed (ETableModel *e_table_model);
-void e_table_model_row_changed (ETableModel *e_table_model, int row);
-void e_table_model_cell_changed (ETableModel *e_table_model, int col, int row);
-
-#endif /* _E_TABLE_MODEL_H_ */
diff --git a/widgets/table/e-table-render.c b/widgets/table/e-table-render.c
deleted file mode 100644
index 49d742132b..0000000000
--- a/widgets/table/e-table-render.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * E-table-render.c: Various renderers
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * Copyright 1999, Helix Code, Inc.
- */
-#include <config.h>
-#include "e-table-header.h"
-#include "e-table-header-item.h"
-#include "e-table-col.h"
-#include "e-table-render.h"
-
-void
-e_table_render_string (ERenderContext *ctxt)
-{
- printf ("Rendering string: %s\n", ctxt->render_data);
-}
-
diff --git a/widgets/table/e-table-render.h b/widgets/table/e-table-render.h
deleted file mode 100644
index ebc65968f0..0000000000
--- a/widgets/table/e-table-render.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef E_TABLE_RENDER_H
-#define E_TABLE_RENDER_H
-
-#include <libgnomeui/gnome-canvas.h>
-
-struct ERenderContext {
- ETableCol *etc;
- int row;
- int base_x, base_y;
- GnomeCanvasItem *gnome_canvas_item;
- GdkDrawable *drawable;
- int drawable_width;
- int drawable_height;
- void *render_data;
- void *closure;
-};
-
-void e_table_render_string (ERenderContext *ctxt);
-
-
-#endif
diff --git a/widgets/table/e-table-simple.c b/widgets/table/e-table-simple.c
deleted file mode 100644
index 38e1dd8eb0..0000000000
--- a/widgets/table/e-table-simple.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * e-table-model.c: a simple table model implementation that uses function
- * pointers to simplify the creation of new, exotic and colorful tables in
- * no time.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc.
- */
-
-#include <config.h>
-#include "e-table-simple.h"
-
-#define PARENT_TYPE e_table_model_get_type()
-
-static int
-simple_column_count (ETableModel *etm)
-{
- ETableSimple *simple = (ETableSimple *)etm;
-
- return simple->col_count (etm, simple->data);
-}
-
-static int
-simple_row_count (ETableModel *etm)
-{
- ETableSimple *simple = (ETableSimple *)etm;
-
- return simple->row_count (etm, simple->data);
-}
-
-static void *
-simple_value_at (ETableModel *etm, int col, int row)
-{
- ETableSimple *simple = (ETableSimple *)etm;
-
- return simple->value_at (etm, col, row, simple->data);
-}
-
-static void
-simple_set_value_at (ETableModel *etm, int col, int row, const void *val)
-{
- ETableSimple *simple = (ETableSimple *)etm;
-
- simple->set_value_at (etm, col, row, val, simple->data);
-}
-
-static gboolean
-simple_is_cell_editable (ETableModel *etm, int col, int row)
-{
- ETableSimple *simple = (ETableSimple *)etm;
-
- return simple->is_cell_editable (etm, col, row, simple->data);
-}
-
-static void
-e_table_simple_class_init (GtkObjectClass *object_class)
-{
- ETableModelClass *model_class = (ETableModelClass *) object_class;
-
- model_class->column_count = simple_column_count;
- model_class->row_count = simple_row_count;
- model_class->value_at = simple_value_at;
- model_class->set_value_at = simple_set_value_at;
- model_class->is_cell_editable = simple_is_cell_editable;
-}
-
-GtkType
-e_table_simple_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type){
- GtkTypeInfo info = {
- "ETableSimple",
- sizeof (ETableSimple),
- sizeof (ETableSimpleClass),
- (GtkClassInitFunc) e_table_simple_class_init,
- (GtkObjectInitFunc) NULL,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- type = gtk_type_unique (PARENT_TYPE, &info);
- }
-
- return type;
-}
-
-ETableModel *
-e_table_simple_new (ETableSimpleColumnCountFn col_count,
- ETableSimpleRowCountFn row_count,
- ETableSimpleValueAtFn value_at,
- ETableSimpleSetValueAtFn set_value_at,
- ETableSimpleIsCellEditableFn is_cell_editable,
- void *data)
-{
- ETableSimple *et;
-
- et = gtk_type_new (e_table_simple_get_type ());
-
- et->col_count = col_count;
- et->row_count = row_count;
- et->value_at = value_at;
- et->set_value_at = set_value_at;
- et->is_cell_editable = is_cell_editable;
- et->data = data;
-
- return (ETableModel *) et;
-}
diff --git a/widgets/table/e-table-simple.h b/widgets/table/e-table-simple.h
deleted file mode 100644
index d890245386..0000000000
--- a/widgets/table/e-table-simple.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _E_TABLE_SIMPLE_H_
-#define _E_TABLE_SIMPLE_H_
-
-#include "e-table-model.h"
-
-typedef int (*ETableSimpleColumnCountFn) (ETableModel *etm, void *data);
-typedef int (*ETableSimpleRowCountFn) (ETableModel *etm, void *data);
-typedef void *(*ETableSimpleValueAtFn) (ETableModel *etm, int col, int row, void *data);
-typedef void (*ETableSimpleSetValueAtFn) (ETableModel *etm, int col, int row, const void *val, void *data);
-typedef gboolean (*ETableSimpleIsCellEditableFn) (ETableModel *etm, int col, int row, void *data);
-
-typedef struct {
- ETableModel parent;
-
- ETableSimpleColumnCountFn col_count;
- ETableSimpleRowCountFn row_count;
- ETableSimpleValueAtFn value_at;
- ETableSimpleSetValueAtFn set_value_at;
- ETableSimpleIsCellEditableFn is_cell_editable;
- void *data;
-} ETableSimple;
-
-typedef struct {
- ETableModelClass parent_class;
-} ETableSimpleClass;
-
-GtkType e_table_simple_get_type (void);
-
-ETableModel *e_table_simple_new (ETableSimpleColumnCountFn col_count,
- ETableSimpleRowCountFn row_count,
- ETableSimpleValueAtFn value_at,
- ETableSimpleSetValueAtFn set_value_at,
- ETableSimpleIsCellEditableFn is_cell_editable,
- void *data);
-
-#endif /* _E_TABLE_SIMPLE_H_ */
-
diff --git a/widgets/table/e-table-sorted.c b/widgets/table/e-table-sorted.c
deleted file mode 100644
index 16644a45b1..0000000000
--- a/widgets/table/e-table-sorted.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * E-table-sorted.c: Implements a table that sorts another table
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc.
- */
-#include <config.h>
-#include <stdlib.h>
-#include "e-util/e-util.h"
-#include "e-table-sorted.h"
-
-#define PARENT_TYPE E_TABLE_SUBSET_TYPE
-
-static ETableModelClass *ets_parent_class;
-
-static void
-ets_class_init (GtkObjectClass *klass)
-{
- ets_parent_class = gtk_type_class (PARENT_TYPE);
-}
-
-E_MAKE_TYPE(e_table_sorted, "ETableSorted", ETableSorted, ets_class_init, NULL, PARENT_TYPE);
-
-static ETableSorted *sort_ets;
-
-static int
-my_sort (const void *a, const void *b)
-{
- ETableModel *source = E_TABLE_SUBSET (sort_ets)->source;
- const int *ia = (const int *) a;
- const int *ib = (const int *) b;
- void *va, *vb;
-
- va = e_table_model_value_at (source, sort_ets->sort_col, *ia);
- vb = e_table_model_value_at (source, sort_ets->sort_col, *ib);
-
- return (*sort_ets->compare) (va, vb);
-}
-
-static void
-do_sort (ETableSorted *ets)
-{
- ETableSubset *etss = E_TABLE_SUBSET (ets);
- g_assert (sort_ets == NULL);
-
- sort_ets = ets;
- qsort (etss->map_table, etss->n_map, sizeof (unsigned int), my_sort);
- sort_ets = NULL;
-}
-
-ETableModel *
-e_table_sorted_new (ETableModel *source, int col, GCompareFunc compare)
-{
- ETableSorted *ets = gtk_type_new (E_TABLE_SORTED_TYPE);
- ETableSubset *etss = E_TABLE_SUBSET (ets);
- const int nvals = e_table_model_row_count (source);
- int i;
-
- if (e_table_subset_construct (etss, source, nvals) == NULL){
- gtk_object_destroy (GTK_OBJECT (ets));
- return NULL;
- }
-
- ets->compare = compare;
- ets->sort_col = col;
-
- /* Init */
- for (i = 0; i < nvals; i++)
- etss->map_table [i] = i;
-
- do_sort (ets);
-
- return (ETableModel *) ets;
-}
-
-void
-e_table_sorted_resort (ETableSorted *ets, int col, GCompareFunc compare)
-{
- if (col == -1 || compare == NULL)
- do_sort (ets);
- else {
- ets->sort_col = col;
- ets->compare = compare;
- do_sort (ets);
- }
-}
-
diff --git a/widgets/table/e-table-sorted.h b/widgets/table/e-table-sorted.h
deleted file mode 100644
index 2ec52df2e7..0000000000
--- a/widgets/table/e-table-sorted.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef _E_TABLE_SORTED_H_
-#define _E_TABLE_SORTED_H_
-
-#include <gtk/gtkobject.h>
-#include "e-table-model.h"
-#include "e-table-subset.h"
-
-#define E_TABLE_SORTED_TYPE (e_table_sorted_get_type ())
-#define E_TABLE_SORTED(o) (GTK_CHECK_CAST ((o), E_TABLE_SORTED_TYPE, ETableSorted))
-#define E_TABLE_SORTED_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_SORTED_TYPE, ETableSortedClass))
-#define E_IS_TABLE_SORTED(o) (GTK_CHECK_TYPE ((o), E_TABLE_SORTED_TYPE))
-#define E_IS_TABLE_SORTED_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_SORTED_TYPE))
-
-typedef struct {
- ETableSubset base;
-
- short sort_col;
- GCompareFunc compare;
-} ETableSorted;
-
-typedef struct {
- ETableSubset parent_class;
-} ETableSortedClass;
-
-GtkType e_table_sorted_get_type (void);
-ETableModel *e_table_sorted_new (ETableModel *etm, int col, GCompareFunc compare);
-void e_table_sorted_resort (ETableSorted *ets, int col, GCompareFunc compare);
-
-#endif /* _E_TABLE_SORTED_H_ */
diff --git a/widgets/table/e-table-subset.c b/widgets/table/e-table-subset.c
deleted file mode 100644
index a9e4a5c5a4..0000000000
--- a/widgets/table/e-table-subset.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * E-table-subset.c: Implements a table that contains a subset of another table.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * (C) 1999 Helix Code, Inc.
- */
-#include <config.h>
-#include <stdlib.h>
-#include <gtk/gtksignal.h>
-#include "e-util/e-util.h"
-#include "e-table-subset.h"
-
-#define PARENT_TYPE E_TABLE_MODEL_TYPE
-
-static ETableModelClass *etss_parent_class;
-
-static void
-etss_destroy (GtkObject *object)
-{
- ETableSubset *etss = E_TABLE_SUBSET (object);
-
- if (etss->source)
- gtk_object_unref (GTK_OBJECT (etss->source));
-
- if (etss->map_table)
- free (etss->map_table);
-
- GTK_OBJECT_CLASS (etss_parent_class)->destroy (object);
-}
-
-static int
-etss_column_count (ETableModel *etm)
-{
- ETableSubset *etss = (ETableSubset *)etm;
-
- return e_table_model_column_count (etss->source);
-}
-
-static int
-etss_row_count (ETableModel *etm)
-{
- ETableSubset *etss = (ETableSubset *)etm;
-
- return etss->n_map;
-}
-
-static void *
-etss_value_at (ETableModel *etm, int col, int row)
-{
- ETableSubset *etss = (ETableSubset *)etm;
-
- return e_table_model_value_at (etss->source, col, etss->map_table [row]);
-}
-
-static void
-etss_set_value_at (ETableModel *etm, int col, int row, const void *val)
-{
- ETableSubset *etss = (ETableSubset *)etm;
-
- return e_table_model_set_value_at (etss->source, col, etss->map_table [row], val);
-}
-
-static gboolean
-etss_is_cell_editable (ETableModel *etm, int col, int row)
-{
- ETableSubset *etss = (ETableSubset *)etm;
-
- return e_table_model_is_cell_editable (etss->source, col, etss->map_table [row]);
-}
-
-static void
-etss_class_init (GtkObjectClass *klass)
-{
- ETableModelClass *table_class = (ETableModelClass *) klass;
-
- etss_parent_class = gtk_type_class (PARENT_TYPE);
-
- klass->destroy = etss_destroy;
-
- table_class->column_count = etss_column_count;
- table_class->row_count = etss_row_count;
- table_class->value_at = etss_value_at;
- table_class->set_value_at = etss_set_value_at;
- table_class->is_cell_editable = etss_is_cell_editable;
-}
-
-E_MAKE_TYPE(e_table_subset, "ETableSubset", ETableSubset, etss_class_init, NULL, PARENT_TYPE);
-
-static void
-etss_proxy_model_changed (ETableModel *etm, ETableSubset *etss)
-{
- e_table_model_changed (E_TABLE_MODEL (etss));
-}
-
-static void
-etss_proxy_model_row_changed (ETableModel *etm, int row, ETableSubset *etss)
-{
- const int n = etss->n_map;
- const int * const map_table = etss->map_table;
- int i;
-
- for (i = 0; i < n; i++){
- if (map_table [i] == row){
- e_table_model_row_changed (E_TABLE_MODEL (etss), i);
- return;
- }
- }
-}
-
-static void
-etss_proxy_model_cell_changed (ETableModel *etm, int col, int row, ETableSubset *etss)
-{
- const int n = etss->n_map;
- const int * const map_table = etss->map_table;
- int i;
-
- for (i = 0; i < n; i++){
- if (map_table [i] == row){
- e_table_model_cell_changed (E_TABLE_MODEL (etss), col, i);
- return;
- }
- }
-}
-
-ETableModel *
-e_table_subset_construct (ETableSubset *etss, ETableModel *source, int nvals)
-{
- unsigned int *buffer;
- int i;
-
- buffer = (unsigned int *) malloc (sizeof (unsigned int) * nvals);
- if (buffer == NULL)
- return NULL;
- etss->map_table = buffer;
- etss->n_map = nvals;
- etss->source = source;
- gtk_object_ref (GTK_OBJECT (source));
-
- /* Init */
- for (i = 0; i < nvals; i++)
- etss->map_table [i] = i;
-
- gtk_signal_connect (GTK_OBJECT (source), "model_changed",
- GTK_SIGNAL_FUNC (etss_proxy_model_changed), etss);
- gtk_signal_connect (GTK_OBJECT (source), "model_row_changed",
- GTK_SIGNAL_FUNC (etss_proxy_model_row_changed), etss);
- gtk_signal_connect (GTK_OBJECT (source), "model_cell_changed",
- GTK_SIGNAL_FUNC (etss_proxy_model_cell_changed), etss);
-
- return E_TABLE_MODEL (etss);
-}
-
-ETableModel *
-e_table_subset_new (ETableModel *source, const int nvals)
-{
- ETableSubset *etss = gtk_type_new (E_TABLE_SUBSET_TYPE);
-
- if (e_table_subset_construct (etss, source, nvals) == NULL){
- gtk_object_destroy (GTK_OBJECT (etss));
- return NULL;
- }
-
- return (ETableModel *) etss;
-}
-
-ETableModel *
-e_table_subset_get_toplevel (ETableSubset *table)
-{
- g_return_val_if_fail (table != NULL, NULL);
- g_return_val_if_fail (E_IS_TABLE_SUBSET (table), NULL);
-
- if (E_IS_TABLE_SUBSET (table->source))
- return e_table_subset_get_toplevel (E_TABLE_SUBSET (table->source));
- else
- return table->source;
-}
diff --git a/widgets/table/e-table-subset.h b/widgets/table/e-table-subset.h
deleted file mode 100644
index 314f28aea6..0000000000
--- a/widgets/table/e-table-subset.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef _E_TABLE_SUBSET_H_
-#define _E_TABLE_SUBSET_H_
-
-#include <gtk/gtkobject.h>
-#include "e-table-model.h"
-
-#define E_TABLE_SUBSET_TYPE (e_table_subset_get_type ())
-#define E_TABLE_SUBSET(o) (GTK_CHECK_CAST ((o), E_TABLE_SUBSET_TYPE, ETableSubset))
-#define E_TABLE_SUBSET_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_SUBSET_TYPE, ETableSubsetClass))
-#define E_IS_TABLE_SUBSET(o) (GTK_CHECK_TYPE ((o), E_TABLE_SUBSET_TYPE))
-#define E_IS_TABLE_SUBSET_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_SUBSET_TYPE))
-
-typedef struct {
- ETableModel base;
-
- ETableModel *source;
- int n_map;
- int *map_table;
-} ETableSubset;
-
-typedef struct {
- ETableModelClass parent_class;
-} ETableSubsetClass;
-
-GtkType e_table_subset_get_type (void);
-ETableModel *e_table_subset_new (ETableModel *etm, int n_vals);
-ETableModel *e_table_subset_construct (ETableSubset *ets, ETableModel *source, int nvals);
-
-ETableModel *e_table_subset_get_toplevel (ETableSubset *table_model);
-
-#endif /* _E_TABLE_SUBSET_H_ */
-
diff --git a/widgets/table/e-table-tree.h b/widgets/table/e-table-tree.h
deleted file mode 100644
index e7e125a6af..0000000000
--- a/widgets/table/e-table-tree.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef _E_TABLE_TREE_H_
-#define _E_TABLE_TREE_H_
-
-typedef struct {
- char *title;
-
- union {
- ETableModel *table;
- GList *children;
- } u;
-
- guint expanded :1;
- guint is_leaf :1;
-} ETableGroup;
-
-ETableGroup *e_table_group_new (const char *title, ETableModel *table);
-ETableGroup *e_table_group_new_leaf (const char *title);
-
-#endif /* _E_TABLE_TREE_H_ */
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
deleted file mode 100644
index a42aaf111b..0000000000
--- a/widgets/table/e-table.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * E-table-view.c: A graphical view of a Table.
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- *
- * Copyright 1999, Helix Code, Inc
- */
-#include <config.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <alloca.h>
-#include <stdio.h>
-#include <libgnomeui/gnome-canvas.h>
-#include <gtk/gtksignal.h>
-#include "e-util/e-util.h"
-#include "e-table.h"
-#include "e-table-header-item.h"
-#include "e-table-subset.h"
-#include "e-table-item.h"
-#include "e-table-group.h"
-
-#define COLUMN_HEADER_HEIGHT 16
-#define TITLE_HEIGHT 16
-#define GROUP_INDENT 10
-
-#define PARENT_TYPE gtk_table_get_type ()
-
-static GtkObjectClass *e_table_parent_class;
-
-static void
-et_destroy (GtkObject *object)
-{
- ETable *et = E_TABLE (object);
-
- gtk_object_unref (GTK_OBJECT (et->model));
- gtk_object_unref (GTK_OBJECT (et->full_header));
- gtk_object_unref (GTK_OBJECT (et->header));
-
- g_free (et->group_spec);
-
- (*e_table_parent_class->destroy)(object);
-}
-
-static void
-e_table_init (GtkObject *object)
-{
- ETable *e_table = E_TABLE (object);
-
- e_table->draw_grid = 1;
- e_table->draw_focus = 1;
- e_table->spreadsheet = 1;
-}
-
-static ETableHeader *
-e_table_make_header (ETable *e_table, ETableHeader *full_header, const char *cols)
-{
- ETableHeader *nh;
- char *copy = alloca (strlen (cols) + 1);
- char *p, *state;
- const int max_cols = e_table_header_count (full_header);
-
- nh = e_table_header_new ();
- strcpy (copy, cols);
- while ((p = strtok_r (copy, ",", &state)) != NULL){
- int col = atoi (p);
-
- copy = NULL;
- if (col >= max_cols)
- continue;
-
- e_table_header_add_column (nh, e_table_header_get_column (full_header, col), -1);
- }
-
- return nh;
-}
-
-static void
-header_canvas_size_alocate (GtkWidget *widget, GtkAllocation *alloc, ETable *e_table)
-{
- gnome_canvas_set_scroll_region (
- GNOME_CANVAS (e_table->header_canvas),
- 0, 0, alloc->width, COLUMN_HEADER_HEIGHT);
-}
-
-static void
-e_table_setup_header (ETable *e_table)
-{
- e_table->header_canvas = GNOME_CANVAS (gnome_canvas_new ());
-
- gtk_widget_show (GTK_WIDGET (e_table->header_canvas));
-
- e_table->header_item = gnome_canvas_item_new (
- gnome_canvas_root (e_table->header_canvas),
- e_table_header_item_get_type (),
- "ETableHeader", e_table->header,
- "x", 0,
- "y", 0,
- NULL);
-
- gtk_signal_connect (
- GTK_OBJECT (e_table->header_canvas), "size_allocate",
- GTK_SIGNAL_FUNC (header_canvas_size_alocate), e_table);
-
- gtk_widget_set_usize (GTK_WIDGET (e_table->header_canvas), -1, COLUMN_HEADER_HEIGHT);
-
- gtk_table_attach (
- GTK_TABLE (e_table), GTK_WIDGET (e_table->header_canvas),
- 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
-
-}
-
-typedef struct {
- void *value;
- GArray *array;
-} group_key_t;
-
-static GArray *
-e_table_create_groups (ETableModel *etm, int key_col, GCompareFunc comp)
-{
- GArray *groups;
- const int rows = e_table_model_row_count (etm);
- int row, i;
-
- groups = g_array_new (FALSE, FALSE, sizeof (group_key_t));
-
- for (row = 0; row < rows; row++){
- void *val = e_table_model_value_at (etm, key_col, row);
- const int n_groups = groups->len;
-
- /*
- * Should replace this with a bsearch later
- */
- for (i = 0; i < n_groups; i++){
- group_key_t *g = &g_array_index (groups, group_key_t, i);
-
- if ((*comp) (g->value, val)){
- g_array_append_val (g->array, row);
- break;
- }
- }
- if (i != n_groups)
- continue;
-
- /*
- * We need to create a new group
- */
- {
- group_key_t gk;
-
- gk.value = val;
- gk.array = g_array_new (FALSE, FALSE, sizeof (int));
-
- g_array_append_val (gk.array, row);
- g_array_append_val (groups, gk);
- }
- }
-
- return groups;
-}
-
-static void
-e_table_destroy_groups (GArray *groups)
-{
- const int n = groups->len;
- int i;
-
- for (i = 0; i < n; i++){
- group_key_t *g = &g_array_index (groups, group_key_t, i);
-
- g_array_free (g->array, TRUE);
- }
- g_array_free (groups, TRUE);
-}
-
-static ETableModel **
-e_table_make_subtables (ETableModel *model, GArray *groups)
-{
- const int n_groups = groups->len;
- ETableModel **tables;
- int i;
-
- tables = g_new (ETableModel *, n_groups+1);
-
- for (i = 0; i < n_groups; i++){
- group_key_t *g = &g_array_index (groups, group_key_t, i);
- const int sub_size = g->array->len;
- ETableSubset *ss;
- int j;
-
- tables [i] = e_table_subset_new (model, sub_size);
- ss = E_TABLE_SUBSET (tables [i]);
-
- for (j = 0; j < sub_size; j++)
- ss->map_table [j] = g_array_index (g->array, int, j);
- }
- tables [i] = NULL;
-
- return (ETableModel **) tables;
-}
-
-typedef struct _Node Node;
-
-struct _Node {
- Node *parent;
- GnomeCanvasItem *item;
- ETableModel *table_model;
- GSList *children;
-
- guint is_leaf:1;
-};
-
-static Node *
-leaf_new (GnomeCanvasItem *table_item, ETableModel *table_model, Node *parent)
-{
- Node *node = g_new (Node, 1);
-
- g_assert (table_item != NULL);
- g_assert (table_model != NULL);
- g_assert (parent != NULL);
-
- node->item = table_item;
- node->parent = parent;
- node->table_model = table_model;
- node->is_leaf = 1;
-
- g_assert (!parent->is_leaf);
-
- parent->children = g_slist_append (parent->children, node);
-
- e_table_group_add (E_TABLE_GROUP (parent->item), table_item);
-
- return node;
-}
-
-static Node *
-node_new (GnomeCanvasItem *group_item, ETableModel *table_model, Node *parent)
-{
- Node *node = g_new (Node, 1);
-
- g_assert (table_model != NULL);
-
- node->children = NULL;
- node->item = group_item;
- node->parent = parent;
- node->table_model = table_model;
- node->is_leaf = 0;
-
- if (parent){
- parent->children = g_slist_append (parent->children, node);
-
- e_table_group_add (E_TABLE_GROUP (parent->item), group_item);
- }
-
- return node;
-}
-
-static Node *
-e_table_create_leaf (ETable *e_table, ETableModel *etm, Node *parent)
-{
- GnomeCanvasItem *table_item;
- static double last_y;
- Node *leaf;
-
- table_item = gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (parent->item),
- e_table_item_get_type (),
- "ETableHeader", e_table->header,
- "ETableModel", etm,
- "drawgrid", e_table->draw_grid,
- "drawfocus", e_table->draw_focus,
- "spreadsheet", e_table->spreadsheet,
- NULL);
-
- leaf = leaf_new (table_item, etm, parent);
-
- return leaf;
-}
-
-static int
-leaf_height (Node *leaf)
-{
- const GnomeCanvasItem *item = leaf->item;
-
- return item->y2 - item->y1;
-}
-
-static int
-leaf_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- static int last_x = -1;
- static int last_y = -1;
-
- if (event->type == GDK_BUTTON_PRESS){
- last_x = event->button.x;
- last_y = event->button.y;
- } else if (event->type == GDK_BUTTON_RELEASE){
- last_x = -1;
- last_y = -1;
- } else if (event->type == GDK_MOTION_NOTIFY){
- if (last_x == -1)
- return FALSE;
-
- gnome_canvas_item_move (item, event->motion.x - last_x, event->motion.y - last_y);
- last_x = event->motion.x;
- last_y = event->motion.y;
- } else
- return FALSE;
- return TRUE;
-}
-
-static Node *
-e_table_create_nodes (ETable *e_table, ETableModel *model, ETableHeader *header,
- GnomeCanvasGroup *root, Node *parent, int *groups_list)
-{
- GArray *groups;
- ETableModel **tables;
- ETableCol *ecol;
- int key_col, i;
- GnomeCanvasItem *group_item;
- Node *group;
-
- key_col = *groups_list;
- g_assert (key_col != -1);
-
- /*
- * Create groups
- */
- ecol = e_table_header_get_column (header, key_col);
-
- g_assert (ecol != NULL);
-
- groups = e_table_create_groups (model, key_col, ecol->compare);
- tables = e_table_make_subtables (e_table->model, groups);
- e_table_destroy_groups (groups);
-
- group_item = e_table_group_new (root, ecol, TRUE, parent == NULL);
- group = node_new (group_item, model, parent);
-
- for (i = 0; tables [i] != NULL; i++){
- Node *node;
-
- /*
- * Leafs
- */
- if (groups_list [1] == -1){
- GnomeCanvasItem *item_leaf_header;
- Node *leaf_header;
-
- item_leaf_header = e_table_group_new (
- GNOME_CANVAS_GROUP (group_item), ecol, TRUE, FALSE);
- leaf_header = node_new (item_leaf_header, tables [i], group);
-
- e_table_create_leaf (e_table, tables [i], leaf_header);
- } else {
- e_table_create_nodes (
- e_table, tables [i], header, GNOME_CANVAS_GROUP (group_item),
- group, &groups_list [1]);
- }
- }
-
- return group;
-}
-
-static int *
-group_spec_to_desc (const char *group_spec)
-{
- int a_size = 10;
- int *elements;
- char *p, *copy, *follow;
- int n_elements = 0;
-
- if (group_spec == NULL)
- return NULL;
-
- elements = g_new (int, a_size);
- copy = alloca (strlen (group_spec) + 1);
- strcpy (copy, group_spec);
-
- while ((p = strtok_r (copy, ",", &follow)) != NULL){
- elements [n_elements] = atoi (p);
- ++n_elements;
- if (n_elements+1 == a_size){
- int *new_e;
-
- n_elements += 10;
- new_e = g_renew (int, elements, n_elements);
- if (new_e == NULL){
- g_free (elements);
- return NULL;
- }
- elements = new_e;
- }
- copy = NULL;
- }
-
- /* Tag end */
- elements [n_elements] = -1;
-
- return elements;
-}
-
-/*
- * The ETableCanvas object is just used to enable us to
- * hook up to the realize/unrealize phases of the canvas
- * initialization (as laying out the subtables requires us to
- * know the actual size of the subtables we are inserting
- */
-
-#define E_TABLE_CANVAS_PARENT_TYPE gnome_canvas_get_type ()
-
-typedef struct {
- GnomeCanvas base;
-
- ETable *e_table;
-} ETableCanvas;
-
-typedef struct {
- GnomeCanvasClass base_class;
-} ETableCanvasClass;
-
-static GnomeCanvasClass *e_table_canvas_parent_class;
-
-static void
-e_table_canvas_realize (GtkWidget *widget)
-{
- ETableCanvas *e_table_canvas = (ETableCanvas *) widget;
- ETable *e_table = e_table_canvas->e_table;
- int *groups;
- Node *leaf;
-
- GTK_WIDGET_CLASS (e_table_canvas_parent_class)->realize (widget);
-
- groups = group_spec_to_desc (e_table->group_spec);
-
- e_table->root = gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (e_table->table_canvas->root),
- gnome_canvas_group_get_type (),
- "x", 0.0,
- "y", 0.0,
- NULL);
-
- leaf = e_table_create_nodes (
- e_table, e_table->model,
- e_table->header, GNOME_CANVAS_GROUP (e_table->root), 0, groups);
-
- gnome_canvas_set_scroll_region (
- GNOME_CANVAS (e_table_canvas),
- 0, 0,
- e_table_header_total_width (e_table->header) + 200,
- leaf_height (leaf));
-
- if (groups)
- g_free (groups);
-}
-
-static void
-e_table_canvas_unrealize (GtkWidget *widget)
-{
- ETableCanvas *e_table_canvas = (ETableCanvas *) widget;
- ETable *e_table = e_table_canvas->e_table;
-
- gtk_object_destroy (GTK_OBJECT (e_table->root));
- e_table->root = NULL;
-
- GTK_WIDGET_CLASS (e_table_canvas_parent_class)->unrealize (widget);
-}
-
-static void
-e_table_canvas_class_init (GtkObjectClass *object_class)
-{
- GtkWidgetClass *widget_class = (GtkWidgetClass *) object_class;
-
- widget_class->realize = e_table_canvas_realize;
- widget_class->unrealize = e_table_canvas_unrealize;
-
- e_table_canvas_parent_class = gtk_type_class (E_TABLE_CANVAS_PARENT_TYPE);
-}
-
-static void
-e_table_canvas_init (GtkObject *canvas)
-{
- GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS);
-}
-
-GtkType e_table_canvas_get_type (void);
-
-E_MAKE_TYPE (e_table_canvas, "ETableCanvas", ETableCanvas, e_table_canvas_class_init,
- e_table_canvas_init, E_TABLE_CANVAS_PARENT_TYPE);
-
-static GnomeCanvas *
-e_table_canvas_new (ETable *e_table)
-{
- ETableCanvas *e_table_canvas;
-
- e_table_canvas = gtk_type_new (e_table_canvas_get_type ());
- e_table_canvas->e_table = e_table;
-
- return GNOME_CANVAS (e_table_canvas);
-}
-
-static void
-e_table_setup_table (ETable *e_table)
-{
- e_table->table_canvas = e_table_canvas_new (e_table);
-
- gtk_widget_show (GTK_WIDGET (e_table->table_canvas));
- gtk_table_attach (
- GTK_TABLE (e_table), GTK_WIDGET (e_table->table_canvas),
- 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
-}
-
-void
-e_table_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm,
- const char *cols_spec, const char *group_spec)
-{
- GTK_TABLE (e_table)->homogeneous = FALSE;
-
- gtk_table_resize (GTK_TABLE (e_table), 1, 2);
-
- e_table->full_header = full_header;
- gtk_object_ref (GTK_OBJECT (full_header));
-
- e_table->model = etm;
- gtk_object_ref (GTK_OBJECT (etm));
-
- e_table->header = e_table_make_header (e_table, full_header, cols_spec);
-
- e_table_setup_header (e_table);
- e_table_setup_table (e_table);
-
- e_table->group_spec = g_strdup (group_spec);
-
-}
-
-GtkWidget *
-e_table_new (ETableHeader *full_header, ETableModel *etm, const char *cols_spec, const char *group_spec)
-{
- ETable *e_table;
-
- e_table = gtk_type_new (e_table_get_type ());
-
- e_table_construct (e_table, full_header, etm, cols_spec, group_spec);
-
- return (GtkWidget *) e_table;
-}
-
-static void
-e_table_class_init (GtkObjectClass *object_class)
-{
- e_table_parent_class = gtk_type_class (PARENT_TYPE);
-
- object_class->destroy = et_destroy;
-}
-
-E_MAKE_TYPE(e_table, "ETable", ETable, e_table_class_init, e_table_init, PARENT_TYPE);
-
diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h
deleted file mode 100644
index 63c131324f..0000000000
--- a/widgets/table/e-table.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef _E_TABLE_H_
-#define _E_TABLE_H_
-
-#include <libgnomeui/gnome-canvas.h>
-#include <gtk/gtktable.h>
-#include "e-table-model.h"
-#include "e-table-header.h"
-
-BEGIN_GNOME_DECLS
-
-#define E_TABLE_TYPE (e_table_get_type ())
-#define E_TABLE(o) (GTK_CHECK_CAST ((o), E_TABLE_TYPE, ETable))
-#define E_TABLE_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_TYPE, ETableClass))
-#define E_IS_TABLE(o) (GTK_CHECK_TYPE ((o), E_TABLE_TYPE))
-#define E_IS_TABLE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_TYPE))
-
-typedef struct {
- GtkTable parent;
-
- ETableModel *model;
-
- ETableHeader *full_header, *header;
-
- GnomeCanvas *header_canvas, *table_canvas;
-
- GnomeCanvasItem *header_item, *root;
-
- guint draw_grid:1;
- guint draw_focus:1;
- guint spreadsheet:1;
-
- char *group_spec;
-} ETable;
-
-typedef struct {
- GtkTableClass parent_class;
-} ETableClass;
-
-GtkType e_table_get_type (void);
-void e_table_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm,
- const char *cols_spec, const char *group_spec);
-GtkWidget *e_table_new (ETableHeader *full_header, ETableModel *etm,
- const char *cols_spec, const char *group_spec);
-
-
-END_GNOME_DECLS
-
- #endif /* _E_TABLE_H_ */
diff --git a/widgets/table/image1.png b/widgets/table/image1.png
deleted file mode 100644
index 8326ac241f..0000000000
--- a/widgets/table/image1.png
+++ /dev/null
Binary files differ
diff --git a/widgets/table/image2.png b/widgets/table/image2.png
deleted file mode 100644
index e6a4c75dbe..0000000000
--- a/widgets/table/image2.png
+++ /dev/null
Binary files differ
diff --git a/widgets/table/image3.png b/widgets/table/image3.png
deleted file mode 100644
index 50e16e8620..0000000000
--- a/widgets/table/image3.png
+++ /dev/null
Binary files differ
diff --git a/widgets/table/remove-col.xpm b/widgets/table/remove-col.xpm
deleted file mode 100644
index ff1024f0c9..0000000000
--- a/widgets/table/remove-col.xpm
+++ /dev/null
@@ -1,22 +0,0 @@
-/* XPM */
-static char * remove_col_xpm[] = {
-"16 16 3 1",
-" c None",
-". c #000000",
-"+ c #FF0000",
-"... ...",
-".++. .++.",
-".+++. .+++.",
-" .+++. .+++. ",
-" .+++. .+++. ",
-" .+++..+++. ",
-" .++++++. ",
-" .++++. ",
-" .++++. ",
-" .++++++. ",
-" .+++..+++. ",
-" .+++. .+++. ",
-" .+++. .+++. ",
-".+++. .+++.",
-".++. .++.",
-"... ..."};
diff --git a/widgets/table/sample.table b/widgets/table/sample.table
deleted file mode 100644
index 45c8ff0691..0000000000
--- a/widgets/table/sample.table
+++ /dev/null
@@ -1,11 +0,0 @@
-Col1 Col2 Address Title Dorks
-c1.a c2.a a.a tit-1 DorkA
-c1.b c2.b a.b tit-2 DDork
-c1.c c2.c a.c tit-1 DorkB
-c1.d c2.d a.d tit-2 ADork
-c1.e c2.e a.e tit-1 DorkC
-c1.f c2.f a.f tit-2 UDork
-c1.g c2.g a.g tit-3 Dork---
-j k k tit-1 DorkA
-
-
diff --git a/widgets/table/table-test.c b/widgets/table/table-test.c
deleted file mode 100644
index e18f38c5ec..0000000000
--- a/widgets/table/table-test.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Test code for the ETable package
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- */
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <gnome.h>
-#include "e-util/e-cursors.h"
-#include "table-test.h"
-
-int
-main (int argc, char *argv [])
-{
-
- if (isatty (0)){
- int fd;
-
- close (0);
- fd = open ("sample.table", O_RDONLY);
- if (fd == -1){
- fprintf (stderr, "Could not find sample.table, try feeding a table on stdin");
- exit (1);
- }
- dup2 (fd, 0);
- }
-
- gnome_init ("TableTest", "TableTest", argc, argv);
- e_cursors_init ();
-
- table_browser_test ();
- multi_cols_test ();
- check_test ();
- e_table_test ();
-
- gtk_main ();
-
- e_cursors_shutdown ();
- return 0;
-}
diff --git a/widgets/table/table-test.h b/widgets/table/table-test.h
deleted file mode 100644
index ad8cfcc083..0000000000
--- a/widgets/table/table-test.h
+++ /dev/null
@@ -1,4 +0,0 @@
-void table_browser_test (void);
-void multi_cols_test (void);
-void check_test (void);
-void e_table_test (void);
diff --git a/widgets/table/test-check.c b/widgets/table/test-check.c
deleted file mode 100644
index 8cc5f6834e..0000000000
--- a/widgets/table/test-check.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Test code for the ETable package
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- */
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <gnome.h>
-#include "e-table-simple.h"
-#include "e-table-header.h"
-#include "e-table-header-item.h"
-#include "e-table-item.h"
-#include "e-util/e-cursors.h"
-#include "e-cell-text.h"
-#include "e-cell-checkbox.h"
-
-#include "table-test.h"
-
-#define LINES 4
-
-static struct {
- int value;
- char *string;
-} my_table [LINES] = {
- { 0, "Buy food" },
- { 1, "Breathe " },
- { 0, "Cancel gdb session with shrink" },
- { 1, "Make screenshots" },
-};
-/*
- * ETableSimple callbacks
- */
-static int
-col_count (ETableModel *etc, void *data)
-{
- return 2;
-}
-
-static int
-row_count (ETableModel *etc, void *data)
-{
- return LINES;
-}
-
-static void *
-value_at (ETableModel *etc, int col, int row, void *data)
-{
- g_assert (col < 2);
- g_assert (row < LINES);
-
- if (col == 0)
- return GINT_TO_POINTER (my_table [row].value);
- else
- return my_table [row].string;
-
-}
-
-static void
-set_value_at (ETableModel *etc, int col, int row, const void *val, void *data)
-{
- g_assert (col < 2);
- g_assert (row < LINES);
-
- if (col == 0){
- my_table [row].value = GPOINTER_TO_INT (val);
- printf ("Value at %d,%d set to %d\n", col, row, GPOINTER_TO_INT (val));
- } else {
- my_table [row].string = g_strdup (val);
- printf ("Value at %d,%d set to %s\n", col, row, (char *) val);
- }
-}
-
-static gboolean
-is_cell_editable (ETableModel *etc, int col, int row, void *data)
-{
- return TRUE;
-}
-
-static void
-set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc)
-{
- gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height);
-}
-
-void
-check_test (void)
-{
- GtkWidget *canvas, *window;
- ETableModel *e_table_model;
- ETableHeader *e_table_header;
- ETableCol *col_0, *col_1;
- ECell *cell_left_just, *cell_image_check;
-
- gtk_widget_push_visual (gdk_rgb_get_visual ());
- gtk_widget_push_colormap (gdk_rgb_get_cmap ());
-
- e_table_model = e_table_simple_new (
- col_count, row_count, value_at,
- set_value_at, is_cell_editable, NULL);
-
- /*
- * Header
- */
- e_table_header = e_table_header_new ();
-
- cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT);
-
- cell_image_check = e_cell_checkbox_new ();
- col_0 = e_table_col_new (0, "", 18, 18, cell_image_check, g_int_equal, TRUE);
- e_table_header_add_column (e_table_header, col_0, 0);
-
- col_1 = e_table_col_new (1, "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
- e_table_header_add_column (e_table_header, col_1, 1);
-
- /*
- * GUI
- */
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- canvas = gnome_canvas_new ();
-
- gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate",
- GTK_SIGNAL_FUNC (set_canvas_size), NULL);
-
- gtk_container_add (GTK_CONTAINER (window), canvas);
- gtk_widget_show_all (window);
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_header_item_get_type (),
- "ETableHeader", e_table_header,
- "x", 0,
- "y", 0,
- NULL);
-
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_item_get_type (),
- "ETableHeader", e_table_header,
- "ETableModel", e_table_model,
- "x", (double) 0,
- "y", (double) 30,
- "drawgrid", TRUE,
- "drawfocus", TRUE,
- "spreadsheet", TRUE,
- NULL);
-
-}
-
-
-
-
-
diff --git a/widgets/table/test-cols.c b/widgets/table/test-cols.c
deleted file mode 100644
index 288e2bd408..0000000000
--- a/widgets/table/test-cols.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Test code for the ETable package
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- */
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <gnome.h>
-#include "e-util/e-cursors.h"
-#include "e-table-simple.h"
-#include "e-table-header.h"
-#include "e-table-header-item.h"
-#include "e-table-item.h"
-#include "e-cell-text.h"
-#include "e-cell-toggle.h"
-
-#include "table-test.h"
-
-#define LINES 4
-
-static struct {
- int value;
- char *string;
-} my_table [LINES] = {
- { 0, "You are not" },
- { 1, "A beautiful and unique " },
- { 0, "Snowflake" },
- { 2, "You are not your wallet" },
-};
-/*
- * ETableSimple callbacks
- */
-static int
-col_count (ETableModel *etc, void *data)
-{
- return 2;
-}
-
-static int
-row_count (ETableModel *etc, void *data)
-{
- return LINES;
-}
-
-static void *
-value_at (ETableModel *etc, int col, int row, void *data)
-{
- g_assert (col < 2);
- g_assert (row < LINES);
-
- if (col == 0)
- return GINT_TO_POINTER (my_table [row].value);
- else
- return my_table [row].string;
-
-}
-
-static void
-set_value_at (ETableModel *etc, int col, int row, const void *val, void *data)
-{
- g_assert (col < 2);
- g_assert (row < LINES);
-
- if (col == 0){
- my_table [row].value = GPOINTER_TO_INT (val);
- printf ("Value at %d,%d set to %d\n", col, row, GPOINTER_TO_INT (val));
- } else {
- my_table [row].string = g_strdup (val);
- printf ("Value at %d,%d set to %s\n", col, row, (char *) val);
- }
-}
-
-static gboolean
-is_cell_editable (ETableModel *etc, int col, int row, void *data)
-{
- return TRUE;
-}
-
-static void
-set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc)
-{
- gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height);
-}
-
-void
-multi_cols_test (void)
-{
- GtkWidget *canvas, *window;
- ETableModel *e_table_model;
- ETableHeader *e_table_header, *e_table_header_multiple;
- ETableCol *col_0, *col_1;
- ECell *cell_left_just, *cell_image_toggle;
-
- gtk_widget_push_visual (gdk_rgb_get_visual ());
- gtk_widget_push_colormap (gdk_rgb_get_cmap ());
-
- e_table_model = e_table_simple_new (
- col_count, row_count, value_at,
- set_value_at, is_cell_editable, NULL);
-
- /*
- * Header
- */
- e_table_header = e_table_header_new ();
-
- cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT);
-
- {
- GdkPixbuf **images = g_new (GdkPixbuf *, 3);
- int i;
-
- images [0] = gdk_pixbuf_new_from_file ("image1.png");
- images [1] = gdk_pixbuf_new_from_file ("image2.png");
- images [2] = gdk_pixbuf_new_from_file ("image3.png");
-
- cell_image_toggle = e_cell_toggle_new (0, 3, images);
-
- for (i = 0; i < 3; i++)
- gdk_pixbuf_unref (images [i]);
-
- g_free (images);
- }
-
- col_1 = e_table_col_new (1, "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
- e_table_header_add_column (e_table_header, col_1, 0);
-
- col_0 = e_table_col_new (0, "A", 48, 48, cell_image_toggle, g_int_equal, TRUE);
- e_table_header_add_column (e_table_header, col_0, 1);
-
- /*
- * Second test
- */
- e_table_header_multiple = e_table_header_new ();
- e_table_header_add_column (e_table_header_multiple, col_0, 0);
- e_table_header_add_column (e_table_header_multiple, col_1, 1);
- e_table_header_add_column (e_table_header_multiple, col_1, 2);
-
- /*
- * GUI
- */
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- canvas = gnome_canvas_new ();
-
- gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate",
- GTK_SIGNAL_FUNC (set_canvas_size), NULL);
-
- gtk_container_add (GTK_CONTAINER (window), canvas);
- gtk_widget_show_all (window);
-
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_header_item_get_type (),
- "ETableHeader", e_table_header,
- "x", 0,
- "y", 0,
- NULL);
-
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_item_get_type (),
- "ETableHeader", e_table_header,
- "ETableModel", e_table_model,
- "x", (double) 0,
- "y", (double) 30,
- "drawgrid", TRUE,
- "drawfocus", TRUE,
- "spreadsheet", TRUE,
- NULL);
-
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_header_item_get_type (),
- "ETableHeader", e_table_header_multiple,
- "x", 300,
- "y", 0,
- NULL);
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_item_get_type (),
- "ETableHeader", e_table_header_multiple,
- "ETableModel", e_table_model,
- "x", (double) 300,
- "y", (double) 30,
- "drawgrid", TRUE,
- "drawfocus", TRUE,
- "spreadsheet", TRUE,
- NULL);
-
-}
-
-
-
-
-
diff --git a/widgets/table/test-table.c b/widgets/table/test-table.c
deleted file mode 100644
index 053f81cfa6..0000000000
--- a/widgets/table/test-table.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Test code for the ETable package
- *
- * Author:
- * Miguel de Icaza (miguel@gnu.org)
- */
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <gnome.h>
-#include "e-util/e-cursors.h"
-#include "e-table-simple.h"
-#include "e-table-header.h"
-#include "e-table-header-item.h"
-#include "e-table-item.h"
-#include "e-cell-text.h"
-#include "e-table.h"
-
-#include "table-test.h"
-
-char buffer [1024];
-char **column_labels;
-char ***table_data;
-int cols = 0;
-int lines = 0;
-int lines_alloc = 0;
-
-static void
-parse_headers ()
-{
- char *p, *s;
- int in_value = 0, i;
-
- fgets (buffer, sizeof (buffer)-1, stdin);
-
- for (p = buffer; *p; p++){
- if (*p == ' ' || *p == '\t'){
- if (in_value){
- cols++;
- in_value = 0;
- }
- } else
- in_value = 1;
- }
- if (in_value)
- cols++;
-
- if (!cols){
- fprintf (stderr, "No columns in first row\n");
- exit (1);
- }
-
- column_labels = g_new0 (char *, cols);
-
- p = buffer;
- for (i = 0; (s = strtok (p, " \t")) != NULL; i++){
- column_labels [i] = g_strdup (s);
- p = NULL;
- }
-
- printf ("%d headers:\n", cols);
- for (i = 0; i < cols; i++){
- printf ("header %d: %s\n", i, column_labels [i]);
- }
-}
-
-static char **
-load_line (char *buffer, int cols)
-{
- char **line = g_new0 (char *, cols);
- char *p;
- int i;
-
- for (i = 0; i < cols; i++){
- p = strtok (buffer, " \t\n");
- if (p == NULL){
- for (; i < cols; i++)
- line [i] = g_strdup ("");
- return line;
- } else
- line [i] = g_strdup (p);
- buffer = NULL;
- }
- return line;
-}
-
-static void
-append_line (char **line)
-{
- if (lines <= lines_alloc){
- lines_alloc = lines + 50;
- table_data = g_renew (char **, table_data, lines_alloc);
- }
- table_data [lines] = line;
- lines++;
-}
-
-static void
-load_data ()
-{
- int i;
-
- {
- static int loaded;
-
- if (loaded)
- return;
-
- loaded = TRUE;
- }
-
-
- parse_headers ();
-
- while (fgets (buffer, sizeof (buffer)-1, stdin) != NULL){
- char **line;
-
- if (buffer [0] == '\n')
- continue;
- line = load_line (buffer, cols);
- append_line (line);
- }
-
- for (i = 0; i < lines; i++){
- int j;
-
- printf ("Line %d: ", i);
- for (j = 0; j < cols; j++)
- printf ("[%s] ", table_data [i][j]);
- printf ("\n");
- }
-}
-
-/*
- * ETableSimple callbacks
- */
-static int
-col_count (ETableModel *etc, void *data)
-{
- return cols;
-}
-
-static int
-row_count (ETableModel *etc, void *data)
-{
- return lines;
-}
-
-static void *
-value_at (ETableModel *etc, int col, int row, void *data)
-{
- g_assert (col < cols);
- g_assert (row < lines);
-
- return (void *) table_data [row][col];
-}
-
-static void
-set_value_at (ETableModel *etc, int col, int row, const void *val, void *data)
-{
- g_assert (col < cols);
- g_assert (row < lines);
-
- g_free (table_data [row][col]);
- table_data [row][col] = g_strdup (val);
-
- printf ("Value at %d,%d set to %s\n", col, row, (char *) val);
-}
-
-static gboolean
-is_cell_editable (ETableModel *etc, int col, int row, void *data)
-{
- return TRUE;
-}
-
-static void
-set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc)
-{
- gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height);
-}
-
-void
-table_browser_test (void)
-{
- GtkWidget *canvas, *window;
- ETableModel *e_table_model;
- ETableHeader *e_table_header;
- ECell *cell_left_just;
- GnomeCanvasItem *group;
- int i;
-
- load_data ();
-
- /*
- * Data model
- */
- e_table_model = e_table_simple_new (
- col_count, row_count, value_at,
- set_value_at, is_cell_editable, NULL);
-
- /*
- * Header
- */
- e_table_header = e_table_header_new ();
- cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT);
-
- for (i = 0; i < cols; i++){
- ETableCol *ecol = e_table_col_new (
- i, column_labels [i],
- 80, 20, cell_left_just,
- g_str_equal, TRUE);
-
- e_table_header_add_column (e_table_header, ecol, i);
- }
-
- /*
- * Setup GUI
- */
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- canvas = gnome_canvas_new ();
-
- gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate",
- GTK_SIGNAL_FUNC (set_canvas_size), NULL);
-
- gtk_container_add (GTK_CONTAINER (window), canvas);
- gtk_widget_show_all (window);
- gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- e_table_header_item_get_type (),
- "ETableHeader", e_table_header,
- "x", 0,
- "y", 0,
- NULL);
-
- group = gnome_canvas_item_new (
- gnome_canvas_root (GNOME_CANVAS (canvas)),
- gnome_canvas_group_get_type (),
- "x", 30.0,
- "y", 30.0,
- NULL);
-
- gnome_canvas_item_new (
- GNOME_CANVAS_GROUP (group),
- e_table_item_get_type (),
- "ETableHeader", e_table_header,
- "ETableModel", e_table_model,
- "x", (double) 0,
- "y", (double) 0,
- "drawgrid", TRUE,
- "drawfocus", TRUE,
- "spreadsheet", TRUE,
- NULL);
-}
-
-static void
-do_e_table_demo (const char *col_spec, const char *group_spec)
-{
- GtkWidget *e_table, *window;
- ETableModel *e_table_model;
- ECell *cell_left_just;
- ETableHeader *full_header;
- int i;
-
- /*
- * Data model
- */
- e_table_model = e_table_simple_new (
- col_count, row_count, value_at,
- set_value_at, is_cell_editable, NULL);
-
- full_header = e_table_header_new ();
- cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT);
-
- for (i = 0; i < cols; i++){
- ETableCol *ecol = e_table_col_new (
- i, column_labels [i],
- 80, 20, cell_left_just,
- g_str_equal, TRUE);
-
- e_table_header_add_column (full_header, ecol, i);
- }
-
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- e_table = e_table_new (full_header, e_table_model, col_spec, group_spec);
-
- gtk_container_add (GTK_CONTAINER (window), e_table);
-
- gtk_widget_set_usize (window, 200, 200);
- gtk_widget_show (e_table);
- gtk_widget_show (window);
-}
-
-void
-e_table_test (void)
-{
- load_data ();
-
- if (getenv ("DO")){
- do_e_table_demo ("0,1,2,3,4", NULL);
- do_e_table_demo ("0,1,2,3,4", "3,4");
- }
- do_e_table_demo ("0,1,2,3,4", "3");
-}
diff --git a/widgets/table/test.c b/widgets/table/test.c
deleted file mode 100644
index 0eece34467..0000000000
--- a/widgets/table/test.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <config.h>
-#include "e-table-simple.h"
-
-struct {
- char *str;
- int val;
-} data [] = {
- { "Miguel", 10 },
- { "Nat", 20 },
- { NULL, 0 },
-};
-
-main ()
-{
-
-}
-
diff --git a/widgets/test-minicard-label.c b/widgets/test-minicard-label.c
deleted file mode 100644
index 67c17a0ace..0000000000
--- a/widgets/test-minicard-label.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* test-minicard-label.c
- *
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * 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.
- */
-
-
-
-#include "config.h"
-
-#include <gnome.h>
-#include "e-minicard-label.h"
-
-/* This is a horrible thing to do, but it is just a test. */
-GnomeCanvasItem *label;
-GnomeCanvasItem *rect;
-
-static void destroy_callback(GtkWidget *app, gpointer data)
-{
- exit(0);
-}
-
-static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data)
-{
- gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height );
- gnome_canvas_item_set( label,
- "width", (double) allocation->width,
- "height", (double) allocation->height,
- NULL );
- gnome_canvas_item_set( rect,
- "x2", (double) allocation->width,
- "y2", (double) allocation->height,
- NULL );
-}
-
-static void about_callback( GtkWidget *widget, gpointer data )
-{
-
- const gchar *authors[] =
- {
- "Christopher James Lahey <clahey@umich.edu>",
- NULL
- };
-
- GtkWidget *about =
- gnome_about_new ( _( "Minicard Label Test" ), VERSION,
- _( "Copyright (C) 2000, Helix Code, Inc." ),
- authors,
- _( "This should test the minicard label canvas item" ),
- NULL);
- gtk_widget_show (about);
-}
-
-static void button_press_callback( GtkWidget *widget, gpointer data )
-{
- gnome_canvas_item_grab_focus( label );
-}
-
-int main( int argc, char *argv[] )
-{
- GtkWidget *app;
- GtkWidget *canvas;
-
- /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);*/
-
- gnome_init( "Minicard Label Test", VERSION, argc, argv);
- app = gnome_app_new("Minicard Label Test", NULL);
-
- canvas = gnome_canvas_new();
- rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) 100,
- "y2", (double) 100,
- "fill_color", "white",
- NULL );
- label = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- e_minicard_label_get_type(),
- "x", (double) 0,
- "y", (double) 0,
- "width", (double) 100,
- "height", (double) 100,
- "fieldname", "Full Name:",
- "field", "Christopher James Lahey",
- NULL );
- gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ),
- 0, 0,
- 100, 100 );
-
- gnome_app_set_contents( GNOME_APP( app ), canvas );
-
-
- /* Connect the signals */
- gtk_signal_connect( GTK_OBJECT( app ), "destroy",
- GTK_SIGNAL_FUNC( destroy_callback ),
- ( gpointer ) app );
-
- gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate",
- GTK_SIGNAL_FUNC( allocate_callback ),
- ( gpointer ) app );
-
- gtk_signal_connect( GTK_OBJECT( canvas ), "button_press_event",
- GTK_SIGNAL_FUNC( button_press_callback ),
- ( gpointer ) app );
-
- gtk_widget_show_all( app );
-
- gtk_main();
-
- /* Not reached. */
- return 0;
-}
diff --git a/widgets/test-minicard.c b/widgets/test-minicard.c
deleted file mode 100644
index 79077c4b2d..0000000000
--- a/widgets/test-minicard.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* test-minicard.c
- *
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * 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.
- */
-
-
-
-#include "config.h"
-
-#include <gnome.h>
-#include "e-minicard.h"
-
-/* This is a horrible thing to do, but it is just a test. */
-GnomeCanvasItem *card;
-GnomeCanvasItem *rect;
-
-static void destroy_callback(GtkWidget *app, gpointer data)
-{
- exit(0);
-}
-
-static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data)
-{
- gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height );
- gnome_canvas_item_set( card,
- "width", (double) allocation->width,
- NULL );
- gnome_canvas_item_set( rect,
- "x2", (double) allocation->width,
- "y2", (double) allocation->height,
- NULL );
-}
-
-static void about_callback( GtkWidget *widget, gpointer data )
-{
-
- const gchar *authors[] =
- {
- "Christopher James Lahey <clahey@umich.edu>",
- NULL
- };
-
- GtkWidget *about =
- gnome_about_new ( _( "Minicard Test" ), VERSION,
- _( "Copyright (C) 2000, Helix Code, Inc." ),
- authors,
- _( "This should test the minicard canvas item" ),
- NULL);
- gtk_widget_show (about);
-}
-
-int main( int argc, char *argv[] )
-{
- GtkWidget *app;
- GtkWidget *canvas;
- int i;
-
- /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);*/
-
- gnome_init( "Minicard Test", VERSION, argc, argv);
- app = gnome_app_new("Minicard Test", NULL);
-
- canvas = gnome_canvas_new();
- rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) 100,
- "y2", (double) 100,
- "fill_color", "white",
- NULL );
- for ( i = 0; i < 1; i++ )
- {
- card = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- e_minicard_get_type(),
- "x", (double) 0,
- "y", (double) 0,
- "width", (double) 100,
- NULL );
- }
- gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ),
- 0, 0,
- 100, 100 );
-
- gnome_app_set_contents( GNOME_APP( app ), canvas );
-
- /* Connect the signals */
- gtk_signal_connect( GTK_OBJECT( app ), "destroy",
- GTK_SIGNAL_FUNC( destroy_callback ),
- ( gpointer ) app );
-
- gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate",
- GTK_SIGNAL_FUNC( allocate_callback ),
- ( gpointer ) app );
-
- gtk_widget_show_all( app );
-
- gtk_main();
-
- /* Not reached. */
- return 0;
-}
diff --git a/widgets/test-reflow.c b/widgets/test-reflow.c
deleted file mode 100644
index 4533e0249d..0000000000
--- a/widgets/test-reflow.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* test-reflow.c
- *
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * 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.
- */
-
-
-
-#include "config.h"
-
-#include <gnome.h>
-#include "e-canvas.h"
-#include "e-reflow.h"
-#include "e-minicard.h"
-
-/* This is a horrible thing to do, but it is just a test. */
-GnomeCanvasItem *reflow;
-GnomeCanvasItem *rect;
-GtkAllocation last_alloc;
-
-static void destroy_callback(GtkWidget *app, gpointer data)
-{
- exit(0);
-}
-
-static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data)
-{
- double width;
- last_alloc = *allocation;
- gnome_canvas_item_set( reflow,
- "height", (double) allocation->height,
- NULL );
- gnome_canvas_item_set( reflow,
- "minimum_width", (double) allocation->width,
- NULL );
- gtk_object_get(GTK_OBJECT(reflow),
- "width", &width,
- NULL);
- width = MAX(width, allocation->width);
- gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, width, allocation->height );
- gnome_canvas_item_set( rect,
- "x2", (double) width,
- "y2", (double) allocation->height,
- NULL );
-}
-
-static void resize(GnomeCanvasItem *item, gpointer data)
-{
- double width;
- gtk_object_get(GTK_OBJECT(reflow),
- "width", &width,
- NULL);
- width = MAX(width, last_alloc.width);
- gnome_canvas_set_scroll_region(item->canvas , 0, 0, width, last_alloc.height );
- gnome_canvas_item_set( rect,
- "x2", (double) width,
- "y2", (double) last_alloc.height,
- NULL );
-}
-
-static void about_callback( GtkWidget *widget, gpointer data )
-{
-
- const gchar *authors[] =
- {
- "Christopher James Lahey <clahey@umich.edu>",
- NULL
- };
-
- GtkWidget *about =
- gnome_about_new ( _( "Reflow Test" ), VERSION,
- _( "Copyright (C) 2000, Helix Code, Inc." ),
- authors,
- _( "This should test the reflow canvas item" ),
- NULL);
- gtk_widget_show (about);
-}
-
-int main( int argc, char *argv[] )
-{
- GtkWidget *app;
- GtkWidget *canvas;
- GtkWidget *vbox;
- GtkWidget *scrollbar;
- int i;
-
- /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);*/
-
- gnome_init( "Reflow Test", VERSION, argc, argv);
- app = gnome_app_new("Reflow Test", NULL);
-
- vbox = gtk_vbox_new(FALSE, 0);
-
- canvas = e_canvas_new();
- rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) 100,
- "y2", (double) 100,
- "fill_color", "white",
- NULL );
- reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- e_reflow_get_type(),
- "x", (double) 0,
- "y", (double) 0,
- "height", (double) 100,
- "minimum_width", (double) 100,
- NULL );
- gtk_signal_connect( GTK_OBJECT( reflow ), "resize",
- GTK_SIGNAL_FUNC( resize ),
- ( gpointer ) app);
- for ( i = 0; i < 200; i++ )
- {
- GnomeCanvasItem *item;
- item = gnome_canvas_item_new( GNOME_CANVAS_GROUP(reflow),
- e_minicard_get_type(),
- NULL);
- e_reflow_add_item(E_REFLOW(reflow), item);
- }
- gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ),
- 0, 0,
- 100, 100 );
-
- gtk_box_pack_start(GTK_BOX(vbox), canvas, TRUE, TRUE, 0);
-
- scrollbar = gtk_hscrollbar_new(gtk_layout_get_hadjustment(GTK_LAYOUT(canvas)));
-
- gtk_box_pack_start(GTK_BOX(vbox), scrollbar, FALSE, FALSE, 0);
-
- gnome_app_set_contents( GNOME_APP( app ), vbox );
-
- /* Connect the signals */
- gtk_signal_connect( GTK_OBJECT( app ), "destroy",
- GTK_SIGNAL_FUNC( destroy_callback ),
- ( gpointer ) app );
-
- gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate",
- GTK_SIGNAL_FUNC( allocate_callback ),
- ( gpointer ) app );
-
- gtk_widget_show_all( app );
- gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE);
-
- gtk_main();
-
- /* Not reached. */
- return 0;
-}
diff --git a/widgets/text/e-text-event-processor-emacs-like.c b/widgets/text/e-text-event-processor-emacs-like.c
deleted file mode 100644
index 41bcd0c31d..0000000000
--- a/widgets/text/e-text-event-processor-emacs-like.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include "e-text-event-processor-emacs-like.h"
-static void e_text_event_processor_emacs_like_init (ETextEventProcessorEmacsLike *card);
-static void e_text_event_processor_emacs_like_class_init (ETextEventProcessorEmacsLikeClass *klass);
-static gint e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event);
-
-static ETextEventProcessorClass *parent_class = NULL;
-
-/* The arguments we take */
-enum {
- ARG_0
-};
-
-static const ETextEventProcessorCommand control_keys[26] =
-{
- { E_TEP_START_OF_LINE, E_TEP_MOVE, 0, "" }, /* a */
- { E_TEP_BACKWARD_CHARACTER, E_TEP_MOVE, 0, "" }, /* b */
- { E_TEP_SELECTION, E_TEP_COPY, 0, "" }, /* c */
- { E_TEP_FORWARD_CHARACTER, E_TEP_DELETE, 0, "" }, /* d */
- { E_TEP_END_OF_LINE, E_TEP_MOVE, 0, "" }, /* e */
- { E_TEP_FORWARD_CHARACTER, E_TEP_MOVE, 0, "" }, /* f */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* g */
- { E_TEP_BACKWARD_CHARACTER, E_TEP_DELETE, 0, "" }, /* h */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* i */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* j */
- { E_TEP_END_OF_LINE, E_TEP_DELETE, 0, "" }, /* k */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* l */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* m */
- { E_TEP_FORWARD_LINE, E_TEP_MOVE, 0, "" }, /* n */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* o */
- { E_TEP_BACKWARD_LINE, E_TEP_MOVE, 0, "" }, /* p */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* q */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* r */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* s */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* t */
- { E_TEP_START_OF_LINE, E_TEP_DELETE, 0, "" }, /* u */
- { E_TEP_SELECTION, E_TEP_PASTE, 0, "" }, /* v */
- { E_TEP_BACKWARD_WORD, E_TEP_DELETE, 0, "" }, /* w */
- { E_TEP_SELECTION, E_TEP_DELETE, 0, "" }, /* x */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* y */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" } /* z */
-};
-
-static const ETextEventProcessorCommand alt_keys[26] =
-{
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* a */
- { E_TEP_BACKWARD_WORD, E_TEP_MOVE, 0, "" }, /* b */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* c */
- { E_TEP_FORWARD_WORD, E_TEP_DELETE, 0, "" }, /* d */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* e */
- { E_TEP_FORWARD_WORD, E_TEP_MOVE, 0, "" }, /* f */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* g */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* h */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* i */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* j */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* k */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* l */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* m */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* n */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* o */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* p */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* q */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* r */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* s */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* t */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* u */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* v */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* w */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* x */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* y */
- { E_TEP_SELECTION, E_TEP_NOP, 0, "" } /* z */
-
-};
-
-GtkType
-e_text_event_processor_emacs_like_get_type (void)
-{
- static GtkType text_event_processor_emacs_like_type = 0;
-
- if (!text_event_processor_emacs_like_type)
- {
- static const GtkTypeInfo text_event_processor_emacs_like_info =
- {
- "ETextEventProcessorEmacsLike",
- sizeof (ETextEventProcessorEmacsLike),
- sizeof (ETextEventProcessorEmacsLikeClass),
- (GtkClassInitFunc) e_text_event_processor_emacs_like_class_init,
- (GtkObjectInitFunc) e_text_event_processor_emacs_like_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- text_event_processor_emacs_like_type = gtk_type_unique (e_text_event_processor_get_type (), &text_event_processor_emacs_like_info);
- }
-
- return text_event_processor_emacs_like_type;
-}
-
-static void
-e_text_event_processor_emacs_like_class_init (ETextEventProcessorEmacsLikeClass *klass)
-{
- GtkObjectClass *object_class;
- ETextEventProcessorClass *processor_class;
-
- object_class = (GtkObjectClass*) klass;
- processor_class = (ETextEventProcessorClass*) klass;
-
- parent_class = gtk_type_class (e_text_event_processor_get_type ());
-
- processor_class->event = e_text_event_processor_emacs_like_event;
-}
-
-static void
-e_text_event_processor_emacs_like_init (ETextEventProcessorEmacsLike *tep)
-{
-}
-
-static gint
-e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event)
-{
- ETextEventProcessorCommand command;
- ETextEventProcessorEmacsLike *tep_el = E_TEXT_EVENT_PROCESSOR_EMACS_LIKE(tep);
- command.action = E_TEP_NOP;
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if (event->button.button == 1) {
- command.action = E_TEP_GRAB;
- command.time = event->button.time;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
- if (event->button.state & GDK_SHIFT_MASK)
- command.action = E_TEP_SELECT;
- else
- command.action = E_TEP_MOVE;
- command.position = E_TEP_VALUE;
- command.value = event->button.position;
- command.time = event->button.time;
- tep_el->mouse_down = TRUE;
- }
- break;
- case GDK_BUTTON_RELEASE:
- if (event->button.button == 1) {
- command.action = E_TEP_UNGRAB;
- command.time = event->button.time;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
- command.time = event->button.time;
- tep_el->mouse_down = FALSE;
- } else if (event->button.button == 2) {
- command.action = E_TEP_MOVE;
- command.position = E_TEP_VALUE;
- command.value = event->button.position;
- command.time = event->button.time;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
-
- command.action = E_TEP_GET_SELECTION;
- command.position = E_TEP_SELECTION;
- command.value = 0;
- command.time = event->button.time;
- }
- break;
- case GDK_MOTION_NOTIFY:
- if (tep_el->mouse_down) {
- command.action = E_TEP_SELECT;
- command.position = E_TEP_VALUE;
- command.time = event->motion.time;
- command.value = event->motion.position;
- }
- break;
- case GDK_KEY_PRESS:
- {
- ETextEventProcessorEventKey key = event->key;
- command.time = event->key.time;
- if (key.state & GDK_SHIFT_MASK)
- command.action = E_TEP_SELECT;
- else
- command.action = E_TEP_MOVE;
- switch(key.keyval) {
- case GDK_Home:
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_START_OF_BUFFER;
- else
- command.position = E_TEP_START_OF_LINE;
- break;
- case GDK_End:
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_END_OF_BUFFER;
- else
- command.position = E_TEP_END_OF_LINE;
- break;
- case GDK_Page_Up: command.position = E_TEP_BACKWARD_PAGE; break;
- case GDK_Page_Down: command.position = E_TEP_FORWARD_PAGE; break;
- /* CUA has Ctrl-Up/Ctrl-Down as paragraph up down */
- case GDK_Up: command.position = E_TEP_BACKWARD_LINE; break;
- case GDK_Down: command.position = E_TEP_FORWARD_LINE; break;
- case GDK_Left:
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_BACKWARD_WORD;
- else
- command.position = E_TEP_BACKWARD_CHARACTER;
- break;
- case GDK_Right:
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_FORWARD_WORD;
- else
- command.position = E_TEP_FORWARD_CHARACTER;
- break;
-
- case GDK_BackSpace:
- command.action = E_TEP_DELETE;
- if (key.state & GDK_CONTROL_MASK)
- command.position = E_TEP_BACKWARD_WORD;
- else
- command.position = E_TEP_BACKWARD_CHARACTER;
- break;
- case GDK_Clear:
- command.action = E_TEP_DELETE;
- command.position = E_TEP_END_OF_LINE;
- break;
- case GDK_Insert:
- if (key.state & GDK_SHIFT_MASK) {
- command.action = E_TEP_PASTE;
- command.position = E_TEP_SELECTION;
- } else if (key.state & GDK_CONTROL_MASK) {
- command.action = E_TEP_COPY;
- command.position = E_TEP_SELECTION;
- } else {
- /* gtk_toggle_insert(text) -- IMPLEMENT */
- }
- break;
- case GDK_Delete:
- if (key.state & GDK_CONTROL_MASK){
- command.action = E_TEP_DELETE;
- command.position = E_TEP_FORWARD_WORD;
- } else if (key.state & GDK_SHIFT_MASK) {
- command.action = E_TEP_COPY;
- command.position = E_TEP_SELECTION;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
-
- command.action = E_TEP_DELETE;
- command.position = E_TEP_SELECTION;
- } else {
- command.action = E_TEP_DELETE;
- command.position = E_TEP_FORWARD_CHARACTER;
- }
- break;
- case GDK_Tab:
- /* Don't insert literally */
- command.action = E_TEP_NOP;
- command.position = E_TEP_SELECTION;
- break;
- case GDK_Return:
- if (key.state & GDK_CONTROL_MASK) {
- command.action = E_TEP_ACTIVATE;
- command.position = E_TEP_SELECTION;
- } else {
- command.action = E_TEP_INSERT;
- command.position = E_TEP_SELECTION;
- command.value = 1;
- command.string = "\n";
- }
- break;
- case GDK_Escape:
- /* Don't insert literally */
- command.action = E_TEP_NOP;
- command.position = E_TEP_SELECTION;
- break;
-
- default:
- if (key.state & GDK_CONTROL_MASK) {
- if ((key.keyval >= 'A') && (key.keyval <= 'Z'))
- key.keyval -= 'A' - 'a';
-
- if ((key.keyval >= 'a') && (key.keyval <= 'z')) {
- command.position = control_keys[(int) (key.keyval - 'a')].position;
- if (control_keys[(int) (key.keyval - 'a')].action != E_TEP_MOVE)
- command.action = control_keys[(int) (key.keyval - 'a')].action;
- command.value = control_keys[(int) (key.keyval - 'a')].value;
- command.string = control_keys[(int) (key.keyval - 'a')].string;
- }
-
- if (key.keyval == 'x') {
- command.action = E_TEP_COPY;
- command.position = E_TEP_SELECTION;
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
-
- command.action = E_TEP_DELETE;
- command.position = E_TEP_SELECTION;
- }
-
- break;
- } else if (key.state & GDK_MOD1_MASK) {
- if ((key.keyval >= 'A') && (key.keyval <= 'Z'))
- key.keyval -= 'A' - 'a';
-
- if ((key.keyval >= 'a') && (key.keyval <= 'z')) {
- command.position = alt_keys[(int) (key.keyval - 'a')].position;
- if (alt_keys[(int) (key.keyval - 'a')].action != E_TEP_MOVE)
- command.action = alt_keys[(int) (key.keyval - 'a')].action;
- command.value = alt_keys[(int) (key.keyval - 'a')].value;
- command.string = alt_keys[(int) (key.keyval - 'a')].string;
- }
- } else if (key.length > 0) {
- command.action = E_TEP_INSERT;
- command.position = E_TEP_SELECTION;
- command.value = strlen(key.string);
- command.string = key.string;
-
- } else {
- command.action = E_TEP_NOP;
- }
- }
- break;
- case GDK_KEY_RELEASE:
- command.time = event->key.time;
- command.action = E_TEP_NOP;
- break;
- default:
- command.action = E_TEP_NOP;
- break;
- }
- }
- if (command.action != E_TEP_NOP) {
- gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
- return 1;
- }
- else
- return 0;
-}
-
-ETextEventProcessor *
-e_text_event_processor_emacs_like_new (void)
-{
- ETextEventProcessorEmacsLike *retval = gtk_type_new (e_text_event_processor_emacs_like_get_type ());
- return E_TEXT_EVENT_PROCESSOR (retval);
-}
-
diff --git a/widgets/text/e-text-event-processor-emacs-like.h b/widgets/text/e-text-event-processor-emacs-like.h
deleted file mode 100644
index 651bb552b3..0000000000
--- a/widgets/text/e-text-event-processor-emacs-like.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor-emacs-like.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__
-#define __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__
-
-#include <gnome.h>
-#include "e-text-event-processor.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* ETextEventProcessorEmacsLike - Turns events on a text widget into commands. Uses an emacs-ish interface.
- *
- */
-
-#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE (e_text_event_processor_emacs_like_get_type ())
-#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE(obj) (GTK_CHECK_CAST ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE, ETextEventProcessorEmacsLike))
-#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE, ETextEventProcessorEmacsLikeClass))
-#define E_IS_TEXT_EVENT_PROCESSOR_EMACS_LIKE(obj) (GTK_CHECK_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE))
-#define E_IS_TEXT_EVENT_PROCESSOR_EMACS_LIKE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE))
-
-
-typedef struct _ETextEventProcessorEmacsLike ETextEventProcessorEmacsLike;
-typedef struct _ETextEventProcessorEmacsLikeClass ETextEventProcessorEmacsLikeClass;
-
-struct _ETextEventProcessorEmacsLike
-{
- ETextEventProcessor parent;
-
- /* object specific fields */
- gboolean mouse_down;
-};
-
-struct _ETextEventProcessorEmacsLikeClass
-{
- ETextEventProcessorClass parent_class;
-};
-
-
-GtkType e_text_event_processor_emacs_like_get_type (void);
-ETextEventProcessor *e_text_event_processor_emacs_like_new (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__ */
diff --git a/widgets/text/e-text-event-processor-types.h b/widgets/text/e-text-event-processor-types.h
deleted file mode 100644
index 32a39bf0c0..0000000000
--- a/widgets/text/e-text-event-processor-types.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __E_TEXT_EVENT_PROCESSOR_TYPES_H__
-#define __E_TEXT_EVENT_PROCESSOR_TYPES_H__
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#include <gdk/gdktypes.h>
-
-typedef enum _ETextEventProcessorCommandPosition ETextEventProcessorCommandPosition;
-typedef enum _ETextEventProcessorCommandAction ETextEventProcessorCommandAction;
-typedef struct _ETextEventProcessorCommand ETextEventProcessorCommand;
-
-typedef union _ETextEventProcessorEvent ETextEventProcessorEvent;
-typedef struct _ETextEventProcessorEventButton ETextEventProcessorEventButton;
-typedef struct _ETextEventProcessorEventKey ETextEventProcessorEventKey;
-typedef struct _ETextEventProcessorEventMotion ETextEventProcessorEventMotion;
-
-enum _ETextEventProcessorCommandPosition {
- E_TEP_VALUE,
- E_TEP_SELECTION,
-
- E_TEP_START_OF_BUFFER,
- E_TEP_END_OF_BUFFER,
-
- E_TEP_START_OF_LINE,
- E_TEP_END_OF_LINE,
-
- E_TEP_FORWARD_CHARACTER,
- E_TEP_BACKWARD_CHARACTER,
-
- E_TEP_FORWARD_WORD,
- E_TEP_BACKWARD_WORD,
-
- E_TEP_FORWARD_LINE,
- E_TEP_BACKWARD_LINE,
-
- E_TEP_FORWARD_PARAGRAPH,
- E_TEP_BACKWARD_PARAGRAPH,
-
- E_TEP_FORWARD_PAGE,
- E_TEP_BACKWARD_PAGE
-};
-
-enum _ETextEventProcessorCommandAction {
- E_TEP_MOVE,
- E_TEP_SELECT,
- E_TEP_DELETE,
- E_TEP_INSERT,
-
- E_TEP_COPY,
- E_TEP_PASTE,
- E_TEP_GET_SELECTION,
- E_TEP_SET_SELECT_BY_WORD,
- E_TEP_ACTIVATE,
-
- E_TEP_GRAB,
- E_TEP_UNGRAB,
-
- E_TEP_NOP
-};
-
-struct _ETextEventProcessorCommand {
- ETextEventProcessorCommandPosition position;
- ETextEventProcessorCommandAction action;
- int value;
- char *string;
- guint32 time;
-};
-
-struct _ETextEventProcessorEventButton {
- GdkEventType type;
- guint32 time;
- guint state;
- guint button;
- gint position;
-};
-
-struct _ETextEventProcessorEventKey {
- GdkEventType type;
- guint32 time;
- guint state;
- guint keyval;
- gint length;
- gchar *string;
-};
-
-struct _ETextEventProcessorEventMotion {
- GdkEventType type;
- guint32 time;
- guint state;
- gint position;
-};
-
-union _ETextEventProcessorEvent {
- GdkEventType type;
- ETextEventProcessorEventButton button;
- ETextEventProcessorEventKey key;
- ETextEventProcessorEventMotion motion;
-};
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_TEXT_EVENT_PROCESSOR_TYPES_H__ */
diff --git a/widgets/text/e-text-event-processor.c b/widgets/text/e-text-event-processor.c
deleted file mode 100644
index 47f028ca62..0000000000
--- a/widgets/text/e-text-event-processor.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <gnome.h>
-#include "e-text-event-processor.h"
-static void e_text_event_processor_init (ETextEventProcessor *card);
-static void e_text_event_processor_class_init (ETextEventProcessorClass *klass);
-
-static GtkObjectClass *parent_class = NULL;
-
-/* The arguments we take */
-enum {
- ARG_0
-};
-
-enum {
- E_TEP_EVENT,
- E_TEP_LAST_SIGNAL
-};
-
-static guint e_tep_signals[E_TEP_LAST_SIGNAL] = { 0 };
-
-GtkType
-e_text_event_processor_get_type (void)
-{
- static GtkType text_event_processor_type = 0;
-
- if (!text_event_processor_type)
- {
- static const GtkTypeInfo text_event_processor_info =
- {
- "ETextEventProcessor",
- sizeof (ETextEventProcessor),
- sizeof (ETextEventProcessorClass),
- (GtkClassInitFunc) e_text_event_processor_class_init,
- (GtkObjectInitFunc) e_text_event_processor_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- text_event_processor_type = gtk_type_unique (gtk_object_get_type (), &text_event_processor_info);
- }
-
- return text_event_processor_type;
-}
-
-static void
-e_text_event_processor_class_init (ETextEventProcessorClass *klass)
-{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass*) klass;
-
- parent_class = gtk_type_class (gtk_object_get_type ());
-
- e_tep_signals[E_TEP_EVENT] =
- gtk_signal_new ("command",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETextEventProcessorClass, command),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
-
- gtk_object_class_add_signals (object_class, e_tep_signals, E_TEP_LAST_SIGNAL);
-
- klass->event = NULL;
- klass->command = NULL;
-}
-
-static void
-e_text_event_processor_init (ETextEventProcessor *tep)
-{
-}
-
-gint
-e_text_event_processor_handle_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event)
-{
- if (E_TEXT_EVENT_PROCESSOR_CLASS(GTK_OBJECT(tep)->klass)->event) {
- return E_TEXT_EVENT_PROCESSOR_CLASS(GTK_OBJECT(tep)->klass)->event(tep, event);
- } else {
- return 0;
- }
-}
diff --git a/widgets/text/e-text-event-processor.h b/widgets/text/e-text-event-processor.h
deleted file mode 100644
index 1fc79f3f70..0000000000
--- a/widgets/text/e-text-event-processor.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-text-event-processor.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_TEXT_EVENT_PROCESSOR_H__
-#define __E_TEXT_EVENT_PROCESSOR_H__
-
-#include <gnome.h>
-#include "e-text-event-processor-types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* ETextEventProcessor - Turns events on a text widget into commands.
- *
- */
-
-#define E_TEXT_EVENT_PROCESSOR_TYPE (e_text_event_processor_get_type ())
-#define E_TEXT_EVENT_PROCESSOR(obj) (GTK_CHECK_CAST ((obj), E_TEXT_EVENT_PROCESSOR_TYPE, ETextEventProcessor))
-#define E_TEXT_EVENT_PROCESSOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TEXT_EVENT_PROCESSOR_TYPE, ETextEventProcessorClass))
-#define E_IS_TEXT_EVENT_PROCESSOR(obj) (GTK_CHECK_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_TYPE))
-#define E_IS_TEXT_EVENT_PROCESSOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_TYPE))
-
-
-typedef struct _ETextEventProcessor ETextEventProcessor;
-typedef struct _ETextEventProcessorClass ETextEventProcessorClass;
-
-struct _ETextEventProcessor
-{
- GtkObject parent;
-
- /* object specific fields */
-
-};
-
-struct _ETextEventProcessorClass
-{
- GtkObjectClass parent_class;
-
- /* signals */
- void (* command) (ETextEventProcessor *tep, ETextEventProcessorCommand *command);
-
- /* virtual functions */
- gint (* event) (ETextEventProcessor *tep, ETextEventProcessorEvent *event);
-};
-
-
-GtkType e_text_event_processor_get_type (void);
-gint e_text_event_processor_handle_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_TEXT_EVENT_PROCESSOR_H__ */
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
deleted file mode 100644
index bfff8e251a..0000000000
--- a/widgets/text/e-text.c
+++ /dev/null
@@ -1,2391 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* EText - Text item for evolution.
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Chris Lahey <clahey@umich.edu>
- *
- * A majority of code taken from:
- *
- * Text item type for GnomeCanvas widget
- *
- * GnomeCanvas is basically a port of the Tk toolkit's most excellent
- * canvas widget. Tk is copyrighted by the Regents of the University
- * of California, Sun Microsystems, and other parties.
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx> */
-
-#include <config.h>
-#include <math.h>
-#include <ctype.h>
-#include "e-text.h"
-#include <gdk/gdkx.h> /* for BlackPixel */
-#include <libart_lgpl/art_affine.h>
-#include <libart_lgpl/art_rgb.h>
-#include <libart_lgpl/art_rgb_bitmap_affine.h>
-#include <gtk/gtkinvisible.h>
-
-#include "e-text-event-processor-emacs-like.h"
-
-enum {
- E_TEXT_RESIZE,
- E_TEXT_CHANGE,
- E_TEXT_LAST_SIGNAL
-};
-
-static guint e_text_signals[E_TEXT_LAST_SIGNAL] = { 0 };
-
-
-
-/* This defines a line of text */
-struct line {
- char *text; /* Line's text, it is a pointer into the text->text string */
- int length; /* Line's length in characters */
- int width; /* Line's width in pixels */
- int ellipsis_length; /* Length before adding ellipsis */
-};
-
-
-
-/* Object argument IDs */
-enum {
- ARG_0,
- ARG_TEXT,
- ARG_X,
- ARG_Y,
- ARG_FONT,
- ARG_FONTSET,
- ARG_FONT_GDK,
- ARG_ANCHOR,
- ARG_JUSTIFICATION,
- ARG_CLIP_WIDTH,
- ARG_CLIP_HEIGHT,
- ARG_CLIP,
- ARG_X_OFFSET,
- ARG_Y_OFFSET,
- ARG_FILL_COLOR,
- ARG_FILL_COLOR_GDK,
- ARG_FILL_COLOR_RGBA,
- ARG_FILL_STIPPLE,
- ARG_TEXT_WIDTH,
- ARG_TEXT_HEIGHT,
- ARG_EDITABLE,
- ARG_USE_ELLIPSIS,
- ARG_ELLIPSIS
-};
-
-
-enum {
- E_SELECTION_PRIMARY,
- E_SELECTION_CLIPBOARD
-};
-enum {
- TARGET_STRING,
- TARGET_TEXT,
- TARGET_COMPOUND_TEXT
-};
-
-static void e_text_class_init (ETextClass *class);
-static void e_text_init (EText *text);
-static void e_text_destroy (GtkObject *object);
-static void e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static void e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-
-static void e_text_update (GnomeCanvasItem *item, double *affine,
- ArtSVP *clip_path, int flags);
-static void e_text_realize (GnomeCanvasItem *item);
-static void e_text_unrealize (GnomeCanvasItem *item);
-static void e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height);
-static double e_text_point (GnomeCanvasItem *item, double x, double y, int cx, int cy,
- GnomeCanvasItem **actual_item);
-static void e_text_bounds (GnomeCanvasItem *item,
- double *x1, double *y1, double *x2, double *y2);
-static void e_text_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf);
-static gint e_text_event (GnomeCanvasItem *item, GdkEvent *event);
-
-static void e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gpointer data);
-
-static guint32 e_text_get_event_time (EText *text);
-
-static void e_text_get_selection(EText *text, GdkAtom selection, guint32 time);
-static void e_text_supply_selection (EText *text, guint time, GdkAtom selection, guchar *data, gint length);
-
-static GtkWidget *e_text_get_invisible(EText *text);
-static void _selection_clear_event (GtkInvisible *invisible,
- GdkEventSelection *event,
- EText *text);
-static void _selection_get (GtkInvisible *invisible,
- GtkSelectionData *selection_data,
- guint info,
- guint time_stamp,
- EText *text);
-static void _selection_received (GtkInvisible *invisible,
- GtkSelectionData *selection_data,
- guint time,
- EText *text);
-
-static ETextSuckFont *e_suck_font (GdkFont *font);
-static void e_suck_font_free (ETextSuckFont *suckfont);
-
-
-static GnomeCanvasItemClass *parent_class;
-static GdkAtom clipboard_atom = GDK_NONE;
-
-
-
-/**
- * e_text_get_type:
- * @void:
- *
- * Registers the &EText class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the &EText class.
- **/
-GtkType
-e_text_get_type (void)
-{
- static GtkType text_type = 0;
-
- if (!text_type) {
- GtkTypeInfo text_info = {
- "EText",
- sizeof (EText),
- sizeof (ETextClass),
- (GtkClassInitFunc) e_text_class_init,
- (GtkObjectInitFunc) e_text_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- text_type = gtk_type_unique (gnome_canvas_item_get_type (), &text_info);
- }
-
- return text_type;
-}
-
-/* Class initialization function for the text item */
-static void
-e_text_class_init (ETextClass *klass)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass *) klass;
- item_class = (GnomeCanvasItemClass *) klass;
-
- parent_class = gtk_type_class (gnome_canvas_item_get_type ());
-
- e_text_signals[E_TEXT_RESIZE] =
- gtk_signal_new ("resize",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETextClass, resize),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
-
- e_text_signals[E_TEXT_CHANGE] =
- gtk_signal_new ("change",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (ETextClass, change),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
-
- gtk_object_class_add_signals (object_class, e_text_signals, E_TEXT_LAST_SIGNAL);
-
- gtk_object_add_arg_type ("EText::text",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TEXT);
- gtk_object_add_arg_type ("EText::x",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_X);
- gtk_object_add_arg_type ("EText::y",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_Y);
- gtk_object_add_arg_type ("EText::font",
- GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FONT);
- gtk_object_add_arg_type ("EText::fontset",
- GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FONTSET);
- gtk_object_add_arg_type ("EText::font_gdk",
- GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_FONT_GDK);
- gtk_object_add_arg_type ("EText::anchor",
- GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_ANCHOR);
- gtk_object_add_arg_type ("EText::justification",
- GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_JUSTIFICATION);
- gtk_object_add_arg_type ("EText::clip_width",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_CLIP_WIDTH);
- gtk_object_add_arg_type ("EText::clip_height",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_CLIP_HEIGHT);
- gtk_object_add_arg_type ("EText::clip",
- GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_CLIP);
- gtk_object_add_arg_type ("EText::x_offset",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_X_OFFSET);
- gtk_object_add_arg_type ("EText::y_offset",
- GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_Y_OFFSET);
- gtk_object_add_arg_type ("EText::fill_color",
- GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FILL_COLOR);
- gtk_object_add_arg_type ("EText::fill_color_gdk",
- GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_FILL_COLOR_GDK);
- gtk_object_add_arg_type ("EText::fill_color_rgba",
- GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_FILL_COLOR_RGBA);
- gtk_object_add_arg_type ("EText::fill_stipple",
- GTK_TYPE_GDK_WINDOW, GTK_ARG_READWRITE, ARG_FILL_STIPPLE);
- gtk_object_add_arg_type ("EText::text_width",
- GTK_TYPE_DOUBLE, GTK_ARG_READABLE, ARG_TEXT_WIDTH);
- gtk_object_add_arg_type ("EText::text_height",
- GTK_TYPE_DOUBLE, GTK_ARG_READABLE, ARG_TEXT_HEIGHT);
- gtk_object_add_arg_type ("EText::editable",
- GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EDITABLE);
- gtk_object_add_arg_type ("EText::use_ellipsis",
- GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_USE_ELLIPSIS);
- gtk_object_add_arg_type ("EText::ellipsis",
- GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ELLIPSIS);
-
- if (!clipboard_atom)
- clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
-
-
-
- klass->resize = NULL;
- klass->change = NULL;
-
- object_class->destroy = e_text_destroy;
- object_class->set_arg = e_text_set_arg;
- object_class->get_arg = e_text_get_arg;
-
- item_class->update = e_text_update;
- item_class->realize = e_text_realize;
- item_class->unrealize = e_text_unrealize;
- item_class->draw = e_text_draw;
- item_class->point = e_text_point;
- item_class->bounds = e_text_bounds;
- item_class->render = e_text_render;
- item_class->event = e_text_event;
-}
-
-/* Object initialization function for the text item */
-static void
-e_text_init (EText *text)
-{
- text->x = 0.0;
- text->y = 0.0;
- text->anchor = GTK_ANCHOR_CENTER;
- text->justification = GTK_JUSTIFY_LEFT;
- text->clip_width = 0.0;
- text->clip_height = 0.0;
- text->xofs = 0.0;
- text->yofs = 0.0;
-
- text->ellipsis = NULL;
- text->use_ellipsis = FALSE;
- text->ellipsis_width = 0;
-
- text->editable = FALSE;
- text->editing = FALSE;
- text->xofs_edit = 0;
-
- text->selection_start = 0;
- text->selection_end = 0;
- text->select_by_word = FALSE;
-
- text->timeout_id = 0;
- text->timer = NULL;
-
- text->lastx = 0;
- text->lasty = 0;
- text->last_state = 0;
-
- text->scroll_start = 0;
- text->show_cursor = TRUE;
- text->button_down = FALSE;
-
- text->tep = NULL;
-
- text->has_selection = FALSE;
-
- text->invisible = NULL;
- text->primary_selection = NULL;
- text->primary_length = 0;
- text->clipboard_selection = NULL;
- text->clipboard_length = 0;
-
- text->pointer_in = FALSE;
- text->default_cursor_shown = TRUE;
-}
-
-/* Destroy handler for the text item */
-static void
-e_text_destroy (GtkObject *object)
-{
- EText *text;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNOME_IS_CANVAS_TEXT (object));
-
- text = E_TEXT (object);
-
- if (text->text)
- g_free (text->text);
-
- if (text->tep)
- gtk_object_unref (GTK_OBJECT(text->tep));
-
- if (text->invisible)
- gtk_object_unref (GTK_OBJECT(text->invisible));
-
- if (text->lines)
- g_free (text->lines);
-
- if (text->font)
- gdk_font_unref (text->font);
-
- if (text->suckfont)
- e_suck_font_free (text->suckfont);
-
- if (text->stipple)
- gdk_bitmap_unref (text->stipple);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-static void
-get_bounds_item_relative (EText *text, double *px1, double *py1, double *px2, double *py2)
-{
- GnomeCanvasItem *item;
- double x, y;
- double clip_x, clip_y;
- int old_height;
-
- item = GNOME_CANVAS_ITEM (text);
-
- x = text->x;
- y = text->y;
-
- clip_x = x;
- clip_y = y;
-
- /* Calculate text dimensions */
-
- old_height = text->height;
-
- if (text->text && text->font)
- text->height = (text->font->ascent + text->font->descent) * text->num_lines;
- else
- text->height = 0;
-
- if (old_height != text->height)
- gtk_signal_emit_by_name (GTK_OBJECT (text), "resize");
-
- /* Anchor text */
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- x -= text->max_width / 2;
- clip_x -= text->clip_width / 2;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- x -= text->max_width;
- clip_x -= text->clip_width;
- break;
- }
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- y -= text->height / 2;
- clip_y -= text->clip_height / 2;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- y -= text->height;
- clip_y -= text->clip_height;
- break;
- }
-
- /* Bounds */
-
- if (text->clip) {
- /* maybe do bbox intersection here? */
- *px1 = clip_x;
- *py1 = clip_y;
- *px2 = clip_x + text->clip_width;
- *py2 = clip_y + text->clip_height;
- } else {
- *px1 = x;
- *py1 = y;
- *px2 = x + text->max_width;
- *py2 = y + text->height;
- }
-}
-
-static void
-get_bounds (EText *text, double *px1, double *py1, double *px2, double *py2)
-{
- GnomeCanvasItem *item;
- double wx, wy;
- int old_height;
-
- item = GNOME_CANVAS_ITEM (text);
-
- /* Get canvas pixel coordinates for text position */
-
- wx = text->x;
- wy = text->y;
- gnome_canvas_item_i2w (item, &wx, &wy);
- gnome_canvas_w2c (item->canvas, wx + text->xofs, wy + text->yofs, &text->cx, &text->cy);
-
- /* Get canvas pixel coordinates for clip rectangle position */
-
- gnome_canvas_w2c (item->canvas, wx, wy, &text->clip_cx, &text->clip_cy);
- text->clip_cwidth = text->clip_width * item->canvas->pixels_per_unit;
- text->clip_cheight = text->clip_height * item->canvas->pixels_per_unit;
-
- /* Calculate text dimensions */
-
- old_height = text->height;
-
- if (text->text && text->font)
- text->height = (text->font->ascent + text->font->descent) * text->num_lines;
- else
- text->height = 0;
-
- if (old_height != text->height)
- gtk_signal_emit_by_name (GTK_OBJECT (text), "resize");
-
- /* Anchor text */
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- text->cx -= text->max_width / 2;
- text->clip_cx -= text->clip_cwidth / 2;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- text->cx -= text->max_width;
- text->clip_cx -= text->clip_cwidth;
- break;
- }
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- text->cy -= text->height / 2;
- text->clip_cy -= text->clip_cheight / 2;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- text->cy -= text->height;
- text->clip_cy -= text->clip_cheight;
- break;
- }
-
- /* Bounds */
-
- if (text->clip) {
- *px1 = text->clip_cx;
- *py1 = text->clip_cy;
- *px2 = text->clip_cx + text->clip_cwidth;
- *py2 = text->clip_cy + text->clip_cheight;
- } else {
- *px1 = text->cx;
- *py1 = text->cy;
- *px2 = text->cx + text->max_width;
- *py2 = text->cy + text->height;
- }
-}
-
-/* Recalculates the bounding box of the text item. The bounding box is defined
- * by the text's extents if the clip rectangle is disabled. If it is enabled,
- * the bounding box is defined by the clip rectangle itself.
- */
-static void
-recalc_bounds (EText *text)
-{
- GnomeCanvasItem *item;
-
- item = GNOME_CANVAS_ITEM (text);
-
- get_bounds (text, &item->x1, &item->y1, &item->x2, &item->y2);
-
- gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
-}
-
-static void
-calc_ellipsis (EText *text)
-{
- if (text->font)
- text->ellipsis_width =
- gdk_text_width (text->font,
- text->ellipsis ? text->ellipsis : "...",
- text->ellipsis ? strlen (text->ellipsis) : 3);
-}
-
-/* Calculates the line widths (in pixels) of the text's splitted lines */
-static void
-calc_line_widths (EText *text)
-{
- struct line *lines;
- int i;
- int j;
-
- lines = text->lines;
- text->max_width = 0;
-
- if (!lines)
- return;
-
- for (i = 0; i < text->num_lines; i++) {
- if (lines->length != 0) {
- if (text->font) {
- lines->width = gdk_text_width (text->font,
- lines->text, lines->length);
- lines->ellipsis_length = 0;
- } else {
- lines->width = 0;
- }
-
- if (text->clip &&
- text->use_ellipsis &&
- ! text->editing &&
- lines->width > text->clip_width) {
- if (text->font) {
- lines->ellipsis_length = 0;
- for (j = 0; j < lines->length; j++ ) {
- if (gdk_text_width (text->font, lines->text, j) + text->ellipsis_width <= text->clip_width)
- lines->ellipsis_length = j;
- else
- break;
- }
- }
- else
- lines->ellipsis_length = 0;
- lines->width = gdk_text_width (text->font, lines->text, lines->ellipsis_length) +
- text->ellipsis_width;
- }
- else
- lines->ellipsis_length = lines->length;
-
- if (lines->width > text->max_width)
- text->max_width = lines->width;
- }
-
- lines++;
- }
-}
-
-/* Splits the text of the text item into lines */
-static void
-split_into_lines (EText *text)
-{
- char *p;
- struct line *lines;
- int len;
-
- /* Free old array of lines */
-
- if (text->lines)
- g_free (text->lines);
-
- text->lines = NULL;
- text->num_lines = 0;
-
- if (!text->text)
- return;
-
- /* First, count the number of lines */
-
- for (p = text->text; *p; p++)
- if (*p == '\n')
- text->num_lines++;
-
- text->num_lines++;
-
- /* Allocate array of lines and calculate split positions */
-
- text->lines = lines = g_new0 (struct line, text->num_lines);
- len = 0;
-
- for (p = text->text; *p; p++) {
- if (len == 0)
- lines->text = p;
- if (*p == '\n') {
- lines->length = len;
- lines++;
- len = 0;
- } else
- len++;
- }
-
- if (len == 0)
- lines->text = p;
- lines->length = len;
-
- calc_line_widths (text);
-}
-
-/* Convenience function to set the text's GC's foreground color */
-static void
-set_text_gc_foreground (EText *text)
-{
- GdkColor c;
-
- if (!text->gc)
- return;
-
- c.pixel = text->pixel;
- gdk_gc_set_foreground (text->gc, &c);
-}
-
-/* Sets the stipple pattern for the text */
-static void
-set_stipple (EText *text, GdkBitmap *stipple, int reconfigure)
-{
- if (text->stipple && !reconfigure)
- gdk_bitmap_unref (text->stipple);
-
- text->stipple = stipple;
- if (stipple && !reconfigure)
- gdk_bitmap_ref (stipple);
-
- if (text->gc) {
- if (stipple) {
- gdk_gc_set_stipple (text->gc, stipple);
- gdk_gc_set_fill (text->gc, GDK_STIPPLED);
- } else
- gdk_gc_set_fill (text->gc, GDK_SOLID);
- }
-}
-
-/* Set_arg handler for the text item */
-static void
-e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EText *text;
- GdkColor color = { 0, 0, 0, 0, };
- GdkColor *pcolor;
- gboolean color_changed;
- int have_pixel;
-
- item = GNOME_CANVAS_ITEM (object);
- text = E_TEXT (object);
-
- color_changed = FALSE;
- have_pixel = FALSE;
-
- switch (arg_id) {
- case ARG_TEXT:
- if (text->text)
- g_free (text->text);
-
- text->text = g_strdup (GTK_VALUE_STRING (*arg));
- split_into_lines (text);
- recalc_bounds (text);
- break;
-
- case ARG_X:
- text->x = GTK_VALUE_DOUBLE (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_Y:
- text->y = GTK_VALUE_DOUBLE (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_FONT:
- if (text->font)
- gdk_font_unref (text->font);
-
- text->font = gdk_font_load (GTK_VALUE_STRING (*arg));
-
- if (item->canvas->aa) {
- if (text->suckfont)
- e_suck_font_free (text->suckfont);
-
- text->suckfont = e_suck_font (text->font);
- }
-
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_FONTSET:
- if (text->font)
- gdk_font_unref (text->font);
-
- text->font = gdk_fontset_load (GTK_VALUE_STRING (*arg));
-
- if (item->canvas->aa) {
- if (text->suckfont)
- e_suck_font_free (text->suckfont);
-
- text->suckfont = e_suck_font (text->font);
- }
-
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_FONT_GDK:
- if (text->font)
- gdk_font_unref (text->font);
-
- text->font = GTK_VALUE_BOXED (*arg);
- gdk_font_ref (text->font);
-
- if (item->canvas->aa) {
- if (text->suckfont)
- e_suck_font_free (text->suckfont);
-
- text->suckfont = e_suck_font (text->font);
- }
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_ANCHOR:
- text->anchor = GTK_VALUE_ENUM (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_JUSTIFICATION:
- text->justification = GTK_VALUE_ENUM (*arg);
- break;
-
- case ARG_CLIP_WIDTH:
- text->clip_width = fabs (GTK_VALUE_DOUBLE (*arg));
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_CLIP_HEIGHT:
- text->clip_height = fabs (GTK_VALUE_DOUBLE (*arg));
- recalc_bounds (text);
- break;
-
- case ARG_CLIP:
- text->clip = GTK_VALUE_BOOL (*arg);
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_X_OFFSET:
- text->xofs = GTK_VALUE_DOUBLE (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_Y_OFFSET:
- text->yofs = GTK_VALUE_DOUBLE (*arg);
- recalc_bounds (text);
- break;
-
- case ARG_FILL_COLOR:
- if (GTK_VALUE_STRING (*arg))
- gdk_color_parse (GTK_VALUE_STRING (*arg), &color);
-
- text->rgba = ((color.red & 0xff00) << 16 |
- (color.green & 0xff00) << 8 |
- (color.blue & 0xff00) |
- 0xff);
- color_changed = TRUE;
- break;
-
- case ARG_FILL_COLOR_GDK:
- pcolor = GTK_VALUE_BOXED (*arg);
- if (pcolor) {
- color = *pcolor;
- gdk_color_context_query_color (item->canvas->cc, &color);
- have_pixel = TRUE;
- }
-
- text->rgba = ((color.red & 0xff00) << 16 |
- (color.green & 0xff00) << 8 |
- (color.blue & 0xff00) |
- 0xff);
- color_changed = TRUE;
- break;
-
- case ARG_FILL_COLOR_RGBA:
- text->rgba = GTK_VALUE_UINT (*arg);
- color_changed = TRUE;
- break;
-
- case ARG_FILL_STIPPLE:
- set_stipple (text, GTK_VALUE_BOXED (*arg), FALSE);
- break;
-
- case ARG_EDITABLE:
- text->editable = GTK_VALUE_BOOL (*arg);
- break;
-
- case ARG_USE_ELLIPSIS:
- text->use_ellipsis = GTK_VALUE_BOOL (*arg);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- case ARG_ELLIPSIS:
- if (text->ellipsis)
- g_free (text->ellipsis);
-
- text->ellipsis = g_strdup (GTK_VALUE_STRING (*arg));
- calc_ellipsis (text);
- calc_line_widths (text);
- recalc_bounds (text);
- break;
-
- default:
- break;
- }
-
- if (color_changed) {
- if (have_pixel)
- text->pixel = color.pixel;
- else
- text->pixel = gnome_canvas_get_color_pixel (item->canvas, text->rgba);
-
- if (!item->canvas->aa)
- set_text_gc_foreground (text);
-
- gnome_canvas_item_request_update (item);
- }
-}
-
-/* Get_arg handler for the text item */
-static void
-e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- EText *text;
- GdkColor *color;
-
- text = E_TEXT (object);
-
- switch (arg_id) {
- case ARG_TEXT:
- GTK_VALUE_STRING (*arg) = g_strdup (text->text);
- break;
-
- case ARG_X:
- GTK_VALUE_DOUBLE (*arg) = text->x;
- break;
-
- case ARG_Y:
- GTK_VALUE_DOUBLE (*arg) = text->y;
- break;
-
- case ARG_FONT_GDK:
- GTK_VALUE_BOXED (*arg) = text->font;
- break;
-
- case ARG_ANCHOR:
- GTK_VALUE_ENUM (*arg) = text->anchor;
- break;
-
- case ARG_JUSTIFICATION:
- GTK_VALUE_ENUM (*arg) = text->justification;
- break;
-
- case ARG_CLIP_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = text->clip_width;
- break;
-
- case ARG_CLIP_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = text->clip_height;
- break;
-
- case ARG_CLIP:
- GTK_VALUE_BOOL (*arg) = text->clip;
- break;
-
- case ARG_X_OFFSET:
- GTK_VALUE_DOUBLE (*arg) = text->xofs;
- break;
-
- case ARG_Y_OFFSET:
- GTK_VALUE_DOUBLE (*arg) = text->yofs;
- break;
-
- case ARG_FILL_COLOR_GDK:
- color = g_new (GdkColor, 1);
- color->pixel = text->pixel;
- gdk_color_context_query_color (text->item.canvas->cc, color);
- GTK_VALUE_BOXED (*arg) = color;
- break;
-
- case ARG_FILL_COLOR_RGBA:
- GTK_VALUE_UINT (*arg) = text->rgba;
- break;
-
- case ARG_FILL_STIPPLE:
- GTK_VALUE_BOXED (*arg) = text->stipple;
- break;
-
- case ARG_TEXT_WIDTH:
- GTK_VALUE_DOUBLE (*arg) = text->max_width / text->item.canvas->pixels_per_unit;
- break;
-
- case ARG_TEXT_HEIGHT:
- GTK_VALUE_DOUBLE (*arg) = text->height / text->item.canvas->pixels_per_unit;
- break;
-
- case ARG_EDITABLE:
- GTK_VALUE_BOOL (*arg) = text->editable;
- break;
-
- case ARG_USE_ELLIPSIS:
- GTK_VALUE_BOOL (*arg) = text->use_ellipsis;
- break;
-
- case ARG_ELLIPSIS:
- GTK_VALUE_STRING (*arg) = g_strdup (text->ellipsis);
- break;
-
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-/* Update handler for the text item */
-static void
-e_text_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
-{
- EText *text;
- double x1, y1, x2, y2;
- ArtDRect i_bbox, c_bbox;
- int i;
-
- text = E_TEXT (item);
-
- if (parent_class->update)
- (* parent_class->update) (item, affine, clip_path, flags);
-
- if (!item->canvas->aa) {
- set_text_gc_foreground (text);
- set_stipple (text, text->stipple, TRUE);
- get_bounds (text, &x1, &y1, &x2, &y2);
-
- gnome_canvas_update_bbox (item, x1, y1, x2, y2);
- } else {
- /* aa rendering */
- for (i = 0; i < 6; i++)
- text->affine[i] = affine[i];
- get_bounds_item_relative (text, &i_bbox.x0, &i_bbox.y0, &i_bbox.x1, &i_bbox.y1);
- art_drect_affine_transform (&c_bbox, &i_bbox, affine);
- gnome_canvas_update_bbox (item, c_bbox.x0, c_bbox.y0, c_bbox.x1, c_bbox.y1);
-
- }
-}
-
-/* Realize handler for the text item */
-static void
-e_text_realize (GnomeCanvasItem *item)
-{
- EText *text;
-
- text = E_TEXT (item);
-
- if (parent_class->realize)
- (* parent_class->realize) (item);
-
- text->gc = gdk_gc_new (item->canvas->layout.bin_window);
-
- text->i_cursor = gdk_cursor_new (GDK_XTERM);
- text->default_cursor = gdk_cursor_new (GDK_LEFT_PTR);
-}
-
-/* Unrealize handler for the text item */
-static void
-e_text_unrealize (GnomeCanvasItem *item)
-{
- EText *text;
-
- text = E_TEXT (item);
-
- gdk_gc_unref (text->gc);
- text->gc = NULL;
-
- gdk_cursor_destroy (text->i_cursor);
- gdk_cursor_destroy (text->default_cursor);
-
- if (parent_class->unrealize)
- (* parent_class->unrealize) (item);
-}
-
-/* Calculates the x position of the specified line of text, based on the text's justification */
-static double
-get_line_xpos_item_relative (EText *text, struct line *line)
-{
- double x;
-
- x = text->x;
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- x -= text->max_width / 2;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- x -= text->max_width;
- break;
- }
-
- switch (text->justification) {
- case GTK_JUSTIFY_RIGHT:
- x += text->max_width - line->width;
- break;
-
- case GTK_JUSTIFY_CENTER:
- x += (text->max_width - line->width) * 0.5;
- break;
-
- default:
- /* For GTK_JUSTIFY_LEFT, we don't have to do anything. We do not support
- * GTK_JUSTIFY_FILL, yet.
- */
- break;
- }
-
- return x;
-}
-
-/* Calculates the y position of the first line of text. */
-static double
-get_line_ypos_item_relative (EText *text)
-{
- double y;
-
- y = text->y;
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- y -= text->height / 2;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- y -= text->height;
- break;
- }
-
- return y;
-}
-
-/* Calculates the x position of the specified line of text, based on the text's justification */
-static int
-get_line_xpos (EText *text, struct line *line)
-{
- int x;
-
- x = text->cx;
-
- switch (text->justification) {
- case GTK_JUSTIFY_RIGHT:
- x += text->max_width - line->width;
- break;
-
- case GTK_JUSTIFY_CENTER:
- x += (text->max_width - line->width) / 2;
- break;
-
- default:
- /* For GTK_JUSTIFY_LEFT, we don't have to do anything. We do not support
- * GTK_JUSTIFY_FILL, yet.
- */
- break;
- }
-
- return x;
-}
-
-static void
-_get_tep(EText *text)
-{
- if (!text->tep) {
- text->tep = e_text_event_processor_emacs_like_new();
- gtk_object_ref (GTK_OBJECT (text->tep));
- gtk_object_sink (GTK_OBJECT (text->tep));
- gtk_signal_connect(GTK_OBJECT(text->tep),
- "command",
- GTK_SIGNAL_FUNC(e_text_command),
- (gpointer) text);
- }
-}
-
-/* Draw handler for the text item */
-static void
-e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height)
-{
- EText *text;
- GdkRectangle rect, *clip_rect;
- struct line *lines;
- int i;
- int xpos, ypos;
- int start_char, end_char;
- int sel_start, sel_end;
- GdkRectangle sel_rect;
- GdkGC *fg_gc;
- GnomeCanvas *canvas;
-
- text = E_TEXT (item);
- canvas = GNOME_CANVAS_ITEM(text)->canvas;
-
- fg_gc = GTK_WIDGET(canvas)->style->fg_gc[text->has_selection ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE];
-
- if (!text->text || !text->font)
- return;
-
- clip_rect = NULL;
- if (text->clip) {
- rect.x = text->clip_cx - x;
- rect.y = text->clip_cy - y;
- rect.width = text->clip_cwidth;
- rect.height = text->clip_cheight;
-
- gdk_gc_set_clip_rectangle (text->gc, &rect);
- gdk_gc_set_clip_rectangle (fg_gc, &rect);
- clip_rect = &rect;
- }
- lines = text->lines;
- ypos = text->cy + text->font->ascent;
-
- if (text->stipple)
- gnome_canvas_set_stipple_origin (item->canvas, text->gc);
-
- for (i = 0; i < text->num_lines; i++) {
- if (lines->length != 0) {
- xpos = get_line_xpos (text, lines);
- if (text->editing) {
- xpos -= text->xofs_edit;
- start_char = lines->text - text->text;
- end_char = start_char + lines->length;
- sel_start = text->selection_start;
- sel_end = text->selection_end;
- if (sel_start > sel_end ) {
- sel_start ^= sel_end;
- sel_end ^= sel_start;
- sel_start ^= sel_end;
- }
- if ( sel_start < start_char )
- sel_start = start_char;
- if ( sel_end > end_char )
- sel_end = end_char;
- if ( sel_start < sel_end ) {
- sel_rect.x = xpos - x + gdk_text_width (text->font,
- lines->text,
- sel_start - start_char);
- sel_rect.y = ypos - y - text->font->ascent;
- sel_rect.width = gdk_text_width (text->font,
- lines->text + sel_start - start_char,
- sel_end - sel_start);
- sel_rect.height = text->font->ascent + text->font->descent;
- gtk_paint_flat_box(GTK_WIDGET(item->canvas)->style,
- drawable,
- text->has_selection ?
- GTK_STATE_SELECTED :
- GTK_STATE_ACTIVE,
- GTK_SHADOW_NONE,
- clip_rect,
- GTK_WIDGET(item->canvas),
- "text",
- sel_rect.x,
- sel_rect.y,
- sel_rect.width,
- sel_rect.height);
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x,
- ypos - y,
- lines->text,
- sel_start - start_char);
- gdk_draw_text (drawable,
- text->font,
- fg_gc,
- xpos - x + gdk_text_width (text->font,
- lines->text,
- sel_start - start_char),
- ypos - y,
- lines->text + sel_start - start_char,
- sel_end - sel_start);
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x + gdk_text_width (text->font,
- lines->text,
- sel_end - start_char),
- ypos - y,
- lines->text + sel_end - start_char,
- end_char - sel_end);
- } else {
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x,
- ypos - y,
- lines->text,
- lines->length);
- }
- if (text->selection_start == text->selection_end &&
- text->selection_start >= start_char &&
- text->selection_start <= end_char &&
- text->show_cursor) {
- gdk_draw_rectangle (drawable,
- text->gc,
- TRUE,
- xpos - x + gdk_text_width (text->font,
- lines->text,
- sel_start - start_char),
- ypos - y - text->font->ascent,
- 1,
- text->font->ascent + text->font->descent);
- }
- } else {
- if ( text->clip && text->use_ellipsis && lines->ellipsis_length < lines->length) {
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x,
- ypos - y,
- lines->text,
- lines->ellipsis_length);
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x +
- lines->width - text->ellipsis_width,
- ypos - y,
- text->ellipsis ? text->ellipsis : "...",
- text->ellipsis ? strlen (text->ellipsis) : 3);
- } else
-
- gdk_draw_text (drawable,
- text->font,
- text->gc,
- xpos - x,
- ypos - y,
- lines->text,
- lines->length);
- }
- }
-
- ypos += text->font->ascent + text->font->descent;
- lines++;
- }
-
- if (text->clip) {
- gdk_gc_set_clip_rectangle (text->gc, NULL);
- gdk_gc_set_clip_rectangle (fg_gc, NULL);
- }
-}
-
-/* Render handler for the text item */
-static void
-e_text_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf)
-{
- EText *text;
- guint32 fg_color;
- double xpos, ypos;
- struct line *lines;
- int i, j;
- double affine[6];
- ETextSuckFont *suckfont;
- int dx, dy;
- ArtPoint start_i, start_c;
-
- text = E_TEXT (item);
-
- if (!text->text || !text->font || !text->suckfont)
- return;
-
- suckfont = text->suckfont;
-
- fg_color = text->rgba;
-
- gnome_canvas_buf_ensure_buf (buf);
-
- lines = text->lines;
- start_i.y = get_line_ypos_item_relative (text);
-
- art_affine_scale (affine, item->canvas->pixels_per_unit, item->canvas->pixels_per_unit);
- for (i = 0; i < 6; i++)
- affine[i] = text->affine[i];
-
- for (i = 0; i < text->num_lines; i++) {
- if (lines->length != 0) {
- start_i.x = get_line_xpos_item_relative (text, lines);
- art_affine_point (&start_c, &start_i, text->affine);
- xpos = start_c.x;
- ypos = start_c.y;
-
- for (j = 0; j < lines->length; j++) {
- ETextSuckChar *ch;
-
- ch = &suckfont->chars[(unsigned char)((lines->text)[j])];
-
- affine[4] = xpos;
- affine[5] = ypos;
- art_rgb_bitmap_affine (
- buf->buf,
- buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1,
- buf->buf_rowstride,
- suckfont->bitmap + (ch->bitmap_offset >> 3),
- ch->width,
- suckfont->bitmap_height,
- suckfont->bitmap_width >> 3,
- fg_color,
- affine,
- ART_FILTER_NEAREST, NULL);
-
- dx = ch->left_sb + ch->width + ch->right_sb;
- xpos += dx * affine[0];
- ypos += dx * affine[1];
- }
- }
-
- dy = text->font->ascent + text->font->descent;
- start_i.y += dy;
- lines++;
- }
-
- buf->is_bg = 0;
-}
-
-/* Point handler for the text item */
-static double
-e_text_point (GnomeCanvasItem *item, double x, double y,
- int cx, int cy, GnomeCanvasItem **actual_item)
-{
- EText *text;
- int i;
- struct line *lines;
- int x1, y1, x2, y2;
- int font_height;
- int dx, dy;
- double dist, best;
-
- text = E_TEXT (item);
-
- *actual_item = item;
-
- /* The idea is to build bounding rectangles for each of the lines of
- * text (clipped by the clipping rectangle, if it is activated) and see
- * whether the point is inside any of these. If it is, we are done.
- * Otherwise, calculate the distance to the nearest rectangle.
- */
-
- if (text->font)
- font_height = text->font->ascent + text->font->descent;
- else
- font_height = 0;
-
- best = 1.0e36;
-
- lines = text->lines;
-
- for (i = 0; i < text->num_lines; i++) {
- /* Compute the coordinates of rectangle for the current line,
- * clipping if appropriate.
- */
-
- x1 = get_line_xpos (text, lines);
- y1 = text->cy + i * font_height;
- x2 = x1 + lines->width;
- y2 = y1 + font_height;
-
- if (text->clip) {
- if (x1 < text->clip_cx)
- x1 = text->clip_cx;
-
- if (y1 < text->clip_cy)
- y1 = text->clip_cy;
-
- if (x2 > (text->clip_cx + text->clip_width))
- x2 = text->clip_cx + text->clip_width;
-
- if (y2 > (text->clip_cy + text->clip_height))
- y2 = text->clip_cy + text->clip_height;
-
- if ((x1 >= x2) || (y1 >= y2))
- continue;
- }
-
- /* Calculate distance from point to rectangle */
-
- if (cx < x1)
- dx = x1 - cx;
- else if (cx >= x2)
- dx = cx - x2 + 1;
- else
- dx = 0;
-
- if (cy < y1)
- dy = y1 - cy;
- else if (cy >= y2)
- dy = cy - y2 + 1;
- else
- dy = 0;
-
- if ((dx == 0) && (dy == 0))
- return 0.0;
-
- dist = sqrt (dx * dx + dy * dy);
- if (dist < best)
- best = dist;
-
- /* Next! */
-
- lines++;
- }
-
- return best / item->canvas->pixels_per_unit;
-}
-
-/* Bounds handler for the text item */
-static void
-e_text_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
-{
- EText *text;
- double width, height;
-
- text = E_TEXT (item);
-
- *x1 = text->x;
- *y1 = text->y;
-
- if (text->clip) {
- width = text->clip_width;
- height = text->clip_height;
- } else {
- width = text->max_width / item->canvas->pixels_per_unit;
- height = text->height / item->canvas->pixels_per_unit;
- }
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- *x1 -= width / 2.0;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- *x1 -= width;
- break;
- }
-
- switch (text->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- *y1 -= height / 2.0;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- *y1 -= height;
- break;
- }
-
- *x2 = *x1 + width;
- *y2 = *y1 + height;
-}
-
-static void
-_get_xy_from_position (EText *text, gint position, gint *xp, gint *yp)
-{
- if (xp || yp) {
- struct line *lines;
- int x, y;
- int j;
- x = get_line_xpos (text, lines);
- y = text->cy;
- for (j = 0, lines = text->lines; j < text->num_lines; lines++, j++) {
- if (lines->text > text->text + position)
- break;
- y += text->font->ascent + text->font->descent;
- }
- lines --;
- y -= text->font->descent;
-
- x += gdk_text_width (text->font,
- lines->text,
- position - (lines->text - text->text));
- x -= text->xofs_edit;
- if (xp)
- *xp = x;
- if (yp)
- *yp = y;
- }
-}
-
-static gint
-_get_position_from_xy (EText *text, gint x, gint y)
-{
- int i, j;
- int ypos = text->cy;
- int xpos;
- struct line *lines;
- j = 0;
- while (y > ypos) {
- ypos += text->font->ascent + text->font->descent;
- j ++;
- }
- j--;
- if (j >= text->num_lines)
- j = text->num_lines - 1;
- if (j < 0)
- j = 0;
- i = 0;
- lines = text->lines;
- lines += j;
- x += text->xofs_edit;
- xpos = get_line_xpos (text, lines);
- for(i = 0; i < lines->length; i++) {
- int charwidth = gdk_text_width(text->font,
- lines->text + i,
- 1);
- xpos += charwidth / 2;
- if (xpos > x) {
- break;
- }
- xpos += (charwidth + 1) / 2;
- }
- return lines->text + i - text->text;
-}
-
-#define SCROLL_WAIT_TIME 30000
-
-static gboolean
-_blink_scroll_timeout (gpointer data)
-{
- EText *text = E_TEXT(data);
- gulong current_time;
- gboolean scroll = FALSE;
- gboolean redraw = FALSE;
-
- g_timer_elapsed(text->timer, &current_time);
-
- if (text->scroll_start + SCROLL_WAIT_TIME > 1000000) {
- if (current_time > text->scroll_start - (1000000 - SCROLL_WAIT_TIME) &&
- current_time < text->scroll_start)
- scroll = TRUE;
- } else {
- if (current_time > text->scroll_start + SCROLL_WAIT_TIME ||
- current_time < text->scroll_start)
- scroll = TRUE;
- }
- if (scroll && text->button_down) {
- if (text->lastx - text->clip_cx > text->clip_cwidth &&
- text->xofs_edit < text->max_width - text->clip_cwidth) {
- text->xofs_edit += 4;
- if (text->xofs_edit > text->max_width - text->clip_cwidth + 1)
- text->xofs_edit = text->max_width - text->clip_cwidth + 1;
- redraw = TRUE;
- }
- if (text->lastx - text->clip_cx < 0 &&
- text->xofs_edit > 0) {
- text->xofs_edit -= 4;
- if (text->xofs_edit < 0)
- text->xofs_edit = 0;
- redraw = TRUE;
- }
- if (redraw) {
- ETextEventProcessorEvent e_tep_event;
- e_tep_event.type = GDK_MOTION_NOTIFY;
- e_tep_event.motion.state = text->last_state;
- e_tep_event.motion.time = 0;
- e_tep_event.motion.position = _get_position_from_xy(text, text->lastx, text->lasty);
- _get_tep(text);
- e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
- text->scroll_start = current_time;
- }
- }
-
- if (!((current_time / 500000) % 2)) {
- if (!text->show_cursor)
- redraw = TRUE;
- text->show_cursor = TRUE;
- } else {
- if (text->show_cursor)
- redraw = TRUE;
- text->show_cursor = FALSE;
- }
- if (redraw)
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text));
- return TRUE;
-}
-
-static gint
-e_text_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EText *text = E_TEXT(item);
- ETextEventProcessorEvent e_tep_event;
-
- gint return_val = 0;
-
- e_tep_event.type = event->type;
- switch (event->type) {
- case GDK_FOCUS_CHANGE:
- if (text->editable) {
- GdkEventFocus *focus_event;
- focus_event = (GdkEventFocus *) event;
- if (focus_event->in) {
- if(!text->editing) {
- text->editing = TRUE;
- if ( text->pointer_in ) {
- if ( text->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->i_cursor);
- text->default_cursor_shown = FALSE;
- }
- }
- text->selection_start = 0;
- text->selection_end = 0;
- text->select_by_word = FALSE;
- text->xofs_edit = 0;
- if (text->timeout_id == 0)
- text->timeout_id = g_timeout_add(10, _blink_scroll_timeout, text);
- text->timer = g_timer_new();
- g_timer_elapsed(text->timer, &(text->scroll_start));
- g_timer_start(text->timer);
- }
- } else {
- text->editing = FALSE;
- if ( ! text->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->default_cursor);
- text->default_cursor_shown = TRUE;
- }
- if (text->timeout_id) {
- g_source_remove(text->timeout_id);
- text->timeout_id = 0;
- }
- if (text->timer) {
- g_timer_stop(text->timer);
- g_timer_destroy(text->timer);
- text->timer = NULL;
- }
- }
- calc_line_widths (text);
- }
- return_val = 0;
- break;
- case GDK_KEY_PRESS: /* Fall Through */
- case GDK_KEY_RELEASE:
- if (text->editing) {
- GdkEventKey key = event->key;
- e_tep_event.key.time = key.time;
- e_tep_event.key.state = key.state;
- e_tep_event.key.keyval = key.keyval;
- e_tep_event.key.length = key.length;
- e_tep_event.key.string = key.string;
- _get_tep(text);
- return e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
- }
- else
- return 0;
- break;
- case GDK_BUTTON_PRESS: /* Fall Through */
- case GDK_BUTTON_RELEASE:
- if (text->editing) {
- GdkEventButton button = event->button;
- e_tep_event.button.time = button.time;
- e_tep_event.button.state = button.state;
- e_tep_event.button.button = button.button;
- e_tep_event.button.position = _get_position_from_xy(text, button.x, button.y);
- _get_tep(text);
- return_val = e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
- if (event->button.button == 1) {
- if (event->type == GDK_BUTTON_PRESS)
- text->button_down = TRUE;
- else
- text->button_down = FALSE;
- }
- text->lastx = button.x;
- text->lasty = button.y;
- text->last_state = button.state;
- } else if (text->editable && event->type == GDK_BUTTON_RELEASE && event->button.button == 1) {
- gnome_canvas_item_grab_focus (item);
- return 1;
- }
- break;
- case GDK_MOTION_NOTIFY:
- if (text->editing) {
- GdkEventMotion motion = event->motion;
- e_tep_event.motion.time = motion.time;
- e_tep_event.motion.state = motion.state;
- e_tep_event.motion.position = _get_position_from_xy(text, motion.x, motion.y);
- _get_tep(text);
- return_val = e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
- text->lastx = motion.x;
- text->lasty = motion.y;
- text->last_state = motion.state;
- }
- break;
- case GDK_ENTER_NOTIFY:
- text->pointer_in = TRUE;
- if (text->editing) {
- if ( text->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->i_cursor);
- text->default_cursor_shown = FALSE;
- }
- }
- break;
- case GDK_LEAVE_NOTIFY:
- text->pointer_in = FALSE;
- if (text->editing) {
- if ( ! text->default_cursor_shown ) {
- gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->default_cursor);
- text->default_cursor_shown = TRUE;
- }
- }
- break;
- default:
- break;
- }
- if (return_val)
- return return_val;
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->event)
- return GNOME_CANVAS_ITEM_CLASS(parent_class)->event(item, event);
- else
- return 0;
-}
-
-static int
-_get_position(EText *text, ETextEventProcessorCommand *command)
-{
- int i;
- int length;
- int x, y;
-
- switch (command->position) {
-
- case E_TEP_VALUE:
- return command->value;
-
- case E_TEP_SELECTION:
- return text->selection_end;
-
- case E_TEP_START_OF_BUFFER:
- return 0;
- case E_TEP_END_OF_BUFFER:
- return strlen(text->text);
-
- case E_TEP_START_OF_LINE:
- for (i = text->selection_end - 2; i > 0; i--)
- if (text->text[i] == '\n') {
- i++;
- break;
- }
- return i;
- case E_TEP_END_OF_LINE:
- length = strlen(text->text);
- for (i = text->selection_end + 1; i < length; i++)
- if (text->text[i] == '\n') {
- break;
- }
- if (i > length)
- i = length;
- return i;
-
- case E_TEP_FORWARD_CHARACTER:
- length = strlen(text->text);
- i = text->selection_end + 1;
- if (i > length)
- i = length;
- return i;
- case E_TEP_BACKWARD_CHARACTER:
- i = text->selection_end - 1;
- if (i < 0)
- i = 0;
- return i;
-
- case E_TEP_FORWARD_WORD:
- length = strlen(text->text);
- for (i = text->selection_end + 1; i < length; i++)
- if (isspace(text->text[i])) {
- break;
- }
- if (i > length)
- i = length;
- return i;
- case E_TEP_BACKWARD_WORD:
- for (i = text->selection_end - 2; i > 0; i--)
- if (isspace(text->text[i])) {
- i++;
- break;
- }
- if (i < 0)
- i = 0;
- return i;
-
- case E_TEP_FORWARD_LINE:
- _get_xy_from_position(text, text->selection_end, &x, &y);
- y += text->font->ascent + text->font->descent;
- return _get_position_from_xy(text, x, y);
- case E_TEP_BACKWARD_LINE:
- _get_xy_from_position(text, text->selection_end, &x, &y);
- y -= text->font->ascent + text->font->descent;
- return _get_position_from_xy(text, x, y);
-
- case E_TEP_FORWARD_PARAGRAPH:
- case E_TEP_BACKWARD_PARAGRAPH:
-
- case E_TEP_FORWARD_PAGE:
- case E_TEP_BACKWARD_PAGE:
- return text->selection_end;
- default:
- return text->selection_end;
- }
-}
-
-static void
-_delete_selection(EText *text)
-{
- gint length = strlen(text->text);
- if (text->selection_end == text->selection_start)
- return;
- if (text->selection_end < text->selection_start) {
- text->selection_end ^= text->selection_start;
- text->selection_start ^= text->selection_end;
- text->selection_end ^= text->selection_start;
- }
- memmove( text->text + text->selection_start,
- text->text + text->selection_end,
- length - text->selection_end + 1 );
- length -= text->selection_end - text->selection_start;
- text->selection_end = text->selection_start;
-}
-
-static void
-_insert(EText *text, char *string, int value)
-{
- if (value > 0) {
- char *temp;
- gint length = strlen(text->text);
- temp = g_new(gchar, length + value + 1);
- strncpy(temp, text->text, text->selection_start);
- strncpy(temp + text->selection_start, string, value);
- strcpy(temp + text->selection_start + value, text->text + text->selection_start);
- g_free(text->text);
- text->text = temp;
- text->selection_start += value;
- text->selection_end = text->selection_start;
- }
-}
-
-static void
-e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gpointer data)
-{
- EText *text = E_TEXT(data);
- int sel_start, sel_end;
- switch (command->action) {
- case E_TEP_MOVE:
- text->selection_start = _get_position(text, command);
- text->selection_end = text->selection_start;
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_SELECT:
- text->selection_end = _get_position(text, command);
- sel_start = MIN(text->selection_start, text->selection_end);
- sel_end = MAX(text->selection_start, text->selection_end);
- if (sel_start != sel_end) {
- e_text_supply_selection (text, command->time, GDK_SELECTION_PRIMARY, text->text + sel_start, sel_end - sel_start);
- } else if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_DELETE:
- if (text->selection_end == text->selection_start) {
- text->selection_end = _get_position(text, command);
- }
- _delete_selection(text);
- split_into_lines (text);
- recalc_bounds (text);
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
-
- case E_TEP_INSERT:
- if (text->selection_end != text->selection_start) {
- _delete_selection(text);
- }
- _insert(text, command->string, command->value);
- split_into_lines (text);
- recalc_bounds (text);
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_COPY:
- sel_start = MIN(text->selection_start, text->selection_end);
- sel_end = MAX(text->selection_start, text->selection_end);
- if (sel_start != sel_end) {
- e_text_supply_selection (text, command->time, clipboard_atom, text->text + sel_start, sel_end - sel_start);
- }
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_PASTE:
- e_text_get_selection (text, clipboard_atom, command->time);
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_GET_SELECTION:
- e_text_get_selection (text, GDK_SELECTION_PRIMARY, command->time);
- break;
- case E_TEP_ACTIVATE:
- if (text->timer) {
- g_timer_reset(text->timer);
- }
- break;
- case E_TEP_SET_SELECT_BY_WORD:
- text->select_by_word = command->value;
- break;
- case E_TEP_GRAB:
- gnome_canvas_item_grab (GNOME_CANVAS_ITEM(text),
- GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
- text->i_cursor,
- command->time);
- break;
- case E_TEP_UNGRAB:
- gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM(text), command->time);
- break;
- case E_TEP_NOP:
- break;
- }
-
- if (!text->button_down) {
- int x;
- int i;
- struct line *lines = text->lines;
- for (lines = text->lines, i = 0; i < text->num_lines ; i++, lines ++) {
- if (lines->text - text->text > text->selection_end) {
- break;
- }
- }
- lines --;
- x = gdk_text_width(text->font,
- lines->text,
- text->selection_end - (lines->text - text->text));
-
-
- if (x < text->xofs_edit) {
- text->xofs_edit = x;
- }
-
- if (2 + x - text->clip_width > text->xofs_edit) {
- text->xofs_edit = 2 + x - text->clip_width;
- }
- }
-
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text));
-}
-
-static void _invisible_destroy (GtkInvisible *invisible,
- EText *text)
-{
- text->invisible = NULL;
-}
-
-static GtkWidget *e_text_get_invisible(EText *text)
-{
- GtkWidget *invisible;
- if (text->invisible) {
- invisible = text->invisible;
- } else {
- invisible = gtk_invisible_new();
- text->invisible = invisible;
-
- gtk_selection_add_target (invisible,
- GDK_SELECTION_PRIMARY,
- GDK_SELECTION_TYPE_STRING,
- E_SELECTION_PRIMARY);
- gtk_selection_add_target (invisible,
- clipboard_atom,
- GDK_SELECTION_TYPE_STRING,
- E_SELECTION_CLIPBOARD);
-
- gtk_signal_connect (GTK_OBJECT(invisible), "selection_get",
- GTK_SIGNAL_FUNC (_selection_get),
- text);
- gtk_signal_connect (GTK_OBJECT(invisible), "selection_clear_event",
- GTK_SIGNAL_FUNC (_selection_clear_event),
- text);
- gtk_signal_connect (GTK_OBJECT(invisible), "selection_received",
- GTK_SIGNAL_FUNC (_selection_received),
- text);
-
- gtk_signal_connect (GTK_OBJECT(invisible), "destroy",
- GTK_SIGNAL_FUNC (_invisible_destroy),
- text);
- }
- return invisible;
-}
-
-static void
-_selection_clear_event (GtkInvisible *invisible,
- GdkEventSelection *event,
- EText *text)
-{
- if (event->selection == GDK_SELECTION_PRIMARY) {
- g_free (text->primary_selection);
- text->primary_selection = NULL;
- text->primary_length = 0;
-
- text->has_selection = FALSE;
- gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text));
-
- } else if (event->selection == clipboard_atom) {
- g_free (text->clipboard_selection);
- text->clipboard_selection = NULL;
- text->clipboard_length = 0;
- }
-}
-
-static void
-_selection_get (GtkInvisible *invisible,
- GtkSelectionData *selection_data,
- guint info,
- guint time_stamp,
- EText *text)
-{
- switch (info) {
- case E_SELECTION_PRIMARY:
- gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING,
- 8, text->primary_selection, text->primary_length);
- break;
- case E_SELECTION_CLIPBOARD:
- gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING,
- 8, text->clipboard_selection, text->clipboard_length);
- break;
- }
-}
-
-static void
-_selection_received (GtkInvisible *invisible,
- GtkSelectionData *selection_data,
- guint time,
- EText *text)
-{
- if (selection_data->length < 0 || selection_data->type != GDK_SELECTION_TYPE_STRING) {
- return;
- } else {
- ETextEventProcessorCommand command;
- command.action = E_TEP_INSERT;
- command.position = E_TEP_SELECTION;
- command.string = selection_data->data;
- command.value = selection_data->length;
- command.time = time;
- e_text_command(text->tep, &command, text);
- }
-}
-
-static void e_text_supply_selection (EText *text, guint time, GdkAtom selection, guchar *data, gint length)
-{
- gboolean successful;
- GtkWidget *invisible;
-
- invisible = e_text_get_invisible(text);
-
- if (selection == GDK_SELECTION_PRIMARY ) {
- if (text->primary_selection) {
- g_free (text->primary_selection);
- }
- text->primary_selection = g_strndup(data, length);
- text->primary_length = length;
- } else if (selection == clipboard_atom) {
- if (text->clipboard_selection) {
- g_free (text->clipboard_selection);
- }
- text->clipboard_selection = g_strndup(data, length);
- text->clipboard_length = length;
- }
-
- successful = gtk_selection_owner_set (invisible,
- selection,
- time);
-
- if (selection == GDK_SELECTION_PRIMARY)
- text->has_selection = successful;
-}
-
-static void
-e_text_get_selection(EText *text, GdkAtom selection, guint32 time)
-{
- GtkWidget *invisible;
- invisible = e_text_get_invisible(text);
- gtk_selection_convert(invisible,
- selection,
- GDK_SELECTION_TYPE_STRING,
- time);
-}
-
-#if 0
-static void
-e_text_real_copy_clipboard (EText *text)
-{
- guint32 time;
- gint selection_start_pos;
- gint selection_end_pos;
-
- g_return_if_fail (text != NULL);
- g_return_if_fail (E_IS_TEXT (text));
-
- time = gtk_text_get_event_time (text);
- selection_start_pos = MIN (text->selection_start, text->selection_end);
- selection_end_pos = MAX (text->selection_start, text->selection_end);
-
- if (selection_start_pos != selection_end_pos)
- {
- if (gtk_selection_owner_set (GTK_WIDGET (text->canvas),
- clipboard_atom,
- time))
- text->clipboard_text = "";
- }
-}
-
-static void
-e_text_real_paste_clipboard (EText *text)
-{
- guint32 time;
-
- g_return_if_fail (text != NULL);
- g_return_if_fail (E_IS_TEXT (text));
-
- time = e_text_get_event_time (text);
- if (text->editable)
- gtk_selection_convert (GTK_WIDGET(text->widget),
- clipboard_atom,
- gdk_atom_intern ("COMPOUND_TEXT", FALSE), time);
-}
-#endif
-
-/* Get the timestamp of the current event. Actually, the only thing
- * we really care about below is the key event
- */
-static guint32
-e_text_get_event_time (EText *text)
-{
- GdkEvent *event;
- guint32 tm = GDK_CURRENT_TIME;
-
- event = gtk_get_current_event();
-
- if (event)
- switch (event->type)
- {
- case GDK_MOTION_NOTIFY:
- tm = event->motion.time; break;
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- tm = event->button.time; break;
- case GDK_KEY_PRESS:
- case GDK_KEY_RELEASE:
- tm = event->key.time; break;
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY:
- tm = event->crossing.time; break;
- case GDK_PROPERTY_NOTIFY:
- tm = event->property.time; break;
- case GDK_SELECTION_CLEAR:
- case GDK_SELECTION_REQUEST:
- case GDK_SELECTION_NOTIFY:
- tm = event->selection.time; break;
- case GDK_PROXIMITY_IN:
- case GDK_PROXIMITY_OUT:
- tm = event->proximity.time; break;
- default: /* use current time */
- break;
- }
- gdk_event_free(event);
-
- return tm;
-}
-
-
-
-/* Routines for sucking fonts from the X server */
-
-static ETextSuckFont *
-e_suck_font (GdkFont *font)
-{
- ETextSuckFont *suckfont;
- int i;
- int x, y;
- char text[1];
- int lbearing, rbearing, ch_width, ascent, descent;
- GdkPixmap *pixmap;
- GdkColor black, white;
- GdkImage *image;
- GdkGC *gc;
- guchar *line;
- int width, height;
- int black_pixel, pixel;
-
- if (!font)
- return NULL;
-
- suckfont = g_new (ETextSuckFont, 1);
-
- height = font->ascent + font->descent;
- x = 0;
- for (i = 0; i < 256; i++) {
- text[0] = i;
- gdk_text_extents (font, text, 1,
- &lbearing, &rbearing, &ch_width, &ascent, &descent);
- suckfont->chars[i].left_sb = lbearing;
- suckfont->chars[i].right_sb = ch_width - rbearing;
- suckfont->chars[i].width = rbearing - lbearing;
- suckfont->chars[i].ascent = ascent;
- suckfont->chars[i].descent = descent;
- suckfont->chars[i].bitmap_offset = x;
- x += (ch_width + 31) & -32;
- }
-
- width = x;
-
- suckfont->bitmap_width = width;
- suckfont->bitmap_height = height;
- suckfont->ascent = font->ascent;
-
- pixmap = gdk_pixmap_new (NULL, suckfont->bitmap_width,
- suckfont->bitmap_height, 1);
- gc = gdk_gc_new (pixmap);
- gdk_gc_set_font (gc, font);
-
- black_pixel = BlackPixel (gdk_display, DefaultScreen (gdk_display));
- black.pixel = black_pixel;
- white.pixel = WhitePixel (gdk_display, DefaultScreen (gdk_display));
- gdk_gc_set_foreground (gc, &white);
- gdk_draw_rectangle (pixmap, gc, 1, 0, 0, width, height);
-
- gdk_gc_set_foreground (gc, &black);
- for (i = 0; i < 256; i++) {
- text[0] = i;
- gdk_draw_text (pixmap, font, gc,
- suckfont->chars[i].bitmap_offset - suckfont->chars[i].left_sb,
- font->ascent,
- text, 1);
- }
-
- /* The handling of the image leaves me with distinct unease. But this
- * is more or less copied out of gimp/app/text_tool.c, so it _ought_ to
- * work. -RLL
- */
-
- image = gdk_image_get (pixmap, 0, 0, width, height);
- suckfont->bitmap = g_malloc0 ((width >> 3) * height);
-
- line = suckfont->bitmap;
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- pixel = gdk_image_get_pixel (image, x, y);
- if (pixel == black_pixel)
- line[x >> 3] |= 128 >> (x & 7);
- }
- line += width >> 3;
- }
-
- gdk_image_destroy (image);
-
- /* free the pixmap */
- gdk_pixmap_unref (pixmap);
-
- /* free the gc */
- gdk_gc_destroy (gc);
-
- return suckfont;
-}
-
-static void
-e_suck_font_free (ETextSuckFont *suckfont)
-{
- g_free (suckfont->bitmap);
- g_free (suckfont);
-}
diff --git a/widgets/text/e-text.h b/widgets/text/e-text.h
deleted file mode 100644
index f4f43a156b..0000000000
--- a/widgets/text/e-text.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* EText - Text item for evolution.
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Author: Chris Lahey <clahey@umich.edu>
- *
- * A majority of code taken from:
- *
- * Text item type for GnomeCanvas widget
- *
- * GnomeCanvas is basically a port of the Tk toolkit's most excellent
- * canvas widget. Tk is copyrighted by the Regents of the University
- * of California, Sun Microsystems, and other parties.
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx> */
-
-#ifndef E_TEXT_H
-#define E_TEXT_H
-
-#include <gnome.h>
-#include "e-text-event-processor.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-/* Text item for the canvas. Text items are positioned by an anchor point and an anchor direction.
- *
- * A clipping rectangle may be specified for the text. The rectangle is anchored at the text's anchor
- * point, and is specified by clipping width and height parameters. If the clipping rectangle is
- * enabled, it will clip the text.
- *
- * In addition, x and y offset values may be specified. These specify an offset from the anchor
- * position. If used in conjunction with the clipping rectangle, these could be used to implement
- * simple scrolling of the text within the clipping rectangle.
- *
- * The following object arguments are available:
- *
- * name type read/write description
- * ------------------------------------------------------------------------------------------
- * text string RW The string of the text label
- * x double RW X coordinate of anchor point
- * y double RW Y coordinate of anchor point
- * font string W X logical font descriptor
- * fontset string W X logical fontset descriptor
- * font_gdk GdkFont* RW Pointer to a GdkFont
- * anchor GtkAnchorType RW Anchor side for the text
- * justification GtkJustification RW Justification for multiline text
- * fill_color string W X color specification for text
- * fill_color_gdk GdkColor* RW Pointer to an allocated GdkColor
- * fill_stipple GdkBitmap* RW Stipple pattern for filling the text
- * clip_width double RW Width of clip rectangle
- * clip_height double RW Height of clip rectangle
- * clip boolean RW Use clipping rectangle?
- * x_offset double RW Horizontal offset distance from anchor position
- * y_offset double RW Vertical offset distance from anchor position
- * text_width double R Used to query the width of the rendered text
- * text_height double R Used to query the rendered height of the text
- *
- * These are currently ignored in the AA version:
- * editable boolean RW Can this item be edited
- * use_ellipsis boolean RW Whether to use ellipsises if text gets cut off. Meaningless if clip == false.
- * ellipsis string RW The characters to use as ellipsis. NULL = "...".
- *
- * These are not implemented yet:
- * line_wrap boolean RW Line wrap when not editing.
- * line_wrap_on_edit boolean RW Switch to line wrap when editing.
- * background boolean RW Draw a background rectangle.
- * background_on_edit boolean RW Draw a background when editing.
- */
-
-#define E_TYPE_TEXT (e_text_get_type ())
-#define E_TEXT(obj) (GTK_CHECK_CAST ((obj), E_TYPE_TEXT, EText))
-#define E_TEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_TEXT, ETextClass))
-#define E_IS_TEXT(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_TEXT))
-#define E_IS_TEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_TEXT))
-
-
-typedef struct _EText EText;
-typedef struct _ETextClass ETextClass;
-typedef struct _ETextSuckFont ETextSuckFont;
-typedef struct _ETextSuckChar ETextSuckChar;
-
-struct _ETextSuckChar {
- int left_sb;
- int right_sb;
- int width;
- int ascent;
- int descent;
- int bitmap_offset; /* in pixels */
-};
-
-struct _ETextSuckFont {
- guchar *bitmap;
- gint bitmap_width;
- gint bitmap_height;
- gint ascent;
- ETextSuckChar chars[256];
-};
-
-struct _EText {
- GnomeCanvasItem item;
-
- char *text; /* Text to display */
- gpointer lines; /* Text split into lines (private field) */
- int num_lines; /* Number of lines of text */
-
- double x, y; /* Position at anchor */
- GdkFont *font; /* Font for text */
- GtkAnchorType anchor; /* Anchor side for text */
- GtkJustification justification; /* Justification for text */
-
- double clip_width; /* Width of optional clip rectangle */
- double clip_height; /* Height of optional clip rectangle */
-
- double xofs, yofs; /* Text offset distance from anchor position */
-
- gulong pixel; /* Fill color */
- GdkBitmap *stipple; /* Stipple for text */
- GdkGC *gc; /* GC for drawing text */
-
- int cx, cy; /* Top-left canvas coordinates for text */
- int clip_cx, clip_cy; /* Top-left canvas coordinates for clip rectangle */
- int clip_cwidth, clip_cheight; /* Size of clip rectangle in pixels */
- int max_width; /* Maximum width of text lines */
- int height; /* Rendered text height in pixels */
-
- guint clip : 1; /* Use clip rectangle? */
-
- /* Antialiased specific stuff follows */
- ETextSuckFont *suckfont; /* Sucked font */
- guint32 rgba; /* RGBA color for text */
- double affine[6]; /* The item -> canvas affine */
-
- char *ellipsis; /* The ellipsis characters. NULL = "...". */
- double ellipsis_width; /* The width of the ellipsis. */
- gboolean use_ellipsis; /* Whether to use the ellipsis. */
-
- gboolean editable; /* Item is editable */
- gboolean editing; /* Item is currently being edited */
-
- int xofs_edit; /* Offset because of editing */
-
- /* This needs to be reworked a bit once we get line wrapping. */
- int selection_start; /* Start of selection */
- int selection_end; /* End of selection */
- gboolean select_by_word; /* Current selection is by word */
-
- /* This section is for drag scrolling and blinking cursor. */
- gint timeout_id; /* Current timeout id for scrolling */
- GTimer *timer; /* Timer for blinking cursor and scrolling */
-
- gint lastx, lasty; /* Last x and y motion events */
- gint last_state; /* Last state */
- gulong scroll_start; /* Starting time for scroll (microseconds) */
-
- gint show_cursor; /* Is cursor currently shown */
- gboolean button_down; /* Is mouse button 1 down */
-
- ETextEventProcessor *tep; /* Text Event Processor */
-
- GtkWidget *invisible; /* For selection handling */
- gboolean has_selection; /* TRUE if we have the selection */
- gchar *primary_selection; /* Primary selection text */
- gint primary_length; /* Primary selection text length */
- gchar *clipboard_selection; /* Clipboard selection text */
- gint clipboard_length; /* Clipboard selection text length*/
-
- guint pointer_in : 1;
- guint default_cursor_shown : 1;
-
- GdkCursor *default_cursor;
- GdkCursor *i_cursor;
-};
-
-struct _ETextClass {
- GnomeCanvasItemClass parent_class;
-
- void (* resize) (EText *text);
- void (* change) (EText *text);
-};
-
-
-/* Standard Gtk function */
-GtkType e_text_get_type (void);
-
-
-END_GNOME_DECLS
-
-#endif