- Added preferences load/save feature.

altough till lacking exception handling
  if no sgpem.cfg file is present, segmentation fault
  therefore no loading is ever done by now.


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@979 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
matrevis 2006-09-01 00:58:12 +00:00
parent 58cf50b500
commit 0912042b50
5 changed files with 717 additions and 453 deletions

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,7 @@
#include "string_utils.hh"
#include <sstream>
// Do not include in header file:
#include "singleton.tcc"
using namespace sgpem;
@ -238,7 +239,7 @@ GlobalPreferences::key_file_read(KeyFile& kf)
{
std::ostringstream ostr;
ostr << "policies-dir-" << i;
Glib::ustring key(ostr.str());
Glib::ustring key(ostr.str().c_str());
val = kf.search_value(key);
if (val)
{
@ -276,14 +277,14 @@ GlobalPreferences::key_file_write(KeyFile& kf)
std::ostringstream ostr;
n++;
ostr << "modules-dir-" << n; // << std::ends;
Glib::ustring key(ostr.str());
Glib::ustring key(ostr.str().c_str());
kf.insert_key_value(key, (*iter));
++iter;
}
Glib::ustring key("modules-dir-number");
std::ostringstream ostr;
ostr << n << std::ends;
Glib::ustring value(ostr.str());
Glib::ustring value(ostr.str().c_str());
kf.insert_key_value(key, value);
}
// add policies directories
@ -299,14 +300,14 @@ GlobalPreferences::key_file_write(KeyFile& kf)
std::ostringstream ostr;
n++;
ostr << "policies-dir-" << n; // << std::ends;
Glib::ustring key(ostr.str());
Glib::ustring key(ostr.str().c_str());
kf.insert_key_value(key, (*iter));
++iter;
}
Glib::ustring key("policies-dir-number");
std::ostringstream ostr;
ostr << n << std::ends;
Glib::ustring value(ostr.str());
Glib::ustring value(ostr.str().c_str());
kf.insert_key_value(key, value);
}
}

View File

@ -133,6 +133,7 @@ void
PreferencesEditor::on_close()
{
preferences_dialog->hide();
prefs.write_configrc();
}
void

View File

@ -101,6 +101,16 @@ parse_options(int argc, char** argv)
Gtk::Main main_loop(argc, argv, context);
GlobalPreferences& prefs = GlobalPreferences::get_instance();
try
{
//prefs.load_configrc();
}
catch (std::exception e)
{
std::cout << std::endl
<< _("Error while loading preferences") << std::endl;
}
for (Glib::OptionGroup::vecustrings::const_iterator it = policies_dir_val.begin();
it != policies_dir_val.end(); ++it)

View File

@ -298,7 +298,6 @@ ResourcesWidget::_on_cell_name_data(Gtk::CellRenderer* cr,
<< "</span>" << " ("
<< (sr.get_length() - sr.get_remaining_time())
<< "/" << sr.get_length() << ")";
++index;
}
oss << "</small>";