[gnome-sudoku] Place numbers in number picker as on numpad
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sudoku] Place numbers in number picker as on numpad
- Date: Thu, 11 Jul 2019 16:10:05 +0000 (UTC)
commit 3db33eb2d81dd674fe2fdb8205f0ce48e79ae9f4
Author: shak-mar <shakmar openmailbox org>
Date: Wed Jul 10 21:49:08 2019 +0200
Place numbers in number picker as on numpad
Now that it's common to open a number picker and then press a number on
the numpad, it's very annoying that the placement of the numbers don't
correspond properly: This makes it easy to get confused, because you
look at the number to press on the number picker, but you need to press
a key that is located differently on your keyboard.
src/number-picker.vala | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/number-picker.vala b/src/number-picker.vala
index 481c0c9..6ab46f0 100644
--- a/src/number-picker.vala
+++ b/src/number-picker.vala
@@ -42,7 +42,7 @@ private class NumberPicker : Gtk.Grid
{
for (var row = 0; row < board.block_rows; row++)
{
- int n = col + row * board.block_cols + 1;
+ int n = col + (2 - row) * board.block_cols + 1;
var button = earmark ? new ToggleButton () : new Button ();
button.focus_on_click = false;
@@ -124,8 +124,7 @@ private class NumberPicker : Gtk.Grid
{
if (state && earmarks_active >= EARMARKS_MAX_ALLOWED)
return false;
- var button = (ToggleButton) this.get_child_at (index % board.block_cols, index / board.block_rows);
- button.set_active (state);
+ get_button_for(index).set_active (state);
return true;
}
@@ -133,13 +132,19 @@ private class NumberPicker : Gtk.Grid
{
if (state)
for (var i = 0; i < board.max_val; i++)
- this.get_child_at (i % board.block_cols, i / board.block_rows).sensitive = true;
+ get_button_for(i).sensitive = true;
else
for (var i = 0; i < board.max_val; i++)
{
- var button = (ToggleButton) this.get_child_at (i % board.block_cols, i / board.block_rows);
+ var button = get_button_for (i);
if (!button.active)
button.sensitive = false;
}
}
+
+ private ToggleButton get_button_for (int number)
+ {
+ return (ToggleButton) this.get_child_at(number % board.block_cols,
+ 2 - (number / board.block_rows));
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]