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

#    This file is part of Gnomolicious.
#
#    Gnomolicious 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 of the License, or
#    (at your option) any later version.
#
#    Gnomolicious 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 Gnomolicious; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#    (C) 2005 Nicolas Évrard <nicoe@altern.org>

import sys
import gettext
import logging

import pygtk
pygtk.require('2.0')

import gtk
import gnome.applet

from gnomolicious.gnomolicious import GnomoliciousApplet


try:
    gettext.install('gnomolicious', '/usr/share/locale/', unicode=True)
except IOError:
    _ = lambda s: s

def init_logger():
    logger = logging.getLogger('gnomolicious')
    hdlr = logging.FileHandler('/tmp/gnomolicious.log')
    formatter = logging.Formatter('%(name)s:%(filename)s:%(lineno)d: %(message)s')
    hdlr.setFormatter(formatter)
    logger.addHandler(hdlr)
    logger.setLevel(logging.INFO)

def gnomolicious_start(applet, iid):
    GnomoliciousApplet(applet, iid)
    return gtk.TRUE

if __name__ == '__main__':
    init_logger()
    gnome.applet.bonobo_factory(
            "OAFIID:Gnomolicious_Factory",
            gnome.applet.Applet.__gtype__,
            _("Gnome applet for del.icio.us"), '0.1', gnomolicious_start)
