Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # This file is part of pybootchartgui. |
| 2 | |
| 3 | # pybootchartgui is free software: you can redistribute it and/or modify |
| 4 | # it under the terms of the GNU General Public License as published by |
| 5 | # the Free Software Foundation, either version 3 of the License, or |
| 6 | # (at your option) any later version. |
| 7 | |
| 8 | # pybootchartgui is distributed in the hope that it will be useful, |
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | # GNU General Public License for more details. |
| 12 | |
| 13 | # You should have received a copy of the GNU General Public License |
| 14 | # along with pybootchartgui. If not, see <http://www.gnu.org/licenses/>. |
| 15 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 16 | import gi |
| 17 | gi.require_version('Gtk', '3.0') |
| 18 | from gi.repository import Gtk as gtk |
| 19 | from gi.repository import Gtk |
| 20 | from gi.repository import Gdk |
| 21 | from gi.repository import GObject as gobject |
| 22 | from gi.repository import GObject |
| 23 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | from . import draw |
| 25 | from .draw import RenderOptions |
| 26 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 27 | class PyBootchartWidget(gtk.DrawingArea, gtk.Scrollable): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | __gsignals__ = { |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 29 | 'clicked' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, Gdk.Event)), |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | 'position-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_INT, gobject.TYPE_INT)), |
| 31 | 'set-scroll-adjustments' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gtk.Adjustment, gtk.Adjustment)) |
| 32 | } |
| 33 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 34 | hadjustment = GObject.property(type=Gtk.Adjustment, |
| 35 | default=Gtk.Adjustment(), |
| 36 | flags=GObject.PARAM_READWRITE) |
| 37 | hscroll_policy = GObject.property(type=Gtk.ScrollablePolicy, |
| 38 | default=Gtk.ScrollablePolicy.MINIMUM, |
| 39 | flags=GObject.PARAM_READWRITE) |
| 40 | vadjustment = GObject.property(type=Gtk.Adjustment, |
| 41 | default=Gtk.Adjustment(), |
| 42 | flags=GObject.PARAM_READWRITE) |
| 43 | vscroll_policy = GObject.property(type=Gtk.ScrollablePolicy, |
| 44 | default=Gtk.ScrollablePolicy.MINIMUM, |
| 45 | flags=GObject.PARAM_READWRITE) |
| 46 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 47 | def __init__(self, trace, options, xscale): |
| 48 | gtk.DrawingArea.__init__(self) |
| 49 | |
| 50 | self.trace = trace |
| 51 | self.options = options |
| 52 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 53 | self.set_can_focus(True) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 54 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 55 | self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 56 | self.connect("button-press-event", self.on_area_button_press) |
| 57 | self.connect("button-release-event", self.on_area_button_release) |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 58 | self.add_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | self.connect("motion-notify-event", self.on_area_motion_notify) |
| 60 | self.connect("scroll-event", self.on_area_scroll_event) |
| 61 | self.connect('key-press-event', self.on_key_press_event) |
| 62 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | self.connect("size-allocate", self.on_allocation_size_changed) |
| 64 | self.connect("position-changed", self.on_position_changed) |
| 65 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 66 | self.connect("draw", self.on_draw) |
| 67 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 68 | self.zoom_ratio = 1.0 |
| 69 | self.xscale = xscale |
| 70 | self.x, self.y = 0.0, 0.0 |
| 71 | |
| 72 | self.chart_width, self.chart_height = draw.extents(self.options, self.xscale, self.trace) |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 73 | self.our_width, self.our_height = self.chart_width, self.chart_height |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 74 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 75 | self.hadj = gtk.Adjustment(0.0, 0.0, 0.0, 0.0, 0.0, 0.0) |
| 76 | self.vadj = gtk.Adjustment(0.0, 0.0, 0.0, 0.0, 0.0, 0.0) |
| 77 | self.vadj.connect('value-changed', self.on_adjustments_changed) |
| 78 | self.hadj.connect('value-changed', self.on_adjustments_changed) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 80 | def bound_vals(self): |
| 81 | self.x = max(0, self.x) |
| 82 | self.y = max(0, self.y) |
| 83 | self.x = min(self.chart_width - self.our_width, self.x) |
| 84 | self.y = min(self.chart_height - self.our_height, self.y) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 85 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 86 | def on_draw(self, darea, cr): |
| 87 | # set a clip region |
| 88 | #cr.rectangle( |
| 89 | # self.x, self.y, |
| 90 | # self.chart_width, self.chart_height |
| 91 | #) |
| 92 | #cr.clip() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 93 | cr.set_source_rgba(1.0, 1.0, 1.0, 1.0) |
| 94 | cr.paint() |
| 95 | cr.scale(self.zoom_ratio, self.zoom_ratio) |
| 96 | cr.translate(-self.x, -self.y) |
| 97 | draw.render(cr, self.options, self.xscale, self.trace) |
| 98 | |
| 99 | def position_changed(self): |
| 100 | self.emit("position-changed", self.x, self.y) |
| 101 | |
| 102 | ZOOM_INCREMENT = 1.25 |
| 103 | |
| 104 | def zoom_image (self, zoom_ratio): |
| 105 | self.zoom_ratio = zoom_ratio |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 106 | self._set_scroll_adjustments() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 107 | self.queue_draw() |
| 108 | |
| 109 | def zoom_to_rect (self, rect): |
| 110 | zoom_ratio = float(rect.width)/float(self.chart_width) |
| 111 | self.zoom_image(zoom_ratio) |
| 112 | self.x = 0 |
| 113 | self.position_changed() |
| 114 | |
| 115 | def set_xscale(self, xscale): |
| 116 | old_mid_x = self.x + self.hadj.page_size / 2 |
| 117 | self.xscale = xscale |
| 118 | self.chart_width, self.chart_height = draw.extents(self.options, self.xscale, self.trace) |
| 119 | new_x = old_mid_x |
| 120 | self.zoom_image (self.zoom_ratio) |
| 121 | |
| 122 | def on_expand(self, action): |
| 123 | self.set_xscale (int(self.xscale * 1.5 + 0.5)) |
| 124 | |
| 125 | def on_contract(self, action): |
| 126 | self.set_xscale (max(int(self.xscale / 1.5), 1)) |
| 127 | |
| 128 | def on_zoom_in(self, action): |
| 129 | self.zoom_image(self.zoom_ratio * self.ZOOM_INCREMENT) |
| 130 | |
| 131 | def on_zoom_out(self, action): |
| 132 | self.zoom_image(self.zoom_ratio / self.ZOOM_INCREMENT) |
| 133 | |
| 134 | def on_zoom_fit(self, action): |
| 135 | self.zoom_to_rect(self.get_allocation()) |
| 136 | |
| 137 | def on_zoom_100(self, action): |
| 138 | self.zoom_image(1.0) |
| 139 | self.set_xscale(1.0) |
| 140 | |
| 141 | def show_toggled(self, button): |
| 142 | self.options.app_options.show_all = button.get_property ('active') |
| 143 | self.chart_width, self.chart_height = draw.extents(self.options, self.xscale, self.trace) |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 144 | self._set_scroll_adjustments() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 145 | self.queue_draw() |
| 146 | |
| 147 | POS_INCREMENT = 100 |
| 148 | |
| 149 | def on_key_press_event(self, widget, event): |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 150 | if event.keyval == Gdk.keyval_from_name("Left"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 151 | self.x -= self.POS_INCREMENT/self.zoom_ratio |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 152 | elif event.keyval == Gdk.keyval_from_name("Right"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 153 | self.x += self.POS_INCREMENT/self.zoom_ratio |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 154 | elif event.keyval == Gdk.keyval_from_name("Up"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 155 | self.y -= self.POS_INCREMENT/self.zoom_ratio |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 156 | elif event.keyval == Gdk.keyval_from_name("Down"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 157 | self.y += self.POS_INCREMENT/self.zoom_ratio |
| 158 | else: |
| 159 | return False |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 160 | self.bound_vals() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 161 | self.queue_draw() |
| 162 | self.position_changed() |
| 163 | return True |
| 164 | |
| 165 | def on_area_button_press(self, area, event): |
| 166 | if event.button == 2 or event.button == 1: |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 167 | window = self.get_window() |
| 168 | window.set_cursor(Gdk.Cursor(Gdk.CursorType.FLEUR)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 169 | self.prevmousex = event.x |
| 170 | self.prevmousey = event.y |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 171 | if event.type not in (Gdk.EventType.BUTTON_PRESS, Gdk.EventType.BUTTON_RELEASE): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 172 | return False |
| 173 | return False |
| 174 | |
| 175 | def on_area_button_release(self, area, event): |
| 176 | if event.button == 2 or event.button == 1: |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 177 | window = self.get_window() |
| 178 | window.set_cursor(Gdk.Cursor(Gdk.CursorType.ARROW)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 179 | self.prevmousex = None |
| 180 | self.prevmousey = None |
| 181 | return True |
| 182 | return False |
| 183 | |
| 184 | def on_area_scroll_event(self, area, event): |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 185 | if event.state & Gdk.CONTROL_MASK: |
| 186 | if event.direction == Gdk.SCROLL_UP: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 187 | self.zoom_image(self.zoom_ratio * self.ZOOM_INCREMENT) |
| 188 | return True |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 189 | if event.direction == Gdk.SCROLL_DOWN: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 190 | self.zoom_image(self.zoom_ratio / self.ZOOM_INCREMENT) |
| 191 | return True |
| 192 | return False |
| 193 | |
| 194 | def on_area_motion_notify(self, area, event): |
| 195 | state = event.state |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 196 | if state & Gdk.ModifierType.BUTTON2_MASK or state & Gdk.ModifierType.BUTTON1_MASK: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 197 | x, y = int(event.x), int(event.y) |
| 198 | # pan the image |
| 199 | self.x += (self.prevmousex - x)/self.zoom_ratio |
| 200 | self.y += (self.prevmousey - y)/self.zoom_ratio |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 201 | self.bound_vals() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 202 | self.queue_draw() |
| 203 | self.prevmousex = x |
| 204 | self.prevmousey = y |
| 205 | self.position_changed() |
| 206 | return True |
| 207 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 208 | def on_allocation_size_changed(self, widget, allocation): |
| 209 | self.hadj.page_size = allocation.width |
| 210 | self.hadj.page_increment = allocation.width * 0.9 |
| 211 | self.vadj.page_size = allocation.height |
| 212 | self.vadj.page_increment = allocation.height * 0.9 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 213 | self.our_width = allocation.width |
| 214 | if self.chart_width < self.our_width: |
| 215 | self.our_width = self.chart_width |
| 216 | self.our_height = allocation.height |
| 217 | if self.chart_height < self.our_height: |
| 218 | self.our_height = self.chart_height |
| 219 | self._set_scroll_adjustments() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 220 | |
| 221 | def _set_adj_upper(self, adj, upper): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 222 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 223 | if adj.get_upper() != upper: |
| 224 | adj.set_upper(upper) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 225 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 226 | def _set_scroll_adjustments(self): |
| 227 | self._set_adj_upper (self.hadj, self.zoom_ratio * (self.chart_width - self.our_width)) |
| 228 | self._set_adj_upper (self.vadj, self.zoom_ratio * (self.chart_height - self.our_height)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 229 | |
| 230 | def on_adjustments_changed(self, adj): |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 231 | self.x = self.hadj.get_value() / self.zoom_ratio |
| 232 | self.y = self.vadj.get_value() / self.zoom_ratio |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 233 | self.queue_draw() |
| 234 | |
| 235 | def on_position_changed(self, widget, x, y): |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 236 | self.hadj.set_value(x * self.zoom_ratio) |
| 237 | #self.hadj.value_changed() |
| 238 | self.vadj.set_value(y * self.zoom_ratio) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 239 | |
| 240 | class PyBootchartShell(gtk.VBox): |
| 241 | ui = ''' |
| 242 | <ui> |
| 243 | <toolbar name="ToolBar"> |
| 244 | <toolitem action="Expand"/> |
| 245 | <toolitem action="Contract"/> |
| 246 | <separator/> |
| 247 | <toolitem action="ZoomIn"/> |
| 248 | <toolitem action="ZoomOut"/> |
| 249 | <toolitem action="ZoomFit"/> |
| 250 | <toolitem action="Zoom100"/> |
| 251 | </toolbar> |
| 252 | </ui> |
| 253 | ''' |
| 254 | def __init__(self, window, trace, options, xscale): |
| 255 | gtk.VBox.__init__(self) |
| 256 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 257 | self.widget2 = PyBootchartWidget(trace, options, xscale) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 258 | |
| 259 | # Create a UIManager instance |
| 260 | uimanager = self.uimanager = gtk.UIManager() |
| 261 | |
| 262 | # Add the accelerator group to the toplevel window |
| 263 | accelgroup = uimanager.get_accel_group() |
| 264 | window.add_accel_group(accelgroup) |
| 265 | |
| 266 | # Create an ActionGroup |
| 267 | actiongroup = gtk.ActionGroup('Actions') |
| 268 | self.actiongroup = actiongroup |
| 269 | |
| 270 | # Create actions |
| 271 | actiongroup.add_actions(( |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 272 | ('Expand', gtk.STOCK_ADD, None, None, None, self.widget2.on_expand), |
| 273 | ('Contract', gtk.STOCK_REMOVE, None, None, None, self.widget2.on_contract), |
| 274 | ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, None, self.widget2.on_zoom_in), |
| 275 | ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, None, self.widget2.on_zoom_out), |
| 276 | ('ZoomFit', gtk.STOCK_ZOOM_FIT, 'Fit Width', None, None, self.widget2.on_zoom_fit), |
| 277 | ('Zoom100', gtk.STOCK_ZOOM_100, None, None, None, self.widget2.on_zoom_100), |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 278 | )) |
| 279 | |
| 280 | # Add the actiongroup to the uimanager |
| 281 | uimanager.insert_action_group(actiongroup, 0) |
| 282 | |
| 283 | # Add a UI description |
| 284 | uimanager.add_ui_from_string(self.ui) |
| 285 | |
| 286 | # Scrolled window |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 287 | scrolled = gtk.ScrolledWindow(self.widget2.hadj, self.widget2.vadj) |
| 288 | scrolled.add(self.widget2) |
| 289 | |
| 290 | #scrolled.set_hadjustment() |
| 291 | #scrolled.set_vadjustment(self.widget2.vadj) |
| 292 | scrolled.set_policy(gtk.PolicyType.ALWAYS, gtk.PolicyType.ALWAYS) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 293 | |
| 294 | # toolbar / h-box |
| 295 | hbox = gtk.HBox(False, 8) |
| 296 | |
| 297 | # Create a Toolbar |
| 298 | toolbar = uimanager.get_widget('/ToolBar') |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 299 | hbox.pack_start(toolbar, True, True, 0) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 300 | |
| 301 | if not options.kernel_only: |
| 302 | # Misc. options |
| 303 | button = gtk.CheckButton("Show more") |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 304 | button.connect ('toggled', self.widget2.show_toggled) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 305 | button.set_active(options.app_options.show_all) |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 306 | hbox.pack_start (button, False, True, 0) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 307 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 308 | self.pack_start(hbox, False, True, 0) |
| 309 | self.pack_start(scrolled, True, True, 0) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 310 | self.show_all() |
| 311 | |
| 312 | def grab_focus(self, window): |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 313 | window.set_focus(self.widget2) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 314 | |
| 315 | |
| 316 | class PyBootchartWindow(gtk.Window): |
| 317 | |
| 318 | def __init__(self, trace, app_options): |
| 319 | gtk.Window.__init__(self) |
| 320 | |
| 321 | window = self |
| 322 | window.set_title("Bootchart %s" % trace.filename) |
| 323 | window.set_default_size(750, 550) |
| 324 | |
| 325 | tab_page = gtk.Notebook() |
| 326 | tab_page.show() |
| 327 | window.add(tab_page) |
| 328 | |
| 329 | full_opts = RenderOptions(app_options) |
| 330 | full_tree = PyBootchartShell(window, trace, full_opts, 1.0) |
| 331 | tab_page.append_page (full_tree, gtk.Label("Full tree")) |
| 332 | |
| 333 | if trace.kernel is not None and len (trace.kernel) > 2: |
| 334 | kernel_opts = RenderOptions(app_options) |
| 335 | kernel_opts.cumulative = False |
| 336 | kernel_opts.charts = False |
| 337 | kernel_opts.kernel_only = True |
| 338 | kernel_tree = PyBootchartShell(window, trace, kernel_opts, 5.0) |
| 339 | tab_page.append_page (kernel_tree, gtk.Label("Kernel boot")) |
| 340 | |
| 341 | full_tree.grab_focus(self) |
| 342 | self.show() |
| 343 | |
| 344 | |
| 345 | def show(trace, options): |
| 346 | win = PyBootchartWindow(trace, options) |
| 347 | win.connect('destroy', gtk.main_quit) |
| 348 | gtk.main() |