Merging skeleton changes
authorEd Page <eopage@byu.net>
Tue, 8 Jun 2010 23:30:27 +0000 (18:30 -0500)
committerEd Page <eopage@byu.net>
Tue, 8 Jun 2010 23:30:27 +0000 (18:30 -0500)
src/REPLACEME.py [new file with mode: 0755]
src/REPLACEME_qt.py [new file with mode: 0755]
support/builddeb.py

diff --git a/src/REPLACEME.py b/src/REPLACEME.py
new file mode 100755 (executable)
index 0000000..fee6217
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+Copyright (C) 2007 Christoph Würstle
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 2 as
+published by the Free Software Foundation.
+"""
+
+
+import os
+import sys
+import logging
+
+
+_moduleLogger = logging.getLogger(__name__)
+sys.path.append("/opt/REPLACEME/lib")
+
+
+import constants
+import REPLACEME_gtk
+
+
+if __name__ == "__main__":
+       try:
+               os.makedirs(constants._data_path_)
+       except OSError, e:
+               if e.errno != 17:
+                       raise
+
+       try:
+               os.makedirs(constants._cache_path_)
+       except OSError, e:
+               if e.errno != 17:
+                       raise
+
+       logFormat = '(%(asctime)s) %(levelname)-5s %(threadName)s.%(name)s: %(message)s'
+       logging.basicConfig(level=logging.DEBUG, filename=constants._user_logpath_, format=logFormat)
+       _moduleLogger.info("%s %s-%s" % (constants.__app_name__, constants.__version__, constants.__build__))
+       _moduleLogger.info("OS: %s" % (os.uname()[0], ))
+       _moduleLogger.info("Kernel: %s (%s) for %s" % os.uname()[2:])
+       _moduleLogger.info("Hostname: %s" % os.uname()[1])
+
+       REPLACEME_gtk.run()
diff --git a/src/REPLACEME_qt.py b/src/REPLACEME_qt.py
new file mode 100755 (executable)
index 0000000..a66596e
--- /dev/null
@@ -0,0 +1,235 @@
+#!/usr/bin/env python
+# -*- coding: UTF8 -*-
+
+from __future__ import with_statement
+
+import sys
+import os
+import simplejson
+import logging
+
+from PyQt4 import QtGui
+from PyQt4 import QtCore
+
+import constants
+import maeqt
+from util import misc as misc_utils
+import unit_data
+
+
+_moduleLogger = logging.getLogger(__name__)
+
+
+IS_MAEMO = True
+
+
+class REPLACEME(object):
+
+       _DATA_PATHS = [
+               os.path.dirname(__file__),
+               os.path.join(os.path.dirname(__file__), "../data"),
+               os.path.join(os.path.dirname(__file__), "../lib"),
+               '/usr/share/%s' % constants.__app_name__,
+               '/usr/lib/%s' % constants.__app_name__,
+       ]
+
+       def __init__(self, app):
+               self._dataPath = ""
+               for dataPath in self._DATA_PATHS:
+                       appIconPath = os.path.join(dataPath, "pixmaps", "%s.png" %  constants.__app_name__)
+                       if os.path.isfile(appIconPath):
+                               self._dataPath = dataPath
+                               break
+               else:
+                       raise RuntimeError("UI Descriptor not found!")
+               self._app = app
+               self._appIconPath = appIconPath
+               self._recent = []
+               self._hiddenCategories = set()
+               self._hiddenUnits = {}
+               self._clipboard = QtGui.QApplication.clipboard()
+
+               self._mainWindow = None
+
+               self._fullscreenAction = QtGui.QAction(None)
+               self._fullscreenAction.setText("Fullscreen")
+               self._fullscreenAction.setCheckable(True)
+               self._fullscreenAction.setShortcut(QtGui.QKeySequence("CTRL+Enter"))
+               self._fullscreenAction.toggled.connect(self._on_toggle_fullscreen)
+
+               self._logAction = QtGui.QAction(None)
+               self._logAction.setText("Log")
+               self._logAction.setShortcut(QtGui.QKeySequence("CTRL+l"))
+               self._logAction.triggered.connect(self._on_log)
+
+               self._quitAction = QtGui.QAction(None)
+               self._quitAction.setText("Quit")
+               self._quitAction.setShortcut(QtGui.QKeySequence("CTRL+q"))
+               self._quitAction.triggered.connect(self._on_quit)
+
+               self._app.lastWindowClosed.connect(self._on_app_quit)
+               self.load_settings()
+
+       def load_settings(self):
+               try:
+                       with open(constants._user_settings_, "r") as settingsFile:
+                               settings = simplejson.load(settingsFile)
+               except IOError, e:
+                       _moduleLogger.info("No settings")
+                       settings = {}
+               except ValueError:
+                       _moduleLogger.info("Settings were corrupt")
+                       settings = {}
+
+               self._fullscreenAction.setChecked(settings.get("isFullScreen", False))
+
+       def save_settings(self):
+               settings = {
+                       "isFullScreen": self._fullscreenAction.isChecked(),
+               }
+               with open(constants._user_settings_, "w") as settingsFile:
+                       simplejson.dump(settings, settingsFile)
+
+       @property
+       def appIconPath(self):
+               return self._appIconPath
+
+       @property
+       def fullscreenAction(self):
+               return self._fullscreenAction
+
+       @property
+       def logAction(self):
+               return self._logAction
+
+       @property
+       def quitAction(self):
+               return self._quitAction
+
+       def _close_windows(self):
+               if self._mainWindow is not None:
+                       self._mainWindow.window.destroyed.disconnect(self._on_child_close)
+                       self._mainWindow.close()
+                       self._mainWindow = None
+
+       @misc_utils.log_exception(_moduleLogger)
+       def _on_app_quit(self, checked = False):
+               self.save_settings()
+
+       @misc_utils.log_exception(_moduleLogger)
+       def _on_child_close(self, obj = None):
+               self._mainWindow = None
+
+       @misc_utils.log_exception(_moduleLogger)
+       def _on_toggle_fullscreen(self, checked = False):
+               for window in self._walk_children():
+                       window.set_fullscreen(checked)
+
+       @misc_utils.log_exception(_moduleLogger)
+       def _on_log(self, checked = False):
+               with open(constants._user_logpath_, "r") as f:
+                       logLines = f.xreadlines()
+                       log = "".join(logLines)
+                       self._clipboard.setText(log)
+
+       @misc_utils.log_exception(_moduleLogger)
+       def _on_quit(self, checked = False):
+               self._close_windows()
+
+
+class MainWindow(object):
+
+       def __init__(self, parent, app):
+               self._app = app
+
+               self._layout = QtGui.QVBoxLayout()
+
+               centralWidget = QtGui.QWidget()
+               centralWidget.setLayout(self._layout)
+
+               self._window = QtGui.QMainWindow(parent)
+               self._window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
+               maeqt.set_autorient(self._window, True)
+               maeqt.set_stackable(self._window, True)
+               self._window.setWindowTitle("%s" % constants.__pretty_app_name__)
+               self._window.setWindowIcon(QtGui.QIcon(self._app.appIconPath))
+               self._window.setCentralWidget(centralWidget)
+
+               self._closeWindowAction = QtGui.QAction(None)
+               self._closeWindowAction.setText("Close")
+               self._closeWindowAction.setShortcut(QtGui.QKeySequence("CTRL+w"))
+               self._closeWindowAction.triggered.connect(self._on_close_window)
+
+               if IS_MAEMO:
+                       fileMenu = self._window.menuBar().addMenu("&File")
+
+                       viewMenu = self._window.menuBar().addMenu("&View")
+
+                       self._window.addAction(self._closeWindowAction)
+                       self._window.addAction(self._app.quitAction)
+                       self._window.addAction(self._app.fullscreenAction)
+               else:
+                       fileMenu = self._window.menuBar().addMenu("&Units")
+                       fileMenu.addAction(self._closeWindowAction)
+                       fileMenu.addAction(self._app.quitAction)
+
+                       viewMenu = self._window.menuBar().addMenu("&View")
+                       viewMenu.addAction(self._app.fullscreenAction)
+
+               self._window.addAction(self._app.logAction)
+
+               self.set_fullscreen(self._app.fullscreenAction.isChecked())
+               self._window.show()
+
+       @property
+       def window(self):
+               return self._window
+
+       def walk_children(self):
+               return ()
+
+       def show(self):
+               self._window.show()
+               for child in self.walk_children():
+                       child.show()
+
+       def hide(self):
+               for child in self.walk_children():
+                       child.hide()
+               self._window.hide()
+
+       def close(self):
+               for child in self.walk_children():
+                       child.window.destroyed.disconnect(self._on_child_close)
+                       child.close()
+               self._window.close()
+
+       def set_fullscreen(self, isFullscreen):
+               if isFullscreen:
+                       self._window.showFullScreen()
+               else:
+                       self._window.showNormal()
+               for child in self.walk_children():
+                       child.set_fullscreen(isFullscreen)
+
+       @misc_utils.log_exception(_moduleLogger)
+       def _on_close_window(self, checked = True):
+               self.close()
+
+
+def run():
+       app = QtGui.QApplication([])
+       handle = REPLACEME(app)
+       return app.exec_()
+
+
+if __name__ == "__main__":
+       logging.basicConfig(level = logging.DEBUG)
+       try:
+               os.makedirs(constants._data_path_)
+       except OSError, e:
+               if e.errno != 17:
+                       raise
+
+       val = run()
+       sys.exit(val)
index bd89d13..b6abd9e 100755 (executable)
@@ -66,7 +66,11 @@ def build_package(distribution):
        p = py2deb.Py2deb(__appname__)
        p.prettyName = constants.__pretty_app_name__
        p.description = __description__
+<<<<<<< HEAD
        p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Gonvert"
+=======
+       p.bugTracker = "REPLACEME"
+>>>>>>> 6e3215856a887adc778853fcacf0dfcee13701bc
        p.author = __author__
        p.mail = __email__
        p.license = "gpl"
@@ -98,6 +102,7 @@ def build_package(distribution):
                "diablo": "data-pixmaps-gonvert.png",
                "fremantle": "data-pixmaps-gonvert.png", # Fremantle natively uses 48x48
        }[distribution]
+<<<<<<< HEAD
        p["/opt/gonvert/bin"] = [ "gonvert.py" ]
        for relPath, files in unflatten_files(find_files("src", ".")).iteritems():
                fullPath = "/opt/gonvert/lib"
@@ -109,6 +114,11 @@ def build_package(distribution):
                )
        for relPath, files in unflatten_files(find_files("data", ".")).iteritems():
                fullPath = "/opt/gonvert/share"
+=======
+       p["/opt/REPLACEME/bin"] = [ "REPLACEME" ]
+       for relPath, files in unflatten_files(find_files("src", ".")).iteritems():
+               fullPath = "/opt/REPLACEME/lib"
+>>>>>>> 6e3215856a887adc778853fcacf0dfcee13701bc
                if relPath:
                        fullPath += os.sep+relPath
                p[fullPath] = list(