gbrainy r525 - trunk/src



Author: jmas
Date: Sat Apr  4 14:19:03 2009
New Revision: 525
URL: http://svn.gnome.org/viewvc/gbrainy?rev=525&view=rev

Log:
2009-04-04 Jordi Mas <jmas softcatala org>

	* gbrainy.glade:Fullscreen mode support
	* gbrainy.cs: Fullscreen mode support
	* GameDrawingArea.cs: Fullscreen mode support



Modified:
   trunk/src/ChangeLog
   trunk/src/GameDrawingArea.cs
   trunk/src/gbrainy.cs
   trunk/src/gbrainy.glade

Modified: trunk/src/GameDrawingArea.cs
==============================================================================
--- trunk/src/GameDrawingArea.cs	(original)
+++ trunk/src/GameDrawingArea.cs	Sat Apr  4 14:19:03 2009
@@ -40,16 +40,19 @@
 	const int tips_shown = 4;
 	CountDown countdown;
 	bool rtl;
-	public Game puzzle;
+	bool margins;
 	Modes mode;
+	gbrainy application;
+	public Game puzzle;
 
-	public GameDrawingArea ()
+	public GameDrawingArea (gbrainy application)
 	{
 		mode = Modes.Welcome;
 		puzzle = null;
 		session = null;
 		countdown = null;
 		rtl = Direction == Gtk.TextDirection.Rtl;
+		this.application = application;
 	}
 
 	public GameSession GameSession {
@@ -70,6 +73,10 @@
 		}
 	}
 
+	public bool Margins {
+		set { margins = value; }
+	}
+
 	static void DrawBand (CairoContextEx gr, double x, double y)
 	{
 		gr.Save ();
@@ -256,7 +263,6 @@
 		double x = 0, y = 0;
 		args.Window.GetSize (out w, out h);
 
-		// TODO: This created and destroyed in every expose event
 		Cairo.Context cc = Gdk.CairoHelper.Create (args.Window);
 		CairoContextEx cr = new CairoContextEx (cc.Handle, this);
 
@@ -264,13 +270,16 @@
 		// For example, squares are squares. This also makes sure that proportions are kept when resizing
 		nh = nw = Math.Min (w, h);
 
-		if (nw < w) {
+		if (nw < w)
 			x = (w - nw) / 2;
-		}
 
-		if (nh < h) {
+		if (nh < h)
 			y = (h - nh) / 2;
-		}
+
+		if (margins)
+			application.SetMargin ((int) x);
+		else
+			application.SetMargin (0);
 
 		cr.Translate (x, y);
 		switch (mode) {

Modified: trunk/src/gbrainy.cs
==============================================================================
--- trunk/src/gbrainy.cs	(original)
+++ trunk/src/gbrainy.cs	Sat Apr  4 14:19:03 2009
@@ -60,7 +60,8 @@
 	Gtk.TextBuffer question_buffer;
 	Gtk.TextBuffer solution_buffer;
 	TextTag tag_green;
-	bool low_res = false;
+	bool low_res;
+	bool full_screen;
 	
 	public static PlayerHistory history = null;
 	public static Preferences preferences = null;
@@ -144,7 +145,7 @@
 			preferences = new Preferences ();
 
 		session.GameManager.Difficulty = (Game.Difficulty) preferences.GetIntValue (Preferences.DifficultyKey);
-		drawing_area = new GameDrawingArea ();
+		drawing_area = new GameDrawingArea (this);
 		GameSensitiveUI ();
 
 		// For low resolutions, hide the toolbar and made the drawing area smaller
@@ -300,6 +301,14 @@
 		drawing_area.QueueDraw ();
 	}
 
+	public void SetMargin (int margin)
+	{
+		question_textview.RightMargin = margin;
+		solution_textview.RightMargin = margin;
+		question_textview.LeftMargin = margin;
+		solution_textview.LeftMargin = margin;
+	}
+
 	void GameSensitiveUI () 
 	{
 		//Toolbar buttons and menu items sensitive when there is or not a game
@@ -583,6 +592,20 @@
 		stock.Add (stockid, iconset);		
 	}
 
+	void OnFullscreen (object sender, EventArgs args)
+	{
+		if (full_screen == false) {
+			drawing_area.Margins = true;
+			app_window.Fullscreen ();
+		}
+		else {
+			drawing_area.Margins = false;
+			app_window.Unfullscreen ();
+		}
+
+		full_screen = !full_screen;
+	}
+
 	[DllImport ("libc")] // Linux
 	private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5);
 
@@ -617,4 +640,3 @@
 		gui.Run ();	
 	}
 }
-

Modified: trunk/src/gbrainy.glade
==============================================================================
--- trunk/src/gbrainy.glade	(original)
+++ trunk/src/gbrainy.glade	Sat Apr  4 14:19:03 2009
@@ -167,6 +167,28 @@
 		      <signal name="activate" handler="OnHistory" last_modification_time="Tue, 06 May 2008 20:52:02 GMT"/>
 		    </widget>
 		  </child>
+
+		  <child>
+		    <widget class="GtkImageMenuItem" id="fullscreen">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">_FullScreen</property>
+		      <property name="use_underline">True</property>
+		      <signal name="activate" handler="OnFullscreen" last_modification_time="Sat, 04 Apr 2009 08:25:52 GMT"/>
+		      <accelerator key="F11" modifiers="0" signal="activate"/>
+
+		      <child internal-child="image">
+			<widget class="GtkImage" id="image7">
+			  <property name="visible">True</property>
+			  <property name="stock">gtk-fullscreen</property>
+			  <property name="icon_size">1</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xpad">0</property>
+			  <property name="ypad">0</property>
+			</widget>
+		      </child>
+		    </widget>
+		  </child>
 		</widget>
 	      </child>
 	    </widget>



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