Beispiel #1
0
void
ConfigTreeView::read_config()
{
  if ( !m_config )
    { return; }

  m_config_tree->clear();

  m_config->lock();
  Configuration::ValueIterator* cit = m_config->iterator();
  while ( cit->next() )
    {
      if ( cit->is_bool() )
	{ set_value(cit->path(), cit->type(), cit->is_default(), cit->get_bool()); }
      else if ( cit->is_int() )
	{ set_value(cit->path(), cit->type(), cit->is_default(), cit->get_int()); }
      else if ( cit->is_uint() )
	{ set_value(cit->path(), cit->type(), cit->is_default(), cit->get_uint()); }
      else if ( cit->is_float() )
	{ set_value(cit->path(), cit->type(), cit->is_default(), cit->get_float()); }
      else if ( cit->is_string() )
	{ set_value(cit->path(), cit->type(), cit->is_default(), cit->get_string()); }
    }

  delete cit;
  m_config->unlock();
}
Beispiel #2
0
bool
ConfigTreeView::remove_entry(const Gtk::TreeIter& iter)
{
  bool ret_val = false;
  int result;
  Gtk::TreeModel::Row row = *iter;
  Glib::ustring type = row[m_config_record.type];
  bool is_default = row[m_config_record.is_default];

  if (type == "") //if type is empty the row is a directory -> return
    { ret_val = false; }
  else
    {
      Glib::ustring path = row[m_config_record.path];
      m_dlg_remove->init(path, is_default);

      Gtk::Window* parent = dynamic_cast<Gtk::Window*>( get_toplevel() );
      m_dlg_remove->set_transient_for(*parent);
      result = m_dlg_remove->run();

      switch (result)
	{
	case Gtk::RESPONSE_OK:
	  {
	    const char* p = path.c_str();
	    bool rem_default = m_dlg_remove->get_remove_default();
	    m_config->erase(p);
	    if (rem_default) m_config->erase_default(p);

	    Gtk::TreePath tree_path = m_config_tree->get_path(iter);
  	    m_config_tree->erase(iter);
	    m_config_tree->row_deleted(tree_path);

	    Configuration::ValueIterator* cit = m_config->search(p);
	    if (!rem_default && cit->next()) //reenter the default value
	      {
                if ( cit->is_bool() )
                  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_bool()); }
                else if ( cit->is_int() )
                  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_int()); }
                else if ( cit->is_uint() )
                  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_uint()); }
                else if ( cit->is_float() )
                  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_float()); }
                else if ( cit->is_string() )
                  { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_string()); }
	      }

	    break;
	  }

	default:
	  ret_val = false;
	  break;
	}

      m_dlg_remove->hide();
    }

  return ret_val;
}