config_add_dialog.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <tools/config_editor/config_add_dialog.h>
00024 #include <gui_utils/utils.h>
00025
00026 using namespace fawkes;
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 ConfigAddDialog::ConfigAddDialog( BaseObjectType* cobject,
00063 const Glib::RefPtr<Gnome::Glade::Xml>& ref_xml )
00064 : Gtk::Dialog(cobject)
00065 {
00066 m_ent_path = dynamic_cast<Gtk::Entry*>( get_widget(ref_xml, "entPathAdd") );
00067 m_cmb_type = dynamic_cast<Gtk::ComboBox*>( get_widget(ref_xml, "cmbTypeAdd") );
00068 m_ent_value = dynamic_cast<Gtk::Entry*>( get_widget(ref_xml, "entValueAdd") );
00069 m_cob_bool_value = dynamic_cast<Gtk::ComboBox*>( get_widget(ref_xml, "cmbBoolAdd") );
00070 m_type_pages = dynamic_cast<Gtk::Notebook*>( get_widget(ref_xml, "nbkTypesAdd") );
00071 m_chb_is_default = dynamic_cast<Gtk::CheckButton*>( get_widget(ref_xml, "chbIsDefaultAdd") );
00072
00073 m_cmb_type->signal_changed().connect( sigc::mem_fun( *this, &ConfigAddDialog::on_my_changed) );
00074 }
00075
00076
00077 ConfigAddDialog::~ConfigAddDialog()
00078 {
00079 }
00080
00081
00082
00083
00084 void
00085 ConfigAddDialog::init(const Glib::ustring& path)
00086 {
00087 m_ent_path->set_text(path);
00088 m_ent_value->set_text("");
00089 m_cmb_type->set_active(-1);
00090 m_cob_bool_value->set_active(-1);
00091 m_chb_is_default->set_active(true);
00092 }
00093
00094
00095
00096
00097 Glib::ustring
00098 ConfigAddDialog::get_path() const
00099 {
00100 return m_ent_path->get_text();
00101 }
00102
00103
00104
00105
00106 Glib::ustring
00107 ConfigAddDialog::get_type() const
00108 {
00109 Gtk::TreeIter iter = m_cmb_type->get_active();
00110 Gtk::TreeRow row = *iter;
00111 Glib::ustring type;
00112
00113 row.get_value(0, type);
00114
00115 return type;
00116 }
00117
00118
00119
00120
00121 Glib::ustring
00122 ConfigAddDialog::get_value() const
00123 {
00124 if (get_type() != "bool") return m_ent_value->get_text();
00125 else
00126 {
00127 Gtk::TreeIter iter = m_cob_bool_value->get_active();
00128 Gtk::TreeRow row = *iter;
00129 Glib::ustring type;
00130
00131 row.get_value(0, type);
00132
00133 return type;
00134 }
00135 }
00136
00137
00138
00139
00140 bool
00141 ConfigAddDialog::get_is_default() const
00142 {
00143 return m_chb_is_default->get_active();
00144 }
00145
00146
00147
00148
00149 void
00150 ConfigAddDialog::on_my_changed()
00151 {
00152 m_type_pages->set_current_page(get_type() != "bool" ? 0 : 1);
00153 }