summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/recipeselectionpage.py')
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/recipeselectionpage.py221
1 files changed, 221 insertions, 0 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
new file mode 100755
index 0000000000..73b8a1e4ef
--- /dev/null
+++ b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
@@ -0,0 +1,221 @@
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 HobWidget, HobViewBar, HobViewTable
27from bb.ui.crumbs.hoblistmodel import RecipeListModel
28from bb.ui.crumbs.hobpages import HobPage
29
30#
31# RecipeSelectionPage
32#
33class RecipeSelectionPage (HobPage):
34 pages = [
35 {
36 'name' : 'Recipe',
37 'filter' : { RecipeListModel.COL_TYPE : ['recipe'] },
38 'columns' : [{
39 'col_name' : 'Recipe',
40 'col_id' : RecipeListModel.COL_NAME,
41 'col_style': 'text',
42 'col_min' : 100,
43 'col_max' : 400
44 }, {
45 'col_name' : 'License',
46 'col_id' : RecipeListModel.COL_LIC,
47 'col_style': 'text',
48 'col_min' : 100,
49 'col_max' : 400
50 }, {
51 'col_name' : 'Group',
52 'col_id' : RecipeListModel.COL_GROUP,
53 'col_style': 'text',
54 'col_min' : 100,
55 'col_max' : 400
56 }, {
57 'col_name' : 'Included',
58 'col_id' : RecipeListModel.COL_INC,
59 'col_style': 'toggle',
60 'col_min' : 50,
61 'col_max' : 50
62 }]
63 }, {
64 'name' : 'Recipe Collection',
65 'filter' : { RecipeListModel.COL_TYPE : ['task'] },
66 'columns' : [{
67 'col_name' : 'Recipe Collection',
68 'col_id' : RecipeListModel.COL_NAME,
69 'col_style': 'text',
70 'col_min' : 100,
71 'col_max' : 400
72 }, {
73 'col_name' : 'Description',
74 'col_id' : RecipeListModel.COL_DESC,
75 'col_style': 'text',
76 'col_min' : 100,
77 'col_max' : 400
78 }, {
79 'col_name' : 'Included',
80 'col_id' : RecipeListModel.COL_INC,
81 'col_style': 'toggle',
82 'col_min' : 50,
83 'col_max' : 50
84 }]
85 }, {
86 'name' : 'Included',
87 'filter' : { RecipeListModel.COL_INC : [True],
88 RecipeListModel.COL_TYPE : ['recipe', 'task'] },
89 'columns' : [{
90 'col_name' : 'Recipe',
91 'col_id' : RecipeListModel.COL_NAME,
92 'col_style': 'text',
93 'col_min' : 100,
94 'col_max' : 400
95 }, {
96 'col_name' : 'Brought by',
97 'col_id' : RecipeListModel.COL_BINB,
98 'col_style': 'text',
99 'col_min' : 100,
100 'col_max' : 500
101 }, {
102 'col_name' : 'Included',
103 'col_id' : RecipeListModel.COL_INC,
104 'col_style': 'toggle',
105 'col_min' : 50,
106 'col_max' : 50
107 }]
108 }
109 ]
110
111 def __init__(self, builder = None):
112 super(RecipeSelectionPage, self).__init__(builder, "Recipe Selection")
113
114 # set invisiable members
115 self.recipe_model = self.builder.recipe_model
116
117 # create visual elements
118 self.create_visual_elements()
119
120 def create_visual_elements(self):
121 self.label = gtk.Label("Recipes included: %s" % len(self.builder.configuration.selected_recipes))
122 self.eventbox = self.add_onto_top_bar(self.label, 73)
123 self.pack_start(self.eventbox, expand=False, fill=False)
124 self.pack_start(self.group_align, expand=True, fill=True)
125
126 # set visiable members
127 self.grid = gtk.Table(10, 1, True)
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
135 # append the tabs in order
136 for i in range(len(self.pages)):
137 columns = self.pages[i]['columns']
138 tab = HobViewTable(columns, self.reset_clicked_cb, self.table_toggled_cb)
139 filter = self.pages[i]['filter']
140 tab.table_tree.set_model(self.recipe_model.tree_model(filter))
141 label = gtk.Label(self.pages[i]['name'])
142 self.ins.append_page(tab, label)
143 self.tables.append(tab)
144
145 self.grid.attach(self.ins, 0, 1, 1, 10, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND)
146 # a black bar associated with the notebook
147 self.topbar = HobViewBar(self.ins)
148 self.grid.attach(self.topbar, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND)
149 # set the search entry for each table
150 for tab in self.tables:
151 tab.table_tree.set_search_entry(self.topbar.search)
152
153 inctab_tree_view = self.tables[len(self.pages)-1].table_tree
154 inctab_tree_selection = inctab_tree_view.get_selection()
155 inctab_tree_selection.connect("changed", self.tree_selection_cb, inctab_tree_view)
156
157 # add all into the window
158 self.box_group_area.add(self.grid)
159
160 button_box = gtk.HBox(False, 5)
161 self.box_group_area.pack_end(button_box, expand=False, fill=False)
162
163 self.build_packages_button = gtk.Button()
164 label = gtk.Label()
165 mark = "<span %s>Build packages</span>" % self.span_tag('24px', 'bold')
166 label.set_markup(mark)
167 self.build_packages_button.set_image(label)
168 self.build_packages_button.set_size_request(205, 49)
169 self.build_packages_button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(HobColors.ORANGE))
170 self.build_packages_button.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(HobColors.ORANGE))
171 self.build_packages_button.modify_bg(gtk.STATE_SELECTED, gtk.gdk.Color(HobColors.ORANGE))
172 self.build_packages_button.set_tooltip_text("Build packages for customization")
173 self.build_packages_button.set_flags(gtk.CAN_DEFAULT)
174 self.build_packages_button.grab_default()
175 self.build_packages_button.connect("clicked", self.build_packages_clicked_cb)
176 button_box.pack_end(self.build_packages_button, expand=False, fill=False)
177
178 self.back_button = gtk.LinkButton("Go back to Image Configuration screen", "<< Back to image configuration")
179 self.back_button.connect("clicked", self.back_button_clicked_cb)
180 button_box.pack_start(self.back_button, expand=False, fill=False)
181
182 def tree_selection_cb(self, tree_selection, tree_view):
183 tree_model = tree_view.get_model()
184 path, column = tree_view.get_cursor()
185 if not path or column == tree_view.get_column(2):
186 return
187
188 it = tree_model.get_iter(path)
189 binb = tree_model.get_value(it, RecipeListModel.COL_BINB)
190 if binb:
191 self.builder.show_binb_dialog(binb)
192
193 def build_packages_clicked_cb(self, button):
194 self.builder.build_packages()
195
196 def back_button_clicked_cb(self, button):
197 self.builder.show_configuration()
198
199 def refresh_selection(self):
200 self.builder.configuration.selected_image = self.recipe_model.get_selected_image()
201 _, self.builder.configuration.selected_recipes = self.recipe_model.get_selected_recipes()
202 self.label.set_text("Recipes included: %s" % len(self.builder.configuration.selected_recipes))
203
204 # Callback functions
205 def reset_clicked_cb(self, button):
206 self.builder.reset_recipe_model()
207
208 def toggle_item_idle_cb(self, path):
209 if not self.recipe_model.path_included(path):
210 self.recipe_model.include_item(item_path=path, binb="User Selected", image_contents=False)
211 else:
212 self.recipe_model.exclude_item(item_path=path)
213
214 self.builder.window_sensitive(True)
215
216 def table_toggled_cb(self, cell, view_path, view_tree):
217 # Click to include a recipe
218 self.builder.window_sensitive(False)
219 view_model = view_tree.get_model()
220 path = self.recipe_model.convert_vpath_to_path(view_model, view_path)
221 glib.idle_add(self.toggle_item_idle_cb, path)