summaryrefslogtreecommitdiffstats
path: root/bitbake-dev/lib/bb/ui/goggle.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake-dev/lib/bb/ui/goggle.py')
-rw-r--r--bitbake-dev/lib/bb/ui/goggle.py146
1 files changed, 1 insertions, 145 deletions
diff --git a/bitbake-dev/lib/bb/ui/goggle.py b/bitbake-dev/lib/bb/ui/goggle.py
index 651a0449b0..0118a356fa 100644
--- a/bitbake-dev/lib/bb/ui/goggle.py
+++ b/bitbake-dev/lib/bb/ui/goggle.py
@@ -22,6 +22,7 @@ import gobject
22import gtk 22import gtk
23import threading 23import threading
24import bb.ui.uihelper 24import bb.ui.uihelper
25from bb.ui.crumbs.runningbuild import RunningBuildTreeView, RunningBuild
25 26
26def event_handle_idle_func (eventHandler, build): 27def event_handle_idle_func (eventHandler, build):
27 28
@@ -33,151 +34,6 @@ def event_handle_idle_func (eventHandler, build):
33 34
34 return True 35 return True
35 36
36class RunningBuildModel (gtk.TreeStore):
37 (COL_TYPE, COL_PACKAGE, COL_TASK, COL_MESSAGE, COL_ICON, COL_ACTIVE) = (0, 1, 2, 3, 4, 5)
38 def __init__ (self):
39 gtk.TreeStore.__init__ (self,
40 gobject.TYPE_STRING,
41 gobject.TYPE_STRING,
42 gobject.TYPE_STRING,
43 gobject.TYPE_STRING,
44 gobject.TYPE_STRING,
45 gobject.TYPE_BOOLEAN)
46
47class RunningBuild (gobject.GObject):
48 __gsignals__ = {
49 'build-finished' : (gobject.SIGNAL_RUN_LAST,
50 gobject.TYPE_NONE,
51 ())
52 }
53 pids_to_task = {}
54 tasks_to_iter = {}
55
56 def __init__ (self):
57 gobject.GObject.__init__ (self)
58 self.model = RunningBuildModel()
59
60 def handle_event (self, event):
61 # Handle an event from the event queue, this may result in updating
62 # the model and thus the UI. Or it may be to tell us that the build
63 # has finished successfully (or not, as the case may be.)
64
65 parent = None
66 pid = 0
67 package = None
68 task = None
69
70 # If we have a pid attached to this message/event try and get the
71 # (package, task) pair for it. If we get that then get the parent iter
72 # for the message.
73 if event[1].has_key ('pid'):
74 pid = event[1]['pid']
75 if self.pids_to_task.has_key(pid):
76 (package, task) = self.pids_to_task[pid]
77 parent = self.tasks_to_iter[(package, task)]
78
79 if event[0].startswith('bb.msg.Msg'):
80 # Set a pretty icon for the message based on it's type.
81 if (event[0].startswith ('bb.msg.MsgWarn')):
82 icon = "dialog-warning"
83 elif (event[0].startswith ('bb.msg.MsgErr')):
84 icon = "dialog-error"
85 else:
86 icon = None
87
88 # Ignore the "Running task i of n .." messages
89 if (event[1]['_message'].startswith ("Running task")):
90 return
91
92 # Add the message to the tree either at the top level if parent is
93 # None otherwise as a descendent of a task.
94 self.model.append (parent,
95 (event[0].split()[-1], # e.g. MsgWarn, MsgError
96 package,
97 task,
98 event[1]['_message'],
99 icon,
100 False))
101 elif event[0].startswith('bb.build.TaskStarted'):
102 (package, task) = (event[1]['_package'], event[1]['_task'])
103
104 # Save out this PID.
105 self.pids_to_task[pid] = (package,task)
106
107 # Check if we already have this package in our model. If so then
108 # that can be the parent for the task. Otherwise we create a new
109 # top level for the package.
110 if (self.tasks_to_iter.has_key ((package, None))):
111 parent = self.tasks_to_iter[(package, None)]
112 else:
113 parent = self.model.append (None, (None,
114 package,
115 None,
116 "Package: %s" % (package),
117 None,
118 False))
119 self.tasks_to_iter[(package, None)] = parent
120
121 # Because this parent package now has an active child mark it as
122 # such.
123 self.model.set(parent, self.model.COL_ICON, "gtk-execute")
124
125 # Add an entry in the model for this task
126 i = self.model.append (parent, (None,
127 package,
128 task,
129 "Task: %s" % (task),
130 None,
131 False))
132
133 # Save out the iter so that we can find it when we have a message
134 # that we need to attach to a task.
135 self.tasks_to_iter[(package, task)] = i
136
137 # Mark this task as active.
138 self.model.set(i, self.model.COL_ICON, "gtk-execute")
139
140 elif event[0].startswith('bb.build.Task'):
141
142 if event[0].startswith('bb.build.TaskFailed'):
143 # Mark the task as failed
144 i = self.tasks_to_iter[(package, task)]
145 self.model.set(i, self.model.COL_ICON, "dialog-error")
146
147 # Mark the parent package as failed
148 i = self.tasks_to_iter[(package, None)]
149 self.model.set(i, self.model.COL_ICON, "dialog-error")
150 else:
151 # Mark the task as inactive
152 i = self.tasks_to_iter[(package, task)]
153 self.model.set(i, self.model.COL_ICON, None)
154
155 # Mark the parent package as inactive
156 i = self.tasks_to_iter[(package, None)]
157 self.model.set(i, self.model.COL_ICON, None)
158
159
160 # Clear the iters and the pids since when the task goes away the
161 # pid will no longer be used for messages
162 del self.tasks_to_iter[(package, task)]
163 del self.pids_to_task[pid]
164
165class RunningBuildTreeView (gtk.TreeView):
166 def __init__ (self):
167 gtk.TreeView.__init__ (self)
168
169 # The icon that indicates whether we're building or failed.
170 renderer = gtk.CellRendererPixbuf ()
171 col = gtk.TreeViewColumn ("Status", renderer)
172 col.add_attribute (renderer, "icon-name", 4)
173 self.append_column (col)
174
175 # The message of the build.
176 renderer = gtk.CellRendererText ()
177 col = gtk.TreeViewColumn ("Message", renderer, text=3)
178 self.append_column (col)
179
180
181class MainWindow (gtk.Window): 37class MainWindow (gtk.Window):
182 def __init__ (self): 38 def __init__ (self):
183 gtk.Window.__init__ (self, gtk.WINDOW_TOPLEVEL) 39 gtk.Window.__init__ (self, gtk.WINDOW_TOPLEVEL)