From 4966a2db4c3add44fc23e141fff61f438786c0ca Mon Sep 17 00:00:00 2001 From: Ariel Calzada Date: Tue, 08 Jan 2013 12:58:59 +0000 Subject: issue dxo #310 and #2769 Custom start/homepage for Browse --- (limited to 'browser.py') diff --git a/browser.py b/browser.py index 7419d2d..47be4c6 100644 --- a/browser.py +++ b/browser.py @@ -340,14 +340,38 @@ class TabbedView(BrowserNotebook): def load_homepage(self): browser = self.current_browser - if os.path.isfile(_LIBRARY_PATH): + if os.path.isfile(activity.get_bundle_path() + "/data/homepage.conf"): + confFile = os.path.join(activity.get_bundle_path(),"data/homepage.conf") + f = open(confFile,"r") + contents = f.read().strip() + f.close() + + if contents != "": + default_page = contents + else: + default_page = os.path.join(activity.get_bundle_path(),"data/index.html") + + browser.load_uri(default_page) + elif os.path.isfile(_LIBRARY_PATH): browser.load_uri('file://' + _LIBRARY_PATH) else: default_page = os.path.join(activity.get_bundle_path(), "data/index.html") browser.load_uri('file://' + default_page) + browser.grab_focus() + def change_homepage(self): + """ Change data/homepage.conf with current URL + """ + confFile = os.path.join(activity.get_bundle_path(),"data/homepage.conf") + index = self.get_current_page() + ui_uri = self.get_nth_page(index).browser.get_uri() + + f = open ( confFile,"w") + f.write(ui_uri) + f.close() + def _get_current_browser(self): if self.get_n_pages(): return self.get_nth_page(self.get_current_page()).browser -- cgit v0.9.1