コード例 #1
0
ファイル: settings.py プロジェクト: chergert/lift
    def __init__(self, name = '', path = ''):
        """
        Creates a new Settings instance which binds properties to
        gconf using GCONF_ROOT/path/prop_name.
        """
        self._name = name
        self._path = path

        if not name:
            self._name = self.settings_name

        if not path:
            self._path = self.settings_path

        config = Runtime.get_config()
        root = config.SETTINGS_ROOT + self._path

        # our gconf client
        self._client = gconf.client_get_default()
        rootdir = root.endswith('/') and root[:-1] or root
        self._client.add_dir(rootdir, gconf.CLIENT_PRELOAD_NONE)

        # lambda to retreive our attributes which are settings
        issetting = lambda a: isinstance(getattr(self, a), Setting)
        attrs = (a for a in dir(self) if issetting(a))

        for attr in list(attrs):
            attr = getattr(self, attr)
            attr.set_client(self._client, root)
コード例 #2
0
ファイル: controller.py プロジェクト: chergert/lift
    def change_channel(self, num):
        VideoService = Runtime.get_service('video')

        # get a live channel stream
        source = VideoService.get_video_for_channel(num)

        # update our video widget to play the source
        self.view.video.set_source(source)

        # update our current channel label
        self.view.channel_label.set_text('<b>%d</b>' % num)
コード例 #3
0
ファイル: views.py プロジェクト: chergert/lift
def get_default_filename(self, suffix = ''):
    """
    Returns what the default template name would be for a particular
    class instance.
    """
    module = self.__class__.__module__.lower()
    if module == '__main__':
        module = ''
    else:
        # trim off the app module
        module = '.'.join(module.split('.')[1:])
    klass = self.__class__.__name__.lower()
    config = Runtime.get_config()
    if hasattr(config, 'VIEW_PATH'):
        viewpath = config.VIEW_PATH
    else:
        viewpath = 'data'
    return os.path.join(viewpath,
                        module.replace('.', os.path.sep),
                        klass) + suffix