Beispiel #1
0
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();
}
Beispiel #2
0
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);
	}
}
Beispiel #3
0
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);
	}
}
Beispiel #4
0
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);
		}
	}
}
Beispiel #5
0
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();
		recent_menu_create();
		program_configure();
		gtk_widget_hide(program_dialog);

		if (gtk_toggle_button_get_active(delete_all_items) &&
			dialogs_show_question(_("Delete all breakpoints, watches et cetera?")))
		{
			breaks_delete_all();
			watches_delete_all();
			inspects_delete_all();
			registers_delete_all();
		}
	}
}