aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/gnome-cal.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-11-13 02:53:08 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-11-13 02:53:08 +0800
commitddae78720c0cdc7984cc50e41a0db99368244e3d (patch)
treed078c6c4d056aa880202b460f2ef466d60d95b57 /calendar/gui/gnome-cal.c
parent25addba20906ecf76e9a819facb9b296069f562b (diff)
downloadgsoc2013-evolution-ddae78720c0cdc7984cc50e41a0db99368244e3d.tar.gz
gsoc2013-evolution-ddae78720c0cdc7984cc50e41a0db99368244e3d.tar.zst
gsoc2013-evolution-ddae78720c0cdc7984cc50e41a0db99368244e3d.zip
Clear the rdate and exrule lists from the component if we are setting a
2000-11-12 Federico Mena Quintero <federico@helixcode.com> * gui/event-editor.c (recur_to_comp_object): Clear the rdate and exrule lists from the component if we are setting a simple recurrence. (recur_to_comp_object): Set the exdate list here instead of in dialog_to_comp_object(). (preview_recur): New function to tag the recurrence preview calendar based on the information from the dialog box. (fill_exception_widgets): Fill the exception widgets here; moved over from fill_widgets(). (fill_recurrence_widgets): Call preview_recur(). Also, call fill_exception_widgets() first of all. (recurrence_type_toggled_cb): Call preview_recur(). (recur_interval_selection_done_cb): Likewise. (recur_ending_selection_done_cb): Likewise. (recurrence_exception_add_cb): Likewise. (recurrence_exception_modify_cb): Likewise. (recurrence_exception_delete_cb): Likewise. (date_changed_cb): Likewise. (recur_interval_value_changed_cb): Likewise, new function. * gui/tag-calendar.[ch]: New files with utilities for tagging calendars. mark.[ch] should go away some day. * gui/tag-calendar.c (tag_calendar): Moved over from gnome_calendar_tag_calendar(). Take in a CalClient instead of a GnomeCalendar. Added API docs. (tag_calendar_by_comp): New function to tag a calendar based on a single calendar component instead of a whole client. * gui/gnome-cal.c (initial_load): Use tag_calendar_by_client(). (obj_updated_cb): Likewise. (obj_removed_cb): Likewise. (gnome_calendar_on_date_navigator_date_range_changed): Likewise. (editor_closed_cb): Free the closure. (destroy_editor_cb): Renamed from free_uid(). Do not free the UID; just unref the event editor. Our destroy handler to it will free things properly. This will also cause the corresponding calendar client to be unrefed. (editor_closed_cb): Use a flag on the GnomeCalendar to decide whether to remove the editor from the hash table. This is sort of icky. * gui/calendar-model.c (obj_updated_cb): If the object is new, we have to use e_table_model_row_inserted(), not row_changed(). Thanks to JP Rosevear for reporting this. * gui/Makefile.am (evolution_calendar_SOURCES): Added tag-calendar.[ch] to the list of sources. svn path=/trunk/; revision=6547
Diffstat (limited to 'calendar/gui/gnome-cal.c')
-rw-r--r--calendar/gui/gnome-cal.c128
1 files changed, 23 insertions, 105 deletions
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 379bbfec95..b3f1556a2c 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -27,6 +27,7 @@
#include "component-factory.h"
#include "calendar-commands.h"
#include "calendar-config.h"
+#include "tag-calendar.h"
@@ -50,6 +51,7 @@ typedef enum {
/* Private part of the GnomeCalendar structure */
struct _GnomeCalendarPrivate {
+ /* The calendar client object we monitor */
CalClient *client;
/* Loading state; we can be loading or creating a calendar */
@@ -109,6 +111,11 @@ struct _GnomeCalendarPrivate {
/* UID->alarms hash */
GHashTable *alarms;
+
+ /* Whether we are being destroyed and should not mess with the object
+ * editor hash table.
+ */
+ guint in_destroy : 1;
};
@@ -330,12 +337,12 @@ free_object_alarms (gpointer key, gpointer value, gpointer data)
/* Used from g_hash_table_foreach(); frees an UID string */
static void
-free_uid (gpointer key, gpointer value, gpointer data)
+destroy_editor_cb (gpointer key, gpointer value, gpointer data)
{
- char *uid;
+ EventEditor *ee;
- uid = key;
- g_free (uid);
+ ee = EVENT_EDITOR (value);
+ gtk_object_unref (GTK_OBJECT (ee));
}
static void
@@ -372,7 +379,8 @@ gnome_calendar_destroy (GtkObject *object)
g_hash_table_destroy (priv->alarms);
priv->alarms = NULL;
- g_hash_table_foreach (priv->object_editor_hash, free_uid, 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;
@@ -1075,7 +1083,7 @@ initial_load (GnomeCalendar *gcal)
priv = gcal->priv;
load_alarms (gcal);
- gnome_calendar_tag_calendar (gcal, priv->date_navigator);
+ tag_calendar_by_client (priv->date_navigator, priv->client);
}
/* Removes any queued alarms for the specified UID */
@@ -1271,7 +1279,7 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data)
remove_alarms_for_object (gcal, uid);
add_alarms_for_object (gcal, uid);
- gnome_calendar_tag_calendar (gcal, priv->date_navigator);
+ tag_calendar_by_client (priv->date_navigator, priv->client);
}
/* Callback from the calendar client when an object is removed */
@@ -1286,7 +1294,7 @@ obj_removed_cb (CalClient *client, const char *uid, gpointer data)
remove_alarms_for_object (gcal, uid);
- gnome_calendar_tag_calendar (gcal, priv->date_navigator);
+ tag_calendar_by_client (priv->date_navigator, priv->client);
}
@@ -1544,98 +1552,6 @@ calendar_notify (time_t activation_time, CalendarAlarm *which, void *data)
#endif
-struct calendar_tag_closure
-{
- ECalendarItem *calitem;
- time_t start_time;
- time_t end_time;
-};
-
-/* Marks the specified range in a GtkCalendar */
-static gboolean
-gnome_calendar_tag_calendar_cb (CalComponent *comp,
- time_t istart,
- time_t iend,
- gpointer data)
-{
- struct calendar_tag_closure *c = data;
- time_t t;
-
- t = time_day_begin (istart);
-
- do {
- struct tm tm;
-
- tm = *localtime (&t);
-
- e_calendar_item_mark_day (c->calitem, tm.tm_year + 1900,
- tm.tm_mon, tm.tm_mday,
- E_CALENDAR_ITEM_MARK_BOLD);
-
- t = time_day_end (t);
- } while (t < iend);
-
- return TRUE;
-}
-
-/*
- * Tags the dates with appointments in a GtkCalendar based on the
- * GnomeCalendar contents
- */
-void
-gnome_calendar_tag_calendar (GnomeCalendar *gcal, ECalendar *ecal)
-{
- GnomeCalendarPrivate *priv;
- struct calendar_tag_closure c;
- gint start_year, start_month, start_day;
- gint end_year, end_month, end_day;
- struct tm start_tm = { 0 }, end_tm = { 0 };
-
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (ecal != NULL);
- g_return_if_fail (E_IS_CALENDAR (ecal));
-
- priv = gcal->priv;
-
- /* If the ECalendar isn't visible, we just return. */
- if (!GTK_WIDGET_VISIBLE (ecal))
- return;
-
- e_calendar_item_clear_marks (ecal->calitem);
-
- if (!cal_client_is_loaded (priv->client))
- return;
-
- e_calendar_item_get_date_range (ecal->calitem,
- &start_year, &start_month, &start_day,
- &end_year, &end_month, &end_day);
-
- start_tm.tm_year = start_year - 1900;
- start_tm.tm_mon = start_month;
- start_tm.tm_mday = start_day;
- start_tm.tm_hour = 0;
- start_tm.tm_min = 0;
- start_tm.tm_sec = 0;
- start_tm.tm_isdst = -1;
-
- end_tm.tm_year = end_year - 1900;
- end_tm.tm_mon = end_month;
- end_tm.tm_mday = end_day;
- end_tm.tm_hour = 0;
- end_tm.tm_min = 0;
- end_tm.tm_sec = 0;
- end_tm.tm_isdst = -1;
-
- c.calitem = ecal->calitem;
- c.start_time = mktime (&start_tm);
- c.end_time = mktime (&end_tm);
-
- cal_client_generate_instances (priv->client, CALOBJ_TYPE_EVENT,
- c.start_time, c.end_time,
- gnome_calendar_tag_calendar_cb, &c);
-}
-
/* Tells the calendar to reload all config settings.
If initializing is TRUE it sets the pane positions as well. (We don't
@@ -1867,9 +1783,7 @@ editor_closed_cb (GtkWidget *widget, gpointer data)
gpointer orig_key;
char *orig_uid;
- g_print ("editor_closed_cb ()\n");
-
- ec = (struct editor_closure *)data;
+ ec = (struct editor_closure *) data;
gcal = ec->gcal;
priv = gcal->priv;
@@ -1878,8 +1792,12 @@ editor_closed_cb (GtkWidget *widget, gpointer data)
orig_uid = orig_key;
- g_hash_table_remove (priv->object_editor_hash, orig_uid);
+ if (!priv->in_destroy)
+ g_hash_table_remove (priv->object_editor_hash, orig_uid);
+
g_free (orig_uid);
+
+ g_free (ec);
}
void
@@ -2139,7 +2057,7 @@ gnome_calendar_on_date_navigator_date_range_changed (ECalendarItem *calitem,
priv = gcal->priv;
- gnome_calendar_tag_calendar (gcal, priv->date_navigator);
+ tag_calendar_by_client (priv->date_navigator, priv->client);
}