1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3
# This file is in the public domain
6
"""Helpers for an Ubuntu application."""
19
from python_name.python_nameconfig import get_data_file
22
from gettext import gettext as _
23
gettext.textdomain('project_name')
25
def get_builder(builder_file_name):
26
"""Return a fully-instantiated gtk.Builder instance from specified ui
29
:param builder_file_name: The name of the builder file, without extension.
30
Assumed to be in the 'ui' directory under the data path.
32
# Look for the ui file that describes the user interface.
33
ui_filename = get_data_file('ui', '%s.ui' % (builder_file_name,))
34
if not os.path.exists(ui_filename):
37
builder = gtk.Builder()
38
builder.set_translation_domain('project_name')
39
builder.add_from_file(ui_filename)
43
# Owais Lone : To get quick access to icons and stuff.
44
def get_media_file(media_file_name):
45
media_filename = get_data_file('media', '%s' % (media_file_name,))
46
if not os.path.exists(media_filename):
49
return "file:///"+media_filename
53
self._q = Queue.Queue()
54
t = threading.Thread(target=self._do_task)
58
def add_task(self, task, name, reply, data = {}):
59
# incoming tasks - put into model loop
60
self._q.put([task, name, reply, data])
63
# this loop is outside of the gtk.main loop
65
task, name, reply, data = self._q.get()
67
task(name, reply, data) # call a model function or method
69
error_in_thread(task, name, reply, data)
72
def error_in_thread(task, name, reply, data):
74
response['reason'] = traceback.format_exc()
75
response['task'] = task
76
response['data'] = data
77
reply(name, 'error', response)