diff options
author | Liming An <limingx.l.an@intel.com> | 2012-05-08 19:48:07 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-05-09 21:56:46 +0100 |
commit | 71b277acb12353eac21fddc2531c8bac886b058b (patch) | |
tree | 8e10221eb4eccec6711718785483f2527469daee /bitbake/lib/bb/ui | |
parent | a75562aa8b62247d09c52c92a620b947d19bbb95 (diff) | |
download | poky-71b277acb12353eac21fddc2531c8bac886b058b.tar.gz |
Hob: add group number show and 'bold' visible effect for Package view
as ui design, add number of packages for each group, and make the
text font to 'bold' when row be selected
[YOCTO #2195]
(Bitbake rev: 5812176a679a39a4d096134c871c3d24a7e505ea)
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/hoblistmodel.py | 7 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hobwidget.py | 39 | ||||
-rwxr-xr-x | bitbake/lib/bb/ui/crumbs/packageselectionpage.py | 26 |
3 files changed, 65 insertions, 7 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hoblistmodel.py b/bitbake/lib/bb/ui/crumbs/hoblistmodel.py index 3f534328ae..0b54f91a12 100644 --- a/bitbake/lib/bb/ui/crumbs/hoblistmodel.py +++ b/bitbake/lib/bb/ui/crumbs/hoblistmodel.py | |||
@@ -34,7 +34,7 @@ class PackageListModel(gtk.TreeStore): | |||
34 | providing convenience functions to access gtk.TreeModel subclasses which | 34 | providing convenience functions to access gtk.TreeModel subclasses which |
35 | provide filtered views of the data. | 35 | provide filtered views of the data. |
36 | """ | 36 | """ |
37 | (COL_NAME, COL_VER, COL_REV, COL_RNM, COL_SEC, COL_SUM, COL_RDEP, COL_RPROV, COL_SIZE, COL_BINB, COL_INC, COL_FADE_INC) = range(12) | 37 | (COL_NAME, COL_VER, COL_REV, COL_RNM, COL_SEC, COL_SUM, COL_RDEP, COL_RPROV, COL_SIZE, COL_BINB, COL_INC, COL_FADE_INC, COL_FONT) = range(13) |
38 | 38 | ||
39 | __gsignals__ = { | 39 | __gsignals__ = { |
40 | "package-selection-changed" : (gobject.SIGNAL_RUN_LAST, | 40 | "package-selection-changed" : (gobject.SIGNAL_RUN_LAST, |
@@ -65,7 +65,8 @@ class PackageListModel(gtk.TreeStore): | |||
65 | gobject.TYPE_STRING, | 65 | gobject.TYPE_STRING, |
66 | gobject.TYPE_STRING, | 66 | gobject.TYPE_STRING, |
67 | gobject.TYPE_BOOLEAN, | 67 | gobject.TYPE_BOOLEAN, |
68 | gobject.TYPE_BOOLEAN) | 68 | gobject.TYPE_BOOLEAN, |
69 | gobject.TYPE_STRING) | ||
69 | 70 | ||
70 | 71 | ||
71 | """ | 72 | """ |
@@ -189,7 +190,7 @@ class PackageListModel(gtk.TreeStore): | |||
189 | self.COL_SEC, section, self.COL_SUM, summary, | 190 | self.COL_SEC, section, self.COL_SUM, summary, |
190 | self.COL_RDEP, rdep + ' ' + rrec, | 191 | self.COL_RDEP, rdep + ' ' + rrec, |
191 | self.COL_RPROV, rprov, self.COL_SIZE, size, | 192 | self.COL_RPROV, rprov, self.COL_SIZE, size, |
192 | self.COL_BINB, "", self.COL_INC, False) | 193 | self.COL_BINB, "", self.COL_INC, False, self.COL_FONT, '10') |
193 | 194 | ||
194 | """ | 195 | """ |
195 | Check whether the item at item_path is included or not | 196 | Check whether the item at item_path is included or not |
diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py index 6cf73b0747..39428270a8 100644 --- a/bitbake/lib/bb/ui/crumbs/hobwidget.py +++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py | |||
@@ -119,6 +119,7 @@ class HobViewTable (gtk.VBox): | |||
119 | self.table_tree.set_headers_clickable(True) | 119 | self.table_tree.set_headers_clickable(True) |
120 | self.table_tree.set_enable_search(True) | 120 | self.table_tree.set_enable_search(True) |
121 | self.table_tree.set_rules_hint(True) | 121 | self.table_tree.set_rules_hint(True) |
122 | self.table_tree.set_enable_tree_lines(True) | ||
122 | self.table_tree.get_selection().set_mode(gtk.SELECTION_SINGLE) | 123 | self.table_tree.get_selection().set_mode(gtk.SELECTION_SINGLE) |
123 | self.toggle_columns = [] | 124 | self.toggle_columns = [] |
124 | self.table_tree.connect("row-activated", self.row_activated_cb) | 125 | self.table_tree.connect("row-activated", self.row_activated_cb) |
@@ -140,6 +141,8 @@ class HobViewTable (gtk.VBox): | |||
140 | cell = gtk.CellRendererText() | 141 | cell = gtk.CellRendererText() |
141 | col.pack_start(cell, True) | 142 | col.pack_start(cell, True) |
142 | col.set_attributes(cell, text=column['col_id']) | 143 | col.set_attributes(cell, text=column['col_id']) |
144 | if 'col_t_id' in column.keys(): | ||
145 | col.add_attribute(cell, 'font', column['col_t_id']) | ||
143 | elif column['col_style'] == 'check toggle': | 146 | elif column['col_style'] == 'check toggle': |
144 | cell = HobCellRendererToggle() | 147 | cell = HobCellRendererToggle() |
145 | cell.set_property('activatable', True) | 148 | cell.set_property('activatable', True) |
@@ -149,6 +152,8 @@ class HobViewTable (gtk.VBox): | |||
149 | col.pack_end(cell, True) | 152 | col.pack_end(cell, True) |
150 | col.set_attributes(cell, active=column['col_id']) | 153 | col.set_attributes(cell, active=column['col_id']) |
151 | self.toggle_columns.append(column['col_name']) | 154 | self.toggle_columns.append(column['col_name']) |
155 | if 'col_group' in column.keys(): | ||
156 | col.set_cell_data_func(cell, self.set_group_number_cb) | ||
152 | elif column['col_style'] == 'radio toggle': | 157 | elif column['col_style'] == 'radio toggle': |
153 | cell = gtk.CellRendererToggle() | 158 | cell = gtk.CellRendererToggle() |
154 | cell.set_property('activatable', True) | 159 | cell.set_property('activatable', True) |
@@ -162,6 +167,8 @@ class HobViewTable (gtk.VBox): | |||
162 | cell = gtk.CellRendererText() | 167 | cell = gtk.CellRendererText() |
163 | col.pack_start(cell, True) | 168 | col.pack_start(cell, True) |
164 | col.set_cell_data_func(cell, self.display_binb_cb, column['col_id']) | 169 | col.set_cell_data_func(cell, self.display_binb_cb, column['col_id']) |
170 | if 'col_t_id' in column.keys(): | ||
171 | col.add_attribute(cell, 'font', column['col_t_id']) | ||
165 | 172 | ||
166 | scroll = gtk.ScrolledWindow() | 173 | scroll = gtk.ScrolledWindow() |
167 | scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) | 174 | scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) |
@@ -204,6 +211,15 @@ class HobViewTable (gtk.VBox): | |||
204 | def stop_cell_fadeinout_cb(self, ctrl, cell, tree): | 211 | def stop_cell_fadeinout_cb(self, ctrl, cell, tree): |
205 | self.emit("cell-fadeinout-stopped", ctrl, cell, tree) | 212 | self.emit("cell-fadeinout-stopped", ctrl, cell, tree) |
206 | 213 | ||
214 | def set_group_number_cb(self, col, cell, model, iter): | ||
215 | if model and (model.iter_parent(iter) == None): | ||
216 | cell.cell_attr["number_of_children"] = model.iter_n_children(iter) | ||
217 | else: | ||
218 | cell.cell_attr["number_of_children"] = 0 | ||
219 | |||
220 | def connect_group_selection(self, cb_func): | ||
221 | self.table_tree.get_selection().connect("changed", cb_func) | ||
222 | |||
207 | """ | 223 | """ |
208 | A method to calculate a softened value for the colour of widget when in the | 224 | A method to calculate a softened value for the colour of widget when in the |
209 | provided state. | 225 | provided state. |
@@ -1084,11 +1100,17 @@ class HobCellRendererToggle(gtk.CellRendererToggle): | |||
1084 | gtk.CellRendererToggle.__init__(self) | 1100 | gtk.CellRendererToggle.__init__(self) |
1085 | self.ctrl = HobCellRendererController(is_draw_row=True) | 1101 | self.ctrl = HobCellRendererController(is_draw_row=True) |
1086 | self.ctrl.running_mode = self.ctrl.MODE_ONE_SHORT | 1102 | self.ctrl.running_mode = self.ctrl.MODE_ONE_SHORT |
1087 | self.cell_attr = {"fadeout": False} | 1103 | self.cell_attr = {"fadeout": False, "number_of_children": 0} |
1088 | 1104 | ||
1089 | def do_render(self, window, widget, background_area, cell_area, expose_area, flags): | 1105 | def do_render(self, window, widget, background_area, cell_area, expose_area, flags): |
1090 | if (not self.ctrl) or (not widget): | 1106 | if (not self.ctrl) or (not widget): |
1091 | return | 1107 | return |
1108 | |||
1109 | if flags & gtk.CELL_RENDERER_SELECTED: | ||
1110 | state = gtk.STATE_SELECTED | ||
1111 | else: | ||
1112 | state = gtk.STATE_NORMAL | ||
1113 | |||
1092 | if self.ctrl.is_active(): | 1114 | if self.ctrl.is_active(): |
1093 | path = widget.get_path_at_pos(cell_area.x + cell_area.width/2, cell_area.y + cell_area.height/2) | 1115 | path = widget.get_path_at_pos(cell_area.x + cell_area.width/2, cell_area.y + cell_area.height/2) |
1094 | # sometimes the parameters of cell_area will be a negative number,such as pull up down the scroll bar | 1116 | # sometimes the parameters of cell_area will be a negative number,such as pull up down the scroll bar |
@@ -1097,14 +1119,23 @@ class HobCellRendererToggle(gtk.CellRendererToggle): | |||
1097 | path = path[0] | 1119 | path = path[0] |
1098 | if path in self.ctrl.running_cell_areas: | 1120 | if path in self.ctrl.running_cell_areas: |
1099 | cr = window.cairo_create() | 1121 | cr = window.cairo_create() |
1100 | color = gtk.gdk.Color(HobColors.WHITE) | 1122 | color = widget.get_style().base[state] |
1101 | 1123 | ||
1102 | row_x, _, row_width, _ = widget.get_visible_rect() | 1124 | row_x, _, row_width, _ = widget.get_visible_rect() |
1103 | border_y = self.get_property("ypad") | 1125 | border_y = self.get_property("ypad") |
1104 | self.ctrl.on_draw_fadeinout_cb(cr, color, row_x, cell_area.y - border_y, row_width, \ | 1126 | self.ctrl.on_draw_fadeinout_cb(cr, color, row_x, cell_area.y - border_y, row_width, \ |
1105 | cell_area.height + border_y * 2, self.cell_attr["fadeout"]) | 1127 | cell_area.height + border_y * 2, self.cell_attr["fadeout"]) |
1106 | 1128 | # draw number of a group | |
1107 | return gtk.CellRendererToggle.do_render(self, window, widget, background_area, cell_area, expose_area, flags) | 1129 | if self.cell_attr["number_of_children"]: |
1130 | text = "%d pkg" % self.cell_attr["number_of_children"] | ||
1131 | pangolayout = widget.create_pango_layout(text) | ||
1132 | textw, texth = pangolayout.get_pixel_size() | ||
1133 | x = cell_area.x + (cell_area.width/2) - (textw/2) | ||
1134 | y = cell_area.y + (cell_area.height/2) - (texth/2) | ||
1135 | |||
1136 | widget.style.paint_layout(window, state, True, cell_area, widget, "checkbox", x, y, pangolayout) | ||
1137 | else: | ||
1138 | return gtk.CellRendererToggle.do_render(self, window, widget, background_area, cell_area, expose_area, flags) | ||
1108 | 1139 | ||
1109 | '''delay: normally delay time is 1000ms | 1140 | '''delay: normally delay time is 1000ms |
1110 | cell_list: whilch cells need to be render | 1141 | cell_list: whilch cells need to be render |
diff --git a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py index 104d49d108..238e2f9771 100755 --- a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py +++ b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py | |||
@@ -39,6 +39,7 @@ class PackageSelectionPage (HobPage): | |||
39 | 'columns' : [{ | 39 | 'columns' : [{ |
40 | 'col_name' : 'Package name', | 40 | 'col_name' : 'Package name', |
41 | 'col_id' : PackageListModel.COL_NAME, | 41 | 'col_id' : PackageListModel.COL_NAME, |
42 | 'col_t_id' : PackageListModel.COL_FONT, | ||
42 | 'col_style': 'text', | 43 | 'col_style': 'text', |
43 | 'col_min' : 100, | 44 | 'col_min' : 100, |
44 | 'col_max' : 300, | 45 | 'col_max' : 300, |
@@ -46,6 +47,7 @@ class PackageSelectionPage (HobPage): | |||
46 | }, { | 47 | }, { |
47 | 'col_name' : 'Brought in by', | 48 | 'col_name' : 'Brought in by', |
48 | 'col_id' : PackageListModel.COL_BINB, | 49 | 'col_id' : PackageListModel.COL_BINB, |
50 | 'col_t_id' : PackageListModel.COL_FONT, | ||
49 | 'col_style': 'binb', | 51 | 'col_style': 'binb', |
50 | 'col_min' : 100, | 52 | 'col_min' : 100, |
51 | 'col_max' : 350, | 53 | 'col_max' : 350, |
@@ -53,6 +55,7 @@ class PackageSelectionPage (HobPage): | |||
53 | }, { | 55 | }, { |
54 | 'col_name' : 'Size', | 56 | 'col_name' : 'Size', |
55 | 'col_id' : PackageListModel.COL_SIZE, | 57 | 'col_id' : PackageListModel.COL_SIZE, |
58 | 'col_t_id' : PackageListModel.COL_FONT, | ||
56 | 'col_style': 'text', | 59 | 'col_style': 'text', |
57 | 'col_min' : 100, | 60 | 'col_min' : 100, |
58 | 'col_max' : 300, | 61 | 'col_max' : 300, |
@@ -60,7 +63,9 @@ class PackageSelectionPage (HobPage): | |||
60 | }, { | 63 | }, { |
61 | 'col_name' : 'Included', | 64 | 'col_name' : 'Included', |
62 | 'col_id' : PackageListModel.COL_INC, | 65 | 'col_id' : PackageListModel.COL_INC, |
66 | 'col_t_id' : PackageListModel.COL_FONT, | ||
63 | 'col_style': 'check toggle', | 67 | 'col_style': 'check toggle', |
68 | 'col_group': 'tree store group', | ||
64 | 'col_min' : 100, | 69 | 'col_min' : 100, |
65 | 'col_max' : 100 | 70 | 'col_max' : 100 |
66 | }] | 71 | }] |
@@ -70,6 +75,7 @@ class PackageSelectionPage (HobPage): | |||
70 | 'columns' : [{ | 75 | 'columns' : [{ |
71 | 'col_name' : 'Package name', | 76 | 'col_name' : 'Package name', |
72 | 'col_id' : PackageListModel.COL_NAME, | 77 | 'col_id' : PackageListModel.COL_NAME, |
78 | 'col_t_id' : PackageListModel.COL_FONT, | ||
73 | 'col_style': 'text', | 79 | 'col_style': 'text', |
74 | 'col_min' : 100, | 80 | 'col_min' : 100, |
75 | 'col_max' : 400, | 81 | 'col_max' : 400, |
@@ -77,6 +83,7 @@ class PackageSelectionPage (HobPage): | |||
77 | }, { | 83 | }, { |
78 | 'col_name' : 'Size', | 84 | 'col_name' : 'Size', |
79 | 'col_id' : PackageListModel.COL_SIZE, | 85 | 'col_id' : PackageListModel.COL_SIZE, |
86 | 'col_t_id' : PackageListModel.COL_FONT, | ||
80 | 'col_style': 'text', | 87 | 'col_style': 'text', |
81 | 'col_min' : 100, | 88 | 'col_min' : 100, |
82 | 'col_max' : 500, | 89 | 'col_max' : 500, |
@@ -85,6 +92,7 @@ class PackageSelectionPage (HobPage): | |||
85 | 'col_name' : 'Included', | 92 | 'col_name' : 'Included', |
86 | 'col_id' : PackageListModel.COL_INC, | 93 | 'col_id' : PackageListModel.COL_INC, |
87 | 'col_style': 'check toggle', | 94 | 'col_style': 'check toggle', |
95 | 'col_group': 'tree store group', | ||
88 | 'col_min' : 100, | 96 | 'col_min' : 100, |
89 | 'col_max' : 100 | 97 | 'col_max' : 100 |
90 | }] | 98 | }] |
@@ -117,6 +125,7 @@ class PackageSelectionPage (HobPage): | |||
117 | filter = page['filter'] | 125 | filter = page['filter'] |
118 | tab.set_model(self.package_model.tree_model(filter)) | 126 | tab.set_model(self.package_model.tree_model(filter)) |
119 | tab.connect("toggled", self.table_toggled_cb, page['name']) | 127 | tab.connect("toggled", self.table_toggled_cb, page['name']) |
128 | tab.connect_group_selection(self.table_selected_cb) | ||
120 | if page['name'] == "Included": | 129 | if page['name'] == "Included": |
121 | tab.connect("button-release-event", self.button_click_cb) | 130 | tab.connect("button-release-event", self.button_click_cb) |
122 | tab.connect("cell-fadeinout-stopped", self.after_fadeout_checkin_include) | 131 | tab.connect("cell-fadeinout-stopped", self.after_fadeout_checkin_include) |
@@ -247,3 +256,20 @@ class PackageSelectionPage (HobPage): | |||
247 | def after_fadeout_checkin_include(self, table, ctrl, cell, tree): | 256 | def after_fadeout_checkin_include(self, table, ctrl, cell, tree): |
248 | tree.set_model(self.package_model.tree_model(self.pages[0]['filter'])) | 257 | tree.set_model(self.package_model.tree_model(self.pages[0]['filter'])) |
249 | tree.expand_all() | 258 | tree.expand_all() |
259 | |||
260 | def foreach_cell_change_font(self, model, path, iter, paths=None): | ||
261 | # Changed the font for a group cells | ||
262 | if path and iter and path[0] == paths[0]: | ||
263 | self.package_model.set(iter, self.package_model.COL_FONT, "bold") | ||
264 | else: | ||
265 | if iter and model.iter_parent(iter) == None: | ||
266 | self.package_model.set(iter, self.package_model.COL_FONT, '11') | ||
267 | else: | ||
268 | self.package_model.set(iter, self.package_model.COL_FONT, '10') | ||
269 | |||
270 | def table_selected_cb(self, selection): | ||
271 | model, paths = selection.get_selected_rows() | ||
272 | if paths: | ||
273 | child_path = self.package_model.convert_vpath_to_path(model, paths[0]) | ||
274 | self.package_model.foreach(self.foreach_cell_change_font, child_path) | ||
275 | |||