diff --git a/data/interface/wadd_files.ui b/data/interface/wadd_files.ui new file mode 100644 index 0000000..3404a3e --- /dev/null +++ b/data/interface/wadd_files.ui @@ -0,0 +1,182 @@ + + + + + + 640 + 400 + False + Add new file(s) + True + center + devede.svg + dialog + True + False + + + False + vertical + 2 + + + False + end + + + gtk-cancel + True + True + True + True + + + False + True + 0 + + + + + gtk-ok + True + True + True + True + + + False + True + 1 + + + + + False + True + end + 0 + + + + + True + False + vertical + + + True + False + False + True + + + + True + True + 0 + + + + + True + False + 0 + none + + + True + False + 12 + + + True + False + vertical + + + Add file(s) to the currently selected title + True + True + False + 0 + True + True + + + + + False + True + 0 + + + + + Add file(s) into its own new title + True + True + False + 0 + True + True + add_to_current_title + + + + + False + True + 1 + + + + + Use file name as title name + True + True + False + 20 + 0 + True + + + False + True + 2 + + + + + + + + + True + False + <b>Extra options</b> + True + + + + + False + True + 1 + + + + + True + True + 1 + + + + + + button1 + button_accept + + + diff --git a/data/interface/wmain.ui b/data/interface/wmain.ui index b0f2d32..2e87b5b 100644 --- a/data/interface/wmain.ui +++ b/data/interface/wmain.ui @@ -353,6 +353,7 @@ True top True + False diff --git a/data/interface/wmain.ui~ b/data/interface/wmain.ui~ index d3ef57e..b0f2d32 100644 --- a/data/interface/wmain.ui~ +++ b/data/interface/wmain.ui~ @@ -908,6 +908,7 @@ True True True + False diff --git a/data/interface/wtitle_properties.ui b/data/interface/wtitle_properties.ui new file mode 100644 index 0000000..5ef4fae --- /dev/null +++ b/data/interface/wtitle_properties.ui @@ -0,0 +1,251 @@ + + + + + + 380 + False + Title properties + False + True + center + devede.svg + dialog + True + False + False + + + False + vertical + 2 + + + False + end + + + gtk-cancel + True + True + True + True + + + False + True + 0 + + + + + gtk-ok + True + True + True + True + + + False + True + 1 + + + + + False + True + end + 0 + + + + + True + False + vertical + + + True + False + 0 + none + + + True + False + 12 + + + True + True + + + + + + + True + False + <b>Title's name</b> + True + + + + + False + True + 0 + + + + + True + False + 0 + none + + + True + False + 12 + + + True + False + vertical + + + Stop reproduction/show disc menu + True + True + False + 0 + True + True + + + False + True + 0 + + + + + Play the first title + True + True + False + 0 + True + True + stop + + + False + True + 1 + + + + + Play the previous title + True + True + False + 0 + True + True + stop + + + False + True + 2 + + + + + Play this title again (loop) + True + True + False + 0 + True + True + stop + + + False + True + 3 + + + + + Play the next title + True + True + False + 0 + True + True + stop + + + False + True + 4 + + + + + Play the last title + True + True + False + 0 + True + True + stop + + + False + True + 5 + + + + + + + + + True + False + <b>Action to perform when this title ends</b> + True + + + + + False + True + 1 + + + + + False + True + 1 + + + + + + button1 + button2 + + + diff --git a/src/devede/add_files.py b/src/devede/add_files.py new file mode 100644 index 0000000..0b65088 --- /dev/null +++ b/src/devede/add_files.py @@ -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 + +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()) \ No newline at end of file diff --git a/src/devede/file_movie.py b/src/devede/file_movie.py index bf1d4e7..fea1c72 100644 --- a/src/devede/file_movie.py +++ b/src/devede/file_movie.py @@ -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 \ No newline at end of file diff --git a/src/devede/project.py b/src/devede/project.py index 663928a..7f598a8 100644 --- a/src/devede/project.py +++ b/src/devede/project.py @@ -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 diff --git a/src/devede/title.py b/src/devede/title.py index f71fc18..a3c1f09 100644 --- a/src/devede/title.py +++ b/src/devede/title.py @@ -16,17 +16,23 @@ # along with this program. If not, see 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)