diff options
author | Lucian Branescu Mihaila <lucian.branescu@gmail.com> | 2009-11-28 20:51:26 (GMT) |
---|---|---|
committer | Lucian Branescu Mihaila <lucian.branescu@gmail.com> | 2009-11-28 20:51:26 (GMT) |
commit | a213ac34d010908c2208969f7ca06f3aafa2e657 (patch) | |
tree | 0f9bfb2f0888ce444f81d7f56e532dad06536743 | |
parent | 81c757a375cf505eaf73c5ffb5a04a5c8c35020a (diff) |
Add userscripts and userstyle support. The GUI needs refactoring. Not tested.
-rw-r--r-- | browser.py | 27 |
1 files changed, 23 insertions, 4 deletions
@@ -40,6 +40,7 @@ import sessionstore from palettes import ContentInvoker from sessionhistory import HistoryListener from progresslistener import ProgressListener +from usercode import ScriptListener _ZOOM_AMOUNT = 0.1 @@ -92,9 +93,9 @@ class TabbedView(gtk.Notebook): _com_interfaces_ = interfaces.nsIWindowCreator AGENT_SHEET = os.path.join(activity.get_bundle_path(), - 'agent-stylesheet.css') - USER_SHEET = os.path.join(env.get_profile_path(), 'gecko', - 'user-stylesheet.css') + 'agent-stylesheet.css') + USER_SHEET = os.path.join(activity.get_activity_root(), + 'data/style.user.css') def __init__(self): gobject.GObject.__init__(self) @@ -176,7 +177,22 @@ class TabbedView(gtk.Notebook): def _get_current_browser(self): return self.get_nth_page(self.get_current_page()) - current_browser = gobject.property(type=object, getter=_get_current_browser) + current_browser = gobject.property(type=object, getter=_get_current_browser) + + def update_userstyle(self): + cls = components.classes['@mozilla.org/content/style-sheet-service;1'] + style_sheet_service = cls.getService(interfaces.nsIStyleSheetService) + + user_sheet_uri = io_service.newURI('file:///' + TabbedView.USER_SHEET, + None, None) + + if style_sheet_service.sheetRegistered(user_sheet_uri, + interfaces.nsIStyleSheetService.USER_SHEET): + style_sheet_service.unregisterSheet(user_sheet_uri, + interfaces.nsIStyleSheetService.USER_SHEET) + + style_sheet_service.loadAndRegisterSheet(user_sheet_uri, + interfaces.nsIStyleSheetService.USER_SHEET) def get_session(self): tab_sessions = [] @@ -269,6 +285,7 @@ class Browser(WebView): self.history = HistoryListener() self.progress = ProgressListener() + self.userscript = ScriptListener() cls = components.classes["@mozilla.org/typeaheadfind;1"] self.typeahead = cls.createInstance(interfaces.nsITypeAheadFind) @@ -287,6 +304,8 @@ class Browser(WebView): self.progress.setup(self) self.history.setup(self.web_navigation) + + self.userscript.setup(self) self.typeahead.init(self.doc_shell) |