2011-11-28 06:32:40 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# BitBake Graphical GTK User Interface
|
|
|
|
#
|
|
|
|
# Copyright (C) 2012 Intel Corporation
|
|
|
|
#
|
|
|
|
# Authored by Dongxiao Xu <dongxiao.xu@intel.com>
|
|
|
|
# Authored by Shane Wang <shane.wang@intel.com>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
import gtk
|
|
|
|
import glib
|
|
|
|
from bb.ui.crumbs.hobcolor import HobColors
|
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>
2012-02-27 05:28:26 +00:00
|
|
|
from bb.ui.crumbs.hobwidget import HobViewTable, HobNotebook
|
2011-11-28 06:32:40 +00:00
|
|
|
from bb.ui.crumbs.hoblistmodel import PackageListModel
|
|
|
|
from bb.ui.crumbs.hobpages import HobPage
|
|
|
|
|
|
|
|
#
|
|
|
|
# PackageSelectionPage
|
|
|
|
#
|
|
|
|
class PackageSelectionPage (HobPage):
|
|
|
|
|
|
|
|
pages = [
|
|
|
|
{
|
|
|
|
'name' : 'All packages',
|
|
|
|
'filter' : {},
|
|
|
|
'columns' : [{
|
|
|
|
'col_name' : 'Name',
|
|
|
|
'col_id' : PackageListModel.COL_NAME,
|
|
|
|
'col_style': 'text',
|
|
|
|
'col_min' : 100,
|
|
|
|
'col_max' : 400
|
|
|
|
}, {
|
|
|
|
'col_name' : 'size',
|
|
|
|
'col_id' : PackageListModel.COL_SIZE,
|
|
|
|
'col_style': 'text',
|
|
|
|
'col_min' : 100,
|
|
|
|
'col_max' : 500
|
|
|
|
}, {
|
|
|
|
'col_name' : 'Included',
|
|
|
|
'col_id' : PackageListModel.COL_INC,
|
2012-02-29 14:14:58 +00:00
|
|
|
'col_style': 'check toggle',
|
2011-11-28 06:32:40 +00:00
|
|
|
'col_min' : 50,
|
|
|
|
'col_max' : 50
|
|
|
|
}]
|
|
|
|
}, {
|
|
|
|
'name' : 'Included',
|
|
|
|
'filter' : { PackageListModel.COL_INC : [True] },
|
|
|
|
'columns' : [{
|
|
|
|
'col_name' : 'Name',
|
|
|
|
'col_id' : PackageListModel.COL_NAME,
|
|
|
|
'col_style': 'text',
|
|
|
|
'col_min' : 100,
|
|
|
|
'col_max' : 300
|
|
|
|
}, {
|
|
|
|
'col_name' : 'Brought by',
|
|
|
|
'col_id' : PackageListModel.COL_BINB,
|
|
|
|
'col_style': 'text',
|
|
|
|
'col_min' : 100,
|
|
|
|
'col_max' : 350
|
|
|
|
}, {
|
|
|
|
'col_name' : 'size',
|
|
|
|
'col_id' : PackageListModel.COL_SIZE,
|
|
|
|
'col_style': 'text',
|
|
|
|
'col_min' : 100,
|
|
|
|
'col_max' : 300
|
|
|
|
}, {
|
|
|
|
'col_name' : 'Included',
|
|
|
|
'col_id' : PackageListModel.COL_INC,
|
2012-02-29 14:14:58 +00:00
|
|
|
'col_style': 'check toggle',
|
2011-11-28 06:32:40 +00:00
|
|
|
'col_min' : 50,
|
|
|
|
'col_max' : 50
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self, builder):
|
|
|
|
super(PackageSelectionPage, self).__init__(builder, "Package Selection")
|
|
|
|
|
|
|
|
# set invisiable members
|
|
|
|
self.package_model = self.builder.package_model
|
|
|
|
|
|
|
|
# create visual elements
|
|
|
|
self.create_visual_elements()
|
|
|
|
|
|
|
|
def create_visual_elements(self):
|
|
|
|
self.label = gtk.Label("Packages included: 0\nSelected packages size: 0 MB")
|
|
|
|
self.eventbox = self.add_onto_top_bar(self.label, 73)
|
|
|
|
self.pack_start(self.eventbox, expand=False, fill=False)
|
|
|
|
self.pack_start(self.group_align, expand=True, fill=True)
|
|
|
|
|
|
|
|
# set visiable members
|
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>
2012-02-27 05:28:26 +00:00
|
|
|
self.ins = HobNotebook()
|
2011-11-28 06:32:40 +00:00
|
|
|
self.tables = [] # we need to modify table when the dialog is shown
|
|
|
|
# append the tab
|
2012-03-16 05:40:41 +00:00
|
|
|
for page in self.pages:
|
|
|
|
columns = page['columns']
|
2012-02-29 14:14:58 +00:00
|
|
|
tab = HobViewTable(columns)
|
2012-03-16 05:40:41 +00:00
|
|
|
filter = page['filter']
|
2012-02-29 14:14:58 +00:00
|
|
|
tab.set_model(self.package_model.tree_model(filter))
|
|
|
|
tab.connect("toggled", self.table_toggled_cb)
|
2012-03-16 05:40:41 +00:00
|
|
|
if page['name'] == "Included":
|
2012-02-29 14:15:01 +00:00
|
|
|
tab.connect("row-activated", self.tree_row_activated_cb)
|
2012-02-29 14:14:58 +00:00
|
|
|
|
2012-03-16 05:40:41 +00:00
|
|
|
label = gtk.Label(page['name'])
|
2011-11-28 06:32:40 +00:00
|
|
|
self.ins.append_page(tab, label)
|
|
|
|
self.tables.append(tab)
|
|
|
|
|
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>
2012-02-27 05:28:26 +00:00
|
|
|
self.ins.set_entry("Search packages:")
|
2011-11-28 06:32:40 +00:00
|
|
|
# set the search entry for each table
|
|
|
|
for tab in self.tables:
|
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>
2012-02-27 05:28:26 +00:00
|
|
|
tab.set_search_entry(0, self.ins.search)
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
# add all into the dialog
|
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>
2012-02-27 05:28:26 +00:00
|
|
|
self.box_group_area.pack_start(self.ins, expand=True, fill=True)
|
2011-11-28 06:32:40 +00:00
|
|
|
|
2012-03-15 06:56:45 +00:00
|
|
|
button_box = gtk.HBox(False, 6)
|
2011-11-28 06:32:40 +00:00
|
|
|
self.box_group_area.pack_start(button_box, expand=False, fill=False)
|
|
|
|
|
|
|
|
self.build_image_button = gtk.Button()
|
|
|
|
label = gtk.Label()
|
|
|
|
mark = "<span %s>Build image</span>" % self.span_tag('24px', 'bold')
|
|
|
|
label.set_markup(mark)
|
|
|
|
self.build_image_button.set_image(label)
|
|
|
|
self.build_image_button.set_size_request(205, 49)
|
|
|
|
self.build_image_button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(HobColors.ORANGE))
|
|
|
|
self.build_image_button.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(HobColors.ORANGE))
|
|
|
|
self.build_image_button.modify_bg(gtk.STATE_SELECTED, gtk.gdk.Color(HobColors.ORANGE))
|
|
|
|
self.build_image_button.set_tooltip_text("Build image to get your target image")
|
|
|
|
self.build_image_button.set_flags(gtk.CAN_DEFAULT)
|
|
|
|
self.build_image_button.grab_default()
|
|
|
|
self.build_image_button.connect("clicked", self.build_image_clicked_cb)
|
|
|
|
button_box.pack_end(self.build_image_button, expand=False, fill=False)
|
|
|
|
|
|
|
|
self.back_button = gtk.LinkButton("Go back to Image Configuration screen", "<< Back to image configuration")
|
|
|
|
self.back_button.connect("clicked", self.back_button_clicked_cb)
|
|
|
|
button_box.pack_start(self.back_button, expand=False, fill=False)
|
|
|
|
|
2012-02-29 14:15:01 +00:00
|
|
|
def tree_row_activated_cb(self, table, tree_model, path):
|
|
|
|
binb = tree_model.get_value(tree_model.get_iter(path), PackageListModel.COL_BINB)
|
2011-11-28 06:32:40 +00:00
|
|
|
if binb:
|
|
|
|
self.builder.show_binb_dialog(binb)
|
|
|
|
|
|
|
|
def build_image_clicked_cb(self, button):
|
|
|
|
self.builder.build_image()
|
|
|
|
|
|
|
|
def back_button_clicked_cb(self, button):
|
|
|
|
self.builder.show_configuration()
|
|
|
|
|
|
|
|
def _expand_all(self):
|
|
|
|
for tab in self.tables:
|
|
|
|
tab.table_tree.expand_all()
|
|
|
|
|
|
|
|
def refresh_selection(self):
|
|
|
|
self._expand_all()
|
|
|
|
|
|
|
|
self.builder.configuration.selected_packages = self.package_model.get_selected_packages()
|
|
|
|
selected_packages_num = len(self.builder.configuration.selected_packages)
|
|
|
|
selected_packages_size = float(self.package_model.get_packages_size())
|
|
|
|
selected_packages_size_str = self._size_to_string(selected_packages_size)
|
|
|
|
|
|
|
|
image_overhead_factor = self.builder.configuration.image_overhead_factor
|
|
|
|
image_rootfs_size = self.builder.configuration.image_rootfs_size
|
|
|
|
image_extra_size = self.builder.configuration.image_extra_size
|
|
|
|
base_size = image_overhead_factor * selected_packages_size
|
|
|
|
image_total_size = max(base_size, image_rootfs_size) + image_extra_size
|
|
|
|
image_total_size_str = self._size_to_string(image_total_size)
|
|
|
|
|
|
|
|
self.label.set_text("Packages included: %s\nSelected packages size: %s\nTotal image size: %s" %
|
|
|
|
(selected_packages_num, selected_packages_size_str, image_total_size_str))
|
2012-02-29 14:15:09 +00:00
|
|
|
self.ins.show_indicator_icon("Included", selected_packages_num)
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
Helper function to convert the package size to string format.
|
|
|
|
The unit of size is KB
|
|
|
|
"""
|
|
|
|
def _size_to_string(self, size):
|
|
|
|
if len(str(int(size))) > 3:
|
|
|
|
size_str = '%.1f' % (size*1.0/1024) + ' MB'
|
|
|
|
else:
|
|
|
|
size_str = str(size) + ' KB'
|
|
|
|
return size_str
|
|
|
|
|
|
|
|
def toggle_item_idle_cb(self, path):
|
|
|
|
if not self.package_model.path_included(path):
|
|
|
|
self.package_model.include_item(item_path=path, binb="User Selected")
|
|
|
|
else:
|
|
|
|
self.package_model.exclude_item(item_path=path)
|
|
|
|
|
2012-03-14 02:53:42 +00:00
|
|
|
self.refresh_selection()
|
2011-11-28 06:32:40 +00:00
|
|
|
self.builder.window_sensitive(True)
|
|
|
|
|
2012-02-29 14:14:58 +00:00
|
|
|
def table_toggled_cb(self, table, cell, view_path, toggled_columnid, view_tree):
|
2011-11-28 06:32:40 +00:00
|
|
|
# Click to include a package
|
|
|
|
self.builder.window_sensitive(False)
|
|
|
|
view_model = view_tree.get_model()
|
|
|
|
path = self.package_model.convert_vpath_to_path(view_model, view_path)
|
|
|
|
glib.idle_add(self.toggle_item_idle_cb, path)
|