📄 preferences.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 "preferences.h"#include "cache_maint.h"#include "editors.h"#include "filelist.h"#include "fullscreen.h"#include "image.h"#include "img-view.h"#include "layout_config.h"#include "layout_util.h"#include "pixbuf_util.h"#include "slideshow.h"#include "utilops.h"#include "ui_fileops.h"#include "ui_misc.h"#include "ui_tabcomp.h"#include "ui_utildlg.h"#include "icons/config.xpm"#include <math.h>#define EDITOR_NAME_MAX_LENGTH 32#define EDITOR_COMMAND_MAX_LENGTH 1024typedef struct _ThumbSize ThumbSize;struct _ThumbSize{ gint w; gint h;};static ThumbSize thumb_size_list[] ={ { 24, 24 }, { 32, 32 }, { 48, 48 }, { 64, 64 }, { 96, 72 }, { 96, 96 }, { 128, 96 }, { 128, 128 }, { 160, 120 }, { 160, 160 }, { 192, 144 }, { 192, 192 }, { 256, 192 }, { 256, 256 }};enum { FE_ENABLE, FE_EXTENSION, FE_DESCRIPTION};/* config memory values */static gint startup_path_enable_c;static gint confirm_delete_c;static gint enable_delete_key_c;static gint safe_delete_enable_c;static gint safe_delete_size_c;static gint restore_tool_c;static gint save_window_positions_c;static gint zoom_mode_c;static gint two_pass_zoom_c;static gint fit_window_c;static gint limit_window_size_c;static gint zoom_to_fit_expands_c;static gint max_window_size_c;static gint progressive_key_scrolling_c;static gint thumb_max_width_c;static gint thumb_max_height_c;static gint enable_thumb_caching_c;static gint enable_thumb_dirs_c;static gint thumbnail_fast_c;#if 0static gint use_xvpics_thumbnails_c;#endifstatic gint thumbnail_spec_standard_c;static gint enable_metadata_dirs_c;static gint show_dot_files_c;static gint file_filter_disable_c;static gint file_sort_case_sensitive_c;static gint slideshow_delay_c;static gint slideshow_random_c;static gint slideshow_repeat_c;static gint mousewheel_scrolls_c;static gint enable_in_place_rename_c;static gint collection_rectangular_selection_c;static gint tile_cache_max_c;static gint thumbnail_quality_c;static gint zoom_quality_c;static gint zoom_increment_c;static gint enable_read_ahead_c;static gint black_window_background_c;static gint fullscreen_screen_c;static gint fullscreen_clean_flip_c;static gint fullscreen_disable_saver_c;static gint fullscreen_above_c;static gint dupe_custom_threshold_c;static GtkWidget *configwindow = NULL;static GtkWidget *startup_path_entry;static GtkListStore *filter_store = NULL;static GtkWidget *editor_name_entry[GQVIEW_EDITOR_SLOTS];static GtkWidget *editor_command_entry[GQVIEW_EDITOR_SLOTS];static GtkWidget *layout_widget;static GtkWidget *safe_delete_path_entry;static gint tree_descend_subdirs_c;static gint update_on_time_change_c;static gint exif_rotate_enable_c;/* *----------------------------------------------------------------------------- * option widget callbacks (private) *----------------------------------------------------------------------------- */ static void startup_path_set_current(GtkWidget *widget, gpointer data){ gtk_entry_set_text(GTK_ENTRY(startup_path_entry), layout_get_path(NULL));}static void zoom_mode_original_cb(GtkWidget *widget, gpointer data){ if (GTK_TOGGLE_BUTTON (widget)->active) zoom_mode_c = ZOOM_RESET_ORIGINAL;}static void zoom_mode_fit_cb(GtkWidget *widget, gpointer data){ if (GTK_TOGGLE_BUTTON (widget)->active) zoom_mode_c = ZOOM_RESET_FIT_WINDOW;}static void zoom_mode_none_cb(GtkWidget *widget, gpointer data){ if (GTK_TOGGLE_BUTTON (widget)->active) zoom_mode_c = ZOOM_RESET_NONE;}static void zoom_increment_cb(GtkWidget *spin, gpointer data){ zoom_increment_c = (gint)(gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin)) * 10.0 + 0.01);}static void slideshow_delay_cb(GtkWidget *spin, gpointer data){ slideshow_delay_c = (gint)(gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin)) * (double)SLIDESHOW_SUBSECOND_PRECISION + 0.01);}/* *----------------------------------------------------------------------------- * sync progam to config window routine (private) *----------------------------------------------------------------------------- */ static void config_window_apply(void){ const gchar *buf; gchar *l_conf; gint new_style; gint i; gint refresh = FALSE; for(i = 0; i < GQVIEW_EDITOR_SLOTS; i++) { g_free(editor_name[i]); editor_name[i] = NULL; buf = gtk_entry_get_text(GTK_ENTRY(editor_name_entry[i])); if (buf && strlen(buf) > 0) editor_name[i] = g_strdup(buf); g_free(editor_command[i]); editor_command[i] = NULL; buf = gtk_entry_get_text(GTK_ENTRY(editor_command_entry[i])); if (buf && strlen(buf) > 0) editor_command[i] = g_strdup(buf); } layout_edit_update_all(); g_free(startup_path); startup_path = NULL; buf = gtk_entry_get_text(GTK_ENTRY(startup_path_entry)); if (buf && strlen(buf) > 0) startup_path = remove_trailing_slash(buf); g_free(safe_delete_path); safe_delete_path = NULL; buf = gtk_entry_get_text(GTK_ENTRY(safe_delete_path_entry)); if (buf && strlen(buf) > 0) safe_delete_path = remove_trailing_slash(buf); if (show_dot_files != show_dot_files_c) refresh = TRUE; if (file_sort_case_sensitive != file_sort_case_sensitive_c) refresh = TRUE; if (file_filter_disable != file_filter_disable_c) refresh = TRUE; startup_path_enable = startup_path_enable_c; confirm_delete = confirm_delete_c; enable_delete_key = enable_delete_key_c; safe_delete_enable = safe_delete_enable_c; safe_delete_size = safe_delete_size_c; restore_tool = restore_tool_c; save_window_positions = save_window_positions_c; zoom_mode = zoom_mode_c; two_pass_zoom = two_pass_zoom_c; fit_window = fit_window_c; limit_window_size = limit_window_size_c; zoom_to_fit_expands = zoom_to_fit_expands_c; max_window_size = max_window_size_c; progressive_key_scrolling = progressive_key_scrolling_c; thumb_max_width = thumb_max_width_c; thumb_max_height = thumb_max_height_c; enable_thumb_caching = enable_thumb_caching_c; enable_thumb_dirs = enable_thumb_dirs_c; thumbnail_fast = thumbnail_fast_c;#if 0 use_xvpics_thumbnails = use_xvpics_thumbnails_c;#endif thumbnail_spec_standard = thumbnail_spec_standard_c; enable_metadata_dirs = enable_metadata_dirs_c; show_dot_files = show_dot_files_c; file_sort_case_sensitive = file_sort_case_sensitive_c; file_filter_disable = file_filter_disable_c; slideshow_random = slideshow_random_c; slideshow_repeat = slideshow_repeat_c; slideshow_delay = slideshow_delay_c; mousewheel_scrolls = mousewheel_scrolls_c; enable_in_place_rename = enable_in_place_rename_c; collection_rectangular_selection = collection_rectangular_selection_c; tile_cache_max = tile_cache_max_c; thumbnail_quality = thumbnail_quality_c; zoom_quality = zoom_quality_c; zoom_increment = zoom_increment_c; enable_read_ahead = enable_read_ahead_c; if (black_window_background != black_window_background_c) { black_window_background = black_window_background_c; layout_colors_update(); view_window_colors_update(); } fullscreen_screen = fullscreen_screen_c; fullscreen_clean_flip = fullscreen_clean_flip_c; fullscreen_disable_saver = fullscreen_disable_saver_c; fullscreen_above = fullscreen_above_c; update_on_time_change = update_on_time_change_c; exif_rotate_enable = exif_rotate_enable_c; dupe_custom_threshold = dupe_custom_threshold_c; tree_descend_subdirs = tree_descend_subdirs_c; l_conf = layout_config_get(layout_widget, &new_style); if (new_style != layout_style || (l_conf == NULL) != (layout_order == NULL) || !layout_order || strcmp(buf, layout_order) != 0) { if (refresh) filter_rebuild(); refresh = FALSE; g_free(layout_order); layout_order = l_conf; l_conf = NULL; layout_style = new_style; layout_styles_update(); } g_free(l_conf); image_options_sync(); if (refresh) { filter_rebuild(); layout_refresh(NULL); }}/* *----------------------------------------------------------------------------- * config window main button callbacks (private) *----------------------------------------------------------------------------- */ static void config_window_close_cb(GtkWidget *widget, gpointer data){ gtk_widget_destroy(configwindow); configwindow = NULL; filter_store = NULL;}static gint config_window_delete(GtkWidget *w, GdkEventAny *event, gpointer data){ config_window_close_cb(NULL, NULL); return TRUE;}static void config_window_ok_cb(GtkWidget *widget, gpointer data){ config_window_apply(); config_window_close_cb(NULL, NULL);}static void config_window_apply_cb(GtkWidget *widget, gpointer data){ config_window_apply();}/* *----------------------------------------------------------------------------- * config window setup (private) *----------------------------------------------------------------------------- */ static void quality_menu_cb(GtkWidget *combo, gpointer data){ gint *option = data; switch (gtk_combo_box_get_active(GTK_COMBO_BOX(combo))) { case 0: default: *option = GDK_INTERP_NEAREST; break; case 1: *option = GDK_INTERP_TILES; break; case 2: *option = GDK_INTERP_BILINEAR; break; case 3: *option = GDK_INTERP_HYPER; break; }}static void add_quality_menu(GtkWidget *table, gint column, gint row, const gchar *text, gint option, gint *option_c){ GtkWidget *combo; gint current = 0; *option_c = option; pref_table_label(table, column, row, text, 0.0); combo = gtk_combo_box_new_text(); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Nearest (worst, but fastest)")); if (option == GDK_INTERP_NEAREST) current = 0; gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Tiles")); if (option == GDK_INTERP_TILES) current = 1; gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Bilinear")); if (option == GDK_INTERP_BILINEAR) current = 2; gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Hyper (best, but slowest)")); if (option == GDK_INTERP_HYPER) current = 3; gtk_combo_box_set_active(GTK_COMBO_BOX(combo), current); g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(quality_menu_cb), option_c); gtk_table_attach(GTK_TABLE(table), combo, column + 1, column + 2, row, row + 1, GTK_EXPAND | GTK_FILL, FALSE, 0, 0); gtk_widget_show(combo);}#if 0static void add_dither_menu(gint option, gint *option_c, gchar *text, GtkWidget *box){ GtkWidget *hbox; GtkWidget *omenu; GtkWidget *menu; *option_c = option; hbox = pref_box_new(box, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); pref_label_new(hbox, text); omenu = gtk_option_menu_new(); menu = gtk_menu_new(); add_menu_item(menu, _("None"), option_c, (gint)GDK_RGB_DITHER_NONE); add_menu_item(menu, _("Normal"), option_c, (gint)GDK_RGB_DITHER_NORMAL); add_menu_item(menu, _("Best"), option_c, (gint)GDK_RGB_DITHER_MAX); gtk_option_menu_set_menu(GTK_OPTION_MENU(omenu), menu); gtk_option_menu_set_history(GTK_OPTION_MENU(omenu), *option_c); gtk_box_pack_start(GTK_BOX(hbox), omenu, FALSE, FALSE, 0); gtk_widget_show(omenu);}#endifstatic void thumb_size_menu_cb(GtkWidget *combo, gpointer data){ gint n; n = gtk_combo_box_get_active(GTK_COMBO_BOX(combo)); if (n >= 0 && n < sizeof(thumb_size_list) / sizeof(ThumbSize)) { thumb_max_width_c = thumb_size_list[n].w; thumb_max_height_c = thumb_size_list[n].h; } else if (n > 0) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -