[gnac] Remember last used directory
- From: BenoÃt Dupasquier <bdupasqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnac] Remember last used directory
- Date: Wed, 1 Feb 2012 00:57:56 +0000 (UTC)
commit 559def32a86214b458b6475f92cc7e9bae30d508
Author: BenoÃt Dupasquier <bdupasqu src gnome org>
Date: Tue Jan 31 21:03:53 2012 +0000
Remember last used directory
src/gnac-ui.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/gnac-ui.c b/src/gnac-ui.c
index bffcbc7..7656bae 100644
--- a/src/gnac-ui.c
+++ b/src/gnac-ui.c
@@ -60,6 +60,7 @@ static GtkBuilder *gnac_main_builder = NULL;
static GtkFileFilter *default_file_filter;
static GtkStatusIcon *trayicon = NULL;
static GtkWidget *gnac_file_chooser;
+static gchar *last_used_folder = NULL;
static gchar *status_msg = NULL;
static gchar *tooltip_path = NULL;
static guint timeout_id;
@@ -103,6 +104,8 @@ gnac_ui_file_chooser_unref_filters(void)
static void
gnac_ui_file_chooser_dispose(void)
{
+ g_free(last_used_folder);
+
if (gnac_file_chooser) {
gnac_ui_file_chooser_unref_filters();
gtk_widget_destroy(gnac_file_chooser);
@@ -355,6 +358,14 @@ gnac_ui_file_chooser_foreach(gpointer data,
}
+static void
+gnac_ui_file_chooser_set_last_used_folder(gchar *folder)
+{
+ g_free(last_used_folder);
+ last_used_folder = folder;
+}
+
+
static GtkWidget *
gnac_ui_file_chooser_new(void)
{
@@ -369,6 +380,8 @@ gnac_ui_file_chooser_new(void)
(GtkCellLayoutDataFunc) gnac_ui_file_chooser_cell_data_func,
NULL, NULL);
+ last_used_folder = g_get_current_dir();
+
gnac_ui_reset_file_filter();
return gnac_file_chooser;
@@ -426,6 +439,9 @@ gnac_ui_get_file_chooser(void)
gnac_file_chooser = gnac_ui_file_chooser_new();
}
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gnac_file_chooser),
+ last_used_folder);
+
return gnac_file_chooser;
}
@@ -473,6 +489,10 @@ gnac_ui_file_chooser_response_cb(GtkDialog *dialog,
g_slist_free(paths);
gnac_add_files(files);
+ gchar *current_folder = gtk_file_chooser_get_current_folder(
+ GTK_FILE_CHOOSER(dialog));
+ gnac_ui_file_chooser_set_last_used_folder(current_folder);
+
/* Do we have to close the file chooser? */
if (!gnac_ui_file_chooser_close_on_add_button_is_active()) return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]