Modified the configuration as a singleton, to simplify the creation of new elements
This commit is contained in:
parent
d4ed74ae5f
commit
4e6a269475
6 changed files with 25 additions and 14 deletions
|
|
@ -17,14 +17,15 @@
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
import os
|
import os
|
||||||
|
import devede.configuration_data
|
||||||
|
|
||||||
class add_files:
|
class add_files:
|
||||||
|
|
||||||
last_path = None
|
last_path = None
|
||||||
|
|
||||||
def __init__(self,config):
|
def __init__(self):
|
||||||
|
|
||||||
self.config = config
|
self.config = devede.configuration_data.configuration.get_config()
|
||||||
self.show_title_options = True
|
self.show_title_options = True
|
||||||
|
|
||||||
def set_type(self,disc_type):
|
def set_type(self,disc_type):
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,13 @@
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
import os
|
import os
|
||||||
|
import devede.configuration_data
|
||||||
|
|
||||||
class ask_window:
|
class ask_window:
|
||||||
|
|
||||||
def __init__(self,config):
|
def __init__(self):
|
||||||
|
|
||||||
self.config = config
|
self.config = devede.configuration_data.configuration.get_config()
|
||||||
|
|
||||||
def run(self,text,title):
|
def run(self,text,title):
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,14 @@ import os
|
||||||
|
|
||||||
class configuration:
|
class configuration:
|
||||||
|
|
||||||
|
current_configuration = None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_config():
|
||||||
|
if configuration.current_configuration == None:
|
||||||
|
configuration.current_configuration = configuration()
|
||||||
|
return configuration.current_configuration
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.error = False
|
self.error = False
|
||||||
|
|
|
||||||
|
|
@ -17,15 +17,16 @@
|
||||||
|
|
||||||
from gi.repository import Gtk,GObject
|
from gi.repository import Gtk,GObject
|
||||||
import os
|
import os
|
||||||
|
import devede.configuration_data
|
||||||
|
|
||||||
class file_movie(GObject.GObject):
|
class file_movie(GObject.GObject):
|
||||||
|
|
||||||
counter2 = 0
|
counter2 = 0
|
||||||
|
|
||||||
def __init__(self,config,file_name):
|
def __init__(self,file_name):
|
||||||
|
|
||||||
GObject.GObject.__init__(self)
|
GObject.GObject.__init__(self)
|
||||||
self.config = config
|
self.config = devede.configuration_data.configuration.get_config()
|
||||||
self.file_name = file_name
|
self.file_name = file_name
|
||||||
self.title_name = os.path.splitext(os.path.basename(file_name))[0]
|
self.title_name = os.path.splitext(os.path.basename(file_name))[0]
|
||||||
self.wfile_properties = None
|
self.wfile_properties = None
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@ import devede.add_files
|
||||||
|
|
||||||
class devede_project:
|
class devede_project:
|
||||||
|
|
||||||
def __init__(self,config):
|
def __init__(self):
|
||||||
|
|
||||||
self.config = config
|
self.config = devede.configuration_data.configuration.get_config()
|
||||||
self.destroy_all()
|
self.destroy_all()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -206,18 +206,18 @@ class devede_project:
|
||||||
|
|
||||||
def on_wmain_window_delete_event(self,b,e=None):
|
def on_wmain_window_delete_event(self,b,e=None):
|
||||||
|
|
||||||
ask = devede.ask.ask_window(self.config)
|
ask = devede.ask.ask_window()
|
||||||
if (ask.run(_("Abort the current DVD and exit?"),_("Exit DeVeDe"))):
|
if (ask.run(_("Abort the current DVD and exit?"),_("Exit DeVeDe"))):
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def on_add_file_clicked(self,b):
|
def on_add_file_clicked(self,b):
|
||||||
|
|
||||||
ask_files = devede.add_files.add_files(self.config)
|
ask_files = devede.add_files.add_files()
|
||||||
ask_files.set_type(self.disc_type)
|
ask_files.set_type(self.disc_type)
|
||||||
if (ask_files.run()):
|
if (ask_files.run()):
|
||||||
for efile in ask_files.files:
|
for efile in ask_files.files:
|
||||||
new_file = devede.file_movie.file_movie(self.config,efile)
|
new_file = devede.file_movie.file_movie(efile)
|
||||||
new_file.set_type(self.disc_type)
|
new_file.set_type(self.disc_type)
|
||||||
self.wliststore_files.append([new_file, new_file.title_name])
|
self.wliststore_files.append([new_file, new_file.title_name])
|
||||||
self.set_interface_status(None)
|
self.set_interface_status(None)
|
||||||
|
|
@ -229,7 +229,7 @@ class devede_project:
|
||||||
if (element == None):
|
if (element == None):
|
||||||
return
|
return
|
||||||
|
|
||||||
ask_w = devede.ask.ask_window(self.config)
|
ask_w = devede.ask.ask_window()
|
||||||
if (ask_w.run(_("The file <b>%(X)s</b> <i>(%(Y)s)</i> will be removed.") % {"X":element.title_name, "Y":element.file_name},_("Delete file"))):
|
if (ask_w.run(_("The file <b>%(X)s</b> <i>(%(Y)s)</i> will be removed.") % {"X":element.title_name, "Y":element.file_name},_("Delete file"))):
|
||||||
element.delete_file()
|
element.delete_file()
|
||||||
model.remove(treeiter)
|
model.remove(treeiter)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ from gi.repository import Gtk
|
||||||
import devede.project
|
import devede.project
|
||||||
import devede.configuration_data
|
import devede.configuration_data
|
||||||
|
|
||||||
config_data = devede.configuration_data.configuration()
|
config_data = devede.configuration_data.configuration.get_config()
|
||||||
|
|
||||||
if config_data.error:
|
if config_data.error:
|
||||||
print ("Can't locate extra files. Aborting.")
|
print ("Can't locate extra files. Aborting.")
|
||||||
|
|
@ -43,7 +43,7 @@ _ = gettext.gettext
|
||||||
|
|
||||||
Gtk.init(sys.argv)
|
Gtk.init(sys.argv)
|
||||||
|
|
||||||
mwindow = devede.project.devede_project(config_data)
|
mwindow = devede.project.devede_project()
|
||||||
mwindow.ask_type()
|
mwindow.ask_type()
|
||||||
Gtk.main()
|
Gtk.main()
|
||||||
config_data.save_config()
|
config_data.save_config()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue