config_editor.cpp

00001 
00002 /***************************************************************************
00003  *  config_editor.cpp - Fawkes Config Editor
00004  *
00005  *  Created: Tue Sep 23 13:21:49 2008
00006  *  Copyright  2008  Daniel Beck
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #include "config_editor.h"
00024 #include "config_tree_view.h"
00025 #include "retriever_config_plugin.h"
00026 #include "naostiffness_config_plugin.h"
00027 
00028 #include <gui_utils/service_selector_cbe.h>
00029 #include <netcomm/fawkes/client.h>
00030 
00031 #include <cstdlib>
00032 #include <cstring>
00033 #include <iostream>
00034 
00035 using namespace std;
00036 using namespace fawkes;
00037 
00038 /** @class FawkesConfigEditor tools/config_editor/config_editor.h
00039  * Graphical configuration editor.
00040  *
00041  * @author Daniel Beck
00042  */
00043 
00044 /** Constructor.
00045  * @param ref_xml Glade XML file
00046  */
00047 FawkesConfigEditor::FawkesConfigEditor( Glib::RefPtr<Gnome::Glade::Xml> ref_xml )
00048 {
00049   ref_xml->get_widget("wndMain", m_wnd_main);
00050   ref_xml->get_widget("btnExit", m_btn_exit);
00051 
00052   m_trv_config = NULL;
00053   ref_xml->get_widget_derived("trvConfig", m_trv_config);
00054   m_trv_config->register_plugin( new RetrieverConfigPlugin( RESDIR"/guis/config_editor/retriever_config_plugin.glade" ) );
00055   m_trv_config->register_plugin(new NaoStiffnessConfigPlugin(RESDIR"/guis/config_editor/naostiffness_config_plugin.glade"));
00056 
00057   m_btn_exit->signal_clicked().connect( sigc::mem_fun( *this, &FawkesConfigEditor::on_btn_exit_clicked) );
00058 
00059   m_service_selector = new ServiceSelectorCBE(ref_xml, "cbeHosts", "btnConnect");
00060   m_service_selector->signal_connected().connect( sigc::mem_fun( *this, &FawkesConfigEditor::on_connected) );
00061   m_service_selector->signal_disconnected().connect( sigc::mem_fun( *this, &FawkesConfigEditor::on_disconnected) );
00062 }
00063 
00064 /** Destructor. */
00065 FawkesConfigEditor::~FawkesConfigEditor()
00066 {
00067   delete m_service_selector;
00068 }
00069 
00070 /** Obtain a reference to the main window of the application.
00071  * @return reference to the main window
00072  */
00073 Gtk::Window&
00074 FawkesConfigEditor::get_window() const
00075 {
00076   return *m_wnd_main;
00077 }
00078 
00079 void
00080 FawkesConfigEditor::on_btn_exit_clicked()
00081 {
00082   m_wnd_main->hide();
00083 }
00084 
00085 void
00086 FawkesConfigEditor::on_connected()
00087 {
00088   m_network_client = m_service_selector->get_network_client();
00089   m_trv_config->set_network_client( m_network_client );
00090   m_wnd_main->set_title("Fawkes Config Editor @ " + m_service_selector->get_name());
00091 }
00092 
00093 void
00094 FawkesConfigEditor::on_disconnected()
00095 {
00096   m_trv_config->set_network_client( NULL );
00097   m_wnd_main->set_title("Fawkes Config Editor");
00098 }

Generated on Tue Feb 22 13:31:30 2011 for Fawkes API by  doxygen 1.4.7