static void load_hash_funcs(GKeyFile *keyfile) { bool has_enabled = false; for (int i = 0; i < HASH_FUNCS_N; i++) { GError *error = NULL; bool active = g_key_file_get_boolean(keyfile, "hash-funcs", hash.funcs[i].name, &error); if (!error) { if (hash.funcs[i].supported) { if (active) has_enabled = true; hash.funcs[i].enabled = active; gtk_toggle_button_set_active(gui.hash_widgets[i].button, active); } else hash.funcs[i].enabled = false; } else g_error_free(error); } if (!has_enabled) default_hash_funcs(); }
static void prefs_default(void) { default_hash_funcs(); default_show_toolbar(); gui_update(); }
void prefs_load(void) { GKeyFile *keyfile = g_key_file_new(); char *filename = g_build_filename(g_get_user_config_dir(), PACKAGE, NULL); bool loaded; if ((loaded = g_key_file_load_from_file(keyfile, filename, G_KEY_FILE_NONE, NULL))) { load_hash_funcs(keyfile); load_digest_format(keyfile); load_window_view(keyfile); load_window_show_toolbar(keyfile); load_window_size(keyfile); } g_free(filename); g_key_file_free(keyfile); if (!loaded) { default_hash_funcs(); default_window_show_toolbar(); } gui_update(); }
static void load_hash_funcs(void) { char **strv = g_settings_get_strv(prefs_priv.settings, PREFS_KEY_HASH_FUNCS); hash_funcs_enable_strv((const char **)strv); g_strfreev(strv); if (!hash_funcs_count_enabled()) default_hash_funcs(); }
static void load_hash_funcs(void) { char **strv = g_settings_get_strv(prefs_priv.settings, PREFS_KEY_HASH_FUNCS); bool has_enabled = false; for (int i = 0; strv[i]; i++) { enum hash_func_e id = gtkhash_hash_func_get_id_from_name(strv[i]); if (id != HASH_FUNC_INVALID && hash.funcs[id].supported) { hash.funcs[id].enabled = true; gtk_toggle_button_set_active(gui.hash_widgets[id].button, true); has_enabled = true; } } g_strfreev(strv); if (!has_enabled) default_hash_funcs(); }