#!/bin/env python
# -*- coding: utf-8 -*-
 
import sys

#TODO: find a way not to put any absolute path in there
sys.path.append("/usr/share/apps/ginkgo/") 

from PyKDE4.kdecore import *
from PyKDE4.kdeui import *
from ginkgo.mainwindow import Ginkgo

class GinkgoApplication(KUniqueApplication):
    def __init__(self):
        super(KUniqueApplication, self).__init__(True, True)
        self.setApplicationName("Gingko")
        self.setWindowIcon(KIcon("nepomuk"))
        self.ginkgo = Ginkgo()
        self.ginkgo.show()
        
    def newInstance(self):
        args = KCmdLineArgs.parsedArgs()
        uris = []
        for index in range(0, args.count()):
            uris.append(args.url(index))
        args.clear()
        self.ginkgo.openResources(uris)
        return 0


if __name__ == "__main__":
    appName = "ginkgo"
    catalog = "ginkgo"
    programName = ki18n ("Ginkgo")
    copyright = ki18n("(c) 2010, Mandriva, Stéphane Laurière")
    version = "0.2.4"
    description = ki18n ("Ginkgo is a navigator for Nepomuk, the KDE semantic toolkit.")
    license = KAboutData.License_GPL_V2
    text = ki18n ("Ginkgo lets you create and explore links between your personal data such as e-mails, contacts, files, Web pages.")
    homePage = "http://nepomuk.kde.org"
    bugEmail = "http://bugs.rosalinux.ru/"

    aboutData = KAboutData (appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail)
    aboutData.addAuthor(ki18n ("Stéphane Laurière"), ki18n("Developer"), "slauriere@mandriva.com")
    aboutData.setProgramIconName("nepomuk")
    aboutData.setTranslator(ki18nc("NAME OF TRANSLATORS", "Your names"), ki18nc("EMAIL OF TRANSLATORS", "Your emails"))
    
    KCmdLineArgs.init (sys.argv, aboutData)

    options = KCmdLineOptions()
    options.add("+uri", ki18n("The URI of the resource annotate"));
    KCmdLineArgs.addCmdLineOptions(options)
    KUniqueApplication.addCmdLineOptions()

    if KUniqueApplication.start():
        app = GinkgoApplication()
        sys.exit(app.exec_())
