~guadalinex-members/gnome-gcs/trunk

« back to all changes in this revision

Viewing changes to gnome_gcs/helpers.py

  • Committer: David Amian
  • Date: 2010-09-15 10:43:40 UTC
  • Revision ID: amialinux@gmail.com-20100915104340-snp72x7cg5hubxjf
Initial project creation with Quickly!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
### BEGIN LICENSE
 
3
# This file is in the public domain
 
4
### END LICENSE
 
5
 
 
6
"""Helpers for an Ubuntu application."""
 
7
 
 
8
__all__ = [
 
9
    'make_window',
 
10
    ]
 
11
 
 
12
import os
 
13
import gtk
 
14
 
 
15
from gnome_gcs.gnome_gcsconfig import get_data_file
 
16
 
 
17
import gettext
 
18
from gettext import gettext as _
 
19
gettext.textdomain('gnome-gcs')
 
20
 
 
21
def get_builder(builder_file_name):
 
22
    """Return a fully-instantiated gtk.Builder instance from specified ui 
 
23
    file
 
24
    
 
25
    :param builder_file_name: The name of the builder file, without extension.
 
26
        Assumed to be in the 'ui' directory under the data path.
 
27
    """
 
28
    # Look for the ui file that describes the user interface.
 
29
    ui_filename = get_data_file('ui', '%s.ui' % (builder_file_name,))
 
30
    if not os.path.exists(ui_filename):
 
31
        ui_filename = None
 
32
 
 
33
    builder = gtk.Builder()
 
34
    builder.set_translation_domain('gnome-gcs')
 
35
    builder.add_from_file(ui_filename)
 
36
    return builder