From 088be2e3e9cfe99f3febf36220469dc129324bac Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 12 Aug 2010 15:59:58 +0100 Subject: [PATCH] Init application --- src/main.py | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/shared.py | 29 ++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 src/shared.py diff --git a/src/main.py b/src/main.py index 3a1213c..12fa9e7 100644 --- a/src/main.py +++ b/src/main.py @@ -1,3 +1,101 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- + +# Imports +import dbus, jack, os, sys +from dbus.mainloop.qt import DBusQtMainLoop +from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs, KCmdLineOptions +from PyKDE4.kdeui import KApplication +import shared + + +#--------------- main ------------------ +if __name__ == '__main__': + + # Application description + appName = "klaudia" + catalog = "" + programName = ki18n("Klaudia") + version = "0.2" + description = ki18n("Linux Audio Applications Manager") + license = KAboutData.License_GPL_V2 + copyright = ki18n("(c) 2010 falkTX") + text = ki18n("Klaudia is a Linux Audio Applications Manager, writen in Python (and KDE)") + homePage = "http://klaudia.sourceforge.net" + bugEmail = "falktx@gmail.com" + + aboutData = KAboutData(appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail) + aboutData.addAuthor(ki18n("falkTX"), ki18n("Main Developer"), "falktx@gmail.com", "") + + # Set Command-Line Options + KCmdLineArgs.init(sys.argv, aboutData) + options = KCmdLineOptions() + options.add("+[project-folder]", ki18n("Project folder to open")) + KCmdLineArgs.addCmdLineOptions(options) + + # Global Variables + shared.p_folder = "" + shared.p_icon = "inode-directory" + shared.p_name = "" + shared.p_author = "" + shared.p_composer = "" + shared.p_track = "" + shared.p_album = "" + shared.p_bpm = 0.0 + shared.p_time_start = "00:00:00" + shared.p_time_end = "00:00:00" + shared.ladish_project_name = "" + + shared.Home = os.getenv("HOME") + shared.Path = sys.path[0] + shared.WinePrefix = shared.Home+"/.wine" + shared.Wine_RT = 15 + shared.Wine_SRV_RT = 10 + + dbus_loop = DBusQtMainLoop(set_as_default=True) + shared.loopBus = dbus.SessionBus(mainloop=dbus_loop) + shared.jackBus = shared.loopBus.get_object("org.jackaudio.service", "/org/jackaudio/Controller") + shared.controlBus = shared.loopBus.get_object("org.ladish", "/org/ladish/Control") + shared.studioBus = shared.loopBus.get_object("org.ladish", "/org/ladish/Studio") + shared.appBus = dbus.Interface(shared.studioBus, 'org.ladish.AppSupervisor') + shared.patchBus = dbus.Interface(shared.jackBus, 'org.jackaudio.JackPatchbay') + + # Load Arguments (file/foldername) + args = KCmdLineArgs.parsedArgs() + if (args.count() > 0): + shared.p_folder = str(args.arg(0)) + + url = shared.p_folder + if (path.exists(url+"/.directory")): + iconF = open(url+"/.directory").read().split("Icon=") + if (len(iconF) > 1): + icon = iconF[-1].split()[0] + shared.p_icon = icon + + # App initialization + app = KApplication() + + # Set variables + ret = -1 + + # Create config folder + if (not os.path.exists(shared.Home+"/.klaudia")): + os.mkdir(shared.Home+"/.klaudia") + + if (shared.p_folder): + print "open a project file, based on argv" + wiz = 1 + else: + print "show wizard" + wiz = 1 + + # Show Main Window if wizard completed + if (wiz): + print "wizard completed, open main window" + + # Terminate Jack stuff + jack.detach() + + # Close Properly + sys.exit(ret) diff --git a/src/shared.py b/src/shared.py new file mode 100644 index 0000000..5473d1a --- /dev/null +++ b/src/shared.py @@ -0,0 +1,29 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +class Globals(object): + __slots__ = [ + 'p_folder', + 'p_icon', + 'p_name', + 'p_author', + 'p_composer', + 'p_album', + 'p_track', + 'p_bpm', + 'p_time_start', + 'p_time_end', + 'ladish_project_name', + 'Home', + 'Path', + 'WinePrefix', + 'loopBus', + 'jackBus', + 'controlBus', + 'studioBus', + 'appBus', + 'patchBus', + 'Wine_RT', + 'Wine_SRV_RT', + ] +Globals = Globals() -- 2.11.4.GIT