File: main.py

package info (click to toggle)
gnome-specimen 0.4-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,024 kB
  • ctags: 85
  • sloc: sh: 3,510; python: 569; makefile: 133
file content (69 lines) | stat: -rw-r--r-- 2,226 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# GNOME Specimen, a font preview application for GNOME
# Copyright (C) 2006--2007  Wouter Bolsterlee <wbolster@gnome.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

import sys

def exit_with_error(msg, e):
    sys.stderr.write('Error: %s (%s)\n' % (msg, str(e)))
    sys.exit(1)

def main(args):
    import gettext

    # Check module dependencies at run time instead of at build time. See
    # http://uwstopia.nl/blog/2006/11/using-autotools-to-detect-python-modules
    # for more information.
    try:
        import pygtk; pygtk.require('2.0')
        import gtk
    except (ImportError, AssertionError), e:
        exit_with_error('Importing pygtk and gtk modules failed',  e)

    try:
        import gtk.glade
    except ImportError, e:
        exit_with_error('Importing gtk.glade module failed',  e)

    try:
        import gnome
    except ImportError, e:
        exit_with_error('Importing gnome module failed',  e)

    try:
        import gconf
    except ImportError, e:
        exit_with_error('Importing gconf module failed',  e)


    import specimen.config as config

    gettext.bindtextdomain(config.PACKAGE, config.LOCALEDIR)
    gettext.textdomain(config.PACKAGE)
    gtk.glade.bindtextdomain(config.PACKAGE, config.LOCALEDIR)
    gtk.glade.textdomain(config.PACKAGE)

    prog = gnome.program_init(config.PACKAGE, config.VERSION)

    gtk.window_set_default_icon_name('gnome-specimen')

    from specimenwindow import SpecimenWindow
    w = SpecimenWindow()
    try:
        gtk.main ()
    except (KeyboardInterrupt):
        pass