Exemple #1
0
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);
	}
}
Exemple #2
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);
		}
	}
}