summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorJussi Kukkonen <jussi.kukkonen@intel.com>2016-06-20 15:20:03 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-20 17:23:56 +0100
commit90d7b09af2cc5c6e92c103aa40e554f586110ecf (patch)
tree53a2d96239286f5bc6ea8eb39e0ad29f113097fc /bitbake/lib/bb
parent8d56c54107cc352a32745a5df11247debe4d2893 (diff)
downloadpoky-90d7b09af2cc5c6e92c103aa40e554f586110ecf.tar.gz
bitbake: depexp.py: port to gtk+3
The code is still a bit icky (and should be refactored to not use Gdk.threads_enter/leave) but it should work about as reliably as it did with Gtk+2. Based on earlier patches by Maxin and Joshua. (Bitbake rev: 8eee64a64144e27b5b8c2aca88e138882c3deab7) Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/ui/depexp.py159
1 files changed, 80 insertions, 79 deletions
diff --git a/bitbake/lib/bb/ui/depexp.py b/bitbake/lib/bb/ui/depexp.py
index 240aafc3e7..995703d3dc 100644
--- a/bitbake/lib/bb/ui/depexp.py
+++ b/bitbake/lib/bb/ui/depexp.py
@@ -18,14 +18,15 @@
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 19
20import sys 20import sys
21import gobject 21import gi
22import gtk 22gi.require_version('Gtk', '3.0')
23import Queue 23from gi.repository import Gtk, Gdk, GObject
24from multiprocessing import Queue
24import threading 25import threading
25import xmlrpclib 26from xmlrpc import client
27import time
26import bb 28import bb
27import bb.event 29import bb.event
28from bb.ui.crumbs.progressbar import HobProgressBar
29 30
30# Package Model 31# Package Model
31(COL_PKG_NAME) = (0) 32(COL_PKG_NAME) = (0)
@@ -35,19 +36,19 @@ from bb.ui.crumbs.progressbar import HobProgressBar
35(COL_DEP_TYPE, COL_DEP_PARENT, COL_DEP_PACKAGE) = (0, 1, 2) 36(COL_DEP_TYPE, COL_DEP_PARENT, COL_DEP_PACKAGE) = (0, 1, 2)
36 37
37 38
38class PackageDepView(gtk.TreeView): 39class PackageDepView(Gtk.TreeView):
39 def __init__(self, model, dep_type, label): 40 def __init__(self, model, dep_type, label):
40 gtk.TreeView.__init__(self) 41 Gtk.TreeView.__init__(self)
41 self.current = None 42 self.current = None
42 self.dep_type = dep_type 43 self.dep_type = dep_type
43 self.filter_model = model.filter_new() 44 self.filter_model = model.filter_new()
44 self.filter_model.set_visible_func(self._filter) 45 self.filter_model.set_visible_func(self._filter, data=None)
45 self.set_model(self.filter_model) 46 self.set_model(self.filter_model)
46 #self.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) 47 self.append_column(Gtk.TreeViewColumn(label, Gtk.CellRendererText(), text=COL_DEP_PACKAGE))
47 self.append_column(gtk.TreeViewColumn(label, gtk.CellRendererText(), text=COL_DEP_PACKAGE))
48 48
49 def _filter(self, model, iter): 49 def _filter(self, model, iter, data):
50 (this_type, package) = model.get(iter, COL_DEP_TYPE, COL_DEP_PARENT) 50 this_type = model[iter][COL_DEP_TYPE]
51 package = model[iter][COL_DEP_PARENT]
51 if this_type != self.dep_type: return False 52 if this_type != self.dep_type: return False
52 return package == self.current 53 return package == self.current
53 54
@@ -56,17 +57,17 @@ class PackageDepView(gtk.TreeView):
56 self.filter_model.refilter() 57 self.filter_model.refilter()
57 58
58 59
59class PackageReverseDepView(gtk.TreeView): 60class PackageReverseDepView(Gtk.TreeView):
60 def __init__(self, model, label): 61 def __init__(self, model, label):
61 gtk.TreeView.__init__(self) 62 Gtk.TreeView.__init__(self)
62 self.current = None 63 self.current = None
63 self.filter_model = model.filter_new() 64 self.filter_model = model.filter_new()
64 self.filter_model.set_visible_func(self._filter) 65 self.filter_model.set_visible_func(self._filter)
65 self.set_model(self.filter_model) 66 self.set_model(self.filter_model)
66 self.append_column(gtk.TreeViewColumn(label, gtk.CellRendererText(), text=COL_DEP_PARENT)) 67 self.append_column(Gtk.TreeViewColumn(label, Gtk.CellRendererText(), text=COL_DEP_PARENT))
67 68
68 def _filter(self, model, iter): 69 def _filter(self, model, iter, data):
69 package = model.get_value(iter, COL_DEP_PACKAGE) 70 package = model[iter][COL_DEP_PACKAGE]
70 return package == self.current 71 return package == self.current
71 72
72 def set_current_package(self, package): 73 def set_current_package(self, package):
@@ -74,50 +75,50 @@ class PackageReverseDepView(gtk.TreeView):
74 self.filter_model.refilter() 75 self.filter_model.refilter()
75 76
76 77
77class DepExplorer(gtk.Window): 78class DepExplorer(Gtk.Window):
78 def __init__(self): 79 def __init__(self):
79 gtk.Window.__init__(self) 80 Gtk.Window.__init__(self)
80 self.set_title("Dependency Explorer") 81 self.set_title("Dependency Explorer")
81 self.set_default_size(500, 500) 82 self.set_default_size(500, 500)
82 self.connect("delete-event", gtk.main_quit) 83 self.connect("delete-event", Gtk.main_quit)
83 84
84 # Create the data models 85 # Create the data models
85 self.pkg_model = gtk.ListStore(gobject.TYPE_STRING) 86 self.pkg_model = Gtk.ListStore(GObject.TYPE_STRING)
86 self.pkg_model.set_sort_column_id(COL_PKG_NAME, gtk.SORT_ASCENDING) 87 self.pkg_model.set_sort_column_id(COL_PKG_NAME, Gtk.SortType.ASCENDING)
87 self.depends_model = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING) 88 self.depends_model = Gtk.ListStore(GObject.TYPE_INT, GObject.TYPE_STRING, GObject.TYPE_STRING)
88 self.depends_model.set_sort_column_id(COL_DEP_PACKAGE, gtk.SORT_ASCENDING) 89 self.depends_model.set_sort_column_id(COL_DEP_PACKAGE, Gtk.SortType.ASCENDING)
89 90
90 pane = gtk.HPaned() 91 pane = Gtk.HPaned()
91 pane.set_position(250) 92 pane.set_position(250)
92 self.add(pane) 93 self.add(pane)
93 94
94 # The master list of packages 95 # The master list of packages
95 scrolled = gtk.ScrolledWindow() 96 scrolled = Gtk.ScrolledWindow()
96 scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) 97 scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
97 scrolled.set_shadow_type(gtk.SHADOW_IN) 98 scrolled.set_shadow_type(Gtk.ShadowType.IN)
98 99
99 self.pkg_treeview = gtk.TreeView(self.pkg_model) 100 self.pkg_treeview = Gtk.TreeView(self.pkg_model)
100 self.pkg_treeview.get_selection().connect("changed", self.on_cursor_changed) 101 self.pkg_treeview.get_selection().connect("changed", self.on_cursor_changed)
101 column = gtk.TreeViewColumn("Package", gtk.CellRendererText(), text=COL_PKG_NAME) 102 column = Gtk.TreeViewColumn("Package", Gtk.CellRendererText(), text=COL_PKG_NAME)
102 self.pkg_treeview.append_column(column) 103 self.pkg_treeview.append_column(column)
103 pane.add1(scrolled) 104 pane.add1(scrolled)
104 scrolled.add(self.pkg_treeview) 105 scrolled.add(self.pkg_treeview)
105 106
106 box = gtk.VBox(homogeneous=True, spacing=4) 107 box = Gtk.VBox(homogeneous=True, spacing=4)
107 108
108 # Runtime Depends 109 # Runtime Depends
109 scrolled = gtk.ScrolledWindow() 110 scrolled = Gtk.ScrolledWindow()
110 scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) 111 scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
111 scrolled.set_shadow_type(gtk.SHADOW_IN) 112 scrolled.set_shadow_type(Gtk.ShadowType.IN)
112 self.rdep_treeview = PackageDepView(self.depends_model, TYPE_RDEP, "Runtime Depends") 113 self.rdep_treeview = PackageDepView(self.depends_model, TYPE_RDEP, "Runtime Depends")
113 self.rdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) 114 self.rdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE)
114 scrolled.add(self.rdep_treeview) 115 scrolled.add(self.rdep_treeview)
115 box.add(scrolled) 116 box.add(scrolled)
116 117
117 # Build Depends 118 # Build Depends
118 scrolled = gtk.ScrolledWindow() 119 scrolled = Gtk.ScrolledWindow()
119 scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) 120 scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
120 scrolled.set_shadow_type(gtk.SHADOW_IN) 121 scrolled.set_shadow_type(Gtk.ShadowType.IN)
121 self.dep_treeview = PackageDepView(self.depends_model, TYPE_DEP, "Build Depends") 122 self.dep_treeview = PackageDepView(self.depends_model, TYPE_DEP, "Build Depends")
122 self.dep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) 123 self.dep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE)
123 scrolled.add(self.dep_treeview) 124 scrolled.add(self.dep_treeview)
@@ -125,9 +126,9 @@ class DepExplorer(gtk.Window):
125 pane.add2(box) 126 pane.add2(box)
126 127
127 # Reverse Depends 128 # Reverse Depends
128 scrolled = gtk.ScrolledWindow() 129 scrolled = Gtk.ScrolledWindow()
129 scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) 130 scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
130 scrolled.set_shadow_type(gtk.SHADOW_IN) 131 scrolled.set_shadow_type(Gtk.ShadowType.IN)
131 self.revdep_treeview = PackageReverseDepView(self.depends_model, "Reverse Depends") 132 self.revdep_treeview = PackageReverseDepView(self.depends_model, "Reverse Depends")
132 self.revdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PARENT) 133 self.revdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PARENT)
133 scrolled.add(self.revdep_treeview) 134 scrolled.add(self.revdep_treeview)
@@ -183,15 +184,23 @@ class gtkthread(threading.Thread):
183 threading.Thread.__init__(self) 184 threading.Thread.__init__(self)
184 self.setDaemon(True) 185 self.setDaemon(True)
185 self.shutdown = shutdown 186 self.shutdown = shutdown
187 if not Gtk.init_check()[0]:
188 sys.stderr.write("Gtk+ init failed. Make sure DISPLAY variable is set.\n")
189 gtkthread.quit.set()
186 190
187 def run(self): 191 def run(self):
188 gobject.threads_init() 192 GObject.threads_init()
189 gtk.gdk.threads_init() 193 Gdk.threads_init()
190 gtk.main() 194 Gtk.main()
191 gtkthread.quit.set() 195 gtkthread.quit.set()
192 196
193 197
194def main(server, eventHandler, params): 198def main(server, eventHandler, params):
199 shutdown = 0
200
201 gtkgui = gtkthread(shutdown)
202 gtkgui.start()
203
195 try: 204 try:
196 params.updateFromServer(server) 205 params.updateFromServer(server)
197 cmdline = params.parseActions() 206 cmdline = params.parseActions()
@@ -212,31 +221,24 @@ def main(server, eventHandler, params):
212 elif ret != True: 221 elif ret != True:
213 print("Error running command '%s': returned %s" % (cmdline, ret)) 222 print("Error running command '%s': returned %s" % (cmdline, ret))
214 return 1 223 return 1
215 except xmlrpclib.Fault as x: 224 except client.Fault as x:
216 print("XMLRPC Fault getting commandline:\n %s" % x) 225 print("XMLRPC Fault getting commandline:\n %s" % x)
217 return 226 return
218 227
219 try: 228 if gtkthread.quit.isSet():
220 gtk.init_check()
221 except RuntimeError:
222 sys.stderr.write("Please set DISPLAY variable before running this command \n")
223 return 229 return
224 230
225 shutdown = 0 231 Gdk.threads_enter()
226
227 gtkgui = gtkthread(shutdown)
228 gtkgui.start()
229
230 gtk.gdk.threads_enter()
231 dep = DepExplorer() 232 dep = DepExplorer()
232 bardialog = gtk.Dialog(parent=dep, 233 bardialog = Gtk.Dialog(parent=dep,
233 flags=gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT) 234 flags=Gtk.DialogFlags.MODAL|Gtk.DialogFlags.DESTROY_WITH_PARENT)
234 bardialog.set_default_size(400, 50) 235 bardialog.set_default_size(400, 50)
235 pbar = HobProgressBar() 236 box = bardialog.get_content_area()
236 bardialog.vbox.pack_start(pbar) 237 pbar = Gtk.ProgressBar()
238 box.pack_start(pbar, True, True, 0)
237 bardialog.show_all() 239 bardialog.show_all()
238 bardialog.connect("delete-event", gtk.main_quit) 240 bardialog.connect("delete-event", Gtk.main_quit)
239 gtk.gdk.threads_leave() 241 Gdk.threads_leave()
240 242
241 progress_total = 0 243 progress_total = 0
242 while True: 244 while True:
@@ -253,49 +255,48 @@ def main(server, eventHandler, params):
253 255
254 if isinstance(event, bb.event.CacheLoadStarted): 256 if isinstance(event, bb.event.CacheLoadStarted):
255 progress_total = event.total 257 progress_total = event.total
256 gtk.gdk.threads_enter() 258 Gdk.threads_enter()
257 bardialog.set_title("Loading Cache") 259 bardialog.set_title("Loading Cache")
258 pbar.update(0) 260 pbar.set_fraction(0.0)
259 gtk.gdk.threads_leave() 261 Gdk.threads_leave()
260 262
261 if isinstance(event, bb.event.CacheLoadProgress): 263 if isinstance(event, bb.event.CacheLoadProgress):
262 x = event.current 264 x = event.current
263 gtk.gdk.threads_enter() 265 Gdk.threads_enter()
264 pbar.update(x * 1.0 / progress_total) 266 pbar.set_fraction(x * 1.0 / progress_total)
265 pbar.set_title('') 267 Gdk.threads_leave()
266 gtk.gdk.threads_leave()
267 continue 268 continue
268 269
269 if isinstance(event, bb.event.CacheLoadCompleted): 270 if isinstance(event, bb.event.CacheLoadCompleted):
270 bardialog.hide()
271 continue 271 continue
272 272
273 if isinstance(event, bb.event.ParseStarted): 273 if isinstance(event, bb.event.ParseStarted):
274 progress_total = event.total 274 progress_total = event.total
275 if progress_total == 0: 275 if progress_total == 0:
276 continue 276 continue
277 gtk.gdk.threads_enter() 277 Gdk.threads_enter()
278 pbar.update(0) 278 pbar.set_fraction(0.0)
279 bardialog.set_title("Processing recipes") 279 bardialog.set_title("Processing recipes")
280 280 Gdk.threads_leave()
281 gtk.gdk.threads_leave()
282 281
283 if isinstance(event, bb.event.ParseProgress): 282 if isinstance(event, bb.event.ParseProgress):
284 x = event.current 283 x = event.current
285 gtk.gdk.threads_enter() 284 Gdk.threads_enter()
286 pbar.update(x * 1.0 / progress_total) 285 pbar.set_fraction(x * 1.0 / progress_total)
287 pbar.set_title('') 286 Gdk.threads_leave()
288 gtk.gdk.threads_leave()
289 continue 287 continue
290 288
291 if isinstance(event, bb.event.ParseCompleted): 289 if isinstance(event, bb.event.ParseCompleted):
292 bardialog.hide() 290 Gdk.threads_enter()
291 bardialog.set_title("Generating dependency tree")
292 Gdk.threads_leave()
293 continue 293 continue
294 294
295 if isinstance(event, bb.event.DepTreeGenerated): 295 if isinstance(event, bb.event.DepTreeGenerated):
296 gtk.gdk.threads_enter() 296 Gdk.threads_enter()
297 bardialog.hide()
297 dep.parse(event._depgraph) 298 dep.parse(event._depgraph)
298 gtk.gdk.threads_leave() 299 Gdk.threads_leave()
299 300
300 if isinstance(event, bb.command.CommandCompleted): 301 if isinstance(event, bb.command.CommandCompleted):
301 continue 302 continue