-PROJECT_NAME=
+PROJECT_NAME=REPLACEME
SOURCE_PATH=src
SOURCE=$(shell find $(SOURCE_PATH) -iname "*.py")
PROGRAM=$(SOURCE_PATH)/$(PROJECT_NAME).py
--- /dev/null
+#!/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('../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()
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from __future__ import with_statement
+
+import gc
+import logging
+import ConfigParser
+
+import gobject
+import dbus
+import gtk
+
+try:
+ import osso
+except ImportError:
+ osso = None
+
+import constants
+import hildonize
+import util.misc as misc_utils
+
+
+_moduleLogger = logging.getLogger(__name__)
+PROFILE_STARTUP = False
+
+
+class REPLACEMElProgram(hildonize.get_app_class()):
+
+ def __init__(self):
+ super(REPLACEMElProgram, self).__init__()
+
+ if not hildonize.IS_HILDON_SUPPORTED:
+ _moduleLogger.info("No hildonization support")
+
+ if osso is not None:
+ self._osso_c = osso.Context(constants.__app_name__, constants.__version__, False)
+ self._deviceState = osso.DeviceState(self._osso_c)
+ self._deviceState.set_device_state_callback(self._on_device_state_change, 0)
+ else:
+ _moduleLogger.info("No osso support")
+ self._osso_c = None
+ self._deviceState = None
+
+ def _save_settings(self):
+ config = ConfigParser.SafeConfigParser()
+
+ self._REPLACEME.save_settings(config, "Windows")
+
+ with open(constants._user_settings_, "wb") as configFile:
+ config.write(configFile)
+
+ def _load_settings(self):
+ config = ConfigParser.SafeConfigParser()
+ config.read(constants._user_settings_)
+
+ self._REPLACEME.load_settings(config, "Windows")
+
+ @misc_utils.log_exception(_moduleLogger)
+ def _on_device_state_change(self, shutdown, save_unsaved_data, memory_low, system_inactivity, message, userData):
+ """
+ For system_inactivity, we have no background tasks to pause
+
+ @note Hildon specific
+ """
+ if memory_low:
+ gc.collect()
+
+ if save_unsaved_data or shutdown:
+ self._save_settings()
+
+ @misc_utils.log_exception(_moduleLogger)
+ def _on_destroy(self, widget = None, data = None):
+ try:
+ self.quit()
+ finally:
+ gtk.main_quit()
+
+ def quit(self):
+ try:
+ self._save_settings()
+ except Exception:
+ _moduleLogger.exception("Error saving settigns")
+
+ try:
+ self._deviceState.close()
+ except AttributeError:
+ pass # Either None or close was removed (in Fremantle)
+ except Exception:
+ _moduleLogger.exception("Error closing device state")
+ try:
+ self._osso_c.close()
+ except AttributeError:
+ pass # Either None or close was removed (in Fremantle)
+ except Exception:
+ _moduleLogger.exception("Error closing osso state")
+
+
+def run():
+ gobject.threads_init()
+ gtk.gdk.threads_init()
+ l = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+ # HACK Playback while silent on Maemo 5
+ hildonize.set_application_name("FMRadio")
+
+ app = REPLACEMElProgram()
+ if not PROFILE_STARTUP:
+ try:
+ gtk.main()
+ except KeyboardInterrupt:
+ app.quit()
+ raise
+ else:
+ app.quit()
+
+
+if __name__ == "__main__":
+ logging.basicConfig(level=logging.DEBUG)
+ run()
import os
-__pretty_app_name__ = ""
-__app_name__ = ""
+__pretty_app_name__ = "REPLACEME"
+__app_name__ = "REPLACEME"
__version__ = "0.1.0"
__build__ = 0
__app_magic__ = 0xdeadbeef
get_app_class = _null_get_app_class
-def _hildon_set_application_title(window, title):
- pass
+def _hildon_set_application_name(name):
+ gtk.set_application_name(name)
-def _null_set_application_title(window, title):
- window.set_title(title)
+def _null_set_application_name(name):
+ pass
-if IS_HILDON_SUPPORTED:
- set_application_title = _hildon_set_application_title
-else:
- set_application_title = _null_set_application_title
+try:
+ gtk.set_application_name
+ set_application_name = _hildon_set_application_name
+except AttributeError:
+ set_application_name = _null_set_application_name
def _fremantle_hildonize_window(app, window):
oldWindow = window
newWindow = hildon.StackableWindow()
- oldWindow.get_child().reparent(newWindow)
+ if oldWindow.get_child() is not None:
+ oldWindow.get_child().reparent(newWindow)
app.add_window(newWindow)
return newWindow
def _hildon_hildonize_window(app, window):
oldWindow = window
newWindow = hildon.Window()
- oldWindow.get_child().reparent(newWindow)
+ if oldWindow.get_child() is not None:
+ oldWindow.get_child().reparent(newWindow)
app.add_window(newWindow)
return newWindow
hildonize_combo_entry = _null_hildonize_combo_entry
+def _null_create_seekbar():
+ adjustment = gtk.Adjustment(0, 0, 101, 1, 5, 1)
+ seek = gtk.HScale(adjustment)
+ seek.set_draw_value(False)
+ return seek
+
+
+def _fremantle_create_seekbar():
+ seek = hildon.Seekbar()
+ seek.set_range(0.0, 100)
+ seek.set_draw_value(False)
+ seek.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
+ return seek
+
+
+try:
+ hildon.Seekbar
+ create_seekbar = _fremantle_create_seekbar
+except AttributeError:
+ create_seekbar = _null_create_seekbar
+
+
def _fremantle_hildonize_scrollwindow(scrolledWindow):
pannableWindow = hildon.PannableArea()
class Timeout(object):
- def __init__(self, func):
+ def __init__(self, func, once = True):
self.__func = func
self.__timeoutId = None
+ self.__once = once
def start(self, **kwds):
assert self.__timeoutId is None
+ callback = self._on_once if self.__once else self.__func
+
assert len(kwds) == 1
timeoutInSeconds = kwds["seconds"]
assert 0 <= timeoutInSeconds
+
if timeoutInSeconds == 0:
- self.__timeoutId = gobject.idle_add(self._on_once)
+ self.__timeoutId = gobject.idle_add(callback)
else:
- self.__timeoutId = timeout_add_seconds(timeoutInSeconds, self._on_once)
+ self.__timeoutId = timeout_add_seconds(timeoutInSeconds, callback)
def is_running(self):
return self.__timeoutId is not None
pass # eat up queue to cut down dumb work
self.__workQueue.put(_QUEUE_EMPTY)
+ def clear_tasks(self):
+ for _ in algorithms.itr_available(self.__workQueue):
+ pass # eat up queue to cut down dumb work
+
def add_task(self, func, args, kwds, on_success, on_error):
task = func, args, kwds, on_success, on_error
self.__workQueue.put(task)
)
+class AutoSignal(object):
+
+ def __init__(self, toplevel):
+ self.__disconnectPool = []
+ toplevel.connect("destroy", self.__on_destroy)
+
+ def connect_auto(self, widget, *args):
+ id = widget.connect(*args)
+ self.__disconnectPool.append((widget, id))
+
+ @misc.log_exception(_moduleLogger)
+ def __on_destroy(self, widget):
+ _moduleLogger.info("Destroy: %r (%s to clean up)" % (self, len(self.__disconnectPool)))
+ for widget, id in self.__disconnectPool:
+ widget.disconnect(id)
+ del self.__disconnectPool[:]
+
+
def throttled(minDelay, queue):
"""
Throttle the calls to a function by queueing all the calls that happen
__appname__ = constants.__app_name__
-__description__ = """
+__description__ = """REPLACEME
+REPLACEME
.
Homepage:
"""
__version__ = constants.__version__
__build__ = constants.__build__
__changelog__ = """
+REPLACEME
"""
"""
-def find_files(path):
+def find_files(prefix, path):
for root, dirs, files in os.walk(path):
for file in files:
- if file.startswith("src-"):
+ if file.startswith(prefix+"-"):
fileParts = file.split("-")
unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
- assert unused == "src"
+ assert unused == prefix
relPath = os.sep.join(relPathParts)
yield relPath, file, newName
p.recommends = ", ".join([
])
p.section = {
- "debian": "",
- "diablo": "",
- "fremantle": "",
+ "debian": "REPLACEME",
+ "diablo": "user/REPLACEME",
+ "fremantle": "user/REPLACEME",
}[distribution]
p.arch = "all"
p.urgency = "low"
p.changelog = __changelog__
p.postinstall = __postinstall__
p.icon = {
- "debian": "",
- "diablo": "",
- "fremantle": "", # Fremantle natively uses 48x48
+ "debian": "REPLACEME",
+ "diablo": "REPLACEME",
+ "fremantle": "REPLACEME", # Fremantle natively uses 48x48
}[distribution]
- p["/usr/bin"] = [ "" ]
+ p["/usr/bin"] = [ "REPLACEME" ]
for relPath, files in unflatten_files(find_files(".")).iteritems():
fullPath = ""
if relPath:
"|".join((oldName, newName))
for (oldName, newName) in files
)
- p["/usr/share/applications/hildon"] = [""]
- p["/usr/share/icons/hicolor/26x26/hildon"] = [""]
- p["/usr/share/icons/hicolor/64x64/hildon"] = [""]
- p["/usr/share/icons/hicolor/scalable/hildon"] = [""]
+ p["/usr/share/applications/hildon"] = ["REPLACEME.desktop"]
+ p["/usr/share/icons/hicolor/26x26/hildon"] = ["REPLACEME"]
+ p["/usr/share/icons/hicolor/64x64/hildon"] = ["REPLACEME"]
+ p["/usr/share/icons/hicolor/scalable/hildon"] = ["REPLACEME"]
if distribution == "debian":
print p