summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/crumbs/hig/propertydialog.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/hig/propertydialog.py')
-rw-r--r--bitbake/lib/bb/ui/crumbs/hig/propertydialog.py451
1 files changed, 451 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..bc40741bf2
--- /dev/null
+++ b/bitbake/lib/bb/ui/crumbs/hig/propertydialog.py
@@ -0,0 +1,451 @@
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
21import string
22import gtk
23import gobject
24import os
25import tempfile
26import glib
27from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog
28from bb.ui.crumbs.hig.settingsuihelper import SettingsUIHelper
29from bb.ui.crumbs.hig.crumbsmessagedialog import CrumbsMessageDialog
30from bb.ui.crumbs.hig.layerselectiondialog import LayerSelectionDialog
31
32"""
33The following are convenience classes for implementing GNOME HIG compliant
34BitBake GUI's
35In summary: spacing = 12px, border-width = 6px
36"""
37
38class 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) == 5:
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.set_resizable(False)
60
61 self.table = gtk.Table(1,1,False)
62 self.table.set_row_spacings(0)
63 self.table.set_col_spacings(0)
64
65 self.image = gtk.Image()
66 self.image.set_from_file(ICON_PACKAGES_DISPLAY_FILE)
67 self.image.set_property("xalign",0)
68 #self.vbox.add(self.image)
69
70 image_info = self.properties.split("*")[0]
71 info = self.properties.split("*")[1]
72
73 vbox = gtk.VBox(True, spacing=30)
74
75 self.label_short = gtk.Label()
76 self.label_short.set_line_wrap(False)
77 self.label_short.set_markup(image_info)
78 self.label_short.set_property("xalign", 0)
79
80 self.info_label = gtk.Label()
81 self.info_label.set_line_wrap(True)
82 self.info_label.set_markup(info)
83 self.info_label.set_property("yalign", 0.5)
84
85 self.table.attach(self.image, 0,1,0,1, xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL,xpadding=5,ypadding=5)
86 self.table.attach(self.label_short, 0,1,0,1, xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL,xpadding=40,ypadding=5)
87 self.table.attach(self.info_label, 0,1,1,2, xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL,xpadding=40,ypadding=10)
88
89 self.vbox.add(self.table)
90 self.connect('delete-event', lambda w, e: self.destroy() or True)
91
92 def treeViewTooltip( self, widget, e, tooltips, cell, emptyText="" ):
93 try:
94 (path,col,x,y) = widget.get_path_at_pos( int(e.x), int(e.y) )
95 it = widget.get_model().get_iter(path)
96 value = widget.get_model().get_value(it,cell)
97 if value in self.tooltip_items:
98 tooltips.set_tip(widget, self.tooltip_items[value])
99 tooltips.enable()
100 else:
101 tooltips.set_tip(widget, emptyText)
102 except:
103 tooltips.set_tip(widget, emptyText)
104
105
106 def create_package_visual_elements(self):
107
108 name = self.properties['name']
109 binb = self.properties['binb']
110 size = self.properties['size']
111 recipe = self.properties['recipe']
112 file_list = self.properties['files_list']
113
114 file_list = file_list.strip("{}'")
115 files_temp = ''
116 paths_temp = ''
117 files_binb = []
118 paths_binb = []
119
120 self.tooltip_items = {}
121
122 self.set_resizable(False)
123
124 #cleaning out the recipe variable
125 recipe = recipe.split("+")[0]
126
127 vbox = gtk.VBox(True,spacing = 0)
128
129 ###################################### NAME ROW + COL #################################
130
131 self.label_short = gtk.Label()
132 self.label_short.set_size_request(300,-1)
133 self.label_short.set_selectable(True)
134 self.label_short.set_line_wrap(True)
135 self.label_short.set_markup("<span weight=\"bold\">Name: </span>" + name)
136 self.label_short.set_property("xalign", 0)
137
138 self.vbox.add(self.label_short)
139
140 ###################################### SIZE ROW + COL ######################################
141
142 self.label_short = gtk.Label()
143 self.label_short.set_size_request(300,-1)
144 self.label_short.set_selectable(True)
145 self.label_short.set_line_wrap(True)
146 self.label_short.set_markup("<span weight=\"bold\">Size: </span>" + size)
147 self.label_short.set_property("xalign", 0)
148
149 self.vbox.add(self.label_short)
150
151 ##################################### RECIPE ROW + COL #########################################
152
153 self.label_short = gtk.Label()
154 self.label_short.set_size_request(300,-1)
155 self.label_short.set_selectable(True)
156 self.label_short.set_line_wrap(True)
157 self.label_short.set_markup("<span weight=\"bold\">Recipe: </span>" + recipe)
158 self.label_short.set_property("xalign", 0)
159
160 self.vbox.add(self.label_short)
161
162 ##################################### BINB ROW + COL #######################################
163
164 if binb != '':
165 self.label_short = gtk.Label()
166 self.label_short.set_selectable(True)
167 self.label_short.set_line_wrap(True)
168 self.label_short.set_markup("<span weight=\"bold\">Brought in by: </span>")
169 self.label_short.set_property("xalign", 0)
170
171 self.label_info = gtk.Label()
172 self.label_info.set_size_request(300,-1)
173 self.label_info.set_selectable(True)
174 self.label_info.set_line_wrap(True)
175 self.label_info.set_markup(binb)
176 self.label_info.set_property("xalign", 0)
177
178 self.vbox.add(self.label_short)
179 self.vbox.add(self.label_info)
180
181 #################################### FILES BROUGHT BY PACKAGES ###################################
182
183 if file_list != '':
184
185 self.textWindow = gtk.ScrolledWindow()
186 self.textWindow.set_shadow_type(gtk.SHADOW_IN)
187 self.textWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
188 self.textWindow.set_size_request(100, 170)
189
190 sstatemirrors_store = gtk.ListStore(str)
191
192 self.sstatemirrors_tv = gtk.TreeView()
193 self.sstatemirrors_tv.set_rules_hint(True)
194 self.sstatemirrors_tv.set_headers_visible(True)
195 self.textWindow.add(self.sstatemirrors_tv)
196
197 self.cell1 = gtk.CellRendererText()
198 col1 = gtk.TreeViewColumn('Package files', self.cell1)
199 col1.set_cell_data_func(self.cell1, self.regex_field)
200 self.sstatemirrors_tv.append_column(col1)
201
202 for items in file_list.split(']'):
203 if len(items) > 1:
204 paths_temp = items.split(":")[0]
205 paths_binb.append(paths_temp.strip(" ,'"))
206 files_temp = items.split(":")[1]
207 files_binb.append(files_temp.strip(" ['"))
208
209 unsorted_list = []
210
211 for items in range(len(paths_binb)):
212 if len(files_binb[items]) > 1:
213 for aduse in (files_binb[items].split(",")):
214 unsorted_list.append(paths_binb[items].split(name)[len(paths_binb[items].split(name))-1] + '/' + aduse.strip(" '"))
215
216
217 unsorted_list.sort()
218 for items in unsorted_list:
219 temp = items
220 while len(items) > 35:
221 items = items[:len(items)/2] + "" + items[len(items)/2+1:]
222 if len(items) == 35:
223 items = items[:len(items)/2] + "..." + items[len(items)/2+3:]
224 self.tooltip_items[items] = temp
225
226 sstatemirrors_store.append([str(items)])
227
228
229 self.sstatemirrors_tv.set_model(sstatemirrors_store)
230
231 tips = gtk.Tooltips()
232 tips.set_tip(self.sstatemirrors_tv, "")
233 self.sstatemirrors_tv.connect("motion-notify-event", self.treeViewTooltip, tips, 0)
234 self.sstatemirrors_tv.set_events(gtk.gdk.POINTER_MOTION_MASK)
235
236 self.vbox.add(self.textWindow)
237
238 self.vbox.show_all()
239
240
241 def regex_field(self, column, cell, model, iter):
242 cell.set_property('text', model.get_value(iter, 0))
243 return
244
245
246 def create_recipe_visual_elements(self):
247
248 summary = self.properties['summary']
249 name = self.properties['name']
250 version = self.properties['version']
251 revision = self.properties['revision']
252 binb = self.properties['binb']
253 group = self.properties['group']
254 license = self.properties['license']
255 homepage = self.properties['homepage']
256 bugtracker = self.properties['bugtracker']
257 description = self.properties['description']
258
259 self.set_resizable(False)
260
261 #cleaning out the version variable and also the summary
262 version = version.split(":")[1]
263 if len(version) > 30:
264 version = version.split("+")[0]
265 else:
266 version = version.split("-")[0]
267 license = license.replace("&" , "and")
268 if (homepage == ''):
269 homepage = 'unknown'
270 if (bugtracker == ''):
271 bugtracker = 'unknown'
272 summary = summary.split("+")[0]
273
274 #calculating the rows needed for the table
275 binb_items_count = len(binb.split(','))
276 binb_items = binb.split(',')
277
278 vbox = gtk.VBox(False,spacing = 0)
279
280 ######################################## SUMMARY LABEL #########################################
281
282 if summary != '':
283 self.label_short = gtk.Label()
284 self.label_short.set_width_chars(37)
285 self.label_short.set_selectable(True)
286 self.label_short.set_line_wrap(True)
287 self.label_short.set_markup("<b>" + summary + "</b>")
288 self.label_short.set_property("xalign", 0)
289
290 self.vbox.add(self.label_short)
291
292 ########################################## NAME ROW + COL #######################################
293
294 self.label_short = gtk.Label()
295 self.label_short.set_selectable(True)
296 self.label_short.set_line_wrap(True)
297 self.label_short.set_markup("<span weight=\"bold\">Name: </span>" + name)
298 self.label_short.set_property("xalign", 0)
299
300 self.vbox.add(self.label_short)
301
302 ####################################### VERSION ROW + COL ####################################
303
304 self.label_short = gtk.Label()
305 self.label_short.set_selectable(True)
306 self.label_short.set_line_wrap(True)
307 self.label_short.set_markup("<span weight=\"bold\">Version: </span>" + version)
308 self.label_short.set_property("xalign", 0)
309
310 self.vbox.add(self.label_short)
311
312 ##################################### REVISION ROW + COL #####################################
313
314 self.label_short = gtk.Label()
315 self.label_short.set_line_wrap(True)
316 self.label_short.set_selectable(True)
317 self.label_short.set_markup("<span weight=\"bold\">Revision: </span>" + revision)
318 self.label_short.set_property("xalign", 0)
319
320 self.vbox.add(self.label_short)
321
322 ################################## GROUP ROW + COL ############################################
323
324 self.label_short = gtk.Label()
325 self.label_short.set_selectable(True)
326 self.label_short.set_line_wrap(True)
327 self.label_short.set_markup("<span weight=\"bold\">Group: </span>" + group)
328 self.label_short.set_property("xalign", 0)
329
330 self.vbox.add(self.label_short)
331
332 ################################# HOMEPAGE ROW + COL ############################################
333
334 if homepage != 'unknown':
335 self.label_info = gtk.Label()
336 self.label_info.set_selectable(True)
337 self.label_info.set_line_wrap(True)
338 if len(homepage) > 35:
339 self.label_info.set_markup("<a href=\"" + homepage + "\">" + homepage[0:35] + "..." + "</a>")
340 else:
341 self.label_info.set_markup("<a href=\"" + homepage + "\">" + homepage[0:60] + "</a>")
342
343 self.label_info.set_property("xalign", 0)
344
345 self.label_short = gtk.Label()
346 self.label_short.set_selectable(True)
347 self.label_short.set_line_wrap(True)
348 self.label_short.set_markup("<b>Homepage: </b>")
349 self.label_short.set_property("xalign", 0)
350
351 self.vbox.add(self.label_short)
352 self.vbox.add(self.label_info)
353
354 ################################# BUGTRACKER ROW + COL ###########################################
355
356 if bugtracker != 'unknown':
357 self.label_info = gtk.Label()
358 self.label_info.set_selectable(True)
359 self.label_info.set_line_wrap(True)
360 if len(bugtracker) > 35:
361 self.label_info.set_markup("<a href=\"" + bugtracker + "\">" + bugtracker[0:35] + "..." + "</a>")
362 else:
363 self.label_info.set_markup("<a href=\"" + bugtracker + "\">" + bugtracker[0:60] + "</a>")
364 self.label_info.set_property("xalign", 0)
365
366 self.label_short = gtk.Label()
367 self.label_short.set_selectable(True)
368 self.label_short.set_line_wrap(True)
369 self.label_short.set_markup("<b>Bugtracker: </b>")
370 self.label_short.set_property("xalign", 0)
371
372 self.vbox.add(self.label_short)
373 self.vbox.add(self.label_info)
374
375 ################################# LICENSE ROW + COL ############################################
376
377 self.label_info = gtk.Label()
378 self.label_info.set_selectable(True)
379 self.label_info.set_line_wrap(True)
380 self.label_info.set_markup(license)
381 self.label_info.set_property("xalign", 0)
382
383 self.label_short = gtk.Label()
384 self.label_short.set_selectable(True)
385 self.label_short.set_line_wrap(True)
386 self.label_short.set_markup("<span weight=\"bold\">License: </span>")
387 self.label_short.set_property("xalign", 0)
388
389 self.vbox.add(self.label_short)
390 self.vbox.add(self.label_info)
391
392 ################################### BINB ROW+COL #############################################
393
394 if binb != '':
395 self.label_short = gtk.Label()
396 self.label_short.set_selectable(True)
397 self.label_short.set_line_wrap(True)
398 self.label_short.set_markup("<span weight=\"bold\">Brought in by: </span>")
399 self.label_short.set_property("xalign", 0)
400 self.vbox.add(self.label_short)
401 self.label_info = gtk.Label()
402 self.label_info.set_selectable(True)
403 self.label_info.set_width_chars(36)
404 if len(binb) > 200:
405 scrolled_window = gtk.ScrolledWindow()
406 scrolled_window.set_policy(gtk.POLICY_NEVER,gtk.POLICY_ALWAYS)
407 scrolled_window.set_size_request(100,100)
408 self.label_info.set_markup(binb)
409 self.label_info.set_padding(6,6)
410 self.label_info.set_alignment(0,0)
411 self.label_info.set_line_wrap(True)
412 scrolled_window.add_with_viewport(self.label_info)
413 self.vbox.add(scrolled_window)
414 else:
415 self.label_info.set_markup(binb)
416 self.label_info.set_property("xalign", 0)
417 self.label_info.set_line_wrap(True)
418 self.vbox.add(self.label_info)
419
420 ################################ DESCRIPTION TAG ROW #################################################
421
422 self.label_short = gtk.Label()
423 self.label_short.set_line_wrap(True)
424 self.label_short.set_markup("<span weight=\"bold\">Description </span>")
425 self.label_short.set_property("xalign", 0)
426 self.vbox.add(self.label_short)
427
428 ################################ DESCRIPTION INFORMATION ROW ##########################################
429
430 hbox = gtk.HBox(True,spacing = 0)
431
432 self.label_short = gtk.Label()
433 self.label_short.set_selectable(True)
434 self.label_short.set_width_chars(36)
435 if len(description) > 200:
436 scrolled_window = gtk.ScrolledWindow()
437 scrolled_window.set_policy(gtk.POLICY_NEVER,gtk.POLICY_ALWAYS)
438 scrolled_window.set_size_request(100,100)
439 self.label_short.set_markup(description)
440 self.label_short.set_padding(6,6)
441 self.label_short.set_alignment(0,0)
442 self.label_short.set_line_wrap(True)
443 scrolled_window.add_with_viewport(self.label_short)
444 self.vbox.add(scrolled_window)
445 else:
446 self.label_short.set_markup(description)
447 self.label_short.set_property("xalign", 0)
448 self.label_short.set_line_wrap(True)
449 self.vbox.add(self.label_short)
450
451 self.vbox.show_all()