[longomatch] Simplify date picking adding a new API in the IGUIToolkit



commit 199fc06ca3be013d3b17e6432a8ad369d64ff9ea
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sat Mar 22 00:35:33 2014 +0100

    Simplify date picking adding a new API in the IGUIToolkit

 LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs      |    3 ++
 LongoMatch.GUI/Gui/Component/PlayerProperties.cs   |   10 -----
 LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs |   25 +------------
 .../{Win32CalendarDialog.cs => CalendarDialog.cs}  |   17 ++++++---
 LongoMatch.GUI/Gui/GUIToolkit.cs                   |    9 +++++
 LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs        |   21 +----------
 LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs   |   10 +++++
 LongoMatch.GUI/LongoMatch.GUI.mdp                  |    6 +--
 ....cs => LongoMatch.Gui.Dialog.CalendarDialog.cs} |   10 +++---
 .../gtk-gui/LongoMatch.Gui.Popup.CalendarPopup.cs  |   39 --------------------
 LongoMatch.GUI/gtk-gui/gui.stetic                  |   24 +------------
 11 files changed, 44 insertions(+), 130 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
index ab7a5ac..bab74ae 100644
--- a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
@@ -82,6 +82,9 @@ namespace LongoMatch.Interfaces.GUI
                void DrawingTool(Image pixbuf, Play play, int stopTime);
                
                string RemuxFile (string filePath, string outputFile, VideoMuxerType muxer);
+               
+               DateTime SelectDate (DateTime date, object widget);
+               
        }
 }
 
diff --git a/LongoMatch.GUI/Gui/Component/PlayerProperties.cs 
b/LongoMatch.GUI/Gui/Component/PlayerProperties.cs
index 970338d..108b522 100644
--- a/LongoMatch.GUI/Gui/Component/PlayerProperties.cs
+++ b/LongoMatch.GUI/Gui/Component/PlayerProperties.cs
@@ -36,20 +36,10 @@ namespace LongoMatch.Gui.Component
                private const int THUMBNAIL_MAX_HEIGHT = 50;
 
                private Player player;
-               private CalendarPopup cp;
 
                public PlayerProperties()
                {
                        this.Build();
-                       //HACK:The calendar dialog does not respond on win32
-                       if(Environment.OSVersion.Platform != PlatformID.Win32NT) {
-                               cp = new CalendarPopup();
-                               cp.Hide();
-                               cp.DateSelectedEvent += delegate(DateTime selectedDate) {
-                                       Player.Birthday = selectedDate;
-                                       bdaylabel.Text = selectedDate.ToShortDateString();
-                               };
-                       }
                }
 
                public Player Player {
diff --git a/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs 
b/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
index d2d81c9..ef8fba8 100644
--- a/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
+++ b/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
@@ -47,8 +47,6 @@ namespace LongoMatch.Gui.Component
                List<Player> selectedPlayers;
                TreeIter loadedPlayerIter;
                TeamTemplate template;
-               CalendarPopup cp;
-               Win32CalendarDialog win32CP;
                bool edited;
                
                public TeamTemplateEditor ()
@@ -85,14 +83,6 @@ namespace LongoMatch.Gui.Component
                        nationalityentry.Changed += HandleEntryChanged;
                        mailentry.Changed += HandleEntryChanged;
                        
-                       if(Environment.OSVersion.Platform != PlatformID.Win32NT) {
-                               cp = new CalendarPopup();
-                               cp.Hide();
-                               cp.DateSelectedEvent += (selectedDate) => {
-                                       bdaylabel.Text = selectedDate.ToShortDateString();
-                                       edited = true;
-                               };
-                       }
                        datebutton.Clicked += HandleCalendarbuttonClicked; 
                        
                        Edited = false;
@@ -292,20 +282,9 @@ namespace LongoMatch.Gui.Component
 
                void HandleCalendarbuttonClicked(object sender, System.EventArgs e)
                {
-                       if(Environment.OSVersion.Platform == PlatformID.Win32NT) {
-                               win32CP = new Win32CalendarDialog();
-                               win32CP.TransientFor = (Gtk.Window)this.Toplevel;
-                               win32CP.Run();
-                               bdaylabel.Text = win32CP.getSelectedDate().ToShortDateString();
-                               Edited = true;
-                               win32CP.Destroy();
-                       }
-                       else {
-                               cp.TransientFor=(Gtk.Window)this.Toplevel;
-                               cp.Show();
-                       }
+                       loadedPlayer.Birthday = Config.GUIToolkit.SelectDate (loadedPlayer.Birthday, this);
+                       bdaylabel.Text = loadedPlayer.Birthday.ToShortDateString ();
                }
-
        }
 }
 
