Mercurial > geeqie
changeset 372:8ce8d565c038
Add and use few new macros in rc file writing code.
author | zas_ |
---|---|
date | Tue, 15 Apr 2008 20:00:27 +0000 |
parents | 7997b6704fdb |
children | 61a3c8b05b24 |
files | src/rcfile.c |
diffstat | 1 files changed, 128 insertions(+), 113 deletions(-) [+] |
line wrap: on
line diff
--- a/src/rcfile.c Tue Apr 15 18:34:24 2008 +0000 +++ b/src/rcfile.c Tue Apr 15 20:00:27 2008 +0000 @@ -278,174 +278,183 @@ return; } +#define WRITE_BOOL(_name_) write_bool_option(ssi, #_name_, options->_name_) +#define WRITE_INT(_name_) write_int_option(ssi, #_name_, options->_name_) +#define WRITE_INT_UNIT(_name_, _unit_) write_int_unit_option(ssi, #_name_, options->_name_, _unit_) +#define WRITE_CHAR(_name_) write_char_option(ssi, #_name_, options->_name_) +#define WRITE_COLOR(_name_) write_color_option(ssi, #_name_, &options->_name_) + +#define WRITE_SEPARATOR() secure_fputc(ssi, '\n') +#define WRITE_SUBTITLE(_title_) secure_fprintf(ssi, "\n\n##### "_title_" #####\n\n") + secure_fprintf(ssi, "######################################################################\n"); secure_fprintf(ssi, "# %30s config file version %7s #\n", GQ_APPNAME, VERSION); secure_fprintf(ssi, "######################################################################\n"); - secure_fputc(ssi, '\n'); + WRITE_SEPARATOR(); secure_fprintf(ssi, "# Note: This file is autogenerated. Options can be changed here,\n"); secure_fprintf(ssi, "# but user comments and formatting will be lost.\n"); - secure_fputc(ssi, '\n'); + WRITE_SEPARATOR(); - secure_fprintf(ssi, "##### General Options #####\n\n"); + WRITE_SUBTITLE("General Options"); - write_bool_option(ssi, "show_icon_names", options->show_icon_names); - secure_fputc(ssi, '\n'); + WRITE_BOOL(show_icon_names); + WRITE_SEPARATOR(); - write_bool_option(ssi, "tree_descend_subdirs", options->tree_descend_subdirs); - write_bool_option(ssi, "lazy_image_sync", options->lazy_image_sync); - write_bool_option(ssi, "update_on_time_change", options->update_on_time_change); - secure_fputc(ssi, '\n'); + WRITE_BOOL(tree_descend_subdirs); + WRITE_BOOL(lazy_image_sync); + WRITE_BOOL(update_on_time_change); + WRITE_SEPARATOR(); - write_bool_option(ssi, "startup_path_enable", options->startup_path_enable); - write_char_option(ssi, "startup_path", options->startup_path); + WRITE_BOOL(startup_path_enable); + WRITE_CHAR(startup_path); - write_bool_option(ssi, "progressive_key_scrolling", options->progressive_key_scrolling); - write_bool_option(ssi, "enable_metadata_dirs", options->enable_metadata_dirs); + WRITE_BOOL(progressive_key_scrolling); + WRITE_BOOL(enable_metadata_dirs); - write_int_option(ssi, "duplicates_similarity_threshold", options->duplicates_similarity_threshold); - secure_fputc(ssi, '\n'); + WRITE_INT(duplicates_similarity_threshold); + WRITE_SEPARATOR(); - write_bool_option(ssi, "mousewheel_scrolls", options->mousewheel_scrolls); - write_int_option(ssi, "open_recent_list_maxsize", options->open_recent_list_maxsize); - write_bool_option(ssi, "place_dialogs_under_mouse", options->place_dialogs_under_mouse); + WRITE_BOOL(mousewheel_scrolls); + WRITE_INT(open_recent_list_maxsize); + WRITE_BOOL(place_dialogs_under_mouse); - secure_fprintf(ssi, "\n##### File operations Options #####\n\n"); + WRITE_SUBTITLE("File operations Options"); - write_bool_option(ssi, "file_ops.enable_in_place_rename", options->file_ops.enable_in_place_rename); - write_bool_option(ssi, "file_ops.confirm_delete", options->file_ops.confirm_delete); - write_bool_option(ssi, "file_ops.enable_delete_key", options->file_ops.enable_delete_key); - write_bool_option(ssi, "file_ops.safe_delete_enable", options->file_ops.safe_delete_enable); - write_char_option(ssi, "file_ops.safe_delete_path", options->file_ops.safe_delete_path); - write_int_option(ssi, "file_ops.safe_delete_folder_maxsize", options->file_ops.safe_delete_folder_maxsize); + WRITE_BOOL(file_ops.enable_in_place_rename); + WRITE_BOOL(file_ops.confirm_delete); + WRITE_BOOL(file_ops.enable_delete_key); + WRITE_BOOL(file_ops.safe_delete_enable); + WRITE_CHAR(file_ops.safe_delete_path); + WRITE_INT(file_ops.safe_delete_folder_maxsize); - secure_fprintf(ssi, "\n##### Layout Options #####\n\n"); + WRITE_SUBTITLE("Layout Options"); - write_int_option(ssi, "layout.style", options->layout.style); - write_char_option(ssi, "layout.order", options->layout.order); - write_bool_option(ssi, "layout.view_as_icons", options->layout.view_as_icons); - write_bool_option(ssi, "layout.view_as_tree", options->layout.view_as_tree); - write_bool_option(ssi, "layout.show_thumbnails", options->layout.show_thumbnails); - secure_fputc(ssi, '\n'); + WRITE_INT(layout.style); + WRITE_CHAR(layout.order); + WRITE_BOOL(layout.view_as_icons); + WRITE_BOOL(layout.view_as_tree); + WRITE_BOOL(layout.show_thumbnails); + WRITE_SEPARATOR(); - write_bool_option(ssi, "layout.save_window_positions", options->layout.save_window_positions); - secure_fputc(ssi, '\n'); + WRITE_BOOL(layout.save_window_positions); + WRITE_SEPARATOR(); - write_int_option(ssi, "layout.main_window.x", options->layout.main_window.x); - write_int_option(ssi, "layout.main_window.y", options->layout.main_window.y); - write_int_option(ssi, "layout.main_window.w", options->layout.main_window.w); - write_int_option(ssi, "layout.main_window.h", options->layout.main_window.h); - write_bool_option(ssi, "layout.main_window.maximized", options->layout.main_window.maximized); - write_int_option(ssi, "layout.main_window.hdivider_pos", options->layout.main_window.hdivider_pos); - write_int_option(ssi, "layout.main_window.vdivider_pos", options->layout.main_window.vdivider_pos); - secure_fputc(ssi, '\n'); + WRITE_INT(layout.main_window.x); + WRITE_INT(layout.main_window.y); + WRITE_INT(layout.main_window.w); + WRITE_INT(layout.main_window.h); + WRITE_BOOL(layout.main_window.maximized); + WRITE_INT(layout.main_window.hdivider_pos); + WRITE_INT(layout.main_window.vdivider_pos); + WRITE_SEPARATOR(); - write_int_option(ssi, "layout.float_window.x", options->layout.float_window.x); - write_int_option(ssi, "layout.float_window.y", options->layout.float_window.y); - write_int_option(ssi, "layout.float_window.w", options->layout.float_window.w); - write_int_option(ssi, "layout.float_window.h", options->layout.float_window.h); - write_int_option(ssi, "layout.float_window.vdivider_pos", options->layout.float_window.vdivider_pos); - secure_fputc(ssi, '\n'); + WRITE_INT(layout.float_window.x); + WRITE_INT(layout.float_window.y); + WRITE_INT(layout.float_window.w); + WRITE_INT(layout.float_window.h); + WRITE_INT(layout.float_window.vdivider_pos); + WRITE_SEPARATOR(); - write_bool_option(ssi, "layout.tools_float", options->layout.tools_float); - write_bool_option(ssi, "layout.tools_hidden", options->layout.tools_hidden); - write_bool_option(ssi, "layout.tools_restore_state", options->layout.tools_restore_state); - secure_fputc(ssi, '\n'); + WRITE_BOOL(layout.tools_float); + WRITE_BOOL(layout.tools_hidden); + WRITE_BOOL(layout.tools_restore_state); + WRITE_SEPARATOR(); - write_bool_option(ssi, "layout.toolbar_hidden", options->layout.toolbar_hidden); + WRITE_BOOL(layout.toolbar_hidden); - secure_fprintf(ssi, "\n##### Image Options #####\n\n"); + WRITE_SUBTITLE("Image Options"); secure_fprintf(ssi, "image.zoom_mode: "); if (options->image.zoom_mode == ZOOM_RESET_ORIGINAL) secure_fprintf(ssi, "original\n"); if (options->image.zoom_mode == ZOOM_RESET_FIT_WINDOW) secure_fprintf(ssi, "fit\n"); if (options->image.zoom_mode == ZOOM_RESET_NONE) secure_fprintf(ssi, "dont_change\n"); - write_bool_option(ssi, "image.zoom_2pass", options->image.zoom_2pass); - write_bool_option(ssi, "image.zoom_to_fit_allow_expand", options->image.zoom_to_fit_allow_expand); - write_int_option(ssi, "image.zoom_quality", options->image.zoom_quality); - write_int_option(ssi, "image.zoom_increment", options->image.zoom_increment); - write_bool_option(ssi, "image.fit_window_to_image", options->image.fit_window_to_image); - write_bool_option(ssi, "image.limit_window_size", options->image.limit_window_size); - write_int_option(ssi, "image.max_window_size", options->image.max_window_size); - write_bool_option(ssi, "image.limit_autofit_size", options->image.limit_autofit_size); - write_int_option(ssi, "image.max_autofit_size", options->image.max_autofit_size); - write_int_option(ssi, "image.scroll_reset_method", options->image.scroll_reset_method); - write_int_option(ssi, "image.tile_cache_max", options->image.tile_cache_max); - write_int_option(ssi, "image.dither_quality", options->image.dither_quality); - write_bool_option(ssi, "image.enable_read_ahead", options->image.enable_read_ahead); - write_bool_option(ssi, "image.exif_rotate_enable", options->image.exif_rotate_enable); - write_bool_option(ssi, "image.use_custom_border_color", options->image.use_custom_border_color); - write_color_option(ssi, "image.border_color", &options->image.border_color); + WRITE_BOOL(image.zoom_2pass); + WRITE_BOOL(image.zoom_to_fit_allow_expand); + WRITE_INT(image.zoom_quality); + WRITE_INT(image.zoom_increment); + WRITE_BOOL(image.fit_window_to_image); + WRITE_BOOL(image.limit_window_size); + WRITE_INT(image.max_window_size); + WRITE_BOOL(image.limit_autofit_size); + WRITE_INT(image.max_autofit_size); + WRITE_INT(image.scroll_reset_method); + WRITE_INT(image.tile_cache_max); + WRITE_INT(image.dither_quality); + WRITE_BOOL(image.enable_read_ahead); + WRITE_BOOL(image.exif_rotate_enable); + WRITE_BOOL(image.use_custom_border_color); + WRITE_COLOR(image.border_color); - secure_fprintf(ssi, "\n##### Thumbnails Options #####\n\n"); + WRITE_SUBTITLE("Thumbnails Options"); - write_int_option(ssi, "thumbnails.max_width", options->thumbnails.max_width); - write_int_option(ssi, "thumbnails.max_height", options->thumbnails.max_height); - write_bool_option(ssi, "thumbnails.enable_caching", options->thumbnails.enable_caching); - write_bool_option(ssi, "thumbnails.cache_into_dirs", options->thumbnails.cache_into_dirs); - write_bool_option(ssi, "thumbnails.fast", options->thumbnails.fast); - write_bool_option(ssi, "thumbnails.use_xvpics", options->thumbnails.use_xvpics); - write_bool_option(ssi, "thumbnails.spec_standard", options->thumbnails.spec_standard); - write_int_option(ssi, "thumbnails.quality", options->thumbnails.quality); + WRITE_INT(thumbnails.max_width); + WRITE_INT(thumbnails.max_height); + WRITE_BOOL(thumbnails.enable_caching); + WRITE_BOOL(thumbnails.cache_into_dirs); + WRITE_BOOL(thumbnails.fast); + WRITE_BOOL(thumbnails.use_xvpics); + WRITE_BOOL(thumbnails.spec_standard); + WRITE_INT(thumbnails.quality); - secure_fprintf(ssi, "\n##### File sorting Options #####\n\n"); + WRITE_SUBTITLE("File sorting Options"); - write_int_option(ssi, "file_sort.method", (gint)options->file_sort.method); - write_bool_option(ssi, "file_sort.ascending", options->file_sort.ascending); - write_bool_option(ssi, "file_sort.case_sensitive", options->file_sort.case_sensitive); + WRITE_INT(file_sort.method); + WRITE_BOOL(file_sort.ascending); + WRITE_BOOL(file_sort.case_sensitive); - secure_fprintf(ssi, "\n##### Fullscreen Options #####\n\n"); + WRITE_SUBTITLE("Fullscreen Options"); - write_int_option(ssi, "fullscreen.screen", options->fullscreen.screen); - write_bool_option(ssi, "fullscreen.clean_flip", options->fullscreen.clean_flip); - write_bool_option(ssi, "fullscreen.disable_saver", options->fullscreen.disable_saver); - write_bool_option(ssi, "fullscreen.above", options->fullscreen.above); - write_bool_option(ssi, "fullscreen.show_info", options->fullscreen.show_info); - write_char_option(ssi, "fullscreen.info", options->fullscreen.info); + WRITE_INT(fullscreen.screen); + WRITE_BOOL(fullscreen.clean_flip); + WRITE_BOOL(fullscreen.disable_saver); + WRITE_BOOL(fullscreen.above); + WRITE_BOOL(fullscreen.show_info); + WRITE_CHAR(fullscreen.info); - secure_fprintf(ssi, "\n##### Slideshow Options #####\n\n"); + WRITE_SUBTITLE("Slideshow Options"); - write_int_unit_option(ssi, "slideshow.delay", options->slideshow.delay, SLIDESHOW_SUBSECOND_PRECISION); - write_bool_option(ssi, "slideshow.random", options->slideshow.random); - write_bool_option(ssi, "slideshow.repeat", options->slideshow.repeat); + WRITE_INT_UNIT(slideshow.delay, SLIDESHOW_SUBSECOND_PRECISION); + WRITE_BOOL(slideshow.random); + WRITE_BOOL(slideshow.repeat); - secure_fprintf(ssi, "\n##### Collection Options #####\n\n"); + WRITE_SUBTITLE("Collection Options"); - write_bool_option(ssi, "collections.rectangular_selection", options->collections.rectangular_selection); + WRITE_BOOL(collections.rectangular_selection); - secure_fprintf(ssi, "\n##### Filtering Options #####\n\n"); + WRITE_SUBTITLE("Filtering Options"); - write_bool_option(ssi, "file_filter.show_hidden_files", options->file_filter.show_hidden_files); - write_bool_option(ssi, "file_filter.disable", options->file_filter.disable); - secure_fputc(ssi, '\n'); + WRITE_BOOL(file_filter.show_hidden_files); + WRITE_BOOL(file_filter.disable); + WRITE_SEPARATOR(); filter_write_list(ssi); - secure_fprintf(ssi, "\n##### Sidecars Options #####\n\n"); + WRITE_SUBTITLE("Sidecars Options"); sidecar_ext_write(ssi); - secure_fprintf(ssi, "\n##### Color Profiles #####\n\n"); + WRITE_SUBTITLE("Color Profiles"); #ifndef HAVE_LCMS secure_fprintf(ssi, "# NOTICE: %s was not built with support for color profiles,\n" - "# color profile options will have no effect.\n\n", GQ_APPNAME); + "# color profile options will have no effect.\n\n", GQ_APPNAME); #endif - write_bool_option(ssi, "color_profile.enabled", options->color_profile.enabled); - write_bool_option(ssi, "color_profile.use_image", options->color_profile.use_image); - write_int_option(ssi, "color_profile.input_type", options->color_profile.input_type); - secure_fputc(ssi, '\n'); + WRITE_BOOL(color_profile.enabled); + WRITE_BOOL(color_profile.use_image); + WRITE_INT(color_profile.input_type); + WRITE_SEPARATOR(); for (i = 0; i < COLOR_PROFILE_INPUTS; i++) { @@ -459,11 +468,12 @@ write_char_option(ssi, buf, options->color_profile.input_name[i]); g_free(buf); } - secure_fputc(ssi, '\n'); - write_int_option(ssi, "color_profile.screen_type", options->color_profile.screen_type); - write_char_option(ssi, "color_profile.screen_file", options->color_profile.screen_file); - secure_fprintf(ssi, "\n##### External Programs #####\n"); + WRITE_SEPARATOR(); + WRITE_INT(color_profile.screen_type); + WRITE_CHAR(color_profile.screen_file); + + WRITE_SUBTITLE("External Programs"); secure_fprintf(ssi, "# Maximum of %d programs (external_1 through external_%d)\n", GQ_EDITOR_GENERIC_SLOTS, GQ_EDITOR_GENERIC_SLOTS); secure_fprintf(ssi, "# external_%d through external_%d are used for file ops\n", GQ_EDITOR_GENERIC_SLOTS + 1, GQ_EDITOR_SLOTS); secure_fprintf(ssi, "# format: external_n: \"menu name\" \"command line\"\n\n"); @@ -479,14 +489,19 @@ } - secure_fprintf(ssi, "\n##### Exif Options #####\n# Display:\n# 0: never\n# 1: if set\n# 2: always\n\n"); + WRITE_SUBTITLE("Exif Options"); + secure_fprintf(ssi, "# Display: 0: never\n" + "# 1: if set\n" + "# 2: always\n\n"); for (i = 0; ExifUIList[i].key; i++) { secure_fprintf(ssi, "exif.display."); write_int_option(ssi, (gchar *)ExifUIList[i].key, ExifUIList[i].current); } - secure_fputc(ssi, '\n'); + WRITE_SEPARATOR(); + WRITE_SEPARATOR(); + secure_fprintf(ssi, "######################################################################\n"); secure_fprintf(ssi, "# end of config file #\n"); secure_fprintf(ssi, "######################################################################\n");