VikLayerParamData *a_preferences_get(const gchar *key) { if ( ! loaded ) { /* since we can't load the file in a_preferences_init (no params registered yet), * do it once before we get the first key. */ preferences_load_from_file(); loaded = TRUE; } return g_hash_table_lookup ( values, key ); }
/** * a_preferences_get_param: * @key: The name of a preference * * Returns the #VikLayerParam of the specified preference. * This may be NULL if the preference doesn't exist. */ VikLayerParam *a_preferences_get_param(const gchar *key) { if ( ! loaded ) { g_debug ( "%s: First time: %s\n", __FUNCTION__, key ); preferences_load_from_file(); loaded = TRUE; } // Search GPtrArray *params for the name for ( int ii = 0; ii < params->len; ii++ ) { VikLayerParam *param = (VikLayerParam*)g_ptr_array_index ( params,ii ); if ( g_strcmp0 (key, param->name) == 0 ) return param; } return NULL; }
void a_preferences_show_window(GtkWindow *parent) { //VikLayerParamData *a_uibuilder_run_dialog ( GtkWindow *parent, VikLayerParam \*params, // guint16 params_count, gchar **groups, guint8 groups_count, // VikLayerParamData *params_defaults ) // TODO: THIS IS A MAJOR HACKAROUND, but ok when we have only a couple preferences. gint params_count = params->len; VikLayerParam *contiguous_params = g_new(VikLayerParam,params_count); int i; for ( i = 0; i < params->len; i++ ) { contiguous_params[i] = *((VikLayerParam*)(g_ptr_array_index(params,i))); } loaded = TRUE; preferences_load_from_file(); if ( a_uibuilder_properties_factory ( _("Preferences"), parent, contiguous_params, params_count, (gchar **) groups_names->pdata, groups_names->len, // groups, groups_count, // groups? what groups?! (gboolean (*) (gpointer,guint16,VikLayerParamData,gpointer,gboolean)) preferences_run_setparam, NULL /* not used */, contiguous_params, preferences_run_getparam, NULL, NULL /* not used */ ) ) { a_preferences_save_to_file(); } g_free ( contiguous_params ); }