Package net.sf.gimme

Source Code of net.sf.gimme.PreferencesDialogHandler

/*
* AddDialogHandler.java 
*
* Copyright (C) 2008 Gimme
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/

package net.sf.gimme;

import net.sf.gimme.event.GUIEventListener;
import net.sf.gimme.event.GUIEventPipe;
import org.gnome.glade.XML;
import org.gnome.gtk.Button;
import org.gnome.gtk.SpinButton;
import org.gnome.gtk.Widget;
import org.gnome.gtk.Window;

/**
*
* @author aiden
*/
public class PreferencesDialogHandler implements GUIEventListener
{
    private XML glade;
    private final Window dialog;

    public PreferencesDialogHandler(XML glade)
    {
        this.glade = glade;

        dialog = (Window)glade.getWidget("wnd_preferences");
        dialog.showAll();

        Button ok = (Button)glade.getWidget("btn_ok1");
        ok.connect(new GUIEventPipe(this, "ok"));

        Button cancel = (Button)glade.getWidget("btn_cancel1");
        cancel.connect(new GUIEventPipe(this, "cancel"));

        SpinButton spinner = (SpinButton)glade.getWidget("spn_segments");
        spinner.setValue(Configuration.get().getNumberOfSegments());
    }

    public void onClicked(Widget widget, String userData)
    {
        if(userData.equals("ok"))
        {
            SpinButton spinner = (SpinButton)glade.getWidget("spn_segments");
            Configuration.get().setNumberOfSegments((int)spinner.getValue());
            dialog.hide();
        }
        else if(userData.equals("cancel"))
        {
            dialog.hide();
        }
    }
}
TOP

Related Classes of net.sf.gimme.PreferencesDialogHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.