An option to save and restore the last path used was added.
authorLaurent Monin <geeqie@norz.org>
Sun, 11 May 2008 13:14:58 +0000 (13:14 +0000)
committerLaurent Monin <geeqie@norz.org>
Sun, 11 May 2008 13:14:58 +0000 (13:14 +0000)
This option appears as startup.use_last_path in rc file.
Preferences > General > Startup was modified accordingly.

src/main.c
src/options.c
src/options.h
src/preferences.c
src/rcfile.c

index ae8c714..d8681f5 100644 (file)
@@ -1229,6 +1229,12 @@ static void exit_program_final(void)
                                       &options->color_profile.screen_type,
                                       &options->color_profile.use_image);
 
+       if (options->startup.restore_path && options->startup.use_last_path)
+               {
+               g_free(options->startup.path);
+               options->startup.path = g_strdup(layout_get_path(NULL));
+               }
+
        save_options();
        keys_save();
 
@@ -1302,7 +1308,7 @@ void exit_program(void)
        exit_program_final();
 }
 
-int main (int argc, char *argv[])
+int main(int argc, char *argv[])
 {
        LayoutWindow *lw;
        gchar *path = NULL;
index dbb8bdc..61d9e27 100644 (file)
@@ -127,8 +127,9 @@ ConfOptions *init_options(ConfOptions *options)
        options->slideshow.random = FALSE;
        options->slideshow.repeat = FALSE;
 
-       options->startup.restore_path = FALSE;
        options->startup.path = NULL;
+       options->startup.restore_path = FALSE;
+       options->startup.use_last_path = FALSE;
 
        options->thumbnails.cache_into_dirs = FALSE;
        options->thumbnails.enable_caching = TRUE;
index f38a14b..1b8386f 100644 (file)
@@ -41,6 +41,7 @@ struct _ConfOptions
 
        struct {
                gboolean restore_path;
+               gboolean use_last_path;
                gchar *path;
        } startup;
 
index f633fee..7608c92 100644 (file)
@@ -173,11 +173,6 @@ static void config_window_apply(void)
                }
        layout_edit_update_all();
 
-       g_free(options->startup.path);
-       options->startup.path = NULL;
-       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->file_ops.safe_delete_path);
        options->file_ops.safe_delete_path = NULL;
        buf = gtk_entry_get_text(GTK_ENTRY(safe_delete_path_entry));
@@ -189,6 +184,12 @@ static void config_window_apply(void)
        if (options->file_filter.disable != c_options->file_filter.disable) refresh = TRUE;
 
        options->startup.restore_path = c_options->startup.restore_path;
+       options->startup.use_last_path = c_options->startup.use_last_path;
+       g_free(options->startup.path);
+       options->startup.path = NULL;
+       buf = gtk_entry_get_text(GTK_ENTRY(startup_path_entry));
+       if (buf && strlen(buf) > 0) options->startup.path = remove_trailing_slash(buf);
+
        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;
@@ -841,6 +842,7 @@ static void config_tab_general(GtkWidget *notebook)
        GtkWidget *label;
        GtkWidget *hbox;
        GtkWidget *vbox;
+       GtkWidget *subvbox;
        GtkWidget *group;
        GtkWidget *subgroup;
        GtkWidget *button;
@@ -857,11 +859,13 @@ static void config_tab_general(GtkWidget *notebook)
 
        group = pref_group_new(vbox, FALSE, _("Startup"), GTK_ORIENTATION_VERTICAL);
 
-       button = pref_checkbox_new_int(group, _("Change to folder:"),
+       button = pref_checkbox_new_int(group, _("Restore folder on startup"),
                                       options->startup.restore_path, &c_options->startup.restore_path);
 
-       hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
-       pref_checkbox_link_sensitivity(button, hbox);
+       subvbox = pref_box_new(group, FALSE, GTK_ORIENTATION_VERTICAL, PREF_PAD_SPACE);
+       pref_checkbox_link_sensitivity(button, subvbox);
+
+       hbox = pref_box_new(subvbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
 
        tabcomp = tab_completion_new(&startup_path_entry, options->startup.path, NULL, NULL);
        tab_completion_add_select_button(startup_path_entry, NULL, TRUE);
@@ -871,6 +875,11 @@ static void config_tab_general(GtkWidget *notebook)
        button = pref_button_new(hbox, NULL, _("Use current"), FALSE,
                                 G_CALLBACK(startup_path_set_current), NULL);
 
+       button = pref_checkbox_new_int(subvbox, _("Use last path"),
+                                      options->startup.use_last_path, &c_options->startup.use_last_path);
+       pref_checkbox_link_sensitivity_swap(button, hbox);
+
+
        group = pref_group_new(vbox, FALSE, _("Thumbnails"), GTK_ORIENTATION_VERTICAL);
 
        table = pref_table_new(group, 2, 2, FALSE, FALSE);
index ee949f8..4d633c0 100644 (file)
@@ -325,6 +325,7 @@ void save_options(void)
        WRITE_SUBTITLE("Startup Options");
 
        WRITE_BOOL(startup.restore_path);
+       WRITE_BOOL(startup.use_last_path);
        WRITE_CHAR(startup.path);
 
 
@@ -646,6 +647,8 @@ void load_options(void)
                COMPAT_READ_BOOL(startup_path_enable, startup.restore_path); /* 2008/05/11 */
                READ_BOOL(startup.restore_path);
 
+               READ_BOOL(startup.use_last_path);
+
                COMPAT_READ_CHAR(startup_path, startup.path); /* 2008/05/11 */
                READ_CHAR(startup.path);