From c4d47316235afab9b11afae003358efed4ad75cd Mon Sep 17 00:00:00 2001 From: Chenthill Palanisamy Date: Thu, 5 Jan 2006 06:30:50 +0000 Subject: modified the alarm-notify.glade file and some code in alarm-notify-dialog.c to include "hours" as an option for snooze time in alarm notification dialog. Fixes 317808 svn path=/trunk/; revision=31058 --- calendar/ChangeLog | 9 ++++ calendar/gui/alarm-notify/alarm-notify-dialog.c | 65 ++++++++++++++++--------- calendar/gui/alarm-notify/alarm-notify.glade | 47 +++++++++++++++++- 3 files changed, 95 insertions(+), 26 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 92e5a43e60..53c58b5099 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,12 @@ +2006-01-05 P S Chakravarthi + + Fixes 317808 + + * gui/alarm-notify/alarm-notify.glade : added hours as a + spin button for snooze + * gui/alarm-notify/alarm-notify-dialog.c : added code to + include hours in calculation of snooze time. + 2006-01-04 Chenthill Palanisamy * gui/e-day-view.c: (e_day_view_convert_event_coords), diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.c b/calendar/gui/alarm-notify/alarm-notify-dialog.c index 4aa356af3e..9ce09b96d6 100644 --- a/calendar/gui/alarm-notify/alarm-notify-dialog.c +++ b/calendar/gui/alarm-notify/alarm-notify-dialog.c @@ -38,15 +38,14 @@ # include #endif #include -#include +#include #include #include "alarm-notify-dialog.h" #include "config-data.h" #include "util.h" #include -#include - + enum { ALARM_DISPLAY_COLUMN, @@ -73,8 +72,10 @@ typedef struct { GladeXML *xml; GtkWidget *dialog; - GtkWidget *snooze_time; + GtkWidget *snooze_time_min; + GtkWidget *snooze_time_hrs; GtkWidget *minutes_label; + GtkWidget *hrs_label; GtkWidget *description; GtkWidget *location; GtkWidget *treeview; @@ -85,7 +86,6 @@ typedef struct { } AlarmNotify; - static void tree_selection_changed_cb (GtkTreeSelection *selection, gpointer data); @@ -98,27 +98,40 @@ edit_pressed_cb (GtkButton *button, gpointer user_data); static void snooze_pressed_cb (GtkButton *button, gpointer user_data); - AlarmNotify *an = NULL; gboolean have_one = FALSE; - static void an_update_minutes_label (GtkSpinButton *sb, gpointer data) { AlarmNotify *an; char *new_label; - int snooze_timeout; + int snooze_timeout_min; an = (AlarmNotify *) data; - snooze_timeout = gtk_spin_button_get_value_as_int (sb); - new_label = g_strdup (ngettext ("minute", "minutes", snooze_timeout)); + snooze_timeout_min = gtk_spin_button_get_value_as_int (sb); + new_label = g_strdup (ngettext ("minute", "minutes", snooze_timeout_min)); gtk_label_set_text (GTK_LABEL (an->minutes_label), new_label); g_free (new_label); } +static void +an_update_hrs_label (GtkSpinButton *sb, gpointer data) +{ + AlarmNotify *an; + char *new_label; + int snooze_timeout_hrs; + + an = (AlarmNotify *) data; + + snooze_timeout_hrs = gtk_spin_button_get_value_as_int (sb); + new_label = g_strdup (ngettext ("hours", "hours", snooze_timeout_hrs)); + gtk_label_set_text (GTK_LABEL (an->hrs_label), new_label); + g_free (new_label); +} + static void dialog_response_cb (GtkDialog *dialog, guint response_id, gpointer user_data) { @@ -175,7 +188,8 @@ snooze_pressed_cb (GtkButton *button, gpointer user_data) g_return_if_fail (funcinfo); - snooze_timeout = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time)); + snooze_timeout = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time_min)); + snooze_timeout += 60 * (gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time_hrs))); (* funcinfo->func) (ALARM_NOTIFY_SNOOZE, snooze_timeout, funcinfo->func_data); } @@ -219,14 +233,8 @@ notified_alarms_dialog_new (void) G_TYPE_POINTER, /* End */ G_TYPE_POINTER /* FuncInfo*/)); - char *gladefile; - gladefile = g_build_filename (EVOLUTION_GLADEDIR, - "alarm-notify.glade", - NULL); - an->xml = glade_xml_new (gladefile, NULL, NULL); - g_free (gladefile); - + an->xml = glade_xml_new (EVOLUTION_GLADEDIR "/alarm-notify.glade", NULL, NULL); if (!an->xml) { g_message ("alarm_notify_dialog(): Could not load the Glade XML file!"); g_free (an); @@ -234,8 +242,10 @@ notified_alarms_dialog_new (void) } an->dialog = glade_xml_get_widget (an->xml, "alarm-notify"); - an->snooze_time = glade_xml_get_widget (an->xml, "snooze-time"); + an->snooze_time_min = glade_xml_get_widget (an->xml, "snooze-time-min"); an->minutes_label = glade_xml_get_widget (an->xml, "minutes-label"); + an->snooze_time_hrs = glade_xml_get_widget (an->xml, "snooze-time-hrs"); + an->hrs_label = glade_xml_get_widget (an->xml, "hrs-label"); an->description = glade_xml_get_widget (an->xml, "description-label"); an->location = glade_xml_get_widget (an->xml, "location-label"); an->treeview = glade_xml_get_widget (an->xml, "appointments-treeview"); @@ -243,7 +253,7 @@ notified_alarms_dialog_new (void) snooze_btn = glade_xml_get_widget (an->xml, "snooze-button"); edit_btn = glade_xml_get_widget (an->xml, "edit-button"); - if (!(an->dialog && an->scrolledwindow && an->treeview && an->snooze_time + if (!(an->dialog && an->scrolledwindow && an->treeview && an->snooze_time_min && an->snooze_time_hrs && an->description && an->location && edit_btn && snooze_btn)) { g_message ("alarm_notify_dialog(): Could not find all widgets in Glade file!"); g_object_unref (an->xml); @@ -291,9 +301,13 @@ notified_alarms_dialog_new (void) } /* Set callback for updating the snooze "minutes" label */ - g_signal_connect (G_OBJECT (an->snooze_time), "value_changed", + g_signal_connect (G_OBJECT (an->snooze_time_min), "value_changed", G_CALLBACK (an_update_minutes_label), an); + /* Set callback for updating the snooze "hours" label */ + g_signal_connect (G_OBJECT (an->snooze_time_hrs), "value_changed", + G_CALLBACK (an_update_hrs_label), an); + na = g_new0 (AlarmNotificationsDialog, 1); @@ -303,6 +317,7 @@ notified_alarms_dialog_new (void) return na; } + /** * add_alarm_to_notified_alarms_dialog: * @na: Pointer to the dialog-info @@ -332,7 +347,7 @@ add_alarm_to_notified_alarms_dialog (AlarmNotificationsDialog *na, time_t trigge GtkTreeIter iter; GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (na->treeview)); AlarmFuncInfo *funcinfo = NULL; - gchar *to_display = NULL, *start, *end; + gchar *to_display = NULL, *start, *end, *str_time; icaltimezone *current_zone; g_return_val_if_fail (trigger != -1, iter); @@ -353,13 +368,15 @@ add_alarm_to_notified_alarms_dialog (AlarmNotificationsDialog *na, time_t trigge current_zone = config_data_get_timezone (); start = timet_to_str_with_zone (occur_start, current_zone); end = timet_to_str_with_zone (occur_end, current_zone); - to_display = g_strdup_printf (_("%s\n%s until %s"), - summary, start, end); + str_time = calculate_time (occur_start, occur_end); + to_display = g_strdup_printf (_("%s\n%s %s"), + summary, start, str_time); g_free (start); g_free (end); gtk_list_store_set (GTK_LIST_STORE(model), &iter, ALARM_DISPLAY_COLUMN, to_display, -1); g_free (to_display); + g_free (str_time); gtk_list_store_set (GTK_LIST_STORE(model), &iter, ALARM_SUMMARY_COLUMN, summary, -1); gtk_list_store_set (GTK_LIST_STORE(model), &iter, ALARM_DESCRIPTION_COLUMN, description, -1); diff --git a/calendar/gui/alarm-notify/alarm-notify.glade b/calendar/gui/alarm-notify/alarm-notify.glade index 97bdea1f45..359cc0915b 100644 --- a/calendar/gui/alarm-notify/alarm-notify.glade +++ b/calendar/gui/alarm-notify/alarm-notify.glade @@ -197,9 +197,52 @@ True False 6 + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 0 0 12 1 5 5 + + + 0 + False + False + + + + + + True + hours + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + - + True True 1 @@ -208,7 +251,7 @@ GTK_UPDATE_ALWAYS False False - 5 1 60 1 10 10 + 5 1 59 1 10 10 0 -- cgit v1.2.3