static void on_program_ok_button_clicked(G_GNUC_UNUSED GtkButton *button, G_GNUC_UNUSED gpointer gdata) { if (check_dialog_path(program_exec_entry, TRUE, R_OK | X_OK) && check_dialog_path(working_dir_entry, FALSE, X_OK) && check_dialog_path(load_script_entry, TRUE, R_OK)) { const gchar *program_name = gtk_entry_get_text(program_exec_entry); if (*program_name == '\0') program_name = gtk_entry_get_text(load_script_entry); if (utils_filenamecmp(program_name, *program_executable ? program_executable : program_load_script)) { save_program_settings(); } stash_foreach((GFunc) stash_group_update, NULL); option_long_mr_format = dialog_long_mr_format; g_free(program_environment); program_environment = utils_text_buffer_get_text(environment, -1); save_program_settings(); program_configure(); gtk_widget_hide(program_dialog); if (gtk_toggle_button_get_active(delete_all_items) && dialogs_show_question(_("Delete all breakpoints, watches and inspects?"))) { breaks_delete_all(); watches_delete_all(); inspects_delete_all(); } } }
void program_load_config(GKeyFile *config) { utils_load(config, "recent", recent_program_load); recent_menu_create(); config = g_key_file_new(); /* load from empty config file == set defaults */ stash_foreach((GFunc) stash_group_load_from_key_file, config); g_key_file_free(config); program_configure(); }
void on_program_setup(G_GNUC_UNUSED const MenuItem *menu_item) { gtk_text_buffer_set_text(environment, program_environment, -1); stash_foreach((GFunc) stash_group_display, NULL); gtk_button_set_label(long_mr_format, LONG_MR_FORMAT[option_long_mr_format]); dialog_long_mr_format = option_long_mr_format; gtk_widget_set_sensitive(import_button, last_state_inactive && build_check_execute()); on_program_name_entry_changed(NULL, NULL); gtk_toggle_button_set_active(delete_all_items, FALSE); if (debug_state() == DS_INACTIVE) gtk_widget_grab_focus(GTK_WIDGET(program_exec_entry)); gtk_dialog_run(GTK_DIALOG(program_dialog)); }
static void on_recent_menu_item_activate(G_GNUC_UNUSED GtkMenuItem *menuitem, const gchar *name) { GtkTreeIter iter; if (utils_filenamecmp(name, *program_executable ? program_executable : program_load_script) && program_find(&iter, name)) { gint id; char *configfile; GKeyFile *config = g_key_file_new(); GError *gerror = NULL; gchar *message; scp_tree_store_get(recent_programs, &iter, PROGRAM_ID, &id, -1); configfile = recent_file_name(id); if (g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, &gerror)) { scp_tree_store_move(recent_programs, &iter, 0); save_program_settings(); stash_foreach((GFunc) stash_group_load_from_key_file, config); if ((unsigned) option_inspect_expand > EXPAND_MAX) option_inspect_expand = 100; breaks_load(config); watches_load(config); inspects_load(config); registers_load(config); parse_load(config); message = g_strdup_printf(_("Loaded debug settings for %s."), name); program_find(&iter, name); scp_tree_store_move(recent_programs, &iter, 0); recent_menu_create(); program_configure(); } else { message = g_strdup_printf(_("Could not load debug settings file %s: %s."), configfile, gerror->message); g_error_free(gerror); } if (menuitem) ui_set_statusbar(TRUE, "%s", message); else msgwin_status_add("%s", message); g_free(message); g_key_file_free(config); g_free(configfile); } }
static void save_program_settings(void) { const gchar *program_name = *program_executable ? program_executable : program_load_script; if (*program_name) { GtkTreeIter iter; gint id; GKeyFile *config = g_key_file_new(); char *configfile; if (program_find(&iter, program_name)) { scp_tree_store_get(recent_programs, &iter, PROGRAM_ID, &id, -1); scp_tree_store_move(recent_programs, &iter, 0); } else { if (scp_tree_store_iter_nth_child(recent_programs, &iter, NULL, RECENT_COUNT - 1)) { scp_tree_store_get(recent_programs, &iter, PROGRAM_ID, &id, -1); scp_tree_store_remove(recent_programs, &iter); } else { for (id = 1; id < RECENT_COUNT; id++) if ((recent_bitmap & (1 << id)) == 0) break; recent_bitmap |= 1 << id; } scp_tree_store_prepend_with_values(recent_programs, &iter, NULL, PROGRAM_NAME, program_name, PROGRAM_ID, id, -1); } configfile = recent_file_name(id); stash_foreach((GFunc) stash_group_save_to_key_file, config); breaks_save(config); watches_save(config); inspects_save(config); registers_save(config); parse_save(config); utils_key_file_write_to_file(config, configfile); g_free(configfile); g_key_file_free(config); } }
void program_finalize(void) { char *configfile = prefs_file_name(); GKeyFile *config = g_key_file_new(); save_program_settings(); g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); store_save(recent_programs, config, "recent", recent_program_save); utils_key_file_write_to_file(config, configfile); g_key_file_free(config); g_free(configfile); gtk_widget_destroy(program_dialog); stash_foreach((GFunc) stash_group_destroy, NULL); }
static void on_recent_menu_item_activate(G_GNUC_UNUSED GtkMenuItem *menuitem, const gchar *name) { RecentProgram *recent = (RecentProgram *) array_find(recent_programs, name, TRUE); if (recent && utils_filenamecmp(recent->name, *program_executable ? program_executable : program_load_script)) { char *configfile = recent_file_name(recent->id); GKeyFile *config = g_key_file_new(); GError *gerror = NULL; gchar *message; if (g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, &gerror)) { save_program_settings(); recent = (RecentProgram *) array_find(recent_programs, name, TRUE); stash_foreach((GFunc) stash_group_load_from_key_file, config); if ((unsigned) option_inspect_expand > EXPAND_MAX) option_inspect_expand = 100; breaks_load(config); watches_load(config); inspects_load(config); parse_load(config); message = g_strdup_printf(_("Loaded debug settings for %s."), recent->name); g_array_insert_vals(recent_programs, 0, ++recent, 1); array_remove(recent_programs, recent); recent_menu_create(); program_configure(); } else { message = g_strdup_printf(_("Could not load debug settings file %s: %s."), configfile, gerror->message); g_error_free(gerror); } if (menuitem) ui_set_statusbar(TRUE, "%s", message); else msgwin_status_add("%s", message); g_free(message); g_key_file_free(config); g_free(configfile); } }
static void save_program_settings(void) { const gchar *program_name = *program_executable ? program_executable : program_load_script; if (*program_name) { RecentProgram *recent = (RecentProgram *) array_find(recent_programs, program_name, TRUE); GKeyFile *config = g_key_file_new(); char *configfile; if (!recent) { recent = (RecentProgram *) array_append(recent_programs); recent->name = g_strdup(program_name); for (recent->id = 1; recent->id < RECENT_COUNT; recent->id++) if ((recent_bitmap & (1 << recent->id)) == 0) break; recent_bitmap |= 1 << recent->id; } configfile = recent_file_name(recent->id); stash_foreach((GFunc) stash_group_save_to_key_file, config); breaks_save(config); watches_save(config); inspects_save(config); parse_save(config); utils_key_file_write_to_file(config, configfile); g_free(configfile); g_key_file_free(config); g_array_insert_vals(recent_programs, 0, ++recent, 1); array_remove(recent_programs, recent); recent_menu_create(); if (recent_programs->len > RECENT_COUNT) { recent_bitmap &= ~(1 << recent->id); array_remove(recent_programs, recent); } } }