#!/usr/bin/python
# -*- coding: utf-8 -*-
import gtk
import gettext
import sys
import os
import gnomevfs
import shutil
from TextFlow.ui.MainWindow import MainWindow
from TextFlow.core import constants

def get_paths(uris):
    paths = []
    for i in uris:
        if i.startswith("file://"):
            if gnomevfs.exists(i):
                file_path = gnomevfs.get_local_path_from_uri(i)
            else:
                continue
        else:
            file_path = os.path.abspath(i)
            if not os.path.exists(file_path):
                continue
            
        paths.append(file_path)
        
    return paths


#Internationalization stuff...
#APP='textflow'
#DIR='/usr/share/locale'

#gettext.bindtextdomain(APP, DIR)
#gettext.textdomain(APP)

#gtk.glade.bindtextdomain(APP, DIR)
#gtk.glade.textdomain(APP)
#End of internationalization stuff

# Verify snippets file
if not os.path.exists(constants.SNIPPETS_USER_DIR):
	shutil.copytree(constants.SNIPPETS_DIR, constants.HOME + '/.textflow/snippets')

args = sys.argv

if len(args) > 1:
    paths = get_paths(args[1:])
    print paths
    main_window = MainWindow(paths)
        
else:
    main_window = MainWindow()

gtk.main()

