[gnome-games] mahjongg: Use pause overlay from gnotravex



commit 41c1cd7308bb0b1ff9b5572e7bb8c06a75785380
Author: Robert Ancell <robert ancell canonical com>
Date:   Sat Nov 19 12:46:32 2011 +1100

    mahjongg: Use pause overlay from gnotravex

 mahjongg/src/game-view.vala |   17 +++++++++++++++++
 mahjongg/src/mahjongg.vala  |   13 +++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/mahjongg/src/game-view.vala b/mahjongg/src/game-view.vala
index cea2be2..66c90fb 100644
--- a/mahjongg/src/game-view.vala
+++ b/mahjongg/src/game-view.vala
@@ -112,6 +112,23 @@ public class GameView : Gtk.DrawingArea
             cr.rectangle (x, y, image_width, image_height);
             cr.fill ();
         }
+
+        /* Draw pause overlay */
+        if (paused)
+        {
+            cr.set_source_rgba (0, 0, 0, 0.75);
+            cr.paint ();
+
+            cr.select_font_face ("Sans", Cairo.FontSlant.NORMAL, Cairo.FontWeight.BOLD);
+            cr.set_font_size (get_allocated_width () * 0.125);
+
+            var text = _("Paused");
+            Cairo.TextExtents extents;
+            cr.text_extents (text, out extents);
+            cr.move_to ((get_allocated_width () - extents.width) / 2.0, (get_allocated_height () + extents.height) / 2.0);
+            cr.set_source_rgb (1, 1, 1);
+            cr.show_text (text);
+        }
     }
 
     private void update_dimensions ()
diff --git a/mahjongg/src/mahjongg.vala b/mahjongg/src/mahjongg.vala
index 9c29ffb..a5afc3d 100644
--- a/mahjongg/src/mahjongg.vala
+++ b/mahjongg/src/mahjongg.vala
@@ -87,6 +87,7 @@ public class Mahjongg
         window.delete_event.connect (window_delete_event_cb);
 
         game_view = new GameView ();
+        game_view.button_press_event.connect (view_button_press_event);        
         game_view.set_size_request (320, 200);
 
         toolbar = (Gtk.Toolbar) ui_manager.get_widget ("/Toolbar");
@@ -211,6 +212,18 @@ public class Mahjongg
         }
     }
 
+    private bool view_button_press_event (Gtk.Widget widget, Gdk.EventButton event)
+    {
+        /* Cancel pause on click */
+        if (pause_action.get_is_paused ())
+        {
+            pause_action.set_is_paused (false);
+            return true;
+        }
+
+        return false;
+    }
+
     private void show_toolbar_cb (Gtk.Action action)
     {
         var toggle_action = (Gtk.ToggleAction) action;



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