- Preferences completed.

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1032 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
matrevis 2006-09-07 00:23:50 +00:00
parent 3dbb0dbd80
commit 6458511399
4 changed files with 54 additions and 13 deletions

View File

@ -230,7 +230,6 @@
<child>
<widget class="GtkButton" id="Plugins.Remove">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-remove</property>
@ -475,7 +474,6 @@
<child>
<widget class="GtkButton" id="Policies.Remove">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-remove</property>

View File

@ -194,6 +194,12 @@ GlobalPreferences::key_file_read(KeyFile& kf)
_mod_dirs.clear();
_pol_dirs.clear();
std::vector<Glib::ustring> old_mod_dirs(1, PLUGDIR);
std::vector<Glib::ustring> old_pol_dirs(1, POLDIR);
_mod_dirs = old_mod_dirs;
_pol_dirs = old_pol_dirs;
// read speed
{
int new_speed = 1000; // use a default value
@ -218,7 +224,7 @@ GlobalPreferences::key_file_read(KeyFile& kf)
ostr << "modules-dir-" << i;
Glib::ustring key(ostr.str());
val = kf.search_value(key);
if (val)
if (val && *val != _mod_dirs[0])
{
// add_modules_dir(*val);
_mod_dirs.push_back(*val);
@ -241,7 +247,7 @@ GlobalPreferences::key_file_read(KeyFile& kf)
ostr << "policies-dir-" << i;
Glib::ustring key(ostr.str().c_str());
val = kf.search_value(key);
if (val)
if (val && *val != _pol_dirs[0])
{
// add_policies_dir(*val);
_pol_dirs.push_back(*val);

View File

@ -82,7 +82,7 @@ PreferencesEditor::PreferencesEditor(const std::string& gladefile)
// List of the policies search paths
// List of the plugins search paths
// set up the model
Gtk::TreeModelColumnRecord column_record_plugins_dirs;
@ -95,6 +95,7 @@ PreferencesEditor::PreferencesEditor(const std::string& gladefile)
_refXml->get_widget("Plugins.Additional.TreeView", plugins_dirs_treeview);
plugins_dirs_treeview->set_model(plugins_dirs_model);
plugins_dirs_treeview->append_column("path", single_column);
plugins_dirs_treeview->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
// update the model with the backend information
typedef std::vector<Glib::ustring> Strings;
@ -108,7 +109,7 @@ PreferencesEditor::PreferencesEditor(const std::string& gladefile)
{
// append one record to the model, describing the path
// note that plugin dirs are returned in reverse order
Gtk::TreeModel::iterator new_row = plugins_dirs_model->prepend();
Gtk::TreeModel::iterator new_row = plugins_dirs_model->append();
new_row->set_value(0, *i_pd);
}
// when the model gets updated, the associated TreeView
@ -169,6 +170,7 @@ PreferencesEditor::PreferencesEditor(const std::string& gladefile)
_refXml->get_widget("Policies.Additional.TreeView", policies_dirs_treeview);
policies_dirs_treeview->set_model(policies_dirs_model);
policies_dirs_treeview->append_column("path", column_path_policies_dirs);
policies_dirs_treeview->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
// update the model with the backend information
typedef std::vector<Glib::ustring> Strings;
@ -182,7 +184,7 @@ PreferencesEditor::PreferencesEditor(const std::string& gladefile)
{
// append one record to the model, describing the path
// note that policies dirs are returned in reverse order
Gtk::TreeModel::iterator new_row = policies_dirs_model->prepend();
Gtk::TreeModel::iterator new_row = policies_dirs_model->append();
new_row->set_value(0, *i_pd);
}
// when the model gets updated, the associated TreeView
@ -319,7 +321,8 @@ PreferencesEditor::on_add_plugins_dir()
if (response == Gtk::RESPONSE_OK)
{
path = ask_path->get_filename();
GlobalPreferences::get_instance().add_modules_dir(path);
std::vector<Glib::ustring>& modules = GlobalPreferences::get_instance().get_plugin_dirs();
modules.push_back(path);
Gtk::TreeModel::iterator new_row = plugins_dirs_model->append();
new_row->set_value(0, path);
@ -331,7 +334,23 @@ PreferencesEditor::on_add_plugins_dir()
void
PreferencesEditor::on_remove_plugins_dir()
{
// Feature not supported by backend
std::vector<Glib::ustring>& modules = GlobalPreferences::get_instance().get_plugin_dirs();
std::vector<Glib::ustring>::iterator mit = modules.begin();
Glib::RefPtr<const Gtk::TreeSelection> selection = plugins_dirs_treeview->get_selection();
Gtk::TreeModel::iterator pit = plugins_dirs_model->children().begin();
while(pit && mit != modules.end())
{
if(selection->is_selected(pit))
{
modules.erase(mit);
pit = plugins_dirs_model->erase(pit);
}
else
{
mit++;
pit++;
}
}
}
@ -352,7 +371,8 @@ PreferencesEditor::on_add_policies_dir()
if (response == Gtk::RESPONSE_OK)
{
path = ask_path->get_filename();
GlobalPreferences::get_instance().add_policies_dir(path);
std::vector<Glib::ustring>& policies = GlobalPreferences::get_instance().get_policy_dirs();
policies.push_back(path);
Gtk::TreeModel::iterator new_row = policies_dirs_model->append();
new_row->set_value(0, path);
@ -364,7 +384,24 @@ PreferencesEditor::on_add_policies_dir()
void
PreferencesEditor::on_remove_policies_dir()
{
// Feature not supported by backend
std::vector<Glib::ustring>& policies = GlobalPreferences::get_instance().get_policy_dirs();
std::vector<Glib::ustring>::iterator mit = policies.begin();
Glib::RefPtr<const Gtk::TreeSelection> selection = policies_dirs_treeview->get_selection();
Gtk::TreeModel::iterator pit = policies_dirs_model->children().begin();
while(pit && mit != policies.end())
{
if(selection->is_selected(pit))
{
policies.erase(mit);
pit = policies_dirs_model->erase(pit);
}
else
{
mit++;
pit++;
}
}
}

View File

@ -103,7 +103,7 @@ parse_options(int argc, char** argv)
GlobalPreferences& prefs = GlobalPreferences::get_instance();
try
{
//prefs.load_configrc();
prefs.load_configrc();
}
catch (std::exception e)