[gthumb] copy/move dialog: save the list of the last 10 choosed folders
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] copy/move dialog: save the list of the last 10 choosed folders
- Date: Sat, 24 Mar 2012 16:18:18 +0000 (UTC)
commit 543a706e6cfe41729acfc532179f2ae47713ef2d
Author: Paolo Bacchilega <paobac src gnome org>
Date: Fri Mar 23 20:25:37 2012 +0100
copy/move dialog: save the list of the last 10 choosed folders
[new feature]
data/org.gnome.gthumb.file-manager.gschema.xml.in | 3 ++
extensions/file_manager/actions.c | 25 ++++++++++++++++++++-
extensions/file_manager/preferences.h | 1 +
3 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/data/org.gnome.gthumb.file-manager.gschema.xml.in b/data/org.gnome.gthumb.file-manager.gschema.xml.in
index 3887517..5419b97 100644
--- a/data/org.gnome.gthumb.file-manager.gschema.xml.in
+++ b/data/org.gnome.gthumb.file-manager.gschema.xml.in
@@ -25,6 +25,9 @@
<key name="view-destination" type="b">
<default>true</default>
</key>
+ <key name="copy-destination-history" type="as">
+ <default>[]</default>
+ </key>
</schema>
</schemalist>
diff --git a/extensions/file_manager/actions.c b/extensions/file_manager/actions.c
index cf60ea3..fb3bd8e 100644
--- a/extensions/file_manager/actions.c
+++ b/extensions/file_manager/actions.c
@@ -29,6 +29,9 @@
#include "preferences.h"
+#define MAX_HISTORY_LENGTH 10
+
+
typedef struct {
GthBrowser *browser;
GFile *parent;
@@ -907,13 +910,15 @@ copy_to_folder_dialog (GthBrowser *browser,
GSettings *settings;
GtkWidget *dialog;
char *start_uri;
+ GList *history;
+ GList *scan;
GtkWidget *box;
GtkWidget *view_destination_button;
settings = g_settings_new (GTHUMB_FILE_MANAGER_SCHEMA);
dialog = gtk_file_chooser_dialog_new (move ? _("Move To") : _("Copy To"),
- NULL,
+ GTK_WINDOW (browser),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
(move ? _("Move") : _("Copy")), GTK_RESPONSE_ACCEPT,
@@ -927,6 +932,12 @@ copy_to_folder_dialog (GthBrowser *browser,
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog), start_uri);
g_free(start_uri);
+ history = _g_settings_get_string_list (settings, PREF_FILE_MANAGER_COPY_HISTORY);
+ for (scan = history; scan; scan = scan->next) {
+ char *uri = scan->data;
+ gtk_file_chooser_add_shortcut_folder_uri (GTK_FILE_CHOOSER (dialog), uri, NULL);
+ }
+
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_set_border_width (GTK_CONTAINER (box), 6);
gtk_widget_show (box);
@@ -952,6 +963,17 @@ copy_to_folder_dialog (GthBrowser *browser,
g_settings_set_boolean (settings, PREF_FILE_MANAGER_COPY_VIEW_DESTINATION, view_destination);
g_settings_set_string (settings, PREF_FILE_MANAGER_COPY_LAST_FOLDER, destination_uri);
+ /* save the destination in the history list, prevent
+ * the list from growing without limit. */
+
+ history = g_list_prepend (history, g_strdup (destination_uri));
+ while (g_list_length (history) > MAX_HISTORY_LENGTH) {
+ GList *link = g_list_last (history);
+ history = g_list_remove_link (history, link);
+ _g_string_list_free (link);
+ }
+ _g_settings_set_string_list (settings, PREF_FILE_MANAGER_COPY_HISTORY, history);
+
/* copy / move the files */
copy_files_to_folder (browser, files, move, destination_uri, view_destination);
@@ -960,6 +982,7 @@ copy_to_folder_dialog (GthBrowser *browser,
g_free (destination_uri);
}
+ _g_string_list_free (history);
gtk_widget_destroy (dialog);
g_object_unref (settings);
}
diff --git a/extensions/file_manager/preferences.h b/extensions/file_manager/preferences.h
index 46f11d1..ae8c29c 100644
--- a/extensions/file_manager/preferences.h
+++ b/extensions/file_manager/preferences.h
@@ -32,6 +32,7 @@ G_BEGIN_DECLS
#define PREF_FILE_MANAGER_COPY_LAST_FOLDER "last-folder"
#define PREF_FILE_MANAGER_COPY_VIEW_DESTINATION "view-destination"
+#define PREF_FILE_MANAGER_COPY_HISTORY "copy-destination-history"
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]