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); } }
void program_finalize(void) { char *configfile = prefs_file_name(); GKeyFile *config = g_key_file_new(); save_program_settings(); g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); store_save(recent_programs, config, "recent", recent_program_save); utils_key_file_write_to_file(config, configfile); g_key_file_free(config); g_free(configfile); gtk_widget_destroy(program_dialog); stash_foreach((GFunc) stash_group_destroy, NULL); }
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); } } }
void prefs_init(void) { guint i; MarkerStyle *style = pref_marker_styles; StashGroup *group; char *configdir = g_build_filename(geany->app->configdir, "plugins", "scope", NULL); char *configfile = prefs_file_name(); GKeyFile *config = g_key_file_new(); gchar *tmp_string; group = stash_group_new("scope"); stash_group_add_string(group, &pref_gdb_executable, "gdb_executable", "gdb"); stash_group_add_boolean(group, &pref_gdb_async_mode, "gdb_async_mode", FALSE); stash_group_add_integer(group, &pref_gdb_buffer_length, "gdb_buffer_length", 16383); stash_group_add_integer(group, &pref_gdb_wait_death, "gdb_wait_death", 20); #ifndef G_OS_UNIX stash_group_add_integer(group, &pref_gdb_send_interval, "gdb_send_interval", 5); stash_group_add_boolean(group, &pref_async_break_bugs, "async_break_bugs", TRUE); #endif stash_group_add_boolean(group, &pref_auto_view_source, "auto_view_source", FALSE); stash_group_add_boolean(group, &pref_keep_exec_point, "keep_exec_point", FALSE); stash_group_add_integer(group, &pref_visual_beep_length, "visual_beep_length", 25); #ifdef G_OS_UNIX stash_group_add_boolean(group, &pref_debug_console_vte, "debug_console_vte", TRUE); #endif stash_group_add_integer(group, &pref_sci_marker_1st, "sci_marker_first", 17); stash_group_add_integer(group, &pref_sci_caret_policy, "sci_caret_policy", CARET_SLOP | CARET_JUMPS | CARET_EVEN); stash_group_add_integer(group, &pref_sci_caret_slop, "sci_caret_slop", 3); stash_group_add_boolean(group, &pref_unmark_current_line, "unmark_current_line", FALSE); stash_group_add_boolean(group, &pref_scope_goto_cursor, "scope_run_to_cursor", FALSE); stash_group_add_boolean(group, &pref_seek_with_navqueue, "seek_with_navqueue", FALSE); stash_group_add_integer(group, &pref_panel_tab_pos, "panel_tab_pos", GTK_POS_TOP); stash_group_add_integer(group, &pref_show_recent_items, "show_recent_items", 10); stash_group_add_integer(group, &pref_show_toolbar_items, "show_toolbar_items", 0xFF); stash_group_add_integer(group, &pref_tooltips_fail_action, "tooltips_fail_action", 0); stash_group_add_integer(group, &pref_tooltips_send_delay, "tooltips_send_delay", 25); stash_group_add_integer(group, &pref_tooltips_length, "tooltips_length", 2048); stash_group_add_integer(group, &pref_memory_bytes_per_line, "memory_line_bytes", 16); stash_group_add_string(group, &pref_memory_font, "memory_font", ""); scope_group = group; config_item = ui_add_config_file_menu_item(configfile, NULL, NULL); plugin_signal_connect(geany_plugin, NULL, "document-save", FALSE, G_CALLBACK(on_document_save), NULL); group = stash_group_new("terminal"); #ifdef G_OS_UNIX stash_group_add_boolean(group, &pref_terminal_save_pos, "save_pos", TRUE); stash_group_add_boolean(group, &pref_terminal_padding, "padding", TRUE); stash_group_add_integer(group, &pref_terminal_window_x, "window_x", 70); stash_group_add_integer(group, &pref_terminal_window_y, "window_y", 50); stash_group_add_integer(group, &pref_terminal_width, "width", 640); stash_group_add_integer(group, &pref_terminal_height, "height", 480); #endif /* G_OS_UNIX */ terminal_group = group; for (i = 0; i < MARKER_COUNT; i++, style++) { group = stash_group_new(style->name); stash_group_add_integer(group, &style->mark, "mark", style->default_mark); stash_group_add_integer(group, &style->alpha, "alpha", style->default_alpha); marker_group[i] = group; } g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); load_scope_prefs(config); pref_sci_marker_first = pref_sci_marker_1st; prefs_configure(); program_load_config(config); if (pref_panel_tab_pos == GTK_POS_LEFT || pref_panel_tab_pos == GTK_POS_RIGHT) { gtk_label_set_label(GTK_LABEL(get_widget("program_terminal_label")), _("Program")); gtk_label_set_label(GTK_LABEL(get_widget("break_view_label")), _("Breaks")); gtk_label_set_label(GTK_LABEL(get_widget("debug_console_label")), _("Console")); } if (!g_file_test(configfile, G_FILE_TEST_IS_REGULAR)) { gint error = utils_mkdir(configdir, TRUE); if (error) msgwin_status_add(_("Scope: %s: %s."), configdir, g_strerror(error)); else { save_scope_prefs(config); if (utils_key_file_write_to_file(config, configfile)) msgwin_status_add(_("Scope: created configuration file.")); } } g_key_file_free(config); g_free(configfile); g_free(configdir); configfile = g_build_filename(geany_data->app->configdir, "geany.conf", NULL); config = g_key_file_new(); g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); pref_vte_blinken = utils_get_setting_boolean(config, "VTE", "cursor_blinks", FALSE); pref_vte_emulation = utils_get_setting_string(config, "VTE", "emulation", "xterm"); pref_vte_font = utils_get_setting_string(config, "VTE", "font", "Monospace 10"); pref_vte_scrollback = utils_get_setting_integer(config, "VTE", "scrollback_lines", 500); tmp_string = utils_get_setting_string(config, "VTE", "colour_fore", "#ffffff"); gdk_color_parse(tmp_string, &pref_vte_colour_fore); g_free(tmp_string); tmp_string = utils_get_setting_string(config, "VTE", "colour_back", "#000000"); gdk_color_parse(tmp_string, &pref_vte_colour_back); g_free(tmp_string); g_key_file_free(config); g_free(configfile); }