~ubuntu-core-dev/update-manager/main

« back to all changes in this revision

Viewing changes to UpdateManager/ReleaseNotesViewerWebkit.py

  • Committer: Michael Terry
  • Date: 2012-06-28 16:15:24 UTC
  • Revision ID: michael.terry@canonical.com-20120628161524-hqs1adtbgl6qahio
drop DistUpgradeFetcher and related bits from this package and move them into ubuntu-release-upgrader

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# ReleaseNotesViewer.py
2
 
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
3
 
#
4
 
#  Copyright (c) 2011 Canonical
5
 
#
6
 
#  Author: Michael Vogt <mvo@ubutnu.com>
7
 
#
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".
11
 
#
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.
16
 
#
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.
21
 
#
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
25
 
#  USA
26
 
 
27
 
from __future__ import absolute_import
28
 
 
29
 
from gi.repository import Gtk
30
 
from gi.repository import WebKit
31
 
 
32
 
from .ReleaseNotesViewer import open_url
33
 
 
34
 
 
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)
41
 
 
42
 
    def _on_navigation_policy_decision_requested(self, view, frame, request,
43
 
                                                 action, policy):
44
 
        open_url(request.get_uri())
45
 
        policy.ignore()
46
 
        return True
47
 
 
48
 
 
49
 
if __name__ == "__main__":
50
 
    win = Gtk.Window()
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")
56
 
    scroll.add(rv)
57
 
    win.add(scroll)
58
 
    win.show_all()
59
 
    Gtk.main()