// Set the option szKey to szValue.  Return NULL if everything worked, a
// (literal) error string for unrecognized or illegal values.
const gchar *
dasher_app_settings_cl_set(DasherAppSettings *pSelf, const gchar *szKey, const gchar *szValue) {

  for(int i(0); i < NUM_OF_APP_BPS; ++i ) {
    if(!strcmp(app_boolparamtable[i].regName, szKey)) {
      
      if(!strcmp(szValue, "1") || !strcmp(szValue, _("true")))
        dasher_app_settings_set_bool(pSelf, app_boolparamtable[i].key, true);
      else if(!strcmp(szValue, "0") || !strcmp(szValue, _("false")))
        dasher_app_settings_set_bool(pSelf, app_boolparamtable[i].key, false);
      else
        return _("boolean value must be specified as 'true' or 'false'.");
      return 0;
    }
  }

  for(int i(0); i < NUM_OF_APP_LPS; ++i ) {
    if(!strcmp(app_longparamtable[i].regName, szKey)) {
      dasher_app_settings_set_long(pSelf, app_longparamtable[i].key, atoi(szValue));
      return 0;
    }
  }

  for(int i(0); i < NUM_OF_APP_SPS; ++i ) {
    if(!strcmp(app_stringparamtable[i].regName, szKey)) {
      dasher_app_settings_set_string(pSelf, app_stringparamtable[i].key, szValue);
      return 0;
    }
  }  

  return gtk_dasher_control_cl_set(GTK_DASHER_CONTROL(pDasherWidget), szKey, szValue);
}
void dasher_app_settings_set_long(DasherAppSettings *pSelf, int iParameter, gint iValue) {
  DasherAppSettingsPrivate *pPrivate = (DasherAppSettingsPrivate *)(pSelf->private_data);

  if( iParameter < END_OF_LPS) {
    if(pPrivate->bWidgetSet)
      gtk_dasher_control_set_parameter_long(GTK_DASHER_CONTROL(pDasherWidget), iParameter, iValue);
  }
  else {
    if(dasher_app_settings_get_long(pSelf, iParameter) == iValue)
      return; // Don't attempt to change to the existing value
    
    //    pre_parameter_notification(0, iParameter, 0);

    app_longparamtable[ iParameter - FIRST_APP_LP ].value = iValue;

#ifdef WITH_GCONF    
    if(app_longparamtable[ iParameter - FIRST_APP_LP ].persistent) {
      gchar szName[256];
      
      strncpy(szName, "/apps/dasher4/", 256);
      strncat(szName,  app_longparamtable[ iParameter - FIRST_APP_LP ].regName, 255 - strlen( szName ));
      
      GError *pGConfError = NULL;
      gconf_client_set_int(pPrivate->pGConfClient, szName, iValue, &pGConfError);
    }
#endif
    
    // TODO: Use real signals to achieve this
    parameter_notification(0, iParameter, 0);
  }
}
void dasher_app_settings_reset(DasherAppSettings *pSelf, int iParameter) {
  DasherAppSettingsPrivate *pPrivate = (DasherAppSettingsPrivate*)(pSelf->private_data);

  if(iParameter < END_OF_SPS) {
    if(pPrivate->bWidgetSet)
      gtk_dasher_control_reset_parameter(GTK_DASHER_CONTROL(pDasherWidget), iParameter);
    return;
  }
  else {
    //    pre_parameter_notification(0, iParameter, 0);
    
    if(iParameter < END_OF_APP_BPS)
      app_boolparamtable[ iParameter - FIRST_APP_BP ].value = app_boolparamtable[ iParameter - FIRST_APP_BP ].bDefaultValue;
    else if(iParameter < END_OF_APP_LPS)
      app_longparamtable[ iParameter - FIRST_APP_LP ].value = app_longparamtable[ iParameter - FIRST_APP_LP ].iDefaultValue; 
    else {
      delete[] app_stringparamtable[iParameter - FIRST_APP_SP].value;
      
      gchar *szNew;
      szNew = new gchar[strlen(app_stringparamtable[iParameter - FIRST_APP_SP].szDefaultValue) + 1];
      strcpy(szNew, app_stringparamtable[iParameter - FIRST_APP_SP].szDefaultValue);
      app_stringparamtable[iParameter - FIRST_APP_SP].value = szNew;
    }
  }
  // TODO: Use real signals to achieve this
  parameter_notification(0, iParameter, 0);
}
bool dasher_app_settings_get_bool(DasherAppSettings *pSelf, int iParameter) { 
  DasherAppSettingsPrivate *pPrivate = (DasherAppSettingsPrivate*)(pSelf->private_data);
  if( iParameter < END_OF_BPS ) {
    if(pPrivate->bWidgetSet)
      return gtk_dasher_control_get_parameter_bool(GTK_DASHER_CONTROL(pDasherWidget), iParameter);
    else
      return false;
  }
  else
    return app_boolparamtable[ iParameter - FIRST_APP_BP ].value;
}
示例#5
0
static void 
gtk_dasher_control_finalize(GObject *pObject) {
  GtkDasherControl *pDasherControl = GTK_DASHER_CONTROL(pObject);

  GtkDasherControlPrivate *pPrivate = GTK_DASHER_CONTROL_GET_PRIVATE(pDasherControl);


  /* TODO: Check that this actually gets called correctly */

  /* TODO: Should just call constructor - this should just be a lightweight wrapper class */
  //ACL not sure what that's about...?
  //The following comment taken from the old ShutdownTimer, which we need to do now:
    // TODO: Figure out how to implement this - at the moment it's done
    // through a return value from the timer callback, but it would be
    // nicer to prevent any further calls as soon as the shutdown signal
    // has been receieved.
  pPrivate->pControl->WriteTrainFileFull();

  delete pPrivate->pControl;
  //  g_free(pDasherControl->private_data);
}
gboolean dasher_app_settings_get_module_settings(DasherAppSettings *pSelf, const gchar *szValue, SModuleSettings **pSettings, gint *iCount) {
  return gtk_dasher_control_get_module_settings(GTK_DASHER_CONTROL(pDasherWidget), szValue, pSettings, iCount);
}
GArray *dasher_app_settings_get_allowed_values(DasherAppSettings *pSelf, int iParameter) {
  return gtk_dasher_control_get_allowed_values(GTK_DASHER_CONTROL(pDasherWidget), iParameter);
}