summaryrefslogtreecommitdiff
path: root/rapid/rapid.py
diff options
context:
space:
mode:
Diffstat (limited to 'rapid/rapid.py')
-rwxr-xr-xrapid/rapid.py56
1 files changed, 38 insertions, 18 deletions
diff --git a/rapid/rapid.py b/rapid/rapid.py
index f5f221e..ddd0b95 100755
--- a/rapid/rapid.py
+++ b/rapid/rapid.py
@@ -751,20 +751,23 @@ class PreferencesDialog(gnomeglade.Component):
w = workers.firstWorkerReadyToDownload()
root, self.sampleImageName = w.firstImage()
image = os.path.join(root, self.sampleImageName)
+
self.sampleImage = metadata.MetaData(image)
- self.sampleImage.readMetadata()
+ self.sampleImage.read()
except:
self.sampleImage = metadata.DummyMetaData()
self.sampleImageName = 'IMG_0524.CR2'
try:
- root, self.sampleVideoName = w.firstVideo()
+ root, self.sampleVideoName, modificationTime = w.firstVideo()
video = os.path.join(root, self.sampleVideoName)
- self.sampleVideo = videometadata.MetaData(video)
+ self.sampleVideo = videometadata.VideoMetaData(video)
+ self.videoFallBackDate = modificationTime
except:
self.sampleVideo = videometadata.DummyMetaData()
self.sampleVideoName = 'MVI_1379.MOV'
+ self.videoFallBackDate = datetime.datetime.now()
# setup tabs
@@ -1077,12 +1080,12 @@ class PreferencesDialog(gnomeglade.Component):
self.backup_duplicate_skip_radiobutton.set_active(True)
- def updateExampleFileName(self, display_table, rename_table, sample, sampleName, example_label):
+ def updateExampleFileName(self, display_table, rename_table, sample, sampleName, example_label, fallback_date = None):
if hasattr(self, display_table):
rename_table.updateExampleJobCode()
name, problem = rename_table.prefsFactory.generateNameUsingPreferences(
sample, sampleName,
- self.prefs.strip_characters, sequencesPreliminary=False)
+ self.prefs.strip_characters, sequencesPreliminary=False, fallback_date=fallback_date)
else:
name = problem = ''
@@ -1107,9 +1110,9 @@ class PreferencesDialog(gnomeglade.Component):
"""
Displays example video name to the user
"""
- self.updateExampleFileName('video_rename_table', self.video_rename_table, self.sampleVideo, self.sampleVideoName, self.video_new_name_label)
+ self.updateExampleFileName('video_rename_table', self.video_rename_table, self.sampleVideo, self.sampleVideoName, self.video_new_name_label, self.videoFallBackDate)
- def updateDownloadFolderExample(self, display_table, subfolder_table, download_folder, sample, sampleName, example_download_path_label, subfolder_warning_label):
+ def updateDownloadFolderExample(self, display_table, subfolder_table, download_folder, sample, sampleName, example_download_path_label, subfolder_warning_label, fallback_date = None):
"""
Displays example subfolder name(s) to the user
"""
@@ -1118,7 +1121,7 @@ class PreferencesDialog(gnomeglade.Component):
subfolder_table.updateExampleJobCode()
path, problem = subfolder_table.prefsFactory.generateNameUsingPreferences(
sample, sampleName,
- self.prefs.strip_characters)
+ self.prefs.strip_characters, fallback_date = fallback_date)
else:
path = problem = ''
@@ -1139,7 +1142,7 @@ class PreferencesDialog(gnomeglade.Component):
def updateVideoDownloadFolderExample(self):
if hasattr(self, 'video_subfolder_table'):
- self.updateDownloadFolderExample('video_subfolder_table', self.video_subfolder_table, self.prefs.video_download_folder, self.sampleVideo, self.sampleVideoName, self.example_video_download_path_label, self.video_subfolder_warning_label)
+ self.updateDownloadFolderExample('video_subfolder_table', self.video_subfolder_table, self.prefs.video_download_folder, self.sampleVideo, self.sampleVideoName, self.example_video_download_path_label, self.video_subfolder_warning_label, self.videoFallBackDate)
def on_hour_spinbutton_value_changed(self, spinbutton):
hour = spinbutton.get_value_as_int()
@@ -1278,7 +1281,9 @@ class PreferencesDialog(gnomeglade.Component):
self.update_job_codes()
self.updateImageRenameExample()
- self.updateDownloadFolderExample()
+ self.updateVideoRenameExample()
+ self.updatePhotoDownloadFolderExample()
+ self.updateVideoDownloadFolderExample()
def on_remove_all_job_code_button_clicked(self, button):
j = RemoveAllJobCodeDialog(self.widget, self.remove_all_job_code)
@@ -1289,14 +1294,18 @@ class PreferencesDialog(gnomeglade.Component):
self.job_code_liststore.clear()
self.update_job_codes()
self.updateImageRenameExample()
- self.updateDownloadFolderExample()
+ self.updateVideoRenameExample()
+ self.updatePhotoDownloadFolderExample()
+ self.updateVideoDownloadFolderExample()
def on_job_code_edited(self, widget, path, new_text):
iter = self.job_code_liststore.get_iter(path)
self.job_code_liststore.set_value(iter, 0, new_text)
self.update_job_codes()
self.updateImageRenameExample()
- self.updateDownloadFolderExample()
+ self.updateVideoRenameExample()
+ self.updatePhotoDownloadFolderExample()
+ self.updateVideoDownloadFolderExample()
def update_job_codes(self):
""" update preferences with list of job codes"""
@@ -1560,9 +1569,20 @@ class CopyPhotos(Thread):
"""
returns name, path and size of the first image
"""
+
name, root, size, modificationTime = self.cardMedia.firstImage()
+
return root, name
+ def firstVideo(self):
+ """
+ returns name, path and size of the first image
+ """
+
+ name, root, size, modificationTime = self.cardMedia.firstVideo()
+
+ return root, name, modificationTime
+
def handlePreferencesError(self, e, prefsFactory):
sys.stderr.write(_("Sorry,these preferences contain an error:\n"))
sys.stderr.write(prefsFactory.formatPreferencesForPrettyPrint() + "\n")
@@ -2022,8 +2042,7 @@ class CopyPhotos(Thread):
nameUniqueBeforeCopy = True
downloadNonUniqueFile = True
-
-
+
# do a preliminary check to see if a file with the same name already exists
if os.path.exists(newFile):
nameUniqueBeforeCopy = False
@@ -3385,7 +3404,7 @@ class RapidApp(gnomeglade.GnomeApp, dbus.service.Object):
return prefsOk
def needJobCode(self):
- return rn.usesJobCode(self.prefs.image_rename) or rn.usesJobCode(self.prefs.subfolder)
+ return rn.usesJobCode(self.prefs.image_rename) or rn.usesJobCode(self.prefs.subfolder) or rn.usesJobCode(self.prefs.video_rename) or rn.usesJobCode(self.prefs.video_subfolder)
def assignJobCode(self, code):
""" assign job code (which may be empty) to global variable and update user preferences
@@ -4195,7 +4214,7 @@ class RapidApp(gnomeglade.GnomeApp, dbus.service.Object):
if not self.preferencesDialogDisplayed:
self.postPreferenceChange()
- elif key in ['subfolder', 'image_rename']:
+ elif key in ['subfolder', 'image_rename', 'video_subfolder', 'video_rename']:
global need_job_code
need_job_code = self.needJobCode()
@@ -4283,9 +4302,10 @@ class Volume:
gicon = self.volume.get_icon()
f = None
if isinstance(gicon, gio.ThemedIcon):
- iconinfo = icontheme.choose_icon(gicon.get_names(), size, gtk.ICON_LOOKUP_USE_BUILTIN)
- f = iconinfo.get_filename()
try:
+ # on some user's systems, themes do not have icons associated with them
+ iconinfo = icontheme.choose_icon(gicon.get_names(), size, gtk.ICON_LOOKUP_USE_BUILTIN)
+ f = iconinfo.get_filename()
v = gtk.gdk.pixbuf_new_from_file_at_size(f, size, size)
except:
f = None