diff options
author | Andrei Dinu <andrei.adrianx.dinu@intel.com> | 2013-03-05 17:36:25 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-03-19 13:51:24 +0000 |
commit | a4fdfa708844494b0a2e0d8c2199959c72832db2 (patch) | |
tree | d9c8d822a1f3a42a2aeac90c01af3364f143bf3f /bitbake/lib/bb/ui/crumbs | |
parent | 5b4b8177b532ff58c93de5ec8bda4ac2f0e9d56f (diff) | |
download | poky-a4fdfa708844494b0a2e0d8c2199959c72832db2.tar.gz |
bitbake: hig/propertydialog: new class added for the property windows.
this covers functionality for : recipe selection page
package selection page
information dialogs
(Bitbake rev: 82cb844c92fcc71cefe7d7ddc110523c62185e9e)
Signed-off-by: Andrei Dinu <andrei.adrianx.dinu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig/propertydialog.py | 347 |
1 files changed, 347 insertions, 0 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hig/propertydialog.py b/bitbake/lib/bb/ui/crumbs/hig/propertydialog.py new file mode 100644 index 0000000000..d68ef3a167 --- /dev/null +++ b/bitbake/lib/bb/ui/crumbs/hig/propertydialog.py | |||
@@ -0,0 +1,347 @@ | |||
1 | # | ||
2 | # BitBake Graphical GTK User Interface | ||
3 | # | ||
4 | # Copyright (C) 2011-2013 Intel Corporation | ||
5 | # | ||
6 | # Authored by Andrei Dinu <andrei.adrianx.dinu@intel.com> | ||
7 | # | ||
8 | # This program is free software; you can redistribute it and/or modify | ||
9 | # it under the terms of the GNU General Public License version 2 as | ||
10 | # published by the Free Software Foundation. | ||
11 | # | ||
12 | # This program is distributed in the hope that it will be useful, | ||
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | # GNU General Public License for more details. | ||
16 | # | ||
17 | # You should have received a copy of the GNU General Public License along | ||
18 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
20 | |||
21 | import string | ||
22 | import gtk | ||
23 | import gobject | ||
24 | import os | ||
25 | import tempfile | ||
26 | import glib | ||
27 | from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog | ||
28 | from bb.ui.crumbs.hig.settingsuihelper import SettingsUIHelper | ||
29 | from bb.ui.crumbs.hig.crumbsmessagedialog import CrumbsMessageDialog | ||
30 | from bb.ui.crumbs.hig.layerselectiondialog import LayerSelectionDialog | ||
31 | |||
32 | """ | ||
33 | The following are convenience classes for implementing GNOME HIG compliant | ||
34 | BitBake GUI's | ||
35 | In summary: spacing = 12px, border-width = 6px | ||
36 | """ | ||
37 | |||
38 | class PropertyDialog(CrumbsDialog): | ||
39 | |||
40 | def __init__(self, title, parent, information, flags, buttons=None): | ||
41 | |||
42 | super(PropertyDialog, self).__init__(title, parent, flags, buttons) | ||
43 | |||
44 | self.properties = information | ||
45 | |||
46 | if len(self.properties) == 10: | ||
47 | self.create_recipe_visual_elements() | ||
48 | elif len(self.properties) == 4: | ||
49 | self.create_package_visual_elements() | ||
50 | else: | ||
51 | self.create_information_visual_elements() | ||
52 | |||
53 | |||
54 | def create_information_visual_elements(self): | ||
55 | |||
56 | HOB_ICON_BASE_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), ("icons/")) | ||
57 | ICON_PACKAGES_DISPLAY_FILE = os.path.join(HOB_ICON_BASE_DIR, ('info/info_display.png')) | ||
58 | |||
59 | self.table = gtk.Table(2,2,False) | ||
60 | self.table.set_row_spacings(0) | ||
61 | self.table.set_col_spacings(0) | ||
62 | |||
63 | self.image = gtk.Image() | ||
64 | self.image.set_from_file(ICON_PACKAGES_DISPLAY_FILE) | ||
65 | self.image.set_property("xalign",0) | ||
66 | #self.vbox.add(self.image) | ||
67 | |||
68 | image_info = self.properties.split("*")[0] | ||
69 | info = self.properties.split("*")[1] | ||
70 | |||
71 | vbox = gtk.VBox(True, spacing=0) | ||
72 | |||
73 | self.label_short = gtk.Label() | ||
74 | self.label_short.set_line_wrap(False) | ||
75 | self.label_short.set_markup(" " + image_info) | ||
76 | self.label_short.set_property("xalign", 0) | ||
77 | |||
78 | self.info_label = gtk.Label() | ||
79 | self.info_label.set_line_wrap(True) | ||
80 | self.info_label.set_markup(info) | ||
81 | self.info_label.set_property("xalign", 1) | ||
82 | |||
83 | self.table.attach(self.image, 0,1,0,1, xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL) | ||
84 | self.table.attach(self.label_short, 0,1,0,1, xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL) | ||
85 | self.table.attach(self.info_label, 0,1,1,2, xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL) | ||
86 | |||
87 | self.vbox.add(self.table) | ||
88 | |||
89 | |||
90 | def create_package_visual_elements(self): | ||
91 | |||
92 | name = self.properties['name'] | ||
93 | binb = self.properties['binb'] | ||
94 | size = self.properties['size'] | ||
95 | recipe = self.properties['recipe'] | ||
96 | |||
97 | #cleaning out the recipe variable | ||
98 | recipe = recipe.split("+")[0] | ||
99 | |||
100 | vbox = gtk.VBox(True,spacing = 0) | ||
101 | |||
102 | ###################################### NAME ROW + COL ################################# | ||
103 | |||
104 | self.label_short = gtk.Label() | ||
105 | self.label_short.set_size_request(300,-1) | ||
106 | self.label_short.set_selectable(True) | ||
107 | self.label_short.set_line_wrap(True) | ||
108 | self.label_short.set_markup("<span weight=\"bold\">Name: </span>" + name) | ||
109 | self.label_short.set_property("xalign", 0) | ||
110 | |||
111 | self.vbox.add(self.label_short) | ||
112 | |||
113 | ###################################### SIZE ROW + COL ###################################### | ||
114 | |||
115 | self.label_short = gtk.Label() | ||
116 | self.label_short.set_size_request(300,-1) | ||
117 | self.label_short.set_selectable(True) | ||
118 | self.label_short.set_line_wrap(True) | ||
119 | self.label_short.set_markup("<span weight=\"bold\">Size: </span>" + size) | ||
120 | self.label_short.set_property("xalign", 0) | ||
121 | |||
122 | self.vbox.add(self.label_short) | ||
123 | |||
124 | ##################################### RECIPE ROW + COL ######################################### | ||
125 | |||
126 | self.label_short = gtk.Label() | ||
127 | self.label_short.set_size_request(300,-1) | ||
128 | self.label_short.set_selectable(True) | ||
129 | self.label_short.set_line_wrap(True) | ||
130 | self.label_short.set_markup("<span weight=\"bold\">Recipe: </span>" + recipe) | ||
131 | self.label_short.set_property("xalign", 0) | ||
132 | |||
133 | self.vbox.add(self.label_short) | ||
134 | |||
135 | ##################################### BINB ROW + COL ####################################### | ||
136 | |||
137 | if binb != '': | ||
138 | self.label_short = gtk.Label() | ||
139 | self.label_short.set_selectable(True) | ||
140 | self.label_short.set_line_wrap(True) | ||
141 | self.label_short.set_markup("<span weight=\"bold\">Brought in by: </span>") | ||
142 | self.label_short.set_property("xalign", 0) | ||
143 | |||
144 | self.label_info = gtk.Label() | ||
145 | self.label_info.set_size_request(300,-1) | ||
146 | self.label_info.set_selectable(True) | ||
147 | self.label_info.set_line_wrap(True) | ||
148 | self.label_info.set_markup(binb) | ||
149 | self.label_info.set_property("xalign", 0) | ||
150 | |||
151 | self.vbox.add(self.label_short) | ||
152 | self.vbox.add(self.label_info) | ||
153 | |||
154 | self.vbox.show_all() | ||
155 | |||
156 | |||
157 | def create_recipe_visual_elements(self): | ||
158 | |||
159 | summary = self.properties['summary'] | ||
160 | name = self.properties['name'] | ||
161 | version = self.properties['version'] | ||
162 | revision = self.properties['revision'] | ||
163 | binb = self.properties['binb'] | ||
164 | group = self.properties['group'] | ||
165 | license = self.properties['license'] | ||
166 | homepage = self.properties['homepage'] | ||
167 | bugtracker = self.properties['bugtracker'] | ||
168 | description = self.properties['description'] | ||
169 | |||
170 | #cleaning out the version variable and also the summary | ||
171 | version = version.split(":")[1] | ||
172 | if len(version) > 30: | ||
173 | version = version.split("+")[0] | ||
174 | else: | ||
175 | version = version.split("-")[0] | ||
176 | license = license.replace("&" , "and") | ||
177 | if (homepage == ''): | ||
178 | homepage = 'unknown' | ||
179 | if (bugtracker == ''): | ||
180 | bugtracker = 'unknown' | ||
181 | summary = summary.split("+")[0] | ||
182 | |||
183 | #calculating the rows needed for the table | ||
184 | binb_items_count = len(binb.split(',')) | ||
185 | binb_items = binb.split(',') | ||
186 | |||
187 | vbox = gtk.VBox(True,spacing = 0) | ||
188 | |||
189 | ######################################## SUMMARY LABEL ######################################### | ||
190 | |||
191 | if summary != '': | ||
192 | self.label_short = gtk.Label() | ||
193 | self.label_short.set_size_request(300,-1) | ||
194 | self.label_short.set_selectable(True) | ||
195 | self.label_short.set_line_wrap(True) | ||
196 | self.label_short.set_markup("<b>" + summary + "</b>") | ||
197 | self.label_short.set_property("xalign", 0) | ||
198 | |||
199 | self.vbox.pack_start(self.label_short, expand=False, fill=False, padding=0) | ||
200 | |||
201 | ########################################## NAME ROW + COL ####################################### | ||
202 | |||
203 | self.label_short = gtk.Label() | ||
204 | self.label_short.set_size_request(300,-1) | ||
205 | self.label_short.set_selectable(True) | ||
206 | self.label_short.set_line_wrap(True) | ||
207 | self.label_short.set_markup("<span weight=\"bold\">Name: </span>" + name) | ||
208 | self.label_short.set_property("xalign", 0) | ||
209 | |||
210 | self.vbox.add(self.label_short) | ||
211 | |||
212 | ####################################### VERSION ROW + COL #################################### | ||
213 | |||
214 | self.label_short = gtk.Label() | ||
215 | self.label_short.set_size_request(300,-1) | ||
216 | self.label_short.set_selectable(True) | ||
217 | self.label_short.set_line_wrap(True) | ||
218 | self.label_short.set_markup("<span weight=\"bold\">Version: </span>" + version) | ||
219 | self.label_short.set_property("xalign", 0) | ||
220 | |||
221 | self.vbox.add(self.label_short) | ||
222 | |||
223 | ##################################### REVISION ROW + COL ##################################### | ||
224 | |||
225 | self.label_short = gtk.Label() | ||
226 | self.label_short.set_size_request(300,-1) | ||
227 | self.label_short.set_line_wrap(True) | ||
228 | self.label_short.set_selectable(True) | ||
229 | self.label_short.set_markup("<span weight=\"bold\">Revision: </span>" + revision) | ||
230 | self.label_short.set_property("xalign", 0) | ||
231 | |||
232 | self.vbox.add(self.label_short) | ||
233 | |||
234 | ################################## GROUP ROW + COL ############################################ | ||
235 | |||
236 | self.label_short = gtk.Label() | ||
237 | self.label_short.set_size_request(300,-1) | ||
238 | self.label_short.set_selectable(True) | ||
239 | self.label_short.set_line_wrap(True) | ||
240 | self.label_short.set_markup("<span weight=\"bold\">Group: </span>" + group) | ||
241 | self.label_short.set_property("xalign", 0) | ||
242 | |||
243 | self.vbox.add(self.label_short) | ||
244 | |||
245 | ################################# HOMEPAGE ROW + COL ############################################ | ||
246 | |||
247 | if homepage != 'unknown': | ||
248 | self.label_info = gtk.Label() | ||
249 | self.label_info.set_selectable(True) | ||
250 | self.label_info.set_line_wrap(True) | ||
251 | if len(homepage) > 35: | ||
252 | self.label_info.set_markup("<a href=\"" + homepage + "\">" + homepage[0:35] + "..." + "</a>") | ||
253 | else: | ||
254 | self.label_info.set_markup("<a href=\"" + homepage + "\">" + homepage[0:60] + "</a>") | ||
255 | |||
256 | self.label_info.set_property("xalign", 0) | ||
257 | |||
258 | self.label_short = gtk.Label() | ||
259 | self.label_short.set_size_request(300,-1) | ||
260 | self.label_short.set_selectable(True) | ||
261 | self.label_short.set_line_wrap(True) | ||
262 | self.label_short.set_markup("<b>Homepage: </b>") | ||
263 | self.label_short.set_property("xalign", 0) | ||
264 | |||
265 | self.vbox.add(self.label_short) | ||
266 | self.vbox.add(self.label_info) | ||
267 | |||
268 | ################################# BUGTRACKER ROW + COL ########################################### | ||
269 | |||
270 | if bugtracker != 'unknown': | ||
271 | self.label_info = gtk.Label() | ||
272 | self.label_info.set_selectable(True) | ||
273 | self.label_info.set_line_wrap(True) | ||
274 | if len(bugtracker) > 35: | ||
275 | self.label_info.set_markup("<a href=\"" + bugtracker + "\">" + bugtracker[0:35] + "..." + "</a>") | ||
276 | else: | ||
277 | self.label_info.set_markup("<a href=\"" + bugtracker + "\">" + bugtracker[0:60] + "</a>") | ||
278 | self.label_info.set_property("xalign", 0) | ||
279 | |||
280 | self.label_short = gtk.Label() | ||
281 | self.label_short.set_size_request(300,-1) | ||
282 | self.label_short.set_selectable(True) | ||
283 | self.label_short.set_line_wrap(True) | ||
284 | self.label_short.set_markup("<b>Bugtracker: </b>") | ||
285 | self.label_short.set_property("xalign", 0) | ||
286 | |||
287 | self.vbox.add(self.label_short) | ||
288 | self.vbox.add(self.label_info) | ||
289 | |||
290 | ################################# LICENSE ROW + COL ############################################ | ||
291 | |||
292 | self.label_info = gtk.Label() | ||
293 | self.label_info.set_size_request(300,-1) | ||
294 | self.label_info.set_selectable(True) | ||
295 | self.label_info.set_line_wrap(True) | ||
296 | self.label_info.set_markup(license) | ||
297 | self.label_info.set_property("xalign", 0) | ||
298 | |||
299 | self.label_short = gtk.Label() | ||
300 | self.label_short.set_selectable(True) | ||
301 | self.label_short.set_line_wrap(True) | ||
302 | self.label_short.set_markup("<span weight=\"bold\">License: </span>") | ||
303 | self.label_short.set_property("xalign", 0) | ||
304 | |||
305 | self.vbox.add(self.label_short) | ||
306 | self.vbox.add(self.label_info) | ||
307 | |||
308 | ################################### BINB ROW+COL ############################################# | ||
309 | |||
310 | if binb != '': | ||
311 | self.label_short = gtk.Label() | ||
312 | self.label_short.set_selectable(True) | ||
313 | self.label_short.set_line_wrap(True) | ||
314 | self.label_short.set_markup("<span weight=\"bold\">Brought in by: </span>") | ||
315 | self.label_short.set_property("xalign", 0) | ||
316 | |||
317 | self.label_info = gtk.Label() | ||
318 | self.label_info.set_size_request(300,-1) | ||
319 | self.label_info.set_selectable(True) | ||
320 | self.label_info.set_markup(binb) | ||
321 | self.label_info.set_property("xalign", 0) | ||
322 | self.label_info.set_line_wrap(True) | ||
323 | |||
324 | self.vbox.add(self.label_short) | ||
325 | self.vbox.add(self.label_info) | ||
326 | |||
327 | ################################ DESCRIPTION TAG ROW ################################################# | ||
328 | |||
329 | self.label_short = gtk.Label() | ||
330 | self.label_short.set_line_wrap(True) | ||
331 | self.label_short.set_markup("<span weight=\"bold\">Description </span>") | ||
332 | self.label_short.set_property("xalign", 0) | ||
333 | self.vbox.add(self.label_short) | ||
334 | |||
335 | ################################ DESCRIPTION INFORMATION ROW ########################################## | ||
336 | |||
337 | hbox = gtk.HBox(True,spacing = 0) | ||
338 | |||
339 | self.label_short = gtk.Label() | ||
340 | self.label_short.set_size_request(300,-1) | ||
341 | self.label_short.set_selectable(True) | ||
342 | self.label_short.set_text(description) | ||
343 | self.label_short.set_line_wrap(True) | ||
344 | self.label_short.set_property("xalign", 0) | ||
345 | self.vbox.add(self.label_short) | ||
346 | |||
347 | self.vbox.show_all() | ||