コード例 #1
0
ファイル: comix.py プロジェクト: Gosha/Comix
def run():
    """Run the program."""
    # Use gettext translations as found in the source dir, otherwise based on
    # the install path.
    exec_path = os.path.abspath(sys.argv[0])
    base_dir = os.path.dirname(os.path.dirname(exec_path))
    if os.path.isdir(os.path.join(base_dir, 'messages')):
        gettext.install('comix', os.path.join(base_dir, 'messages'),
            unicode=True)
    else:
        gettext.install('comix', os.path.join(base_dir, 'share/locale'),
            unicode=True)

    animate_gifs = False
    fullscreen = False
    show_library = False
    open_path = None
    open_page = 1
    try:
        opts, args = getopt.gnu_getopt(sys.argv[1:], 'fhla',
            ['fullscreen', 'help', 'library', 'animate-gifs'])
    except getopt.GetoptError:
        print_help()
    for opt, value in opts:
        if opt in ('-h', '--help'):
            print_help()
        elif opt in ('-f', '--fullscreen'):
            fullscreen = True
        elif opt in ('-l', '--library'):
            show_library = True
        if opt in ('-a', '--animate-gifs'):
            animate_gifs = True

    if not os.path.exists(constants.DATA_DIR):
        os.makedirs(constants.DATA_DIR, 0700)
    if not os.path.exists(constants.CONFIG_DIR):
        os.makedirs(constants.CONFIG_DIR, 0700)
    deprecated.move_files_to_xdg_dirs()
    preferences.read_preferences_file()
    icons.load_icons()

    if len(args) >= 1:
        open_path = os.path.abspath(args[0])  # try to open whatever it is.
    elif preferences.prefs['auto load last file']:
        open_path = preferences.prefs['path to last file']
        open_page = preferences.prefs['page of last file']

    window = main.MainWindow(animate_gifs=animate_gifs,
        fullscreen=fullscreen, show_library=show_library,
        open_path=open_path, open_page=open_page)
    deprecated.check_for_deprecated_files(window)

    def sigterm_handler(signal, frame):
        gobject.idle_add(window.terminate_program)
    signal.signal(signal.SIGTERM, sigterm_handler)

    try:
        gtk.main()
    except KeyboardInterrupt: # Will not always work because of threading.
        window.terminate_program()
コード例 #2
0
ファイル: comix.py プロジェクト: sergey-dryabzhinsky/Comix
def run():
    """Run the program."""
    # Use gettext translations as found in the source dir, otherwise based on
    # the install path.
    exec_path = os.path.abspath(sys.argv[0])
    base_dir = os.path.dirname(os.path.dirname(exec_path))
    if os.path.isdir(os.path.join(base_dir, 'messages')):
        gettext.install('comix',
                        os.path.join(base_dir, 'messages'),
                        unicode=True)
    else:
        gettext.install('comix',
                        os.path.join(base_dir, 'share/locale'),
                        unicode=True)

    animate_gifs = False
    fullscreen = False
    show_library = False
    open_path = None
    open_page = 1
    try:
        opts, args = getopt.gnu_getopt(
            sys.argv[1:], 'fhla',
            ['fullscreen', 'help', 'library', 'animate-gifs'])
    except getopt.GetoptError:
        print_help()
    for opt, value in opts:
        if opt in ('-h', '--help'):
            print_help()
        elif opt in ('-f', '--fullscreen'):
            fullscreen = True
        elif opt in ('-l', '--library'):
            show_library = True
        if opt in ('-a', '--animate-gifs'):
            animate_gifs = True

    if not os.path.exists(constants.DATA_DIR):
        os.makedirs(constants.DATA_DIR, 0700)
    if not os.path.exists(constants.CONFIG_DIR):
        os.makedirs(constants.CONFIG_DIR, 0700)
    deprecated.move_files_to_xdg_dirs()
    preferences.read_preferences_file()
    icons.load_icons()

    if len(args) >= 1:
        open_path = os.path.abspath(args[0])  # try to open whatever it is.
    elif preferences.prefs['auto load last file']:
        open_path = preferences.prefs['path to last file']
        open_page = preferences.prefs['page of last file']

    window = main.MainWindow(animate_gifs=animate_gifs,
                             fullscreen=fullscreen,
                             show_library=show_library,
                             open_path=open_path,
                             open_page=open_page)
    deprecated.check_for_deprecated_files(window)

    def sigterm_handler(signal, frame):
        gobject.idle_add(window.terminate_program)

    signal.signal(signal.SIGTERM, sigterm_handler)

    try:
        gtk.main()
    except KeyboardInterrupt:  # Will not always work because of threading.
        window.terminate_program()
