[chronojump] photo ok on new person, and photos deleted on deleting person
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] photo ok on new person, and photos deleted on deleting person
- Date: Tue, 8 Feb 2011 10:36:49 +0000 (UTC)
commit 3d07a6084fb92fcd2ddd6b35f99418772198be6e
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Feb 8 11:36:14 2011 +0100
photo ok on new person, and photos deleted on deleting person
src/constants.cs | 2 ++
src/gui/chronojump.cs | 9 +++++++++
src/gui/person.cs | 20 ++++++++++++++++++--
src/sqlite/personSession.cs | 9 ++++++++-
src/util.cs | 11 +++++++++++
5 files changed, 48 insertions(+), 3 deletions(-)
---
diff --git a/src/constants.cs b/src/constants.cs
index d625102..6071839 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -477,5 +477,7 @@ public class Constants
public const string ExtensionPhoto = ".jpg";
public const string SmallPhotoDir = "small";
public static string MultimediaFileNoExists = Catalog.GetString("Sorry, this multimedia file does not exists.");
+ public static string PhotoTemp = "chronojump-photo";
+ public static string PhotoSmallTemp = "chronojump-photo-small";
}
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index d76a92f..ad7194f 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2026,6 +2026,15 @@ public class ChronoJumpWindow
currentPerson = personAddModifyWin.CurrentPerson;
currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID);
myTreeViewPersons.Add(currentPerson.UniqueID.ToString(), currentPerson.Name);
+
+ //when adding new person, photos cannot be recorded as currentPerson.UniqueID
+ //because it was undefined. Copy them now
+ if(File.Exists(Util.GetPhotoTempFileName(false)) && File.Exists(Util.GetPhotoTempFileName(true))) {
+ File.Copy(Util.GetPhotoTempFileName(false),
+ Util.GetPhotoFileName(false, currentPerson.UniqueID));
+ File.Copy(Util.GetPhotoTempFileName(true),
+ Util.GetPhotoFileName(true, currentPerson.UniqueID));
+ }
int rowToSelect = findRowOfCurrentPerson(treeview_persons, treeview_persons_store, currentPerson);
if(rowToSelect != -1) {
diff --git a/src/gui/person.cs b/src/gui/person.cs
index 1e936de..01c1db9 100644
--- a/src/gui/person.cs
+++ b/src/gui/person.cs
@@ -977,17 +977,33 @@ public class PersonAddModifyWindow
capturerWindow.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");
+ string fileName = Util.GetPhotoFileName(false, currentPerson.UniqueID);
+ if(adding)
+ fileName = Path.Combine(Path.GetTempPath(), Constants.PhotoTemp +
+ Util.GetMultimediaExtension(Constants.MultimediaItems.PHOTO));
+
+ pixbuf.Save(fileName,"jpeg");
button_zoom.Sensitive = true;
}
+
private void on_snapshot_mini_done(Pixbuf pixbuf) {
- pixbuf.Save(Util.GetPhotoFileName(true, currentPerson.UniqueID),"jpeg");
+ string fileName = Util.GetPhotoFileName(true, currentPerson.UniqueID);
+ if(adding)
+ fileName = Path.Combine(Path.GetTempPath(), Constants.PhotoSmallTemp +
+ Util.GetMultimediaExtension(Constants.MultimediaItems.PHOTO));
+
+ pixbuf.Save(fileName,"jpeg");
capturer.Close();
capturer.Dispose();
capturerWindow.Hide();
string photoFile = Util.GetPhotoFileName(true, currentPerson.UniqueID);
+ if(adding)
+ photoFile = Path.Combine(Path.GetTempPath(), Constants.PhotoSmallTemp +
+ Util.GetMultimediaExtension(Constants.MultimediaItems.PHOTO));
+
if(File.Exists(photoFile)) {
Pixbuf pixbuf2 = new Pixbuf (photoFile); //from a file
image_photo_mini.Pixbuf = pixbuf2;
diff --git a/src/sqlite/personSession.cs b/src/sqlite/personSession.cs
index 07d274a..4a88d00 100644
--- a/src/sqlite/personSession.cs
+++ b/src/sqlite/personSession.cs
@@ -353,8 +353,15 @@ class SqlitePersonSession : Sqlite
dbcmd.ExecuteNonQuery();
//if person is not in other sessions, delete it from DB
- if(! PersonExistsInPS(Convert.ToInt32(personID)))
+ if(! PersonExistsInPS(Convert.ToInt32(personID))) {
SqlitePerson.Delete(Convert.ToInt32(personID));
+
+ //delete photos if any
+ if(File.Exists(Util.GetPhotoFileName(false, Convert.ToInt32(personID))))
+ File.Delete(Util.GetPhotoFileName(false, Convert.ToInt32(personID)));
+ if(File.Exists(Util.GetPhotoFileName(true, Convert.ToInt32(personID))))
+ File.Delete(Util.GetPhotoFileName(true, Convert.ToInt32(personID)));
+ }
//delete normal jumps
dbcmd.CommandText = "Delete FROM jump WHERE sessionID == " + sessionID +
diff --git a/src/util.cs b/src/util.cs
index e6e6208..9166e39 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -707,6 +707,7 @@ public class Util
"Chronojump" + Path.DirectorySeparatorChar + "multimedia" +
Path.DirectorySeparatorChar + "videos");
}
+
//to store user videos and photos
public static void CreateMultimediaDirsIfNeeded () {
@@ -743,6 +744,16 @@ public class Util
GetMultimediaExtension(Constants.MultimediaItems.PHOTO);
}
+ public static string GetPhotoTempFileName(bool small) {
+ string fileName = Constants.PhotoTemp;
+ if(small)
+ fileName = Constants.PhotoSmallTemp;
+
+ return Path.Combine(
+ Path.GetTempPath(), fileName + GetMultimediaExtension(Constants.MultimediaItems.PHOTO));
+ }
+
+
public static string GetMultimediaExtension (Constants.MultimediaItems multimediaItem) {
if(multimediaItem == Constants.MultimediaItems.VIDEO)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]