[hamster-applet] remembering report path. fixes bug 617913



commit 6ee9d259bdfe4f7a39d81a4315812a277ab759d1
Author: Toms Bauģis <toms baugis gmail com>
Date:   Sat Jun 5 20:48:41 2010 +0100

    remembering report path. fixes bug 617913

 src/hamster/configuration.py               |    3 ++-
 src/hamster/widgets/reportchooserdialog.py |   11 ++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/hamster/configuration.py b/src/hamster/configuration.py
index 8d6cc66..758fdec 100644
--- a/src/hamster/configuration.py
+++ b/src/hamster/configuration.py
@@ -175,7 +175,8 @@ class GConfStore(gobject.GObject, Singleton):
         'workspace_mapping'           :   [],          # Mapping between workspace numbers and activities
         'standalone_window_box'       :   [],          # X, Y, W, H
         'standalone_window_maximized' :   False,       # Is overview window maximized
-        'activities_source'           :   "",           # Source of TODO items ("", "evo", "gtg")
+        'activities_source'           :   "",          # Source of TODO items ("", "evo", "gtg")
+        'last_report_folder'          :   "~",         # Path to directory where the last report was saved
     }
 
     __gsignals__ = {
diff --git a/src/hamster/widgets/reportchooserdialog.py b/src/hamster/widgets/reportchooserdialog.py
index 9c560ba..4d75e26 100644
--- a/src/hamster/widgets/reportchooserdialog.py
+++ b/src/hamster/widgets/reportchooserdialog.py
@@ -23,6 +23,7 @@ pygtk.require('2.0')
 
 import os
 import gtk, gobject
+from .hamster.configuration import conf
 
 class ReportChooserDialog(gtk.Dialog):
     __gsignals__ = {
@@ -42,7 +43,13 @@ class ReportChooserDialog(gtk.Dialog):
                                                      gtk.RESPONSE_CANCEL,
                                                      gtk.STOCK_SAVE,
                                                      gtk.RESPONSE_OK))
-        self.dialog.set_current_folder(os.path.expanduser("~"))
+
+        # try to set path to last known folder or fall back to home
+        report_folder = os.path.expanduser(conf.get("last_report_folder"))
+        if os.path.exists(report_folder):
+            self.dialog.set_current_folder(report_folder)
+        else:
+            self.dialog.set_current_folder(os.path.expanduser("~"))
 
         self.filters = {}
 
@@ -125,6 +132,8 @@ class ReportChooserDialog(gtk.Dialog):
 
         categories = []
 
+        conf.set("last_report_folder", os.path.dirname(path))
+
         # format, path, start_date, end_date
         self.emit("report-chosen", format, path)
         self.dialog.destroy()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]