diff --git a/LongoMatch.GUI/Gui/Dialog/Win32CalendarDialog.cs b/LongoMatch.GUI/Gui/Dialog/CalendarDialog.cs
similarity index 81%
rename from LongoMatch.GUI/Gui/Dialog/Win32CalendarDialog.cs
rename to LongoMatch.GUI/Gui/Dialog/CalendarDialog.cs
index 017d66b..a690fd9 100644
--- a/LongoMatch.GUI/Gui/Dialog/Win32CalendarDialog.cs
+++ b/LongoMatch.GUI/Gui/Dialog/CalendarDialog.cs
@@ -22,21 +22,26 @@ using Gtk;
 namespace LongoMatch.Gui.Dialog
 {
 
-
-       public partial class Win32CalendarDialog : Gtk.Dialog
+       public partial class CalendarDialog : Gtk.Dialog
        {
                DateTime selectedDate;
 
-               public Win32CalendarDialog()
+               public CalendarDialog (DateTime date)
                {
                        this.Build();
+                       SkipPagerHint = true;
+                       SkipTaskbarHint = true;
+                       Decorated = false;
+                       Modal = true;
+                       calendar1.Date = date;
                }
 
-               public DateTime getSelectedDate() {
-                       return selectedDate;
+               public DateTime Date {
+                       get {
+                               return selectedDate;
+                       }
                }
 
-
                protected virtual void OnCalendar1DaySelectedDoubleClick(object sender, System.EventArgs e)
                {
                        selectedDate = calendar1.Date;
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
index 7b6cfba..3fe174f 100644
--- a/LongoMatch.GUI/Gui/GUIToolkit.cs
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -326,6 +326,15 @@ namespace LongoMatch.Gui
                        mainWindow.CloseProject ();
                }
                
+               public DateTime SelectDate (DateTime date, object widget) {
+                       CalendarDialog dialog = new CalendarDialog (date);
+                       dialog.TransientFor = (widget as Widget).Toplevel as Gtk.Window;
+                       dialog.Run();
+                       date = dialog.Date;
+                       dialog.Destroy ();
+                       return date;
+               }
+               
                public void Quit () {
                        Log.Information ("Quit application");
                        Gtk.Application.Quit ();
diff --git a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
index d2994af..d947105 100644
--- a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
@@ -52,8 +52,6 @@ namespace LongoMatch.Gui.Panel
                ProjectType projectType;
                List<Device> videoDevices;
                ListStore videoStandardList, encProfileList, qualList;
-               CalendarPopup cp;
-               Win32CalendarDialog win32CP;
                MediaFile mediaFile;
                IMultimediaToolkit mtoolkit;
                IGUIToolkit gtoolkit;
@@ -94,13 +92,6 @@ namespace LongoMatch.Gui.Panel
                }
                
                void ConnectSignals () {
-                       if(Environment.OSVersion.Platform != PlatformID.Win32NT) {
-                               cp = new CalendarPopup();
-                               cp.Hide();
-                               cp.DateSelectedEvent += (selectedDate) => {
-                                       dateEntry.Text = selectedDate.ToShortDateString();};
-                       }
-                       
                        calendarbutton.Clicked += HandleCalendarbuttonClicked; 
                        openbutton.Clicked += HandleOpenbuttonClicked;
                        savebutton.Clicked += HandleSavebuttonClicked;
@@ -187,17 +178,7 @@ namespace LongoMatch.Gui.Panel
 
                void HandleCalendarbuttonClicked(object sender, System.EventArgs e)
                {
-                       if(Environment.OSVersion.Platform == PlatformID.Win32NT) {
-                               win32CP = new Win32CalendarDialog();
-                               win32CP.TransientFor = (Gtk.Window)this.Toplevel;
-                               win32CP.Run();
-                               dateEntry.Text = win32CP.getSelectedDate().ToShortDateString();
-                               win32CP.Destroy();
-                       }
-                       else {
-                               cp.TransientFor=(Gtk.Window)this.Toplevel;
-                               cp.Show();
-                       }
+                       dateEntry.Text = Config.GUIToolkit.SelectDate (project.Description.MatchDate, 
this).ToShortDateString ();
                }
 
                void HandleSavebuttonClicked(object sender, System.EventArgs e)
diff --git a/LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs 
b/LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs
index c762264..f3b48ef 100644
--- a/LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs
@@ -61,6 +61,7 @@ namespace LongoMatch.Gui.Panel
                        savebutton.Clicked += HandleSaveClicked;
                        exportbutton.Clicked += HandleExportClicked;
                        deletebutton.Clicked += HandleDeleteClicked;
+                       calendarbutton.Clicked += HandleCalendarClicked;
                        notebook1.Page = 0;
                }
 
@@ -167,6 +168,15 @@ namespace LongoMatch.Gui.Panel
                        }                       
                }
 
+               void HandleCalendarClicked (object sender, EventArgs e)
+               {
+                       DateTime date;
+                       
+                       date = gkit.SelectDate (loadedProject.Description.MatchDate, this);
+                       loadedProject.Description.MatchDate = date;
+                       datelabel.Text = date.ToShortDateString ();
+               }
+
                void HandleDeleteClicked (object sender, EventArgs e)
                {
                        List<ProjectDescription> deletedProjects;
diff --git a/LongoMatch.GUI/LongoMatch.GUI.mdp b/LongoMatch.GUI/LongoMatch.GUI.mdp
index 443b803..0f371c0 100644
--- a/LongoMatch.GUI/LongoMatch.GUI.mdp
+++ b/LongoMatch.GUI/LongoMatch.GUI.mdp
@@ -34,9 +34,8 @@
     <File subtype="Code" buildaction="Compile" name="Gui/TreeView/PlaysTreeView.cs" />
     <File subtype="Code" buildaction="Compile" name="Gui/Dialog/SnapshotsDialog.cs" />
     <File subtype="Code" buildaction="Compile" name="Gui/Dialog/UpdateDialog.cs" />
-    <File subtype="Code" buildaction="Compile" name="Gui/Dialog/Win32CalendarDialog.cs" />
+    <File subtype="Code" buildaction="Compile" name="Gui/Dialog/CalendarDialog.cs" />
     <File subtype="Directory" buildaction="Compile" name="Gui/Popup" />
-    <File subtype="Code" buildaction="Compile" name="Gui/Popup/CalendarPopup.cs" />
     <File subtype="Code" buildaction="Compile" name="Gui/Component/PlayersListTreeWidget.cs" />
     <File subtype="Code" buildaction="Compile" name="Gui/Component/PlayListWidget.cs" />
     <File subtype="Code" buildaction="Compile" name="Gui/Component/ProjectListWidget.cs" />
@@ -57,7 +56,6 @@
     <File subtype="Code" buildaction="Compile" name="gtk-gui/generated.cs" />
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Component.ProjectListWidget.cs" 
/>
     <File subtype="Code" buildaction="Compile" 
name="gtk-gui/LongoMatch.Gui.Component.PlaysListTreeWidget.cs" />
-    <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Popup.CalendarPopup.cs" />
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Component.ButtonsWidget.cs" />
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.MainWindow.cs" />
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Component.CategoryProperties.cs" 
/>
@@ -71,7 +69,6 @@
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Dialog.HotKeySelectorDialog.cs" 
/>
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Component.PlayerProperties.cs" />
     <File subtype="Code" buildaction="Compile" 
name="gtk-gui/LongoMatch.Gui.Component.PlayersListTreeWidget.cs" />
-    <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Dialog.Win32CalendarDialog.cs" />
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Popup.TransparentDrawingArea.cs" 
/>
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Component.DrawingToolBox.cs" />
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Dialog.EditCategoryDialog.cs" />
@@ -203,6 +200,7 @@
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Panel.ProjectsManagerPanel.cs" />
     <File subtype="Code" buildaction="Compile" name="Gui/Panel/SportsTemplatesPanel.cs" />
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Panel.SportsTemplatesPanel.cs" />
+    <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Dialog.CalendarDialog.cs" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="atk-sharp, Version=2.12.0.0, Culture=neutral, 
PublicKeyToken=35e10195dab3c99f" />
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.Win32CalendarDialog.cs 
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.CalendarDialog.cs
similarity index 87%
rename from LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.Win32CalendarDialog.cs
rename to LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.CalendarDialog.cs
index 78e6620..51f064a 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.Win32CalendarDialog.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.CalendarDialog.cs
@@ -2,7 +2,7 @@
 // This file has been generated by the GUI designer. Do not modify.
 namespace LongoMatch.Gui.Dialog
 {
-       public partial class Win32CalendarDialog
+       public partial class CalendarDialog
        {
                private global::Gtk.Calendar calendar1;
                private global::Gtk.Button buttonOk;
@@ -10,15 +10,15 @@ namespace LongoMatch.Gui.Dialog
                protected virtual void Build ()
                {
                        global::Stetic.Gui.Initialize (this);
-                       // Widget LongoMatch.Gui.Dialog.Win32CalendarDialog
-                       this.Name = "LongoMatch.Gui.Dialog.Win32CalendarDialog";
+                       // Widget LongoMatch.Gui.Dialog.CalendarDialog
+                       this.Name = "LongoMatch.Gui.Dialog.CalendarDialog";
                        this.Title = global::Mono.Unix.Catalog.GetString ("Calendar");
                        this.Icon = global::Stetic.IconLoader.LoadIcon (this, "longomatch", 
global::Gtk.IconSize.Menu);
                        this.WindowPosition = ((global::Gtk.WindowPosition)(4));
                        this.Gravity = ((global::Gdk.Gravity)(5));
                        this.SkipPagerHint = true;
                        this.SkipTaskbarHint = true;
-                       // Internal child LongoMatch.Gui.Dialog.Win32CalendarDialog.VBox
+                       // Internal child LongoMatch.Gui.Dialog.CalendarDialog.VBox
                        global::Gtk.VBox w1 = this.VBox;
                        w1.Name = "dialog1_VBox";
                        w1.BorderWidth = ((uint)(2));
@@ -30,7 +30,7 @@ namespace LongoMatch.Gui.Dialog
                        w1.Add (this.calendar1);
                        global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(w1 [this.calendar1]));
                        w2.Position = 0;
-                       // Internal child LongoMatch.Gui.Dialog.Win32CalendarDialog.ActionArea
+                       // Internal child LongoMatch.Gui.Dialog.CalendarDialog.ActionArea
                        global::Gtk.HButtonBox w3 = this.ActionArea;
                        w3.Name = "dialog1_ActionArea";
                        w3.Spacing = 6;
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index ee8303d..a2ad3de 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -95,27 +95,6 @@
       </widget>
     </child>
   </widget>
-  <widget class="Gtk.Window" id="LongoMatch.Gui.Popup.CalendarPopup" design-size="281 214">
-    <property name="MemberName" />
-    <property name="Title" translatable="yes" />
-    <property name="WindowPosition">Mouse</property>
-    <property name="Modal">True</property>
-    <property name="Resizable">False</property>
-    <property name="AllowGrow">False</property>
-    <property name="Decorated">False</property>
-    <property name="Gravity">Center</property>
-    <property name="SkipPagerHint">True</property>
-    <property name="SkipTaskbarHint">True</property>
-    <signal name="FocusOutEvent" handler="OnFocusOutEvent" />
-    <child>
-      <widget class="Gtk.Calendar" id="calendar1">
-        <property name="MemberName" />
-        <property name="CanFocus">True</property>
-        <property name="DisplayOptions">ShowHeading, ShowDayNames</property>
-        <signal name="DaySelectedDoubleClick" handler="OnCalendar1DaySelectedDoubleClick" />
-      </widget>
-    </child>
-  </widget>
   <widget class="Gtk.Bin" id="LongoMatch.Gui.Component.ButtonsWidget" design-size="532 149">
     <property name="MemberName" />
     <child>
@@ -3002,7 +2981,7 @@ No</property>
       </widget>
     </child>
   </widget>
-  <widget class="Gtk.Dialog" id="LongoMatch.Gui.Dialog.Win32CalendarDialog" design-size="259 258">
+  <widget class="Gtk.Dialog" id="LongoMatch.Gui.Dialog.CalendarDialog" design-size="259 258">
     <property name="MemberName" />
     <property name="Title" translatable="yes">Calendar</property>
     <property name="Icon">stock:longomatch Menu</property>
@@ -7894,7 +7873,6 @@ Defining &lt;b&gt; Game Units &lt;/b&gt; will help you during the analysis to in
                             <property name="MemberName" />
                             <property name="CanFocus">True</property>
                             <property name="Label" translatable="yes">New project using a video 
file</property>
-                            <property name="Active">True</property>
                             <property name="DrawIndicator">True</property>
                             <property name="HasLabel">True</property>
                             <property name="UseUnderline">True</property>


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