[chronojump] Snapshot works in persons (need small fixes)



commit 9f41dfa6db90d3842f3a9dca773f7d075fbcb255
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Feb 7 14:29:59 2011 +0100

    Snapshot works in persons (need small fixes)

 CesarPlayer/Gui/CapturerBin.cs |    2 +-
 glade/chronojump.glade         |   58 +++++++++++++++++++++++++++++++++++++--
 src/constants.cs               |    2 +
 src/gui/chronojump.cs          |   27 +-----------------
 src/gui/dialogImageTest.cs     |    9 +++++-
 src/gui/person.cs              |   56 +++++++++++++++++++++++++++++++++++++-
 src/util.cs                    |   44 ++++++++++++++++--------------
 7 files changed, 145 insertions(+), 53 deletions(-)
---
diff --git a/CesarPlayer/Gui/CapturerBin.cs b/CesarPlayer/Gui/CapturerBin.cs
index d1916f7..a2d6ecc 100644
--- a/CesarPlayer/Gui/CapturerBin.cs
+++ b/CesarPlayer/Gui/CapturerBin.cs
@@ -46,7 +46,7 @@ namespace LongoMatch.Gui
 		private CapturerType capturerType;
 		private bool captureStarted;
 		private bool capturing;
-		private const int THUMBNAIL_MAX_WIDTH = 200;		
+		private const int THUMBNAIL_MAX_WIDTH = 150;		
 		
 		ICapturer capturer;
 		
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index f942b9e..1968ffa 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -46,6 +46,7 @@
                         <child>
                           <widget class="GtkHBox" id="hbox5">
                             <property name="visible">True</property>
+                            <property name="spacing">8</property>
                             <child>
                               <widget class="GtkTable" id="table2">
                                 <property name="visible">True</property>
@@ -240,12 +241,63 @@
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkImage" id="image-photo-mini">
+                              <widget class="GtkVBox" id="vbox3">
                                 <property name="visible">True</property>
-                                <property name="stock">gtk-missing-image</property>
+                                <property name="spacing">4</property>
+                                <child>
+                                  <widget class="GtkImage" id="image_photo_mini">
+                                    <property name="visible">True</property>
+                                    <property name="stock">gtk-missing-image</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkHBox" id="hbox6">
+                                    <property name="visible">True</property>
+                                    <property name="spacing">4</property>
+                                    <child>
+                                      <widget class="GtkButton" id="button_zoom">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="receives_default">True</property>
+                                        <property name="has_tooltip">True</property>
+                                        <signal name="clicked" handler="on_button_zoom_clicked"/>
+                                        <accelerator key="z" signal="clicked"/>
+                                        <child>
+                                          <widget class="GtkImage" id="image_zoom">
+                                            <property name="visible">True</property>
+                                          </widget>
+                                        </child>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <widget class="GtkButton" id="button_take_photo">
+                                        <property name="label" translatable="yes">Take snapshot</property>
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="receives_default">True</property>
+                                        <signal name="clicked" handler="on_button_take_photo_clicked"/>
+                                        <accelerator key="z" signal="clicked"/>
+                                      </widget>
+                                      <packing>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
                               </widget>
                               <packing>
-                                <property name="pack_type">end</property>
                                 <property name="position">1</property>
                               </packing>
                             </child>
diff --git a/src/constants.cs b/src/constants.cs
index d81f3c3..d625102 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -475,5 +475,7 @@ public class Constants
 	}
 	public const string ExtensionVideo = ".avi";
 	public const string ExtensionPhoto = ".jpg";
+	public const string SmallPhotoDir = "small";
+	public static string MultimediaFileNoExists = Catalog.GetString("Sorry, this multimedia file does not exists.");
 	
 }
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 582e4b4..4d8ca51 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2154,9 +2154,8 @@ public class ChronoJumpWindow
 		CapturerBin capturer = new CapturerBin();
 		CapturePropertiesStruct s = new CapturePropertiesStruct();
 
