diff options
author | Liming An <limingx.l.an@intel.com> | 2012-05-30 20:01:10 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-05-30 17:23:30 +0100 |
commit | 6609a813bbfa3fe5a0681c4ec7b17f18b846efc7 (patch) | |
tree | 33c319ba6dd382c1c5214bb6a41a2fdfa06e8a91 /bitbake/lib/bb/ui | |
parent | cc3da1236c4f5a26bf2ffd0f0357273f4e070b56 (diff) | |
download | poky-6609a813bbfa3fe5a0681c4ec7b17f18b846efc7.tar.gz |
Hob: Fixed a compatible issue for indicator icon view
Because some screen not support the alpha visual channel, so the function
'screen.get_rgba_colormap()' will return None, it's a compatible issue, so
change it by another way.
(Bitbake rev: e58ba1ad944ea1ba95a5ada80d4c88f0165bd1ca)
Signed-off-by: Liming An <limingx.l.an@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hobwidget.py | 51 |
1 files changed, 8 insertions, 43 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py index f8e97ad1f8..bd9e2e28e9 100644 --- a/bitbake/lib/bb/ui/crumbs/hobwidget.py +++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py | |||
@@ -400,50 +400,33 @@ class HobInfoButton(gtk.EventBox): | |||
400 | class HobIndicator(gtk.DrawingArea): | 400 | class HobIndicator(gtk.DrawingArea): |
401 | def __init__(self, count): | 401 | def __init__(self, count): |
402 | gtk.DrawingArea.__init__(self) | 402 | gtk.DrawingArea.__init__(self) |
403 | 403 | # Set no window for transparent background | |
404 | # We want to composite the transparent indicator onto the parent | 404 | self.set_has_window(False) |
405 | # HBox | ||
406 | screen = self.get_screen() | ||
407 | rgba = screen.get_rgba_colormap() | ||
408 | self.set_colormap(rgba) | ||
409 | self.set_app_paintable(True) | ||
410 | self.set_size_request(38,38) | 405 | self.set_size_request(38,38) |
411 | # We need to pass through button clicks | 406 | # We need to pass through button clicks |
412 | self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK) | 407 | self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK) |
413 | 408 | ||
414 | self.connect('expose-event', self.expose) | 409 | self.connect('expose-event', self.expose) |
415 | self.connect_after('realize', self.composite) | ||
416 | 410 | ||
417 | self.count = count | 411 | self.count = count |
418 | self.color = HobColors.GRAY | 412 | self.color = HobColors.GRAY |
419 | 413 | ||
420 | def composite(self, widget): | ||
421 | # This property must be set after the widget has been realised | ||
422 | self.window.set_composited(True) | ||
423 | |||
424 | def expose(self, widget, event): | 414 | def expose(self, widget, event): |
425 | # Transparent background | ||
426 | ctx = widget.window.cairo_create() | ||
427 | ctx.set_operator(cairo.OPERATOR_CLEAR) | ||
428 | region = gtk.gdk.region_rectangle(event.area) | ||
429 | |||
430 | ctx.region(region) | ||
431 | ctx.fill() | ||
432 | |||
433 | if self.count and self.count > 0: | 415 | if self.count and self.count > 0: |
434 | w = self.allocation.width | 416 | ctx = widget.window.cairo_create() |
435 | h = self.allocation.height | 417 | |
418 | x, y, w, h = self.allocation | ||
436 | 419 | ||
437 | ctx.set_operator(cairo.OPERATOR_OVER) | 420 | ctx.set_operator(cairo.OPERATOR_OVER) |
438 | ctx.set_source_color(gtk.gdk.color_parse(self.color)) | 421 | ctx.set_source_color(gtk.gdk.color_parse(self.color)) |
439 | ctx.translate(w/2, h/2) | 422 | ctx.translate(w/2, h/2) |
440 | ctx.arc(1, 1, min(w,h)/2 - 2, 0, 2*math.pi) | 423 | ctx.arc(x, y, min(w,h)/2 - 2, 0, 2*math.pi) |
441 | ctx.fill_preserve() | 424 | ctx.fill_preserve() |
442 | 425 | ||
443 | layout = self.create_pango_layout(str(self.count)) | 426 | layout = self.create_pango_layout(str(self.count)) |
444 | textw, texth = layout.get_pixel_size() | 427 | textw, texth = layout.get_pixel_size() |
445 | x = (w/2)-(textw/2) + 1 | 428 | x = (w/2)-(textw/2) + x |
446 | y = (h/2) - (texth/2) + 1 | 429 | y = (h/2) - (texth/2) + y |
447 | ctx.move_to(x, y) | 430 | ctx.move_to(x, y) |
448 | self.window.draw_layout(self.style.light_gc[gtk.STATE_NORMAL], int(x), int(y), layout) | 431 | self.window.draw_layout(self.style.light_gc[gtk.STATE_NORMAL], int(x), int(y), layout) |
449 | 432 | ||
@@ -466,24 +449,6 @@ class HobTabLabel(gtk.HBox): | |||
466 | self.lbl.set_alignment(0.0, 0.5) | 449 | self.lbl.set_alignment(0.0, 0.5) |
467 | self.lbl.show() | 450 | self.lbl.show() |
468 | self.pack_end(self.lbl, True, True, 6) | 451 | self.pack_end(self.lbl, True, True, 6) |
469 | self.connect_after('expose-event', self.expose_event) | ||
470 | |||
471 | def expose_event(self, widget, event): | ||
472 | # Composite the child indicator onto the Box | ||
473 | child = self.indicator | ||
474 | ctx = widget.window.cairo_create() | ||
475 | |||
476 | ctx.set_source_pixmap(child.window, child.allocation.x, child.allocation.y) | ||
477 | |||
478 | region = gtk.gdk.region_rectangle(child.allocation) | ||
479 | r = gtk.gdk.region_rectangle(event.area) | ||
480 | region.intersect(r) | ||
481 | ctx.region(region) | ||
482 | ctx.clip() | ||
483 | |||
484 | ctx.paint() | ||
485 | |||
486 | return False | ||
487 | 452 | ||
488 | def set_count(self, count): | 453 | def set_count(self, count): |
489 | self.indicator.set_count(count) | 454 | self.indicator.set_count(count) |