diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2000-09-02 06:47:32 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2000-09-02 06:47:32 +0800 |
commit | 91c7d5d800c1b03e014b5fb10dfea6cd8609e627 (patch) | |
tree | 5ff8405ec2ce4c356c3642e8b70180b00b161aab /calendar/gui | |
parent | 6993fc1c571c50c9d042cc26f0fd0e049492e37c (diff) | |
download | gsoc2013-evolution-91c7d5d800c1b03e014b5fb10dfea6cd8609e627.tar.gz gsoc2013-evolution-91c7d5d800c1b03e014b5fb10dfea6cd8609e627.tar.zst gsoc2013-evolution-91c7d5d800c1b03e014b5fb10dfea6cd8609e627.zip |
Use gnome_calendar_construct() so that we can check for proper creation of
2000-09-01 Federico Mena Quintero <federico@helixcode.com>
* gui/gnome-cal.c (gnome_calendar_new): Use
gnome_calendar_construct() so that we can check for proper
creation of the client.
(gnome_calendar_destroy): Check that the client exists before we
unref it.
(gnome_calendar_construct): Do the CalClient creation here. Bind
the views to it here as well instead of in setup_widgets().
(gnome_calendar_init): Call setup_widgets() here.
* gui/e-calendar-table.c (e_calendar_table_destroy): Unref the
model.
2000-09-01 JP Rosevear <jpr@helixcode.com>
svn path=/trunk/; revision=5175
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/e-calendar-table.c | 3 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 210 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 3 |
3 files changed, 119 insertions, 97 deletions
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index b84e21b34a..17f957623f 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -285,7 +285,8 @@ e_calendar_table_destroy (GtkObject *object) cal_table = E_CALENDAR_TABLE (object); - + gtk_object_unref (GTK_OBJECT (cal_table->model)); + cal_table->model = NULL; GTK_OBJECT_CLASS (parent_class)->destroy (object); } diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 415d4abec0..ec70e56cc0 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -106,81 +106,6 @@ gnome_calendar_class_init (GnomeCalendarClass *class) object_class->destroy = gnome_calendar_destroy; } -/* Object initialization function for the gnome calendar */ -static void -gnome_calendar_init (GnomeCalendar *gcal) -{ - gcal->object_editor_hash = g_hash_table_new (g_str_hash, g_str_equal); - gcal->alarms = g_hash_table_new (g_str_hash, g_str_equal); - - gcal->current_view_type = GNOME_CALENDAR_VIEW_NOT_SET; - gcal->range_selected = FALSE; - - /* Set the default pane positions. These will eventually come from - gconf settings. They are multiples of calendar month widths & - heights in the date navigator. */ - gcal->hpane_pos = 1.0; - gcal->vpane_pos = 1.0; - gcal->hpane_pos_month_view = 0.0; - gcal->vpane_pos_month_view = 1.0; - - gcal->ignore_view_button_clicks = FALSE; -} - -/* Used from g_hash_table_foreach(); frees an object alarms entry */ -static void -free_object_alarms (gpointer key, gpointer value, gpointer data) -{ - ObjectAlarms *oa; - - oa = value; - - g_assert (oa->uid != NULL); - g_free (oa->uid); - oa->uid = NULL; - - g_assert (oa->alarm_ids != NULL); - g_list_free (oa->alarm_ids); - oa->alarm_ids = NULL; - - g_free (oa); -} - -/* Used from g_hash_table_foreach(); frees an UID string */ -static void -free_uid (gpointer key, gpointer value, gpointer data) -{ - char *uid; - - uid = key; - g_free (uid); -} - -static void -gnome_calendar_destroy (GtkObject *object) -{ - GnomeCalendar *gcal; - - g_return_if_fail (object != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (object)); - - gcal = GNOME_CALENDAR (object); - - gtk_object_unref (GTK_OBJECT (gcal->client)); - - g_hash_table_foreach (gcal->alarms, free_object_alarms, NULL); - g_hash_table_destroy (gcal->alarms); - gcal->alarms = NULL; - - g_hash_table_foreach (gcal->object_editor_hash, free_uid, NULL); - g_hash_table_destroy (gcal->object_editor_hash); - gcal->object_editor_hash = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - static void setup_widgets (GnomeCalendar *gcal) { @@ -230,14 +155,10 @@ setup_widgets (GnomeCalendar *gcal) gcal->todo = e_calendar_table_new (); e_paned_pack2 (E_PANED (gcal->vpane), gcal->todo, TRUE, TRUE); gtk_widget_show (gcal->todo); - e_calendar_table_set_cal_client (E_CALENDAR_TABLE (gcal->todo), - gcal->client); - /* The Day View. */ gcal->day_view = e_day_view_new (); e_day_view_set_calendar (E_DAY_VIEW (gcal->day_view), gcal); - e_day_view_set_cal_client (E_DAY_VIEW (gcal->day_view), gcal->client); gtk_widget_show (gcal->day_view); gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view, gtk_label_new ("")); @@ -248,7 +169,6 @@ setup_widgets (GnomeCalendar *gcal) TRUE); e_day_view_set_days_shown (E_DAY_VIEW (gcal->work_week_view), 5); e_day_view_set_calendar (E_DAY_VIEW (gcal->work_week_view), gcal); - e_day_view_set_cal_client (E_DAY_VIEW (gcal->work_week_view), gcal->client); gtk_widget_show (gcal->work_week_view); gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->work_week_view, gtk_label_new ("")); @@ -256,7 +176,6 @@ setup_widgets (GnomeCalendar *gcal) /* The Week View. */ gcal->week_view = e_week_view_new (); e_week_view_set_calendar (E_WEEK_VIEW (gcal->week_view), gcal); - e_week_view_set_cal_client (E_WEEK_VIEW (gcal->week_view), gcal->client); gtk_widget_show (gcal->week_view); gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->week_view, gtk_label_new ("")); @@ -265,12 +184,93 @@ setup_widgets (GnomeCalendar *gcal) gcal->month_view = e_week_view_new (); e_week_view_set_calendar (E_WEEK_VIEW (gcal->month_view), gcal); e_week_view_set_multi_week_view (E_WEEK_VIEW (gcal->month_view), TRUE); - e_week_view_set_cal_client (E_WEEK_VIEW (gcal->month_view), gcal->client); gtk_widget_show (gcal->month_view); gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->month_view, gtk_label_new ("")); } +/* Object initialization function for the gnome calendar */ +static void +gnome_calendar_init (GnomeCalendar *gcal) +{ + gcal->object_editor_hash = g_hash_table_new (g_str_hash, g_str_equal); + gcal->alarms = g_hash_table_new (g_str_hash, g_str_equal); + + gcal->current_view_type = GNOME_CALENDAR_VIEW_NOT_SET; + gcal->range_selected = FALSE; + + gcal->selection_start_time = time_day_begin (time (NULL)); + gcal->selection_end_time = time_add_day (gcal->selection_start_time, 1); + + /* Set the default pane positions. These will eventually come from + gconf settings. They are multiples of calendar month widths & + heights in the date navigator. */ + gcal->hpane_pos = 1.0; + gcal->vpane_pos = 1.0; + gcal->hpane_pos_month_view = 0.0; + gcal->vpane_pos_month_view = 1.0; + + gcal->ignore_view_button_clicks = FALSE; + + setup_widgets (gcal); +} + +/* Used from g_hash_table_foreach(); frees an object alarms entry */ +static void +free_object_alarms (gpointer key, gpointer value, gpointer data) +{ + ObjectAlarms *oa; + + oa = value; + + g_assert (oa->uid != NULL); + g_free (oa->uid); + oa->uid = NULL; + + g_assert (oa->alarm_ids != NULL); + g_list_free (oa->alarm_ids); + oa->alarm_ids = NULL; + + g_free (oa); +} + +/* Used from g_hash_table_foreach(); frees an UID string */ +static void +free_uid (gpointer key, gpointer value, gpointer data) +{ + char *uid; + + uid = key; + g_free (uid); +} + +static void +gnome_calendar_destroy (GtkObject *object) +{ + GnomeCalendar *gcal; + + g_return_if_fail (object != NULL); + g_return_if_fail (GNOME_IS_CALENDAR (object)); + + gcal = GNOME_CALENDAR (object); + + if (gcal->client) { + gtk_object_unref (GTK_OBJECT (gcal->client)); + gcal->client = NULL; + } + + g_hash_table_foreach (gcal->alarms, free_object_alarms, NULL); + g_hash_table_destroy (gcal->alarms); + gcal->alarms = NULL; + + g_hash_table_foreach (gcal->object_editor_hash, free_uid, NULL); + g_hash_table_destroy (gcal->object_editor_hash); + gcal->object_editor_hash = NULL; + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + static GtkWidget * get_current_page (GnomeCalendar *gcal) { @@ -991,29 +991,47 @@ gnome_calendar_object_removed_cb (GtkWidget *cal_client, GtkWidget * -gnome_calendar_new (char *title) +gnome_calendar_construct (GnomeCalendar *gcal) { - GtkWidget *retval; - GnomeCalendar *gcal; - - retval = gtk_type_new (gnome_calendar_get_type ()); - - gcal = GNOME_CALENDAR (retval); + g_return_val_if_fail (gcal != NULL, NULL); + g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL); - gcal->selection_start_time = time_day_begin (time (NULL)); - gcal->selection_end_time = time_add_day (gcal->selection_start_time, 1); gcal->client = cal_client_new (); - - setup_widgets (gcal); - - gnome_calendar_set_view (gcal, "dayview", FALSE); + if (!gcal->client) + return NULL; gtk_signal_connect (GTK_OBJECT (gcal->client), "obj_updated", gnome_calendar_object_updated_cb, gcal); gtk_signal_connect (GTK_OBJECT (gcal->client), "obj_removed", gnome_calendar_object_removed_cb, gcal); - return retval; + e_calendar_table_set_cal_client (E_CALENDAR_TABLE (gcal->todo), + gcal->client); + + e_day_view_set_cal_client (E_DAY_VIEW (gcal->day_view), gcal->client); + e_day_view_set_cal_client (E_DAY_VIEW (gcal->work_week_view), gcal->client); + e_week_view_set_cal_client (E_WEEK_VIEW (gcal->week_view), gcal->client); + e_week_view_set_cal_client (E_WEEK_VIEW (gcal->month_view), gcal->client); + + gnome_calendar_set_view (gcal, "dayview", FALSE); + + return GTK_WIDGET (gcal); +} + +GtkWidget * +gnome_calendar_new (char *title) +{ + GnomeCalendar *gcal; + + gcal = gtk_type_new (gnome_calendar_get_type ()); + + if (!gnome_calendar_construct (gcal)) { + g_message ("gnome_calendar_new(): Could not construct the calendar GUI"); + gtk_object_unref (GTK_OBJECT (gcal)); + return NULL; + } + + return GTK_WIDGET (gcal); } typedef struct diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 84d103f830..a3a171701f 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -109,7 +109,10 @@ typedef enum { } GnomeCalendarOpenMode; guint gnome_calendar_get_type (void); +GtkWidget *gnome_calendar_construct (GnomeCalendar *gcal); + GtkWidget *gnome_calendar_new (char *title); + int gnome_calendar_open (GnomeCalendar *gcal, char *file, GnomeCalendarOpenMode gcom); |