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
00025
00026
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
00063 ConfigAddDialog::ConfigAddDialog(Gtk::Entry *ent_path,
00064 Gtk::Entry *ent_value,
00065 Gtk::ComboBox *cob_bool_value,
00066 Gtk::Notebook *type_pages,
00067 Gtk::ComboBox *cmb_type,
00068 Gtk::CheckButton *chb_is_default)
00069 {
00070 m_ent_path = ent_path;
00071 m_cmb_type = cmb_type;
00072 m_ent_value = ent_value;
00073 m_cob_bool_value = cob_bool_value;
00074 m_type_pages = type_pages;
00075 m_chb_is_default = chb_is_default;
00076
00077 m_cmb_type->signal_changed().connect( sigc::mem_fun( *this, &ConfigAddDialog::on_my_changed) );
00078 }
00079
00080 #ifdef HAVE_GLADEMM
00081
00082
00083
00084
00085 ConfigAddDialog::ConfigAddDialog( BaseObjectType* cobject,
00086 const Glib::RefPtr<Gnome::Glade::Xml>& ref_xml )
00087 : Gtk::Dialog(cobject)
00088 {
00089 ref_xml->get_widget("entPathAdd", m_ent_path);
00090 ref_xml->get_widget("cmbTypeAdd", m_cmb_type);
00091 ref_xml->get_widget("entValueAdd", m_ent_value);
00092 ref_xml->get_widget("cmbBoolAdd", m_cob_bool_value);
00093 ref_xml->get_widget("nbkTypesAdd", m_type_pages);
00094 ref_xml->get_widget("chbIsDefaultAdd", m_chb_is_default);
00095
00096 m_cmb_type->signal_changed().connect( sigc::mem_fun( *this, &ConfigAddDialog::on_my_changed) );
00097 }
00098 #endif
00099
00100
00101 ConfigAddDialog::~ConfigAddDialog()
00102 {
00103 }
00104
00105
00106
00107
00108 void
00109 ConfigAddDialog::init(const Glib::ustring& path)
00110 {
00111 m_ent_path->set_text(path);
00112 m_ent_value->set_text("");
00113 m_cmb_type->set_active(-1);
00114 m_cob_bool_value->set_active(-1);
00115 m_chb_is_default->set_active(true);
00116 }
00117
00118
00119
00120
00121 Glib::ustring
00122 ConfigAddDialog::get_path() const
00123 {
00124 return m_ent_path->get_text();
00125 }
00126
00127
00128
00129
00130 Glib::ustring
00131 ConfigAddDialog::get_type() const
00132 {
00133 Gtk::TreeIter iter = m_cmb_type->get_active();
00134 Gtk::TreeRow row = *iter;
00135 Glib::ustring type;
00136
00137 row.get_value(0, type);
00138
00139 return type;
00140 }
00141
00142
00143
00144
00145 Glib::ustring
00146 ConfigAddDialog::get_value() const
00147 {
00148 if (get_type() != "bool") return m_ent_value->get_text();
00149 else
00150 {
00151 Gtk::TreeIter iter = m_cob_bool_value->get_active();
00152 Gtk::TreeRow row = *iter;
00153 Glib::ustring type;
00154
00155 row.get_value(0, type);
00156
00157 return type;
00158 }
00159 }
00160
00161
00162
00163
00164 bool
00165 ConfigAddDialog::get_is_default() const
00166 {
00167 return m_chb_is_default->get_active();
00168 }
00169
00170
00171
00172
00173 void
00174 ConfigAddDialog::on_my_changed()
00175 {
00176 m_type_pages->set_current_page(get_type() != "bool" ? 0 : 1);
00177 }