Merge lp:~chrisccoulson/screenlets/webkit-port into lp:screenlets

Proposed by Chris Coulson
Status: Merged
Merge reported by: Märt Põder
Merged at revision: not available
Proposed branch: lp:~chrisccoulson/screenlets/webkit-port
Merge into: lp:screenlets
Diff against target: 280 lines (+23/-127)
5 files modified
debian/control (+1/-1)
setup.py (+0/-1)
src/share/screenlets-manager/WebappScreenlet.py (+9/-60)
src/share/screenlets-manager/WidgetScreenlet.py (+13/-63)
src/share/screenlets-manager/screenlets-manager.py (+0/-2)
To merge this branch: bzr merge lp:~chrisccoulson/screenlets/webkit-port
Reviewer Review Type Date Requested Status
Märt Põder Approve
Review via email: mp+63787@code.launchpad.net

Description of the change

Hi,

We're planning to drop xulrunner from Ubuntu in Oneiric, and Mozilla have dropped support for GtkMozEmbed anyway. Here is a first cut at porting the gtkmozembed parts of screenlets to webkit

(see https://blueprints.launchpad.net/ubuntu/+spec/desktop-o-mozilla-rapid-release-maintenance)

To post a comment you must log in.
679. By Chris Coulson

import webkit in a try/except clause, as python-webkit is only a recommend

Revision history for this message
Märt Põder (boamaod) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2011-04-25 12:40:42 +0000
3+++ debian/control 2011-06-08 20:36:52 +0000
4@@ -28,7 +28,7 @@
5 python-xdg,
6 python-gconf,
7 python-beautifulsoup,
8-Recommends: python-gtkmozembed | python-gnome2-extras (<< 2.19),
9+Recommends: python-webkit,
10 python-evolution | python-gnome2-desktop,
11 python-rsvg | python-gnome2-desktop,
12 metacity (>= 2.21.4) | xcompmgr | compiz | xfwm4 (>= 4.2) | mutter,
13
14=== modified file 'setup.py'
15--- setup.py 2011-03-26 19:27:07 +0000
16+++ setup.py 2011-06-08 20:36:52 +0000
17@@ -81,7 +81,6 @@
18 'src/share/screenlets-manager/KarambaScreenlet.py',
19 'src/share/screenlets-manager/widget.png',
20 'src/share/screenlets-manager/WidgetScreenlet.py',
21- 'src/share/screenlets-manager/prefs.js',
22 'src/share/screenlets-manager/webapp.png',
23 'src/share/screenlets-manager/WebappScreenlet.py',
24 'src/share/screenlets-manager/karamba.png']))
25
26=== modified file 'src/share/screenlets-manager/WebappScreenlet.py'
27--- src/share/screenlets-manager/WebappScreenlet.py 2008-04-10 15:10:23 +0000
28+++ src/share/screenlets-manager/WebappScreenlet.py 2011-06-08 20:36:52 +0000
29@@ -22,59 +22,13 @@
30 import os
31 from screenlets import sensors
32
33-#########WORKARROUND FOR GTKOZEMBED BUG BY WHISE################
34 myfile = 'WebappScreenlet.py'
35-mypath = sys.argv[0][:sys.argv[0].find('myfile')].strip()
36-
37-if sys.argv[0].endswith(myfile): # Makes Shure its not the manager running...
38- # First workarround
39- c = None
40- workarround = "python "+ sys.argv[0] + " &"
41- a = str(commands.getoutput('whereis firefox')).replace('firefox: ','').split(' ')
42- for b in a:
43- if os.path.isfile(b + '/run-mozilla.sh'):
44- c = b + '/run-mozilla.sh'
45- workarround = c + " " + sys.argv[0] + " &"
46-
47- if c == None:
48- # Second workarround
49- print 'First workarround didnt work let run a second manual workarround'
50- if str(sensors.sys_get_distrib_name()).lower().find('ubuntu') != -1: # Works for ubuntu 32
51- workarround = "export LD_LIBRARY_PATH=/usr/lib/firefox \n export MOZILLA_FIVE_HOME=/usr/lib/firefox \n python "+ sys.argv[0] + " &"
52- elif str(sensors.sys_get_distrib_name()).lower().find('debian') != -1: # Works for debian 32 with iceweasel installed
53- workarround = "export LD_LIBRARY_PATH=/usr/lib/iceweasel \n export MOZILLA_FIVE_HOME=/usr/lib/iceweasel \n python " + sys.argv[0] + " &"
54- elif str(sensors.sys_get_distrib_name()).lower().find('suse') != -1: # Works for suse 32 with seamonkey installed
55- workarround = "export LD_LIBRARY_PATH=/usr/lib/seamonkey \n export MOZILLA_FIVE_HOME=/usr/lib/seamonkey \n python "+ sys.argv[0] + " &"
56- print 'Your running suse , make shure you have seamonkey installed'
57- elif str(sensors.sys_get_distrib_name()).lower().find('fedora') != -1: # Works for fedora 32 with seamonkey installed
58- workarround = "export LD_LIBRARY_PATH=/usr/lib/seamonkey \n export MOZILLA_FIVE_HOME=/usr/lib/seamonkey \n python "+ sys.argv[0] + " &"
59- print 'Your running fedora , make shure you have seamonkey installed'
60-
61-
62- if os.path.isfile("/tmp/"+ myfile+"running"):
63- os.system("rm -f " + "/tmp/"+ myfile+"running")
64-
65- else:
66- if workarround == "python "+ sys.argv[0] + " &":
67- print 'No workarround will be applied to your sistem , this screenlet will probably not work properly'
68- os.system (workarround)
69- fileObj = open("/tmp/"+ myfile+"running","w") #// open for for write
70- fileObj.write('gtkmozembed bug workarround')
71-
72- fileObj.close()
73- sys.exit()
74-
75-
76-else:
77- pass
78+
79 try:
80- import gtkmozembed
81+ import webkit
82 except:
83- if sys.argv[0].endswith(myfile):screenlets.show_error(None,"You need Gtkmozembed to run this Screenlet , please install it")
84- else: print "You need Gtkmozembed to run this Screenlet , please install it"
85-#########WORKARROUND FOR GTKOZEMBED BUG BY WHISE################
86-
87-
88+ if sys.argv[0].endswith(myfile):screenlets.show_error(None,"You need WebKit to run this Screenlet , please install it")
89+ else: print "You need WebKit to run this Screenlet , please install it"
90
91 class WebappScreenlet (screenlets.Screenlet):
92 """Brings Web applications to your desktop"""
93@@ -93,21 +47,16 @@
94 screenlets.Screenlet.__init__(self, width=325, height=370,uses_theme=True,
95 is_widget=False, is_sticky=True,draw_buttons=False, **keyword_args)
96
97- if hasattr(gtkmozembed, 'set_profile_path'):
98- gtkmozembed.set_profile_path(self.mypath,'mozilla')
99- else:
100- gtkmozembed.gtk_moz_embed_set_profile_path(self.mypath ,'mozilla')
101-
102- self.moz = gtkmozembed.MozEmbed()
103+ self.view = webkit.WebView()
104 self.win = gtk.Window()
105
106 #self.win.maximize()
107- self.win.add(self.moz)
108+ self.win.add(self.view)
109
110- self.moz.load_url(self.url)
111+ self.view.load_uri(self.url)
112 self.win.connect('destroy',self.quitall)
113 self.win.connect("configure-event", self.configure)
114- self.moz.connect("title",self.update)
115+ self.view.connect("notify::title",self.update)
116
117
118 def configure (self, widget, event):
119@@ -133,7 +82,7 @@
120
121 def update(self,widget):
122
123- title = self.moz.get_title()
124+ title = self.view.get_title()
125 self.win.set_title(title)
126 def quitall(self,widget):
127 if len(self.session.instances) > 1:
128
129=== modified file 'src/share/screenlets-manager/WidgetScreenlet.py'
130--- src/share/screenlets-manager/WidgetScreenlet.py 2008-05-25 13:40:09 +0000
131+++ src/share/screenlets-manager/WidgetScreenlet.py 2011-06-08 20:36:52 +0000
132@@ -22,60 +22,14 @@
133 import os
134 from screenlets import sensors
135
136-
137-
138-#########WORKARROUND FOR GTKOZEMBED BUG BY WHISE################
139 myfile = 'WidgetScreenlet.py'
140-mypath = sys.argv[0][:sys.argv[0].find(myfile)].strip()
141-
142-if sys.argv[0].endswith(myfile): # Makes Shure its not the manager running...
143- # First workarround
144- c = None
145- workarround = "python "+ sys.argv[0] + " &"
146- a = str(commands.getoutput('whereis firefox')).replace('firefox: ','').split(' ')
147- for b in a:
148- if os.path.isfile(b + '/run-mozilla.sh'):
149- c = b + '/run-mozilla.sh'
150- workarround = c + " " + sys.argv[0] + " &"
151-
152-
153- if c == None:
154- # Second workarround
155- print 'First workarround didnt work let run a second manual workarround'
156- if str(sensors.sys_get_distrib_name()).lower().find('ubuntu') != -1: # Works for ubuntu 32
157- workarround = "export LD_LIBRARY_PATH=/usr/lib/firefox \n export MOZILLA_FIVE_HOME=/usr/lib/firefox \n python "+ sys.argv[0] + " &"
158- elif str(sensors.sys_get_distrib_name()).lower().find('debian') != -1: # Works for debian 32 with iceweasel installed
159- workarround = "export LD_LIBRARY_PATH=/usr/lib/iceweasel \n export MOZILLA_FIVE_HOME=/usr/lib/iceweasel \n python " + sys.argv[0] + " &"
160- elif str(sensors.sys_get_distrib_name()).lower().find('suse') != -1: # Works for suse 32 with seamonkey installed
161- workarround = "export LD_LIBRARY_PATH=/usr/lib/seamonkey \n export MOZILLA_FIVE_HOME=/usr/lib/seamonkey \n python "+ sys.argv[0] + " &"
162- print 'Your running suse , make shure you have seamonkey installed'
163- elif str(sensors.sys_get_distrib_name()).lower().find('fedora') != -1: # Works for fedora 32 with seamonkey installed
164- workarround = "export LD_LIBRARY_PATH=/usr/lib/seamonkey \n export MOZILLA_FIVE_HOME=/usr/lib/seamonkey \n python "+ sys.argv[0] + " &"
165- print 'Your running fedora , make shure you have seamonkey installed'
166-
167-
168- if os.path.isfile("/tmp/"+ myfile+"running"):
169- os.system("rm -f " + "/tmp/"+ myfile+"running")
170-
171- else:
172- if workarround == "python "+ sys.argv[0] + " &":
173- print 'No workarround will be applied to your sistem , this screenlet will probably not work properly'
174- os.system (workarround)
175- fileObj = open("/tmp/"+ myfile+"running","w") #// open for for write
176- fileObj.write('gtkmozembed bug workarround')
177-
178- fileObj.close()
179- sys.exit()
180-
181-
182-else:
183- pass
184+
185 try:
186- import gtkmozembed
187+ import webkit
188 except:
189- if sys.argv[0].endswith(myfile):screenlets.show_error(None,"You need Gtkmozembed to run this Screenlet , please install it")
190- else: print "You need Gtkmozembed to run this Screenlet , please install it"
191-#########WORKARROUND FOR GTKOZEMBED BUG BY WHISE################
192+ if sys.argv[0].endswith(myfile):screenlets.show_error(None,"You need WebKit to run this Screenlet , please install it")
193+ else: print "You need WebKit to run this Screenlet , please install it"
194+
195 #Check for internet connection required for web widgets
196
197 if sys.argv[0].endswith(myfile):# Makes Shure its not the manager running...
198@@ -97,7 +51,7 @@
199 __desc__ = __doc__
200
201 started = False
202- moz = None
203+ view = None
204 box = None
205 mypath = sys.argv[0][:sys.argv[0].find('WidgetScreenlet.py')].strip()
206 url = mypath + 'index.html'
207@@ -130,12 +84,8 @@
208 self.disable_option('scale')
209 self.theme_name = 'default'
210 self.box = gtk.VBox(False, 0)
211- if hasattr(gtkmozembed, 'set_profile_path'):
212- gtkmozembed.set_profile_path(self.mypath,'mozilla')
213- else:
214- gtkmozembed.gtk_moz_embed_set_profile_path(self.mypath ,'mozilla')
215- self.moz = gtkmozembed.MozEmbed()
216- self.box.pack_start(self.moz, False, False, 0)
217+ self.view = webkit.WebView()
218+ self.box.pack_start(self.view, False, False, 0)
219
220 self.window.add(self.box)
221
222@@ -202,7 +152,7 @@
223 #ctx.translate(0,10)
224 self.draw_scaled_image(ctx,0,0,self.width,self.height,self.mypath + 'icon.png')
225
226- self.moz.shape_combine_mask(self.bgpbms,0,0)
227+ self.view.shape_combine_mask(self.bgpbms,0,0)
228 else:
229 self.bgpb = gtk.gdk.pixbuf_new_from_file(self.mypath + 'icon.png').scale_simple(int(self.widget_width),int(self.widget_height),gtk.gdk.INTERP_HYPER)
230 self.bgpbim, self.bgpbms = self.bgpb.render_pixmap_and_mask(alpha_threshold=128)
231@@ -211,7 +161,7 @@
232 ctx.translate(0,10)
233 self.draw_image(ctx,0,0,self.mypath + 'icon.png')
234
235- self.moz.shape_combine_mask(self.bgpbms,8,8)
236+ self.view.shape_combine_mask(self.bgpbms,8,8)
237
238
239
240@@ -276,7 +226,7 @@
241 self.url = self.widget_info[13:][:(len(self.widget_info)-24)]
242
243 self.engine = 'google'
244- self.moz.load_url(self.url)
245+ self.view.load_uri(self.url)
246 print 'loading ' + self.url
247
248 self.width = int(self.widget_width)+30
249@@ -291,9 +241,9 @@
250
251 self.box.set_uposition(-1,7)
252
253- self.moz.set_size_request(-1,int(self.widget_height))
254+ self.view.set_size_request(-1,int(self.widget_height))
255 else:
256- self.moz.set_size_request(-1,int(self.height))
257+ self.view.set_size_request(-1,int(self.height))
258 self.redraw_canvas()
259
260 def on_mouse_down(self,event):
261
262=== modified file 'src/share/screenlets-manager/screenlets-manager.py'
263--- src/share/screenlets-manager/screenlets-manager.py 2011-04-24 20:51:36 +0000
264+++ src/share/screenlets-manager/screenlets-manager.py 2011-06-08 20:36:52 +0000
265@@ -1060,7 +1060,6 @@
266 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/WebappScreenlet.py ' +DIR_USER + '/' + a + '/' + a + 'Screenlet.py')
267 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/webapp.png ' +DIR_USER + '/' + a + '/icon.png')
268 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/webapp.png ' +DIR_USER + '/' + a + '/themes/default')
269- os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/prefs.js ' +DIR_USER + '/' + a + '/mozilla')
270
271 enginecopy = open(DIR_USER + '/' + a + '/' + a + 'Screenlet.py','r')
272 enginesave = enginecopy.read()
273@@ -1147,7 +1146,6 @@
274 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/WidgetScreenlet.py ' +DIR_USER + '/' + a + '/' + a + 'Screenlet.py')
275 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/widget.png ' +DIR_USER + '/' + a + '/icon.png')
276 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/widget.png ' +DIR_USER + '/' + a + '/themes/default')
277- os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/prefs.js ' +DIR_USER + '/' + a + '/mozilla')
278 enginecopy = open(DIR_USER + '/' + a + '/' + a + 'Screenlet.py','r')
279 enginesave = enginecopy.read()
280 enginesave = enginesave.replace('WidgetScreenlet',a + 'Screenlet')

Subscribers

People subscribed via source and target branches

to status/vote changes: