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 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); } }