コード例 #1
1
bool dialog_localsettings::load()
{
    string settingsfile = Glib::get_home_dir() + "/.gutorrent";

    Glib::KeyFile kf;

    if(kf.load_from_file(settingsfile, Glib::KEY_FILE_KEEP_COMMENTS | Glib::KEY_FILE_KEEP_TRANSLATIONS) == false) return false;
    eHost->set_text(kf.get_string("gutorrent", "host"));
    eUserName->set_text(kf.get_string("gutorrent", "username"));
    ePassword->set_text(kf.get_string("gutorrent", "password"));
    sUpdateInterval->set_value(kf.get_integer("gutorrent", "update_interval"));
}
コード例 #2
0
ファイル: settings.cpp プロジェクト: Tyndi/3dprint
void Settings::load_settings (Glib::RefPtr<Gio::File> file)
{
  Glib::KeyFile cfg;

  set_defaults();

  try {
    if (!cfg.load_from_file (file->get_path())) {
      std::cout << "Failed to load settings from file '" << file->get_path() << "\n";
      return;
    }
  } catch (const Glib::KeyFileError &err) {
    std::cout << "Exception " << err.what() << " loading settings from file '" << file->get_path() << "\n";
    return;
  }

  std::cout << "parsing config from '" << file->get_path() << "\n";

  for (uint i = 0; i < G_N_ELEMENTS (settings); i++) {
    Glib::ustring group, key;

    if (!get_group_and_key (i, group, key))
      continue;

    if (!cfg.has_key (group, key))
      continue;

    // group & string ...
    switch (settings[i].type) {
    case T_BOOL:
      *PTR_BOOL(this, i) = cfg.get_boolean (group, key);
      break;
    case T_INT:
      *PTR_INT(this, i) = cfg.get_integer (group, key);
      break;
    case T_FLOAT:
    case T_COLOUR_MEMBER:
      *PTR_FLOAT(this, i) = cfg.get_double (group, key);
      break;
    case T_STRING:
      *PTR_STRING(this, i) = cfg.get_string (group, key);
      break;
    default:
      std::cerr << "corrupt setting type\n";
      break;
    }
  }

  GCode.m_impl->loadSettings (cfg);

  m_signal_visual_settings_changed.emit();
  m_signal_update_settings_gui.emit();
}
コード例 #3
0
ファイル: window.cpp プロジェクト: bsantos/visualboyadvance-m
void Window::vApplyPerGameConfig()
{
    std::string sRDBFile = PKGDATADIR "/vba-over.ini";
    if (!Glib::file_test(sRDBFile, Glib::FILE_TEST_EXISTS))
        return;

    char csGameID[5];
    csGameID[0] = rom[0xac];
    csGameID[1] = rom[0xad];
    csGameID[2] = rom[0xae];
    csGameID[3] = rom[0xaf];
    csGameID[4] = '\0';

    Glib::KeyFile oKeyFile;
    oKeyFile.load_from_file(sRDBFile);

    if (!oKeyFile.has_group(csGameID))
        return;

    if (oKeyFile.has_key(csGameID, "rtcEnabled")) {
        bool bRTCEnabled = oKeyFile.get_boolean(csGameID, "rtcEnabled");
        rtcEnable(bRTCEnabled);
    }

    if (oKeyFile.has_key(csGameID, "flashSize")) {
        Glib::ustring sFlashSize = oKeyFile.get_string(csGameID, "flashSize");
        int iFlashSize = atoi(sFlashSize.c_str());
        if (iFlashSize == 0x10000 || iFlashSize == 0x20000)
            flashSetSize(iFlashSize);
    }

    if (oKeyFile.has_key(csGameID, "saveType")) {
        int iSaveType = oKeyFile.get_integer(csGameID, "saveType");
        if (iSaveType >= 0 && iSaveType <= 5)
            cpuSaveType = iSaveType;
    }

    if (oKeyFile.has_key(csGameID, "mirroringEnabled")) {
        mirroringEnable = oKeyFile.get_boolean(csGameID, "mirroringEnabled");
    }
}