예제 #1
0
파일: project.c 프로젝트: Nordvind/geany
/* Reads the given filename and creates a new project with the data found in the file.
 * At this point there should not be an already opened project in Geany otherwise it will just
 * return.
 * The filename is expected in the locale encoding. */
static gboolean load_config(const gchar *filename)
{
	GKeyFile *config;
	GeanyProject *p;
	GSList *node;

	/* there should not be an open project */
	g_return_val_if_fail(app->project == NULL && filename != NULL, FALSE);

	config = g_key_file_new();
	if (! g_key_file_load_from_file(config, filename, G_KEY_FILE_NONE, NULL))
	{
		g_key_file_free(config);
		return FALSE;
	}

	p = create_project();

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

	p->name = utils_get_setting_string(config, "project", "name", GEANY_STRING_UNTITLED);
	p->description = utils_get_setting_string(config, "project", "description", "");
	p->file_name = utils_get_utf8_from_locale(filename);
	p->base_path = utils_get_setting_string(config, "project", "base_path", "");
	p->file_patterns = g_key_file_get_string_list(config, "project", "file_patterns", NULL, NULL);

	p->long_line_behaviour = utils_get_setting_integer(config, "long line marker",
		"long_line_behaviour", 1 /* follow global */);
	p->long_line_column = utils_get_setting_integer(config, "long line marker",
		"long_line_column", editor_prefs.long_line_column);
	apply_editor_prefs();

	build_load_menu(config, GEANY_BCS_PROJ, (gpointer)p);
	if (project_prefs.project_session)
	{
		/* save current (non-project) session (it could has been changed since program startup) */
		configuration_save_default_session();
		/* now close all open files */
		document_close_all();
		/* read session files so they can be opened with configuration_open_files() */
		configuration_load_session_files(config, FALSE);
		ui_focus_current_document();
	}
	g_signal_emit_by_name(geany_object, "project-open", config);
	g_key_file_free(config);

	update_ui();
	return TRUE;
}
예제 #2
0
파일: prefs.c 프로젝트: BYC/geany-plugins
static void load_scope_prefs(GKeyFile *config)
{
	guint i;
	MarkerStyle *style = pref_marker_styles;

	stash_group_load_from_key_file(scope_group, config);
	stash_group_load_from_key_file(terminal_group, config);

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

		stash_group_load_from_key_file(marker_group[i], config);
		tmp_string = utils_get_setting_string(config, style->name, "fore",
			style->default_fore);
		style->fore = utils_parse_sci_color(tmp_string);
		g_free(tmp_string);
		tmp_string = utils_get_setting_string(config, style->name, "back",
			style->default_back);
		style->back = utils_parse_sci_color(tmp_string);
		g_free(tmp_string);
	}
}
예제 #3
0
파일: keyfile.c 프로젝트: hauk142/geany
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;
		}
	}
}
예제 #4
0
파일: project.c 프로젝트: Nordvind/geany
static void init_stash_prefs(void)
{
	StashGroup *group;
	GKeyFile *kf;

	group = stash_group_new("indentation");
	/* copy global defaults */
	indentation = *editor_get_indent_prefs(NULL);
	stash_group_set_use_defaults(group, FALSE);
	add_stash_group(group);

	stash_group_add_spin_button_integer(group, &indentation.width,
		"indent_width", 4, "spin_indent_width_project");
	stash_group_add_radio_buttons(group, (gint*)(gpointer)&indentation.type,
		"indent_type", GEANY_INDENT_TYPE_TABS,
		"radio_indent_spaces_project", GEANY_INDENT_TYPE_SPACES,
		"radio_indent_tabs_project", GEANY_INDENT_TYPE_TABS,
		"radio_indent_both_project", GEANY_INDENT_TYPE_BOTH,
		NULL);
	/* This is a 'hidden' pref for backwards-compatibility */
	stash_group_add_integer(group, &indentation.hard_tab_width,
		"indent_hard_tab_width", 8);
	stash_group_add_toggle_button(group, &indentation.detect_type,
		"detect_indent", FALSE, "check_detect_indent_type_project");
	stash_group_add_toggle_button(group, &indentation.detect_width,
		"detect_indent_width", FALSE, "check_detect_indent_width_project");
	stash_group_add_combo_box(group, (gint*)(gpointer)&indentation.auto_indent_mode,
		"indent_mode", GEANY_AUTOINDENT_CURRENTCHARS, "combo_auto_indent_mode_project");

	group = stash_group_new("file_prefs");
	stash_group_add_toggle_button(group, &priv.final_new_line,
		"final_new_line", file_prefs.final_new_line, "check_new_line1");
	stash_group_add_toggle_button(group, &priv.ensure_convert_new_lines,
		"ensure_convert_new_lines", file_prefs.ensure_convert_new_lines, "check_ensure_convert_new_lines1");
	stash_group_add_toggle_button(group, &priv.strip_trailing_spaces,
		"strip_trailing_spaces", file_prefs.strip_trailing_spaces, "check_trailing_spaces1");
	stash_group_add_toggle_button(group, &priv.replace_tabs,
		"replace_tabs", file_prefs.replace_tabs, "check_replace_tabs1");
	add_stash_group(group);
	/* apply defaults */
	kf = g_key_file_new();
	stash_group_load_from_key_file(group, kf);
	g_key_file_free(kf);
}