Move safe_delete* and in place rename options to file_ops
authorLaurent Monin <geeqie@norz.org>
Sat, 12 Apr 2008 22:04:29 +0000 (22:04 +0000)
committerLaurent Monin <geeqie@norz.org>
Sat, 12 Apr 2008 22:04:29 +0000 (22:04 +0000)
struct.
Re-order rc file a bit.

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

index 2f6e4d7..9d36ac5 100644 (file)
@@ -44,11 +44,11 @@ ConfOptions *init_options(ConfOptions *options)
        
        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 @@ ConfOptions *init_options(ConfOptions *options)
        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;
        
index 7b29a20..afc7b45 100644 (file)
@@ -557,7 +557,7 @@ static gint view_window_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpoi
                                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);
                                        }
index 6ab9195..d9248c2 100644 (file)
@@ -190,7 +190,7 @@ gint layout_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
                                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);
                                        }
index 2b1b3a9..5d6b73e 100644 (file)
@@ -1169,8 +1169,8 @@ static void setup_default_options(void)
        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++)
                {
index 56a3d0d..b6da0f3 100644 (file)
@@ -173,20 +173,20 @@ static void config_window_apply(void)
        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 @@ static void config_window_apply(void)
 
        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 @@ static void safe_delete_clear_cb(GtkWidget* widget, gpointer data)
        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 @@ static void config_tab_advanced(GtkWidget *notebook)
        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 @@ static void config_tab_advanced(GtkWidget *notebook)
        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 @@ static void config_tab_advanced(GtkWidget *notebook)
 
        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 @@ static void config_tab_advanced(GtkWidget *notebook)
                              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);
 
index f27857f..412e283 100644 (file)
@@ -289,22 +289,24 @@ void save_options(void)
        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 @@ void load_options(void)
                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 @@ void load_options(void)
                        "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 @@ void load_options(void)
                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 @@ void load_options(void)
                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 @@ void load_options(void)
                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);
-
-               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);
-
+               /* 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);
+
+               /* 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 @@ void load_options(void)
                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,
index 70c5d8d..4ef902a 100644 (file)
@@ -739,7 +739,6 @@ struct _ConfOptions
        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 @@ struct _ConfOptions
        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;
index 20607f6..97fcc22 100644 (file)
@@ -1304,7 +1304,7 @@ static gint file_util_safe_number(gint64 free_space)
        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 @@ static gint file_util_safe_number(gint64 free_space)
                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 @@ static gchar *file_util_safe_dest(const gchar *path)
        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 @@ static gint file_util_unlink(FileData *fd)
        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 @@ static gint file_util_unlink(FileData *fd)
                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 @@ static void box_append_safe_delete_status(GenericDialog *gd)
                }
        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_review_scroll_cb(ImageWindow *imd, GdkScro
 
 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_cancel_cb(GenericDialog *gd, gpointer data)
 
 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));
                }
index 5244d26..fa042d6 100644 (file)
@@ -356,7 +356,7 @@ static void vflist_pop_menu_rename_cb(GtkWidget *widget, gpointer data)
        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;