summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
diff options
context:
space:
mode:
authorDongxiao Xu <dongxiao.xu@intel.com>2011-11-28 14:32:40 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-02-24 18:04:27 +0000
commit656f9a07588cc00704825a78de9649ca4a1552b8 (patch)
tree653c7941689599994d5876162c540fb7ee22736e /bitbake/lib/bb/ui/crumbs/packageselectionpage.py
parent14df6d53b6856ec78322b9c0ef01e26c0406fe28 (diff)
downloadpoky-656f9a07588cc00704825a78de9649ca4a1552b8.tar.gz
Hob: A new implemetation (v2)
This commit implements a new design for hob Some of the new features: - Friendly new designed GUI. Quick response to user actions. - Two step builds support package generation and image generation. - Support running GUI seprarately from bitbake server. - Recipe/package selection and deselection. - Accurate customization for image contents and size. - Progress bars showing the parsing and build status. - Load/save user configurations from/into templates. (Bitbake rev: 4dacd29f9c957d20f4583330b51e5420f9c3338d) Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com> Signed-off-by: Shane Wang <shane.wang@intel.com> Signed-off-by: Liming An <limingx.l.an@intel.com> Signed-off-by: Fengxia Hua <fengxia.hua@intel.com> Designed-by: Belen Barros Pena <belen.barros.pena@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/packageselectionpage.py')
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/packageselectionpage.py226
1 files changed, 226 insertions, 0 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
new file mode 100755
index 0000000000..8a8ab7585e
--- /dev/null
+++ b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
@@ -0,0 +1,226 @@
1#!/usr/bin/env python
2#
3# BitBake Graphical GTK User Interface
4#
5# Copyright (C) 2012 Intel Corporation
6#
7# Authored by Dongxiao Xu <dongxiao.xu@intel.com>
8# Authored by Shane Wang <shane.wang@intel.com>
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License version 2 as
12# published by the Free Software Foundation.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License along
20# with this program; if not, write to the Free Software Foundation, Inc.,
21# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
23import gtk
24import glib
25from bb.ui.crumbs.hobcolor import HobColors
26from bb.ui.crumbs.hobwidget import HobViewBar, HobViewTable
27from bb.ui.crumbs.hoblistmodel import PackageListModel
28from bb.ui.crumbs.hobpages import HobPage
29
30#
31# PackageSelectionPage
32#
33class PackageSelectionPage (HobPage):
34
35 pages = [
36 {
37 'name' : 'All packages',
38 'filter' : {},
39 'columns' : [{
40 'col_name' : 'Name',
41 'col_id' : PackageListModel.COL_NAME,
42 'col_style': 'text',
43 'col_min' : 100,
44 'col_max' : 400
45 }, {
46 'col_name' : 'size',
47 'col_id' : PackageListModel.COL_SIZE,
48 'col_style': 'text',
49 'col_min' : 100,
50 'col_max' : 500
51 }, {
52 'col_name' : 'Included',
53 'col_id' : PackageListModel.COL_INC,
54 'col_style': 'toggle',
55 'col_min' : 50,
56 'col_max' : 50
57 }]
58 }, {
59 'name' : 'Included',
60 'filter' : { PackageListModel.COL_INC : [True] },
61 'columns' : [{
62 'col_name' : 'Name',
63 'col_id' : PackageListModel.COL_NAME,
64 'col_style': 'text',
65 'col_min' : 100,
66 'col_max' : 300
67 }, {
68 'col_name' : 'Brought by',
69 'col_id' : PackageListModel.COL_BINB,
70 'col_style': 'text',
71 'col_min' : 100,
72 'col_max' : 350
73 }, {
74 'col_name' : 'size',
75 'col_id' : PackageListModel.COL_SIZE,
76 'col_style': 'text',
77 'col_min' : 100,
78 'col_max' : 300
79 }, {
80 'col_name' : 'Included',
81 'col_id' : PackageListModel.COL_INC,
82 'col_style': 'toggle',
83 'col_min' : 50,
84 'col_max' : 50
85 }]
86 }
87 ]
88
89 def __init__(self, builder):
90 super(PackageSelectionPage, self).__init__(builder, "Package Selection")
91
92 # set invisiable members
93 self.package_model = self.builder.package_model
94
95 # create visual elements
96 self.create_visual_elements()
97
98 def create_visual_elements(self):
99 self.label = gtk.Label("Packages included: 0\nSelected packages size: 0 MB")
100 self.eventbox = self.add_onto_top_bar(self.label, 73)
101 self.pack_start(self.eventbox, expand=False, fill=False)
102 self.pack_start(self.group_align, expand=True, fill=True)
103
104 # set visiable members
105 self.grid = gtk.Table(10, 1, True)
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
111 # append the tab
112 for i in range(len(self.pages)):
113 columns = self.pages[i]['columns']
114 tab = HobViewTable(columns, self.reset_clicked_cb, self.table_toggled_cb)
115 filter = self.pages[i]['filter']
116 tab.table_tree.set_model(self.package_model.tree_model(filter))
117 label = gtk.Label(self.pages[i]['name'])
118 self.ins.append_page(tab, label)
119 self.tables.append(tab)
120
121 self.grid.attach(self.ins, 0, 1, 1, 10, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND, 1, 1)
122 # a black bar associated with the notebook
123 self.topbar = HobViewBar(self.ins)
124 self.grid.attach(self.topbar, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND, 1, 1)
125 # set the search entry for each table
126 for tab in self.tables:
127 tab.table_tree.set_search_entry(self.topbar.search)
128
129 inctab_tree_view = self.tables[len(self.pages)-1].table_tree
130 inctab_tree_selection = inctab_tree_view.get_selection()
131 inctab_tree_selection.connect("changed", self.tree_selection_cb, inctab_tree_view)
132
133 # add all into the dialog
134 self.box_group_area.add(self.grid)
135
136 button_box = gtk.HBox(False, 5)
137 self.box_group_area.pack_start(button_box, expand=False, fill=False)
138
139 self.build_image_button = gtk.Button()
140 label = gtk.Label()
141 mark = "<span %s>Build image</span>" % self.span_tag('24px', 'bold')
142 label.set_markup(mark)
143 self.build_image_button.set_image(label)
144 self.build_image_button.set_size_request(205, 49)
145 self.build_image_button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(HobColors.ORANGE))
146 self.build_image_button.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(HobColors.ORANGE))
147 self.build_image_button.modify_bg(gtk.STATE_SELECTED, gtk.gdk.Color(HobColors.ORANGE))
148 self.build_image_button.set_tooltip_text("Build image to get your target image")
149 self.build_image_button.set_flags(gtk.CAN_DEFAULT)
150 self.build_image_button.grab_default()
151 self.build_image_button.connect("clicked", self.build_image_clicked_cb)
152 button_box.pack_end(self.build_image_button, expand=False, fill=False)
153
154 self.back_button = gtk.LinkButton("Go back to Image Configuration screen", "<< Back to image configuration")
155 self.back_button.connect("clicked", self.back_button_clicked_cb)
156 button_box.pack_start(self.back_button, expand=False, fill=False)
157
158 def tree_selection_cb(self, tree_selection, tree_view):
159 tree_model = tree_view.get_model()
160 path, column = tree_view.get_cursor()
161 if not path or column == tree_view.get_column(2):
162 return
163
164 it = tree_model.get_iter(path)
165 binb = tree_model.get_value(it, PackageListModel.COL_BINB)
166 if binb:
167 self.builder.show_binb_dialog(binb)
168
169 def build_image_clicked_cb(self, button):
170 self.builder.build_image()
171
172 def back_button_clicked_cb(self, button):
173 self.builder.show_configuration()
174
175 def _expand_all(self):
176 for tab in self.tables:
177 tab.table_tree.expand_all()
178
179 def refresh_selection(self):
180 self._expand_all()
181
182 self.builder.configuration.selected_packages = self.package_model.get_selected_packages()
183 selected_packages_num = len(self.builder.configuration.selected_packages)
184 selected_packages_size = float(self.package_model.get_packages_size())
185 selected_packages_size_str = self._size_to_string(selected_packages_size)
186
187 image_overhead_factor = self.builder.configuration.image_overhead_factor
188 image_rootfs_size = self.builder.configuration.image_rootfs_size
189 image_extra_size = self.builder.configuration.image_extra_size
190 base_size = image_overhead_factor * selected_packages_size
191 image_total_size = max(base_size, image_rootfs_size) + image_extra_size
192 image_total_size_str = self._size_to_string(image_total_size)
193
194 self.label.set_text("Packages included: %s\nSelected packages size: %s\nTotal image size: %s" %
195 (selected_packages_num, selected_packages_size_str, image_total_size_str))
196
197 """
198 Helper function to convert the package size to string format.
199 The unit of size is KB
200 """
201 def _size_to_string(self, size):
202 if len(str(int(size))) > 3:
203 size_str = '%.1f' % (size*1.0/1024) + ' MB'
204 else:
205 size_str = str(size) + ' KB'
206 return size_str
207
208 # Callback functions
209 def reset_clicked_cb(self, button):
210 self.package_model.reset()
211 self.builder.reset_package_model()
212
213 def toggle_item_idle_cb(self, path):
214 if not self.package_model.path_included(path):
215 self.package_model.include_item(item_path=path, binb="User Selected")
216 else:
217 self.package_model.exclude_item(item_path=path)
218
219 self.builder.window_sensitive(True)
220
221 def table_toggled_cb(self, cell, view_path, view_tree):
222 # Click to include a package
223 self.builder.window_sensitive(False)
224 view_model = view_tree.get_model()
225 path = self.package_model.convert_vpath_to_path(view_model, view_path)
226 glib.idle_add(self.toggle_item_idle_cb, path)