Bug #639043 - Alarm notify snooze time not properly adjustable

This commit is contained in:
Chris Hemsing
2011-02-18 13:47:01 +01:00
committed by Rodrigo Moya
parent fab082af35
commit cb4f089f51
2 changed files with 65 additions and 16 deletions

View File

@ -63,10 +63,12 @@ typedef struct {
GtkWidget *dialog;
GtkWidget *snooze_time_min;
GtkWidget *snooze_time_hrs;
GtkWidget *snooze_time_days;
GtkWidget *snooze_btn;
GtkWidget *dismiss_btn;
GtkWidget *minutes_label;
GtkWidget *hrs_label;
GtkWidget *days_label;
GtkWidget *description;
GtkWidget *location;
GtkWidget *treeview;
@ -92,30 +94,36 @@ static void
an_update_minutes_label (GtkSpinButton *sb, gpointer data)
{
AlarmNotify *an;
gchar *new_label;
gint snooze_timeout_min;
an = (AlarmNotify *) data;
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);
gtk_label_set_text (GTK_LABEL (an->minutes_label), ngettext ("minute", "minutes", snooze_timeout_min));
}
static void
an_update_hrs_label (GtkSpinButton *sb, gpointer data)
{
AlarmNotify *an;
gchar *new_label;
gint snooze_timeout_hrs;
an = (AlarmNotify *) data;
snooze_timeout_hrs = gtk_spin_button_get_value_as_int (sb);
new_label = g_strdup (ngettext ("hour", "hours", snooze_timeout_hrs));
gtk_label_set_text (GTK_LABEL (an->hrs_label), new_label);
g_free (new_label);
gtk_label_set_text (GTK_LABEL (an->hrs_label), ngettext ("hour", "hours", snooze_timeout_hrs));
}
static void
an_update_days_label (GtkSpinButton *sb, gpointer data)
{
AlarmNotify *an;
gint snooze_timeout_days;
an = (AlarmNotify *) data;
snooze_timeout_days = gtk_spin_button_get_value_as_int (sb);
gtk_label_set_text (GTK_LABEL (an->days_label), ngettext ("days", "days", snooze_timeout_days));
}
static void
@ -185,6 +193,7 @@ snooze_pressed_cb (GtkButton *button, gpointer user_data)
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)));
snooze_timeout += 60 * 24 * (gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time_days)));
if (!snooze_timeout)
snooze_timeout = DEFAULT_SNOOZE_MINS;
(* funcinfo->func) (ALARM_NOTIFY_SNOOZE, snooze_timeout, funcinfo->func_data);
@ -261,6 +270,8 @@ notified_alarms_dialog_new (void)
an->minutes_label = e_builder_get_widget (an->builder, "minutes-label");
an->snooze_time_hrs = e_builder_get_widget (an->builder, "snooze-time-hrs");
an->hrs_label = e_builder_get_widget (an->builder, "hrs-label");
an->snooze_time_days = e_builder_get_widget (an->builder, "snooze-time-days");
an->days_label = e_builder_get_widget (an->builder, "days-label");
an->description = e_builder_get_widget (an->builder, "description-label");
an->location = e_builder_get_widget (an->builder, "location-label");
an->treeview = e_builder_get_widget (an->builder, "appointments-treeview");
@ -269,7 +280,8 @@ notified_alarms_dialog_new (void)
an->dismiss_btn = e_builder_get_widget (an->builder, "dismiss-button");
edit_btn = e_builder_get_widget (an->builder, "edit-button");
if (!(an->dialog && an->treeview && an->snooze_time_min && an->snooze_time_hrs
if (!(an->dialog && an->treeview
&& an->snooze_time_min && an->snooze_time_hrs && an->snooze_time_days
&& an->description && an->location && edit_btn && snooze_btn && an->dismiss_btn)) {
g_warning ("alarm_notify_dialog(): Could not find all widgets in alarm-notify.ui file!");
g_object_unref (an->builder);
@ -327,6 +339,10 @@ notified_alarms_dialog_new (void)
g_signal_connect (G_OBJECT (an->snooze_time_hrs), "value_changed",
G_CALLBACK (an_update_hrs_label), an);
/* Set callback for updating the snooze "days" label */
g_signal_connect (G_OBJECT (an->snooze_time_days), "value_changed",
G_CALLBACK (an_update_days_label), an);
na = g_new0 (AlarmNotificationsDialog, 1);
na->treeview = an->treeview;

View File

@ -3,13 +3,18 @@
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">12</property>
<property name="upper">65535</property>
<property name="step_increment">1</property>
<property name="page_increment">5</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
<property name="upper">65535</property>
<property name="step_increment">1</property>
<property name="page_increment">5</property>
</object>
<object class="GtkAdjustment" id="adjustment3">
<property name="upper">65535</property>
<property name="value">5</property>
<property name="upper">59</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
@ -177,7 +182,7 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkSpinButton" id="snooze-time-hrs">
<object class="GtkSpinButton" id="snooze-time-days">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
@ -191,9 +196,9 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="hrs-label">
<object class="GtkLabel" id="days-label">
<property name="visible">True</property>
<property name="label" translatable="yes">hours</property>
<property name="label" translatable="yes">days</property>
</object>
<packing>
<property name="expand">False</property>
@ -201,8 +206,9 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="snooze-time-min">
<object class="GtkSpinButton" id="snooze-time-hrs">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
@ -215,6 +221,33 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="hrs-label">
<property name="visible">True</property>
<property name="label" translatable="yes">hours</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="snooze-time-min">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">adjustment3</property>
<property name="climb_rate">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="minutes-label">
<property name="visible">True</property>
@ -223,7 +256,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
<property name="position">5</property>
</packing>
</child>
</object>