datetime: Avoid emitting the time-changed signal

When setting the widget value, don’t emit the time-changed signal.

Fixes #2943
This commit is contained in:
Xiaoguang Wang 2024-04-03 12:46:24 +08:00 committed by Felipe Borges
parent e76c39fe2c
commit 97c0d13a3a

View file

@ -207,6 +207,10 @@ clock_settings_changed_cb (CcDateTimePage *self,
g_signal_handlers_unblock_by_func (self->ampm_format_button, change_clock_settings, self);
}
static void on_month_selection_changed_cb (CcDateTimePage *self);
static void time_changed_cb (CcDateTimePage *self,
CcTimeEditor *editor);
/* Update the widgets based on the system time */
static void
@ -220,9 +224,11 @@ update_time (CcDateTimePage *self)
else
use_ampm = FALSE;
g_signal_handlers_block_by_func (self->time_editor, time_changed_cb, self);
cc_time_editor_set_time (self->time_editor,
g_date_time_get_hour (self->date),
g_date_time_get_minute (self->date));
g_signal_handlers_unblock_by_func (self->time_editor, time_changed_cb, self);
/* Update the time on the listbow row */
if (use_ampm)
@ -237,7 +243,9 @@ update_time (CcDateTimePage *self)
}
self->month = g_date_time_get_month (self->date);
g_signal_handlers_block_by_func (self->month_model, on_month_selection_changed_cb, self);
gtk_single_selection_set_selected (self->month_model, self->month - 1);
g_signal_handlers_unblock_by_func (self->month_model, on_month_selection_changed_cb, self);
cc_list_row_set_secondary_label (self->datetime_row, label);
}
@ -363,9 +371,11 @@ change_date (CcDateTimePage *self)
g_date_time_get_hour (old_date),
g_date_time_get_minute (old_date),
g_date_time_get_second (old_date));
g_signal_handlers_block_by_func (self->time_editor, time_changed_cb, self);
cc_time_editor_set_time (self->time_editor,
g_date_time_get_hour (self->date),
g_date_time_get_minute (self->date));
g_signal_handlers_unblock_by_func (self->time_editor, time_changed_cb, self);
queue_set_datetime (self);
}
@ -749,7 +759,9 @@ setup_datetime_dialog (CcDateTimePage *self)
/* Month */
self->month = g_date_time_get_month (self->date);
g_signal_handlers_block_by_func (self->month_model, on_month_selection_changed_cb, self);
gtk_single_selection_set_selected (self->month_model, self->month - 1);
g_signal_handlers_unblock_by_func (self->month_model, on_month_selection_changed_cb, self);
}
static int