[gnome-sudoku/vala-port] Fix app menu stateful action states
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sudoku/vala-port] Fix app menu stateful action states
- Date: Wed, 2 Apr 2014 00:26:02 +0000 (UTC)
commit 5aa8f690578af920d362089779ebd750df2d8b1f
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Tue Apr 1 18:45:55 2014 -0500
Fix app menu stateful action states
The menu was not properly displaying the state of show possible numbers
and warn on unfillable squares.
src/gnome-sudoku.vala | 38 +++++++++++++++-----------------------
1 files changed, 15 insertions(+), 23 deletions(-)
---
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index 7fb8a61..316b87a 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -37,17 +37,17 @@ public class Sudoku : Gtk.Application
private const GLib.ActionEntry action_entries[] =
{
- {"new-game", new_game_cb },
- {"reset", reset_cb },
- {"undo", undo_cb },
- {"redo", redo_cb },
- {"print", print_cb },
- {"print-multiple", print_multiple_cb },
- {"possible-numbers", possible_numbers_cb, null, "false", possible_numbers_changed },
- {"unfillable-squares", unfillable_squares_cb, null, "false", unfillable_squares_changed },
- {"help", help_cb },
- {"about", about_cb },
- {"quit", quit_cb }
+ {"new-game", new_game_cb },
+ {"reset", reset_cb },
+ {"undo", undo_cb },
+ {"redo", redo_cb },
+ {"print", print_cb },
+ {"print-multiple", print_multiple_cb },
+ {"possible-numbers", possible_numbers_cb, null, "false" },
+ {"unfillable-squares", unfillable_squares_cb, null, "false" },
+ {"help", help_cb },
+ {"about", about_cb },
+ {"quit", quit_cb }
};
public Sudoku ()
@@ -464,24 +464,16 @@ public class Sudoku : Gtk.Application
printer.run_dialog ();
}
- public void possible_numbers_cb ()
+ public void possible_numbers_cb (SimpleAction action)
{
view.show_possibilities = !view.show_possibilities;
+ action.set_state (new Variant.boolean (view.show_possibilities));
}
- private void possible_numbers_changed (SimpleAction action, Variant state)
- {
- view.show_possibilities = (bool) state;
- }
-
- public void unfillable_squares_cb ()
+ public void unfillable_squares_cb (SimpleAction action)
{
view.show_warnings = !view.show_warnings;
- }
-
- private void unfillable_squares_changed (SimpleAction action, Variant state)
- {
- view.show_warnings = (bool) state;
+ action.set_state (new Variant.boolean (view.show_warnings));
}
public void quit_cb ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]