aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/alarm-notify/alarm-queue.c
diff options
context:
space:
mode:
authorPhilip Van Hoof <pvanhoof@gnome.org>2005-05-09 17:11:05 +0800
committerPhilip Van Hoof <pvanhoof@src.gnome.org>2005-05-09 17:11:05 +0800
commita7f677b5b8454ade1f5dd81f0fa01ea368772187 (patch)
tree1e7f5a44c93def080589498244db89780575437b /calendar/gui/alarm-notify/alarm-queue.c
parent71b1d2839752a246a4bc7855da634ebb7eab0ba0 (diff)
downloadgsoc2013-evolution-a7f677b5b8454ade1f5dd81f0fa01ea368772187.tar.gz
gsoc2013-evolution-a7f677b5b8454ade1f5dd81f0fa01ea368772187.tar.zst
gsoc2013-evolution-a7f677b5b8454ade1f5dd81f0fa01ea368772187.zip
Made the alarm-notify dialog multi-alarm aware
2005-05-11 Philip Van Hoof <pvanhoof@gnome.org> * gui/alarm-notify/*: Made the alarm-notify dialog multi-alarm aware svn path=/trunk/; revision=29315
Diffstat (limited to 'calendar/gui/alarm-notify/alarm-queue.c')
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c100
1 files changed, 87 insertions, 13 deletions
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index 9fc55e5869..9d2c57db26 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -56,6 +56,9 @@
+/* The dialog with alarm nofications */
+static AlarmNotificationsDialog *alarm_notifications_dialog = NULL;
+
/* Whether the queueing system has been initialized */
static gboolean alarm_queue_inited;
@@ -123,6 +126,8 @@ typedef struct {
/* Alarm ID for the midnight refresh function */
static gpointer midnight_refresh_id = NULL;
+static void
+remove_client_alarms (ClientAlarms *ca);
static void display_notification (time_t trigger, CompQueuedAlarms *cqa,
gpointer alarm_id, gboolean use_description);
static void audio_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id);
@@ -723,7 +728,7 @@ typedef struct {
ECalView *query;
GtkWidget *tray_icon;
GtkWidget *image;
- GtkWidget *alarm_dialog;
+ GtkTreeIter iter;
} TrayIconData;
static void
@@ -756,7 +761,7 @@ static void
notify_dialog_cb (AlarmNotifyResult result, int snooze_mins, gpointer data)
{
TrayIconData *tray_data = data;
-
+
g_signal_handlers_disconnect_matched (tray_data->query, G_SIGNAL_MATCH_FUNC,
0, 0, NULL, on_dialog_objs_removed_cb, NULL);
@@ -764,39 +769,86 @@ notify_dialog_cb (AlarmNotifyResult result, int snooze_mins, gpointer data)
case ALARM_NOTIFY_SNOOZE:
create_snooze (tray_data->cqa, tray_data->alarm_id, snooze_mins);
tray_data->cqa = NULL;
+
+ if (alarm_notifications_dialog) {
+ GtkTreeSelection *selection =
+ gtk_tree_view_get_selection (
+ GTK_TREE_VIEW (alarm_notifications_dialog->treeview));
+ GtkTreeIter iter;
+ GtkTreeModel *model = NULL;
+
+ /* We can also use tray_data->iter */
+ if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ if (!gtk_tree_model_get_iter_first (model, &iter)) {
+ /* We removed the last one */
+ gtk_widget_destroy (alarm_notifications_dialog->dialog);
+ g_free (alarm_notifications_dialog);
+ alarm_notifications_dialog = NULL;
+ } else {
+ /* Select the first */
+ gtk_tree_selection_select_iter (selection, &iter);
+ }
+ }
+
+ }
+
break;
case ALARM_NOTIFY_EDIT:
edit_component (tray_data->client, tray_data->comp);
+
+ gtk_widget_destroy (alarm_notifications_dialog->dialog);
+ g_free (alarm_notifications_dialog);
+ alarm_notifications_dialog = NULL;
+
+ gtk_widget_destroy (tray_data->tray_icon);
+
break;
case ALARM_NOTIFY_CLOSE:
- /* Do nothing */
+
+
+ if (alarm_notifications_dialog) {
+ GtkTreeIter iter;
+ GtkTreeModel *model =
+ gtk_tree_view_get_model (
+ GTK_TREE_VIEW (alarm_notifications_dialog->treeview));
+ gboolean valid = gtk_tree_model_get_iter_first (model, &iter);
+
+ /* Maybe we should warn about this first? */
+ while (valid) {
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ valid = gtk_tree_model_iter_next (model, &iter);
+ }
+
+ gtk_widget_destroy (alarm_notifications_dialog->dialog);
+ g_free (alarm_notifications_dialog);
+ alarm_notifications_dialog = NULL;
+ }
+
+ gtk_widget_destroy (tray_data->tray_icon);
+
break;
default:
g_assert_not_reached ();
}
- gtk_widget_destroy (tray_data->tray_icon);
+ return;
}
static gint
tray_icon_destroyed_cb (GtkWidget *tray, gpointer user_data)
{
TrayIconData *tray_data = user_data;
-
+
g_signal_handlers_disconnect_matched (tray_data->query, G_SIGNAL_MATCH_FUNC,
0, 0, NULL, on_dialog_objs_removed_cb, NULL);
if (tray_data->cqa != NULL)
remove_queued_alarm (tray_data->cqa, tray_data->alarm_id, TRUE, TRUE);
- if (tray_data->alarm_dialog != NULL) {
- gtk_widget_destroy (tray_data->alarm_dialog);
- tray_data->alarm_dialog = NULL;
- }
-
if (tray_data->summary != NULL) {
g_free (tray_data->summary);
tray_data->summary = NULL;
@@ -830,11 +882,28 @@ static gboolean
open_alarm_dialog (TrayIconData *tray_data)
{
QueuedAlarm *qa;
-
+
qa = lookup_queued_alarm (tray_data->cqa, tray_data->alarm_id);
if (qa) {
+
gtk_widget_hide (tray_data->tray_icon);
- tray_data->alarm_dialog = alarm_notify_dialog (tray_data->trigger,
+
+ if (!alarm_notifications_dialog)
+ alarm_notifications_dialog = notified_alarms_dialog_new ();
+
+ if (alarm_notifications_dialog) {
+
+ GtkTreeSelection *selection = NULL;
+ GtkTreeModel *model = NULL;
+
+ selection = gtk_tree_view_get_selection (
+ GTK_TREE_VIEW (alarm_notifications_dialog->treeview));
+ model = gtk_tree_view_get_model (
+ GTK_TREE_VIEW(alarm_notifications_dialog->treeview));
+
+ tray_data->iter = add_alarm_to_notified_alarms_dialog (
+ alarm_notifications_dialog,
+ tray_data->trigger,
qa->instance->occur_start,
qa->instance->occur_end,
e_cal_component_get_vtype (tray_data->comp),
@@ -842,6 +911,11 @@ open_alarm_dialog (TrayIconData *tray_data)
tray_data->description,
tray_data->location,
notify_dialog_cb, tray_data);
+
+ gtk_tree_selection_select_iter (selection, &tray_data->iter);
+
+ }
+
}
return TRUE;
@@ -1037,7 +1111,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
if (!config_data_get_notify_with_tray ()) {
tray_data->blink_id = -1;
open_alarm_dialog (tray_data);
- gtk_window_stick (GTK_WINDOW (tray_data->alarm_dialog));
+ gtk_window_stick (GTK_WINDOW (alarm_notifications_dialog->dialog));
} else {
tray_data->blink_id = g_timeout_add (500, tray_icon_blink_cb, tray_data);
gtk_widget_show (tray_icon);