/* Copyright 2005 Nicholas Bishop * * This file is part of SharpConstruct. * * SharpConstruct 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. * * SharpConstruct 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 SharpConstruct; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "InputDialog.hh" #include "Preferences.h" #include "Utilities.h" #include #include using SharpConstruct::GInterface::InputDialog; InputDialog::InputDialog() { widget_.get_close_button()->signal_clicked().connect( sigc::mem_fun( *this, &InputDialog::Close ) ); widget_.get_save_button()->hide(); } InputDialog::~InputDialog() { Save(); } void InputDialog::Close() { widget_.hide(); Save(); } void InputDialog::Save() { std::list< Glib::RefPtr< const Gdk::Device > > devices( widget_.get_display()->list_devices() ); for( std::list< Glib::RefPtr< const Gdk::Device > >::iterator i = devices.begin(); i != devices.end(); i++ ) { Preferences::Instance().Set( StripSpaces( ( *i )->get_name() ) + "Mode", ( *i )->get_mode() ); } } void InputDialog::Show() { widget_.show(); } void InputDialog::Initialize() { //std::cout << "ID Init" << std::endl; if( !widget_.is_realized() ) return; Glib::RefPtr< Gdk::Display > display( Gdk::DisplayManager::get()->get_default_display() ); if( !display ) return; std::list< Glib::RefPtr< Gdk::Device > > devices( display->list_devices() ); for( std::list< Glib::RefPtr< Gdk::Device > >::iterator i = devices.begin(); i != devices.end(); i++ ) { const int mode( Preferences::Instance().Get( StripSpaces( ( *i )->get_name() ) + "Mode", 1 ) ); Gdk::InputMode enmode; if( mode == 1 ) enmode = Gdk::MODE_SCREEN; else if( mode == 2 ) enmode = Gdk::MODE_WINDOW; else enmode = Gdk::MODE_DISABLED; ( *i )->set_mode( enmode ); } }