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
|
2012-05-22 03:08:34 +00:00
|
|
|
import re
|
2011-11-28 06:32:40 +00:00
|
|
|
from bb.ui.crumbs.progressbar import HobProgressBar
|
|
|
|
from bb.ui.crumbs.hobcolor import HobColors
|
2012-03-22 22:54:37 +00:00
|
|
|
from bb.ui.crumbs.hobwidget import hic, HobImageButton, HobInfoButton, HobAltButton, HobButton
|
2011-11-28 06:32:40 +00:00
|
|
|
from bb.ui.crumbs.hoblistmodel import RecipeListModel
|
|
|
|
from bb.ui.crumbs.hobpages import HobPage
|
2013-07-16 13:33:21 +00:00
|
|
|
from bb.ui.crumbs.hig.retrieveimagedialog import RetrieveImageDialog
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# ImageConfigurationPage
|
|
|
|
#
|
|
|
|
class ImageConfigurationPage (HobPage):
|
|
|
|
|
2012-05-21 14:41:20 +00:00
|
|
|
__dummy_machine__ = "--select a machine--"
|
2013-07-25 07:50:33 +00:00
|
|
|
__dummy_image__ = "--select an image recipe--"
|
|
|
|
__custom_image__ = "Select from my image recipes"
|
2012-05-21 14:41:20 +00:00
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
def __init__(self, builder):
|
|
|
|
super(ImageConfigurationPage, self).__init__(builder, "Image configuration")
|
|
|
|
|
|
|
|
self.image_combo_id = None
|
2012-04-09 14:13:49 +00:00
|
|
|
# we use machine_combo_changed_by_manual to identify the machine is changed by code
|
|
|
|
# or by manual. If by manual, all user's recipe selection and package selection are
|
|
|
|
# cleared.
|
|
|
|
self.machine_combo_changed_by_manual = True
|
2012-10-16 11:23:27 +00:00
|
|
|
self.stopping = False
|
2013-01-21 14:40:07 +00:00
|
|
|
self.warning_shift = 0
|
2013-07-16 13:33:21 +00:00
|
|
|
self.custom_image_selected = None
|
2011-11-28 06:32:40 +00:00
|
|
|
self.create_visual_elements()
|
|
|
|
|
|
|
|
def create_visual_elements(self):
|
|
|
|
# create visual elements
|
|
|
|
self.toolbar = gtk.Toolbar()
|
|
|
|
self.toolbar.set_orientation(gtk.ORIENTATION_HORIZONTAL)
|
|
|
|
self.toolbar.set_style(gtk.TOOLBAR_BOTH)
|
|
|
|
|
2012-03-13 20:09:18 +00:00
|
|
|
my_images_button = self.append_toolbar_button(self.toolbar,
|
2012-04-09 08:42:00 +00:00
|
|
|
"Images",
|
2011-11-28 06:32:40 +00:00
|
|
|
hic.ICON_IMAGES_DISPLAY_FILE,
|
|
|
|
hic.ICON_IMAGES_HOVER_FILE,
|
2012-04-09 08:42:00 +00:00
|
|
|
"Open previously built images",
|
2011-11-28 06:32:40 +00:00
|
|
|
self.my_images_button_clicked_cb)
|
2012-03-13 20:09:18 +00:00
|
|
|
settings_button = self.append_toolbar_button(self.toolbar,
|
2011-11-28 06:32:40 +00:00
|
|
|
"Settings",
|
|
|
|
hic.ICON_SETTINGS_DISPLAY_FILE,
|
|
|
|
hic.ICON_SETTINGS_HOVER_FILE,
|
2012-04-09 08:42:00 +00:00
|
|
|
"View additional build settings",
|
2011-11-28 06:32:40 +00:00
|
|
|
self.settings_button_clicked_cb)
|
|
|
|
|
|
|
|
self.config_top_button = self.add_onto_top_bar(self.toolbar)
|
|
|
|
|
|
|
|
self.gtable = gtk.Table(40, 40, True)
|
|
|
|
self.create_config_machine()
|
|
|
|
self.create_config_baseimg()
|
|
|
|
self.config_build_button = self.create_config_build_button()
|
|
|
|
|
|
|
|
def _remove_all_widget(self):
|
|
|
|
children = self.gtable.get_children() or []
|
|
|
|
for child in children:
|
|
|
|
self.gtable.remove(child)
|
|
|
|
children = self.box_group_area.get_children() or []
|
|
|
|
for child in children:
|
|
|
|
self.box_group_area.remove(child)
|
|
|
|
children = self.get_children() or []
|
|
|
|
for child in children:
|
|
|
|
self.remove(child)
|
|
|
|
|
2012-02-29 14:15:08 +00:00
|
|
|
def _pack_components(self, pack_config_build_button = False):
|
2011-11-28 06:32:40 +00:00
|
|
|
self._remove_all_widget()
|
|
|
|
self.pack_start(self.config_top_button, expand=False, fill=False)
|
|
|
|
self.pack_start(self.group_align, expand=True, fill=True)
|
|
|
|
|
|
|
|
self.box_group_area.pack_start(self.gtable, expand=True, fill=True)
|
2012-03-26 21:32:12 +00:00
|
|
|
if pack_config_build_button:
|
2012-02-29 14:15:08 +00:00
|
|
|
self.box_group_area.pack_end(self.config_build_button, expand=False, fill=False)
|
2012-03-26 21:32:12 +00:00
|
|
|
else:
|
|
|
|
box = gtk.HBox(False, 6)
|
|
|
|
box.show()
|
|
|
|
subbox = gtk.HBox(False, 0)
|
|
|
|
subbox.set_size_request(205, 49)
|
|
|
|
subbox.show()
|
|
|
|
box.add(subbox)
|
|
|
|
self.box_group_area.pack_end(box, False, False)
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
def show_machine(self):
|
|
|
|
self.progress_bar.reset()
|
2012-02-29 14:15:08 +00:00
|
|
|
self._pack_components(pack_config_build_button = False)
|
|
|
|
self.set_config_machine_layout(show_progress_bar = False)
|
|
|
|
self.show_all()
|
2011-11-28 06:32:40 +00:00
|
|
|
|
2012-03-28 00:02:27 +00:00
|
|
|
def update_progress_bar(self, title, fraction, status=None):
|
2012-10-16 11:23:27 +00:00
|
|
|
if self.stopping == False:
|
|
|
|
self.progress_bar.update(fraction)
|
2012-10-31 13:31:07 +00:00
|
|
|
self.progress_bar.set_text(title)
|
2012-10-16 11:23:27 +00:00
|
|
|
self.progress_bar.set_rcstyle(status)
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
def show_info_populating(self):
|
2012-02-29 14:15:08 +00:00
|
|
|
self._pack_components(pack_config_build_button = False)
|
|
|
|
self.set_config_machine_layout(show_progress_bar = True)
|
2011-11-28 06:32:40 +00:00
|
|
|
self.show_all()
|
|
|
|
|
|
|
|
def show_info_populated(self):
|
2012-03-13 07:06:25 +00:00
|
|
|
self.progress_bar.reset()
|
|
|
|
self._pack_components(pack_config_build_button = False)
|
|
|
|
self.set_config_machine_layout(show_progress_bar = False)
|
|
|
|
self.set_config_baseimg_layout()
|
|
|
|
self.show_all()
|
|
|
|
|
|
|
|
def show_baseimg_selected(self):
|
2012-02-29 14:15:08 +00:00
|
|
|
self.progress_bar.reset()
|
|
|
|
self._pack_components(pack_config_build_button = True)
|
|
|
|
self.set_config_machine_layout(show_progress_bar = False)
|
2011-11-28 06:32:40 +00:00
|
|
|
self.set_config_baseimg_layout()
|
|
|
|
self.show_all()
|
2012-08-21 15:21:23 +00:00
|
|
|
if self.builder.recipe_model.get_selected_image() == self.builder.recipe_model.__custom_image__:
|
|
|
|
self.just_bake_button.hide()
|
2011-11-28 06:32:40 +00:00
|
|
|
|
2013-01-21 14:40:07 +00:00
|
|
|
def add_warnings_bar(self):
|
|
|
|
#create the warnings bar shown when recipes parsing generates warnings
|
|
|
|
color = HobColors.KHAKI
|
|
|
|
warnings_bar = gtk.EventBox()
|
|
|
|
warnings_bar.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
|
|
|
|
warnings_bar.set_flags(gtk.CAN_DEFAULT)
|
|
|
|
warnings_bar.grab_default()
|
|
|
|
|
|
|
|
build_stop_tab = gtk.Table(10, 20, True)
|
|
|
|
warnings_bar.add(build_stop_tab)
|
|
|
|
|
|
|
|
icon = gtk.Image()
|
|
|
|
icon_pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_INDI_ALERT_FILE)
|
|
|
|
icon.set_from_pixbuf(icon_pix_buffer)
|
|
|
|
build_stop_tab.attach(icon, 0, 2, 0, 10)
|
|
|
|
|
|
|
|
label = gtk.Label()
|
|
|
|
label.set_alignment(0.0, 0.5)
|
|
|
|
warnings_nb = len(self.builder.parsing_warnings)
|
|
|
|
if warnings_nb == 1:
|
|
|
|
label.set_markup("<span size='x-large'><b>1 recipe parsing warning</b></span>")
|
|
|
|
else:
|
|
|
|
label.set_markup("<span size='x-large'><b>%s recipe parsing warnings</b></span>" % warnings_nb)
|
|
|
|
build_stop_tab.attach(label, 2, 12, 0, 10)
|
|
|
|
|
|
|
|
view_warnings_button = HobButton("View warnings")
|
|
|
|
view_warnings_button.connect('clicked', self.view_warnings_button_clicked_cb)
|
|
|
|
build_stop_tab.attach(view_warnings_button, 15, 19, 1, 9)
|
|
|
|
|
|
|
|
return warnings_bar
|
|
|
|
|
2013-02-04 14:56:00 +00:00
|
|
|
def disable_warnings_bar(self):
|
|
|
|
if self.builder.parsing_warnings:
|
2013-06-20 11:16:01 +00:00
|
|
|
if hasattr(self, 'warnings_bar'):
|
|
|
|
self.warnings_bar.hide_all()
|
2013-02-04 14:56:00 +00:00
|
|
|
self.builder.parsing_warnings = []
|
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
def create_config_machine(self):
|
|
|
|
self.machine_title = gtk.Label()
|
|
|
|
self.machine_title.set_alignment(0.0, 0.5)
|
2012-03-28 23:32:28 +00:00
|
|
|
mark = "<span %s>Select a machine</span>" % self.span_tag('x-large', 'bold')
|
2011-11-28 06:32:40 +00:00
|
|
|
self.machine_title.set_markup(mark)
|
|
|
|
|
|
|
|
self.machine_title_desc = gtk.Label()
|
2012-03-28 23:32:28 +00:00
|
|
|
self.machine_title_desc.set_alignment(0.0, 0.5)
|
2012-04-09 08:42:00 +00:00
|
|
|
mark = ("<span %s>Your selection is the profile of the target machine for which you"
|
2012-03-28 23:32:28 +00:00
|
|
|
" are building the image.\n</span>") % (self.span_tag('medium'))
|
2011-11-28 06:32:40 +00:00
|
|
|
self.machine_title_desc.set_markup(mark)
|
|
|
|
|
|
|
|
self.machine_combo = gtk.combo_box_new_text()
|
|
|
|
self.machine_combo.connect("changed", self.machine_combo_changed_cb)
|
|
|
|
|
|
|
|
icon_file = hic.ICON_LAYERS_DISPLAY_FILE
|
|
|
|
hover_file = hic.ICON_LAYERS_HOVER_FILE
|
2012-03-22 22:54:37 +00:00
|
|
|
self.layer_button = HobImageButton("Layers", "Add support for machines, software, etc.",
|
|
|
|
icon_file, hover_file)
|
|
|
|
self.layer_button.connect("clicked", self.layer_button_clicked_cb)
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
markup = "Layers are a powerful mechanism to extend the Yocto Project "
|
|
|
|
markup += "with your own functionality.\n"
|
2012-03-02 23:43:37 +00:00
|
|
|
markup += "For more on layers, check the <a href=\""
|
2012-04-09 08:42:00 +00:00
|
|
|
markup += "http://www.yoctoproject.org/docs/current/dev-manual/"
|
|
|
|
markup += "dev-manual.html#understanding-and-using-layers\">reference manual</a>."
|
2013-03-05 15:36:29 +00:00
|
|
|
self.layer_info_icon = HobInfoButton("<b>Layers</b>" + "*" + markup, self.get_parent())
|
2011-11-28 06:32:40 +00:00
|
|
|
self.progress_bar = HobProgressBar()
|
2012-03-22 01:42:35 +00:00
|
|
|
self.stop_button = HobAltButton("Stop")
|
2012-03-13 09:10:26 +00:00
|
|
|
self.stop_button.connect("clicked", self.stop_button_clicked_cb)
|
2011-11-28 06:32:40 +00:00
|
|
|
self.machine_separator = gtk.HSeparator()
|
|
|
|
|
2012-02-29 14:15:08 +00:00
|
|
|
def set_config_machine_layout(self, show_progress_bar = False):
|
2011-11-28 06:32:40 +00:00
|
|
|
self.gtable.attach(self.machine_title, 0, 40, 0, 4)
|
|
|
|
self.gtable.attach(self.machine_title_desc, 0, 40, 4, 6)
|
2012-03-28 23:32:28 +00:00
|
|
|
self.gtable.attach(self.machine_combo, 0, 12, 7, 10)
|
|
|
|
self.gtable.attach(self.layer_button, 14, 36, 7, 12)
|
|
|
|
self.gtable.attach(self.layer_info_icon, 36, 40, 7, 11)
|
2012-03-22 22:54:37 +00:00
|
|
|
if show_progress_bar:
|
2012-09-26 12:13:42 +00:00
|
|
|
#self.gtable.attach(self.progress_box, 0, 40, 15, 18)
|
|
|
|
self.gtable.attach(self.progress_bar, 0, 37, 15, 18)
|
|
|
|
self.gtable.attach(self.stop_button, 37, 40, 15, 18, 0, 0)
|
2013-01-21 14:40:07 +00:00
|
|
|
if self.builder.parsing_warnings:
|
|
|
|
self.warnings_bar = self.add_warnings_bar()
|
|
|
|
self.gtable.attach(self.warnings_bar, 0, 40, 14, 18)
|
|
|
|
self.warning_shift = 4
|
|
|
|
else:
|
|
|
|
self.warning_shift = 0
|
2012-03-28 23:32:28 +00:00
|
|
|
self.gtable.attach(self.machine_separator, 0, 40, 13, 14)
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
def create_config_baseimg(self):
|
|
|
|
self.image_title = gtk.Label()
|
|
|
|
self.image_title.set_alignment(0, 1.0)
|
2013-07-25 07:21:06 +00:00
|
|
|
mark = "<span %s>Select an image recipe</span>" % self.span_tag('x-large', 'bold')
|
2011-11-28 06:32:40 +00:00
|
|
|
self.image_title.set_markup(mark)
|
|
|
|
|
|
|
|
self.image_title_desc = gtk.Label()
|
|
|
|
self.image_title_desc.set_alignment(0, 0.5)
|
2013-07-25 07:21:06 +00:00
|
|
|
|
|
|
|
mark = ("<span %s>Image recipes are a starting point for the type of image you want. "
|
2011-11-28 06:32:40 +00:00
|
|
|
"You can build them as \n"
|
2013-07-25 07:21:06 +00:00
|
|
|
"they are or edit them to suit your needs.\n</span>") % self.span_tag('medium')
|
2011-11-28 06:32:40 +00:00
|
|
|
self.image_title_desc.set_markup(mark)
|
|
|
|
|
|
|
|
self.image_combo = gtk.combo_box_new_text()
|
2013-07-25 07:50:33 +00:00
|
|
|
self.image_combo.set_row_separator_func(self.combo_separator_func, None)
|
2011-11-28 06:32:40 +00:00
|
|
|
self.image_combo_id = self.image_combo.connect("changed", self.image_combo_changed_cb)
|
|
|
|
|
|
|
|
self.image_desc = gtk.Label()
|
2012-03-28 23:32:28 +00:00
|
|
|
self.image_desc.set_alignment(0.0, 0.5)
|
2012-09-06 07:58:32 +00:00
|
|
|
self.image_desc.set_size_request(256, -1)
|
2012-05-14 12:51:48 +00:00
|
|
|
self.image_desc.set_justify(gtk.JUSTIFY_LEFT)
|
2011-11-28 06:32:40 +00:00
|
|
|
self.image_desc.set_line_wrap(True)
|
|
|
|
|
2012-09-06 07:58:32 +00:00
|
|
|
# button to view recipes
|
|
|
|
icon_file = hic.ICON_RCIPE_DISPLAY_FILE
|
|
|
|
hover_file = hic.ICON_RCIPE_HOVER_FILE
|
|
|
|
self.view_adv_configuration_button = HobImageButton("Advanced configuration",
|
|
|
|
"Select image types, package formats, etc",
|
|
|
|
icon_file, hover_file)
|
|
|
|
self.view_adv_configuration_button.connect("clicked", self.view_adv_configuration_button_clicked_cb)
|
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
self.image_separator = gtk.HSeparator()
|
|
|
|
|
2013-07-25 07:50:33 +00:00
|
|
|
def combo_separator_func(self, model, iter, user_data):
|
|
|
|
name = model.get_value(iter, 0)
|
|
|
|
if name == "--Separator--":
|
|
|
|
return True
|
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
def set_config_baseimg_layout(self):
|
2013-01-21 14:40:07 +00:00
|
|
|
self.gtable.attach(self.image_title, 0, 40, 15+self.warning_shift, 17+self.warning_shift)
|
|
|
|
self.gtable.attach(self.image_title_desc, 0, 40, 18+self.warning_shift, 22+self.warning_shift)
|
|
|
|
self.gtable.attach(self.image_combo, 0, 12, 23+self.warning_shift, 26+self.warning_shift)
|
|
|
|
self.gtable.attach(self.image_desc, 0, 12, 27+self.warning_shift, 33+self.warning_shift)
|
|
|
|
self.gtable.attach(self.view_adv_configuration_button, 14, 36, 23+self.warning_shift, 28+self.warning_shift)
|
|
|
|
self.gtable.attach(self.image_separator, 0, 40, 35+self.warning_shift, 36+self.warning_shift)
|
2012-03-13 07:06:25 +00:00
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
def create_config_build_button(self):
|
2012-03-29 12:54:52 +00:00
|
|
|
# Create the "Build packages" and "Build image" buttons at the bottom
|
2012-03-15 06:56:45 +00:00
|
|
|
button_box = gtk.HBox(False, 6)
|
2011-11-28 06:32:40 +00:00
|
|
|
|
2012-03-29 12:54:52 +00:00
|
|
|
# create button "Build image"
|
2012-08-21 15:21:23 +00:00
|
|
|
self.just_bake_button = HobButton("Build image")
|
2013-07-25 07:21:06 +00:00
|
|
|
self.just_bake_button.set_tooltip_text("Build the image recipe as it is")
|
2012-08-21 15:21:23 +00:00
|
|
|
self.just_bake_button.connect("clicked", self.just_bake_button_clicked_cb)
|
|
|
|
button_box.pack_end(self.just_bake_button, expand=False, fill=False)
|
|
|
|
|
2013-07-25 07:21:06 +00:00
|
|
|
# create button "Edit image recipe"
|
|
|
|
self.edit_image_button = HobAltButton("Edit image recipe")
|
|
|
|
self.edit_image_button.set_tooltip_text("Customize the recipes and packages to be included in your image")
|
2012-08-21 15:21:23 +00:00
|
|
|
self.edit_image_button.connect("clicked", self.edit_image_button_clicked_cb)
|
|
|
|
button_box.pack_end(self.edit_image_button, expand=False, fill=False)
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
return button_box
|
|
|
|
|
2012-03-13 09:10:26 +00:00
|
|
|
def stop_button_clicked_cb(self, button):
|
2012-10-16 11:23:27 +00:00
|
|
|
self.stopping = True
|
|
|
|
self.progress_bar.set_text("Stopping recipe parsing")
|
|
|
|
self.progress_bar.set_rcstyle("stop")
|
2012-04-09 14:13:46 +00:00
|
|
|
self.builder.cancel_parse_sync()
|
2012-03-13 09:10:26 +00:00
|
|
|
|
2013-01-21 14:40:07 +00:00
|
|
|
def view_warnings_button_clicked_cb(self, button):
|
|
|
|
self.builder.show_warning_dialog()
|
|
|
|
|
2013-09-10 12:58:52 +00:00
|
|
|
def machine_combo_changed_idle_cb(self):
|
|
|
|
self.builder.window.set_cursor(None)
|
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
def machine_combo_changed_cb(self, machine_combo):
|
2012-10-16 11:23:27 +00:00
|
|
|
self.stopping = False
|
2013-01-25 15:05:26 +00:00
|
|
|
self.builder.parsing_warnings = []
|
2011-11-28 06:32:40 +00:00
|
|
|
combo_item = machine_combo.get_active_text()
|
2012-05-21 14:41:20 +00:00
|
|
|
if not combo_item or combo_item == self.__dummy_machine__:
|
2012-03-13 09:10:26 +00:00
|
|
|
return
|
|
|
|
|
2014-01-21 15:59:37 +00:00
|
|
|
self.builder.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
|
|
|
self.builder.wait(0.1) #wait for combo and cursor to update
|
|
|
|
|
2012-05-21 14:41:20 +00:00
|
|
|
# remove __dummy_machine__ item from the store list after first user selection
|
|
|
|
# because it is no longer valid
|
|
|
|
combo_store = machine_combo.get_model()
|
|
|
|
if len(combo_store) and (combo_store[0][0] == self.__dummy_machine__):
|
|
|
|
machine_combo.remove_text(0)
|
|
|
|
|
2012-03-13 06:32:30 +00:00
|
|
|
self.builder.configuration.curr_mach = combo_item
|
2012-04-09 14:13:49 +00:00
|
|
|
if self.machine_combo_changed_by_manual:
|
2012-04-14 18:58:59 +00:00
|
|
|
self.builder.configuration.clear_selection()
|
2012-04-09 14:13:49 +00:00
|
|
|
# reset machine_combo_changed_by_manual
|
|
|
|
self.machine_combo_changed_by_manual = True
|
|
|
|
|
2013-08-20 13:30:22 +00:00
|
|
|
self.builder.configuration.selected_image = None
|
|
|
|
|
2012-03-13 06:32:30 +00:00
|
|
|
# Do reparse recipes
|
2012-04-09 14:13:38 +00:00
|
|
|
self.builder.populate_recipe_package_info_async()
|
2011-11-28 06:32:40 +00:00
|
|
|
|
2013-09-10 12:58:52 +00:00
|
|
|
glib.idle_add(self.machine_combo_changed_idle_cb)
|
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
def update_machine_combo(self):
|
2013-02-04 14:56:00 +00:00
|
|
|
self.disable_warnings_bar()
|
2012-05-21 14:41:20 +00:00
|
|
|
all_machines = [self.__dummy_machine__] + self.builder.parameters.all_machines
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
model = self.machine_combo.get_model()
|
|
|
|
model.clear()
|
|
|
|
for machine in all_machines:
|
|
|
|
self.machine_combo.append_text(machine)
|
2012-05-21 14:41:20 +00:00
|
|
|
self.machine_combo.set_active(0)
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
def switch_machine_combo(self):
|
2013-02-04 14:56:00 +00:00
|
|
|
self.disable_warnings_bar()
|
2012-04-09 14:13:49 +00:00
|
|
|
self.machine_combo_changed_by_manual = False
|
2011-11-28 06:32:40 +00:00
|
|
|
model = self.machine_combo.get_model()
|
|
|
|
active = 0
|
|
|
|
while active < len(model):
|
|
|
|
if model[active][0] == self.builder.configuration.curr_mach:
|
|
|
|
self.machine_combo.set_active(active)
|
|
|
|
return
|
|
|
|
active += 1
|
2012-05-21 14:41:20 +00:00
|
|
|
|
|
|
|
if model[0][0] != self.__dummy_machine__:
|
|
|
|
self.machine_combo.insert_text(0, self.__dummy_machine__)
|
|
|
|
|
|
|
|
self.machine_combo.set_active(0)
|
2011-11-28 06:32:40 +00:00
|
|
|
|
2012-05-22 03:08:35 +00:00
|
|
|
def update_image_desc(self):
|
2012-04-09 14:13:49 +00:00
|
|
|
desc = ""
|
2012-05-22 03:08:35 +00:00
|
|
|
selected_image = self.image_combo.get_active_text()
|
2012-04-09 14:13:49 +00:00
|
|
|
if selected_image and selected_image in self.builder.recipe_model.pn_path.keys():
|
|
|
|
image_path = self.builder.recipe_model.pn_path[selected_image]
|
|
|
|
image_iter = self.builder.recipe_model.get_iter(image_path)
|
|
|
|
desc = self.builder.recipe_model.get_value(image_iter, self.builder.recipe_model.COL_DESC)
|
|
|
|
|
|
|
|
mark = ("<span %s>%s</span>\n") % (self.span_tag('small'), desc)
|
|
|
|
self.image_desc.set_markup(mark)
|
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
def image_combo_changed_idle_cb(self, selected_image, selected_recipes, selected_packages):
|
|
|
|
self.builder.update_recipe_model(selected_image, selected_recipes)
|
|
|
|
self.builder.update_package_model(selected_packages)
|
|
|
|
self.builder.window_sensitive(True)
|
|
|
|
|
|
|
|
def image_combo_changed_cb(self, combo):
|
|
|
|
self.builder.window_sensitive(False)
|
|
|
|
selected_image = self.image_combo.get_active_text()
|
2013-07-25 07:50:33 +00:00
|
|
|
if selected_image == self.__custom_image__:
|
2013-07-16 13:33:21 +00:00
|
|
|
topdir = self.builder.get_topdir()
|
2014-02-25 13:30:10 +00:00
|
|
|
images_dir = topdir + "/recipes/images/custom/"
|
2013-07-16 13:33:21 +00:00
|
|
|
self.builder.ensure_dir(images_dir)
|
|
|
|
|
|
|
|
dialog = RetrieveImageDialog(images_dir, "Select from my image recipes",
|
|
|
|
self.builder, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
|
|
|
|
response = dialog.run()
|
|
|
|
if response == gtk.RESPONSE_OK:
|
|
|
|
image_name = dialog.get_filename()
|
|
|
|
head, tail = os.path.split(image_name)
|
|
|
|
selected_image = os.path.splitext(tail)[0]
|
|
|
|
self.custom_image_selected = selected_image
|
|
|
|
self.update_image_combo(self.builder.recipe_model, selected_image)
|
|
|
|
else:
|
|
|
|
selected_image = self.__dummy_image__
|
|
|
|
self.update_image_combo(self.builder.recipe_model, None)
|
|
|
|
dialog.destroy()
|
2013-09-04 15:45:07 +00:00
|
|
|
else:
|
|
|
|
if self.custom_image_selected:
|
|
|
|
self.custom_image_selected = None
|
|
|
|
self.update_image_combo(self.builder.recipe_model, selected_image)
|
2013-07-16 13:33:21 +00:00
|
|
|
|
2012-05-21 14:41:20 +00:00
|
|
|
if not selected_image or (selected_image == self.__dummy_image__):
|
2013-07-16 13:33:21 +00:00
|
|
|
self.builder.window_sensitive(True)
|
|
|
|
self.just_bake_button.hide()
|
|
|
|
self.edit_image_button.hide()
|
2011-11-28 06:32:40 +00:00
|
|
|
return
|
|
|
|
|
2012-05-21 14:41:20 +00:00
|
|
|
# remove __dummy_image__ item from the store list after first user selection
|
|
|
|
# because it is no longer valid
|
|
|
|
combo_store = combo.get_model()
|
|
|
|
if len(combo_store) and (combo_store[0][0] == self.__dummy_image__):
|
|
|
|
combo.remove_text(0)
|
|
|
|
|
2012-04-09 08:41:57 +00:00
|
|
|
self.builder.customized = False
|
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
selected_recipes = []
|
|
|
|
|
|
|
|
image_path = self.builder.recipe_model.pn_path[selected_image]
|
|
|
|
image_iter = self.builder.recipe_model.get_iter(image_path)
|
|
|
|
selected_packages = self.builder.recipe_model.get_value(image_iter, self.builder.recipe_model.COL_INSTALL).split()
|
2012-05-22 03:08:35 +00:00
|
|
|
self.update_image_desc()
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
self.builder.recipe_model.reset()
|
|
|
|
self.builder.package_model.reset()
|
|
|
|
|
2012-03-13 07:06:25 +00:00
|
|
|
self.show_baseimg_selected()
|
|
|
|
|
2012-08-21 15:21:23 +00:00
|
|
|
if selected_image == self.builder.recipe_model.__custom_image__:
|
|
|
|
self.just_bake_button.hide()
|
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
glib.idle_add(self.image_combo_changed_idle_cb, selected_image, selected_recipes, selected_packages)
|
|
|
|
|
|
|
|
def _image_combo_connect_signal(self):
|
|
|
|
if not self.image_combo_id:
|
|
|
|
self.image_combo_id = self.image_combo.connect("changed", self.image_combo_changed_cb)
|
|
|
|
|
|
|
|
def _image_combo_disconnect_signal(self):
|
|
|
|
if self.image_combo_id:
|
|
|
|
self.image_combo.disconnect(self.image_combo_id)
|
|
|
|
self.image_combo_id = None
|
|
|
|
|
|
|
|
def update_image_combo(self, recipe_model, selected_image):
|
|
|
|
# Update the image combo according to the images in the recipe_model
|
|
|
|
# populate image combo
|
|
|
|
filter = {RecipeListModel.COL_TYPE : ['image']}
|
|
|
|
image_model = recipe_model.tree_model(filter)
|
2012-09-11 16:52:01 +00:00
|
|
|
image_model.set_sort_column_id(recipe_model.COL_NAME, gtk.SORT_ASCENDING)
|
2012-05-21 14:41:20 +00:00
|
|
|
active = 0
|
2013-01-15 14:50:39 +00:00
|
|
|
cnt = 0
|
2011-11-28 06:32:40 +00:00
|
|
|
|
2012-05-22 03:08:34 +00:00
|
|
|
white_pattern = []
|
|
|
|
if self.builder.parameters.image_white_pattern:
|
|
|
|
for i in self.builder.parameters.image_white_pattern.split():
|
|
|
|
white_pattern.append(re.compile(i))
|
|
|
|
|
|
|
|
black_pattern = []
|
|
|
|
if self.builder.parameters.image_black_pattern:
|
|
|
|
for i in self.builder.parameters.image_black_pattern.split():
|
|
|
|
black_pattern.append(re.compile(i))
|
2012-10-08 10:05:06 +00:00
|
|
|
black_pattern.append(re.compile("hob-image"))
|
2014-03-18 12:17:06 +00:00
|
|
|
black_pattern.append(re.compile("edited(-[0-9]*)*.bb$"))
|
2012-05-22 03:08:34 +00:00
|
|
|
|
2011-11-28 06:32:40 +00:00
|
|
|
it = image_model.get_iter_first()
|
|
|
|
self._image_combo_disconnect_signal()
|
|
|
|
model = self.image_combo.get_model()
|
|
|
|
model.clear()
|
2012-05-21 14:41:20 +00:00
|
|
|
# Set a indicator text to combo store when first open
|
2013-01-15 14:50:39 +00:00
|
|
|
if not selected_image:
|
|
|
|
self.image_combo.append_text(self.__dummy_image__)
|
|
|
|
cnt = cnt + 1
|
|
|
|
|
2013-07-25 07:50:33 +00:00
|
|
|
self.image_combo.append_text(self.__custom_image__)
|
|
|
|
self.image_combo.append_text("--Separator--")
|
2013-08-20 13:30:22 +00:00
|
|
|
cnt = cnt + 2
|
2013-07-25 07:50:33 +00:00
|
|
|
|
2013-07-25 11:37:51 +00:00
|
|
|
topdir = self.builder.get_topdir()
|
2011-11-28 06:32:40 +00:00
|
|
|
# append and set active
|
|
|
|
while it:
|
|
|
|
path = image_model.get_path(it)
|
2012-03-21 03:19:51 +00:00
|
|
|
it = image_model.iter_next(it)
|
2011-11-28 06:32:40 +00:00
|
|
|
image_name = image_model[path][recipe_model.COL_NAME]
|
2012-05-21 14:41:20 +00:00
|
|
|
if image_name == self.builder.recipe_model.__custom_image__:
|
2012-03-21 03:19:51 +00:00
|
|
|
continue
|
2012-05-22 03:08:34 +00:00
|
|
|
|
|
|
|
if black_pattern:
|
|
|
|
allow = True
|
|
|
|
for pattern in black_pattern:
|
|
|
|
if pattern.search(image_name):
|
|
|
|
allow = False
|
|
|
|
break
|
|
|
|
elif white_pattern:
|
|
|
|
allow = False
|
|
|
|
for pattern in white_pattern:
|
|
|
|
if pattern.search(image_name):
|
|
|
|
allow = True
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
allow = True
|
|
|
|
|
2013-07-25 11:37:51 +00:00
|
|
|
file_name = image_model[path][recipe_model.COL_FILE]
|
|
|
|
if file_name and topdir in file_name:
|
|
|
|
allow = False
|
|
|
|
|
2012-05-22 03:08:34 +00:00
|
|
|
if allow:
|
|
|
|
self.image_combo.append_text(image_name)
|
|
|
|
if image_name == selected_image:
|
|
|
|
active = cnt
|
|
|
|
cnt = cnt + 1
|
2013-07-25 08:25:29 +00:00
|
|
|
self.image_combo.append_text(self.builder.recipe_model.__custom_image__)
|
2012-05-22 03:08:34 +00:00
|
|
|
|
2013-08-27 10:27:37 +00:00
|
|
|
if selected_image == self.builder.recipe_model.__custom_image__:
|
|
|
|
active = cnt
|
|
|
|
|
2013-07-16 13:33:21 +00:00
|
|
|
if self.custom_image_selected:
|
|
|
|
self.image_combo.append_text("--Separator--")
|
|
|
|
self.image_combo.append_text(self.custom_image_selected)
|
2013-08-27 10:27:37 +00:00
|
|
|
cnt = cnt + 2
|
2013-07-16 13:33:21 +00:00
|
|
|
if self.custom_image_selected == selected_image:
|
|
|
|
active = cnt
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
self.image_combo.set_active(active)
|
|
|
|
|
2012-05-21 14:41:20 +00:00
|
|
|
if active != 0:
|
2012-04-01 12:14:16 +00:00
|
|
|
self.show_baseimg_selected()
|
|
|
|
|
|
|
|
self._image_combo_connect_signal()
|
|
|
|
|
2012-03-22 22:54:37 +00:00
|
|
|
def layer_button_clicked_cb(self, button):
|
2011-11-28 06:32:40 +00:00
|
|
|
# Create a layer selection dialog
|
|
|
|
self.builder.show_layer_selection_dialog()
|
2013-07-16 13:33:21 +00:00
|
|
|
|
2012-09-06 07:58:32 +00:00
|
|
|
def view_adv_configuration_button_clicked_cb(self, button):
|
|
|
|
# Create an advanced settings dialog
|
|
|
|
response, settings_changed = self.builder.show_adv_settings_dialog()
|
|
|
|
if not response:
|
|
|
|
return
|
|
|
|
if settings_changed:
|
2013-09-10 12:58:52 +00:00
|
|
|
self.builder.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
|
|
|
self.builder.wait(0.1) #wait for adv_settings_dialog to terminate
|
2013-07-16 13:33:21 +00:00
|
|
|
self.builder.reparse_post_adv_settings()
|
2013-09-10 12:58:52 +00:00
|
|
|
self.builder.window.set_cursor(None)
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
def just_bake_button_clicked_cb(self, button):
|
2013-01-21 14:40:07 +00:00
|
|
|
self.builder.parsing_warnings = []
|
2011-11-28 06:32:40 +00:00
|
|
|
self.builder.just_bake()
|
|
|
|
|
2012-08-21 15:21:23 +00:00
|
|
|
def edit_image_button_clicked_cb(self, button):
|
2014-03-18 12:17:06 +00:00
|
|
|
self.builder.set_base_image()
|
2012-08-21 15:21:23 +00:00
|
|
|
self.builder.show_recipes()
|
2011-11-28 06:32:40 +00:00
|
|
|
|
|
|
|
def my_images_button_clicked_cb(self, button):
|
|
|
|
self.builder.show_load_my_images_dialog()
|
|
|
|
|
|
|
|
def settings_button_clicked_cb(self, button):
|
|
|
|
# Create an advanced settings dialog
|
2012-09-06 07:58:32 +00:00
|
|
|
response, settings_changed = self.builder.show_simple_settings_dialog()
|
2012-03-28 16:10:30 +00:00
|
|
|
if not response:
|
|
|
|
return
|
|
|
|
if settings_changed:
|
|
|
|
self.builder.reparse_post_adv_settings()
|