[gnome-games/sudoku-vala] Bugfix in number_picker and note_editor



commit cc6e6d9eff9f00f814caeb0da21e73842eb8e982
Author: PioneerAxon <arth svnit gmail com>
Date:   Mon Mar 26 03:24:27 2012 +0530

    Bugfix in number_picker and note_editor
    
    FIXED: note_editor not getting keyboard focus on open.
    FIXED: number_picker not getting keyboard focus on open.

 gnome-sudoku/src/sudoku-game.vala |    2 +-
 gnome-sudoku/src/sudoku-view.vala |   30 +++++++++++++++++++-----------
 2 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/gnome-sudoku/src/sudoku-game.vala b/gnome-sudoku/src/sudoku-game.vala
index 26fb416..c13e0f8 100644
--- a/gnome-sudoku/src/sudoku-game.vala
+++ b/gnome-sudoku/src/sudoku-game.vala
@@ -9,7 +9,7 @@ public class SudokuBoard
     private bool[,,] possible_in_block;         /* if specific value is possible in specific block */
     private int block_row;                      /* size of sub-part ( block ) in board */
     private int block_col;                      /* size of sub-part ( block ) in board */
-    public bool broken;                        /* true if forced inserted */
+    public bool broken;                         /* true if forced inserted */
 
     public signal void value_changed (int row, int col, int old_value, int new_value);
     public signal void value_changing (int row, int col, int old_value, int new_value);
diff --git a/gnome-sudoku/src/sudoku-view.vala b/gnome-sudoku/src/sudoku-view.vala
index c01402f..f166d4b 100644
--- a/gnome-sudoku/src/sudoku-view.vala
+++ b/gnome-sudoku/src/sudoku-view.vala
@@ -129,13 +129,21 @@ private class SudokuCellView : Gtk.DrawingArea
         return true;
     }
 
+    private bool number_pick { get; set; default = false; }
+
     private void show_number_picker ()
     {
         if (popup != null)
             return;
         if (is_fixed)
             return;
-        popup = new Gtk.Window (Gtk.WindowType.POPUP);
+        number_pick = true;
+        popup = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
+        popup.decorated = false;
+        popup.resizable = false;
+        popup.skip_taskbar_hint = true;
+        popup.skip_pager_hint = true;
+        popup.set_type_hint (Gdk.WindowTypeHint.DIALOG);
 
         var table = new Gtk.Table (3, 3, false);
         for (var col = 0; col < 3; col++)
@@ -146,10 +154,6 @@ private class SudokuCellView : Gtk.DrawingArea
 
                 var button = new Gtk.Button ();
                 table.attach_defaults (button, col, col+1, row, row+1);
-                button.show ();
-
-                /* Make buttons the same size as cells */
-                button.set_size_request (get_allocated_width (), get_allocated_height ());
 
                 var label = new Gtk.Label ("%d".printf (n));
                 label.use_markup = true;
@@ -163,13 +167,19 @@ private class SudokuCellView : Gtk.DrawingArea
 
                 if (n == 5)
                     button.grab_focus ();
+
+                button.show ();
+
+                /* Make buttons the same size as cells */
+                button.set_size_request (get_allocated_width (), get_allocated_height ());
+
             }
         }
         table.show ();
         popup.add (table);
-
         int x, y, width, height;
         get_window ().get_origin (out x, out y);
+        popup.show ();
         popup.get_size (out width, out height);
 
         var screen = popup.get_screen ();
@@ -184,12 +194,11 @@ private class SudokuCellView : Gtk.DrawingArea
         else if (popup_y + height > screen.get_height ())
             popup_y = screen.get_height () - height;
         popup.move (popup_x, popup_y);
-
-        popup.show ();
     }
 
     private void hide_popup ()
     {
+        number_pick = false;
         if (popup == null)
             return;
         popup.destroy ();
@@ -211,7 +220,7 @@ private class SudokuCellView : Gtk.DrawingArea
         popup.resizable = false;
         popup.skip_taskbar_hint = true;
         popup.skip_pager_hint = true;
-        popup.set_type_hint (Gdk.WindowTypeHint.POPUP_MENU);
+        popup.set_type_hint (Gdk.WindowTypeHint.DIALOG);
         popup.set_size_request (get_allocated_width (), -1);
 
         var entry = new Gtk.Entry ();
@@ -235,7 +244,6 @@ private class SudokuCellView : Gtk.DrawingArea
         popup.show_all ();
         popup.get_size (null, out height);
         popup.move (x, y + top * (get_allocated_height () - height));
-        /* FIXME: entry doesn't get keyboard focus when note editor is shown and does not hide if focus is lost before clicking in entry. */
     }
 
     private void hide_note_editor (Gtk.Entry entry, int top)
@@ -250,7 +258,7 @@ private class SudokuCellView : Gtk.DrawingArea
 
     private bool focus_out_cb (Gtk.Widget widget, Gdk.EventFocus event)
     {
-        if (editing_notes) return false;
+        if (editing_notes || number_pick) return false;
         if (popup != null)
             hide_popup ();
         return false;



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