1
# ReleaseNotesViewer.py
3
# Copyright (c) 2011 Canonical
5
# Author: Michael Vogt <mvo@ubutnu.com>
7
# This modul provides an inheritance of the Gtk.TextView that is
8
# aware of http URLs and allows to open them in a browser.
9
# It is based on the pygtk-demo "hypertext".
11
# This program is free software; you can redistribute it and/or
12
# modify it under the terms of the GNU General Public License as
13
# published by the Free Software Foundation; either version 2 of the
14
# License, or (at your option) any later version.
16
# This program is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
# GNU General Public License for more details.
21
# You should have received a copy of the GNU General Public License
22
# along with this program; if not, write to the Free Software
23
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26
from __future__ import absolute_import
28
from gi.repository import Gtk
29
from gi.repository import WebKit
31
from .ReleaseNotesViewer import open_url
33
class ReleaseNotesViewerWebkit(WebKit.WebView):
34
def __init__(self, notes_url):
35
super(ReleaseNotesViewerWebkit, self).__init__()
36
self.load_uri(notes_url)
37
self.connect("navigation-policy-decision-requested", self._on_navigation_policy_decision_requested)
38
def _on_navigation_policy_decision_requested(self, view, frame, request, action, policy):
39
open_url(request.get_uri())
44
if __name__ == "__main__":
46
win.set_size_request(600, 400)
47
scroll = Gtk.ScrolledWindow()
48
rv = ReleaseNotesViewerWebkit("http://archive.ubuntu.com/ubuntu/dists/natty/main/dist-upgrader-all/0.150/ReleaseAnnouncement.html")