[gnome-sudoku] SudokuPrinter: store a list instead of an array
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sudoku] SudokuPrinter: store a list instead of an array
- Date: Sun, 5 Oct 2014 18:07:19 +0000 (UTC)
commit 264ae339f28a7bb3ffe04ceada86f8fe41413605
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Oct 5 12:56:58 2014 -0500
SudokuPrinter: store a list instead of an array
src/gnome-sudoku.vala | 6 +++++-
src/print-dialog.vala | 2 +-
src/sudoku-printer.vala | 10 +++++-----
3 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index 6e79522..cc6bfa3 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -468,8 +468,12 @@ public class Sudoku : Gtk.Application
return;
print_action.set_enabled (false);
print_multiple_action.set_enabled (false);
- var printer = new SudokuPrinter ({game.board.clone ()}, (Window) window);
+
+ var list = new Gee.ArrayList<SudokuBoard> ();
+ list.add (game.board.clone ());
+ var printer = new SudokuPrinter (list, (Window) window);
printer.print_sudoku ();
+
print_action.set_enabled (true);
print_multiple_action.set_enabled (true);
}
diff --git a/src/print-dialog.vala b/src/print-dialog.vala
index cb0e58e..aa588ba 100644
--- a/src/print-dialog.vala
+++ b/src/print-dialog.vala
@@ -129,7 +129,7 @@ once = true;
spinner.hide ();
sensitive = true;
- var printer = new SudokuPrinter (boards, this);
+ var printer = new SudokuPrinter (new Gee.ArrayList<SudokuBoard>.wrap (boards), this);
if (printer.print_sudoku () == Gtk.PrintOperationResult.APPLY)
{
foreach (SudokuBoard board in boards)
diff --git a/src/sudoku-printer.vala b/src/sudoku-printer.vala
index d8aa4b6..dfc77b5 100644
--- a/src/sudoku-printer.vala
+++ b/src/sudoku-printer.vala
@@ -24,7 +24,7 @@ using Gdk;
public class SudokuPrinter : GLib.Object {
- private SudokuBoard[] boards;
+ private Gee.List<SudokuBoard> boards;
private Gtk.Window window;
private int margin;
@@ -51,12 +51,12 @@ public class SudokuPrinter : GLib.Object {
return Gtk.PrintOperationResult.ERROR;
}
- public SudokuPrinter (SudokuBoard[] boards, Gtk.Window window)
+ public SudokuPrinter (Gee.List<SudokuBoard> boards, Gtk.Window window)
{
this.boards = boards;
this.window = window;
this.margin = 25;
- this.n_sudokus = boards.length;
+ this.n_sudokus = boards.size;
this.print_op = new Gtk.PrintOperation ();
print_op.begin_print.connect (begin_print_cb);
@@ -81,8 +81,8 @@ public class SudokuPrinter : GLib.Object {
var best_square_size = fit_squares_in_rectangle (width, height, margin);
var start = page_nr * SUDOKUS_PER_PAGE;
- var end = int.min ((start + SUDOKUS_PER_PAGE), boards.length);
- SudokuBoard[] sudokus_on_page = boards[start : end];
+ var end = int.min ((start + SUDOKUS_PER_PAGE), boards.size);
+ Gee.List<SudokuBoard> sudokus_on_page = boards.slice (start, end);
double left = (width - best_square_size) / 2;
double top = margin;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]