Now shows the duration of each title

This commit is contained in:
Sergio Costas 2014-12-07 19:10:51 +01:00
parent 34670d3ebd
commit d830276387
3 changed files with 39 additions and 5 deletions

View file

@ -36,6 +36,8 @@
<column type="gchararray"/>
<!-- column-name toedit -->
<column type="gboolean"/>
<!-- column-name duration -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkWindow" id="wmain_window">
@ -218,18 +220,18 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">liststore_files</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="reorderable">True</property>
<property name="enable_search">False</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<signal name="cursor-changed" handler="set_interface_status" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<property name="title" translatable="yes">column</property>
<property name="title" translatable="yes">Title</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext3">
<signal name="edited" handler="on_cellrenderertext3_edited" swapped="no"/>
@ -241,6 +243,19 @@
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title" translatable="yes">Duration</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2">
<property name="alignment">right</property>
</object>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>

View file

@ -183,6 +183,10 @@ class file_movie(devede.interface_manager.interface_manager):
self.emit('title_changed',self.title_name)
def get_duration(self):
return self.original_length
def get_estimated_size(self):
""" Returns the estimated final file size, in kBytes, based on the final audio and video rate, and the subtitles """

View file

@ -21,6 +21,7 @@ import time
import shutil
import urllib.parse
import pickle
import math
import devede.file_movie
import devede.ask
@ -219,6 +220,20 @@ class devede_project:
self.add_several_files(ask_files.files)
def duration_to_string(self,duration):
seconds = math.floor(duration%60)
minutes = math.floor((duration/60)%60)
hours = math.floor(duration/3600)
output = str(seconds)+"s"
if ((hours != 0) or (minutes != 0)):
output = str(minutes)+"m "+output
if (hours != 0):
output = str(hours)+"h "+output
return output
def add_several_files(self,file_list):
error_list = []
for efile in file_list:
@ -229,7 +244,7 @@ class devede_project:
error_list.append(os.path.basename(efile))
else:
new_file.connect('title_changed',self.title_changed)
self.wliststore_files.append([new_file, new_file.title_name,True])
self.wliststore_files.append([new_file, new_file.title_name,True,self.duration_to_string(new_file.get_duration())])
if (len(error_list)!=0):
devede.message.message_window(_("The following files could not be added:"),_("Error while adding files"),error_list)
self.set_interface_status(None)
@ -648,7 +663,7 @@ class devede_project:
else:
new_file.restore_file(efile)
new_file.connect('title_changed',self.title_changed)
self.wliststore_files.append([new_file, new_file.title_name,True])
self.wliststore_files.append([new_file, new_file.title_name,True,self.duration_to_string(new_file.get_duration())])
if (len(error_list)!=0):
devede.message.message_window(_("The following files in the project could not be added again:"),_("Error while adding files"),error_list)
self.set_interface_status(None)