Allows to set the properties of a title
Allows to add several files, and add the all in the current title, or each one in a new title
This commit is contained in:
parent
6cb04b131e
commit
a60221b57d
8 changed files with 614 additions and 13 deletions
99
src/devede/add_files.py
Normal file
99
src/devede/add_files.py
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
# Copyright 2014 (C) Raster Software Vigo (Sergio Costas)
|
||||
#
|
||||
# This file is part of DeVeDe-NG
|
||||
#
|
||||
# DeVeDe-NG is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# DeVeDe-NG is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
from gi.repository import Gtk
|
||||
import os
|
||||
|
||||
class add_files:
|
||||
|
||||
last_path = None
|
||||
|
||||
def __init__(self,paths):
|
||||
|
||||
self.paths = paths
|
||||
self.show_title_options = True
|
||||
|
||||
def set_type(self,disc_type):
|
||||
|
||||
if (disc_type == "dvd"):
|
||||
self.show_title_options = True
|
||||
else:
|
||||
self.show_title_options = False
|
||||
|
||||
def run(self):
|
||||
|
||||
builder = Gtk.Builder()
|
||||
builder.set_translation_domain("devede_ng")
|
||||
|
||||
builder.add_from_file(os.path.join(self.paths.glade,"wadd_files.ui"))
|
||||
builder.connect_signals(self)
|
||||
wadd_files = builder.get_object("add_files")
|
||||
self.wfile_chooser = builder.get_object("filechooserwidget1")
|
||||
if (add_files.last_path != None):
|
||||
self.wfile_chooser.set_current_folder(add_files.last_path)
|
||||
self.wadd_to_current_title = builder.get_object("add_to_current_title")
|
||||
self.wadd_to_new_titles = builder.get_object("add_to_new_titles")
|
||||
self.wuse_filename_as_title = builder.get_object("use_filename_as_title")
|
||||
self.wbutton_accept = builder.get_object("button_accept")
|
||||
|
||||
woptions = builder.get_object("frame_options")
|
||||
|
||||
wadd_files.show_all()
|
||||
if (self.show_title_options == False):
|
||||
woptions.hide()
|
||||
|
||||
self.on_add_to_new_titles_toggled(None)
|
||||
retval = wadd_files.run()
|
||||
self.files = None
|
||||
self.add_to_current_title = True
|
||||
self.use_filename_as_title = False
|
||||
|
||||
if (retval == 2):
|
||||
self.add_to_current_title = self.wadd_to_current_title.get_active()
|
||||
self.use_filename_as_title = self.wuse_filename_as_title.get_active()
|
||||
self.files = self.get_files()
|
||||
|
||||
print(self.files)
|
||||
|
||||
add_files.last_path = self.wfile_chooser.get_current_folder()
|
||||
wadd_files.destroy()
|
||||
|
||||
if (retval == 2):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_files(self):
|
||||
files = self.wfile_chooser.get_filenames()
|
||||
files_out = []
|
||||
for element in files:
|
||||
if (os.path.isdir(element)):
|
||||
continue
|
||||
files_out.append(element)
|
||||
return files_out
|
||||
|
||||
def on_filechooserwidget1_selection_changed(self,b):
|
||||
|
||||
files = self.get_files()
|
||||
if (len(files) == 0):
|
||||
self.wbutton_accept.set_sensitive(False)
|
||||
else:
|
||||
self.wbutton_accept.set_sensitive(True)
|
||||
|
||||
def on_add_to_new_titles_toggled(self,b):
|
||||
|
||||
self.wuse_filename_as_title.set_sensitive(self.wadd_to_new_titles.get_active())
|
||||
|
|
@ -21,9 +21,11 @@ class file_movie(GObject.GObject):
|
|||
|
||||
counter2 = 0
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self,paths,file_name):
|
||||
|
||||
GObject.GObject.__init__(self)
|
||||
self.paths = paths
|
||||
self.file_name = file_name
|
||||
|
||||
def set_type(self,disc_type):
|
||||
|
||||
|
|
@ -35,5 +37,4 @@ class file_movie(GObject.GObject):
|
|||
|
||||
def properties(self):
|
||||
|
||||
self.file_name = "Hola"+str(file_movie.counter2)
|
||||
file_movie.counter2 += 1
|
||||
|
|
@ -21,6 +21,7 @@ import os
|
|||
import devede.title
|
||||
import devede.file_movie
|
||||
import devede.ask
|
||||
import devede.add_files
|
||||
|
||||
class devede_project:
|
||||
|
||||
|
|
@ -289,7 +290,7 @@ class devede_project:
|
|||
|
||||
self.get_current_title()
|
||||
|
||||
new_title = devede.title.title(self.wfiles,self.wliststore_files)
|
||||
new_title = devede.title.title(self.paths,self.wfiles,self.wliststore_files)
|
||||
new_title.set_type(self.disc_type)
|
||||
self.wliststore_titles.append([new_title.title_name, new_title])
|
||||
self.set_interface_status(None)
|
||||
|
|
@ -300,13 +301,24 @@ class devede_project:
|
|||
if (element == None):
|
||||
return
|
||||
|
||||
new_file = devede.file_movie.file_movie()
|
||||
new_file.set_type(self.disc_type)
|
||||
new_file.properties()
|
||||
|
||||
if (new_file.file_name != None):
|
||||
element.add_file(new_file)
|
||||
self.set_interface_status(None)
|
||||
ask_files = devede.add_files.add_files(self.paths)
|
||||
ask_files.set_type(self.disc_type)
|
||||
if (ask_files.run()):
|
||||
for efile in ask_files.files:
|
||||
new_file = devede.file_movie.file_movie(self.paths,efile)
|
||||
new_file.set_type(self.disc_type)
|
||||
if (ask_files.add_to_current_title):
|
||||
element.add_file(new_file)
|
||||
else:
|
||||
if (ask_files.use_filename_as_title):
|
||||
filename = os.path.splitext(os.path.basename(efile))[0]
|
||||
new_title = devede.title.title(self.paths,self.wfiles,self.wliststore_files,filename)
|
||||
else:
|
||||
new_title = devede.title.title(self.paths,self.wfiles,self.wliststore_files)
|
||||
new_title.set_type(self.disc_type)
|
||||
self.wliststore_titles.append([new_title.title_name, new_title])
|
||||
new_title.add_file(new_file)
|
||||
self.set_interface_status(None)
|
||||
|
||||
|
||||
def on_delete_title_clicked(self,b):
|
||||
|
|
@ -373,6 +385,14 @@ class devede_project:
|
|||
self.wfiles.get_model().swap(last_element.iter,treeiter)
|
||||
self.set_interface_status(None)
|
||||
|
||||
def on_properties_title_clicked(self,b):
|
||||
(element, position, model, treeiter) = self.get_current_title()
|
||||
if (element == None) or (position == (len(self.wfiles.get_model())-1)):
|
||||
return
|
||||
|
||||
element.properties()
|
||||
self.wliststore_titles.set_value(treeiter,0,element.title_name)
|
||||
|
||||
def on_adjust_disc_usage_clicked(self,b):
|
||||
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -16,17 +16,23 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
from gi.repository import Gtk,GObject
|
||||
import os
|
||||
|
||||
class title(GObject.GObject):
|
||||
|
||||
counter = 0
|
||||
|
||||
def __init__(self,file_treeview,original_liststore):
|
||||
def __init__(self,paths,file_treeview,original_liststore,title_name = None):
|
||||
|
||||
GObject.GObject.__init__(self)
|
||||
self.paths = paths
|
||||
self.file_treeview = file_treeview
|
||||
title.counter += 1
|
||||
self.title_name = _("Title %(X)d") % {"X":title.counter}
|
||||
if (title_name == None):
|
||||
title.counter += 1
|
||||
self.title_name = _("Title %(X)d") % {"X":title.counter}
|
||||
else:
|
||||
self.title_name = title_name
|
||||
self.post_action = "stop"
|
||||
columns = []
|
||||
for iterator in range(0, original_liststore.get_n_columns()):
|
||||
columns.append(original_liststore.get_column_type(iterator))
|
||||
|
|
@ -37,6 +43,46 @@ class title(GObject.GObject):
|
|||
|
||||
self.disc_type = disc_type
|
||||
|
||||
def properties(self):
|
||||
|
||||
builder = Gtk.Builder()
|
||||
builder.set_translation_domain("devede_ng")
|
||||
|
||||
builder.add_from_file(os.path.join(self.paths.glade,"wtitle_properties.ui"))
|
||||
builder.connect_signals(self)
|
||||
|
||||
# Interface widgets
|
||||
wtitle_properties = builder.get_object("title_properties")
|
||||
wtitle = builder.get_object("entry_title")
|
||||
wplay_first = builder.get_object("play_first")
|
||||
wplay_prev = builder.get_object("play_previous")
|
||||
wplay_again = builder.get_object("play_again")
|
||||
wplay_next = builder.get_object("play_next")
|
||||
wplay_last = builder.get_object("play_last")
|
||||
|
||||
wtitle.set_text(self.title_name)
|
||||
builder.get_object(self.post_action).set_active(True)
|
||||
|
||||
wtitle_properties.show_all()
|
||||
retval = wtitle_properties.run()
|
||||
if (retval == 2):
|
||||
self.title_name = wtitle.get_text()
|
||||
if (wplay_first.get_active()):
|
||||
self.post_action = "play_first"
|
||||
elif (wplay_prev.get_active()):
|
||||
self.post_action = "play_previous"
|
||||
elif (wplay_again.get_active()):
|
||||
self.post_action = "play_again"
|
||||
elif (wplay_next.get_active()):
|
||||
self.post_action = "play_next"
|
||||
elif (wplay_last.get_active()):
|
||||
self.post_action = "play_last"
|
||||
else:
|
||||
self.post_action = "stop"
|
||||
|
||||
wtitle_properties.destroy()
|
||||
|
||||
|
||||
def delete_title(self):
|
||||
|
||||
print("Deleted title "+self.title_name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue