[longomatch] Enable Calendar in Win32 using a dialog instead of a popup Window



commit 113d6d4ff7e3a6618739f5e22e566533db529f11
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Mon Aug 24 21:33:53 2009 +0200

    Enable Calendar in Win32 using a dialog instead of a popup Window

 LongoMatch/Gui/CalendarPopup.cs                    |    6 +--
 LongoMatch/Gui/FileDescriptionWidget.cs            |   30 +++++---
 LongoMatch/Gui/Win32CalendarDialog.cs              |   51 ++++++++++++++
 LongoMatch/LongoMatch.mdp                          |    2 +
 LongoMatch/Makefile.am                             |    2 +
 LongoMatch/Makefile.in                             |    2 +
 .../LongoMatch.Gui.Dialog.Win32CalendarDialog.cs   |   71 ++++++++++++++++++++
 .../gtk-gui/LongoMatch.Gui.Popup.CalendarPopup.cs  |    3 +-
 LongoMatch/gtk-gui/objects.xml                     |   28 ++++----
 9 files changed, 164 insertions(+), 31 deletions(-)
---
diff --git a/LongoMatch/Gui/CalendarPopup.cs b/LongoMatch/Gui/CalendarPopup.cs
index 086bad7..a6ce302 100644
--- a/LongoMatch/Gui/CalendarPopup.cs
+++ b/LongoMatch/Gui/CalendarPopup.cs
@@ -47,11 +47,7 @@ namespace LongoMatch.Gui.Popup
 		protected virtual void OnFocusOutEvent (object o, Gtk.FocusOutEventArgs args)
 		{
 			this.Hide();
-		}
-		
-		
-
-	
+		}	
 
 		protected virtual void OnCalendar1DaySelectedDoubleClick (object sender, System.EventArgs e)
 		{
diff --git a/LongoMatch/Gui/FileDescriptionWidget.cs b/LongoMatch/Gui/FileDescriptionWidget.cs
index d2ca9f2..ce42e98 100644
--- a/LongoMatch/Gui/FileDescriptionWidget.cs
+++ b/LongoMatch/Gui/FileDescriptionWidget.cs
@@ -46,6 +46,7 @@ namespace LongoMatch.Gui.Component
 		private Project project;
 		private LongoMatch.Video.Utils.PreviewMediaFile mFile;
 		private CalendarPopup cp;
+		private Win32CalendarDialog win32CP;
 		private Sections actualSection;
 		private TeamTemplate actualVisitorTeam;
 		private TeamTemplate actualLocalTeam;
@@ -56,19 +57,17 @@ namespace LongoMatch.Gui.Component
 				
 			this.Build();
 			
-			cp = new CalendarPopup();			
-			cp.Hide();			
-			cp.DateSelectedEvent += new DateSelectedHandler(OnDateSelected);	
+			//HACK:The calendar dialog does not respond on win32
+			if (Environment.OSVersion.Platform != PlatformID.Win32NT){				
+				cp = new CalendarPopup();			
+				cp.Hide();			
+				cp.DateSelectedEvent += new DateSelectedHandler(OnDateSelected);
+			}
 			
 			FillSections();
 			FillTeamsTemplate();
 			
-			this.Use=UseType.NewFromFileProject;			
-						
-			if (Environment.OSVersion.Platform == PlatformID.Win32NT){
-				this.calendarbutton.Sensitive = false;
-				this.calendarbutton.Visible = false;	
-			}		
+			this.Use=UseType.NewFromFileProject;					
 		}
 		
 		public UseType Use{
@@ -335,8 +334,17 @@ namespace LongoMatch.Gui.Component
 
 		protected virtual void OnCalendarbuttonClicked (object sender, System.EventArgs e)
 		{
-			cp.TransientFor=(Gtk.Window)this.Toplevel;		
-			cp.Show();		
+			if (Environment.OSVersion.Platform == PlatformID.Win32NT){
+				win32CP = new Win32CalendarDialog();
+				win32CP.TransientFor = (Gtk.Window)this.Toplevel;
+				win32CP.Run();
+				Date = win32CP.getSelectedDate();
+				win32CP.Destroy();
+			}
+			else {
+				cp.TransientFor=(Gtk.Window)this.Toplevel;		
+				cp.Show();	
+			}
 		}
 
 		protected virtual void OnEditbuttonClicked (object sender, System.EventArgs e)
diff --git a/LongoMatch/Gui/Win32CalendarDialog.cs b/LongoMatch/Gui/Win32CalendarDialog.cs
new file mode 100644
index 0000000..c5af24e
--- /dev/null
+++ b/LongoMatch/Gui/Win32CalendarDialog.cs
@@ -0,0 +1,51 @@
+// 
+//  Copyright (C) 2009 Andoni Morales Alastruey
+// 
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+// 
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//  
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// 
+
+using System;
+using Gtk;
+
+namespace LongoMatch.Gui.Dialog
+{
+	
+	
+	public partial class Win32CalendarDialog : Gtk.Dialog
+	{
+		DateTime selectedDate;
+		
+		public Win32CalendarDialog()
+		{
+			this.Build();
+		}
+		
+		public DateTime getSelectedDate(){
+			return selectedDate;
+		}
+
+	
+		protected virtual void OnCalendar1DaySelectedDoubleClick (object sender, System.EventArgs e)
+		{
+			selectedDate = calendar1.Date;
+			this.Respond(ResponseType.Accept);			
+		}
+
+		protected virtual void OnCalendar1DaySelected (object sender, System.EventArgs e)
+		{
+			selectedDate = calendar1.Date;
+		}
+	}
+}
diff --git a/LongoMatch/LongoMatch.mdp b/LongoMatch/LongoMatch.mdp
index 7b53483..0abcc63 100644
--- a/LongoMatch/LongoMatch.mdp
+++ b/LongoMatch/LongoMatch.mdp
@@ -140,6 +140,8 @@
     <File name="Compat/0.0/Time/TimeNode.cs" subtype="Code" buildaction="Compile" />
     <File name="Compat/0.0/TemplatesMigrator.cs" subtype="Code" buildaction="Compile" />
     <File name="Compat/0.0/IO/SectionsReader.cs" subtype="Code" buildaction="Compile" />
+    <File name="gtk-gui/LongoMatch.Gui.Dialog.Win32CalendarDialog.cs" subtype="Code" buildaction="Compile" />
+    <File name="Gui/Win32CalendarDialog.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
diff --git a/LongoMatch/Makefile.am b/LongoMatch/Makefile.am
index e91271e..c70a92a 100644
--- a/LongoMatch/Makefile.am
+++ b/LongoMatch/Makefile.am
@@ -112,6 +112,7 @@ FILES = \
 	Gui/VideoEditionProperties.cs \
 	Gui/UpdateDialog.cs \
 	Gui/HotKeySelectorDialog.cs \
+	Gui/Win32CalendarDialog.cs\
 	Gui/WorkspaceChooser.cs \
 	DB/Project.cs \
 	DB/Sections.cs \
@@ -156,6 +157,7 @@ FILES = \
 	gtk-gui/LongoMatch.Gui.Dialog.WorkspaceChooser.cs \
 	gtk-gui/LongoMatch.Gui.Dialog.PlayersSelectionDialog.cs \
 	gtk-gui/LongoMatch.Gui.Dialog.EntryDialog.cs \
+	gtk-gui/LongoMatch.Gui.Dialog.Win32CalendarDialog.cs \
 	Playlist/IPlayList.cs \
 	Playlist/PlayList.cs \
 	Updates/Updater.cs \
diff --git a/LongoMatch/Makefile.in b/LongoMatch/Makefile.in
index 6df31ba..63d6440 100644
--- a/LongoMatch/Makefile.in
+++ b/LongoMatch/Makefile.in
@@ -294,6 +294,7 @@ FILES = \
 	Gui/VideoEditionProperties.cs \
 	Gui/UpdateDialog.cs \
 	Gui/HotKeySelectorDialog.cs \
+	Gui/Win32CalendarDialog.cs\
 	Gui/WorkspaceChooser.cs \
 	DB/Project.cs \
 	DB/Sections.cs \
@@ -338,6 +339,7 @@ FILES = \
 	gtk-gui/LongoMatch.Gui.Dialog.WorkspaceChooser.cs \
 	gtk-gui/LongoMatch.Gui.Dialog.PlayersSelectionDialog.cs \
 	gtk-gui/LongoMatch.Gui.Dialog.EntryDialog.cs \
+	gtk-gui/LongoMatch.Gui.Dialog.Win32CalendarDialog.cs \
 	Playlist/IPlayList.cs \
 	Playlist/PlayList.cs \
 	Updates/Updater.cs \
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.Win32CalendarDialog.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.Win32CalendarDialog.cs
new file mode 100644
index 0000000..ec78846
--- /dev/null
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.Win32CalendarDialog.cs
@@ -0,0 +1,71 @@
+// ------------------------------------------------------------------------------
+//  <autogenerated>
+//      This code was generated by a tool.
+//      
+// 
+//      Changes to this file may cause incorrect behavior and will be lost if 
+//      the code is regenerated.
+//  </autogenerated>
+// ------------------------------------------------------------------------------
+
+namespace LongoMatch.Gui.Dialog {
+    
+    
+    public partial class Win32CalendarDialog {
+        
+        private Gtk.Calendar calendar1;
+        
+        private Gtk.Button buttonOk;
+        
+        protected virtual void Build() {
+            Stetic.Gui.Initialize(this);
+            // Widget LongoMatch.Gui.Dialog.Win32CalendarDialog
+            this.Name = "LongoMatch.Gui.Dialog.Win32CalendarDialog";
+            this.Title = Mono.Unix.Catalog.GetString("Calendar");
+            this.Icon = Stetic.IconLoader.LoadIcon(this, "longomatch", Gtk.IconSize.Menu, 16);
+            this.WindowPosition = ((Gtk.WindowPosition)(4));
+            this.Gravity = ((Gdk.Gravity)(5));
+            this.SkipPagerHint = true;
+            this.SkipTaskbarHint = true;
+            this.HasSeparator = false;
+            // Internal child LongoMatch.Gui.Dialog.Win32CalendarDialog.VBox
+            Gtk.VBox w1 = this.VBox;
+            w1.Name = "dialog1_VBox";
+            w1.BorderWidth = ((uint)(2));
+            // Container child dialog1_VBox.Gtk.Box+BoxChild
+            this.calendar1 = new Gtk.Calendar();
+            this.calendar1.CanFocus = true;
+            this.calendar1.Name = "calendar1";
+            this.calendar1.DisplayOptions = ((Gtk.CalendarDisplayOptions)(35));
+            w1.Add(this.calendar1);
+            Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(w1[this.calendar1]));
+            w2.Position = 0;
+            // Internal child LongoMatch.Gui.Dialog.Win32CalendarDialog.ActionArea
+            Gtk.HButtonBox w3 = this.ActionArea;
+            w3.Name = "dialog1_ActionArea";
+            w3.Spacing = 6;
+            w3.BorderWidth = ((uint)(5));
+            w3.LayoutStyle = ((Gtk.ButtonBoxStyle)(4));
+            // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
+            this.buttonOk = new Gtk.Button();
+            this.buttonOk.CanDefault = true;
+            this.buttonOk.CanFocus = true;
+            this.buttonOk.Name = "buttonOk";
+            this.buttonOk.UseStock = true;
+            this.buttonOk.UseUnderline = true;
+            this.buttonOk.Label = "gtk-ok";
+            this.AddActionWidget(this.buttonOk, -5);
+            Gtk.ButtonBox.ButtonBoxChild w4 = ((Gtk.ButtonBox.ButtonBoxChild)(w3[this.buttonOk]));
+            w4.Expand = false;
+            w4.Fill = false;
+            if ((this.Child != null)) {
+                this.Child.ShowAll();
+            }
+            this.DefaultWidth = 217;
+            this.DefaultHeight = 204;
+            this.Show();
+            this.calendar1.DaySelectedDoubleClick += new System.EventHandler(this.OnCalendar1DaySelectedDoubleClick);
+            this.calendar1.DaySelected += new System.EventHandler(this.OnCalendar1DaySelected);
+        }
+    }
+}
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.Popup.CalendarPopup.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.Popup.CalendarPopup.cs
index 21c2869..bc732c6 100644
--- a/LongoMatch/gtk-gui/LongoMatch.Gui.Popup.CalendarPopup.cs
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.Popup.CalendarPopup.cs
@@ -38,8 +38,9 @@ namespace LongoMatch.Gui.Popup {
                 this.Child.ShowAll();
             }
             this.DefaultWidth = 281;
