aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorJP Rosevear <jpr@helixcode.com>2000-08-31 23:07:42 +0800
committerJP Rosevear <jpr@src.gnome.org>2000-08-31 23:07:42 +0800
commit72f85e235d8d49582709d912ba52f326e5dfddaa (patch)
treebd3c926b4618f28f381d37f44d42e016169accf1 /calendar
parente242f753cdc7ef38832a9fc22a2faae2015c4fbb (diff)
downloadgsoc2013-evolution-72f85e235d8d49582709d912ba52f326e5dfddaa.tar.gz
gsoc2013-evolution-72f85e235d8d49582709d912ba52f326e5dfddaa.tar.zst
gsoc2013-evolution-72f85e235d8d49582709d912ba52f326e5dfddaa.zip
Event editor destroyed callback to do hash cleanup
2000-08-31 JP Rosevear <jpr@helixcode.com> * gui/gnome-cal.c (editor_closed_cb): Event editor destroyed callback to do hash cleanup (gnome_calendar_edit_object): Set event editor calendar client. * gui/event-editor.h: Add new prototype * gui/event-editor.c: Trash signal stuff. We will manipulate the client directly. Make the toolbar save and menu save items work identically. Add icons to the toolbar. (save_event_object): Call cal_client_update_object (close_dialog): Unref the client and disconnect signals Actually destroy the event editor object. (obj_updated_cb): New function. Doesn't really do anything yet but it will inform the user the event has changed elsewhere in the future. (obj_removed_cb): ditto (event_editor_set_cal_client): New function to set the calendar client * gui/gnome-cal.c (gnome_calendar_new_appointment): Commit the sequence to the cal component and use non UTC times. svn path=/trunk/; revision=5142
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog24
-rw-r--r--calendar/gui/event-editor.c251
-rw-r--r--calendar/gui/event-editor.h7
-rw-r--r--calendar/gui/gnome-cal.c73
4 files changed, 217 insertions, 138 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 3ca3cc789d..dfe2f7f91e 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,27 @@
+2000-08-31 JP Rosevear <jpr@helixcode.com>
+
+ * gui/gnome-cal.c (editor_closed_cb): Event editor destroyed
+ callback to do hash cleanup
+ (gnome_calendar_edit_object): Set event editor calendar client.
+
+ * gui/event-editor.h: Add new prototype
+
+ * gui/event-editor.c: Trash signal stuff. We will manipulate
+ the client directly. Make the toolbar save and menu save items
+ work identically. Add icons to the toolbar.
+ (save_event_object): Call cal_client_update_object
+ (close_dialog): Unref the client and disconnect signals
+ Actually destroy the event editor object.
+ (obj_updated_cb): New function. Doesn't really do anything
+ yet but it will inform the user the event has changed elsewhere
+ in the future.
+ (obj_removed_cb): ditto
+ (event_editor_set_cal_client): New function to set the calendar
+ client
+
+ * gui/gnome-cal.c (gnome_calendar_new_appointment): Commit
+ the sequence to the cal component and use non UTC times.
+
2000-08-30 Lauris Kaplinski <lauris@helixcode.com>
* gui/print.c: Countless small changes for gnome-print 0.21+
diff --git a/calendar/gui/event-editor.c b/calendar/gui/event-editor.c
index b5a0322af1..6163cb9d12 100644
--- a/calendar/gui/event-editor.c
+++ b/calendar/gui/event-editor.c
@@ -38,9 +38,10 @@ typedef struct {
/* 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.
- */
+ /* Client to use */
+ CalClient *client;
+
+ /* Calendar object/uid we are editing; this is an internal copy */
CalComponent *comp;
/* Widgets from the Glade file */
@@ -117,14 +118,6 @@ typedef struct {
-/* Signal IDs */
-enum {
- SAVE_EVENT_OBJECT,
- RELEASED_EVENT_OBJECT,
- EDITOR_CLOSED,
- LAST_SIGNAL
-};
-
static void event_editor_class_init (EventEditorClass *class);
static void event_editor_init (EventEditor *ee);
static void event_editor_destroy (GtkObject *object);
@@ -148,8 +141,6 @@ static void recurrence_exception_added (GtkWidget *widget, EventEditor *ee);
static void recurrence_exception_deleted (GtkWidget *widget, EventEditor *ee);
static void recurrence_exception_changed (GtkWidget *widget, EventEditor *ee);
-static guint event_editor_signals[LAST_SIGNAL];
-
/**
@@ -194,34 +185,6 @@ event_editor_class_init (EventEditorClass *class)
parent_class = gtk_type_class (GTK_TYPE_OBJECT);
- event_editor_signals[SAVE_EVENT_OBJECT] =
- gtk_signal_new ("save_event_object",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EventEditorClass, save_event_object),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
-
- event_editor_signals[RELEASED_EVENT_OBJECT] =
- gtk_signal_new ("released_event_object",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EventEditorClass, released_event_object),
- gtk_marshal_NONE__STRING,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
-
- event_editor_signals[EDITOR_CLOSED] =
- gtk_signal_new ("editor_closed",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EventEditorClass, editor_closed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, event_editor_signals, LAST_SIGNAL);
-
object_class->destroy = event_editor_destroy;
}
@@ -260,11 +223,6 @@ event_editor_destroy (GtkObject *object)
}
if (priv->comp) {
- /* We do not emit the "released_event_object" signal here. If
- * the user closed the dialog box, then it has already been
- * released. If the application just destroyed the event
- * editor, then it had better clean up after itself.
- */
gtk_object_unref (GTK_OBJECT (priv->comp));
priv->comp = NULL;
}
@@ -1095,7 +1053,6 @@ dialog_to_comp_object (EventEditor *ee)
cal_component_commit_sequence (comp);
}
-/* Emits the "save_event_object" signal if the event editor is editing an object. */
static void
save_event_object (EventEditor *ee)
{
@@ -1113,8 +1070,8 @@ save_event_object (EventEditor *ee)
gtk_window_set_title (GTK_WINDOW (priv->app), title);
g_free (title);
- gtk_signal_emit (GTK_OBJECT (ee), event_editor_signals[SAVE_EVENT_OBJECT],
- priv->comp);
+ if (!cal_client_update_object (priv->client, priv->comp))
+ g_message ("save_event_object(): Could not update the object!");
}
/* Closes the dialog box and emits the appropriate signals */
@@ -1133,15 +1090,18 @@ close_dialog (EventEditor *ee)
priv->app = NULL;
if (priv->comp) {
- const char *uid;
-
- cal_component_get_uid (priv->comp, &uid);
- gtk_signal_emit (GTK_OBJECT (ee), event_editor_signals[RELEASED_EVENT_OBJECT], uid);
gtk_object_unref (GTK_OBJECT (priv->comp));
priv->comp = NULL;
}
- gtk_signal_emit (GTK_OBJECT (ee), event_editor_signals[EDITOR_CLOSED]);
+ if (priv->client) {
+ gtk_signal_disconnect_by_data (GTK_OBJECT (priv->client), ee);
+ gtk_object_unref (GTK_OBJECT (priv->client));
+ priv->client = NULL;
+ }
+
+
+ gtk_object_destroy (GTK_OBJECT (ee));
}
@@ -1359,47 +1319,46 @@ create_menu (EventEditor *ee)
-/* Toolbar/Save and Close callback */
-static void
-tb_save_and_close_cb (GtkWidget *widget, gpointer data)
-{
- EventEditor *ee;
-
- ee = EVENT_EDITOR (data);
- save_event_object (ee);
- close_dialog (ee);
-}
-
-
-
/* Toolbar */
static GnomeUIInfo toolbar[] = {
- GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Save and Close"),
- N_("Save the appointment and close the dialog box"),
- tb_save_and_close_cb,
+ GNOMEUIINFO_ITEM_STOCK (N_("Save"),
+ N_("Save the appointment"),
+ file_save_cb,
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_ITEM_STOCK (N_("FIXME: Print..."),
+ N_("Print this item"), NULL,
+ GNOME_STOCK_PIXMAP_PRINT),
+ GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Insert File..."),
+ N_("Insert a file as an attachment"), NULL,
+ GNOME_STOCK_PIXMAP_ATTACH),
+
GNOMEUIINFO_SEPARATOR,
- GNOMEUIINFO_ITEM_NONE (N_("FIXME: Invite Attendees..."),
- N_("Invite attendees to a meeting"), NULL),
+
+ GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Invite Attendees..."),
+ N_("Invite attendees to a meeting"), NULL,
+ GNOME_STOCK_PIXMAP_MULTIPLE),
+
GNOMEUIINFO_SEPARATOR,
- GNOMEUIINFO_ITEM_NONE (N_("FIXME: Delete"),
- N_("Delete this item"), NULL),
+
+ GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Delete"),
+ N_("Delete this item"), NULL,
+ GNOME_STOCK_PIXMAP_TRASH),
+
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: Previous"),
+ N_("Go to the previous item"), NULL,
+ GNOME_STOCK_PIXMAP_BACK),
+ GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Next"),
+ N_("Go to the next item"), NULL,
+ GNOME_STOCK_PIXMAP_FORWARD),
GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Help"),
- N_("See online help"), NULL, GNOME_STOCK_PIXMAP_HELP),
+ N_("See online help"), NULL,
+ GNOME_STOCK_PIXMAP_HELP),
GNOMEUIINFO_END
};
@@ -1529,6 +1488,109 @@ event_editor_new (void)
return event_editor_construct (EVENT_EDITOR (ee));
}
+/* Brings attention to a window by raising it and giving it focus */
+static void
+raise_and_focus (GtkWidget *widget)
+{
+ g_assert (GTK_WIDGET_REALIZED (widget));
+ gdk_window_show (widget->window);
+ gtk_widget_grab_focus (widget);
+}
+
+/* Callback used when the calendar client tells us that an object changed */
+static void
+obj_updated_cb (CalClient *client, const char *uid, gpointer data)
+{
+ EventEditor *ee;
+ EventEditorPrivate *priv;
+ CalComponent *comp;
+ CalClientGetStatus status;
+ gint day, event_num;
+
+ ee = EVENT_EDITOR (data);
+
+ g_return_if_fail (IS_EVENT_EDITOR (ee));
+
+ priv = ee->priv;
+
+ /* Get the event from the server. */
+ status = cal_client_get_object (priv->client, uid, &comp);
+
+ switch (status) {
+ case CAL_CLIENT_GET_SUCCESS:
+ /* Everything is fine */
+ break;
+
+ case CAL_CLIENT_GET_SYNTAX_ERROR:
+ g_message ("obj_updated_cb(): Syntax error when getting object `%s'", uid);
+ return;
+
+ case CAL_CLIENT_GET_NOT_FOUND:
+ /* The object is no longer in the server, so do nothing */
+ return;
+
+ default:
+ g_assert_not_reached ();
+ return;
+ }
+
+ raise_and_focus (priv->app);
+}
+
+/* Callback used when the calendar client tells us that an object was removed */
+static void
+obj_removed_cb (CalClient *client, const char *uid, gpointer data)
+{
+ EventEditor *ee;
+ EventEditorPrivate *priv;
+
+ ee = EVENT_EDITOR (data);
+
+ g_return_if_fail (ee != NULL);
+ g_return_if_fail (IS_EVENT_EDITOR (ee));
+
+ priv = ee->priv;
+
+ raise_and_focus (priv->app);
+}
+
+void
+event_editor_set_cal_client (EventEditor *ee, CalClient *client)
+{
+ EventEditorPrivate *priv;
+
+ g_return_if_fail (ee != NULL);
+ g_return_if_fail (IS_EVENT_EDITOR (ee));
+
+ priv = ee->priv;
+
+ if (client == priv->client)
+ return;
+
+ if (client)
+ g_return_if_fail (IS_CAL_CLIENT (client));
+
+ if (client)
+ g_return_if_fail (cal_client_is_loaded (client));
+
+ if (client)
+ gtk_object_ref (GTK_OBJECT (client));
+
+ if (priv->client) {
+ gtk_signal_disconnect_by_data (GTK_OBJECT (priv->client), ee);
+ gtk_object_unref (GTK_OBJECT (priv->client));
+ }
+
+ priv->client = client;
+
+ if (priv->client) {
+ gtk_signal_connect (GTK_OBJECT (priv->client), "obj_updated",
+ GTK_SIGNAL_FUNC (obj_updated_cb), ee);
+ gtk_signal_connect (GTK_OBJECT (priv->client), "obj_removed",
+ GTK_SIGNAL_FUNC (obj_removed_cb), ee);
+ }
+}
+
/**
* event_editor_set_event_object:
* @ee: An event editor.
@@ -1540,6 +1602,7 @@ void
event_editor_set_event_object (EventEditor *ee, CalComponent *comp)
{
EventEditorPrivate *priv;
+ CalClientGetStatus status;
char *title;
g_return_if_fail (ee != NULL);
@@ -1548,16 +1611,13 @@ event_editor_set_event_object (EventEditor *ee, CalComponent *comp)
priv = ee->priv;
if (priv->comp) {
- const char *uid;
-
- cal_component_get_uid (priv->comp, &uid);
- gtk_signal_emit (GTK_OBJECT (ee), event_editor_signals[RELEASED_EVENT_OBJECT], uid);
gtk_object_unref (GTK_OBJECT (priv->comp));
priv->comp = NULL;
}
- if (comp)
+ if (comp) {
priv->comp = cal_component_clone (comp);
+ }
title = make_title_from_comp (priv->comp);
gtk_window_set_title (GTK_WINDOW (priv->app), title);
@@ -1566,15 +1626,6 @@ event_editor_set_event_object (EventEditor *ee, CalComponent *comp)
fill_widgets (ee);
}
-/* Brings attention to a window by raising it and giving it focus */
-static void
-raise_and_focus (GtkWidget *widget)
-{
- g_assert (GTK_WIDGET_REALIZED (widget));
- gdk_window_show (widget->window);
- gtk_widget_grab_focus (widget);
-}
-
/**
* event_editor_focus:
* @ee: An event editor.
diff --git a/calendar/gui/event-editor.h b/calendar/gui/event-editor.h
index 1a61934766..009beb4dd5 100644
--- a/calendar/gui/event-editor.h
+++ b/calendar/gui/event-editor.h
@@ -49,12 +49,6 @@ struct _EventEditor {
struct _EventEditorClass {
GtkObjectClass parent_class;
-
- /* Notification signals */
-
- void (* save_event_object) (EventEditor *ee, CalComponent *comp);
- void (* released_event_object) (EventEditor *ee, const char *uid);
- void (* editor_closed) (EventEditor *ee);
};
@@ -63,6 +57,7 @@ EventEditor *event_editor_construct (EventEditor *ee);
EventEditor *event_editor_new (void);
+void event_editor_set_cal_client (EventEditor *ee, CalClient *client);
void event_editor_set_event_object (EventEditor *ee, CalComponent *comp);
void event_editor_focus (EventEditor *ee);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 2f6a8ddf4a..415d4abec0 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -1369,19 +1369,6 @@ gnome_calendar_set_selected_time_range (GnomeCalendar *gcal,
gnome_calendar_update_date_navigator (gcal);
}
-
-/* Callback used when an event editor requests that an object be saved */
-static void
-save_event_object_cb (EventEditor *ee, CalComponent *comp, gpointer data)
-{
- GnomeCalendar *gcal;
-
- gcal = GNOME_CALENDAR (data);
- if (!cal_client_update_object (gcal->client, comp))
- g_message ("save_event_object_cb(): Could not update the object!");
-}
-
-
/* Callback used when an event editor finishes editing an object */
static void
released_event_object_cb (EventEditor *ee, const char *uid, gpointer data)
@@ -1403,16 +1390,41 @@ released_event_object_cb (EventEditor *ee, const char *uid, gpointer data)
}
/* Callback used when an event editor dialog is closed */
+struct editor_closure
+{
+ GnomeCalendar *gcal;
+ char *uid;
+};
+
static void
-editor_closed_cb (EventEditor *ee, gpointer data)
+editor_closed_cb (GtkWidget *widget, gpointer data)
{
- gtk_object_unref (GTK_OBJECT (ee));
+ GnomeCalendar *gcal;
+ struct editor_closure *ec;
+ gboolean result;
+ gpointer orig_key;
+ char *orig_uid;
+
+ g_print ("editor_closed_cb ()\n");
+
+ ec = (struct editor_closure *)data;
+ gcal = ec->gcal;
+
+ result = g_hash_table_lookup_extended (gcal->object_editor_hash,
+ ec->uid, &orig_key, NULL);
+ g_assert (result != FALSE);
+
+ orig_uid = orig_key;
+
+ g_hash_table_remove (gcal->object_editor_hash, orig_uid);
+ g_free (orig_uid);
}
void
gnome_calendar_edit_object (GnomeCalendar *gcal, CalComponent *comp)
{
EventEditor *ee;
+ struct editor_closure *ec;
const char *uid;
g_return_if_fail (gcal != NULL);
@@ -1423,29 +1435,24 @@ gnome_calendar_edit_object (GnomeCalendar *gcal, CalComponent *comp)
ee = g_hash_table_lookup (gcal->object_editor_hash, uid);
if (!ee) {
+ ec = g_new0 (struct editor_closure, 1);
+
ee = event_editor_new ();
if (!ee) {
g_message ("gnome_calendar_edit_object(): Could not create the event editor");
return;
}
- /* FIXME: what to do when an event editor wants to switch
- * objects? We would need to know about it as well.
- */
-
- g_hash_table_insert (gcal->object_editor_hash, g_strdup (uid), ee);
-
- gtk_signal_connect (GTK_OBJECT (ee), "save_event_object",
- GTK_SIGNAL_FUNC (save_event_object_cb),
- gcal);
-
- gtk_signal_connect (GTK_OBJECT (ee), "released_event_object",
- GTK_SIGNAL_FUNC (released_event_object_cb),
- gcal);
+ ec->gcal = gcal;
+ ec->uid = g_strdup (uid);
+
+ g_hash_table_insert (gcal->object_editor_hash, ec->uid, ee);
- gtk_signal_connect (GTK_OBJECT (ee), "editor_closed",
- GTK_SIGNAL_FUNC (editor_closed_cb), gcal);
+ gtk_signal_connect (GTK_OBJECT (ee), "destroy",
+ GTK_SIGNAL_FUNC (editor_closed_cb),
+ ec);
+ event_editor_set_cal_client (EVENT_EDITOR (ee), gcal->client);
event_editor_set_event_object (EVENT_EDITOR (ee), comp);
}
@@ -1478,12 +1485,14 @@ gnome_calendar_new_appointment (GnomeCalendar *gcal)
comp = cal_component_new ();
cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT);
- itt = icaltime_from_timet (dtstart, 0, TRUE);
+ itt = icaltime_from_timet (dtstart, FALSE, FALSE);
cal_component_set_dtstart (comp, &dt);
- itt = icaltime_from_timet (dtend, 0, TRUE);
+ itt = icaltime_from_timet (dtend, FALSE, FALSE);
cal_component_set_dtend (comp, &dt);
+ cal_component_commit_sequence (comp);
+
gnome_calendar_edit_object (gcal, comp);
gtk_object_unref (GTK_OBJECT (comp));