diff --git a/src/gui/gcal-window.blp b/src/gui/gcal-window.blp index 6f251615..1acacbff 100644 --- a/src/gui/gcal-window.blp +++ b/src/gui/gcal-window.blp @@ -252,12 +252,14 @@ template $GcalWindow: Adw.ApplicationWindow { [start] Button previous_date_button { icon-name: bind $get_previous_date_icon(views_stack.visible-child) as ; + tooltip-text: bind $get_previous_date_tooltip(views_stack.visible-child-name) as ; action-name: "win.previous-date"; } [start] Button next_date_button { icon-name: bind $get_next_date_icon(views_stack.visible-child) as ; + tooltip-text: bind $get_next_date_tooltip(views_stack.visible-child-name) as ; action-name: "win.next-date"; } diff --git a/src/gui/gcal-window.c b/src/gui/gcal-window.c index 03e94653..0804ce8d 100644 --- a/src/gui/gcal-window.c +++ b/src/gui/gcal-window.c @@ -122,9 +122,6 @@ struct _GcalWindow GtkWidget *last_focused_widget; - GtkButton *next_date_button; - GtkButton *previous_date_button; - /* new event popover widgets */ GtkWidget *quick_add_popover; @@ -223,33 +220,6 @@ update_today_action_enabled (GcalWindow *window) GCAL_EXIT; } -static void -update_view_buttons (GcalWindow *window) -{ - GCAL_ENTRY; - - switch (window->active_view) - { - case GCAL_WINDOW_VIEW_WEEK: - gtk_widget_set_tooltip_text (GTK_WIDGET (window->previous_date_button), _("Go to previous week")); - gtk_widget_set_tooltip_text (GTK_WIDGET (window->next_date_button), _("Go to next week")); - break; - case GCAL_WINDOW_VIEW_MONTH: - gtk_widget_set_tooltip_text (GTK_WIDGET (window->previous_date_button), _("Go to previous month")); - gtk_widget_set_tooltip_text (GTK_WIDGET (window->next_date_button), _("Go to next month")); - break; - case GCAL_WINDOW_VIEW_AGENDA: - gtk_widget_set_tooltip_text (GTK_WIDGET (window->previous_date_button), _("Go to previous day")); - gtk_widget_set_tooltip_text (GTK_WIDGET (window->next_date_button), _("Go to next day")); - break; - default: - g_assert_not_reached (); - break; - } - - GCAL_EXIT; -} - static gchar* get_previous_date_icon (GcalWindow *window, GcalWindowView *view) @@ -267,6 +237,20 @@ get_previous_date_icon (GcalWindow *window, } } +static gchar* +get_previous_date_tooltip (GcalWindow *window, + const gchar *view_name) +{ + if (g_str_equal (view_name, "week")) + return g_strdup (_("Go to previous week")); + else if (g_str_equal (view_name, "month")) + return g_strdup (_("Go to previous month")); + else if (g_str_equal (view_name, "agenda")) + return g_strdup (_("Go to previous day")); + else + g_assert_not_reached (); +} + static gchar* get_next_date_icon (GcalWindow *window, GcalWindowView *view) @@ -284,6 +268,20 @@ get_next_date_icon (GcalWindow *window, } } +static gchar* +get_next_date_tooltip (GcalWindow *window, + const gchar *view_name) +{ + if (g_str_equal (view_name, "week")) + return g_strdup (_("Go to next week")); + else if (g_str_equal (view_name, "month")) + return g_strdup (_("Go to next month")); + else if (g_str_equal (view_name, "agenda")) + return g_strdup (_("Go to next day")); + else + g_assert_not_reached (); +} + static void maybe_add_subscribers_to_timeline (GcalWindow *self) { @@ -724,7 +722,6 @@ view_changed (GObject *object, window->active_view = view_type; update_today_action_enabled (window); - update_view_buttons (window); g_object_notify_by_pspec (G_OBJECT (user_data), properties[PROP_ACTIVE_VIEW]); } @@ -1376,10 +1373,8 @@ gcal_window_class_init (GcalWindowClass *klass) gtk_widget_class_bind_template_child (widget_class, GcalWindow, header_bar); gtk_widget_class_bind_template_child (widget_class, GcalWindow, menu_button); gtk_widget_class_bind_template_child (widget_class, GcalWindow, month_view); - gtk_widget_class_bind_template_child (widget_class, GcalWindow, next_date_button); gtk_widget_class_bind_template_child (widget_class, GcalWindow, quick_add_popover); gtk_widget_class_bind_template_child (widget_class, GcalWindow, overlay); - gtk_widget_class_bind_template_child (widget_class, GcalWindow, previous_date_button); gtk_widget_class_bind_template_child (widget_class, GcalWindow, split_view); gtk_widget_class_bind_template_child (widget_class, GcalWindow, sync_indicator); gtk_widget_class_bind_template_child (widget_class, GcalWindow, search_button); @@ -1392,7 +1387,9 @@ 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, view_changed); gtk_widget_class_bind_template_callback (widget_class, get_previous_date_icon); + gtk_widget_class_bind_template_callback (widget_class, get_previous_date_tooltip); gtk_widget_class_bind_template_callback (widget_class, get_next_date_icon); + gtk_widget_class_bind_template_callback (widget_class, get_next_date_tooltip); /* Event creation related */ gtk_widget_class_bind_template_callback (widget_class, close_new_event_widget);