[gnome-sudoku/vala-port] Show 'Clear' button in popover for a filled cell
- From: Parin Porecha <parinporecha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sudoku/vala-port] Show 'Clear' button in popover for a filled cell
- Date: Tue, 27 May 2014 13:20:42 +0000 (UTC)
commit 15ec227748a0c3671f1f2660aec00fe283ab2c1a
Author: Parin Porecha <parinporecha gmail com>
Date: Sat May 24 12:51:59 2014 +0530
Show 'Clear' button in popover for a filled cell
src/number-picker.vala | 37 +++++++++++++++++++++----------------
src/sudoku-view.vala | 7 ++++++-
2 files changed, 27 insertions(+), 17 deletions(-)
---
diff --git a/src/number-picker.vala b/src/number-picker.vala
index 94e29ea..c39417e 100644
--- a/src/number-picker.vala
+++ b/src/number-picker.vala
@@ -6,7 +6,9 @@ private class NumberPicker : Gtk.Grid
public signal void number_picked (int number);
- public NumberPicker (ref SudokuBoard board, bool show_clear = true) {
+ private Gtk.Button clear_button;
+
+ public NumberPicker (ref SudokuBoard board) {
this.board = board;
for (var col = 0; col < board.block_cols; col++)
@@ -35,24 +37,27 @@ private class NumberPicker : Gtk.Grid
}
}
- if (show_clear)
- {
- var button = new Gtk.Button ();
- button.focus_on_click = false;
- this.attach (button, 0, 4, 3, 1);
-
- var label = new Gtk.Label ("<big>Clear</big>");
- label.use_markup = true;
- button.add (label);
- label.show ();
+ clear_button = new Gtk.Button ();
+ clear_button.focus_on_click = false;
+ this.attach (clear_button, 0, 4, 3, 1);
- button.clicked.connect (() => {
- number_picked(0);
- });
+ var label = new Gtk.Label ("<big>Clear</big>");
+ label.use_markup = true;
+ clear_button.add (label);
+ label.show ();
- button.show ();
- }
+ clear_button.clicked.connect (() => {
+ number_picked(0);
+ });
this.show ();
}
+
+ public void set_clear_button_visibility (bool visible)
+ {
+ if (visible)
+ clear_button.show ();
+ else
+ clear_button.hide ();
+ }
}
diff --git a/src/sudoku-view.vala b/src/sudoku-view.vala
index 3f2b7de..27cf25b 100644
--- a/src/sudoku-view.vala
+++ b/src/sudoku-view.vala
@@ -124,13 +124,15 @@ private class SudokuCellView : Gtk.DrawingArea
}
}
+ private NumberPicker number_picker;
+
public SudokuCellView (int row, int col, ref SudokuGame game, bool small = false)
{
this.game = game;
this._row = row;
this._col = col;
- var number_picker = new NumberPicker(ref game.board, value != 0);
+ number_picker = new NumberPicker(ref game.board);
number_picker.number_picked.connect ((o, number) => {
value = number;
if (number == 0)
@@ -215,7 +217,10 @@ private class SudokuCellView : Gtk.DrawingArea
private void show_number_picker ()
{
if (!is_fixed)
+ {
+ number_picker.set_clear_button_visibility (value != 0);
popover.show ();
+ }
}
private void show_note_editor (int top)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]