📄 rcfile.c
字号:
/* * GQview * (C) 2004 John Ellis * * Author: John Ellis * * This software is released under the GNU General Public License (GNU GPL). * Please read the included file COPYING for more information. * This software comes with no warranty of any kind, use at your own risk! */#include "gqview.h"#include "rcfile.h"#include "filelist.h"#include "slideshow.h"#include "ui_fileops.h"/* *----------------------------------------------------------------------------- * line write/parse routines (private) *----------------------------------------------------------------------------- */ gchar *quoted_value(const gchar *text){ const gchar *ptr; gint c = 0; gint l = strlen(text); if (l == 0) return NULL; while (c < l && text[c] !='"') c++; if (text[c] == '"') { gint e; c++; ptr = text + c; e = c; while (e < l && text[e] !='"') e++; if (text[e] == '"') { if (e - c > 0) { return g_strndup(ptr, e - c); } } } else /* for compatibility with older formats (<0.3.7) * read a line without quotes too */ { c = 0; while (c < l && text[c] !=' ' && text[c] !=8 && text[c] != '\n') c++; if (c != 0) { return g_strndup(text, c); } } return NULL;}static void write_char_option(FILE *f, gchar *label, gchar *text){ if (text) fprintf(f,"%s: \"%s\"\n", label, text); else fprintf(f,"%s: \n", label);}static gchar *read_char_option(FILE *f, gchar *option, gchar *label, gchar *value, gchar *text){ if (strcasecmp(option, label) == 0) { g_free(text); text = quoted_value(value); } return text;}static void write_int_option(FILE *f, gchar *label, gint n){ fprintf(f,"%s: %d\n\n", label, n);}static gint read_int_option(FILE *f, gchar *option, gchar *label, gchar *value, gint n){ if (strcasecmp(option, label) == 0) { n = strtol(value, NULL, 10); } return n;}static void write_int_unit_option(FILE *f, gchar *label, gint n, gint subunits){ gint l, r; if (subunits > 0) { l = n / subunits; r = n % subunits; } else { l = n; r = 0; } fprintf(f,"%s: %d.%d\n\n", label, l, r);}static gint read_int_unit_option(FILE *f, gchar *option, gchar *label, gchar *value, gint n, gint subunits){ if (strcasecmp(option, label) == 0) { gint l, r; gchar *ptr; ptr = value; while (*ptr != '\0' && *ptr != '.') ptr++; if (*ptr == '.') { *ptr = '\0'; l = strtol(value, NULL, 10); *ptr = '.'; ptr++; r = strtol(ptr, NULL, 10); } else { l = strtol(value, NULL, 10); r = 0; } n = l * subunits + r; } return n;}static void write_bool_option(FILE *f, gchar *label, gint n){ fprintf(f,"%s: ", label); if (n) fprintf(f,"true\n"); else fprintf(f,"false\n"); fprintf(f,"\n");}static gint read_bool_option(FILE *f, gchar *option, gchar *label, gchar *value, gint n){ if (strcasecmp(option, label) == 0) { if (strcasecmp(value, "true") == 0) n = TRUE; else n = FALSE; } return n;}/* *----------------------------------------------------------------------------- * save configuration (public) *----------------------------------------------------------------------------- */ void save_options(void){ FILE *f; gchar *rc_path; gchar *rc_pathl; gint i; rc_path = g_strconcat(homedir(), "/", GQVIEW_RC_DIR, "/", RC_FILE_NAME, NULL); rc_pathl = path_from_utf8(rc_path); f = fopen(rc_pathl, "w"); g_free(rc_pathl); if (!f) { gchar *buf; buf = g_strdup_printf(_("error saving config file: %s\n"), rc_path); print_term(buf); g_free(buf); g_free(rc_path); return; } fprintf(f,"######################################################################\n"); fprintf(f,"# GQview config file version %7s #\n", VERSION); fprintf(f,"######################################################################\n"); fprintf(f,"\n"); fprintf(f,"# Note: This file is autogenerated. Options can be changed here,\n"); fprintf(f,"# but user comments and formatting will be lost.\n"); fprintf(f,"\n"); fprintf(f,"##### General Options #####\n\n"); write_int_option(f, "layout_style", layout_style); write_char_option(f, "layout_order", layout_order); fprintf(f,"\n"); write_bool_option(f, "layout_view_as_icons", layout_view_icons); write_bool_option(f, "layout_view_as_tree", layout_view_tree); write_bool_option(f, "show_icon_names", show_icon_names); fprintf(f,"\n"); write_bool_option(f, "tree_descend_folders", tree_descend_subdirs); write_bool_option(f, "lazy_image_sync", lazy_image_sync); write_bool_option(f, "update_on_time_change", update_on_time_change); write_bool_option(f, "exif_auto_rotate", exif_rotate_enable); fprintf(f,"\n"); write_bool_option(f, "enable_startup_path", startup_path_enable); write_char_option(f, "startup_path", startup_path); fprintf(f,"\n"); fprintf(f,"zoom_mode: "); if (zoom_mode == ZOOM_RESET_ORIGINAL) fprintf(f,"original\n"); if (zoom_mode == ZOOM_RESET_FIT_WINDOW) fprintf(f,"fit\n"); if (zoom_mode == ZOOM_RESET_NONE) fprintf(f,"dont_change\n"); write_bool_option(f, "two_pass_scaling", two_pass_zoom); write_bool_option(f, "zoom_to_fit_allow_expand", zoom_to_fit_expands); fprintf(f,"\n"); write_bool_option(f, "fit_window_to_image", fit_window); write_bool_option(f, "limit_window_size", limit_window_size); write_int_option(f, "max_window_size", max_window_size); fprintf(f,"\n"); write_bool_option(f, "progressive_keyboard_scrolling", progressive_key_scrolling); write_int_option(f, "scroll_reset_method", scroll_reset_method); fprintf(f,"\n"); write_bool_option(f, "enable_thumbnails", thumbnails_enabled); write_int_option(f, "thumbnail_width", thumb_max_width); write_int_option(f, "thumbnail_height", thumb_max_height); write_bool_option(f, "cache_thumbnails", enable_thumb_caching); write_bool_option(f, "cache_thumbnails_into_dirs", enable_thumb_dirs); write_bool_option(f, "thumbnail_fast", thumbnail_fast); write_bool_option(f, "use_xvpics_thumbnails", use_xvpics_thumbnails); write_bool_option(f, "thumbnail_spec_standard", thumbnail_spec_standard); fprintf(f,"\n"); write_bool_option(f, "local_metadata", enable_metadata_dirs); fprintf(f,"\n"); write_int_option(f, "sort_method", (gint)file_sort_method); write_bool_option(f, "sort_ascending", file_sort_ascending); write_bool_option(f, "sort_case_sensitive", file_sort_case_sensitive); fprintf(f,"\n"); write_bool_option(f, "confirm_delete", confirm_delete); write_bool_option(f, "enable_delete_key", enable_delete_key); write_bool_option(f, "safe_delete", safe_delete_enable); write_char_option(f, "safe_delete_path", safe_delete_path); write_int_option(f, "safe_delete_size", safe_delete_size); fprintf(f,"\n"); write_bool_option(f, "tools_float", tools_float); write_bool_option(f, "tools_hidden", tools_hidden); write_bool_option(f, "restore_tool_state", restore_tool); write_bool_option(f, "toolbar_hidden", toolbar_hidden); write_bool_option(f, "mouse_wheel_scrolls", mousewheel_scrolls); write_bool_option(f, "in_place_rename", enable_in_place_rename); write_int_option(f, "open_recent_max", recent_list_max); write_int_option(f, "image_cache_size_max", tile_cache_max); write_int_option(f, "thumbnail_quality", thumbnail_quality); write_int_option(f, "zoom_quality", zoom_quality); write_int_option(f, "dither_quality", dither_quality); write_int_option(f, "zoom_increment", zoom_increment); write_bool_option(f, "enable_read_ahead", enable_read_ahead); write_bool_option(f, "display_dialogs_under_mouse", place_dialogs_under_mouse); write_bool_option(f, "black_window_background", black_window_background); write_int_option(f, "fullscreen_screen", fullscreen_screen); write_bool_option(f, "fullscreen_clean_flip", fullscreen_clean_flip); write_bool_option(f, "fullscreen_disable_saver", fullscreen_disable_saver); write_bool_option(f, "fullscreen_above", fullscreen_above); write_int_option(f, "custom_similarity_threshold", dupe_custom_threshold); fprintf(f,"\n##### Slideshow Options #####\n\n"); write_int_unit_option(f, "slideshow_delay", slideshow_delay, SLIDESHOW_SUBSECOND_PRECISION); write_bool_option(f, "slideshow_random", slideshow_random); write_bool_option(f, "slideshow_repeat", slideshow_repeat); fprintf(f,"\n##### Filtering Options #####\n\n"); write_bool_option(f, "show_dotfiles", show_dot_files); write_bool_option(f, "disable_filtering", file_filter_disable); filter_write_list(f); fprintf(f,"\n##### External Programs #####\n"); fprintf(f,"# Maximum of 10 programs (external_1 through external_10)\n"); fprintf(f,"# format: external_n: \"menu name\" \"command line\"\n\n"); for (i = 0; i < GQVIEW_EDITOR_SLOTS; i++) { fprintf(f,"external_%d: \"", i+1); if (editor_name[i]) fprintf(f, "%s", editor_name[i]); fprintf(f, "\" \""); if (editor_command[i]) fprintf(f, "%s", editor_command[i]); fprintf(f, "\"\n"); } fprintf(f,"\n##### Collection Options #####\n\n"); write_bool_option(f, "rectangular_selections", collection_rectangular_selection);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -