Codebase list mirage / e58b891 bin / mirage
e58b891

Tree @e58b891 (Download .tar.gz)

mirage @e58b891raw · history · blame

#!/usr/bin/env python
"""Mirage is a fast GTK+ Image Viewer
"""

__author__ = "Scott Horowitz"
__email__ = "stonecrest@gmail.com"
__license__ = """
Mirage, a simple GTK+ Image Viewer
Copyright 2007 Scott Horowitz <stonecrest@gmail.com>

This file is part of Mirage.

Mirage 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 3 of the License, or
(at your option) any later version.

Mirage 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, see <http://www.gnu.org/licenses/>.
"""

import os

from gi.repository import Gdk


def get_mirage_source_dir():
    mirage_bin_dir = os.path.dirname(os.path.realpath(__file__))
    mirage_source_dir = os.path.abspath(os.path.join(mirage_bin_dir, ".."))

    if os.path.exists(os.path.join(mirage_source_dir, "mirage", "__init__.py")):
        return mirage_source_dir

    return None


if __name__ == "__main__":
    mirage_source_dir = get_mirage_source_dir()
    uninstalled = mirage_source_dir is not None

    if uninstalled:
        import sys

        sys.path.insert(0, mirage_source_dir)

    import mirage

    app = mirage.Base()
    Gdk.threads_enter()

    try:
        app.run([])
    except KeyboardInterrupt:
        pass

    Gdk.threads_leave()