コード例 #3
0
ファイル: comix.py プロジェクト: incandescant/comix
def run():
    """Run the program."""
    # Use gettext translations as found in the source dir, otherwise based on
    # the install path.
    exec_path = os.path.abspath(sys.argv[0])
    base_dir = os.path.dirname(os.path.dirname(exec_path))
    if os.path.isdir(os.path.join(base_dir, 'messages')):
        gettext.install('comix', os.path.join(base_dir, 'messages'),
            unicode=True)
    else:
        gettext.install('comix', os.path.join(base_dir, 'share/locale'),
            unicode=True)

    fullscreen = False
    show_library = False
    open_path = None
    open_page = 1
    try:
        opts, args = getopt.gnu_getopt(sys.argv[1:], 'fhl',
            ['fullscreen', 'help', 'library'])
    except getopt.GetoptError:
        print_help()
    for opt, value in opts:
        if opt in ('-h', '--help'):
            print_help()
        elif opt in ('-f', '--fullscreen'):
            fullscreen = True
        elif opt in ('-l', '--library'):
            show_library = True

    if not os.path.exists(constants.DATA_DIR):
        os.makedirs(constants.DATA_DIR, 0700)
    if not os.path.exists(constants.CONFIG_DIR):
        os.makedirs(constants.CONFIG_DIR, 0700)
    deprecated.move_files_to_xdg_dirs()
    preferences.read_preferences_file()

    GLib.set_application_name("Comix")
    Gtk.Window.set_default_icon_name("comix");

    icons.load_icons()
    
    if len(args) >= 1:
        param_path = os.path.abspath(args[0])
        if os.path.isdir(param_path):
            dir_files = os.listdir(param_path)
            dir_files.sort(locale.strcoll)
            for filename in dir_files:
                full_path = os.path.join(param_path, filename)
                if filehandler.is_image_file(full_path):
                    open_path = full_path
                    break
        else:
            open_path = param_path
    elif preferences.prefs['auto load last file']:
        open_path = preferences.prefs['path to last file']
        open_page = preferences.prefs['page of last file']
    
    window = main.MainWindow(fullscreen=fullscreen, show_library=show_library,
        open_path=open_path, open_page=open_page)
    deprecated.check_for_deprecated_files(window)
    try:
        Gtk.main()
    except KeyboardInterrupt: # Will not always work because of threading.
        window.terminate_program()
コード例 #4
0
ファイル: comix.py プロジェクト: foxes485/comix
def run():
    """Run the program."""
    # Use gettext translations as found in the source dir, otherwise based on
    # the install path.
    exec_path = os.path.abspath(sys.argv[0])
    base_dir = os.path.dirname(os.path.dirname(exec_path))
    if os.path.isdir(os.path.join(base_dir, 'messages')):
        gettext.install('comix', os.path.join(base_dir, 'messages'),
            unicode=True)
    else:
        gettext.install('comix', os.path.join(base_dir, 'share/locale'),
            unicode=True)

    fullscreen = False
    show_library = False
    open_path = None
    open_page = 1
    try:
        opts, args = getopt.gnu_getopt(sys.argv[1:], 'fhl',
            ['fullscreen', 'help', 'library'])
    except getopt.GetoptError:
        print_help()
    for opt, value in opts:
        if opt in ('-h', '--help'):
            print_help()
        elif opt in ('-f', '--fullscreen'):
            fullscreen = True
        elif opt in ('-l', '--library'):
            show_library = True

    if not os.path.exists(constants.DATA_DIR):
        os.makedirs(constants.DATA_DIR, 0700)
    if not os.path.exists(constants.CONFIG_DIR):
        os.makedirs(constants.CONFIG_DIR, 0700)
    deprecated.move_files_to_xdg_dirs()
    preferences.read_preferences_file()
    icons.load_icons()
    
    if len(args) >= 1:
        param_path = os.path.abspath(args[0])
        if os.path.isdir(param_path):
            dir_files = os.listdir(param_path)
            dir_files.sort(locale.strcoll)
            for filename in dir_files:
                full_path = os.path.join(param_path, filename)
                if filehandler.is_image_file(full_path):
                    open_path = full_path
                    break
        else:
            open_path = param_path
    elif preferences.prefs['auto load last file']:
        open_path = preferences.prefs['path to last file']
        open_page = preferences.prefs['page of last file']
    
    window = main.MainWindow(fullscreen=fullscreen, show_library=show_library,
        open_path=open_path, open_page=open_page)
    deprecated.check_for_deprecated_files(window)
    try:
        gtk.main()
    except KeyboardInterrupt: # Will not always work because of threading.
        window.terminate_program()