aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/alarm-notify/alarm-notify-dialog.c
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@novell.com>2005-03-04 22:39:13 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2005-03-04 22:39:13 +0800
commita45b33e0dbc03ee82cf15513a7e014cc79b596c8 (patch)
tree717fc7b0f391543d775fbb0ca76f0dcec9bbf65e /calendar/gui/alarm-notify/alarm-notify-dialog.c
parent255fb5979b405a0a9cb9289ee980d7bad99e535c (diff)
downloadgsoc2013-evolution-a45b33e0dbc03ee82cf15513a7e014cc79b596c8.tar
gsoc2013-evolution-a45b33e0dbc03ee82cf15513a7e014cc79b596c8.tar.gz
gsoc2013-evolution-a45b33e0dbc03ee82cf15513a7e014cc79b596c8.tar.bz2
gsoc2013-evolution-a45b33e0dbc03ee82cf15513a7e014cc79b596c8.tar.lz
gsoc2013-evolution-a45b33e0dbc03ee82cf15513a7e014cc79b596c8.tar.xz
gsoc2013-evolution-a45b33e0dbc03ee82cf15513a7e014cc79b596c8.tar.zst
gsoc2013-evolution-a45b33e0dbc03ee82cf15513a7e014cc79b596c8.zip
Fixes #72835
2005-03-04 Rodrigo Moya <rodrigo@novell.com> Fixes #72835 * gui/alarm-notify/alarm-notify-dialog.[ch] (alarm_notify_dialog): changed to return the dialog we create, and to run in the background. (dialog_response_cb): response callback for the dialog. * gui/alarm-notify/alarm-queue.c (alarm_queue_done): don't g_assert, just check for midnight_refresh pointer, and clear it up if not NULL. Also, traverse all clients with g_hash_table_foreach_remove. (free_client_alarms_cb, alarm_queue_remove_client, load_alarms): added missing cleanup code. (queue_midnight_refresh): don't g_assert, just check for midnigh_refresh pointer and clear it up if not NULL. (open_alarm_dialog): store the dialog returned by alarm_notify_dialog(). (tray_icon_destroyed_cb): destroy the dialog if still around. svn path=/trunk/; revision=28956
Diffstat (limited to 'calendar/gui/alarm-notify/alarm-notify-dialog.c')
-rw-r--r--calendar/gui/alarm-notify/alarm-notify-dialog.c73
1 files changed, 45 insertions, 28 deletions
diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.c b/calendar/gui/alarm-notify/alarm-notify-dialog.c
index 8d60fb7c70..ee625c96f9 100644
--- a/calendar/gui/alarm-notify/alarm-notify-dialog.c
+++ b/calendar/gui/alarm-notify/alarm-notify-dialog.c
@@ -81,6 +81,36 @@ an_update_minutes_label (GtkSpinButton *sb, gpointer data)
g_free (new_label);
}
+static void
+dialog_response_cb (GtkDialog *dialog, guint response_id, gpointer user_data)
+{
+ int snooze_timeout;
+ AlarmNotify *an = user_data;
+
+ switch (response_id) {
+ case AN_RESPONSE_EDIT:
+ (* an->func) (ALARM_NOTIFY_EDIT, -1, an->func_data);
+ break;
+ case AN_RESPONSE_SNOOZE:
+ snooze_timeout = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time));
+ (* an->func) (ALARM_NOTIFY_SNOOZE, snooze_timeout, an->func_data);
+ break;
+ case GTK_RESPONSE_CLOSE:
+ case GTK_RESPONSE_DELETE_EVENT:
+ (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data);
+ break;
+ }
+}
+
+static void
+dialog_destroyed_cb (GtkWidget *dialog, gpointer user_data)
+{
+ AlarmNotify *an = user_data;
+
+ g_object_unref (an->xml);
+ g_free (an);
+}
+
/**
* alarm_notify_dialog:
* @trigger: Trigger time for the alarm.
@@ -96,9 +126,9 @@ an_update_minutes_label (GtkSpinButton *sb, gpointer data)
* Runs the alarm notification dialog. The specified @func will be used to
* notify the client about result of the actions in the dialog.
*
- * Return value: a pointer to the dialog structure if successful or NULL if an error occurs.
+ * Return value: a pointer to the dialog widget created or NULL if there is an error.
**/
-void
+GtkWidget *
alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
ECalComponentVType vtype, const char *summary,
const char *description, const char *location,
@@ -111,17 +141,15 @@ alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
char *start, *end;
char *icon_path;
GList *icon_list;
- int snooze_timeout;
- g_return_if_fail (trigger != -1);
+ g_return_val_if_fail (trigger != -1, NULL);
/* Only VEVENTs or VTODOs can have alarms */
- g_return_if_fail (vtype == E_CAL_COMPONENT_EVENT
- || vtype == E_CAL_COMPONENT_TODO);
- g_return_if_fail (summary != NULL);
- g_return_if_fail (description != NULL);
- g_return_if_fail (location != NULL);
- g_return_if_fail (func != NULL);
+ g_return_val_if_fail (vtype == E_CAL_COMPONENT_EVENT || vtype == E_CAL_COMPONENT_TODO, NULL);
+ g_return_val_if_fail (summary != NULL, NULL);
+ g_return_val_if_fail (description != NULL, NULL);
+ g_return_val_if_fail (location != NULL, NULL);
+ g_return_val_if_fail (func != NULL, NULL);
an = g_new0 (AlarmNotify, 1);
@@ -132,7 +160,7 @@ alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
if (!an->xml) {
g_message ("alarm_notify_dialog(): Could not load the Glade XML file!");
g_free (an);
- return;
+ return NULL;
}
an->dialog = glade_xml_get_widget (an->xml, "alarm-notify");
@@ -149,7 +177,7 @@ alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
g_message ("alarm_notify_dialog(): Could not find all widgets in Glade file!");
g_object_unref (an->xml);
g_free (an);
- return;
+ return NULL;
}
gtk_widget_realize (an->dialog);
@@ -199,20 +227,9 @@ alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
g_list_free (icon_list);
}
- switch (gtk_dialog_run (GTK_DIALOG (an->dialog))) {
- case AN_RESPONSE_EDIT:
- (* an->func) (ALARM_NOTIFY_EDIT, -1, an->func_data);
- break;
- case AN_RESPONSE_SNOOZE:
- snooze_timeout = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time));
- (* an->func) (ALARM_NOTIFY_SNOOZE, snooze_timeout, an->func_data);
- break;
- case GTK_RESPONSE_CLOSE:
- case GTK_RESPONSE_DELETE_EVENT:
- break;
- }
- gtk_widget_destroy (an->dialog);
-
- g_object_unref (an->xml);
- g_free (an);
+ g_signal_connect (G_OBJECT (an->dialog), "response", G_CALLBACK (dialog_response_cb), an);
+ g_signal_connect (G_OBJECT (an->dialog), "destroy", G_CALLBACK (dialog_destroyed_cb), an);
+ gtk_widget_show (an->dialog);
+
+ return an->dialog;
}