First great commit for Gtk. It is partially functional now

This commit is contained in:
2015-04-03 16:57:08 -06:00
parent 9356a0544f
commit 2e32fa7ef2
44 changed files with 1814 additions and 110 deletions

View File

@@ -1,42 +1,51 @@
# -*- coding: utf-8 -*-
import sys
import os
#redirect the original stdout and stderr
stdout=sys.stdout
stderr=sys.stderr
sys.stdout = open(os.path.join(os.getenv("temp"), "stdout.log"), "w")
sys.stderr = open(os.path.join(os.getenv("temp"), "stderr.log"), "w")
import platform
""" there are lots of things not implemented for Gtk+ yet.
We've started this effort 1 Apr 2015 so it isn't fully functional. We will remove the ifs statements when are no needed"""
system = platform.system()
if system == "Windows":
import sys
import os
#redirect the original stdout and stderr
stdout=sys.stdout
stderr=sys.stderr
sys.stdout = open(os.path.join(os.getenv("temp"), "stdout.log"), "w")
sys.stderr = open(os.path.join(os.getenv("temp"), "stderr.log"), "w")
import languageHandler
import wx
import paths
import commandline
import config
import sound
import output
from logger import logger
import logging
import platform
import application
import keys
from mysc.thread_utils import call_threaded
from update import updater
import fixes
#extra variables to control the temporal stdout and stderr, while the final files are opened. We understand that some errors could happen while all outputs are closed, so let's try to avoid it.
stdout_temp=sys.stdout
stderr_temp=sys.stderr
import widgetUtils
if system == "Windows":
from logger import logger
from update import updater
stdout_temp=sys.stdout
stderr_temp=sys.stderr
#if it's a binary version
if hasattr(sys, 'frozen'):
sys.stderr = open(paths.logs_path("stderr.log"), 'w')
sys.stdout = open(paths.logs_path("stdout.log"), 'w')
else:
sys.stdout=stdout
sys.stderr=stderr
#the final log files have been opened succesfully, let's close the temporal files
stdout_temp.close()
stderr_temp.close()
#finally, remove the temporal files. TW Blue doesn't need them anymore, and we will get more free space on the harddrive
os.remove(stdout_temp.name)
os.remove(stderr_temp.name)
if hasattr(sys, 'frozen'):
sys.stderr = open(paths.logs_path("stderr.log"), 'w')
sys.stdout = open(paths.logs_path("stdout.log"), 'w')
else:
sys.stdout=stdout
sys.stderr=stderr
#the final log files have been opened succesfully, let's close the temporal files
stdout_temp.close()
stderr_temp.close()
#finally, remove the temporal files. TW Blue doesn't need them anymore, and we will get more free space on the harddrive
os.remove(stdout_temp.name)
os.remove(stderr_temp.name)
if system == "Linux":
from gi.repository import Gdk, GObject, GLib
log = logging.getLogger("main")
def setup():
@@ -51,20 +60,26 @@ def setup():
keys.setup()
from controller import mainController
from sessionmanager import sessionManager
app = wx.App()
updater.do_update()
app = widgetUtils.mainLoopObject()
if system == "Windows":
updater.do_update()
sm = sessionManager.sessionManagerController()
sm.fill_list()
if len(sm.sessions) == 0: sm.show()
else:
sm.do_ok()
if hasattr(sm.view, "destroy"):
sm.view.destroy()
del sm
fixes.setup()
r = mainController.Controller()
r.view.Show()
r.view.show()
r.do_work()
r.check_invisible_at_startup()
call_threaded(r.start)
app.MainLoop()
if system == "Windows":
call_threaded(r.start)
elif system == "Linux":
GLib.idle_add(r.start)
app.run()
setup()
setup()