From 2c1887f5fed391efb16a1f5084a5a9016bd73f32 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Sun, 24 Jun 2001 22:53:14 +0000 Subject: Converted to use BonoboXObject. 2001-06-24 Federico Mena Quintero * gui/alarm-notify/alarm-notify.c: Converted to use BonoboXObject. * gui/gnome-cal.c (gnome_calendar_open): Ask the alarm notification service to add the calendar and tasks URIs. (add_alarms): New function. * gui/alarm-notify/notify-main.c (main): Doh, fixed typo in the OAFIID. (main): Initialize and shut down gnome-vfs. * gui/Makefile.am (IDLS): Added evolution-calendar.idl, sigh. (evolution_calendar_SOURCES): Added the files generated from the IDL. * gui/alarm-notify/alarm-queue.c (alarm_trigger_cb): New function used when an alarm is triggered. * gui/dialogs/Makefile.am: Removed the alarm-notify-dialog files; they are now in gui/alarm-notify. * gui/alarm-notify/Makefile.am: Added the alarm-notify-dialog files. * pcs/cal.c (cal_forget_password): This was incorrectly named cal_client_forget_password(); renamed it. * gui/main.c (main): Initialize and shut down gnome-vfs. svn path=/trunk/; revision=10453 --- calendar/gui/gnome-cal.c | 72 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 16 deletions(-) (limited to 'calendar/gui/gnome-cal.c') diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index cac469808f..16afc47bd1 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -35,17 +35,18 @@ #include #include #include +#include #include #include #include #include "widgets/menus/gal-view-menus.h" #include "widgets/misc/e-search-bar.h" #include "widgets/misc/e-filter-bar.h" -#include "dialogs/alarm-notify-dialog.h" #include "dialogs/event-editor.h" #include "e-calendar-table.h" #include "e-day-view.h" #include "e-week-view.h" +#include "evolution-calendar.h" #include "gnome-cal.h" #include "component-factory.h" #include "calendar-commands.h" @@ -503,17 +504,11 @@ gnome_calendar_destroy (GtkObject *object) g_free (filename); if (priv->client) { -#if 0 - alarm_notify_remove_client (priv->client); -#endif gtk_object_unref (GTK_OBJECT (priv->client)); priv->client = NULL; } if (priv->task_pad_client) { -#if 0 - alarm_notify_remove_client (priv->task_pad_client); -#endif gtk_object_unref (GTK_OBJECT (priv->task_pad_client)); priv->task_pad_client = NULL; } @@ -1120,10 +1115,6 @@ gnome_calendar_construct (GnomeCalendar *gcal) gtk_signal_connect (GTK_OBJECT (priv->client), "obj_removed", GTK_SIGNAL_FUNC (obj_removed_cb), gcal); -#if 0 - alarm_notify_add_client (priv->client); -#endif - e_day_view_set_cal_client (E_DAY_VIEW (priv->day_view), priv->client); e_day_view_set_cal_client (E_DAY_VIEW (priv->work_week_view), @@ -1143,14 +1134,9 @@ gnome_calendar_construct (GnomeCalendar *gcal) gtk_signal_connect (GTK_OBJECT (priv->task_pad_client), "cal_opened", GTK_SIGNAL_FUNC (cal_opened_cb), gcal); -#if 0 - alarm_notify_add_client (priv->task_pad_client); -#endif - e_calendar_table_set_cal_client (E_CALENDAR_TABLE (priv->todo), priv->task_pad_client); - /* Get the default view to show. */ view_type = calendar_config_get_default_view (); if (view_type < GNOME_CAL_DAY_VIEW || view_type > GNOME_CAL_MONTH_VIEW) @@ -1220,6 +1206,56 @@ gnome_calendar_get_task_pad_cal_client (GnomeCalendar *gcal) return priv->task_pad_client; } +/* Adds the specified URI to the alarm notification service */ +static void +add_alarms (const char *uri) +{ + CORBA_Environment ev; + GNOME_Evolution_Calendar_AlarmNotify an; + + /* Activate the alarm notification service */ + + CORBA_exception_init (&ev); + an = oaf_activate_from_id ("OAFIID:GNOME_Evolution_Calendar_AlarmNotify", 0, NULL, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_message ("add_alarms(): Could not activate the alarm notification service"); + CORBA_exception_free (&ev); + return; + } + CORBA_exception_free (&ev); + + /* Ask the service to load the URI */ + + CORBA_exception_init (&ev); + GNOME_Evolution_Calendar_AlarmNotify_addCalendar (an, uri, &ev); + + if (ev._major == CORBA_USER_EXCEPTION) { + char *ex_id; + + ex_id = CORBA_exception_id (&ev); + if (strcmp (ex_id, ex_GNOME_Evolution_Calendar_AlarmNotify_InvalidURI) == 0) + g_message ("add_calendar(): Invalid URI reported from the " + "alarm notification service"); + else if (strcmp (ex_id, + ex_GNOME_Evolution_Calendar_AlarmNotify_BackendContactError) == 0) + g_message ("add_calendar(): The alarm notification service could " + "not contact the backend"); + } else if (ev._major != CORBA_NO_EXCEPTION) + g_message ("add_calendar(): Could not issue the addCalendar request"); + + CORBA_exception_free (&ev); + + /* Get rid of the service */ + + CORBA_exception_init (&ev); + bonobo_object_release_unref (an, &ev); + if (ev._major != CORBA_NO_EXCEPTION) + g_message ("add_alarms(): Could not unref the alarm notification service"); + + CORBA_exception_free (&ev); +} + gboolean gnome_calendar_open (GnomeCalendar *gcal, const char *str_uri) { @@ -1246,12 +1282,16 @@ gnome_calendar_open (GnomeCalendar *gcal, const char *str_uri) return FALSE; } + add_alarms (str_uri); + /* Open the appropriate Tasks folder to show in the TaskPad. Currently we just show the folder named "Tasks", but it will be a per-calendar option in future. */ tasks_uri = g_strdup_printf ("%s/local/Tasks/tasks.ics", evolution_dir); success = cal_client_open_calendar (priv->task_pad_client, tasks_uri, FALSE); + + add_alarms (tasks_uri); g_free (tasks_uri); if (!success) { -- cgit