-		Util.CreateMultimediaSessionDirIfNeeded(Constants.MultimediaItems.VIDEO, 111);
-		s.OutputFile = Util.GetMultimediaFileName(
-			Constants.MultimediaItems.VIDEO,
+		Util.CreateVideoSessionDirIfNeeded(111);
+		s.OutputFile = Util.GetVideoFileName(
 			111, //sessionID
 			Constants.TestTypes.JUMP,
 			123 //jump uniqueID
@@ -2179,30 +2178,8 @@ public class ChronoJumpWindow
 	}
 	
 	private void on_menuitem_camera_photo(object o, EventArgs args) {
-		CapturerBin capturer = new CapturerBin();
-		CapturePropertiesStruct s = new CapturePropertiesStruct();
-
-		s.CaptureSourceType = CaptureSourceType.Raw;
-
-		capturer.CaptureProperties = s;
-		capturer.Type = CapturerType.Snapshot;
-		capturer.Visible=true;
-		capturer.NewSnapshot += on_snapshot_done;
-		capturer.NewSnapshotMini += on_snapshot_mini_done;
-		
-		Gtk.Window d = new Gtk.Window("Capturer");
-		d.Add(capturer);
-		d.ShowAll();
-		d.DeleteEvent += delegate(object sender, DeleteEventArgs e) {capturer.Close(); capturer.Dispose();};
-		capturer.Run();
 	}
 
-	private void on_snapshot_done(Pixbuf pixbuf) {
-		pixbuf.Save("/tmp/test-foto.jpg","jpeg");
-	}
-	private void on_snapshot_mini_done(Pixbuf pixbuf) {
-		pixbuf.Save("/tmp/test-foto-mini.jpg","jpeg");
-	}
 
 
 	/* ---------------------------------------------------------
diff --git a/src/gui/dialogImageTest.cs b/src/gui/dialogImageTest.cs
index 6e76a45..646dc9d 100644
--- a/src/gui/dialogImageTest.cs
+++ b/src/gui/dialogImageTest.cs
@@ -22,6 +22,7 @@ using System;
 using Gtk;
 using Gdk;
 using Glade;
+using System.IO; 
 
 public class DialogImageTest
 {
@@ -70,8 +71,12 @@ public class DialogImageTest
 
 		scrolledwindow28.Hide();
 
-                Pixbuf pixbuf = new Pixbuf (imagePath);
-                image_test.Pixbuf = pixbuf;
+		if(File.Exists(imagePath)) {
+	                Pixbuf pixbuf = new Pixbuf (imagePath);
+        	        image_test.Pixbuf = pixbuf;
+		} else 
+			new DialogMessage(Constants.MessageTypes.WARNING, Constants.MultimediaFileNoExists);
+
 	}
 				
 	public void on_close_button_clicked (object obj, EventArgs args) {
diff --git a/src/gui/person.cs b/src/gui/person.cs
index ec1f0d8..832c7f9 100644
--- a/src/gui/person.cs
+++ b/src/gui/person.cs
@@ -27,7 +27,10 @@ using System.Text; //StringBuilder
 using System.Collections; //ArrayList
 using Mono.Unix;
 using System.Threading;
-
+using System.IO; 
+using LongoMatch.Gui;
+using LongoMatch.Video.Capturer;
+using LongoMatch.Video.Common;
 
 //load person (jumper)
 public class PersonRecuperateWindow {
@@ -841,6 +844,10 @@ public class PersonAddModifyWindow
 	[Widget] Gtk.Image image_sport;
 	[Widget] Gtk.Image image_speciallity;
 	[Widget] Gtk.Image image_level;
+	
+	[Widget] Gtk.Button button_zoom;
+	[Widget] Gtk.Image image_photo_mini;
+	[Widget] Gtk.Image image_zoom;
 
 	[Widget] Gtk.Button button_accept;
 	[Widget] Gtk.Button button_cancel;
@@ -917,8 +924,22 @@ public class PersonAddModifyWindow
 		createComboCountries();
 		
 		Pixbuf pixbuf;
-		pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "calendar.png");
+		pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "calendar.png"); //from asssembly
 		image_calendar.Pixbuf = pixbuf;
+
+		pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameZoomInIcon);
+		image_zoom.Pixbuf = pixbuf;
+
+		string photoFile = Util.GetPhotoFileName(true, currentPerson.UniqueID);
+		if(File.Exists(photoFile)) {
+			pixbuf = new Pixbuf (photoFile); //from a file
+			image_photo_mini.Pixbuf = pixbuf;
+		}
+		//show zoom button only if big image exists
+		if(File.Exists(Util.GetPhotoFileName(false, currentPerson.UniqueID)))
+			button_zoom.Sensitive = true;
+		else
+			button_zoom.Sensitive = false;
 			
 		fakeButtonAccept = new Gtk.Button();
 		fakeButtonCancel = new Gtk.Button();
@@ -930,6 +951,37 @@ public class PersonAddModifyWindow
 			person_win.Title = Catalog.GetString ("Edit jumper");
 	}
 	
+	void on_button_zoom_clicked (object o, EventArgs args) {
+		new DialogImageTest(currentPerson.Name, Util.GetPhotoFileName(false, currentPerson.UniqueID));
+	}
+
+	void on_button_take_photo_clicked (object o, EventArgs args) 
+	{
+		CapturerBin capturer = new CapturerBin();
+		CapturePropertiesStruct s = new CapturePropertiesStruct();
+
+		s.CaptureSourceType = CaptureSourceType.Raw;
+
+		capturer.CaptureProperties = s;
+		capturer.Type = CapturerType.Snapshot;
+		capturer.Visible=true;
+		capturer.NewSnapshot += on_snapshot_done;
+		capturer.NewSnapshotMini += on_snapshot_mini_done;
+		
+		Gtk.Window d = new Gtk.Window("Capturer");
+		d.Add(capturer);
+		d.ShowAll();
+		d.DeleteEvent += delegate(object sender, DeleteEventArgs e) {capturer.Close(); capturer.Dispose();};
+		capturer.Run();
+	}
+	private void on_snapshot_done(Pixbuf pixbuf) {
+		pixbuf.Save(Util.GetPhotoFileName(false, currentPerson.UniqueID),"jpeg");
+		button_zoom.Sensitive = true;
+	}
+	private void on_snapshot_mini_done(Pixbuf pixbuf) {
+		pixbuf.Save(Util.GetPhotoFileName(true, currentPerson.UniqueID),"jpeg");
+	}
+
 	void on_entries_required_changed (object o, EventArgs args)
 	{
 		bool allOk = true;
diff --git a/src/util.cs b/src/util.cs
index 1e8ddac..e6e6208 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -690,11 +690,15 @@ public class Util
 				"Chronojump" + Path.DirectorySeparatorChar + "multimedia");
 	}
 	
-	public static string GetPhotosDir() {
+	public static string GetPhotosDir(bool small) {
+		string smallDir = "";
+		if(small)
+			smallDir = Path.DirectorySeparatorChar + Constants.SmallPhotoDir; 
+
 		return Path.Combine(
 				Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
 				"Chronojump" + Path.DirectorySeparatorChar + "multimedia" +
-				Path.DirectorySeparatorChar + "photos");
+				Path.DirectorySeparatorChar + "photos") + smallDir;
 	}
 	
 	public static string GetVideosDir() {
@@ -703,20 +707,10 @@ public class Util
 				"Chronojump" + Path.DirectorySeparatorChar + "multimedia" +
 				Path.DirectorySeparatorChar + "videos");
 	}
-	
-	public static string GetMultimediaSessionDir (Constants.MultimediaItems multimediaItem, int sessionID) {
-		string dir = "";
-		if(multimediaItem == Constants.MultimediaItems.VIDEO)
-			dir = GetVideosDir();
-		else //multimediaItem = Constants.MultimediaItems.PHOTO
-			dir = GetPhotosDir();
 
-		return dir + Path.DirectorySeparatorChar + sessionID.ToString();
-	}
-	
 	//to store user videos and photos
 	public static void CreateMultimediaDirsIfNeeded () {
-		string [] dirs = { GetMultimediaDir(), GetPhotosDir(), GetVideosDir() }; 
+		string [] dirs = { GetMultimediaDir(), GetPhotosDir(false), GetPhotosDir(true), GetVideosDir() }; 
 		foreach (string d in dirs) {
 			if( ! Directory.Exists(d)) {
 				Directory.CreateDirectory (d);
@@ -725,21 +719,31 @@ public class Util
 		}
 	}
 	
-	public static void CreateMultimediaSessionDirIfNeeded (Constants.MultimediaItems multimediaItem, int sessionID) {
-		string sessionDir = GetMultimediaSessionDir(multimediaItem, sessionID);
+	//videos ar organized by sessions. Photos no.	
+	public static string GetVideoSessionDir (int sessionID) {
+		return GetVideosDir() + Path.DirectorySeparatorChar + sessionID.ToString();
+	}
+	
+	public static void CreateVideoSessionDirIfNeeded (int sessionID) {
+		string sessionDir = GetVideoSessionDir(sessionID);
 		if( ! Directory.Exists(sessionDir)) {
 			Directory.CreateDirectory (sessionDir);
 			Log.WriteLine (string.Format("created dir: {0}", sessionDir));
 		}
 	}
 
-	public static string GetMultimediaFileName (Constants.MultimediaItems multimediaItem, 
-			int sessionID, Constants.TestTypes testType, int uniqueID) {
-		
-		return GetMultimediaSessionDir(multimediaItem, sessionID) + Path.DirectorySeparatorChar + 
-			testType.ToString() + "-" + uniqueID.ToString() + GetMultimediaExtension(multimediaItem);
+	public static string GetVideoFileName (int sessionID, Constants.TestTypes testType, int uniqueID) {
+		return GetVideoSessionDir(sessionID) + Path.DirectorySeparatorChar + 
+			testType.ToString() + "-" + uniqueID.ToString() +
+			GetMultimediaExtension(Constants.MultimediaItems.VIDEO);
 	}
 	
+	public static string GetPhotoFileName (bool small, int uniqueID) {
+		return GetPhotosDir(small) + Path.DirectorySeparatorChar + uniqueID.ToString() +
+			GetMultimediaExtension(Constants.MultimediaItems.PHOTO);
+	}
+	
+	
 	public static string GetMultimediaExtension (Constants.MultimediaItems multimediaItem) {
 		if(multimediaItem == Constants.MultimediaItems.VIDEO)
 			return Constants.ExtensionVideo;



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