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