#! /usr/bin/ruby

=begin

This file is part of Teatime.

Teatime 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,
version 3 of the License.

Teatime 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
Teatime. If not, see http://www.gnu.org/licenses/.


Copyright 1998-2009 Detlef Reichl  detlef!reichl()gmx!org

=end


require 'panelapplet2'
require 'teatime'

OAFIID = "OAFIID:GNOME_TeatimeApplet3_Factory"
oafiid = OAFIID
run_in_window = (ARGV.length == 1 && ARGV.first == "run-in-window")
oafiid += "_debug" if run_in_window


init = proc do |applet, iid|
    applet.add_preferences '/schemas/apps/teatime_applet_3/prefs'
    applet.set_flags PanelApplet::EXPAND_MINOR
    gui = Teatime::Applet.new applet, run_in_window
    applet << gui.area
    applet.show_all
    true
end


PanelApplet.main oafiid, "Teatime", "3.0", &init

if run_in_window
    window = Gtk::Window.new
    window.set_title "Teatime Applet"
    window.set_default_size 64, 64
    window.signal_connect(:destroy) { Gtk::main_quit }
    app = PanelApplet.new
    init.call app, oafiid
    app.reparent window
    window.show_all
    Gtk.main
end

