Mercurial > geeqie.yaz
changeset 341:15c6b94545a2
Move safe_delete* and in place rename options to file_ops
struct.
Re-order rc file a bit.
author | zas_ |
---|---|
date | Sat, 12 Apr 2008 22:04:29 +0000 |
parents | 77103f3f2cb1 |
children | 07490120df2d |
files | src/globals.c src/img-view.c src/layout_util.c src/main.c src/preferences.c src/rcfile.c src/typedefs.h src/utilops.c src/view_file_list.c |
diffstat | 9 files changed, 114 insertions(+), 104 deletions(-) [+] |
line wrap: on
line diff
--- a/src/globals.c Sat Apr 12 21:45:30 2008 +0000 +++ b/src/globals.c Sat Apr 12 22:04:29 2008 +0000 @@ -44,11 +44,11 @@ options->startup_path_enable = FALSE; options->startup_path = NULL; - options->confirm_delete = TRUE; - options->enable_delete_key = TRUE; - options->safe_delete_enable = FALSE; - options->safe_delete_path = NULL; - options->safe_delete_size = 128; + options->file_ops.confirm_delete = TRUE; + options->file_ops.enable_delete_key = TRUE; + options->file_ops.safe_delete_enable = FALSE; + options->file_ops.safe_delete_path = NULL; + options->file_ops.safe_delete_folder_maxsize = 128; options->layout.tools_restore_state = FALSE; options->image.zoom_mode = ZOOM_RESET_ORIGINAL; options->image.zoom_2pass = TRUE; @@ -80,7 +80,7 @@ options->slideshow.repeat = FALSE; options->mousewheel_scrolls = FALSE; - options->enable_in_place_rename = TRUE; + options->file_ops.enable_in_place_rename = TRUE; options->recent_list_max = 10;
--- a/src/img-view.c Sat Apr 12 21:45:30 2008 +0000 +++ b/src/img-view.c Sat Apr 12 22:04:29 2008 +0000 @@ -557,7 +557,7 @@ image_alter(imd, ALTER_ROTATE_90_CC); break; case GDK_Delete: case GDK_KP_Delete: - if (options->enable_delete_key) + if (options->file_ops.enable_delete_key) { file_util_delete(image_get_fd(imd), NULL, imd->widget); }
--- a/src/layout_util.c Sat Apr 12 21:45:30 2008 +0000 +++ b/src/layout_util.c Sat Apr 12 22:04:29 2008 +0000 @@ -190,7 +190,7 @@ layout_image_next(lw); break; case GDK_Delete: case GDK_KP_Delete: - if (options->enable_delete_key) + if (options->file_ops.enable_delete_key) { file_util_delete(NULL, layout_selection_list(lw), widget); }
--- a/src/main.c Sat Apr 12 21:45:30 2008 +0000 +++ b/src/main.c Sat Apr 12 22:04:29 2008 +0000 @@ -1169,8 +1169,8 @@ bookmark_add_default(_("Collections"), path); g_free(path); - g_free(options->safe_delete_path); - options->safe_delete_path = concat_dir_and_file(homedir(), GQ_RC_DIR_TRASH); + g_free(options->file_ops.safe_delete_path); + options->file_ops.safe_delete_path = concat_dir_and_file(homedir(), GQ_RC_DIR_TRASH); for (i = 0; i < COLOR_PROFILE_INPUTS; i++) {
--- a/src/preferences.c Sat Apr 12 21:45:30 2008 +0000 +++ b/src/preferences.c Sat Apr 12 22:04:29 2008 +0000 @@ -173,20 +173,20 @@ buf = gtk_entry_get_text(GTK_ENTRY(startup_path_entry)); if (buf && strlen(buf) > 0) options->startup_path = remove_trailing_slash(buf); - g_free(options->safe_delete_path); - options->safe_delete_path = NULL; + g_free(options->file_ops.safe_delete_path); + options->file_ops.safe_delete_path = NULL; buf = gtk_entry_get_text(GTK_ENTRY(safe_delete_path_entry)); - if (buf && strlen(buf) > 0) options->safe_delete_path = remove_trailing_slash(buf); + if (buf && strlen(buf) > 0) options->file_ops.safe_delete_path = remove_trailing_slash(buf); if (options->file_filter.show_dot_files != c_options->file_filter.show_dot_files) refresh = TRUE; if (options->file_sort.case_sensitive != c_options->file_sort.case_sensitive) refresh = TRUE; if (options->file_filter.disable != c_options->file_filter.disable) refresh = TRUE; options->startup_path_enable = c_options->startup_path_enable; - options->confirm_delete = c_options->confirm_delete; - options->enable_delete_key = c_options->enable_delete_key; - options->safe_delete_enable = c_options->safe_delete_enable; - options->safe_delete_size = c_options->safe_delete_size; + options->file_ops.confirm_delete = c_options->file_ops.confirm_delete; + options->file_ops.enable_delete_key = c_options->file_ops.enable_delete_key; + options->file_ops.safe_delete_enable = c_options->file_ops.safe_delete_enable; + options->file_ops.safe_delete_folder_maxsize = c_options->file_ops.safe_delete_folder_maxsize; options->layout.tools_restore_state = c_options->layout.tools_restore_state; options->layout.save_window_positions = c_options->layout.save_window_positions; options->image.zoom_mode = c_options->image.zoom_mode; @@ -220,7 +220,7 @@ options->mousewheel_scrolls = c_options->mousewheel_scrolls; - options->enable_in_place_rename = c_options->enable_in_place_rename; + options->file_ops.enable_in_place_rename = c_options->file_ops.enable_in_place_rename; options->collections.rectangular_selection = c_options->collections.rectangular_selection; @@ -757,7 +757,7 @@ entry = gtk_entry_new(); GTK_WIDGET_UNSET_FLAGS(entry, GTK_CAN_FOCUS); gtk_editable_set_editable(GTK_EDITABLE(entry), FALSE); - if (options->safe_delete_path) gtk_entry_set_text(GTK_ENTRY(entry), options->safe_delete_path); + if (options->file_ops.safe_delete_path) gtk_entry_set_text(GTK_ENTRY(entry), options->file_ops.safe_delete_path); gtk_box_pack_start(GTK_BOX(gd->vbox), entry, FALSE, FALSE, 0); gtk_widget_show(entry); gtk_widget_show(gd->dialog); @@ -1310,12 +1310,12 @@ group = pref_group_new(vbox, FALSE, _("Delete"), GTK_ORIENTATION_VERTICAL); pref_checkbox_new_int(group, _("Confirm file delete"), - options->confirm_delete, &c_options->confirm_delete); + options->file_ops.confirm_delete, &c_options->file_ops.confirm_delete); pref_checkbox_new_int(group, _("Enable Delete key"), - options->enable_delete_key, &c_options->enable_delete_key); + options->file_ops.enable_delete_key, &c_options->file_ops.enable_delete_key); ct_button = pref_checkbox_new_int(group, _("Safe delete"), - options->safe_delete_enable, &c_options->safe_delete_enable); + options->file_ops.safe_delete_enable, &c_options->file_ops.safe_delete_enable); hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); pref_checkbox_link_sensitivity(ct_button, hbox); @@ -1323,7 +1323,7 @@ pref_spacer(hbox, PREF_PAD_INDENT - PREF_PAD_SPACE); pref_label_new(hbox, _("Folder:")); - tabcomp = tab_completion_new(&safe_delete_path_entry, options->safe_delete_path, NULL, NULL); + tabcomp = tab_completion_new(&safe_delete_path_entry, options->file_ops.safe_delete_path, NULL, NULL); tab_completion_add_select_button(safe_delete_path_entry, NULL, TRUE); gtk_box_pack_start(GTK_BOX(hbox), tabcomp, TRUE, TRUE, 0); gtk_widget_show(tabcomp); @@ -1333,7 +1333,7 @@ pref_spacer(hbox, PREF_PAD_INDENT - PREF_PAD_GAP); spin = pref_spin_new_int(hbox, _("Maximum size:"), _("MB"), - 0, 2048, 1, options->safe_delete_size, &c_options->safe_delete_size); + 0, 2048, 1, options->file_ops.safe_delete_folder_maxsize, &c_options->file_ops.safe_delete_folder_maxsize); #if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_markup(spin, _("Set to 0 for unlimited size")); #endif @@ -1356,7 +1356,7 @@ options->tree_descend_subdirs, &c_options->tree_descend_subdirs); pref_checkbox_new_int(group, _("In place renaming"), - options->enable_in_place_rename, &c_options->enable_in_place_rename); + options->file_ops.enable_in_place_rename, &c_options->file_ops.enable_in_place_rename); group = pref_group_new(vbox, FALSE, _("Navigation"), GTK_ORIENTATION_VERTICAL);
--- a/src/rcfile.c Sat Apr 12 21:45:30 2008 +0000 +++ b/src/rcfile.c Sat Apr 12 22:04:29 2008 +0000 @@ -289,22 +289,24 @@ write_bool_option(ssi, "progressive_keyboard_scrolling", options->progressive_key_scrolling); write_bool_option(ssi, "local_metadata", options->enable_metadata_dirs); - write_bool_option(ssi, "confirm_delete", options->confirm_delete); - write_bool_option(ssi, "enable_delete_key", options->enable_delete_key); - write_bool_option(ssi, "safe_delete", options->safe_delete_enable); - write_char_option(ssi, "safe_delete_path", options->safe_delete_path); - write_int_option(ssi, "safe_delete_size", options->safe_delete_size); - secure_fputc(ssi, '\n'); - write_int_option(ssi, "custom_similarity_threshold", options->dupe_custom_threshold); secure_fputc(ssi, '\n'); write_bool_option(ssi, "mouse_wheel_scrolls", options->mousewheel_scrolls); - write_bool_option(ssi, "in_place_rename", options->enable_in_place_rename); write_int_option(ssi, "open_recent_max", options->recent_list_max); write_bool_option(ssi, "display_dialogs_under_mouse", options->place_dialogs_under_mouse); + + + secure_fprintf(ssi, "\n##### File operations Options #####\n\n"); + + 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); + - secure_fprintf(ssi, "\n##### Layout Options #####\n\n"); write_int_option(ssi, "layout.style", options->layout.style); @@ -540,6 +542,42 @@ strncpy(option, s_buf, sizeof(option)); strncpy(value, s_buf_ptr, sizeof(value)); + + /* general options */ + options->show_icon_names = read_bool_option(f, option, + "show_icon_names", value, options->show_icon_names); + + options->tree_descend_subdirs = read_bool_option(f, option, + "tree_descend_folders", value, options->tree_descend_subdirs); + options->lazy_image_sync = read_bool_option(f, option, + "lazy_image_sync", value, options->lazy_image_sync); + options->update_on_time_change = read_bool_option(f, option, + "update_on_time_change", value, options->update_on_time_change); + + options->startup_path_enable = read_bool_option(f, option, + "enable_startup_path", value, options->startup_path_enable); + options->startup_path = read_char_option(f, option, + "startup_path", value_all, options->startup_path); + + options->dupe_custom_threshold = read_int_option(f, option, + "custom_similarity_threshold", value, options->dupe_custom_threshold); + + options->progressive_key_scrolling = read_bool_option(f, option, + "progressive_keyboard_scrolling", value, options->progressive_key_scrolling); + + options->enable_metadata_dirs = read_bool_option(f, option, + "local_metadata", value, options->enable_metadata_dirs); + + options->mousewheel_scrolls = read_bool_option(f, option, + "mouse_wheel_scrolls", value, options->mousewheel_scrolls); + + options->recent_list_max = read_int_option(f, option, + "open_recent_max", value, options->recent_list_max); + + options->place_dialogs_under_mouse = read_bool_option(f, option, + "display_dialogs_under_mouse", value, options->place_dialogs_under_mouse); + + /* layout options */ options->layout.style = read_int_option(f, option, @@ -592,22 +630,6 @@ "layout.toolbar_hidden", value, options->layout.toolbar_hidden); - /* general options */ - options->show_icon_names = read_bool_option(f, option, - "show_icon_names", value, options->show_icon_names); - - options->tree_descend_subdirs = read_bool_option(f, option, - "tree_descend_folders", value, options->tree_descend_subdirs); - options->lazy_image_sync = read_bool_option(f, option, - "lazy_image_sync", value, options->lazy_image_sync); - options->update_on_time_change = read_bool_option(f, option, - "update_on_time_change", value, options->update_on_time_change); - - options->startup_path_enable = read_bool_option(f, option, - "enable_startup_path", value, options->startup_path_enable); - options->startup_path = read_char_option(f, option, - "startup_path", value_all, options->startup_path); - /* image options */ if (strcasecmp(option, "image.zoom_mode") == 0) { @@ -648,9 +670,6 @@ read_color_option(f, option, "image.border_color", value, &options->image.border_color); - options->progressive_key_scrolling = read_bool_option(f, option, - "progressive_keyboard_scrolling", value, options->progressive_key_scrolling); - /* thumbnails options */ options->thumbnails.max_width = read_int_option(f, option, @@ -672,9 +691,6 @@ options->thumbnails.quality = CLAMP(read_int_option(f, option, "thumbnails.quality", value, options->thumbnails.quality), GDK_INTERP_NEAREST, GDK_INTERP_HYPER); - options->enable_metadata_dirs = read_bool_option(f, option, - "local_metadata", value, options->enable_metadata_dirs); - /* file sorting options */ options->file_sort.method = (SortType)read_int_option(f, option, "file_sort.method", value, (gint)options->file_sort.method); @@ -683,28 +699,21 @@ options->file_sort.case_sensitive = read_bool_option(f, option, "file_sort.case_sensitive", value, options->file_sort.case_sensitive); - options->confirm_delete = read_bool_option(f, option, - "confirm_delete", value, options->confirm_delete); - options->enable_delete_key = read_bool_option(f, option, - "enable_delete_key", value, options->enable_delete_key); - options->safe_delete_enable = read_bool_option(f, option, - "safe_delete", value, options->safe_delete_enable); - options->safe_delete_path = read_char_option(f, option, - "safe_delete_path", value, options->safe_delete_path); - options->safe_delete_size = read_int_option(f, option, - "safe_delete_size", value,options->safe_delete_size); + /* file operations options */ + options->file_ops.enable_in_place_rename = read_bool_option(f, option, + "file_ops.enable_in_place_rename", value, options->file_ops.enable_in_place_rename); + options->file_ops.confirm_delete = read_bool_option(f, option, + "file_ops.confirm_delete", value, options->file_ops.confirm_delete); + options->file_ops.enable_delete_key = read_bool_option(f, option, + "file_ops.enable_delete_key", value, options->file_ops.enable_delete_key); + options->file_ops.safe_delete_enable = read_bool_option(f, option, + "file_ops.safe_delete_enable", value, options->file_ops.safe_delete_enable); + options->file_ops.safe_delete_path = read_char_option(f, option, + "file_ops.safe_delete_path", value, options->file_ops.safe_delete_path); + options->file_ops.safe_delete_folder_maxsize = read_int_option(f, option, + "file_ops.safe_delete_folder_maxsize", value,options->file_ops.safe_delete_folder_maxsize); - options->mousewheel_scrolls = read_bool_option(f, option, - "mouse_wheel_scrolls", value, options->mousewheel_scrolls); - options->enable_in_place_rename = read_bool_option(f, option, - "in_place_rename", value, options->enable_in_place_rename); - - options->recent_list_max = read_int_option(f, option, - "open_recent_max", value, options->recent_list_max); - - options->place_dialogs_under_mouse = read_bool_option(f, option, - "display_dialogs_under_mouse", value, options->place_dialogs_under_mouse); - + /* fullscreen options */ options->fullscreen.screen = read_int_option(f, option, "fullscreen.screen", value, options->fullscreen.screen); options->fullscreen.clean_flip = read_bool_option(f, option, @@ -718,9 +727,6 @@ options->fullscreen.info = read_char_option(f, option, "fullscreen.info", value_all, options->fullscreen.info); - options->dupe_custom_threshold = read_int_option(f, option, - "custom_similarity_threshold", value, options->dupe_custom_threshold); - /* slideshow options */ options->slideshow.delay = read_int_unit_option(f, option,
--- a/src/typedefs.h Sat Apr 12 21:45:30 2008 +0000 +++ b/src/typedefs.h Sat Apr 12 22:04:29 2008 +0000 @@ -739,7 +739,6 @@ gint show_icon_names; /* various */ - gint enable_in_place_rename; gint startup_path_enable; gchar *startup_path; gint enable_metadata_dirs; @@ -749,16 +748,21 @@ gint lazy_image_sync; gint update_on_time_change; - gint confirm_delete; - gint enable_delete_key; - gint safe_delete_enable; - gchar *safe_delete_path; - gint safe_delete_size; - gint dupe_custom_threshold; gint recent_list_max; + /* file ops */ + struct { + gint enable_in_place_rename; + + gint confirm_delete; + gint enable_delete_key; + gint safe_delete_enable; + gchar *safe_delete_path; + gint safe_delete_folder_maxsize; + } file_ops; + /* image */ struct { gint exif_rotate_enable;
--- a/src/utilops.c Sat Apr 12 21:45:30 2008 +0000 +++ b/src/utilops.c Sat Apr 12 22:04:29 2008 +0000 @@ -1304,7 +1304,7 @@ gint sorted = FALSE; gint warned = FALSE; - if (!filelist_read(options->safe_delete_path, &list, NULL)) return 0; + if (!filelist_read(options->file_ops.safe_delete_path, &list, NULL)) return 0; work = list; while (work) @@ -1321,8 +1321,8 @@ total += fd->size; } - while (options->safe_delete_size > 0 && list && - (free_space < 0 || total + free_space > (gint64)options->safe_delete_size * 1048576) ) + while (options->file_ops.safe_delete_folder_maxsize > 0 && list && + (free_space < 0 || total + free_space > (gint64)options->file_ops.safe_delete_folder_maxsize * 1048576) ) { FileData *fd; @@ -1362,12 +1362,12 @@ gint n; n = file_util_safe_number(filesize(path)); - return g_strdup_printf("%s/%06d_%s", options->safe_delete_path, n, filename_from_path(path)); + return g_strdup_printf("%s/%06d_%s", options->file_ops.safe_delete_path, n, filename_from_path(path)); } static void file_util_safe_del_toggle_cb(GtkWidget *button, gpointer data) { - options->safe_delete_enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); + options->file_ops.safe_delete_enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); } static void file_util_safe_del_close_cb(GtkWidget *dialog, gpointer data) @@ -1386,15 +1386,15 @@ if (!isfile(fd->path)) return FALSE; - if (!options->safe_delete_enable) + if (!options->file_ops.safe_delete_enable) { return unlink_file(fd->path); } - if (!isdir(options->safe_delete_path)) + if (!isdir(options->file_ops.safe_delete_path)) { - if (debug) printf("creating trash: %s\n", options->safe_delete_path); - if (!options->safe_delete_path || !mkdir_utf8(options->safe_delete_path, 0755)) + if (debug) printf("creating trash: %s\n", options->file_ops.safe_delete_path); + if (!options->file_ops.safe_delete_path || !mkdir_utf8(options->file_ops.safe_delete_path, 0755)) { result = _("Could not create folder"); success = FALSE; @@ -1428,7 +1428,7 @@ GtkWidget *button; gchar *buf; - buf = g_strdup_printf(_("Unable to access or create the trash folder.\n\"%s\""), options->safe_delete_path); + buf = g_strdup_printf(_("Unable to access or create the trash folder.\n\"%s\""), options->file_ops.safe_delete_path); gd = file_util_warning_dialog(result, buf, GTK_STOCK_DIALOG_WARNING, NULL); g_free(buf); @@ -1456,15 +1456,15 @@ } else { - if (options->safe_delete_enable) + if (options->file_ops.safe_delete_enable) { gchar *buf2; - if (options->safe_delete_size > 0) - buf2 = g_strdup_printf(_(" (max. %d MB)"), options->safe_delete_size); + if (options->file_ops.safe_delete_folder_maxsize > 0) + buf2 = g_strdup_printf(_(" (max. %d MB)"), options->file_ops.safe_delete_folder_maxsize); else buf2 = g_strdup(""); - buf = g_strdup_printf(_("Safe delete: %s%s\nTrash: %s"), _("on"), buf2, options->safe_delete_path); + buf = g_strdup_printf(_("Safe delete: %s%s\nTrash: %s"), _("on"), buf2, options->file_ops.safe_delete_path); g_free(buf2); } else @@ -1746,7 +1746,7 @@ static void file_util_delete_multiple(GList *source_list, GtkWidget *parent) { - if (!options->confirm_delete) + if (!options->file_ops.confirm_delete) { file_util_delete_multiple_ok_cb(NULL, source_list); } @@ -1846,7 +1846,7 @@ static void file_util_delete_single(FileData *fd, GtkWidget *parent) { - if (!options->confirm_delete) + if (!options->file_ops.confirm_delete) { file_util_delete_ok_cb(NULL, file_data_ref(fd)); }
--- a/src/view_file_list.c Sat Apr 12 21:45:30 2008 +0000 +++ b/src/view_file_list.c Sat Apr 12 22:04:29 2008 +0000 @@ -356,7 +356,7 @@ GList *list; list = vflist_pop_menu_file_list(vfl); - if (options->enable_in_place_rename && + if (options->file_ops.enable_in_place_rename && list && !list->next && vfl->click_fd) { GtkTreeModel *store;