window: Use closures for view button tooltip text
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/592>
This commit is contained in:
committed by
Marge Bot
parent
684ed71711
commit
7eb65ded71
@@ -252,12 +252,14 @@ template $GcalWindow: Adw.ApplicationWindow {
|
|||||||
[start]
|
[start]
|
||||||
Button previous_date_button {
|
Button previous_date_button {
|
||||||
icon-name: bind $get_previous_date_icon(views_stack.visible-child) as <string>;
|
icon-name: bind $get_previous_date_icon(views_stack.visible-child) as <string>;
|
||||||
|
tooltip-text: bind $get_previous_date_tooltip(views_stack.visible-child-name) as <string>;
|
||||||
action-name: "win.previous-date";
|
action-name: "win.previous-date";
|
||||||
}
|
}
|
||||||
|
|
||||||
[start]
|
[start]
|
||||||
Button next_date_button {
|
Button next_date_button {
|
||||||
icon-name: bind $get_next_date_icon(views_stack.visible-child) as <string>;
|
icon-name: bind $get_next_date_icon(views_stack.visible-child) as <string>;
|
||||||
|
tooltip-text: bind $get_next_date_tooltip(views_stack.visible-child-name) as <string>;
|
||||||
action-name: "win.next-date";
|
action-name: "win.next-date";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
-33
@@ -122,9 +122,6 @@ struct _GcalWindow
|
|||||||
|
|
||||||
GtkWidget *last_focused_widget;
|
GtkWidget *last_focused_widget;
|
||||||
|
|
||||||
GtkButton *next_date_button;
|
|
||||||
GtkButton *previous_date_button;
|
|
||||||
|
|
||||||
/* new event popover widgets */
|
/* new event popover widgets */
|
||||||
GtkWidget *quick_add_popover;
|
GtkWidget *quick_add_popover;
|
||||||
|
|
||||||
@@ -223,33 +220,6 @@ update_today_action_enabled (GcalWindow *window)
|
|||||||
GCAL_EXIT;
|
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*
|
static gchar*
|
||||||
get_previous_date_icon (GcalWindow *window,
|
get_previous_date_icon (GcalWindow *window,
|
||||||
GcalWindowView *view)
|
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*
|
static gchar*
|
||||||
get_next_date_icon (GcalWindow *window,
|
get_next_date_icon (GcalWindow *window,
|
||||||
GcalWindowView *view)
|
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
|
static void
|
||||||
maybe_add_subscribers_to_timeline (GcalWindow *self)
|
maybe_add_subscribers_to_timeline (GcalWindow *self)
|
||||||
{
|
{
|
||||||
@@ -724,7 +722,6 @@ view_changed (GObject *object,
|
|||||||
|
|
||||||
window->active_view = view_type;
|
window->active_view = view_type;
|
||||||
update_today_action_enabled (window);
|
update_today_action_enabled (window);
|
||||||
update_view_buttons (window);
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (user_data), properties[PROP_ACTIVE_VIEW]);
|
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, header_bar);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, menu_button);
|
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, 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, quick_add_popover);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, overlay);
|
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, split_view);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, sync_indicator);
|
gtk_widget_class_bind_template_child (widget_class, GcalWindow, sync_indicator);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, search_button);
|
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, 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_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_icon);
|
||||||
|
gtk_widget_class_bind_template_callback (widget_class, get_next_date_tooltip);
|
||||||
|
|
||||||
/* 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