-            this.DefaultHeight = 260;
+            this.DefaultHeight = 154;
             this.Show();
+            this.FocusOutEvent += new Gtk.FocusOutEventHandler(this.OnFocusOutEvent);
             this.calendar1.DaySelectedDoubleClick += new System.EventHandler(this.OnCalendar1DaySelectedDoubleClick);
         }
     }
diff --git a/LongoMatch/gtk-gui/objects.xml b/LongoMatch/gtk-gui/objects.xml
index bff93d2..c163b01 100755
--- a/LongoMatch/gtk-gui/objects.xml
+++ b/LongoMatch/gtk-gui/objects.xml
@@ -131,20 +131,6 @@
     </itemgroups>
     <signals />
   </object>
-  <object type="LongoMatch.Gui.Component.FileDescriptionWidget" palette-category="LongoMatch" allow-children="false" base-type="Gtk.Bin">
-    <itemgroups>
-      <itemgroup label="FileDescriptionWidget Properties">
-        <property name="LocalName" />
-        <property name="VisitorName" />
-        <property name="Season" />
-        <property name="Competition" />
-        <property name="LocalGoals" />
-        <property name="VisitorGoals" />
-        <property name="Date" />
-      </itemgroup>
-    </itemgroups>
-    <signals />
-  </object>
   <object type="LongoMatch.Gui.Component.PlayerProperties" palette-category="General" allow-children="false" base-type="Gtk.Bin">
     <itemgroups />
     <signals />
@@ -173,4 +159,18 @@
       </itemgroup>
     </signals>
   </object>
+  <object type="LongoMatch.Gui.Component.FileDescriptionWidget" palette-category="LongoMatch" allow-children="false" base-type="Gtk.Bin">
+    <itemgroups>
+      <itemgroup label="FileDescriptionWidget Properties">
+        <property name="LocalName" />
+        <property name="VisitorName" />
+        <property name="Season" />
+        <property name="Competition" />
+        <property name="LocalGoals" />
+        <property name="VisitorGoals" />
+        <property name="Date" />
+      </itemgroup>
+    </itemgroups>
+    <signals />
+  </object>
 </objects>
\ No newline at end of file



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