Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 77cc76b0a5
Fetching contributors…

Cannot retrieve contributors at this time

executable file 93 lines (77 sloc) 3.026 kb
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
#!/usr/bin/python
# labyrinth
# This file is part of Labyrinth
#
# Copyright (C) 2006 - Don Scorgie <Don@Scorgie.org>
# Copyright (C) 2008 - Labyrinth-Dev-Team
#
# Labyrinth 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.
#
# Labyrinth 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 Labyrinth; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA
#

import pygtk
import gettext, locale
import optparse
import sys, os
import os.path as osp

if os.name != 'nt':
    pygtk.require('2.0')

import gtk

from labyrinth_lib import utils
from labyrinth_lib import Browser
try:
    from labyrinth_lib import defs
    localedir = osp.abspath(osp.join(defs.DATA_DIR, "locale"))
except:
    localedir = "/usr/share/locale"

gettext.bindtextdomain('labyrinth', localedir)
if hasattr(gettext, 'bind_textdomain_codeset'):
    gettext.bind_textdomain_codeset('labyrinth','UTF-8')

gettext.textdomain('labyrinth')

if hasattr(locale, 'bindtextdomain'):
    if not os.name == 'nt':
        locale.bindtextdomain('labyrinth', localedir)
        if hasattr(locale, 'bind_textdomain_codeset'):
            locale.bind_textdomain_codeset('labyrinth','UTF-8')
        locale.textdomain('labyrinth')


gtk.glade.bindtextdomain('labyrinth')
gtk.glade.textdomain('labyrinth')


def main():
    parser = optparse.OptionParser()
    parser.add_option("--use-tray-icon", dest="tray_icon",
            action="store_true", default=False)
    parser.add_option("--no-tray-icon", dest="tray_icon", action="store_false")
    parser.add_option("--hide-main-window", action="store_true", default=False)
    parser.add_option("-m", "--map", action="store", type="string", dest="filename",
            help="Open a map from a given filename (from internal database)")
    parser.add_option("-o", "--open", action="store", type="string",
            dest="filepath", help="Open a map from a given filename (including path)")

    (options, args) = parser.parse_args()
    if not options.tray_icon:
        options.hide_main_window=False

    MapBrowser = Browser.Browser (
            start_hidden = options.hide_main_window,
            tray_icon = options.tray_icon
    )

    if options.filename != None:
        MapBrowser.open_map_filename (os.path.join (utils.get_save_dir(), options.filename))
    elif options.filepath != None:
        MapBrowser.open_map_filename (options.filepath)

    try:
        gtk.main()
    except:
        print "Exception caught while running. Dying a death."
        sys.exit(1)

if __name__ == '__main__':
    main()
Something went wrong with that request. Please try again.