aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/gnome-cal.c
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2002-05-27 00:21:28 +0800
committerJP Rosevear <jpr@src.gnome.org>2002-05-27 00:21:28 +0800
commitfb1d17d150cb5178ca1d63431958d3df9dfc60b3 (patch)
tree5c17aae3a1d8b6a5d52909a30bcc5391c03f465f /calendar/gui/gnome-cal.c
parente6298a6cd5faa861d4185c1399fe627e6d70d8f8 (diff)
downloadgsoc2013-evolution-fb1d17d150cb5178ca1d63431958d3df9dfc60b3.tar
gsoc2013-evolution-fb1d17d150cb5178ca1d63431958d3df9dfc60b3.tar.gz
gsoc2013-evolution-fb1d17d150cb5178ca1d63431958d3df9dfc60b3.tar.bz2
gsoc2013-evolution-fb1d17d150cb5178ca1d63431958d3df9dfc60b3.tar.lz
gsoc2013-evolution-fb1d17d150cb5178ca1d63431958d3df9dfc60b3.tar.xz
gsoc2013-evolution-fb1d17d150cb5178ca1d63431958d3df9dfc60b3.tar.zst
gsoc2013-evolution-fb1d17d150cb5178ca1d63431958d3df9dfc60b3.zip
a registry of comp editors so we can close them all centrally
2002-05-26 JP Rosevear <jpr@ximian.com> * gui/e-comp-editor-registry.[hc]: a registry of comp editors so we can close them all centrally * gui/gnome-cal.c (gnome_calendar_init): there is no editor hash now (gnome_calendar_destroy): ditto (gnome_calendar_edit_object): look for the event editor in the registry, if it isn't there, create it and add it to the registry * gui/e-calendar-table.c (open_task): look for the task editor in the registry, if it isn't there, create it and add it to the registry * gui/component-factory.c (request_quit): close all open editors (create_object): add a request_quit function to the shell component * gui/comp-editor-factory.c (free_client): there is no uid_comp_hash to free any more (editor_destroy_cb): we get an OpenClient as callback data now, reduce the editor count and destroy it if it is 0 (edit_existing): don't create the Component, add the new editor to the registry, increase the editor count (edit_new): ditto (open_client): set the editor count to 0 (impl_editExisting): look in the registry for the editor * gui/Makefile.am: Build new sources * gui/main.c (main): create the registry * gui/dialogs/comp-editor.c (comp_editor_close): prompt to save and then close dialog * gui/dialogs/comp-editor.h: new proto * gui/GNOME_Evolution_Calendar.oaf.in: remove dead summary stuff svn path=/trunk/; revision=17018
Diffstat (limited to 'calendar/gui/gnome-cal.c')
-rw-r--r--calendar/gui/gnome-cal.c78
1 files changed, 6 insertions, 72 deletions
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 848902fa04..67b84575c0 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -41,6 +41,7 @@
#include "e-util/e-url.h"
#include <cal-util/timeutil.h>
#include "widgets/menus/gal-view-menus.h"
+#include "e-comp-editor-registry.h"
#include "dialogs/event-editor.h"
#include "dialogs/task-editor.h"
#include "comp-util.h"
@@ -56,6 +57,8 @@
#include "calendar-view-factory.h"
#include "tag-calendar.h"
+extern ECompEditorRegistry *comp_editor_registry;
+
/* Private part of the GnomeCalendar structure */
@@ -84,9 +87,6 @@ struct _GnomeCalendarPrivate {
* Fields for the calendar view
*/
- /* Mapping of component UIDs to event editors */
- GHashTable *object_editor_hash;
-
/* This is the last selection explicitly selected by the user. We try
to keep it the same when we switch views, but we may have to alter
it depending on the view (e.g. the week views only select days, so
@@ -134,11 +134,6 @@ struct _GnomeCalendarPrivate {
GalViewInstance *view_instance;
GalViewMenus *view_menus;
- /* Whether we are being destroyed and should not mess with the object
- * editor hash table.
- */
- guint in_destroy : 1;
-
/* Our current timezone. */
icaltimezone *zone;
@@ -905,8 +900,6 @@ gnome_calendar_init (GnomeCalendar *gcal)
priv->cal_categories = NULL;
priv->tasks_categories = NULL;
- priv->object_editor_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
priv->current_view_type = GNOME_CAL_DAY_VIEW;
priv->range_selected = FALSE;
@@ -940,16 +933,6 @@ free_categories (GPtrArray *categories)
g_ptr_array_free (categories, TRUE);
}
-/* Used from g_hash_table_foreach(); frees an UID string */
-static void
-destroy_editor_cb (gpointer key, gpointer value, gpointer data)
-{
- EventEditor *ee;
-
- ee = EVENT_EDITOR (value);
- gtk_object_unref (GTK_OBJECT (ee));
-}
-
static void
gnome_calendar_destroy (GtkObject *object)
{
@@ -995,11 +978,6 @@ gnome_calendar_destroy (GtkObject *object)
priv->task_pad_client = NULL;
}
- priv->in_destroy = TRUE;
- g_hash_table_foreach (priv->object_editor_hash, destroy_editor_cb, NULL);
- g_hash_table_destroy (priv->object_editor_hash);
- priv->object_editor_hash = NULL;
-
if (priv->view_instance) {
gtk_object_unref (GTK_OBJECT (priv->view_instance));
priv->view_instance = NULL;
@@ -2139,48 +2117,12 @@ gnome_calendar_get_selected_time_range (GnomeCalendar *gcal,
*end_time = priv->selection_end_time;
}
-
-/* Callback used when an event editor dialog is closed */
-struct editor_closure
-{
- GnomeCalendar *gcal;
- char *uid;
-};
-
-static void
-editor_closed_cb (GtkWidget *widget, gpointer data)
-{
- GnomeCalendar *gcal;
- GnomeCalendarPrivate *priv;
- struct editor_closure *ec;
- gboolean result;
- gpointer orig_key;
- char *orig_uid;
-
- ec = (struct editor_closure *) data;
- gcal = ec->gcal;
- priv = gcal->priv;
-
- result = g_hash_table_lookup_extended (priv->object_editor_hash, ec->uid, &orig_key, NULL);
- g_assert (result != FALSE);
-
- orig_uid = orig_key;
-
- if (!priv->in_destroy)
- g_hash_table_remove (priv->object_editor_hash, orig_uid);
-
- g_free (orig_uid);
-
- g_free (ec);
-}
-
void
gnome_calendar_edit_object (GnomeCalendar *gcal, CalComponent *comp,
gboolean meeting)
{
GnomeCalendarPrivate *priv;
EventEditor *ee;
- struct editor_closure *ec;
const char *uid;
g_return_if_fail (gcal != NULL);
@@ -2191,28 +2133,20 @@ gnome_calendar_edit_object (GnomeCalendar *gcal, CalComponent *comp,
cal_component_get_uid (comp, &uid);
- ee = g_hash_table_lookup (priv->object_editor_hash, uid);
+ ee = EVENT_EDITOR (e_comp_editor_registry_find (comp_editor_registry, 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;
}
- ec->gcal = gcal;
- ec->uid = g_strdup (uid);
-
- g_hash_table_insert (priv->object_editor_hash, ec->uid, ee);
-
- gtk_signal_connect (GTK_OBJECT (ee), "destroy",
- GTK_SIGNAL_FUNC (editor_closed_cb),
- ec);
comp_editor_set_cal_client (COMP_EDITOR (ee), priv->client);
comp_editor_edit_comp (COMP_EDITOR (ee), comp);
if (meeting)
event_editor_show_meeting (ee);
+
+ e_comp_editor_registry_add (comp_editor_registry, COMP_EDITOR (ee), FALSE);
}
comp_editor_focus (COMP_EDITOR (ee));