diff --git a/setup.py b/setup.py index a461239..a0218d8 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,6 @@ setup(name = "simplesvnbrowser", license = "zlib", packages = ["simplesvnbrowser"], zip_safe = False, - scripts = ["bin/simple-svn-browser"], + install_requires = ["pyxdg"], ) diff --git a/simplesvnbrowser/cache_file.py b/simplesvnbrowser/cache_file.py new file mode 100644 index 0000000..b9ef56d --- /dev/null +++ b/simplesvnbrowser/cache_file.py @@ -0,0 +1,20 @@ +import xdg.BaseDirectory +import os + +class CacheFile: + params = None + + def __init__(self): + if CacheFile.params is None: + CacheFile.params = {} + cfp = self.__cache_file_path() + if os.path.exists(cfp): + with open(cfp, "r") as f: + cache_content = f.read() + exec(cache_content, CacheFile.params) + + def __cache_dir(self): + return xdg.BaseDirectory.save_cache_path("simple-svn-browser") + + def __cache_file_path(self): + return os.path.join(self.__cache_dir(), "settings") diff --git a/simplesvnbrowser/main_window.py b/simplesvnbrowser/main_window.py index 9fa253e..7ebaf5b 100644 --- a/simplesvnbrowser/main_window.py +++ b/simplesvnbrowser/main_window.py @@ -3,11 +3,14 @@ gi.require_version("Gtk", "3.0") from gi.repository import Gtk from .version import VERSION from .run_svn import run_svn +from .cache_file import CacheFile class MainWindow(Gtk.Window): def __init__(self, url): super().__init__(title = "Simple SVN Browser v%s" % VERSION) + self.cache_file = CacheFile() + top_hbox = Gtk.Box() address_entry = Gtk.Entry(text = url) go_button = Gtk.Button(label = "Go")