Merge lp:~fossfreedom/ubiquity-slideshow-ubuntu/webkit2update into lp:ubiquity-slideshow-ubuntu

Proposed by fossfreedom on 2019-02-26
Status: Merged
Approved by: Sebastien Bacher on 2019-03-14
Approved revision: 839
Merged at revision: 844
Proposed branch: lp:~fossfreedom/ubiquity-slideshow-ubuntu/webkit2update
Merge into: lp:ubiquity-slideshow-ubuntu
Diff against target: 123 lines (+26/-30)
2 files modified
Slideshow.py (+25/-29)
test-slideshow.sh (+1/-1)
To merge this branch: bzr merge lp:~fossfreedom/ubiquity-slideshow-ubuntu/webkit2update
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve on 2019-03-14
Mathieu Trudel-Lapierre 2019-02-26 Pending
Review via email: mp+363686@code.launchpad.net

Commit message

Update SlideShow to use WebKit2

Description of the change

SlideShow uses obsolete webkit to display and test.
webkit has been dropped from Disco and as such, the SlideShow no longer works.

This commit updates SlideShow.py to use WebKit2.
Some python depreciations has also been resolved.

The test-slideshow window opens too small to allow easy navigation to flavor slideshows.

The size of this zenity window has been enlarged to allow all flavors to display and selected.

Testing:

1. run ./test-slideshow
2. make flavorname and compile and run a specific flavorname
3. make flavorname locale to compile and run a specific flavorname and display with a given locale

To post a comment you must log in.
Sebastien Bacher (seb128) wrote :

Looks good to me, thx!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Slideshow.py'
2--- Slideshow.py 2015-01-11 22:18:30 +0000
3+++ Slideshow.py 2019-02-26 22:31:24 +0000
4@@ -1,7 +1,11 @@
5 #!/usr/bin/python3
6
7 import os
8-from gi.repository import GLib, Gdk, Gtk, WebKit
9+import gi
10+gi.require_version('WebKit2', '4.0')
11+gi.require_version('Gdk', '3.0')
12+gi.require_version('Gtk', '3.0')
13+from gi.repository import GLib, Gdk, Gtk, WebKit2
14 from configparser import ConfigParser
15 import subprocess
16
17@@ -10,9 +14,9 @@
18 from optparse import OptionParser
19
20
21-class SlideshowViewer(WebKit.WebView):
22+class SlideshowViewer(WebKit2.WebView):
23 '''
24- A basic GTK widget (WebKit.WebView) which displays a slideshow in the
25+ A basic GTK widget (WebKit2.WebView) which displays a slideshow in the
26 ubiquity-slideshow format. Feel free to copy and paste this to your application
27 and customize it as needed.
28 '''
29@@ -38,23 +42,24 @@
30 if controls:
31 parameters.append('controls')
32
33- WebKit.WebView.__init__(self)
34+ WebKit2.WebView.__init__(self)
35 parameters_encoded = '&'.join(parameters)
36- self.open('%s#%s' % (slideshow_main, parameters_encoded))
37+ slideshow_main = '%s#%s' % (slideshow_main, parameters_encoded)
38+ self.load_uri(slideshow_main)
39
40 settings = self.get_settings()
41- settings.set_property("enable-default-context-menu", False)
42+ ##settings.set_property("enable-default-context-menu", False)
43 #Recent webkit feature. See <http://trac.WebKit.org/changeset/52087>.
44- settings.set_property("enable-file-access-from-file-uris", True)
45+ settings.set_property("allow-file-access-from-file-urls", True)
46
47 config_width = int(config.get('Slideshow', 'width'))
48 config_height = int(config.get('Slideshow', 'height'))
49 self.set_size_request(config_width, config_height)
50
51- self.connect('navigation-policy-decision-requested', self._on_navigate_decision)
52- self.connect('navigation-requested', self._on_navigate)
53- self.connect('new-window-policy-decision-requested', self._on_new_window_decision)
54- self.connect('create-web-view', self._on_new_window)
55+ self.connect('decide-policy', self._on_navigate_decision)
56+ ##self.connect('navigation-requested', self._on_navigate)
57+ ##self.connect('new-window-policy-decision-requested', self._on_new_window_decision)
58+ ##self.connect('create-web-view', self._on_new_window)
59
60 '''
61 Determines the ideal locale for the slideshow, based on the given locale,
62@@ -79,13 +84,14 @@
63 def _new_browser_window(self, uri):
64 subprocess.Popen(['xdg-open', uri], close_fds=True)
65
66- def _on_navigate_decision(self, view, frame, req, action, decision):
67- reason = action.get_reason()
68- if reason == "link-clicked":
69- decision.use()
70+ def _on_navigate_decision(self, web_view, decision, decision_type):
71+ if decision_type == WebKit2.PolicyDecisionType.NEW_WINDOW_ACTION:
72+ request = decision.get_request()
73+ uri = request.get_uri()
74+ decision.ignore()
75+ subprocess.Popen(['sensible-browser', uri],
76+ close_fds=True)
77 return False
78-
79- decision.ignore()
80 return True
81
82 def _on_navigate(self, view, frame, req):
83@@ -131,16 +137,6 @@
84 if not os.path.exists(options.path):
85 sys.exit("\033[91m * Please build the slideshow content first by using the make command * \033[0m")
86
87-
88-Gdk.threads_init()
89-
90-# Set default SSL CA file for secure communication with web services.
91-# This is important, because libsoup is not secure by default.
92-soup_session = WebKit.get_default_session()
93-soup_session.set_property('ssl-strict', True)
94-soup_session.set_property('ssl-use-system-ca-file', True)
95-
96-
97 slideshow_window = Gtk.Window()
98 slideshow_window.set_title("Installer slideshow preview")
99 slideshow_window.connect('destroy', Gtk.main_quit)
100@@ -154,9 +150,9 @@
101
102 install_progressbar = Gtk.ProgressBar()
103 install_progressbar.set_margin_top(8)
104-install_progressbar.set_margin_right(8)
105+install_progressbar.set_margin_end(8)
106 install_progressbar.set_margin_bottom(8)
107-install_progressbar.set_margin_left(8)
108+install_progressbar.set_margin_start(8)
109 install_progressbar.set_fraction(0)
110
111
112
113=== modified file 'test-slideshow.sh'
114--- test-slideshow.sh 2015-01-15 21:39:47 +0000
115+++ test-slideshow.sh 2019-02-26 22:31:24 +0000
116@@ -19,7 +19,7 @@
117 [ $showname = "ubuntu" ] && select=TRUE
118 slideshows="$slideshows $select $showname"
119 done
120- slideshow=$(zenity --list --radiolist --column="Pick" --column="Slideshow" $slideshows --title="$TITLE" --text="Choose a slideshow to test")
121+ slideshow=$(zenity --height=450 --list --radiolist --column="Pick" --column="Slideshow" $slideshows --title="$TITLE" --text="Choose a slideshow to test")
122 [ "$slideshow" = "" ] | [ "$slideshow" = "(null)" ] && exit
123 fi
124

Subscribers

People subscribed via source and target branches