[gnome-sudoku] Disallow printing actions when the "print multiple" dialog is shown.



commit ac6c022de654529aa840ff2a40b580bc3ac995b6
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Sep 5 20:13:23 2014 +0200

    Disallow printing actions when the "print multiple" dialog is shown.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735260

 data/print-games.ui     |    1 +
 src/gnome-sudoku.vala   |    8 +++++++-
 src/sudoku-printer.vala |   10 +++++++---
 3 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/data/print-games.ui b/data/print-games.ui
index 0bb967d..aec4626 100644
--- a/data/print-games.ui
+++ b/data/print-games.ui
@@ -16,6 +16,7 @@
     <property name="height_request">300</property>
     <property name="width_request">450</property>
     <property name="expand">False</property>
+    <property name="modal">True</property>
     <child internal-child="headerbar">
       <object class="GtkHeaderBar" id="the_headerbar">
         <property name="title" translatable="yes">Print Multiple Puzzles</property>
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index 844e9c3..c1c674b 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -361,7 +361,7 @@ public class Sudoku : Gtk.Application
             return;
         print_action.set_enabled (false);
         print_multiple_action.set_enabled (false);
-        var printer = new SudokuPrinter ({game.board.clone ()}, ref window);
+        var printer = new SudokuPrinter ({game.board.clone ()}, (Window) window);
         printer.print_sudoku ();
         print_action.set_enabled (true);
         print_multiple_action.set_enabled (true);
@@ -369,8 +369,14 @@ public class Sudoku : Gtk.Application
 
     private void print_multiple_cb ()
     {
+        print_action.set_enabled (false);
+        print_multiple_action.set_enabled (false);
         var printer = new GamePrinter (saver, ref window);
         printer.run_dialog ();
+        printer.game_printer_closed.connect ((p) => {
+            this.print_action.set_enabled (main_stack.get_visible_child_name () == "frame");
+            this.print_multiple_action.set_enabled (true);
+        });
     }
 
     private void help_cb ()
diff --git a/src/sudoku-printer.vala b/src/sudoku-printer.vala
index 3116fed..1cb8da5 100644
--- a/src/sudoku-printer.vala
+++ b/src/sudoku-printer.vala
@@ -6,7 +6,7 @@ using Gdk;
 public class SudokuPrinter : GLib.Object {
 
     private SudokuBoard[] boards;
-    private ApplicationWindow window;
+    private Gtk.Window window;
 
     private int margin;
     private int n_sudokus;
@@ -32,7 +32,7 @@ public class SudokuPrinter : GLib.Object {
         return Gtk.PrintOperationResult.ERROR;
     }
 
-    public SudokuPrinter (SudokuBoard[] boards, ref ApplicationWindow window)
+    public SudokuPrinter (SudokuBoard[] boards, Gtk.Window window)
     {
         this.boards = boards;
         this.window = window;
@@ -233,6 +233,8 @@ public class GamePrinter: GLib.Object
 
     private Spinner spinner;
 
+    public signal void game_printer_closed ();
+
     private const string DIFFICULTY_KEY_NAME = "print-multiple-sudoku-difficulty";
 
     public GamePrinter (SudokuSaver saver, ref ApplicationWindow window)
@@ -281,6 +283,7 @@ public class GamePrinter: GLib.Object
         if (response != Gtk.ResponseType.ACCEPT && response != Gtk.ResponseType.OK)
         {
             dialog.hide ();
+            game_printer_closed ();
             return;
         }
 
@@ -314,11 +317,12 @@ public class GamePrinter: GLib.Object
                 spinner.hide ();
                 dialog.sensitive = true;
 
-                SudokuPrinter printer = new SudokuPrinter (boards, ref window);
+                SudokuPrinter printer = new SudokuPrinter (boards, (Gtk.Window) dialog);
                 PrintOperationResult result = printer.print_sudoku ();
                 if (result == PrintOperationResult.APPLY)
                 {
                     dialog.hide ();
+                    game_printer_closed ();
                     foreach (SudokuBoard board in boards)
                         saver.add_game_to_finished (new SudokuGame (board));
                 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]