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

Proposed by Chris Coulson on 2011-06-07
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 2011-06-07 Approve on 2011-06-12
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 on 2011-06-08

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

Märt Põder (boamaod) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2011-04-25 12:40:42 +0000
+++ debian/control 2011-06-08 20:36:52 +0000
@@ -28,7 +28,7 @@
28 python-xdg,28 python-xdg,
29 python-gconf,29 python-gconf,
30 python-beautifulsoup,30 python-beautifulsoup,
31Recommends: python-gtkmozembed | python-gnome2-extras (<< 2.19),31Recommends: python-webkit,
32 python-evolution | python-gnome2-desktop,32 python-evolution | python-gnome2-desktop,
33 python-rsvg | python-gnome2-desktop,33 python-rsvg | python-gnome2-desktop,
34 metacity (>= 2.21.4) | xcompmgr | compiz | xfwm4 (>= 4.2) | mutter,34 metacity (>= 2.21.4) | xcompmgr | compiz | xfwm4 (>= 4.2) | mutter,
3535
=== modified file 'setup.py'
--- setup.py 2011-03-26 19:27:07 +0000
+++ setup.py 2011-06-08 20:36:52 +0000
@@ -81,7 +81,6 @@
81 'src/share/screenlets-manager/KarambaScreenlet.py',81 'src/share/screenlets-manager/KarambaScreenlet.py',
82 'src/share/screenlets-manager/widget.png',82 'src/share/screenlets-manager/widget.png',
83 'src/share/screenlets-manager/WidgetScreenlet.py',83 'src/share/screenlets-manager/WidgetScreenlet.py',
84 'src/share/screenlets-manager/prefs.js',
85 'src/share/screenlets-manager/webapp.png',84 'src/share/screenlets-manager/webapp.png',
86 'src/share/screenlets-manager/WebappScreenlet.py',85 'src/share/screenlets-manager/WebappScreenlet.py',
87 'src/share/screenlets-manager/karamba.png']))86 'src/share/screenlets-manager/karamba.png']))
8887
=== modified file 'src/share/screenlets-manager/WebappScreenlet.py'
--- src/share/screenlets-manager/WebappScreenlet.py 2008-04-10 15:10:23 +0000
+++ src/share/screenlets-manager/WebappScreenlet.py 2011-06-08 20:36:52 +0000
@@ -22,59 +22,13 @@
22import os22import os
23from screenlets import sensors23from screenlets import sensors
2424
25#########WORKARROUND FOR GTKOZEMBED BUG BY WHISE################
26myfile = 'WebappScreenlet.py'25myfile = 'WebappScreenlet.py'
27mypath = sys.argv[0][:sys.argv[0].find('myfile')].strip()26
28
29if sys.argv[0].endswith(myfile): # Makes Shure its not the manager running...
30 # First workarround
31 c = None
32 workarround = "python "+ sys.argv[0] + " &"
33 a = str(commands.getoutput('whereis firefox')).replace('firefox: ','').split(' ')
34 for b in a:
35 if os.path.isfile(b + '/run-mozilla.sh'):
36 c = b + '/run-mozilla.sh'
37 workarround = c + " " + sys.argv[0] + " &"
38
39 if c == None:
40 # Second workarround
41 print 'First workarround didnt work let run a second manual workarround'
42 if str(sensors.sys_get_distrib_name()).lower().find('ubuntu') != -1: # Works for ubuntu 32
43 workarround = "export LD_LIBRARY_PATH=/usr/lib/firefox \n export MOZILLA_FIVE_HOME=/usr/lib/firefox \n python "+ sys.argv[0] + " &"
44 elif str(sensors.sys_get_distrib_name()).lower().find('debian') != -1: # Works for debian 32 with iceweasel installed
45 workarround = "export LD_LIBRARY_PATH=/usr/lib/iceweasel \n export MOZILLA_FIVE_HOME=/usr/lib/iceweasel \n python " + sys.argv[0] + " &"
46 elif str(sensors.sys_get_distrib_name()).lower().find('suse') != -1: # Works for suse 32 with seamonkey installed
47 workarround = "export LD_LIBRARY_PATH=/usr/lib/seamonkey \n export MOZILLA_FIVE_HOME=/usr/lib/seamonkey \n python "+ sys.argv[0] + " &"
48 print 'Your running suse , make shure you have seamonkey installed'
49 elif str(sensors.sys_get_distrib_name()).lower().find('fedora') != -1: # Works for fedora 32 with seamonkey installed
50 workarround = "export LD_LIBRARY_PATH=/usr/lib/seamonkey \n export MOZILLA_FIVE_HOME=/usr/lib/seamonkey \n python "+ sys.argv[0] + " &"
51 print 'Your running fedora , make shure you have seamonkey installed'
52
53
54 if os.path.isfile("/tmp/"+ myfile+"running"):
55 os.system("rm -f " + "/tmp/"+ myfile+"running")
56
57 else:
58 if workarround == "python "+ sys.argv[0] + " &":
59 print 'No workarround will be applied to your sistem , this screenlet will probably not work properly'
60 os.system (workarround)
61 fileObj = open("/tmp/"+ myfile+"running","w") #// open for for write
62 fileObj.write('gtkmozembed bug workarround')
63
64 fileObj.close()
65 sys.exit()
66
67
68else:
69 pass
70try:27try:
71 import gtkmozembed28 import webkit
72except:29except:
73 if sys.argv[0].endswith(myfile):screenlets.show_error(None,"You need Gtkmozembed to run this Screenlet , please install it")30 if sys.argv[0].endswith(myfile):screenlets.show_error(None,"You need WebKit to run this Screenlet , please install it")
74 else: print "You need Gtkmozembed to run this Screenlet , please install it"31 else: print "You need WebKit to run this Screenlet , please install it"
75#########WORKARROUND FOR GTKOZEMBED BUG BY WHISE################
76
77
7832
79class WebappScreenlet (screenlets.Screenlet):33class WebappScreenlet (screenlets.Screenlet):
80 """Brings Web applications to your desktop"""34 """Brings Web applications to your desktop"""
@@ -93,21 +47,16 @@
93 screenlets.Screenlet.__init__(self, width=325, height=370,uses_theme=True, 47 screenlets.Screenlet.__init__(self, width=325, height=370,uses_theme=True,
94 is_widget=False, is_sticky=True,draw_buttons=False, **keyword_args)48 is_widget=False, is_sticky=True,draw_buttons=False, **keyword_args)
9549
96 if hasattr(gtkmozembed, 'set_profile_path'):50 self.view = webkit.WebView()
97 gtkmozembed.set_profile_path(self.mypath,'mozilla')
98 else:
99 gtkmozembed.gtk_moz_embed_set_profile_path(self.mypath ,'mozilla')
100
101 self.moz = gtkmozembed.MozEmbed()
102 self.win = gtk.Window()51 self.win = gtk.Window()
10352
104 #self.win.maximize()53 #self.win.maximize()
105 self.win.add(self.moz)54 self.win.add(self.view)
10655
107 self.moz.load_url(self.url)56 self.view.load_uri(self.url)
108 self.win.connect('destroy',self.quitall)57 self.win.connect('destroy',self.quitall)
109 self.win.connect("configure-event", self.configure)58 self.win.connect("configure-event", self.configure)
110 self.moz.connect("title",self.update) 59 self.view.connect("notify::title",self.update)
11160
112 61
113 def configure (self, widget, event):62 def configure (self, widget, event):
@@ -133,7 +82,7 @@
13382
134 def update(self,widget):83 def update(self,widget):
135 84
136 title = self.moz.get_title()85 title = self.view.get_title()
137 self.win.set_title(title)86 self.win.set_title(title)
138 def quitall(self,widget):87 def quitall(self,widget):
139 if len(self.session.instances) > 1:88 if len(self.session.instances) > 1:
14089
=== modified file 'src/share/screenlets-manager/WidgetScreenlet.py'
--- src/share/screenlets-manager/WidgetScreenlet.py 2008-05-25 13:40:09 +0000
+++ src/share/screenlets-manager/WidgetScreenlet.py 2011-06-08 20:36:52 +0000
@@ -22,60 +22,14 @@
22import os22import os
23from screenlets import sensors23from screenlets import sensors
2424
25
26
27#########WORKARROUND FOR GTKOZEMBED BUG BY WHISE################
28myfile = 'WidgetScreenlet.py'25myfile = 'WidgetScreenlet.py'
29mypath = sys.argv[0][:sys.argv[0].find(myfile)].strip()26
30
31if sys.argv[0].endswith(myfile): # Makes Shure its not the manager running...
32 # First workarround
33 c = None
34 workarround = "python "+ sys.argv[0] + " &"
35 a = str(commands.getoutput('whereis firefox')).replace('firefox: ','').split(' ')
36 for b in a:
37 if os.path.isfile(b + '/run-mozilla.sh'):
38 c = b + '/run-mozilla.sh'
39 workarround = c + " " + sys.argv[0] + " &"
40
41
42 if c == None:
43 # Second workarround
44 print 'First workarround didnt work let run a second manual workarround'
45 if str(sensors.sys_get_distrib_name()).lower().find('ubuntu') != -1: # Works for ubuntu 32
46 workarround = "export LD_LIBRARY_PATH=/usr/lib/firefox \n export MOZILLA_FIVE_HOME=/usr/lib/firefox \n python "+ sys.argv[0] + " &"
47 elif str(sensors.sys_get_distrib_name()).lower().find('debian') != -1: # Works for debian 32 with iceweasel installed
48 workarround = "export LD_LIBRARY_PATH=/usr/lib/iceweasel \n export MOZILLA_FIVE_HOME=/usr/lib/iceweasel \n python " + sys.argv[0] + " &"
49 elif str(sensors.sys_get_distrib_name()).lower().find('suse') != -1: # Works for suse 32 with seamonkey installed
50 workarround = "export LD_LIBRARY_PATH=/usr/lib/seamonkey \n export MOZILLA_FIVE_HOME=/usr/lib/seamonkey \n python "+ sys.argv[0] + " &"
51 print 'Your running suse , make shure you have seamonkey installed'
52 elif str(sensors.sys_get_distrib_name()).lower().find('fedora') != -1: # Works for fedora 32 with seamonkey installed
53 workarround = "export LD_LIBRARY_PATH=/usr/lib/seamonkey \n export MOZILLA_FIVE_HOME=/usr/lib/seamonkey \n python "+ sys.argv[0] + " &"
54 print 'Your running fedora , make shure you have seamonkey installed'
55
56
57 if os.path.isfile("/tmp/"+ myfile+"running"):
58 os.system("rm -f " + "/tmp/"+ myfile+"running")
59
60 else:
61 if workarround == "python "+ sys.argv[0] + " &":
62 print 'No workarround will be applied to your sistem , this screenlet will probably not work properly'
63 os.system (workarround)
64 fileObj = open("/tmp/"+ myfile+"running","w") #// open for for write
65 fileObj.write('gtkmozembed bug workarround')
66
67 fileObj.close()
68 sys.exit()
69
70
71else:
72 pass
73try:27try:
74 import gtkmozembed28 import webkit
75except:29except:
76 if sys.argv[0].endswith(myfile):screenlets.show_error(None,"You need Gtkmozembed to run this Screenlet , please install it")30 if sys.argv[0].endswith(myfile):screenlets.show_error(None,"You need WebKit to run this Screenlet , please install it")
77 else: print "You need Gtkmozembed to run this Screenlet , please install it"31 else: print "You need WebKit to run this Screenlet , please install it"
78#########WORKARROUND FOR GTKOZEMBED BUG BY WHISE################32
79#Check for internet connection required for web widgets33#Check for internet connection required for web widgets
8034
81if sys.argv[0].endswith(myfile):# Makes Shure its not the manager running...35if sys.argv[0].endswith(myfile):# Makes Shure its not the manager running...
@@ -97,7 +51,7 @@
97 __desc__ = __doc__51 __desc__ = __doc__
9852
99 started = False53 started = False
100 moz = None54 view = None
101 box = None55 box = None
102 mypath = sys.argv[0][:sys.argv[0].find('WidgetScreenlet.py')].strip()56 mypath = sys.argv[0][:sys.argv[0].find('WidgetScreenlet.py')].strip()
103 url = mypath + 'index.html'57 url = mypath + 'index.html'
@@ -130,12 +84,8 @@
130 self.disable_option('scale')84 self.disable_option('scale')
131 self.theme_name = 'default'85 self.theme_name = 'default'
132 self.box = gtk.VBox(False, 0)86 self.box = gtk.VBox(False, 0)
133 if hasattr(gtkmozembed, 'set_profile_path'):87 self.view = webkit.WebView()
134 gtkmozembed.set_profile_path(self.mypath,'mozilla')88 self.box.pack_start(self.view, False, False, 0)
135 else:
136 gtkmozembed.gtk_moz_embed_set_profile_path(self.mypath ,'mozilla')
137 self.moz = gtkmozembed.MozEmbed()
138 self.box.pack_start(self.moz, False, False, 0)
13989
140 self.window.add(self.box) 90 self.window.add(self.box)
141 91
@@ -202,7 +152,7 @@
202 #ctx.translate(0,10)152 #ctx.translate(0,10)
203 self.draw_scaled_image(ctx,0,0,self.width,self.height,self.mypath + 'icon.png')153 self.draw_scaled_image(ctx,0,0,self.width,self.height,self.mypath + 'icon.png')
204154
205 self.moz.shape_combine_mask(self.bgpbms,0,0) 155 self.view.shape_combine_mask(self.bgpbms,0,0)
206 else:156 else:
207 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)157 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)
208 self.bgpbim, self.bgpbms = self.bgpb.render_pixmap_and_mask(alpha_threshold=128)158 self.bgpbim, self.bgpbms = self.bgpb.render_pixmap_and_mask(alpha_threshold=128)
@@ -211,7 +161,7 @@
211 ctx.translate(0,10)161 ctx.translate(0,10)
212 self.draw_image(ctx,0,0,self.mypath + 'icon.png')162 self.draw_image(ctx,0,0,self.mypath + 'icon.png')
213163
214 self.moz.shape_combine_mask(self.bgpbms,8,8) 164 self.view.shape_combine_mask(self.bgpbms,8,8)
215 165
216166
217167
@@ -276,7 +226,7 @@
276 self.url = self.widget_info[13:][:(len(self.widget_info)-24)]226 self.url = self.widget_info[13:][:(len(self.widget_info)-24)]
277 227
278 self.engine = 'google'228 self.engine = 'google'
279 self.moz.load_url(self.url)229 self.view.load_uri(self.url)
280 print 'loading ' + self.url230 print 'loading ' + self.url
281 231
282 self.width = int(self.widget_width)+30232 self.width = int(self.widget_width)+30
@@ -291,9 +241,9 @@
291241
292 self.box.set_uposition(-1,7)242 self.box.set_uposition(-1,7)
293 243
294 self.moz.set_size_request(-1,int(self.widget_height))244 self.view.set_size_request(-1,int(self.widget_height))
295 else:245 else:
296 self.moz.set_size_request(-1,int(self.height))246 self.view.set_size_request(-1,int(self.height))
297 self.redraw_canvas()247 self.redraw_canvas()
298248
299 def on_mouse_down(self,event):249 def on_mouse_down(self,event):
300250
=== modified file 'src/share/screenlets-manager/screenlets-manager.py'
--- src/share/screenlets-manager/screenlets-manager.py 2011-04-24 20:51:36 +0000
+++ src/share/screenlets-manager/screenlets-manager.py 2011-06-08 20:36:52 +0000
@@ -1060,7 +1060,6 @@
1060 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/WebappScreenlet.py ' +DIR_USER + '/' + a + '/' + a + 'Screenlet.py')1060 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/WebappScreenlet.py ' +DIR_USER + '/' + a + '/' + a + 'Screenlet.py')
1061 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/webapp.png ' +DIR_USER + '/' + a + '/icon.png') 1061 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/webapp.png ' +DIR_USER + '/' + a + '/icon.png')
1062 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/webapp.png ' +DIR_USER + '/' + a + '/themes/default')1062 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/webapp.png ' +DIR_USER + '/' + a + '/themes/default')
1063 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/prefs.js ' +DIR_USER + '/' + a + '/mozilla')
1064 1063
1065 enginecopy = open(DIR_USER + '/' + a + '/' + a + 'Screenlet.py','r')1064 enginecopy = open(DIR_USER + '/' + a + '/' + a + 'Screenlet.py','r')
1066 enginesave = enginecopy.read()1065 enginesave = enginecopy.read()
@@ -1147,7 +1146,6 @@
1147 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/WidgetScreenlet.py ' +DIR_USER + '/' + a + '/' + a + 'Screenlet.py')1146 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/WidgetScreenlet.py ' +DIR_USER + '/' + a + '/' + a + 'Screenlet.py')
1148 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/widget.png ' +DIR_USER + '/' + a + '/icon.png') 1147 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/widget.png ' +DIR_USER + '/' + a + '/icon.png')
1149 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/widget.png ' +DIR_USER + '/' + a + '/themes/default')1148 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/widget.png ' +DIR_USER + '/' + a + '/themes/default')
1150 os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/prefs.js ' +DIR_USER + '/' + a + '/mozilla')
1151 enginecopy = open(DIR_USER + '/' + a + '/' + a + 'Screenlet.py','r')1149 enginecopy = open(DIR_USER + '/' + a + '/' + a + 'Screenlet.py','r')
1152 enginesave = enginecopy.read()1150 enginesave = enginecopy.read()
1153 enginesave = enginesave.replace('WidgetScreenlet',a + 'Screenlet')1151 enginesave = enginesave.replace('WidgetScreenlet',a + 'Screenlet')

Subscribers

People subscribed via source and target branches

to status/vote changes: