From ec86e3f4d5d20bd6ce273030f7f6201fa6cc9851 Mon Sep 17 00:00:00 2001 From: Chenthill Palanisamy Date: Wed, 25 Jan 2006 10:48:16 +0000 Subject: fixes #325762 svn path=/trunk/; revision=31308 --- calendar/ChangeLog | 29 +++ calendar/gui/alarm-notify/alarm-notify.c | 22 +- calendar/gui/alarm-notify/alarm-queue.c | 328 +++------------------------- calendar/gui/dialogs/cal-prefs-dialog.c | 78 +++++++ calendar/gui/dialogs/cal-prefs-dialog.glade | 98 ++++++++- calendar/gui/dialogs/cal-prefs-dialog.h | 6 + 6 files changed, 258 insertions(+), 303 deletions(-) (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 7f18df0647..5369bf45c1 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,32 @@ +2006-01-25 Chenthill Palanisamy + + * gui/alarm-notify/alarm-queue.c: (popup_notification): + Removed the unsed variable filename. Do not set the icon + from pixbuf. Just pass the icon name to notification_new. + +2006-01-25 Srinivasa Ragavan + + Fixes #325762 + * gui/alarm-notify/alarm-notify.c: (process_removal_in_hash), + (list_changed_cb), (load_calendars), (alarm_notify_init): + * gui/alarm-notify/alarm-queue.c: (open_alarm_dialog), + (tray_icon_clicked_cb), (icon_activated), (tray_icon_blink_cb), + (display_notification), , (alarm_queue_init), + (alarm_queue_remove_client): + * gui/dialogs/cal-prefs-dialog.c: (alarms_selection_changed), + (setup_changes), (initialize_selection), (show_alarms_config), + (show_config), (calendar_prefs_dialog_construct): + * gui/dialogs/cal-prefs-dialog.glade: + * gui/dialogs/cal-prefs-dialog.h: The alarms icon is show in the + notification tray only when there is an alarm. The selection + of calendars for alarms is moved to preferences. + +2006-01-25 Chenthill Palanisamy + + Fixes # + * gui/e-calendar-view.c: (on_unrecur_appointment): + + 2006-01-25 Chenthill Palanisamy Fixes #327879 diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c index edef6d34bb..d268c6ffda 100644 --- a/calendar/gui/alarm-notify/alarm-notify.c +++ b/calendar/gui/alarm-notify/alarm-notify.c @@ -92,10 +92,13 @@ process_removal_in_hash (gpointer key, gpointer value, gpointer data) for (q = sources; q != NULL; q = q->next) { ESource *source = E_SOURCE (q->data); char *source_uri; - + const char *completion = e_source_get_property (source, "alarm"); + source_uri = e_source_get_uri (source); if (strcmp (source_uri, uri) == 0) - found = TRUE; + if (!completion || !g_ascii_strcasecmp (completion, "true")) + found = TRUE; + g_free (source_uri); if (found) @@ -118,6 +121,7 @@ list_changed_cb (ESourceList *source_list, gpointer data) GList *l; int i; + printf("LIST CHANGED\n"); priv = an->priv; /* Figure out the source type */ @@ -139,9 +143,9 @@ list_changed_cb (ESourceList *source_list, gpointer data) for (q = sources; q != NULL; q = q->next) { ESource *source = E_SOURCE (q->data); char *uri; - const char *uid = e_source_peek_uid (source); - - if (!e_source_list_peek_source_by_uid (priv->selected_calendars, uid)) + const char *completion = e_source_get_property (source, "alarm"); + + if (completion && !g_ascii_strcasecmp (completion, "false")) continue; uri = e_source_get_uri (source); @@ -195,9 +199,9 @@ load_calendars (AlarmNotify *an, ECalSourceType source_type) for (q = sources; q != NULL; q = q->next) { ESource *source = E_SOURCE (q->data); char *uri; - const char *uid = e_source_peek_uid (source); - - if (!e_source_list_peek_source_by_uid (priv->selected_calendars, uid)) + const char *completion = e_source_get_property (source, "alarm"); + + if (completion && !g_ascii_strcasecmp (completion, "false")) continue; uri = e_source_get_uri (source); @@ -236,7 +240,7 @@ alarm_notify_init (AlarmNotify *an, AlarmNotifyClass *klass) priv = g_new0 (AlarmNotifyPrivate, 1); an->priv = priv; priv->mutex = g_mutex_new (); - priv->selected_calendars = config_data_get_calendars ("/apps/evolution/calendar/notify/calendars"); + priv->selected_calendars = config_data_get_calendars ("/apps/evolution/calendar/sources"); for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 0f15ce342d..73e6be43f9 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -102,6 +102,7 @@ static GList *tray_icons_list = NULL; /* Top Tray Image */ #ifndef USE_GTK_STATUS_ICON +static GtkWidget *tray_icon = NULL; static GtkWidget *tray_image = NULL; static GtkWidget *tray_event_box = NULL; #else @@ -964,27 +965,15 @@ open_alarm_dialog (TrayIconData *tray_data) qa = lookup_queued_alarm (tray_data->cqa, tray_data->alarm_id); if (qa) { - GdkPixbuf *pixbuf; - GtkTooltips *tooltips = gtk_tooltips_new (); - - pixbuf = e_icon_factory_get_icon ("stock_appointment-reminder", E_ICON_SIZE_LARGE_TOOLBAR); - -#ifndef USE_GTK_STATUS_ICON - gtk_image_set_from_pixbuf (GTK_IMAGE (tray_image), pixbuf); -#else - gtk_status_icon_set_from_pixbuf (tray_icon, pixbuf); -#endif - g_object_unref (pixbuf); if (tray_blink_id > -1) g_source_remove (tray_blink_id); tray_blink_id = -1; -#ifndef USE_GTK_STATUS_ICON - gtk_tooltips_set_tip (tooltips, tray_event_box, NULL, NULL); -#else - gtk_status_icon_set_tooltip (tray_icon, NULL); -#endif + gtk_widget_destroy (tray_icon); + tray_icon = NULL; + tray_image = NULL; + if (!alarm_notifications_dialog) alarm_notifications_dialog = notified_alarms_dialog_new (); @@ -1018,204 +1007,6 @@ open_alarm_dialog (TrayIconData *tray_data) return TRUE; } -static void -alarm_quit (EPopup *ep, EPopupItem *pitem, void *data) -{ - bonobo_main_quit (); -} - -static void -menu_item_toggle_callback (GtkToggleButton *item, void *data) -{ - gboolean state = gtk_toggle_button_get_active (item); - ESource *source = e_source_copy ((ESource *) data); - GSList *groups, *sel_groups, *p; - - if (e_source_get_uri ((ESource *)data)) { - g_free (e_source_get_uri (source)); - e_source_set_absolute_uri (source, g_strdup (e_source_get_uri ((ESource *)data))); - } - - if (state) { - const char *uid = e_source_peek_uid (source); - ESourceList *selected_cal = alarm_notify_get_selected_calendars (an); - ESourceList *all_cal; - ESourceGroup *group = NULL, *sel_group = NULL; - const char *grp_uid = NULL; - char * check_grp_uid = NULL; - ESource *source_got = NULL; - gboolean found_grp = FALSE; - - e_cal_get_sources (&all_cal, E_CAL_SOURCE_TYPE_EVENT, NULL); - - alarm_notify_add_calendar (an, E_CAL_SOURCE_TYPE_EVENT, source, FALSE); - - /* Browse the list of all calendars for the newly added calendar*/ - groups = e_source_list_peek_groups (all_cal); - for (p = groups; p != NULL; p = p->next) { - group = E_SOURCE_GROUP (p->data); - source_got = e_source_group_peek_source_by_uid (group, uid); - - if (source_got) { /* You have got the group */ - break; - } - } - - /* Ensure that the source is under some source group in all calendar list */ - if (group == NULL){ - g_warning ("Source Group selected is *NOT* in all calendar list"); - g_object_unref (all_cal); - return; - } - - /* Get the group id from the above */ - grp_uid = e_source_group_peek_uid (group); - - /* Look for the particular group in the original selected calendars list */ - sel_groups = e_source_list_peek_groups (selected_cal); - for (p = sel_groups; p != NULL; p = p->next) { - sel_group = E_SOURCE_GROUP (p->data); - check_grp_uid = g_strdup ((const char *)e_source_group_peek_uid (sel_group)); - if (!strcmp (grp_uid, check_grp_uid)) { - g_free (check_grp_uid); - found_grp = TRUE; - break; - } - g_free (check_grp_uid); - } - - if (found_grp != TRUE) { - g_warning ("Did not find the source group to add the source in the selected calendars"); - g_object_unref (all_cal); - return; - } - - e_source_group_add_source (sel_group, source, -1); - - g_object_unref (all_cal); - - } else { - const char *uid = e_source_peek_uid (source); - ESourceList *selected_cal = alarm_notify_get_selected_calendars (an); - alarm_notify_remove_calendar (an, E_CAL_SOURCE_TYPE_EVENT, e_source_get_uri (source)); - - /* Browse the calendar for alarms and remove the source */ - groups = e_source_list_peek_groups (selected_cal); - for (p = groups; p != NULL; p = p->next) { - ESourceGroup *group = E_SOURCE_GROUP (p->data); - ESource *del_source; - - del_source = e_source_group_peek_source_by_uid (group, uid); - if (del_source) { - e_source_group_remove_source_by_uid (group, uid); - break; - } - } - } - -} - -static GtkWidget * -populate () -{ - GtkWidget *frame = gtk_frame_new (NULL); - GtkWidget *label1 = gtk_label_new (NULL); - GtkWidget *box = gtk_vbox_new(FALSE, 0); - ESourceList *selected_cal = alarm_notify_get_selected_calendars (an); - GSList *groups; - GSList *p; - ESourceList *source_list; - - gtk_label_set_markup (GTK_LABEL(label1), _("Calendars")); - gtk_frame_set_label_widget (GTK_FRAME(frame), label1); - - if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_EVENT, NULL)) { - g_message (G_STRLOC ": Could not get the list of sources to load"); - - return NULL; - } - - groups = e_source_list_peek_groups (source_list); - - for (p = groups; p != NULL; p = p->next) { - ESourceGroup *group = E_SOURCE_GROUP (p->data); - char *txt = g_strdup_printf ("%s", e_source_group_peek_name (group)); - GtkWidget *item = gtk_label_new (NULL); - GSList *q; - GtkWidget *hbox, *image; - - hbox = gtk_hbox_new (FALSE, 0); - image = e_icon_factory_get_image ("stock_appointment-reminder", E_ICON_SIZE_SMALL_TOOLBAR); - - gtk_box_pack_start ((GtkBox *)hbox, image, FALSE, FALSE, 2); - gtk_box_pack_start ((GtkBox *)hbox, item, FALSE, FALSE, 2); - - gtk_label_set_markup (GTK_LABEL(item), txt); - gtk_label_set_justify (GTK_LABEL(item), GTK_JUSTIFY_LEFT); - g_free (txt); - - gtk_box_pack_start (GTK_BOX(box), hbox, TRUE, TRUE, 4); - gtk_widget_show_all (hbox); - - for (q = e_source_group_peek_sources (group); q != NULL; q = q->next) { - ESource *source = E_SOURCE (q->data); - GtkWidget *hbox = gtk_hbox_new (FALSE, 0); - GtkWidget *item = gtk_check_button_new_with_label (e_source_peek_name (source)); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(item), e_source_list_peek_source_by_uid (selected_cal, e_source_peek_uid (source)) ? TRUE:FALSE); - - gtk_box_pack_start ((GtkBox *)hbox, item, FALSE, FALSE, 24); - gtk_object_set_data_full (GTK_OBJECT (item), "ESourceMenu", source, - (GtkDestroyNotify) g_object_unref); - - g_signal_connect (item, "toggled", G_CALLBACK (menu_item_toggle_callback), source); - - gtk_box_pack_start (GTK_BOX(box), hbox, FALSE, FALSE, 2); - gtk_widget_show_all (hbox); - } - } - - gtk_container_add (GTK_CONTAINER(frame), box); - gtk_container_set_border_width (GTK_CONTAINER(frame), 6); - return frame; -} - -static void -alarm_pref_response (GtkWidget *widget, int response, gpointer dummy) -{ - gtk_widget_destroy (widget); -} - -static void -alarms_configure (EPopup *ep, EPopupItem *pitem, void *data) -{ - GtkWidget *box = populate (); - GtkWidget *dialog; - - dialog = gtk_dialog_new_with_buttons (_("Preferences"), - NULL,0, - GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, - GTK_STOCK_HELP, GTK_RESPONSE_HELP, - NULL); - - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box); - gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE); - g_signal_connect (dialog, "response", G_CALLBACK (alarm_pref_response), NULL); - gtk_widget_show_all (dialog); -} - -static EPopupItem tray_items[] = { - { E_POPUP_ITEM, "00.configure", N_("_Configure Alarms"), alarms_configure, NULL, GTK_STOCK_PREFERENCES }, - { E_POPUP_BAR , "10.bar" }, - { E_POPUP_ITEM, "10.quit", N_("_Quit"), alarm_quit, NULL, GTK_STOCK_QUIT }, -}; - -static void -tray_popup_free(EPopup *ep, GSList *items, void *data) -{ - g_slist_free(items); -} - static gint tray_icon_clicked_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { @@ -1230,42 +1021,14 @@ tray_icon_clicked_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_da return TRUE; } else if (event->button == 3) { - GtkMenu *menu; - GSList *menus = NULL; - EPopup *ep; - int i; - GdkPixbuf *pixbuf; - GtkTooltips *tooltips = gtk_tooltips_new (); - tray_blink_state = FALSE; - pixbuf = e_icon_factory_get_icon (tray_blink_state == TRUE ? - "stock_appointment-reminder-excl" : - "stock_appointment-reminder", - E_ICON_SIZE_LARGE_TOOLBAR); - -#ifndef USE_GTK_STATUS_ICON - gtk_image_set_from_pixbuf (GTK_IMAGE (tray_image), pixbuf); -#else - gtk_status_icon_set_from_pixbuf (tray_icon, pixbuf); -#endif - g_object_unref (pixbuf); - if (tray_blink_id > -1) g_source_remove (tray_blink_id); tray_blink_id = -1; -#ifndef USE_GTK_STATUS_ICON - gtk_tooltips_set_tip (tooltips, tray_event_box, NULL, NULL); -#else - gtk_status_icon_set_tooltip (tray_icon, NULL); -#endif - - ep = e_popup_new("org.gnome.evolution.alarmNotify.popup"); - for (i=0;ibutton, event->time); + gtk_widget_destroy (tray_icon); + tray_icon = NULL; + tray_image = NULL; return TRUE; } @@ -1286,20 +1049,6 @@ icon_activated (GtkStatusIcon *icon) tray_icon_clicked_cb (NULL, &event, NULL); } - -static void -popup_menu (GtkStatusIcon *icon, - guint button, - guint32 activate_time) -{ - GdkEventButton event; - - event.type = GDK_BUTTON_PRESS; - event.button = button; - event.time = activate_time; - - tray_icon_clicked_cb (NULL, &event, NULL); -} #endif static gboolean @@ -1315,9 +1064,11 @@ tray_icon_blink_cb (gpointer data) E_ICON_SIZE_LARGE_TOOLBAR); #ifndef USE_GTK_STATUS_ICON - gtk_image_set_from_pixbuf (GTK_IMAGE (tray_image), pixbuf); + if (tray_icon && tray_image) + gtk_image_set_from_pixbuf (GTK_IMAGE (tray_image), pixbuf); #else - gtk_status_icon_set_from_pixbuf (tray_icon, pixbuf); + if (tray_icon) + gtk_status_icon_set_from_pixbuf (tray_icon, pixbuf); #endif g_object_unref (pixbuf); @@ -1333,7 +1084,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, ECalComponent *comp; const char *summary, *description, *location; #ifndef USE_GTK_STATUS_ICON - GtkWidget *tray_icon=NULL, *image=NULL; + GtkWidget *image=NULL; GtkTooltips *tooltips; #endif TrayIconData *tray_data; @@ -1378,8 +1129,27 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, /* create the tray icon */ #ifndef USE_GTK_STATUS_ICON + if (tray_icon == NULL) { + tray_icon = GTK_WIDGET (egg_tray_icon_new ("Evolution Alarm")); + tray_image = e_icon_factory_get_image ("stock_appointment-reminder", E_ICON_SIZE_LARGE_TOOLBAR); + tray_event_box = gtk_event_box_new (); + gtk_container_add (GTK_CONTAINER (tray_event_box), tray_image); + gtk_container_add (GTK_CONTAINER (tray_icon), tray_event_box); + g_signal_connect (G_OBJECT (tray_event_box), "button_press_event", + G_CALLBACK (tray_icon_clicked_cb), NULL); + gtk_widget_show_all (tray_icon); + } tooltips = gtk_tooltips_new (); + +#else + if (tray_icon == NULL) { + tray_icon = gtk_status_icon_new (); + gtk_status_icon_set_from_pixbuf (tray_icon, e_icon_factory_get_icon ("stock_appointment-reminder", E_ICON_SIZE_LARGE_TOOLBAR)); + g_signal_connect (G_OBJECT (tray_icon), "activate", + G_CALLBACK (icon_activated), NULL); + } #endif + current_zone = config_data_get_timezone (); alarm_str = timet_to_str_with_zone (trigger, current_zone); start_str = timet_to_str_with_zone (qa->instance->occur_start, current_zone); @@ -1425,7 +1195,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, #ifndef USE_GTK_STATUS_ICON gtk_tooltips_set_tip (GTK_TOOLTIPS (tooltips), tray_event_box, str, NULL); #else - gtk_status_icon_set_tooltip (tray_icon, NULL); + gtk_status_icon_set_tooltip (tray_icon, str); #endif } @@ -1447,7 +1217,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, if (tray_blink_id == -1) tray_blink_id = g_timeout_add (500, tray_icon_blink_cb, tray_data); } - } +} #ifdef HAVE_LIBNOTIFY static void @@ -1462,7 +1232,6 @@ popup_notification (time_t trigger, CompQueuedAlarms *cqa, char *str, *start_str, *end_str, *alarm_str, *time_str; icaltimezone *current_zone; ECalComponentOrganizer organiser; - char *filename; char *body; comp = cqa->alarms->comp; @@ -1471,8 +1240,6 @@ popup_notification (time_t trigger, CompQueuedAlarms *cqa, return; if (!notify_is_initted ()) notify_init("Evolution Alarm Notify"); - GdkPixbuf *icon = e_icon_factory_get_icon("stock_appointment-reminder", E_ICON_SIZE_DIALOG); - g_free (filename); /* get a sensible description for the event */ e_cal_component_get_summary (comp, &text); @@ -1509,10 +1276,9 @@ popup_notification (time_t trigger, CompQueuedAlarms *cqa, body = g_strdup_printf ("%s %s\n%s %s", _("Location:"), location, start_str, time_str); else body = g_strdup_printf ("%s %s", start_str, time_str); -} + } - NotifyNotification *n = notify_notification_new (summary, body, "", NULL); - notify_notification_set_icon_data_from_pixbuf (n, icon); + NotifyNotification *n = notify_notification_new (summary, body, "stock_appointment-reminder", NULL); if (!notify_notification_show(n, NULL)) g_warning ("Could not send notification to daemon\n"); @@ -1727,9 +1493,6 @@ check_midnight_refresh (gpointer user_data) void alarm_queue_init (gpointer data) { -#ifndef USE_GTK_STATUS_ICON - GtkWidget *tray_icon; -#endif an = data; g_return_if_fail (alarm_queue_inited == FALSE); @@ -1745,24 +1508,6 @@ alarm_queue_init (gpointer data) /* install timeout handler (every 30 mins) for not missing the midnight refresh */ g_timeout_add (1800000, (GSourceFunc) check_midnight_refresh, NULL); -#ifndef USE_GTK_STATUS_ICON - tray_icon = GTK_WIDGET (egg_tray_icon_new ("Evolution Alarm")); - tray_image = e_icon_factory_get_image ("stock_appointment-reminder", E_ICON_SIZE_LARGE_TOOLBAR); - tray_event_box = gtk_event_box_new (); - gtk_container_add (GTK_CONTAINER (tray_event_box), tray_image); - gtk_container_add (GTK_CONTAINER (tray_icon), tray_event_box); - g_signal_connect (G_OBJECT (tray_event_box), "button_press_event", - G_CALLBACK (tray_icon_clicked_cb), NULL); - gtk_widget_show_all (tray_icon); -#else - tray_icon = gtk_status_icon_new (); - gtk_status_icon_set_from_pixbuf (tray_icon, e_icon_factory_get_icon ("stock_appointment-reminder", E_ICON_SIZE_LARGE_TOOLBAR)); - g_signal_connect (G_OBJECT (tray_icon), "activate", - G_CALLBACK (icon_activated), NULL); - g_signal_connect (G_OBJECT (tray_icon), "popup-menu", - G_CALLBACK (popup_menu), NULL); -#endif - #ifdef HAVE_LIBNOTIFY notify_init("Evolution Alarms"); #endif @@ -1929,7 +1674,6 @@ alarm_queue_remove_client (ECal *client) remove_client_alarms (ca); /* Clean up */ - if (ca->client) { g_signal_handlers_disconnect_matched (ca->client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca); diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c index 2f548b66c1..996b257353 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ b/calendar/gui/dialogs/cal-prefs-dialog.c @@ -302,6 +302,41 @@ default_reminder_units_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) e_dialog_combo_box_get (prefs->default_reminder_units, default_reminder_units_map)); } +static void +alarms_selection_changed (ESourceSelector *selector, CalendarPrefsDialog *prefs) +{ + ESourceList *source_list = prefs->alarms_list; + GSList *selection; + GSList *l; + GSList *groups; + + /* first we clear all the alarm flags from all sources */ + g_message ("Clearing selection"); + for (groups = e_source_list_peek_groups (source_list); groups; groups = groups->next) { + ESourceGroup *group = E_SOURCE_GROUP (groups->data); + GSList *sources; + for (sources = e_source_group_peek_sources (group); sources; sources = sources->next) { + ESource *source = E_SOURCE (sources->data); + + g_message ("Unsetting for %s", e_source_peek_name (source)); + e_source_set_property (source, "alarm", "false"); + } + } + + /* then we loop over the selector's selection, setting the + property on those sources */ + selection = e_source_selector_get_selection (selector); + for (l = selection; l; l = l->next) { + g_message ("Setting for %s", e_source_peek_name (E_SOURCE (l->data))); + e_source_set_property (E_SOURCE (l->data), "alarm", "true"); + } + e_source_selector_free_selection (selection); + + /* FIXME show an error if this fails? */ + e_source_list_sync (source_list, NULL); + printf("changed\n"); +} + static void template_url_changed (GtkEntry *entry, CalendarPrefsDialog *prefs) { @@ -347,6 +382,9 @@ setup_changes (CalendarPrefsDialog *prefs) G_CALLBACK (default_reminder_interval_changed), prefs); g_signal_connect (G_OBJECT (prefs->default_reminder_units), "changed", G_CALLBACK (default_reminder_units_changed), prefs); + g_signal_connect (G_OBJECT (prefs->alarm_list_widget), "selection_changed", G_CALLBACK (alarms_selection_changed), prefs); + + g_signal_connect (G_OBJECT (prefs->template_url), "changed", G_CALLBACK (template_url_changed), prefs); } @@ -402,6 +440,38 @@ show_task_list_config (CalendarPrefsDialog *prefs) gtk_widget_set_sensitive (prefs->tasks_hide_completed_units, hide_completed_tasks); } +static void +initialize_selection (ESourceSelector *selector, ESourceList *source_list) +{ + GSList *groups; + + for (groups = e_source_list_peek_groups (source_list); groups; groups = groups->next) { + ESourceGroup *group = E_SOURCE_GROUP (groups->data); + GSList *sources; + for (sources = e_source_group_peek_sources (group); sources; sources = sources->next) { + ESource *source = E_SOURCE (sources->data); + const char *completion = e_source_get_property (source, "alarm"); + if (!completion || !g_ascii_strcasecmp (completion, "true")) { + if (!completion) + e_source_set_property (E_SOURCE (source), "alarm", "true"); + e_source_selector_select_source (selector, source); + } + } + } +} + +static void +show_alarms_config (CalendarPrefsDialog *prefs) +{ + if (!e_cal_get_sources (&prefs->alarms_list, E_CAL_SOURCE_TYPE_EVENT, NULL)) + return; + + prefs->alarm_list_widget = e_source_selector_new (prefs->alarms_list); + atk_object_set_name (gtk_widget_get_accessible (prefs->alarm_list_widget), _("Selected Calendars for Alarms")); + gtk_container_add (GTK_CONTAINER (prefs->scrolled_window), prefs->alarm_list_widget); + initialize_selection (prefs->alarm_list_widget, prefs->alarms_list); +} + /* Shows the current config settings in the dialog. */ static void show_config (CalendarPrefsDialog *prefs) @@ -460,6 +530,9 @@ show_config (CalendarPrefsDialog *prefs) /* Task list */ show_task_list_config (prefs); + /* Alarms list*/ + show_alarms_config (prefs); + /* Free/Busy */ show_fb_config (prefs); @@ -480,6 +553,7 @@ static ECalConfigItem eccp_items[] = { { E_CONFIG_PAGE, "10.display", "display", eccp_widget_glade }, { E_CONFIG_SECTION, "10.display/00.general", "displayGeneral", eccp_widget_glade }, { E_CONFIG_SECTION, "10.display/10.taskList", "taskList", eccp_widget_glade }, + { E_CONFIG_PAGE, "15.alarms", "alarms", eccp_widget_glade }, { E_CONFIG_PAGE, "20.freeBusy", "freebusy", eccp_widget_glade }, { E_CONFIG_SECTION, "20.freeBusy/00.defaultServer", "defaultFBServer", eccp_widget_glade }, }; @@ -558,6 +632,10 @@ calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs) prefs->tasks_hide_completed_interval = glade_xml_get_widget (gui, "tasks_hide_completed_interval"); prefs->tasks_hide_completed_units = glade_xml_get_widget (gui, "tasks_hide_completed_units"); + + /* Alarms tab */ + prefs->scrolled_window = glade_xml_get_widget (gui, "calendar-source-scrolled-window"); + /* Free/Busy tab */ prefs->template_url = glade_xml_get_widget (gui, "template_url"); target = e_cal_config_target_new_prefs (ec, prefs->gconf); diff --git a/calendar/gui/dialogs/cal-prefs-dialog.glade b/calendar/gui/dialogs/cal-prefs-dialog.glade index fbc149683a..09966cb4ca 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.glade +++ b/calendar/gui/dialogs/cal-prefs-dialog.glade @@ -1210,7 +1210,7 @@ Days True True False - Color for tasks due today + Pick a color True @@ -1229,7 +1229,7 @@ Days True True False - Color for overdue tasks + Pick a color True @@ -1359,6 +1359,100 @@ Days + + + 12 + True + False + 6 + + + + True + False + 0 + + + + True + Select the calendars for alarm notification + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + + + + 0 + True + True + + + + + False + True + + + + + + True + Alarms + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + 12 diff --git a/calendar/gui/dialogs/cal-prefs-dialog.h b/calendar/gui/dialogs/cal-prefs-dialog.h index ab717d85a9..3575e9baca 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.h +++ b/calendar/gui/dialogs/cal-prefs-dialog.h @@ -28,6 +28,7 @@ #include #include #include +#include #include "evolution-config-control.h" G_BEGIN_DECLS @@ -66,6 +67,11 @@ struct _CalendarPrefsDialog { GtkWidget *tasks_hide_completed_interval; GtkWidget *tasks_hide_completed_units; + /* Alarms tab */ + GtkWidget *scrolled_window; + ESourceList *alarms_list; + GtkWidget *alarm_list_widget; + /* Free/Busy tab */ GtkWidget *url_add; GtkWidget *url_edit; -- cgit v1.2.3