Skip to content
Snippets Groups Projects
Verified Commit fb5ae3d7 authored by Bruce Cowan's avatar Bruce Cowan :airplane:
Browse files

Use action for showing try filter

parent b789c7c1
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,11 @@ ShortcutsWindow help_overlay {
title: "Decrement score";
action-name: "win.score-changed::down";
}
ShortcutsShortcut {
title: "Show try filter";
action-name: "win.show-try-filter";
}
}
}
}
......@@ -24,10 +24,9 @@ template RugbyAppWindow : Adw.ApplicationWindow {
}
ToggleButton filter_toggle {
action-name: "win.show-try-filter";
icon-name: "funnel";
tooltip-text: "Show Try Filter";
toggled => filter_toggle_toggled_cb();
}
[end]
......
......@@ -77,6 +77,9 @@ on_startup (GApplication *app,
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"win.score-changed::down",
(const char*[]) { "<Ctrl>Down", "<Ctrl>Left", NULL });
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"win.show-try-filter",
(const char*[]) { "<Ctrl>F", NULL });
}
int
......
......@@ -148,12 +148,13 @@ try_filter_func (gpointer item,
}
static void
filter_toggle_toggled_cb (GtkToggleButton *btn,
gpointer user_data)
show_try_filter_change_state (GSimpleAction *action,
GVariant *value,
gpointer user_data)
{
RugbyAppWindow *self = RUGBY_APP_WINDOW (user_data);
if (gtk_toggle_button_get_active (btn))
if (g_variant_get_boolean (value))
{
gtk_custom_filter_set_filter_func (self->try_filter, try_filter_func, self, NULL);
gtk_filter_changed (GTK_FILTER (self->try_filter), GTK_FILTER_CHANGE_DIFFERENT);
......@@ -162,6 +163,8 @@ filter_toggle_toggled_cb (GtkToggleButton *btn,
{
gtk_custom_filter_set_filter_func (self->try_filter, NULL, NULL, NULL);
}
g_simple_action_set_state (action, value);
}
static void
......@@ -171,6 +174,7 @@ rugby_app_window_init (RugbyAppWindow *self)
const GActionEntry win_entries[] = {
{ .name = "score-changed", .activate = activate_score_changed, .parameter_type = "s" },
{ .name = "show-try-filter", .state = "false", .change_state = show_try_filter_change_state },
};
g_action_map_add_action_entries (G_ACTION_MAP (self),
......@@ -201,7 +205,6 @@ rugby_app_window_class_init (RugbyAppWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, try_filter);
gtk_widget_class_bind_template_callback (widget_class, filter_toggle_toggled_cb);
gtk_widget_class_bind_template_callback (widget_class, try_spin_value_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, item_tooltip_cb);
gtk_widget_class_bind_template_callback (widget_class, list_store_items_changed_cb);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment