#!/usr/bin/env python
#
# $Id: lookuplet,v 1.3 2003/11/28 21:34:59 mdb Exp $
# 
# lookuplet - a utility for quickly looking up information
# Copyright (C) 2001 Michael Bayne
# 
# This program 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 2.1 of the License, or (at your
# option) any later version.
# 
# This program 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, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

import string
import sys
import re
import os

import pygtk
pygtk.require('2.0')

import gnome.applet
import gtk
import gtk.glade

# figure out where we were run from
basedir = sys.argv[0];
basedir = re.sub("/lookuplet$", "", basedir);
basedir = re.sub("/bin$", "", basedir);
libdir = basedir + "/share/lookuplet";

# add our library directory to the system path
sys.path.append(libdir);

import bindings
import lookuplet
import properties

# load up our glade UI definition
try:
    os.stat(basedir + "/lookuplet.glade");
    xmlui = gtk.glade.XML(basedir + "/lookuplet.glade");
except OSError:
    os.stat(libdir + "/lookuplet.glade");
    xmlui = gtk.glade.XML(libdir + "/lookuplet.glade");

# load up our bindings
bindings = bindings.BindingSet();

# figure out if we're an applet or not
appletMode = 0;
for arg in sys.argv:
    if (arg.find("activate-goad-server") != -1):
        appletMode = 1

# create our properties manager
props = properties.Properties(xmlui, bindings);

# create our primary user interface
lookuplet = lookuplet.Lookuplet(xmlui, bindings, props, appletMode);

# let GTK do its business
gtk.mainloop();
