1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Author :
* Damon Chaplin <damon@helixcode.com>
*
* Copyright 2000, 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
*/
/*
* TaskEditor - a GtkObject which handles a libglade-loaded dialog to edit
* tasks.
*/
#include <config.h>
#include <gnome.h>
#include <glade/glade.h>
#include <e-util/e-util.h>
#include <cal-client/cal-client.h>
#include "task-editor.h"
typedef struct {
/* Glade XML data */
GladeXML *xml;
/* UI handler */
BonoboUIHandler *uih;
/* Calendar object we are editing; this is an internal copy and is not
* one of the read-only objects from the parent calendar.
*/
iCalObject *ico;
/* Widgets from the Glade file */
GtkWidget *app;
} TaskEditorPrivate;
static void task_editor_class_init (TaskEditorClass *class);
static void task_editor_init (TaskEditor *tedit);
TaskEditor * task_editor_construct (TaskEditor *tedit);
static gboolean get_widgets (TaskEditor *tedit);
static void init_widgets (TaskEditor *tedit);
static void create_menu (TaskEditor *tedit);
static void create_toolbar (TaskEditor *tedit);
static void task_editor_destroy (GtkObject *object);
static GtkObjectClass *parent_class;
E_MAKE_TYPE(task_editor, "TaskEditor", TaskEditor,
task_editor_class_init, task_editor_init, GTK_TYPE_OBJECT)
static void
task_editor_class_init (TaskEditorClass *class)
{
GtkObjectClass *object_class;
object_class = (GtkObjectClass *) class;
parent_class = gtk_type_class (GTK_TYPE_OBJECT);
object_class->destroy = task_editor_destroy;
}
static void
task_editor_init (TaskEditor *tedit)
{
TaskEditorPrivate *priv;
priv = g_new0 (TaskEditorPrivate, 1);
tedit->priv = priv;
}
/**
* task_editor_new:
* @Returns: a new #TaskEditor.
*
* Creates a new #TaskEditor.
**/
TaskEditor *
task_editor_new (void)
{
TaskEditor *tedit;
tedit = TASK_EDITOR (gtk_type_new (task_editor_get_type ()));
return task_editor_construct (tedit);
}
/**
* task_editor_construct:
* @tedit: A #TaskEditor.
*
* Constructs a task editor by loading its Glade XML file.
*
* Return value: The same object as @tedit, or NULL if the widgets could not be
* created. In the latter case, the task editor will automatically be
* destroyed.
**/
TaskEditor *
task_editor_construct (TaskEditor *tedit)
{
TaskEditorPrivate *priv;
g_return_val_if_fail (tedit != NULL, NULL);
g_return_val_if_fail (IS_TASK_EDITOR (tedit), NULL);
priv = tedit->priv;
/* Load the content widgets */
priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/task-editor-dialog.glade", NULL);
if (!priv->xml) {
g_message ("task_editor_construct(): Could not load the Glade XML file!");
goto error;
}
if (!get_widgets (tedit)) {
g_message ("task_editor_construct(): Could not find all widgets in the XML file!");
goto error;
}
init_widgets (tedit);
/* Construct the app */
priv->uih = bonobo_ui_handler_new ();
if (!priv->uih) {
g_message ("task_editor_construct(): Could not create the UI handler");
goto error;
}
bonobo_ui_handler_set_app (priv->uih, GNOME_APP (priv->app));
create_menu (tedit);
create_toolbar (tedit);
/* Hook to destruction of the dialog */
#if 0
gtk_signal_connect (GTK_OBJECT (priv->app), "delete_event",
GTK_SIGNAL_FUNC (app_delete_event_cb), tedit);
#endif
/* Show the dialog */
gtk_widget_show (priv->app);
return tedit;
error:
gtk_object_unref (GTK_OBJECT (tedit));
return NULL;
}
/* Gets the widgets from the XML file and returns if they are all available.
* For the widgets whose values can be simply set with e-dialog-utils, it does
* that as well.
*/
static gboolean
get_widgets (TaskEditor *tedit)
{
TaskEditorPrivate *priv;
priv = tedit->priv;
#define GW(name) glade_xml_get_widget (priv->xml, name)
priv->app = GW ("task-editor-dialog");
return TRUE;
}
/* Hooks the widget signals */
static void
init_widgets (TaskEditor *tedit)
{
TaskEditorPrivate *priv;
priv = tedit->priv;
}
/* Menu bar */
static GnomeUIInfo file_new_menu[] = {
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Task"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Task _Request"), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Mail Message"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Appointment"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Meeting Re_quest"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Contact"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Task"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Task _Request"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Journal Entry"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Note"), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ch_oose Form..."), NULL, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo file_page_setup_menu[] = {
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Memo Style"), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Define Print _Styles..."), NULL, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo file_menu[] = {
GNOMEUIINFO_MENU_NEW_SUBTREE (file_new_menu),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: S_end"), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_MENU_SAVE_ITEM (NULL, NULL),
GNOMEUIINFO_MENU_SAVE_AS_ITEM (NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Save Attac_hments..."), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Delete"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Move to Folder..."), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Cop_y to Folder..."), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_SUBTREE (N_("Page Set_up"), file_page_setup_menu),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print Pre_view"), NULL, NULL),
GNOMEUIINFO_MENU_PRINT_ITEM (NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_MENU_PROPERTIES_ITEM (NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_MENU_CLOSE_ITEM (NULL, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo edit_object_menu[] = {
GNOMEUIINFO_ITEM_NONE ("FIXME: what goes here?", NULL, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo edit_menu[] = {
GNOMEUIINFO_MENU_UNDO_ITEM (NULL, NULL),
GNOMEUIINFO_MENU_REDO_ITEM (NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_MENU_CUT_ITEM (NULL, NULL),
GNOMEUIINFO_MENU_COPY_ITEM (NULL, NULL),
GNOMEUIINFO_MENU_PASTE_ITEM (NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Paste _Special..."), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_MENU_CLEAR_ITEM (NULL, NULL),
GNOMEUIINFO_MENU_SELECT_ALL_ITEM (NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Mark as U_nread"), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_MENU_FIND_ITEM (NULL, NULL),
GNOMEUIINFO_MENU_FIND_AGAIN_ITEM (NULL, NULL),
GNOMEUIINFO_SUBTREE (N_("_Object"), edit_object_menu),
GNOMEUIINFO_END
};
static GnomeUIInfo view_previous_menu[] = {
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Item"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Unread Item"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: In_complete Task"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Fi_rst Item in Folder"), NULL, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo view_next_menu[] = {
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Item"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Unread Item"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: In_complete Task"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Last Item in Folder"), NULL, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo view_toolbars_menu[] = {
{ GNOME_APP_UI_TOGGLEITEM, N_("FIXME: _Standard"), NULL, NULL, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL },
{ GNOME_APP_UI_TOGGLEITEM, N_("FIXME: __Formatting"), NULL, NULL, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL },
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Customize..."), NULL, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo view_menu[] = {
GNOMEUIINFO_SUBTREE (N_("Pre_vious"), view_previous_menu),
GNOMEUIINFO_SUBTREE (N_("Ne_xt"), view_next_menu),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_SUBTREE (N_("_Toolbars"), view_toolbars_menu),
GNOMEUIINFO_END
};
static GnomeUIInfo insert_menu[] = {
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _File..."), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: It_em..."), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Object..."), NULL, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo format_menu[] = {
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Font..."), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Paragraph..."), NULL, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo tools_forms_menu[] = {
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ch_oose Form..."), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Desi_gn This Form"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: D_esign a Form..."), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Publish _Form..."), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Pu_blish Form As..."), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Script _Debugger"), NULL, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo tools_menu[] = {
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Spelling..."), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Chec_k Names"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Address _Book..."), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_SUBTREE (N_("_Forms"), tools_forms_menu),
GNOMEUIINFO_END
};
static GnomeUIInfo actions_menu[] = {
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _New Task"), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: S_end Status Report"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Mark Complete"), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Rec_urrence..."), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: S_kip Occurrence"), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Assig_n Task"), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Reply"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Reply to A_ll"), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: For_ward"), NULL, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo help_menu[] = {
GNOMEUIINFO_ITEM_NONE ("FIXME: fix Bonobo so it supports help items!", NULL, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo main_menu[] = {
GNOMEUIINFO_MENU_FILE_TREE (file_menu),
GNOMEUIINFO_MENU_EDIT_TREE (edit_menu),
GNOMEUIINFO_MENU_VIEW_TREE (view_menu),
GNOMEUIINFO_SUBTREE (N_("_Insert"), insert_menu),
GNOMEUIINFO_SUBTREE (N_("F_ormat"), format_menu),
GNOMEUIINFO_SUBTREE (N_("_Tools"), tools_menu),
GNOMEUIINFO_SUBTREE (N_("Actio_ns"), actions_menu),
GNOMEUIINFO_MENU_HELP_TREE (help_menu),
GNOMEUIINFO_END
};
/* Creates the menu bar for the event editor */
static void
create_menu (TaskEditor *tedit)
{
TaskEditorPrivate *priv;
BonoboUIHandlerMenuItem *list;
priv = tedit->priv;
bonobo_ui_handler_create_menubar (priv->uih);
list = bonobo_ui_handler_menu_parse_uiinfo_list_with_data (main_menu,
tedit);
bonobo_ui_handler_menu_add_list (priv->uih, "/", list);
}
/* Toolbar */
static GnomeUIInfo toolbar[] = {
GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Save and Close"),
N_("Save the task and close the dialog box"),
NULL,
GNOME_STOCK_PIXMAP_SAVE),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print..."),
N_("Print this item"), NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Insert File..."),
N_("Insert a file as an attachment"), NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Recurrence..."),
N_("Configure recurrence rules"), NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Assign Task..."),
N_("Assign the task to someone"), NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Delete"),
N_("Delete this item"), NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Previous"),
N_("Go to the previous item"), NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Next"),
N_("Go to the next item"), NULL),
GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Help"),
N_("See online help"), NULL, GNOME_STOCK_PIXMAP_HELP),
GNOMEUIINFO_END
};
/* Creates the toolbar for the event editor */
static void
create_toolbar (TaskEditor *tedit)
{
TaskEditorPrivate *priv;
BonoboUIHandlerToolbarItem *list;
GnomeDockItem *dock_item;
GtkWidget *toolbar_child;
priv = tedit->priv;
bonobo_ui_handler_create_toolbar (priv->uih, "Toolbar");
/* Fetch the toolbar. What a pain in the ass. */
dock_item = gnome_app_get_dock_item_by_name (GNOME_APP (priv->app), GNOME_APP_TOOLBAR_NAME);
g_assert (dock_item != NULL);
toolbar_child = gnome_dock_item_get_child (dock_item);
g_assert (toolbar_child != NULL && GTK_IS_TOOLBAR (toolbar_child));
/* Turn off labels as GtkToolbar sucks */
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar_child), GTK_TOOLBAR_ICONS);
list = bonobo_ui_handler_toolbar_parse_uiinfo_list_with_data (toolbar,
tedit);
bonobo_ui_handler_toolbar_add_list (priv->uih, "/Toolbar", list);
}
static void
task_editor_destroy (GtkObject *object)
{
TaskEditor *tedit;
g_return_if_fail (object != NULL);
g_return_if_fail (IS_TASK_EDITOR (object));
tedit = TASK_EDITOR (object);
}
|