common/date-chooser: Increment or decrement year when GcalMultiChoice wraps
Closes: https://gitlab.gnome.org/GNOME/gnome-calendar/-/work_items/97 Closes: https://gitlab.gnome.org/GNOME/gnome-calendar/-/work_items/1484 Co-authored-by: mindonwarp <mind.on.warp@gmail.com> Co-authored-by: Koc13 <ilija.kocinac@proton.me> Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/853>
This commit is contained in:
committed by
Marge Bot
co-authored by
mindonwarp
Koc13
parent
1c5b826af0
commit
6bba8e2cc8
@@ -17,6 +17,7 @@ template $GcalDateChooser: Adw.Bin {
|
||||
next-button-tooltip: _("Next Month");
|
||||
visible: bind $get_split_choice_visible(template.show-heading, template.split-month-year) as <bool>;
|
||||
user-changed => $on_split_multi_choice_user_changed() swapped;
|
||||
wrapped => $on_split_multi_choice_wrapped() swapped;
|
||||
|
||||
layout {
|
||||
column: 0;
|
||||
@@ -93,6 +94,7 @@ Popover popover {
|
||||
next-button-tooltip: bind month_choice.next-button-tooltip;
|
||||
string-list: bind month_choice.string-list;
|
||||
user-changed => $on_split_multi_choice_user_changed() swapped;
|
||||
wrapped => $on_split_multi_choice_wrapped() swapped;
|
||||
}
|
||||
|
||||
$GcalMultiChoice {
|
||||
|
||||
@@ -889,6 +889,29 @@ on_split_multi_choice_user_changed (GcalDateChooser *self)
|
||||
multi_choice_changed (self, year, month, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
on_split_multi_choice_wrapped (GcalDateChooser *self)
|
||||
{
|
||||
int year, month;
|
||||
|
||||
year = gcal_multi_choice_get_value (GCAL_MULTI_CHOICE (self->year_choice));
|
||||
month = gcal_multi_choice_get_value (GCAL_MULTI_CHOICE (self->month_choice)) + 1;
|
||||
|
||||
switch (month)
|
||||
{
|
||||
case G_DATE_JANUARY:
|
||||
year++;
|
||||
break;
|
||||
case G_DATE_DECEMBER:
|
||||
year--;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
multi_choice_changed (self, year, month, 1);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
on_drop_target_drop_cb (GtkDropTarget *target,
|
||||
const GValue *value,
|
||||
@@ -1021,6 +1044,7 @@ gcal_date_chooser_class_init (GcalDateChooserClass *class)
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalDateChooser, gizmo);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_combined_multi_choice_user_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_split_multi_choice_wrapped);
|
||||
gtk_widget_class_bind_template_callback (widget_class, get_combined_choice_visible);
|
||||
gtk_widget_class_bind_template_callback (widget_class, get_split_choice_visible);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_split_multi_choice_user_changed);
|
||||
|
||||
Reference in New Issue
Block a user