diff options
author | Shane Wang <shane.wang@intel.com> | 2012-02-27 13:28:26 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-03-20 15:21:32 +0000 |
commit | 88bbc0ce562aa80d2b98c8b48d79a612b47ca852 (patch) | |
tree | d3bbe6d318e96cbbcc46f350d6a730c36320a47c /bitbake/lib/bb/ui/crumbs | |
parent | 8b206d38c7fb172022e98a0879963e5f44bc2092 (diff) | |
download | poky-88bbc0ce562aa80d2b98c8b48d79a612b47ca852.tar.gz |
Hob: implement a self-defined notebook visual component for Hob
In recipe selection page, package selection page, and build details page, etc, there is a notebook component which is not gtk.Notebook in the design video.
We implement the visual component with a drawing area, and use it to replace the old notebook in recipe selection page and package selection page. The reasons why we do it are:
1) General speaking, gtk.Notebook doesn't look like the designer worked out. (see https://wiki.yoctoproject.org/wiki/File:Hob1.2-screencast2.mov)
2) And the designer version looks better, for example, there is an indicator to show how many recipes or packages are included, and how many issues happened when building? Very straightforward.
But technically, gtk.Notebook can't implement that, as far as we know.
3) Moreover, there is an entry for "search recipes", and "search packages". How to make it horizontal to the tabs is a problem to us.
Regarding those, we give up gtk.Notebook and use our own.
(From Poky rev: e4ebac226cc5e4589bcecd8bada9fde462e925cc)
(Bitbake rev: b0c2ca3f600694c6d37924006de3f9474b2a9a8e)
Signed-off-by: Liming An <limingx.l.an@intel.com>
Signed-off-by: Shane Wang <shane.wang@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hobcolor.py | 1 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hobwidget.py | 468 | ||||
-rwxr-xr-x | bitbake/lib/bb/ui/crumbs/packageselectionpage.py | 17 | ||||
-rwxr-xr-x | bitbake/lib/bb/ui/crumbs/recipeselectionpage.py | 19 |
4 files changed, 394 insertions, 111 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hobcolor.py b/bitbake/lib/bb/ui/crumbs/hobcolor.py index 9d67d5c496..402f022128 100644 --- a/bitbake/lib/bb/ui/crumbs/hobcolor.py +++ b/bitbake/lib/bb/ui/crumbs/hobcolor.py | |||
@@ -28,6 +28,7 @@ class HobColors: | |||
28 | DARK = "#3c3b37" | 28 | DARK = "#3c3b37" |
29 | BLACK = "#000000" | 29 | BLACK = "#000000" |
30 | LIGHT_ORANGE = "#f7a787" | 30 | LIGHT_ORANGE = "#f7a787" |
31 | YELLOW = "#ffff00" | ||
31 | 32 | ||
32 | OK = WHITE | 33 | OK = WHITE |
33 | RUNNING = PALE_GREEN | 34 | RUNNING = PALE_GREEN |
diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py index f4ff1dc881..8fa663c78a 100644 --- a/bitbake/lib/bb/ui/crumbs/hobwidget.py +++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py | |||
@@ -17,11 +17,14 @@ | |||
17 | # You should have received a copy of the GNU General Public License along | 17 | # You should have received a copy of the GNU General Public License along |
18 | # with this program; if not, write to the Free Software Foundation, Inc., | 18 | # with this program; if not, write to the Free Software Foundation, Inc., |
19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 | |||
21 | import gtk | 20 | import gtk |
22 | import gobject | 21 | import gobject |
23 | import os | 22 | import os |
24 | import os.path | 23 | import os.path |
24 | import sys | ||
25 | import pango, pangocairo | ||
26 | import math | ||
27 | |||
25 | from bb.ui.crumbs.hobcolor import HobColors | 28 | from bb.ui.crumbs.hobcolor import HobColors |
26 | from bb.ui.crumbs.persistenttooltip import PersistentTooltip | 29 | from bb.ui.crumbs.persistenttooltip import PersistentTooltip |
27 | 30 | ||
@@ -168,90 +171,6 @@ class HobViewTable (gtk.VBox): | |||
168 | if not view_column.get_title() in self.toggle_columns: | 171 | if not view_column.get_title() in self.toggle_columns: |
169 | self.emit("row-activated", tree.get_model(), path) | 172 | self.emit("row-activated", tree.get_model(), path) |
170 | 173 | ||
171 | class HobViewBar (gtk.EventBox): | ||
172 | """ | ||
173 | A EventBox with the specified gray background color is associated with a notebook. | ||
174 | And the toolbar to simulate the tabs. | ||
175 | """ | ||
176 | |||
177 | def __init__(self, notebook): | ||
178 | if not notebook: | ||
179 | return | ||
180 | self.notebook = notebook | ||
181 | |||
182 | # setup an event box | ||
183 | gtk.EventBox.__init__(self) | ||
184 | self.set_border_width(2) | ||
185 | style = self.get_style().copy() | ||
186 | style.bg[gtk.STATE_NORMAL] = self.get_colormap().alloc_color (HobColors.GRAY, False, False) | ||
187 | self.set_style(style) | ||
188 | |||
189 | hbox = gtk.HBox() | ||
190 | self.add(hbox) | ||
191 | |||
192 | # setup a tool bar in the event box | ||
193 | self.toolbar = gtk.Toolbar() | ||
194 | self.toolbar.set_orientation(gtk.ORIENTATION_HORIZONTAL) | ||
195 | self.toolbar.set_style(gtk.TOOLBAR_TEXT) | ||
196 | self.toolbar.set_border_width(5) | ||
197 | |||
198 | self.toolbuttons = [] | ||
199 | for index in range(self.notebook.get_n_pages()): | ||
200 | child = self.notebook.get_nth_page(index) | ||
201 | label = self.notebook.get_tab_label_text(child) | ||
202 | tip_text = 'switch to ' + label + ' page' | ||
203 | toolbutton = self.toolbar.append_element(gtk.TOOLBAR_CHILD_RADIOBUTTON, None, | ||
204 | label, tip_text, "Private text", None, | ||
205 | self.toolbutton_cb, index) | ||
206 | toolbutton.set_size_request(200, 100) | ||
207 | self.toolbuttons.append(toolbutton) | ||
208 | |||
209 | # set the default current page | ||
210 | self.modify_toolbuttons_bg(0) | ||
211 | self.notebook.set_current_page(0) | ||
212 | |||
213 | self.toolbar.append_space() | ||
214 | |||
215 | # add the tool bar into the event box | ||
216 | hbox.pack_start(self.toolbar, expand=False, fill=False) | ||
217 | |||
218 | self.search = gtk.Entry() | ||
219 | self.align = gtk.Alignment(xalign=0.5, yalign=0.5) | ||
220 | self.align.add(self.search) | ||
221 | hbox.pack_end(self.align, expand=False, fill=False) | ||
222 | |||
223 | self.label = gtk.Label(" Search: ") | ||
224 | self.label.set_alignment(0.5, 0.5) | ||
225 | hbox.pack_end(self.label, expand=False, fill=False) | ||
226 | |||
227 | def toolbutton_cb(self, widget, index): | ||
228 | if index >= self.notebook.get_n_pages(): | ||
229 | return | ||
230 | self.notebook.set_current_page(index) | ||
231 | self.modify_toolbuttons_bg(index) | ||
232 | |||
233 | def modify_toolbuttons_bg(self, index): | ||
234 | if index >= len(self.toolbuttons): | ||
235 | return | ||
236 | for i in range(0, len(self.toolbuttons)): | ||
237 | toolbutton = self.toolbuttons[i] | ||
238 | if i == index: | ||
239 | self.modify_toolbutton_bg(toolbutton, True) | ||
240 | else: | ||
241 | self.modify_toolbutton_bg(toolbutton) | ||
242 | |||
243 | def modify_toolbutton_bg(self, toolbutton, active=False): | ||
244 | if active: | ||
245 | toolbutton.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(HobColors.WHITE)) | ||
246 | toolbutton.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.Color(HobColors.WHITE)) | ||
247 | toolbutton.modify_bg(gtk.STATE_SELECTED, gtk.gdk.Color(HobColors.WHITE)) | ||
248 | toolbutton.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(HobColors.WHITE)) | ||
249 | else: | ||
250 | toolbutton.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(HobColors.GRAY)) | ||
251 | toolbutton.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.Color(HobColors.GRAY)) | ||
252 | toolbutton.modify_bg(gtk.STATE_SELECTED, gtk.gdk.Color(HobColors.GRAY)) | ||
253 | toolbutton.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(HobColors.GRAY)) | ||
254 | |||
255 | class HobXpmLabelButtonBox(gtk.EventBox): | 174 | class HobXpmLabelButtonBox(gtk.EventBox): |
256 | """ label: name of buttonbox | 175 | """ label: name of buttonbox |
257 | description: the simple description | 176 | description: the simple description |
@@ -360,3 +279,382 @@ class HobInfoButton(gtk.EventBox): | |||
360 | """ | 279 | """ |
361 | def mouse_out_cb(self, widget, event): | 280 | def mouse_out_cb(self, widget, event): |
362 | self.image.set_from_file(hic.ICON_INFO_DISPLAY_FILE) | 281 | self.image.set_from_file(hic.ICON_INFO_DISPLAY_FILE) |
282 | |||
283 | class HobTabBar(gtk.DrawingArea): | ||
284 | __gsignals__ = { | ||
285 | "blank-area-changed" : (gobject.SIGNAL_RUN_LAST, | ||
286 | gobject.TYPE_NONE, | ||
287 | (gobject.TYPE_INT, | ||
288 | gobject.TYPE_INT, | ||
289 | gobject.TYPE_INT, | ||
290 | gobject.TYPE_INT,)), | ||
291 | |||
292 | "tab-switched" : (gobject.SIGNAL_RUN_LAST, | ||
293 | gobject.TYPE_NONE, | ||
294 | (gobject.TYPE_INT,)), | ||
295 | } | ||
296 | |||
297 | def __init__(self): | ||
298 | gtk.DrawingArea.__init__(self) | ||
299 | self.children = [] | ||
300 | |||
301 | self.tab_width = 140 | ||
302 | self.tab_height = 52 | ||
303 | self.tab_x = 10 | ||
304 | self.tab_y = 0 | ||
305 | |||
306 | self.width = 500 | ||
307 | self.height = 53 | ||
308 | self.tab_w_ratio = 140 * 1.0/500 | ||
309 | self.tab_h_ratio = 52 * 1.0/53 | ||
310 | self.set_size_request(self.width, self.height) | ||
311 | |||
312 | self.current_child = 0 | ||
313 | self.font = self.get_style().font_desc | ||
314 | self.font.set_size(pango.SCALE * 13) | ||
315 | self.update_children_text_layout_and_bg_color() | ||
316 | |||
317 | self.blank_rectangle = None | ||
318 | self.tab_pressed = False | ||
319 | |||
320 | self.set_property('can-focus', True) | ||
321 | self.set_events(gtk.gdk.EXPOSURE_MASK | gtk.gdk.POINTER_MOTION_MASK | | ||
322 | gtk.gdk.BUTTON1_MOTION_MASK | gtk.gdk.BUTTON_PRESS_MASK | | ||
323 | gtk.gdk.BUTTON_RELEASE_MASK) | ||
324 | |||
325 | self.connect("expose-event", self.on_draw) | ||
326 | self.connect("button-press-event", self.button_pressed_cb) | ||
327 | self.connect("button-release-event", self.button_released_cb) | ||
328 | self.show_all() | ||
329 | |||
330 | def button_released_cb(self, widget, event): | ||
331 | self.tab_pressed = False | ||
332 | self.queue_draw() | ||
333 | |||
334 | def button_pressed_cb(self, widget, event): | ||
335 | if event.type == gtk.gdk._2BUTTON_PRESS: | ||
336 | return | ||
337 | |||
338 | result = False | ||
339 | if self.is_focus() or event.type == gtk.gdk.BUTTON_PRESS: | ||
340 | x, y = event.get_coords() | ||
341 | # check which tab be clicked | ||
342 | for i, child in enumerate(self.children): | ||
343 | if (child["x"] < x) and (x < child["x"] + self.tab_width) \ | ||
344 | and (child["y"] < y) and (y < child["y"] + self.tab_height): | ||
345 | self.current_child = i | ||
346 | result = True | ||
347 | break | ||
348 | |||
349 | # check the blank area is focus in or not | ||
350 | if (self.blank_rectangle) and (self.blank_rectangle.x > 0) and (self.blank_rectangle.y > 0): | ||
351 | if (self.blank_rectangle.x < x) and (x < self.blank_rectangle.x + self.blank_rectangle.width) \ | ||
352 | and (self.blank_rectangle.y < y) and (y < self.blank_rectangle.y + self.blank_rectangle.height): | ||
353 | self.grab_focus() | ||
354 | |||
355 | if result == True: | ||
356 | page = self.children[self.current_child]["toggled_page"] | ||
357 | self.emit("tab-switched", page) | ||
358 | self.tab_pressed = True | ||
359 | self.queue_draw() | ||
360 | |||
361 | def update_children_size(self): | ||
362 | # calculate the size of tabs | ||
363 | self.tab_width = int(self.width * self.tab_w_ratio) | ||
364 | self.tab_height = int(self.height * self.tab_h_ratio) | ||
365 | for i, child in enumerate(self.children): | ||
366 | child["x"] = self.tab_x + i * self.tab_width | ||
367 | child["y"] = self.tab_y | ||
368 | |||
369 | if self.blank_rectangle != None: | ||
370 | self.resize_blank_rectangle() | ||
371 | |||
372 | def resize_blank_rectangle(self): | ||
373 | width = self.width - self.tab_width * len(self.children) - self.tab_x | ||
374 | x = self.tab_x + self.tab_width * len(self.children) | ||
375 | hpadding = vpadding = 5 | ||
376 | self.blank_rectangle = self.set_blank_size(x + hpadding, self.tab_y + vpadding, | ||
377 | width - 2 * hpadding, self.tab_height - 2 * vpadding) | ||
378 | |||
379 | def update_children_text_layout_and_bg_color(self): | ||
380 | style = self.get_style().copy() | ||
381 | color = style.base[gtk.STATE_NORMAL] | ||
382 | for child in self.children: | ||
383 | pangolayout = self.create_pango_layout(child["title"]) | ||
384 | pangolayout.set_font_description(self.font) | ||
385 | child["title_layout"] = pangolayout | ||
386 | child[i]["r"] = color.red | ||
387 | child[i]["g"] = color.green | ||
388 | child[i]["b"] = color.blue | ||
389 | |||
390 | def append_tab_child(self, title, page): | ||
391 | num = len(self.children) + 1 | ||
392 | self.tab_width = self.tab_width * len(self.children) / num | ||
393 | |||
394 | i = 0 | ||
395 | for child in self.children: | ||
396 | child["x"] = self.tab_x + i * self.tab_width | ||
397 | i += 1 | ||
398 | |||
399 | x = self.tab_x + i * self.tab_width | ||
400 | y = self.tab_y | ||
401 | pangolayout = self.create_pango_layout(title) | ||
402 | pangolayout.set_font_description(self.font) | ||
403 | color = self.style.base[gtk.STATE_NORMAL] | ||
404 | new_one = { | ||
405 | "x" : x, | ||
406 | "y" : y, | ||
407 | "r" : color.red, | ||
408 | "g" : color.green, | ||
409 | "b" : color.blue, | ||
410 | "title_layout" : pangolayout, | ||
411 | "toggled_page" : page, | ||
412 | "title" : title, | ||
413 | "indicator_show" : False, | ||
414 | "indicator_number" : 0, | ||
415 | } | ||
416 | self.children.append(new_one) | ||
417 | |||
418 | def on_draw(self, widget, event): | ||
419 | cr = widget.window.cairo_create() | ||
420 | |||
421 | self.width = self.allocation.width | ||
422 | self.height = self.allocation.height | ||
423 | |||
424 | self.update_children_size() | ||
425 | |||
426 | self.draw_background(cr) | ||
427 | self.draw_toggled_tab(cr) | ||
428 | self.draw_tab_text(cr) | ||
429 | |||
430 | for i, child in enumerate(self.children): | ||
431 | if child["indicator_show"] == True: | ||
432 | self.draw_indicator(cr, i) | ||
433 | |||
434 | def draw_background(self, cr): | ||
435 | style = self.get_style() | ||
436 | |||
437 | if self.is_focus(): | ||
438 | cr.set_source_color(style.base[gtk.STATE_SELECTED]) | ||
439 | else: | ||
440 | cr.set_source_color(style.base[gtk.STATE_NORMAL]) | ||
441 | |||
442 | y = 6 | ||
443 | h = self.height - 6 - 1 | ||
444 | gap = 1 | ||
445 | |||
446 | w = self.children[0]["x"] | ||
447 | cr.set_source_color(gtk.gdk.color_parse(HobColors.GRAY)) | ||
448 | cr.rectangle(0, y, w - gap, h) # start rectangle | ||
449 | cr.fill() | ||
450 | |||
451 | cr.set_source_color(style.base[gtk.STATE_NORMAL]) | ||
452 | cr.rectangle(w - gap, y, w, h) #first gap | ||
453 | cr.fill() | ||
454 | |||
455 | w = self.tab_width | ||
456 | for child in self.children: | ||
457 | x = child["x"] | ||
458 | cr.set_source_color(gtk.gdk.color_parse(HobColors.GRAY)) | ||
459 | cr.rectangle(x, y, w - gap, h) # tab rectangle | ||
460 | cr.fill() | ||
461 | cr.set_source_color(style.base[gtk.STATE_NORMAL]) | ||
462 | cr.rectangle(x + w - gap, y, w, h) # gap | ||
463 | cr.fill() | ||
464 | |||
465 | cr.set_source_color(gtk.gdk.color_parse(HobColors.GRAY)) | ||
466 | cr.rectangle(x + w, y, self.width - x - w, h) # last rectangle | ||
467 | cr.fill() | ||
468 | |||
469 | def draw_tab_text(self, cr): | ||
470 | style = self.get_style() | ||
471 | |||
472 | for child in self.children: | ||
473 | pangolayout = child["title_layout"] | ||
474 | if pangolayout: | ||
475 | fontw, fonth = pangolayout.get_pixel_size() | ||
476 | # center pos | ||
477 | off_x = (self.tab_width - fontw) / 2 | ||
478 | off_y = (self.tab_height - fonth) / 2 | ||
479 | x = child[i]["x"] + off_x | ||
480 | y = child[i]["y"] + off_y | ||
481 | self.window.draw_layout(self.style.fg_gc[gtk.STATE_NORMAL], int(x), int(y), pangolayout) | ||
482 | |||
483 | def draw_toggled_tab(self, cr): | ||
484 | i = self.current_child | ||
485 | x = self.children[i]["x"] | ||
486 | y = self.children[i]["y"] | ||
487 | width = self.tab_width | ||
488 | height = self.tab_height | ||
489 | style = self.get_style() | ||
490 | color = style.base[gtk.STATE_NORMAL] | ||
491 | |||
492 | r = height / 10 | ||
493 | if self.tab_pressed == True: | ||
494 | for xoff, yoff in [(1, 0), (2, 0)]: | ||
495 | cr.set_source_color(gtk.gdk.color_parse(HobColors.PALE_GREEN)) | ||
496 | cr.move_to(x + r + xoff, y + yoff) | ||
497 | cr.line_to(x + width - r + xoff, y + yoff) | ||
498 | cr.arc(x + width - r+ xoff, y + r + yoff, r, 1.5*math.pi, 2*math.pi) | ||
499 | cr.move_to(x + width + xoff, r + yoff) | ||
500 | cr.line_to(x + width + xoff, y + height + yoff) | ||
501 | cr.line_to(x + xoff, y + height + yoff) | ||
502 | cr.line_to(x + xoff, r + yoff) | ||
503 | cr.arc(x + r + xoff, y + r + yoff, r, math.pi, 1.5*math.pi) | ||
504 | cr.stroke() | ||
505 | x = x + 2 | ||
506 | y = y + 2 | ||
507 | cr.set_source_rgba(color.red, color.green, color.blue, 1) | ||
508 | cr.move_to(x + r, y) | ||
509 | cr.line_to(x + width - r , y) | ||
510 | cr.arc(x + width - r, y + r, r, 1.5*math.pi, 2*math.pi) | ||
511 | cr.move_to(x + width, r) | ||
512 | cr.line_to(x + width, y + height) | ||
513 | cr.line_to(x, y + height) | ||
514 | cr.line_to(x, r) | ||
515 | cr.arc(x + r, y + r, r, math.pi, 1.5*math.pi) | ||
516 | cr.fill() | ||
517 | |||
518 | def draw_indicator(self, cr, i): | ||
519 | style = self.get_style() | ||
520 | tab_x = self.children[i]["x"] | ||
521 | tab_y = self.children[i]["y"] | ||
522 | number = self.children[i]["indicator_number"] | ||
523 | dest_w = int(32 * self.tab_w_ratio) | ||
524 | dest_h = int(32 * self.tab_h_ratio) | ||
525 | if dest_h < self.tab_height: | ||
526 | dest_w = dest_h | ||
527 | |||
528 | # x position is offset(tab_width*3/4 - icon_width/2) + start_pos(tab_x) | ||
529 | x = tab_x + self.tab_width * 3/4 - dest_w/2 | ||
530 | y = tab_y + self.tab_height/2 - dest_h/2 | ||
531 | cr.move_to(tab_x, tab_y) | ||
532 | r = min(dest_w, dest_h)/2 | ||
533 | color = cr.set_source_color(gtk.gdk.color_parse(HobColors.ORANGE)) | ||
534 | cr.arc(x + r, y + r, r, 0, 2*math.pi) | ||
535 | cr.fill() | ||
536 | |||
537 | text = ("%d" % number) | ||
538 | layout = self.create_pango_layout(text) | ||
539 | layout.set_font_description(self.font) | ||
540 | textw, texth = layout.get_pixel_size() | ||
541 | x = x + (dest_w/2)-(textw/2) | ||
542 | y = y + (dest_h/2) - (texth/2) | ||
543 | cr.move_to(x, y) | ||
544 | self.window.draw_layout(self.style.fg_gc[gtk.STATE_NORMAL], int(x), int(y), layout) | ||
545 | |||
546 | def show_indicator_icon(self, i, number): | ||
547 | self.children[i]["indicator_show"] = True | ||
548 | self.children[i]["indicator_number"] = number | ||
549 | self.queue_draw() | ||
550 | |||
551 | def hide_indicator_icon(self, i): | ||
552 | self.children[i]["indicator_show"] = False | ||
553 | self.queue_draw() | ||
554 | |||
555 | def set_blank_size(self, x, y, w, h): | ||
556 | if self.blank_rectangle == None or self.blank_rectangle.x != x or self.blank_rectangle.width != w: | ||
557 | self.emit("blank-area-changed", x, y, w, h) | ||
558 | |||
559 | return gtk.gdk.Rectangle(x, y, w, h) | ||
560 | |||
561 | class HobNotebook(gtk.VBox): | ||
562 | |||
563 | def __init__(self): | ||
564 | gtk.VBox.__init__(self, False, 0) | ||
565 | |||
566 | self.notebook = gtk.Notebook() | ||
567 | self.notebook.set_property('homogeneous', True) | ||
568 | self.notebook.set_property('show-tabs', False) | ||
569 | |||
570 | self.tabbar = HobTabBar() | ||
571 | self.tabbar.connect("tab-switched", self.tab_switched_cb) | ||
572 | self.notebook.connect("page-added", self.page_added_cb) | ||
573 | self.notebook.connect("page-removed", self.page_removed_cb) | ||
574 | |||
575 | self.search = None | ||
576 | self.search_name = "" | ||
577 | |||
578 | self.tb = gtk.Table(1, 100, False) | ||
579 | self.hbox= gtk.HBox(False, 0) | ||
580 | self.hbox.pack_start(self.tabbar, True, True) | ||
581 | self.tb.attach(self.hbox, 0, 100, 0, 1) | ||
582 | |||
583 | self.pack_start(self.tb, False, False) | ||
584 | self.pack_start(self.notebook) | ||
585 | |||
586 | self.show_all() | ||
587 | |||
588 | def append_page(self, child, tab_label): | ||
589 | self.notebook.set_current_page(self.notebook.append_page(child, tab_label)) | ||
590 | |||
591 | def set_entry(self, name="Search:"): | ||
592 | for child in self.tb.get_children(): | ||
593 | if child: | ||
594 | self.tb.remove(child) | ||
595 | |||
596 | hbox_entry = gtk.HBox(False, 0) | ||
597 | hbox_entry.show() | ||
598 | |||
599 | self.search = gtk.Entry() | ||
600 | self.search_name = name | ||
601 | style = self.search.get_style() | ||
602 | style.text[gtk.STATE_NORMAL] = self.get_colormap().alloc_color(HobColors.GRAY, False, False) | ||
603 | self.search.set_style(style) | ||
604 | self.search.set_text(name) | ||
605 | self.search.set_editable(False) | ||
606 | self.search.show() | ||
607 | self.align = gtk.Alignment(xalign=1.0, yalign=0.7) | ||
608 | self.align.add(self.search) | ||
609 | self.align.show() | ||
610 | hbox_entry.pack_end(self.align, False, False) | ||
611 | self.tabbar.resize_blank_rectangle() | ||
612 | |||
613 | self.tb.attach(hbox_entry, 75, 100, 0, 1, xpadding=5) | ||
614 | self.tb.attach(self.hbox, 0, 100, 0, 1) | ||
615 | |||
616 | self.tabbar.connect("blank-area-changed", self.blank_area_resize_cb) | ||
617 | self.search.connect("focus-in-event", self.set_search_entry_editable_cb) | ||
618 | self.search.connect("focus-out-event", self.set_search_entry_reset_cb) | ||
619 | |||
620 | self.tb.show() | ||
621 | |||
622 | def tab_switched_cb(self, widget, page): | ||
623 | self.notebook.set_current_page(page) | ||
624 | |||
625 | def page_added_cb(self, notebook, notebook_child, page): | ||
626 | if not notebook: | ||
627 | return | ||
628 | title = notebook.get_tab_label_text(notebook_child) | ||
629 | if title == None: | ||
630 | return | ||
631 | for child in self.tabbar.children: | ||
632 | if child["title"] == title: | ||
633 | child["toggled_page"] = page | ||
634 | return | ||
635 | self.tabbar.append_tab_child(title, page) | ||
636 | |||
637 | def page_removed_cb(self, notebook, notebook_child, page, title=""): | ||
638 | for child in self.tabbar.children: | ||
639 | if child["title"] == title: | ||
640 | child["toggled_page"] = -1 | ||
641 | |||
642 | def blank_area_resize_cb(self, widget, request_x, request_y, request_width, request_height): | ||
643 | self.search.set_size_request(request_width, request_height) | ||
644 | widget.modify_bg(gtk.STATE_SELECTED, gtk.gdk.color_parse(HobColors.YELLOW)) | ||
645 | |||
646 | def set_search_entry_editable_cb(self, widget, event): | ||
647 | if self.search: | ||
648 | self.search.set_editable(True) | ||
649 | self.search.set_text("") | ||
650 | style = self.search.get_style() | ||
651 | style.text[gtk.STATE_NORMAL] = self.get_colormap().alloc_color(HobColors.BLACK, False, False) | ||
652 | self.search.set_style(style) | ||
653 | |||
654 | def set_search_entry_reset_cb(self, widget, event): | ||
655 | if self.search: | ||
656 | style = self.search.get_style() | ||
657 | style.text[gtk.STATE_NORMAL] = self.get_colormap().alloc_color(HobColors.GRAY, False, False) | ||
658 | self.search.set_style(style) | ||
659 | self.search.set_text(self.search_name) | ||
660 | self.search.set_editable(False) | ||
diff --git a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py index 1c335ac733..3cd1c5e725 100755 --- a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py +++ b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py | |||
@@ -23,7 +23,7 @@ | |||
23 | import gtk | 23 | import gtk |
24 | import glib | 24 | import glib |
25 | from bb.ui.crumbs.hobcolor import HobColors | 25 | from bb.ui.crumbs.hobcolor import HobColors |
26 | from bb.ui.crumbs.hobwidget import HobViewBar, HobViewTable | 26 | from bb.ui.crumbs.hobwidget import HobViewTable, HobNotebook |
27 | from bb.ui.crumbs.hoblistmodel import PackageListModel | 27 | from bb.ui.crumbs.hoblistmodel import PackageListModel |
28 | from bb.ui.crumbs.hobpages import HobPage | 28 | from bb.ui.crumbs.hobpages import HobPage |
29 | 29 | ||
@@ -102,11 +102,7 @@ class PackageSelectionPage (HobPage): | |||
102 | self.pack_start(self.group_align, expand=True, fill=True) | 102 | self.pack_start(self.group_align, expand=True, fill=True) |
103 | 103 | ||
104 | # set visiable members | 104 | # set visiable members |
105 | self.grid = gtk.Table(10, 1, True) | 105 | self.ins = HobNotebook() |
106 | self.grid.set_col_spacings(3) | ||
107 | |||
108 | self.ins = gtk.Notebook() | ||
109 | self.ins.set_show_tabs(False) | ||
110 | self.tables = [] # we need to modify table when the dialog is shown | 106 | self.tables = [] # we need to modify table when the dialog is shown |
111 | # append the tab | 107 | # append the tab |
112 | for i in range(len(self.pages)): | 108 | for i in range(len(self.pages)): |
@@ -122,16 +118,13 @@ class PackageSelectionPage (HobPage): | |||
122 | self.ins.append_page(tab, label) | 118 | self.ins.append_page(tab, label) |
123 | self.tables.append(tab) | 119 | self.tables.append(tab) |
124 | 120 | ||
125 | self.grid.attach(self.ins, 0, 1, 1, 10, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND, 1, 1) | 121 | self.ins.set_entry("Search packages:") |
126 | # a black bar associated with the notebook | ||
127 | self.topbar = HobViewBar(self.ins) | ||
128 | self.grid.attach(self.topbar, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND, 1, 1) | ||
129 | # set the search entry for each table | 122 | # set the search entry for each table |
130 | for tab in self.tables: | 123 | for tab in self.tables: |
131 | tab.set_search_entry(0, self.topbar.search) | 124 | tab.set_search_entry(0, self.ins.search) |
132 | 125 | ||
133 | # add all into the dialog | 126 | # add all into the dialog |
134 | self.box_group_area.add(self.grid) | 127 | self.box_group_area.pack_start(self.ins, expand=True, fill=True) |
135 | 128 | ||
136 | button_box = gtk.HBox(False, 6) | 129 | button_box = gtk.HBox(False, 6) |
137 | self.box_group_area.pack_start(button_box, expand=False, fill=False) | 130 | self.box_group_area.pack_start(button_box, expand=False, fill=False) |
diff --git a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py index d615ef1897..db873b611a 100755 --- a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py +++ b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py | |||
@@ -23,7 +23,7 @@ | |||
23 | import gtk | 23 | import gtk |
24 | import glib | 24 | import glib |
25 | from bb.ui.crumbs.hobcolor import HobColors | 25 | from bb.ui.crumbs.hobcolor import HobColors |
26 | from bb.ui.crumbs.hobwidget import HobViewBar, HobViewTable | 26 | from bb.ui.crumbs.hobwidget import HobViewTable, HobNotebook |
27 | from bb.ui.crumbs.hoblistmodel import RecipeListModel | 27 | from bb.ui.crumbs.hoblistmodel import RecipeListModel |
28 | from bb.ui.crumbs.hobpages import HobPage | 28 | from bb.ui.crumbs.hobpages import HobPage |
29 | 29 | ||
@@ -124,13 +124,7 @@ class RecipeSelectionPage (HobPage): | |||
124 | self.pack_start(self.group_align, expand=True, fill=True) | 124 | self.pack_start(self.group_align, expand=True, fill=True) |
125 | 125 | ||
126 | # set visiable members | 126 | # set visiable members |
127 | self.grid = gtk.Table(10, 1, True) | 127 | self.ins = HobNotebook() |
128 | self.grid.set_col_spacings(3) | ||
129 | |||
130 | # draw the left part of the window | ||
131 | # a notebook | ||
132 | self.ins = gtk.Notebook() | ||
133 | self.ins.set_show_tabs(False) | ||
134 | self.tables = [] # we need modify table when the dialog is shown | 128 | self.tables = [] # we need modify table when the dialog is shown |
135 | # append the tabs in order | 129 | # append the tabs in order |
136 | for i in range(len(self.pages)): | 130 | for i in range(len(self.pages)): |
@@ -146,16 +140,13 @@ class RecipeSelectionPage (HobPage): | |||
146 | self.ins.append_page(tab, label) | 140 | self.ins.append_page(tab, label) |
147 | self.tables.append(tab) | 141 | self.tables.append(tab) |
148 | 142 | ||
149 | self.grid.attach(self.ins, 0, 1, 1, 10, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND) | 143 | self.ins.set_entry("Search recipes:") |
150 | # a black bar associated with the notebook | ||
151 | self.topbar = HobViewBar(self.ins) | ||
152 | self.grid.attach(self.topbar, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND) | ||
153 | # set the search entry for each table | 144 | # set the search entry for each table |
154 | for tab in self.tables: | 145 | for tab in self.tables: |
155 | tab.set_search_entry(0, self.topbar.search) | 146 | tab.set_search_entry(0, self.ins.search) |
156 | 147 | ||
157 | # add all into the window | 148 | # add all into the window |
158 | self.box_group_area.add(self.grid) | 149 | self.box_group_area.pack_start(self.ins, expand=True, fill=True) |
159 | 150 | ||
160 | button_box = gtk.HBox(False, 6) | 151 | button_box = gtk.HBox(False, 6) |
161 | self.box_group_area.pack_end(button_box, expand=False, fill=False) | 152 | self.box_group_area.pack_end(button_box, expand=False, fill=False) |