# Path: conf.py
# CONF_FILE = os.path.join(urk.userpath,'urk.conf')
# def pprint(obj, depth=-2):
# def save(*args):


import sys #only needed for the stupid workaround
import os
import thread
import socket
import signal
import commands
import gobject
import gtk
import irc
import events
    import remote
import widgets
import windows
from conf import conf
    os_commands = ( #list of commands to search for for opening files
        ('xdg-open', ('xdg-open',)),
        ('/usr/bin/open', ('/usr/bin/open',)),
        ('gnome-open', ('gnome-open',)),
        ('kfmclient', ('kfmclient','exec')),
        ('sensible-browser', ('sensible-browser')),
        )
    def open_file(filename):
        flags = gobject.SPAWN_LEAVE_DESCRIPTORS_OPEN | gobject.SPAWN_SEARCH_PATH
        filename = str(filename) #gobject won't accept unicode strings
        if conf.get('open-file-command'):
            command = conf['open-file-command'].split(' ') + [filename]
            try:
                gobject.spawn_async(command,flags=flags)
            except OSError:
                print "Unable to start %s" % command
        elif open_file_cmd:
            try:
                command = open_file_cmd + (filename,)
                gobject.spawn_async(command,flags=flags)
            except OSError:
                print "Unable to start %s" % command
        else:
            paths = os.getenv("PATH") or os.defpath
            for cmdfile, cmd in os_commands:
                for path in paths.split(os.pathsep):
                    if os.access(os.path.join(path,cmdfile),os.X_OK):
                        globals()['open_file_cmd'] = cmd
                        try:
                            command = cmd + (filename,)

# Path: conf.py
# CONF_FILE = os.path.join(urk.userpath,'urk.conf')
# def pprint(obj, depth=-2):
# def save(*args):


# Path: platform/gtk/ui.py
import sys #only needed for the stupid workaround
import os
import thread
import socket
import signal
import commands
import gobject
import gtk
import irc
import events
    import remote
import widgets
import windows
from conf import conf

    os_commands = ( #list of commands to search for for opening files
        ('xdg-open', ('xdg-open',)),
        ('/usr/bin/open', ('/usr/bin/open',)),
        ('gnome-open', ('gnome-open',)),
        ('kfmclient', ('kfmclient','exec')),
        ('sensible-browser', ('sensible-browser')),
        )
    def open_file(filename):
        flags = gobject.SPAWN_LEAVE_DESCRIPTORS_OPEN | gobject.SPAWN_SEARCH_PATH
        filename = str(filename) #gobject won't accept unicode strings
        if conf.get('open-file-command'):
            command = conf['open-file-command'].split(' ') + [filename]
            try:
                gobject.spawn_async(command,flags=flags)
            except OSError:
                print "Unable to start %s" % command
        elif open_file_cmd:
            try:
                command = open_file_cmd + (filename,)
                gobject.spawn_async(command,flags=flags)
            except OSError:
                print "Unable to start %s" % command
        else:
            paths = os.getenv("PATH") or os.defpath
            for cmdfile, cmd in os_commands:
                for path in paths.split(os.pathsep):
                    if os.access(os.path.join(path,cmdfile),os.X_OK):
                        globals()['open_file_cmd'] = cmd
                        try:
                            command = cmd + (filename,)

                            gobject.spawn_async(command,flags=flags)