diff options
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/hobpages.py')
-rwxr-xr-x | bitbake/lib/bb/ui/crumbs/hobpages.py | 128 |
1 files changed, 0 insertions, 128 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hobpages.py b/bitbake/lib/bb/ui/crumbs/hobpages.py deleted file mode 100755 index 0fd3598c3a..0000000000 --- a/bitbake/lib/bb/ui/crumbs/hobpages.py +++ /dev/null | |||
@@ -1,128 +0,0 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # | ||
3 | # BitBake Graphical GTK User Interface | ||
4 | # | ||
5 | # Copyright (C) 2012 Intel Corporation | ||
6 | # | ||
7 | # Authored by Dongxiao Xu <dongxiao.xu@intel.com> | ||
8 | # Authored by Shane Wang <shane.wang@intel.com> | ||
9 | # | ||
10 | # This program is free software; you can redistribute it and/or modify | ||
11 | # it under the terms of the GNU General Public License version 2 as | ||
12 | # published by the Free Software Foundation. | ||
13 | # | ||
14 | # This program is distributed in the hope that it will be useful, | ||
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | # GNU General Public License for more details. | ||
18 | # | ||
19 | # You should have received a copy of the GNU General Public License along | ||
20 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
22 | |||
23 | import gtk | ||
24 | from bb.ui.crumbs.hobcolor import HobColors | ||
25 | from bb.ui.crumbs.hobwidget import hwc | ||
26 | |||
27 | # | ||
28 | # HobPage: the super class for all Hob-related pages | ||
29 | # | ||
30 | class HobPage (gtk.VBox): | ||
31 | |||
32 | def __init__(self, builder, title = None): | ||
33 | super(HobPage, self).__init__(False, 0) | ||
34 | self.builder = builder | ||
35 | self.builder_width, self.builder_height = self.builder.size_request() | ||
36 | |||
37 | if not title: | ||
38 | self.title = "Hob -- Image Creator" | ||
39 | else: | ||
40 | self.title = title | ||
41 | self.title_label = gtk.Label() | ||
42 | |||
43 | self.box_group_area = gtk.VBox(False, 12) | ||
44 | self.box_group_area.set_size_request(self.builder_width - 73 - 73, self.builder_height - 88 - 15 - 15) | ||
45 | self.group_align = gtk.Alignment(xalign = 0, yalign=0.5, xscale=1, yscale=1) | ||
46 | self.group_align.set_padding(15, 15, 73, 73) | ||
47 | self.group_align.add(self.box_group_area) | ||
48 | self.box_group_area.set_homogeneous(False) | ||
49 | |||
50 | def set_title(self, title): | ||
51 | self.title = title | ||
52 | self.title_label.set_markup("<span size='x-large'>%s</span>" % self.title) | ||
53 | |||
54 | def add_onto_top_bar(self, widget = None, padding = 0): | ||
55 | # the top button occupies 1/7 of the page height | ||
56 | # setup an event box | ||
57 | eventbox = gtk.EventBox() | ||
58 | style = eventbox.get_style().copy() | ||
59 | style.bg[gtk.STATE_NORMAL] = eventbox.get_colormap().alloc_color(HobColors.LIGHT_GRAY, False, False) | ||
60 | eventbox.set_style(style) | ||
61 | eventbox.set_size_request(-1, 88) | ||
62 | |||
63 | hbox = gtk.HBox() | ||
64 | |||
65 | self.title_label = gtk.Label() | ||
66 | self.title_label.set_markup("<span size='x-large'>%s</span>" % self.title) | ||
67 | hbox.pack_start(self.title_label, expand=False, fill=False, padding=20) | ||
68 | |||
69 | if widget: | ||
70 | # add the widget in the event box | ||
71 | hbox.pack_end(widget, expand=False, fill=False, padding=padding) | ||
72 | eventbox.add(hbox) | ||
73 | |||
74 | return eventbox | ||
75 | |||
76 | def span_tag(self, size="medium", weight="normal", forground="#1c1c1c"): | ||
77 | span_tag = "weight='%s' foreground='%s' size='%s'" % (weight, forground, size) | ||
78 | return span_tag | ||
79 | |||
80 | def append_toolbar_button(self, toolbar, buttonname, icon_disp, icon_hovor, tip, cb): | ||
81 | # Create a button and append it on the toolbar according to button name | ||
82 | icon = gtk.Image() | ||
83 | icon_display = icon_disp | ||
84 | icon_hover = icon_hovor | ||
85 | pix_buffer = gtk.gdk.pixbuf_new_from_file(icon_display) | ||
86 | icon.set_from_pixbuf(pix_buffer) | ||
87 | tip_text = tip | ||
88 | button = toolbar.append_item(buttonname, tip, None, icon, cb) | ||
89 | return button | ||
90 | |||
91 | @staticmethod | ||
92 | def _size_to_string(size): | ||
93 | try: | ||
94 | if not size: | ||
95 | size_str = "0 B" | ||
96 | else: | ||
97 | if len(str(int(size))) > 6: | ||
98 | size_str = '%.1f' % (size*1.0/(1024*1024)) + ' MB' | ||
99 | elif len(str(int(size))) > 3: | ||
100 | size_str = '%.1f' % (size*1.0/1024) + ' KB' | ||
101 | else: | ||
102 | size_str = str(size) + ' B' | ||
103 | except: | ||
104 | size_str = "0 B" | ||
105 | return size_str | ||
106 | |||
107 | @staticmethod | ||
108 | def _string_to_size(str_size): | ||
109 | try: | ||
110 | if not str_size: | ||
111 | size = 0 | ||
112 | else: | ||
113 | unit = str_size.split() | ||
114 | if len(unit) > 1: | ||
115 | if unit[1] == 'MB': | ||
116 | size = float(unit[0])*1024*1024 | ||
117 | elif unit[1] == 'KB': | ||
118 | size = float(unit[0])*1024 | ||
119 | elif unit[1] == 'B': | ||
120 | size = float(unit[0]) | ||
121 | else: | ||
122 | size = 0 | ||
123 | else: | ||
124 | size = float(unit[0]) | ||
125 | except: | ||
126 | size = 0 | ||
127 | return size | ||
128 | |||