[gnome-sudoku/gnome-3-16: 7/14] Makes the highlighter optional
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sudoku/gnome-3-16: 7/14] Makes the highlighter optional
- Date: Mon, 16 Feb 2015 21:12:47 +0000 (UTC)
commit a69e5a945599f1a4f62f8db41d05bdda974a921c
Author: Andrei Ghincu <ghincuandrei gmail com>
Date: Mon Nov 10 22:19:03 2014 +0200
Makes the highlighter optional
The highlighting of the row, column and square that contain
the selected cell was always on.
https://bugzilla.gnome.org/show_bug.cgi?id=734724
data/gnome-sudoku-menu.ui | 6 ++++++
data/org.gnome.sudoku.gschema.xml | 4 ++++
src/gnome-sudoku.vala | 6 ++++++
src/sudoku-view.vala | 29 ++++++++++++++++++++++++++---
4 files changed, 42 insertions(+), 3 deletions(-)
---
diff --git a/data/gnome-sudoku-menu.ui b/data/gnome-sudoku-menu.ui
index 908c96b..b8b551e 100644
--- a/data/gnome-sudoku-menu.ui
+++ b/data/gnome-sudoku-menu.ui
@@ -25,6 +25,12 @@
</section>
<section>
<item>
+ <attribute name="label" translatable="yes">High_lighter</attribute>
+ <attribute name="action">app.highlighter</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
<attribute name="label" translatable="yes">_Help</attribute>
<attribute name="action">app.help</attribute>
</item>
diff --git a/data/org.gnome.sudoku.gschema.xml b/data/org.gnome.sudoku.gschema.xml
index 8b5aa05..ffefc18 100644
--- a/data/org.gnome.sudoku.gschema.xml
+++ b/data/org.gnome.sudoku.gschema.xml
@@ -22,6 +22,10 @@
<summary>Warn about unfillable squares and duplicate numbers</summary>
<description>Displays a big red X in a square if it cannot possibly be filled by any number and
duplicate numbers are highlighted in red</description>
</key>
+ <key name="highlighter" type="b">
+ <default>false</default>
+ <summary>Highlight row, column and square that contain the selected cell</summary>
+ </key>
<key name="window-width" type="i">
<default>730</default>
<summary>Width of the window in pixels</summary>
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index b7d23a7..a48d64c 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -132,6 +132,11 @@ public class Sudoku : Gtk.Application
view.show_warnings = settings.get_boolean ("show-warnings"));
add_action (action);
+ var highlighter_action = settings.create_action ("highlighter");
+ highlighter_action.notify["state"].connect (() =>
+ view.highlighter = settings.get_boolean ("highlighter"));
+ add_action (highlighter_action);
+
set_accels_for_action ("app.new-game", {"<Primary>n"});
set_accels_for_action ("app.print", {"<Primary>p"});
set_accels_for_action ("app.quit", {"<Primary>q"});
@@ -265,6 +270,7 @@ public class Sudoku : Gtk.Application
view.show_possibilities = show_possibilities;
view.show_warnings = settings.get_boolean ("show-warnings");
+ view.highlighter = settings.get_boolean ("highlighter");
view.show ();
game_box.pack_start (view);
diff --git a/src/sudoku-view.vala b/src/sudoku-view.vala
index c7f133d..2111c59 100644
--- a/src/sudoku-view.vala
+++ b/src/sudoku-view.vala
@@ -447,15 +447,29 @@ public class SudokuView : Gtk.AspectFrame
for (var col_tmp = 0; col_tmp < game.board.cols; col_tmp++)
{
- var color = (col_tmp == cell_col) ? highlight_color : free_cell_color;
+ var color = (col_tmp == cell_col && _highlighter) ? highlight_color :
free_cell_color;
for (var row_tmp = 0; row_tmp < game.board.rows; row_tmp++)
cells[row_tmp,col_tmp].background_color = cells[row_tmp,col_tmp].is_fixed ?
fixed_cell_color : color;
}
for (var col_tmp = 0; col_tmp < game.board.cols; col_tmp++)
- cells[cell_row, col_tmp].background_color = cells[cell_row, col_tmp].is_fixed ?
fixed_cell_color : highlight_color;
+ {
+ if (cells[cell_row, col_tmp].is_fixed)
+ cells[cell_row, col_tmp].background_color = fixed_cell_color;
+ else if (_highlighter)
+ cells[cell_row, col_tmp].background_color = highlight_color;
+ else
+ cells[cell_row, col_tmp].background_color = free_cell_color;
+ }
foreach (Coord? coord in game.board.coords_for_block.get (Coord (cell_row /
game.board.block_rows, cell_col / game.board.block_cols)))
- cells[coord.row, coord.col].background_color = cells[coord.row, coord.col].is_fixed
? fixed_cell_color : highlight_color;
+ {
+ if (cells[coord.row, coord.col].is_fixed)
+ cells[coord.row, coord.col].background_color = fixed_cell_color;
+ else if (_highlighter)
+ cells[coord.row, coord.col].background_color = highlight_color;
+ else
+ cells[coord.row, coord.col].background_color = free_cell_color;
+ }
cells[cell_row, cell_col].background_color = selected_bg_color;
@@ -575,4 +589,13 @@ public class SudokuView : Gtk.AspectFrame
cells[i,j].show_possibilities = value;
}
}
+
+ private bool _highlighter = false;
+ public bool highlighter
+ {
+ get { return _highlighter; }
+ set {
+ _highlighter = value;
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]