summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
diff options
context:
space:
mode:
authorShane Wang <shane.wang@intel.com>2012-02-29 22:14:58 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-03-01 15:51:30 +0000
commit030ba4bc71a1e7ea9a74e819949e5fb794af09f2 (patch)
treee3105c650c90a21546e8ccde22bc939f5df536b7 /bitbake/lib/bb/ui/crumbs/imagedetailspage.py
parent8f07bdc0a42dd7a7c3acf5d1b13220dbc98c8017 (diff)
downloadpoky-030ba4bc71a1e7ea9a74e819949e5fb794af09f2.tar.gz
Hob: make HobViewTable more general in hob and make the image selection dialog and the image details page reuse it.
This patch is to make the class HobViewTable more general as a tree view in Hob. Now the recipe selection page and the package selection page are using it. And we have tree views in the image selection dialog and the image details page, which used the class methods in HobWidget to create the tree views. That is not good in OO. So, make them reuse HobViewTable to create its instances. (Bitbake rev: 3c900211e8bc0311542873480d79b347d7449f59) Signed-off-by: Shane Wang <shane.wang@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/imagedetailspage.py')
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/imagedetailspage.py65
1 files changed, 53 insertions, 12 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
index e8419e0ee9..7f93db7ef9 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -23,7 +23,7 @@
23import gobject 23import gobject
24import gtk 24import gtk
25from bb.ui.crumbs.hobcolor import HobColors 25from bb.ui.crumbs.hobcolor import HobColors
26from bb.ui.crumbs.hobwidget import hic, HobWidget 26from bb.ui.crumbs.hobwidget import hic, HobViewTable
27from bb.ui.crumbs.hobpages import HobPage 27from bb.ui.crumbs.hobpages import HobPage
28 28
29# 29#
@@ -31,8 +31,28 @@ from bb.ui.crumbs.hobpages import HobPage
31# 31#
32class ImageDetailsPage (HobPage): 32class ImageDetailsPage (HobPage):
33 33
34 __columns__ = [{
35 'col_name' : 'Image name',
36 'col_id' : 0,
37 'col_style': 'text',
38 'col_min' : 500,
39 'col_max' : 500
40 }, {
41 'col_name' : 'Image size',
42 'col_id' : 1,
43 'col_style': 'text',
44 'col_min' : 100,
45 'col_max' : 100
46 }, {
47 'col_name' : 'Select',
48 'col_id' : 2,
49 'col_style': 'radio toggle',
50 'col_min' : 100,
51 'col_max' : 100
52 }]
53
34 class DetailBox (gtk.EventBox): 54 class DetailBox (gtk.EventBox):
35 def __init__(self, varlist, vallist, icon = None, button = None, color = HobColors.LIGHT_GRAY): 55 def __init__(self, widget = None, varlist = None, vallist = None, icon = None, button = None, color = HobColors.LIGHT_GRAY):
36 gtk.EventBox.__init__(self) 56 gtk.EventBox.__init__(self)
37 57
38 # set color 58 # set color
@@ -44,8 +64,11 @@ class ImageDetailsPage (HobPage):
44 self.hbox.set_border_width(15) 64 self.hbox.set_border_width(15)
45 self.add(self.hbox) 65 self.add(self.hbox)
46 66
47 # pack the icon and the text on the left 67 if widget != None:
48 row = len(varlist) 68 row = 1
69 elif varlist != None and vallist != None:
70 # pack the icon and the text on the left
71 row = len(varlist)
49 self.table = gtk.Table(row, 20, True) 72 self.table = gtk.Table(row, 20, True)
50 self.table.set_size_request(100, -1) 73 self.table.set_size_request(100, -1)
51 self.hbox.pack_start(self.table, expand=True, fill=True, padding=15) 74 self.hbox.pack_start(self.table, expand=True, fill=True, padding=15)
@@ -54,8 +77,11 @@ class ImageDetailsPage (HobPage):
54 if icon != None: 77 if icon != None:
55 self.table.attach(icon, colid, colid + 2, 0, 1) 78 self.table.attach(icon, colid, colid + 2, 0, 1)
56 colid = colid + 2 79 colid = colid + 2
57 for line in range(0, row): 80 if widget != None:
58 self.table.attach(self.text2label(varlist[line], vallist[line]), colid, 20, line, line + 1) 81 self.table.attach(widget, colid, 20, 0, 1)
82 elif varlist != None and vallist != None:
83 for line in range(0, row):
84 self.table.attach(self.text2label(varlist[line], vallist[line]), colid, 20, line, line + 1)
59 85
60 # pack the button on the right 86 # pack the button on the right
61 if button != None: 87 if button != None:
@@ -137,7 +163,7 @@ class ImageDetailsPage (HobPage):
137 icon.set_from_pixbuf(pix_buffer) 163 icon.set_from_pixbuf(pix_buffer)
138 varlist = [""] 164 varlist = [""]
139 vallist = ["Your image is ready"] 165 vallist = ["Your image is ready"]
140 build_result = self.DetailBox(varlist=varlist, vallist=vallist, icon=icon, button=None, color=color) 166 build_result = self.DetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color)
141 self.box_group_area.pack_start(build_result, expand=False, fill=False) 167 self.box_group_area.pack_start(build_result, expand=False, fill=False)
142 168
143 # Name 169 # Name
@@ -145,9 +171,12 @@ class ImageDetailsPage (HobPage):
145 for image_name in image_names: 171 for image_name in image_names:
146 image_size = self._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size) 172 image_size = self._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size)
147 self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False) 173 self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False)
148 images_widget, treeview = HobWidget.gen_images_widget(600, 200, 100) 174 image_table = HobViewTable(self.__columns__)
149 treeview.set_model(self.image_store) 175 image_table.set_model(self.image_store)
150 self.box_group_area.pack_start(images_widget, expand=False, fill=False) 176 image_table.toggle_default()
177 image_table.connect("toggled", self.toggled_cb)
178 view_files_button = gtk.LinkButton("file://%s" % image_addr, "View files")
179 self.box_group_area.pack_start(self.DetailBox(widget=image_table, button=view_files_button), expand=True, fill=True)
151 180
152 # Machine, Base image and Layers 181 # Machine, Base image and Layers
153 layer_num_limit = 15 182 layer_num_limit = 15
@@ -175,7 +204,7 @@ class ImageDetailsPage (HobPage):
175 204
176 edit_config_button = gtk.LinkButton("Changes settings for build", "Edit configuration") 205 edit_config_button = gtk.LinkButton("Changes settings for build", "Edit configuration")
177 edit_config_button.connect("clicked", self.edit_config_button_clicked_cb) 206 edit_config_button.connect("clicked", self.edit_config_button_clicked_cb)
178 setting_detail = self.DetailBox(varlist=varlist, vallist=vallist, icon=None, button=edit_config_button) 207 setting_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_config_button)
179 self.box_group_area.pack_start(setting_detail, expand=False, fill=False) 208 self.box_group_area.pack_start(setting_detail, expand=False, fill=False)
180 209
181 # Packages included, and Total image size 210 # Packages included, and Total image size
@@ -188,7 +217,7 @@ class ImageDetailsPage (HobPage):
188 edit_packages_button.connect("clicked", self.edit_packages_button_clicked_cb) 217 edit_packages_button.connect("clicked", self.edit_packages_button_clicked_cb)
189 else: # get to this page from "My images" 218 else: # get to this page from "My images"
190 edit_packages_button = None 219 edit_packages_button = None
191 package_detail = self.DetailBox(varlist=varlist, vallist=vallist, icon=None, button=edit_packages_button) 220 package_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_packages_button)
192 self.box_group_area.pack_start(package_detail, expand=False, fill=False) 221 self.box_group_area.pack_start(package_detail, expand=False, fill=False)
193 if build_succeeded: 222 if build_succeeded:
194 buttonlist = ["Build new image", "Save as template", "Run image", "Deploy image"] 223 buttonlist = ["Build new image", "Save as template", "Run image", "Deploy image"]
@@ -199,6 +228,18 @@ class ImageDetailsPage (HobPage):
199 228
200 self.show_all() 229 self.show_all()
201 230
231 def toggled_cb(self, table, cell, path, columnid, tree):
232 model = tree.get_model()
233 if not model:
234 return
235 iter = model.get_iter_first()
236 while iter:
237 rowpath = model.get_path(iter)
238 model[rowpath][columnid] = False
239 iter = model.iter_next(iter)
240
241 model[path][columnid] = True
242
202 def create_bottom_buttons(self, buttonlist): 243 def create_bottom_buttons(self, buttonlist):
203 # Create the buttons at the bottom 244 # Create the buttons at the bottom
204 bottom_buttons = gtk.HBox(False, 5) 245 bottom_buttons = gtk.HBox(False, 5)