window: Use closures for view button icons
Fixes #1405 Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/591>
This commit is contained in:
@@ -251,13 +251,13 @@ template $GcalWindow: Adw.ApplicationWindow {
|
|||||||
ActionBar {
|
ActionBar {
|
||||||
[start]
|
[start]
|
||||||
Button previous_date_button {
|
Button previous_date_button {
|
||||||
icon-name: "go-previous-symbolic";
|
icon-name: bind $get_previous_date_icon(views_stack.visible-child) as <string>;
|
||||||
action-name: "win.previous-date";
|
action-name: "win.previous-date";
|
||||||
}
|
}
|
||||||
|
|
||||||
[start]
|
[start]
|
||||||
Button next_date_button {
|
Button next_date_button {
|
||||||
icon-name: "go-next-symbolic";
|
icon-name: bind $get_next_date_icon(views_stack.visible-child) as <string>;
|
||||||
action-name: "win.next-date";
|
action-name: "win.next-date";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+28
-12
@@ -228,18 +228,6 @@ update_view_buttons (GcalWindow *window)
|
|||||||
{
|
{
|
||||||
GCAL_ENTRY;
|
GCAL_ENTRY;
|
||||||
|
|
||||||
switch (gcal_view_get_time_direction (GCAL_VIEW (window->views[window->active_view])))
|
|
||||||
{
|
|
||||||
case GTK_ORIENTATION_VERTICAL:
|
|
||||||
gtk_button_set_icon_name (window->previous_date_button, "go-up-symbolic");
|
|
||||||
gtk_button_set_icon_name (window->next_date_button, "go-down-symbolic");
|
|
||||||
break;
|
|
||||||
case GTK_ORIENTATION_HORIZONTAL:
|
|
||||||
gtk_button_set_icon_name (window->previous_date_button, "go-previous-symbolic");
|
|
||||||
gtk_button_set_icon_name (window->next_date_button, "go-next-symbolic");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (window->active_view)
|
switch (window->active_view)
|
||||||
{
|
{
|
||||||
case GCAL_WINDOW_VIEW_WEEK:
|
case GCAL_WINDOW_VIEW_WEEK:
|
||||||
@@ -262,6 +250,32 @@ update_view_buttons (GcalWindow *window)
|
|||||||
GCAL_EXIT;
|
GCAL_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar*
|
||||||
|
get_previous_date_icon (GcalWindow *window,
|
||||||
|
GcalWindowView *view)
|
||||||
|
{
|
||||||
|
switch (gcal_view_get_time_direction (GCAL_VIEW (view)))
|
||||||
|
{
|
||||||
|
case GTK_ORIENTATION_VERTICAL:
|
||||||
|
return g_strdup ("go-up-symbolic");
|
||||||
|
case GTK_ORIENTATION_HORIZONTAL:
|
||||||
|
return g_strdup ("go-previous-symbolic");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gchar*
|
||||||
|
get_next_date_icon (GcalWindow *window,
|
||||||
|
GcalWindowView *view)
|
||||||
|
{
|
||||||
|
switch (gcal_view_get_time_direction (GCAL_VIEW (view)))
|
||||||
|
{
|
||||||
|
case GTK_ORIENTATION_VERTICAL:
|
||||||
|
return g_strdup ("go-down-symbolic");
|
||||||
|
case GTK_ORIENTATION_HORIZONTAL:
|
||||||
|
return g_strdup ("go-next-symbolic");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
maybe_add_subscribers_to_timeline (GcalWindow *self)
|
maybe_add_subscribers_to_timeline (GcalWindow *self)
|
||||||
{
|
{
|
||||||
@@ -1366,6 +1380,8 @@ gcal_window_class_init (GcalWindowClass *klass)
|
|||||||
|
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_breakpoint_changed);
|
gtk_widget_class_bind_template_callback (widget_class, on_breakpoint_changed);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, view_changed);
|
gtk_widget_class_bind_template_callback (widget_class, view_changed);
|
||||||
|
gtk_widget_class_bind_template_callback (widget_class, get_previous_date_icon);
|
||||||
|
gtk_widget_class_bind_template_callback (widget_class, get_next_date_icon);
|
||||||
|
|
||||||
/* Event creation related */
|
/* Event creation related */
|
||||||
gtk_widget_class_bind_template_callback (widget_class, close_new_event_widget);
|
gtk_widget_class_bind_template_callback (widget_class, close_new_event_widget);
|
||||||
|
|||||||
Reference in New Issue
Block a user