Starting to implement main window

This commit is contained in:
Sergio Costas 2014-07-09 21:04:10 +02:00
parent 069909c964
commit 0f197561c5
18 changed files with 2400 additions and 25 deletions

View file

@ -13,7 +13,7 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>
def test():
print("Test function")
print("Test function2")

View file

@ -13,11 +13,19 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>
import devede.convert
import devede.main_window
from gi.repository import Gtk
# This is the first call made, where we initializate everything
def main(argv):
def main(argv,paths):
devede.convert.test()
global _
Gtk.init(argv)
ventana = devede.main_window.choose_disk(paths)
Gtk.main()

83
src/devede/main_window.py Normal file
View file

@ -0,0 +1,83 @@
# 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 choose_disk:
def __init__(self,paths):
self.paths = paths
self.builder = Gtk.Builder()
self.builder.set_translation_domain("devede_ng")
self.builder.add_from_file(os.path.join(paths.glade,"wselect_disk.ui"))
self.builder.connect_signals(self)
self.window = self.builder.get_object("wselect_disk")
self.window.show_all()
def main_window(self,disk_type):
self.window.hide()
self.window.destroy()
self.main_window = main_window(self.paths,disk_type)
def on_button_dvd_clicked(self,b):
self.main_window("dvd")
def on_button_vcd_clicked(self,b):
self.main_window("vcd")
def on_button_svcd_clicked(self,b):
self.main_window("svcd")
def on_button_cvd_clicked(self,b):
self.main_window("cvd")
def on_button_divx_clicked(self,b):
self.main_window("divx")
def on_wselect_disk_delete_event(self,w,e):
Gtk.main_quit()
return False
class main_window:
def __init__(self,paths,disk_type):
self.paths = paths
self.disk_type = disk_type
self.builder = Gtk.Builder()
self.builder.set_translation_domain("devede_ng")
self.builder.add_from_file(os.path.join(paths.glade,"wmain.ui"))
self.builder.connect_signals(self)
self.window = self.builder.get_object("wmain")
self.window.show_all()

View file

@ -15,9 +15,63 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>
import sys
import os
import gettext
import locale
import devede.devede
devede.devede.main(sys.argv)
class config_paths:
def __init__(self,is_local):
if (is_local):
# locales must be always at /usr/share/locale because Gtk.Builder always search there
self.share_locale="/usr/share/locale"
self.glade="/usr/local/share/devede_ng"
self.font_path="/usr/local/share/devede_ng"
self.pic_path="/usr/local/share/devede_ng"
self.other_path="/usr/local/share/devede_ng"
self.help_path="/usr/local/share/doc/devede_ng"
else:
self.share_locale="/usr/share/locale"
self.glade="/usr/share/devede_ng"
self.font_path="/usr/share/devede_ng"
self.pic_path="/usr/share/devede_ng"
self.other_path="/usr/share/devede_ng"
self.help_path="/usr/share/doc/devede_ng"
paths = None
try:
os.stat("/usr/share/devede_ng/wselect_disk.ui")
paths = config_paths(False)
except:
pass
if paths == None:
try:
os.stat("/usr/local/share/devede_ng/wselect_disk.ui")
paths = config_paths(True)
except:
pass
if paths == None:
print ("Can't locate extra files. Aborting.")
sys.exit(1)
gettext.bindtextdomain('devede_ng',paths.share_locale)
try:
locale.setlocale(locale.LC_ALL,"")
except locale.Error:
pass
gettext.textdomain('devede_ng')
gettext.install("devede_ng",localedir=paths.share_locale)
_ = gettext.gettext
devede.devede.main(sys.argv,paths)