Fawkes API  Fawkes Development Version
config_editor.cpp
1 
2 /***************************************************************************
3  * config_editor.cpp - Fawkes Config Editor
4  *
5  * Created: Tue Sep 23 13:21:49 2008
6  * Copyright 2008 Daniel Beck
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #include "config_editor.h"
24 #include "config_tree_view.h"
25 #include "retriever_config_plugin.h"
26 #include "naostiffness_config_plugin.h"
27 
28 #include <gui_utils/service_selector_cbe.h>
29 #include <netcomm/fawkes/client.h>
30 
31 #include <cstdlib>
32 #include <cstring>
33 #include <iostream>
34 
35 using namespace std;
36 using namespace fawkes;
37 
38 /** @class FawkesConfigEditor "config_editor.h"
39  * Graphical configuration editor.
40  *
41  * @author Daniel Beck
42  */
43 
44 /** Constructor.
45  * @param builder Gtk builder
46  */
47 FawkesConfigEditor::FawkesConfigEditor(Glib::RefPtr<Gtk::Builder> builder)
48 {
49  builder->get_widget("wndMain", m_wnd_main);
50  builder->get_widget("btnExit", m_btn_exit);
51 
52  m_trv_config = NULL;
53  builder->get_widget_derived("trvConfig", m_trv_config);
54  m_trv_config->register_plugin( new RetrieverConfigPlugin( RESDIR"/guis/config_editor/retriever_config_plugin.ui" ) );
55  m_trv_config->register_plugin(new NaoStiffnessConfigPlugin(RESDIR"/guis/config_editor/naostiffness_config_plugin.ui"));
56 
57  m_btn_exit->signal_clicked().connect( sigc::mem_fun( *this, &FawkesConfigEditor::on_btn_exit_clicked) );
58 
59  m_service_selector = new ServiceSelectorCBE(builder, "cbeHosts", "btnConnect");
60  m_service_selector->signal_connected().connect(sigc::mem_fun(*this, &FawkesConfigEditor::on_connected));
61  m_service_selector->signal_disconnected().connect(sigc::mem_fun( *this, &FawkesConfigEditor::on_disconnected));
62 }
63 
64 /** Destructor. */
66 {
67  delete m_service_selector;
68 }
69 
70 /** Obtain a reference to the main window of the application.
71  * @return reference to the main window
72  */
73 Gtk::Window&
75 {
76  return *m_wnd_main;
77 }
78 
79 void
80 FawkesConfigEditor::on_btn_exit_clicked()
81 {
82  m_wnd_main->hide();
83 }
84 
85 void
86 FawkesConfigEditor::on_connected()
87 {
88  m_network_client = m_service_selector->get_network_client();
89  m_trv_config->set_network_client( m_network_client );
90  m_wnd_main->set_title("Fawkes Config Editor @ " + m_service_selector->get_name());
91 }
92 
93 void
94 FawkesConfigEditor::on_disconnected()
95 {
96  m_trv_config->set_network_client( NULL );
97  m_wnd_main->set_title("Fawkes Config Editor");
98 }
FawkesConfigEditor(Glib::RefPtr< Gtk::Builder > builder)
Constructor.
Fawkes library namespace.
STL namespace.
Gtk::Window & get_window() const
Obtain a reference to the main window of the application.
Config editor plugin for the fvretriever plugin.
~FawkesConfigEditor()
Destructor.
Config editor plugin for the Nao joint stiffness values.
This widget consists of a Gtk::ComboBox and a Gtk::Button.