Ejemplo n.º 1
0
/* Write the project settings as well as the project session files into its configuration files.
 * emit_signal defines whether the project-save signal should be emitted. When write_config()
 * is called while closing a project, this is used to skip emitting the signal because
 * project-close will be emitted afterwards.
 * Returns: TRUE if project file was written successfully. */
static gboolean write_config(gboolean emit_signal)
{
	GeanyProject *p;
	GKeyFile *config;
	gchar *filename;
	gchar *data;
	gboolean ret = FALSE;
	GSList *node;

	g_return_val_if_fail(app->project != NULL, FALSE);

	p = app->project;

	config = g_key_file_new();
	/* try to load an existing config to keep manually added comments */
	filename = utils_get_locale_from_utf8(p->file_name);
	g_key_file_load_from_file(config, filename, G_KEY_FILE_NONE, NULL);

	foreach_slist(node, stash_groups)
		stash_group_save_to_key_file(node->data, config);

	g_key_file_set_string(config, "project", "name", p->name);
	g_key_file_set_string(config, "project", "base_path", p->base_path);

	if (p->description)
		g_key_file_set_string(config, "project", "description", p->description);
	if (p->file_patterns)
		g_key_file_set_string_list(config, "project", "file_patterns",
			(const gchar**) p->file_patterns, g_strv_length(p->file_patterns));

	g_key_file_set_integer(config, "long line marker", "long_line_behaviour", p->long_line_behaviour);
	g_key_file_set_integer(config, "long line marker", "long_line_column", p->long_line_column);

	/* store the session files into the project too */
	if (project_prefs.project_session)
		configuration_save_session_files(config);
	build_save_menu(config, (gpointer)p, GEANY_BCS_PROJ);
	if (emit_signal)
	{
		g_signal_emit_by_name(geany_object, "project-save", config);
	}
	/* write the file */
	data = g_key_file_to_data(config, NULL, NULL);
	ret = (utils_write_file(filename, data) == 0);

	g_free(data);
	g_free(filename);
	g_key_file_free(config);

	return ret;
}
Ejemplo n.º 2
0
static void save_scope_prefs(GKeyFile *config)
{
	guint i;
	MarkerStyle *style = pref_marker_styles;

	stash_group_save_to_key_file(scope_group, config);
	stash_group_save_to_key_file(terminal_group, config);

	for (i = 0; i < MARKER_COUNT; i++, style++)
	{
		gchar *tmp_string;

		stash_group_save_to_key_file(marker_group[i], config);
		tmp_string = g_strdup_printf("#%02X%02X%02X", style->fore & 0xFF,
			(style->fore >> 8) & 0xFF, style->fore >> 16);
		g_key_file_set_string(config, style->name, "fore", tmp_string);
		g_free(tmp_string);
		tmp_string = g_strdup_printf("#%02X%02X%02X", style->back & 0xFF,
			(style->back >> 8) & 0xFF, style->back >> 16);
		g_key_file_set_string(config, style->name, "back", tmp_string);
		g_free(tmp_string);
	}
}
Ejemplo n.º 3
0
static void settings_action(GKeyFile *config, SettingAction action)
{
	guint i;
	StashGroup *group;

	foreach_ptr_array(group, i, keyfile_groups)
	{
		switch (action)
		{
			case SETTING_READ:
				stash_group_load_from_key_file(group, config); break;
			case SETTING_WRITE:
				stash_group_save_to_key_file(group, config); break;
		}
	}
}