diff options
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/hig')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig/__init__.py | 0 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig/crumbsdialog.py | 44 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig/crumbsmessagedialog.py | 70 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig/deployimagedialog.py | 219 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig/imageselectiondialog.py | 172 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig/layerselectiondialog.py | 298 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig/propertydialog.py | 437 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig/settingsuihelper.py | 122 |
8 files changed, 0 insertions, 1362 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hig/__init__.py b/bitbake/lib/bb/ui/crumbs/hig/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 --- a/bitbake/lib/bb/ui/crumbs/hig/__init__.py +++ /dev/null | |||
diff --git a/bitbake/lib/bb/ui/crumbs/hig/crumbsdialog.py b/bitbake/lib/bb/ui/crumbs/hig/crumbsdialog.py deleted file mode 100644 index 73b9234c27..0000000000 --- a/bitbake/lib/bb/ui/crumbs/hig/crumbsdialog.py +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | # | ||
2 | # BitBake Graphical GTK User Interface | ||
3 | # | ||
4 | # Copyright (C) 2011-2012 Intel Corporation | ||
5 | # | ||
6 | # Authored by Joshua Lock <josh@linux.intel.com> | ||
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 | |||
25 | """ | ||
26 | The following are convenience classes for implementing GNOME HIG compliant | ||
27 | BitBake GUI's | ||
28 | In summary: spacing = 12px, border-width = 6px | ||
29 | """ | ||
30 | |||
31 | class CrumbsDialog(gtk.Dialog): | ||
32 | """ | ||
33 | A GNOME HIG compliant dialog widget. | ||
34 | Add buttons with gtk.Dialog.add_button or gtk.Dialog.add_buttons | ||
35 | """ | ||
36 | def __init__(self, title="", parent=None, flags=0, buttons=None): | ||
37 | super(CrumbsDialog, self).__init__(title, parent, flags, buttons) | ||
38 | |||
39 | #FIXME self.set_property("has-separator", False) # note: deprecated in 2.22 | ||
40 | |||
41 | self.set_border_width(6) | ||
42 | self.vbox.set_property("spacing", 12) | ||
43 | self.action_area.set_property("spacing", 12) | ||
44 | self.action_area.set_property("border-width", 6) | ||
diff --git a/bitbake/lib/bb/ui/crumbs/hig/crumbsmessagedialog.py b/bitbake/lib/bb/ui/crumbs/hig/crumbsmessagedialog.py deleted file mode 100644 index 3b998e4637..0000000000 --- a/bitbake/lib/bb/ui/crumbs/hig/crumbsmessagedialog.py +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | # | ||
2 | # BitBake Graphical GTK User Interface | ||
3 | # | ||
4 | # Copyright (C) 2011-2012 Intel Corporation | ||
5 | # | ||
6 | # Authored by Joshua Lock <josh@linux.intel.com> | ||
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 glib | ||
24 | import gtk | ||
25 | from bb.ui.crumbs.hobwidget import HobIconChecker | ||
26 | from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog | ||
27 | |||
28 | """ | ||
29 | The following are convenience classes for implementing GNOME HIG compliant | ||
30 | BitBake GUI's | ||
31 | In summary: spacing = 12px, border-width = 6px | ||
32 | """ | ||
33 | |||
34 | class CrumbsMessageDialog(gtk.MessageDialog): | ||
35 | """ | ||
36 | A GNOME HIG compliant dialog widget. | ||
37 | Add buttons with gtk.Dialog.add_button or gtk.Dialog.add_buttons | ||
38 | """ | ||
39 | def __init__(self, parent = None, label="", dialog_type = gtk.MESSAGE_QUESTION, msg=""): | ||
40 | super(CrumbsMessageDialog, self).__init__(None, | ||
41 | gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, | ||
42 | dialog_type, | ||
43 | gtk.BUTTONS_NONE, | ||
44 | None) | ||
45 | |||
46 | self.set_skip_taskbar_hint(False) | ||
47 | |||
48 | self.set_markup(label) | ||
49 | |||
50 | if 0 <= len(msg) < 300: | ||
51 | self.format_secondary_markup(msg) | ||
52 | else: | ||
53 | vbox = self.get_message_area() | ||
54 | vbox.set_border_width(1) | ||
55 | vbox.set_property("spacing", 12) | ||
56 | self.textWindow = gtk.ScrolledWindow() | ||
57 | self.textWindow.set_shadow_type(gtk.SHADOW_IN) | ||
58 | self.textWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) | ||
59 | self.msgView = gtk.TextView() | ||
60 | self.msgView.set_editable(False) | ||
61 | self.msgView.set_wrap_mode(gtk.WRAP_WORD) | ||
62 | self.msgView.set_cursor_visible(False) | ||
63 | self.msgView.set_size_request(300, 300) | ||
64 | self.buf = gtk.TextBuffer() | ||
65 | self.buf.set_text(msg) | ||
66 | self.msgView.set_buffer(self.buf) | ||
67 | self.textWindow.add(self.msgView) | ||
68 | self.msgView.show() | ||
69 | vbox.add(self.textWindow) | ||
70 | self.textWindow.show() | ||
diff --git a/bitbake/lib/bb/ui/crumbs/hig/deployimagedialog.py b/bitbake/lib/bb/ui/crumbs/hig/deployimagedialog.py deleted file mode 100644 index a13fff906a..0000000000 --- a/bitbake/lib/bb/ui/crumbs/hig/deployimagedialog.py +++ /dev/null | |||
@@ -1,219 +0,0 @@ | |||
1 | # | ||
2 | # BitBake Graphical GTK User Interface | ||
3 | # | ||
4 | # Copyright (C) 2011-2012 Intel Corporation | ||
5 | # | ||
6 | # Authored by Joshua Lock <josh@linux.intel.com> | ||
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 glob | ||
24 | import gtk | ||
25 | import gobject | ||
26 | import os | ||
27 | import re | ||
28 | import shlex | ||
29 | import subprocess | ||
30 | import tempfile | ||
31 | from bb.ui.crumbs.hobwidget import hic, HobButton | ||
32 | from bb.ui.crumbs.progressbar import HobProgressBar | ||
33 | import bb.ui.crumbs.utils | ||
34 | import bb.process | ||
35 | from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog | ||
36 | from bb.ui.crumbs.hig.crumbsmessagedialog import CrumbsMessageDialog | ||
37 | |||
38 | """ | ||
39 | The following are convenience classes for implementing GNOME HIG compliant | ||
40 | BitBake GUI's | ||
41 | In summary: spacing = 12px, border-width = 6px | ||
42 | """ | ||
43 | |||
44 | class DeployImageDialog (CrumbsDialog): | ||
45 | |||
46 | __dummy_usb__ = "--select a usb drive--" | ||
47 | |||
48 | def __init__(self, title, image_path, parent, flags, buttons=None, standalone=False): | ||
49 | super(DeployImageDialog, self).__init__(title, parent, flags, buttons) | ||
50 | |||
51 | self.image_path = image_path | ||
52 | self.standalone = standalone | ||
53 | |||
54 | self.create_visual_elements() | ||
55 | self.connect("response", self.response_cb) | ||
56 | |||
57 | def create_visual_elements(self): | ||
58 | self.set_size_request(600, 400) | ||
59 | label = gtk.Label() | ||
60 | label.set_alignment(0.0, 0.5) | ||
61 | markup = "<span font_desc='12'>The image to be written into usb drive:</span>" | ||
62 | label.set_markup(markup) | ||
63 | self.vbox.pack_start(label, expand=False, fill=False, padding=2) | ||
64 | |||
65 | table = gtk.Table(2, 10, False) | ||
66 | table.set_col_spacings(5) | ||
67 | table.set_row_spacings(5) | ||
68 | self.vbox.pack_start(table, expand=True, fill=True) | ||
69 | |||
70 | scroll = gtk.ScrolledWindow() | ||
71 | scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) | ||
72 | scroll.set_shadow_type(gtk.SHADOW_IN) | ||
73 | tv = gtk.TextView() | ||
74 | tv.set_editable(False) | ||
75 | tv.set_wrap_mode(gtk.WRAP_WORD) | ||
76 | tv.set_cursor_visible(False) | ||
77 | self.buf = gtk.TextBuffer() | ||
78 | self.buf.set_text(self.image_path) | ||
79 | tv.set_buffer(self.buf) | ||
80 | scroll.add(tv) | ||
81 | table.attach(scroll, 0, 10, 0, 1) | ||
82 | |||
83 | # There are 2 ways to use DeployImageDialog | ||
84 | # One way is that called by HOB when the 'Deploy Image' button is clicked | ||
85 | # The other way is that called by a standalone script. | ||
86 | # Following block of codes handles the latter way. It adds a 'Select Image' button and | ||
87 | # emit a signal when the button is clicked. | ||
88 | if self.standalone: | ||
89 | gobject.signal_new("select_image_clicked", self, gobject.SIGNAL_RUN_FIRST, | ||
90 | gobject.TYPE_NONE, ()) | ||
91 | icon = gtk.Image() | ||
92 | pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_IMAGES_DISPLAY_FILE) | ||
93 | icon.set_from_pixbuf(pix_buffer) | ||
94 | button = gtk.Button("Select Image") | ||
95 | button.set_image(icon) | ||
96 | #button.set_size_request(140, 50) | ||
97 | table.attach(button, 9, 10, 1, 2, gtk.FILL, 0, 0, 0) | ||
98 | button.connect("clicked", self.select_image_button_clicked_cb) | ||
99 | |||
100 | separator = gtk.HSeparator() | ||
101 | self.vbox.pack_start(separator, expand=False, fill=False, padding=10) | ||
102 | |||
103 | self.usb_desc = gtk.Label() | ||
104 | self.usb_desc.set_alignment(0.0, 0.5) | ||
105 | markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>" | ||
106 | self.usb_desc.set_markup(markup) | ||
107 | |||
108 | self.usb_combo = gtk.combo_box_new_text() | ||
109 | self.usb_combo.connect("changed", self.usb_combo_changed_cb) | ||
110 | model = self.usb_combo.get_model() | ||
111 | model.clear() | ||
112 | self.usb_combo.append_text(self.__dummy_usb__) | ||
113 | for usb in self.find_all_usb_devices(): | ||
114 | self.usb_combo.append_text("/dev/" + usb) | ||
115 | self.usb_combo.set_active(0) | ||
116 | self.vbox.pack_start(self.usb_combo, expand=False, fill=False) | ||
117 | self.vbox.pack_start(self.usb_desc, expand=False, fill=False, padding=2) | ||
118 | |||
119 | self.progress_bar = HobProgressBar() | ||
120 | self.vbox.pack_start(self.progress_bar, expand=False, fill=False) | ||
121 | separator = gtk.HSeparator() | ||
122 | self.vbox.pack_start(separator, expand=False, fill=True, padding=10) | ||
123 | |||
124 | self.vbox.show_all() | ||
125 | self.progress_bar.hide() | ||
126 | |||
127 | def set_image_text_buffer(self, image_path): | ||
128 | self.buf.set_text(image_path) | ||
129 | |||
130 | def set_image_path(self, image_path): | ||
131 | self.image_path = image_path | ||
132 | |||
133 | def popen_read(self, cmd): | ||
134 | tmpout, errors = bb.process.run("%s" % cmd) | ||
135 | return tmpout.strip() | ||
136 | |||
137 | def find_all_usb_devices(self): | ||
138 | usb_devs = [ os.readlink(u) | ||
139 | for u in glob.glob('/dev/disk/by-id/usb*') | ||
140 | if not re.search(r'part\d+', u) ] | ||
141 | return [ '%s' % u[u.rfind('/')+1:] for u in usb_devs ] | ||
142 | |||
143 | def get_usb_info(self, dev): | ||
144 | return "%s %s" % \ | ||
145 | (self.popen_read('cat /sys/class/block/%s/device/vendor' % dev), | ||
146 | self.popen_read('cat /sys/class/block/%s/device/model' % dev)) | ||
147 | |||
148 | def select_image_button_clicked_cb(self, button): | ||
149 | self.emit('select_image_clicked') | ||
150 | |||
151 | def usb_combo_changed_cb(self, usb_combo): | ||
152 | combo_item = self.usb_combo.get_active_text() | ||
153 | if not combo_item or combo_item == self.__dummy_usb__: | ||
154 | markup = "<span font_desc='12'>You haven't chosen any USB drive.</span>" | ||
155 | self.usb_desc.set_markup(markup) | ||
156 | else: | ||
157 | markup = "<span font_desc='12'>" + self.get_usb_info(combo_item.lstrip("/dev/")) + "</span>" | ||
158 | self.usb_desc.set_markup(markup) | ||
159 | |||
160 | def response_cb(self, dialog, response_id): | ||
161 | if response_id == gtk.RESPONSE_YES: | ||
162 | lbl = '' | ||
163 | msg = '' | ||
164 | combo_item = self.usb_combo.get_active_text() | ||
165 | if combo_item and combo_item != self.__dummy_usb__ and self.image_path: | ||
166 | cmdline = bb.ui.crumbs.utils.which_terminal() | ||
167 | if cmdline: | ||
168 | tmpfile = tempfile.NamedTemporaryFile() | ||
169 | cmdline += "\"sudo dd if=" + self.image_path + \ | ||
170 | " of=" + combo_item + " && sync; echo $? > " + tmpfile.name + "\"" | ||
171 | subprocess.call(shlex.split(cmdline)) | ||
172 | |||
173 | if int(tmpfile.readline().strip()) == 0: | ||
174 | lbl = "<b>Deploy image successfully.</b>" | ||
175 | else: | ||
176 | lbl = "<b>Failed to deploy image.</b>" | ||
177 | msg = "Please check image <b>%s</b> exists and USB device <b>%s</b> is writable." % (self.image_path, combo_item) | ||
178 | tmpfile.close() | ||
179 | else: | ||
180 | if not self.image_path: | ||
181 | lbl = "<b>No selection made.</b>" | ||
182 | msg = "You have not selected an image to deploy." | ||
183 | else: | ||
184 | lbl = "<b>No selection made.</b>" | ||
185 | msg = "You have not selected a USB device." | ||
186 | if len(lbl): | ||
187 | crumbs_dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_INFO, msg) | ||
188 | button = crumbs_dialog.add_button("Close", gtk.RESPONSE_OK) | ||
189 | HobButton.style_button(button) | ||
190 | crumbs_dialog.run() | ||
191 | crumbs_dialog.destroy() | ||
192 | |||
193 | def update_progress_bar(self, title, fraction, status=None): | ||
194 | self.progress_bar.update(fraction) | ||
195 | self.progress_bar.set_title(title) | ||
196 | self.progress_bar.set_rcstyle(status) | ||
197 | |||
198 | def write_file(self, ifile, ofile): | ||
199 | self.progress_bar.reset() | ||
200 | self.progress_bar.show() | ||
201 | |||
202 | f_from = os.open(ifile, os.O_RDONLY) | ||
203 | f_to = os.open(ofile, os.O_WRONLY) | ||
204 | |||
205 | total_size = os.stat(ifile).st_size | ||
206 | written_size = 0 | ||
207 | |||
208 | while True: | ||
209 | buf = os.read(f_from, 1024*1024) | ||
210 | if not buf: | ||
211 | break | ||
212 | os.write(f_to, buf) | ||
213 | written_size += 1024*1024 | ||
214 | self.update_progress_bar("Writing to usb:", written_size * 1.0/total_size) | ||
215 | |||
216 | self.update_progress_bar("Writing completed:", 1.0) | ||
217 | os.close(f_from) | ||
218 | os.close(f_to) | ||
219 | self.progress_bar.hide() | ||
diff --git a/bitbake/lib/bb/ui/crumbs/hig/imageselectiondialog.py b/bitbake/lib/bb/ui/crumbs/hig/imageselectiondialog.py deleted file mode 100644 index 21216adc97..0000000000 --- a/bitbake/lib/bb/ui/crumbs/hig/imageselectiondialog.py +++ /dev/null | |||
@@ -1,172 +0,0 @@ | |||
1 | # | ||
2 | # BitBake Graphical GTK User Interface | ||
3 | # | ||
4 | # Copyright (C) 2011-2012 Intel Corporation | ||
5 | # | ||
6 | # Authored by Joshua Lock <josh@linux.intel.com> | ||
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 | import gobject | ||
25 | import os | ||
26 | from bb.ui.crumbs.hobwidget import HobViewTable, HobInfoButton, HobButton, HobAltButton | ||
27 | from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog | ||
28 | from bb.ui.crumbs.hig.layerselectiondialog import LayerSelectionDialog | ||
29 | |||
30 | """ | ||
31 | The following are convenience classes for implementing GNOME HIG compliant | ||
32 | BitBake GUI's | ||
33 | In summary: spacing = 12px, border-width = 6px | ||
34 | """ | ||
35 | |||
36 | class ImageSelectionDialog (CrumbsDialog): | ||
37 | |||
38 | __columns__ = [{ | ||
39 | 'col_name' : 'Image name', | ||
40 | 'col_id' : 0, | ||
41 | 'col_style': 'text', | ||
42 | 'col_min' : 400, | ||
43 | 'col_max' : 400 | ||
44 | }, { | ||
45 | 'col_name' : 'Select', | ||
46 | 'col_id' : 1, | ||
47 | 'col_style': 'radio toggle', | ||
48 | 'col_min' : 160, | ||
49 | 'col_max' : 160 | ||
50 | }] | ||
51 | |||
52 | |||
53 | def __init__(self, image_folder, image_types, title, parent, flags, buttons=None, image_extension = {}): | ||
54 | super(ImageSelectionDialog, self).__init__(title, parent, flags, buttons) | ||
55 | self.connect("response", self.response_cb) | ||
56 | |||
57 | self.image_folder = image_folder | ||
58 | self.image_types = image_types | ||
59 | self.image_list = [] | ||
60 | self.image_names = [] | ||
61 | self.image_extension = image_extension | ||
62 | |||
63 | # create visual elements on the dialog | ||
64 | self.create_visual_elements() | ||
65 | |||
66 | self.image_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN) | ||
67 | self.fill_image_store() | ||
68 | |||
69 | def create_visual_elements(self): | ||
70 | hbox = gtk.HBox(False, 6) | ||
71 | |||
72 | self.vbox.pack_start(hbox, expand=False, fill=False) | ||
73 | |||
74 | entry = gtk.Entry() | ||
75 | entry.set_text(self.image_folder) | ||
76 | table = gtk.Table(1, 10, True) | ||
77 | table.set_size_request(560, -1) | ||
78 | hbox.pack_start(table, expand=False, fill=False) | ||
79 | table.attach(entry, 0, 9, 0, 1) | ||
80 | image = gtk.Image() | ||
81 | image.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON) | ||
82 | open_button = gtk.Button() | ||
83 | open_button.set_image(image) | ||
84 | open_button.connect("clicked", self.select_path_cb, self, entry) | ||
85 | table.attach(open_button, 9, 10, 0, 1) | ||
86 | |||
87 | self.image_table = HobViewTable(self.__columns__, "Images") | ||
88 | self.image_table.set_size_request(-1, 300) | ||
89 | self.image_table.connect("toggled", self.toggled_cb) | ||
90 | self.image_table.connect_group_selection(self.table_selected_cb) | ||
91 | self.image_table.connect("row-activated", self.row_actived_cb) | ||
92 | self.vbox.pack_start(self.image_table, expand=True, fill=True) | ||
93 | |||
94 | self.show_all() | ||
95 | |||
96 | def change_image_cb(self, model, path, columnid): | ||
97 | if not model: | ||
98 | return | ||
99 | iter = model.get_iter_first() | ||
100 | while iter: | ||
101 | rowpath = model.get_path(iter) | ||
102 | model[rowpath][columnid] = False | ||
103 | iter = model.iter_next(iter) | ||
104 | |||
105 | model[path][columnid] = True | ||
106 | |||
107 | def toggled_cb(self, table, cell, path, columnid, tree): | ||
108 | model = tree.get_model() | ||
109 | self.change_image_cb(model, path, columnid) | ||
110 | |||
111 | def table_selected_cb(self, selection): | ||
112 | model, paths = selection.get_selected_rows() | ||
113 | if paths: | ||
114 | self.change_image_cb(model, paths[0], 1) | ||
115 | |||
116 | def row_actived_cb(self, tab, model, path): | ||
117 | self.change_image_cb(model, path, 1) | ||
118 | self.emit('response', gtk.RESPONSE_YES) | ||
119 | |||
120 | def select_path_cb(self, action, parent, entry): | ||
121 | dialog = gtk.FileChooserDialog("", parent, | ||
122 | gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER) | ||
123 | text = entry.get_text() | ||
124 | dialog.set_current_folder(text if len(text) > 0 else os.getcwd()) | ||
125 | button = dialog.add_button("Cancel", gtk.RESPONSE_NO) | ||
126 | HobAltButton.style_button(button) | ||
127 | button = dialog.add_button("Open", gtk.RESPONSE_YES) | ||
128 | HobButton.style_button(button) | ||
129 | response = dialog.run() | ||
130 | if response == gtk.RESPONSE_YES: | ||
131 | path = dialog.get_filename() | ||
132 | entry.set_text(path) | ||
133 | self.image_folder = path | ||
134 | self.fill_image_store() | ||
135 | |||
136 | dialog.destroy() | ||
137 | |||
138 | def fill_image_store(self): | ||
139 | self.image_list = [] | ||
140 | self.image_store.clear() | ||
141 | imageset = set() | ||
142 | for root, dirs, files in os.walk(self.image_folder): | ||
143 | # ignore the sub directories | ||
144 | dirs[:] = [] | ||
145 | for f in files: | ||
146 | for image_type in self.image_types: | ||
147 | if image_type in self.image_extension: | ||
148 | real_types = self.image_extension[image_type] | ||
149 | else: | ||
150 | real_types = [image_type] | ||
151 | for real_image_type in real_types: | ||
152 | if f.endswith('.' + real_image_type): | ||
153 | imageset.add(f.rsplit('.' + real_image_type)[0].rsplit('.rootfs')[0]) | ||
154 | self.image_list.append(f) | ||
155 | |||
156 | for image in imageset: | ||
157 | self.image_store.set(self.image_store.append(), 0, image, 1, False) | ||
158 | |||
159 | self.image_table.set_model(self.image_store) | ||
160 | |||
161 | def response_cb(self, dialog, response_id): | ||
162 | self.image_names = [] | ||
163 | if response_id == gtk.RESPONSE_YES: | ||
164 | iter = self.image_store.get_iter_first() | ||
165 | while iter: | ||
166 | path = self.image_store.get_path(iter) | ||
167 | if self.image_store[path][1]: | ||
168 | for f in self.image_list: | ||
169 | if f.startswith(self.image_store[path][0] + '.'): | ||
170 | self.image_names.append(f) | ||
171 | break | ||
172 | iter = self.image_store.iter_next(iter) | ||
diff --git a/bitbake/lib/bb/ui/crumbs/hig/layerselectiondialog.py b/bitbake/lib/bb/ui/crumbs/hig/layerselectiondialog.py deleted file mode 100644 index 52d57b6738..0000000000 --- a/bitbake/lib/bb/ui/crumbs/hig/layerselectiondialog.py +++ /dev/null | |||
@@ -1,298 +0,0 @@ | |||
1 | # | ||
2 | # BitBake Graphical GTK User Interface | ||
3 | # | ||
4 | # Copyright (C) 2011-2012 Intel Corporation | ||
5 | # | ||
6 | # Authored by Joshua Lock <josh@linux.intel.com> | ||
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 | import gobject | ||
25 | import os | ||
26 | import tempfile | ||
27 | from bb.ui.crumbs.hobwidget import hic, HobButton, HobAltButton | ||
28 | from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog | ||
29 | from bb.ui.crumbs.hig.crumbsmessagedialog import CrumbsMessageDialog | ||
30 | |||
31 | """ | ||
32 | The following are convenience classes for implementing GNOME HIG compliant | ||
33 | BitBake GUI's | ||
34 | In summary: spacing = 12px, border-width = 6px | ||
35 | """ | ||
36 | |||
37 | class CellRendererPixbufActivatable(gtk.CellRendererPixbuf): | ||
38 | """ | ||
39 | A custom CellRenderer implementation which is activatable | ||
40 | so that we can handle user clicks | ||
41 | """ | ||
42 | __gsignals__ = { 'clicked' : (gobject.SIGNAL_RUN_LAST, | ||
43 | gobject.TYPE_NONE, | ||
44 | (gobject.TYPE_STRING,)), } | ||
45 | |||
46 | def __init__(self): | ||
47 | gtk.CellRendererPixbuf.__init__(self) | ||
48 | self.set_property('mode', gtk.CELL_RENDERER_MODE_ACTIVATABLE) | ||
49 | self.set_property('follow-state', True) | ||
50 | |||
51 | """ | ||
52 | Respond to a user click on a cell | ||
53 | """ | ||
54 | def do_activate(self, even, widget, path, background_area, cell_area, flags): | ||
55 | self.emit('clicked', path) | ||
56 | |||
57 | # | ||
58 | # LayerSelectionDialog | ||
59 | # | ||
60 | class LayerSelectionDialog (CrumbsDialog): | ||
61 | |||
62 | TARGETS = [ | ||
63 | ("MY_TREE_MODEL_ROW", gtk.TARGET_SAME_WIDGET, 0), | ||
64 | ("text/plain", 0, 1), | ||
65 | ("TEXT", 0, 2), | ||
66 | ("STRING", 0, 3), | ||
67 | ] | ||
68 | |||
69 | def gen_label_widget(self, content): | ||
70 | label = gtk.Label() | ||
71 | label.set_alignment(0, 0) | ||
72 | label.set_markup(content) | ||
73 | label.show() | ||
74 | return label | ||
75 | |||
76 | def layer_widget_toggled_cb(self, cell, path, layer_store): | ||
77 | name = layer_store[path][0] | ||
78 | toggle = not layer_store[path][1] | ||
79 | layer_store[path][1] = toggle | ||
80 | |||
81 | def layer_widget_add_clicked_cb(self, action, layer_store, parent): | ||
82 | dialog = gtk.FileChooserDialog("Add new layer", parent, | ||
83 | gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER) | ||
84 | button = dialog.add_button("Cancel", gtk.RESPONSE_NO) | ||
85 | HobAltButton.style_button(button) | ||
86 | button = dialog.add_button("Open", gtk.RESPONSE_YES) | ||
87 | HobButton.style_button(button) | ||
88 | label = gtk.Label("Select the layer you wish to add") | ||
89 | label.show() | ||
90 | dialog.set_extra_widget(label) | ||
91 | response = dialog.run() | ||
92 | path = dialog.get_filename() | ||
93 | dialog.destroy() | ||
94 | |||
95 | lbl = "<b>Error</b>" | ||
96 | msg = "Unable to load layer <i>%s</i> because " % path | ||
97 | if response == gtk.RESPONSE_YES: | ||
98 | import os | ||
99 | import os.path | ||
100 | layers = [] | ||
101 | it = layer_store.get_iter_first() | ||
102 | while it: | ||
103 | layers.append(layer_store.get_value(it, 0)) | ||
104 | it = layer_store.iter_next(it) | ||
105 | |||
106 | if not path: | ||
107 | msg += "it is an invalid path." | ||
108 | elif not os.path.exists(path+"/conf/layer.conf"): | ||
109 | msg += "there is no layer.conf inside the directory." | ||
110 | elif path in layers: | ||
111 | msg += "it is already in loaded layers." | ||
112 | else: | ||
113 | layer_store.append([path]) | ||
114 | return | ||
115 | dialog = CrumbsMessageDialog(parent, lbl, gtk.MESSAGE_ERROR, msg) | ||
116 | dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_OK) | ||
117 | response = dialog.run() | ||
118 | dialog.destroy() | ||
119 | |||
120 | def layer_widget_del_clicked_cb(self, action, tree_selection, layer_store): | ||
121 | model, iter = tree_selection.get_selected() | ||
122 | if iter: | ||
123 | layer_store.remove(iter) | ||
124 | |||
125 | |||
126 | def gen_layer_widget(self, layers, layers_avail, window, tooltip=""): | ||
127 | hbox = gtk.HBox(False, 6) | ||
128 | |||
129 | layer_tv = gtk.TreeView() | ||
130 | layer_tv.set_rules_hint(True) | ||
131 | layer_tv.set_headers_visible(False) | ||
132 | tree_selection = layer_tv.get_selection() | ||
133 | tree_selection.set_mode(gtk.SELECTION_SINGLE) | ||
134 | |||
135 | # Allow enable drag and drop of rows including row move | ||
136 | dnd_internal_target = '' | ||
137 | dnd_targets = [(dnd_internal_target, gtk.TARGET_SAME_WIDGET, 0)] | ||
138 | layer_tv.enable_model_drag_source( gtk.gdk.BUTTON1_MASK, | ||
139 | dnd_targets, | ||
140 | gtk.gdk.ACTION_MOVE) | ||
141 | layer_tv.enable_model_drag_dest(dnd_targets, | ||
142 | gtk.gdk.ACTION_MOVE) | ||
143 | layer_tv.connect("drag_data_get", self.drag_data_get_cb) | ||
144 | layer_tv.connect("drag_data_received", self.drag_data_received_cb) | ||
145 | |||
146 | col0= gtk.TreeViewColumn('Path') | ||
147 | cell0 = gtk.CellRendererText() | ||
148 | cell0.set_padding(5,2) | ||
149 | col0.pack_start(cell0, True) | ||
150 | col0.set_cell_data_func(cell0, self.draw_layer_path_cb) | ||
151 | layer_tv.append_column(col0) | ||
152 | |||
153 | scroll = gtk.ScrolledWindow() | ||
154 | scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) | ||
155 | scroll.set_shadow_type(gtk.SHADOW_IN) | ||
156 | scroll.add(layer_tv) | ||
157 | |||
158 | table_layer = gtk.Table(2, 10, False) | ||
159 | hbox.pack_start(table_layer, expand=True, fill=True) | ||
160 | |||
161 | table_layer.attach(scroll, 0, 10, 0, 1) | ||
162 | |||
163 | layer_store = gtk.ListStore(gobject.TYPE_STRING) | ||
164 | for layer in layers: | ||
165 | layer_store.append([layer]) | ||
166 | |||
167 | col1 = gtk.TreeViewColumn('Enabled') | ||
168 | layer_tv.append_column(col1) | ||
169 | |||
170 | cell1 = CellRendererPixbufActivatable() | ||
171 | cell1.set_fixed_size(-1,35) | ||
172 | cell1.connect("clicked", self.del_cell_clicked_cb, layer_store) | ||
173 | col1.pack_start(cell1, True) | ||
174 | col1.set_cell_data_func(cell1, self.draw_delete_button_cb, layer_tv) | ||
175 | |||
176 | add_button = gtk.Button() | ||
177 | add_button.set_relief(gtk.RELIEF_NONE) | ||
178 | box = gtk.HBox(False, 6) | ||
179 | box.show() | ||
180 | add_button.add(box) | ||
181 | add_button.connect("enter-notify-event", self.add_hover_cb) | ||
182 | add_button.connect("leave-notify-event", self.add_leave_cb) | ||
183 | self.im = gtk.Image() | ||
184 | self.im.set_from_file(hic.ICON_INDI_ADD_FILE) | ||
185 | self.im.show() | ||
186 | box.pack_start(self.im, expand=False, fill=False, padding=6) | ||
187 | lbl = gtk.Label("Add layer") | ||
188 | lbl.set_alignment(0.0, 0.5) | ||
189 | lbl.show() | ||
190 | box.pack_start(lbl, expand=True, fill=True, padding=6) | ||
191 | add_button.connect("clicked", self.layer_widget_add_clicked_cb, layer_store, window) | ||
192 | table_layer.attach(add_button, 0, 10, 1, 2, gtk.EXPAND | gtk.FILL, 0, 0, 6) | ||
193 | layer_tv.set_model(layer_store) | ||
194 | |||
195 | hbox.show_all() | ||
196 | |||
197 | return hbox, layer_store | ||
198 | |||
199 | def drag_data_get_cb(self, treeview, context, selection, target_id, etime): | ||
200 | treeselection = treeview.get_selection() | ||
201 | model, iter = treeselection.get_selected() | ||
202 | data = model.get_value(iter, 0) | ||
203 | selection.set(selection.target, 8, data) | ||
204 | |||
205 | def drag_data_received_cb(self, treeview, context, x, y, selection, info, etime): | ||
206 | model = treeview.get_model() | ||
207 | data = selection.data | ||
208 | drop_info = treeview.get_dest_row_at_pos(x, y) | ||
209 | if drop_info: | ||
210 | path, position = drop_info | ||
211 | iter = model.get_iter(path) | ||
212 | if (position == gtk.TREE_VIEW_DROP_BEFORE or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE): | ||
213 | model.insert_before(iter, [data]) | ||
214 | else: | ||
215 | model.insert_after(iter, [data]) | ||
216 | else: | ||
217 | model.append([data]) | ||
218 | if context.action == gtk.gdk.ACTION_MOVE: | ||
219 | context.finish(True, True, etime) | ||
220 | return | ||
221 | |||
222 | def add_hover_cb(self, button, event): | ||
223 | self.im.set_from_file(hic.ICON_INDI_ADD_HOVER_FILE) | ||
224 | |||
225 | def add_leave_cb(self, button, event): | ||
226 | self.im.set_from_file(hic.ICON_INDI_ADD_FILE) | ||
227 | |||
228 | def __init__(self, title, layers, layers_non_removable, all_layers, parent, flags, buttons=None): | ||
229 | super(LayerSelectionDialog, self).__init__(title, parent, flags, buttons) | ||
230 | |||
231 | # class members from other objects | ||
232 | self.layers = layers | ||
233 | self.layers_non_removable = layers_non_removable | ||
234 | self.all_layers = all_layers | ||
235 | self.layers_changed = False | ||
236 | |||
237 | # icon for remove button in TreeView | ||
238 | im = gtk.Image() | ||
239 | im.set_from_file(hic.ICON_INDI_REMOVE_FILE) | ||
240 | self.rem_icon = im.get_pixbuf() | ||
241 | |||
242 | # class members for internal use | ||
243 | self.layer_store = None | ||
244 | |||
245 | # create visual elements on the dialog | ||
246 | self.create_visual_elements() | ||
247 | self.connect("response", self.response_cb) | ||
248 | |||
249 | def create_visual_elements(self): | ||
250 | layer_widget, self.layer_store = self.gen_layer_widget(self.layers, self.all_layers, self, None) | ||
251 | layer_widget.set_size_request(450, 250) | ||
252 | self.vbox.pack_start(layer_widget, expand=True, fill=True) | ||
253 | self.show_all() | ||
254 | |||
255 | def response_cb(self, dialog, response_id): | ||
256 | model = self.layer_store | ||
257 | it = model.get_iter_first() | ||
258 | layers = [] | ||
259 | while it: | ||
260 | layers.append(model.get_value(it, 0)) | ||
261 | it = model.iter_next(it) | ||
262 | |||
263 | self.layers_changed = (self.layers != layers) | ||
264 | self.layers = layers | ||
265 | |||
266 | """ | ||
267 | A custom cell_data_func to draw a delete 'button' in the TreeView for layers | ||
268 | other than the meta layer. The deletion of which is prevented so that the | ||
269 | user can't shoot themselves in the foot too badly. | ||
270 | """ | ||
271 | def draw_delete_button_cb(self, col, cell, model, it, tv): | ||
272 | path = model.get_value(it, 0) | ||
273 | if path in self.layers_non_removable: | ||
274 | cell.set_sensitive(False) | ||
275 | cell.set_property('pixbuf', None) | ||
276 | cell.set_property('mode', gtk.CELL_RENDERER_MODE_INERT) | ||
277 | else: | ||
278 | cell.set_property('pixbuf', self.rem_icon) | ||
279 | cell.set_sensitive(True) | ||
280 | cell.set_property('mode', gtk.CELL_RENDERER_MODE_ACTIVATABLE) | ||
281 | |||
282 | return True | ||
283 | |||
284 | """ | ||
285 | A custom cell_data_func to write an extra message into the layer path cell | ||
286 | for the meta layer. We should inform the user that they can't remove it for | ||
287 | their own safety. | ||
288 | """ | ||
289 | def draw_layer_path_cb(self, col, cell, model, it): | ||
290 | path = model.get_value(it, 0) | ||
291 | if path in self.layers_non_removable: | ||
292 | cell.set_property('markup', "<b>It cannot be removed</b>\n%s" % path) | ||
293 | else: | ||
294 | cell.set_property('text', path) | ||
295 | |||
296 | def del_cell_clicked_cb(self, cell, path, model): | ||
297 | it = model.get_iter_from_string(path) | ||
298 | model.remove(it) | ||
diff --git a/bitbake/lib/bb/ui/crumbs/hig/propertydialog.py b/bitbake/lib/bb/ui/crumbs/hig/propertydialog.py deleted file mode 100644 index 09b9ce6de3..0000000000 --- a/bitbake/lib/bb/ui/crumbs/hig/propertydialog.py +++ /dev/null | |||
@@ -1,437 +0,0 @@ | |||
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) == 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 | import json | ||
109 | |||
110 | name = self.properties['name'] | ||
111 | binb = self.properties['binb'] | ||
112 | size = self.properties['size'] | ||
113 | recipe = self.properties['recipe'] | ||
114 | file_list = json.loads(self.properties['files_list']) | ||
115 | |||
116 | files_temp = '' | ||
117 | paths_temp = '' | ||
118 | files_binb = [] | ||
119 | paths_binb = [] | ||
120 | |||
121 | self.tooltip_items = {} | ||
122 | |||
123 | self.set_resizable(False) | ||
124 | |||
125 | #cleaning out the recipe variable | ||
126 | recipe = recipe.split("+")[0] | ||
127 | |||
128 | vbox = gtk.VBox(True,spacing = 0) | ||
129 | |||
130 | ###################################### NAME ROW + COL ################################# | ||
131 | |||
132 | self.label_short = gtk.Label() | ||
133 | self.label_short.set_size_request(300,-1) | ||
134 | self.label_short.set_selectable(True) | ||
135 | self.label_short.set_line_wrap(True) | ||
136 | self.label_short.set_markup("<span weight=\"bold\">Name: </span>" + name) | ||
137 | self.label_short.set_property("xalign", 0) | ||
138 | |||
139 | self.vbox.add(self.label_short) | ||
140 | |||
141 | ###################################### SIZE ROW + COL ###################################### | ||
142 | |||
143 | self.label_short = gtk.Label() | ||
144 | self.label_short.set_size_request(300,-1) | ||
145 | self.label_short.set_selectable(True) | ||
146 | self.label_short.set_line_wrap(True) | ||
147 | self.label_short.set_markup("<span weight=\"bold\">Size: </span>" + size) | ||
148 | self.label_short.set_property("xalign", 0) | ||
149 | |||
150 | self.vbox.add(self.label_short) | ||
151 | |||
152 | ##################################### RECIPE ROW + COL ######################################### | ||
153 | |||
154 | self.label_short = gtk.Label() | ||
155 | self.label_short.set_size_request(300,-1) | ||
156 | self.label_short.set_selectable(True) | ||
157 | self.label_short.set_line_wrap(True) | ||
158 | self.label_short.set_markup("<span weight=\"bold\">Recipe: </span>" + recipe) | ||
159 | self.label_short.set_property("xalign", 0) | ||
160 | |||
161 | self.vbox.add(self.label_short) | ||
162 | |||
163 | ##################################### BINB ROW + COL ####################################### | ||
164 | |||
165 | if binb != '': | ||
166 | self.label_short = gtk.Label() | ||
167 | self.label_short.set_selectable(True) | ||
168 | self.label_short.set_line_wrap(True) | ||
169 | self.label_short.set_markup("<span weight=\"bold\">Brought in by: </span>") | ||
170 | self.label_short.set_property("xalign", 0) | ||
171 | |||
172 | self.label_info = gtk.Label() | ||
173 | self.label_info.set_size_request(300,-1) | ||
174 | self.label_info.set_selectable(True) | ||
175 | self.label_info.set_line_wrap(True) | ||
176 | self.label_info.set_markup(binb) | ||
177 | self.label_info.set_property("xalign", 0) | ||
178 | |||
179 | self.vbox.add(self.label_short) | ||
180 | self.vbox.add(self.label_info) | ||
181 | |||
182 | #################################### FILES BROUGHT BY PACKAGES ################################### | ||
183 | |||
184 | if file_list: | ||
185 | |||
186 | self.textWindow = gtk.ScrolledWindow() | ||
187 | self.textWindow.set_shadow_type(gtk.SHADOW_IN) | ||
188 | self.textWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) | ||
189 | self.textWindow.set_size_request(100, 170) | ||
190 | |||
191 | packagefiles_store = gtk.ListStore(str) | ||
192 | |||
193 | self.packagefiles_tv = gtk.TreeView() | ||
194 | self.packagefiles_tv.set_rules_hint(True) | ||
195 | self.packagefiles_tv.set_headers_visible(True) | ||
196 | self.textWindow.add(self.packagefiles_tv) | ||
197 | |||
198 | self.cell1 = gtk.CellRendererText() | ||
199 | col1 = gtk.TreeViewColumn('Package files', self.cell1) | ||
200 | col1.set_cell_data_func(self.cell1, self.regex_field) | ||
201 | self.packagefiles_tv.append_column(col1) | ||
202 | |||
203 | items = file_list.keys() | ||
204 | items.sort() | ||
205 | for item in items: | ||
206 | fullpath = item | ||
207 | while len(item) > 35: | ||
208 | item = item[:len(item)/2] + "" + item[len(item)/2+1:] | ||
209 | if len(item) == 35: | ||
210 | item = item[:len(item)/2] + "..." + item[len(item)/2+3:] | ||
211 | self.tooltip_items[item] = fullpath | ||
212 | |||
213 | packagefiles_store.append([str(item)]) | ||
214 | |||
215 | self.packagefiles_tv.set_model(packagefiles_store) | ||
216 | |||
217 | tips = gtk.Tooltips() | ||
218 | tips.set_tip(self.packagefiles_tv, "") | ||
219 | self.packagefiles_tv.connect("motion-notify-event", self.treeViewTooltip, tips, 0) | ||
220 | self.packagefiles_tv.set_events(gtk.gdk.POINTER_MOTION_MASK) | ||
221 | |||
222 | self.vbox.add(self.textWindow) | ||
223 | |||
224 | self.vbox.show_all() | ||
225 | |||
226 | |||
227 | def regex_field(self, column, cell, model, iter): | ||
228 | cell.set_property('text', model.get_value(iter, 0)) | ||
229 | return | ||
230 | |||
231 | |||
232 | def create_recipe_visual_elements(self): | ||
233 | |||
234 | summary = self.properties['summary'] | ||
235 | name = self.properties['name'] | ||
236 | version = self.properties['version'] | ||
237 | revision = self.properties['revision'] | ||
238 | binb = self.properties['binb'] | ||
239 | group = self.properties['group'] | ||
240 | license = self.properties['license'] | ||
241 | homepage = self.properties['homepage'] | ||
242 | bugtracker = self.properties['bugtracker'] | ||
243 | description = self.properties['description'] | ||
244 | |||
245 | self.set_resizable(False) | ||
246 | |||
247 | #cleaning out the version variable and also the summary | ||
248 | version = version.split(":")[1] | ||
249 | if len(version) > 30: | ||
250 | version = version.split("+")[0] | ||
251 | else: | ||
252 | version = version.split("-")[0] | ||
253 | license = license.replace("&" , "and") | ||
254 | if (homepage == ''): | ||
255 | homepage = 'unknown' | ||
256 | if (bugtracker == ''): | ||
257 | bugtracker = 'unknown' | ||
258 | summary = summary.split("+")[0] | ||
259 | |||
260 | #calculating the rows needed for the table | ||
261 | binb_items_count = len(binb.split(',')) | ||
262 | binb_items = binb.split(',') | ||
263 | |||
264 | vbox = gtk.VBox(False,spacing = 0) | ||
265 | |||
266 | ######################################## SUMMARY LABEL ######################################### | ||
267 | |||
268 | if summary != '': | ||
269 | self.label_short = gtk.Label() | ||
270 | self.label_short.set_width_chars(37) | ||
271 | self.label_short.set_selectable(True) | ||
272 | self.label_short.set_line_wrap(True) | ||
273 | self.label_short.set_markup("<b>" + summary + "</b>") | ||
274 | self.label_short.set_property("xalign", 0) | ||
275 | |||
276 | self.vbox.add(self.label_short) | ||
277 | |||
278 | ########################################## NAME ROW + COL ####################################### | ||
279 | |||
280 | self.label_short = gtk.Label() | ||
281 | self.label_short.set_selectable(True) | ||
282 | self.label_short.set_line_wrap(True) | ||
283 | self.label_short.set_markup("<span weight=\"bold\">Name: </span>" + name) | ||
284 | self.label_short.set_property("xalign", 0) | ||
285 | |||
286 | self.vbox.add(self.label_short) | ||
287 | |||
288 | ####################################### VERSION ROW + COL #################################### | ||
289 | |||
290 | self.label_short = gtk.Label() | ||
291 | self.label_short.set_selectable(True) | ||
292 | self.label_short.set_line_wrap(True) | ||
293 | self.label_short.set_markup("<span weight=\"bold\">Version: </span>" + version) | ||
294 | self.label_short.set_property("xalign", 0) | ||
295 | |||
296 | self.vbox.add(self.label_short) | ||
297 | |||
298 | ##################################### REVISION ROW + COL ##################################### | ||
299 | |||
300 | self.label_short = gtk.Label() | ||
301 | self.label_short.set_line_wrap(True) | ||
302 | self.label_short.set_selectable(True) | ||
303 | self.label_short.set_markup("<span weight=\"bold\">Revision: </span>" + revision) | ||
304 | self.label_short.set_property("xalign", 0) | ||
305 | |||
306 | self.vbox.add(self.label_short) | ||
307 | |||
308 | ################################## GROUP ROW + COL ############################################ | ||
309 | |||
310 | self.label_short = gtk.Label() | ||
311 | self.label_short.set_selectable(True) | ||
312 | self.label_short.set_line_wrap(True) | ||
313 | self.label_short.set_markup("<span weight=\"bold\">Group: </span>" + group) | ||
314 | self.label_short.set_property("xalign", 0) | ||
315 | |||
316 | self.vbox.add(self.label_short) | ||
317 | |||
318 | ################################# HOMEPAGE ROW + COL ############################################ | ||
319 | |||
320 | if homepage != 'unknown': | ||
321 | self.label_info = gtk.Label() | ||
322 | self.label_info.set_selectable(True) | ||
323 | self.label_info.set_line_wrap(True) | ||
324 | if len(homepage) > 35: | ||
325 | self.label_info.set_markup("<a href=\"" + homepage + "\">" + homepage[0:35] + "..." + "</a>") | ||
326 | else: | ||
327 | self.label_info.set_markup("<a href=\"" + homepage + "\">" + homepage[0:60] + "</a>") | ||
328 | |||
329 | self.label_info.set_property("xalign", 0) | ||
330 | |||
331 | self.label_short = gtk.Label() | ||
332 | self.label_short.set_selectable(True) | ||
333 | self.label_short.set_line_wrap(True) | ||
334 | self.label_short.set_markup("<b>Homepage: </b>") | ||
335 | self.label_short.set_property("xalign", 0) | ||
336 | |||
337 | self.vbox.add(self.label_short) | ||
338 | self.vbox.add(self.label_info) | ||
339 | |||
340 | ################################# BUGTRACKER ROW + COL ########################################### | ||
341 | |||
342 | if bugtracker != 'unknown': | ||
343 | self.label_info = gtk.Label() | ||
344 | self.label_info.set_selectable(True) | ||
345 | self.label_info.set_line_wrap(True) | ||
346 | if len(bugtracker) > 35: | ||
347 | self.label_info.set_markup("<a href=\"" + bugtracker + "\">" + bugtracker[0:35] + "..." + "</a>") | ||
348 | else: | ||
349 | self.label_info.set_markup("<a href=\"" + bugtracker + "\">" + bugtracker[0:60] + "</a>") | ||
350 | self.label_info.set_property("xalign", 0) | ||
351 | |||
352 | self.label_short = gtk.Label() | ||
353 | self.label_short.set_selectable(True) | ||
354 | self.label_short.set_line_wrap(True) | ||
355 | self.label_short.set_markup("<b>Bugtracker: </b>") | ||
356 | self.label_short.set_property("xalign", 0) | ||
357 | |||
358 | self.vbox.add(self.label_short) | ||
359 | self.vbox.add(self.label_info) | ||
360 | |||
361 | ################################# LICENSE ROW + COL ############################################ | ||
362 | |||
363 | self.label_info = gtk.Label() | ||
364 | self.label_info.set_selectable(True) | ||
365 | self.label_info.set_line_wrap(True) | ||
366 | self.label_info.set_markup(license) | ||
367 | self.label_info.set_property("xalign", 0) | ||
368 | |||
369 | self.label_short = gtk.Label() | ||
370 | self.label_short.set_selectable(True) | ||
371 | self.label_short.set_line_wrap(True) | ||
372 | self.label_short.set_markup("<span weight=\"bold\">License: </span>") | ||
373 | self.label_short.set_property("xalign", 0) | ||
374 | |||
375 | self.vbox.add(self.label_short) | ||
376 | self.vbox.add(self.label_info) | ||
377 | |||
378 | ################################### BINB ROW+COL ############################################# | ||
379 | |||
380 | if binb != '': | ||
381 | self.label_short = gtk.Label() | ||
382 | self.label_short.set_selectable(True) | ||
383 | self.label_short.set_line_wrap(True) | ||
384 | self.label_short.set_markup("<span weight=\"bold\">Brought in by: </span>") | ||
385 | self.label_short.set_property("xalign", 0) | ||
386 | self.vbox.add(self.label_short) | ||
387 | self.label_info = gtk.Label() | ||
388 | self.label_info.set_selectable(True) | ||
389 | self.label_info.set_width_chars(36) | ||
390 | if len(binb) > 200: | ||
391 | scrolled_window = gtk.ScrolledWindow() | ||
392 | scrolled_window.set_policy(gtk.POLICY_NEVER,gtk.POLICY_ALWAYS) | ||
393 | scrolled_window.set_size_request(100,100) | ||
394 | self.label_info.set_markup(binb) | ||
395 | self.label_info.set_padding(6,6) | ||
396 | self.label_info.set_alignment(0,0) | ||
397 | self.label_info.set_line_wrap(True) | ||
398 | scrolled_window.add_with_viewport(self.label_info) | ||
399 | self.vbox.add(scrolled_window) | ||
400 | else: | ||
401 | self.label_info.set_markup(binb) | ||
402 | self.label_info.set_property("xalign", 0) | ||
403 | self.label_info.set_line_wrap(True) | ||
404 | self.vbox.add(self.label_info) | ||
405 | |||
406 | ################################ DESCRIPTION TAG ROW ################################################# | ||
407 | |||
408 | self.label_short = gtk.Label() | ||
409 | self.label_short.set_line_wrap(True) | ||
410 | self.label_short.set_markup("<span weight=\"bold\">Description </span>") | ||
411 | self.label_short.set_property("xalign", 0) | ||
412 | self.vbox.add(self.label_short) | ||
413 | |||
414 | ################################ DESCRIPTION INFORMATION ROW ########################################## | ||
415 | |||
416 | hbox = gtk.HBox(True,spacing = 0) | ||
417 | |||
418 | self.label_short = gtk.Label() | ||
419 | self.label_short.set_selectable(True) | ||
420 | self.label_short.set_width_chars(36) | ||
421 | if len(description) > 200: | ||
422 | scrolled_window = gtk.ScrolledWindow() | ||
423 | scrolled_window.set_policy(gtk.POLICY_NEVER,gtk.POLICY_ALWAYS) | ||
424 | scrolled_window.set_size_request(100,100) | ||
425 | self.label_short.set_markup(description) | ||
426 | self.label_short.set_padding(6,6) | ||
427 | self.label_short.set_alignment(0,0) | ||
428 | self.label_short.set_line_wrap(True) | ||
429 | scrolled_window.add_with_viewport(self.label_short) | ||
430 | self.vbox.add(scrolled_window) | ||
431 | else: | ||
432 | self.label_short.set_markup(description) | ||
433 | self.label_short.set_property("xalign", 0) | ||
434 | self.label_short.set_line_wrap(True) | ||
435 | self.vbox.add(self.label_short) | ||
436 | |||
437 | self.vbox.show_all() | ||
diff --git a/bitbake/lib/bb/ui/crumbs/hig/settingsuihelper.py b/bitbake/lib/bb/ui/crumbs/hig/settingsuihelper.py deleted file mode 100644 index e0285c93ce..0000000000 --- a/bitbake/lib/bb/ui/crumbs/hig/settingsuihelper.py +++ /dev/null | |||
@@ -1,122 +0,0 @@ | |||
1 | # | ||
2 | # BitBake Graphical GTK User Interface | ||
3 | # | ||
4 | # Copyright (C) 2011-2012 Intel Corporation | ||
5 | # | ||
6 | # Authored by Joshua Lock <josh@linux.intel.com> | ||
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 | import os | ||
25 | from bb.ui.crumbs.hobwidget import HobInfoButton, HobButton, HobAltButton | ||
26 | |||
27 | """ | ||
28 | The following are convenience classes for implementing GNOME HIG compliant | ||
29 | BitBake GUI's | ||
30 | In summary: spacing = 12px, border-width = 6px | ||
31 | """ | ||
32 | |||
33 | class SettingsUIHelper(): | ||
34 | |||
35 | def gen_label_widget(self, content): | ||
36 | label = gtk.Label() | ||
37 | label.set_alignment(0, 0) | ||
38 | label.set_markup(content) | ||
39 | label.show() | ||
40 | return label | ||
41 | |||
42 | def gen_label_info_widget(self, content, tooltip): | ||
43 | table = gtk.Table(1, 10, False) | ||
44 | label = self.gen_label_widget(content) | ||
45 | info = HobInfoButton(tooltip, self) | ||
46 | table.attach(label, 0, 1, 0, 1, xoptions=gtk.FILL) | ||
47 | table.attach(info, 1, 2, 0, 1, xoptions=gtk.FILL, xpadding=10) | ||
48 | return table | ||
49 | |||
50 | def gen_spinner_widget(self, content, lower, upper, tooltip=""): | ||
51 | hbox = gtk.HBox(False, 12) | ||
52 | adjust = gtk.Adjustment(value=content, lower=lower, upper=upper, step_incr=1) | ||
53 | spinner = gtk.SpinButton(adjustment=adjust, climb_rate=1, digits=0) | ||
54 | |||
55 | spinner.set_value(content) | ||
56 | hbox.pack_start(spinner, expand=False, fill=False) | ||
57 | |||
58 | info = HobInfoButton(tooltip, self) | ||
59 | hbox.pack_start(info, expand=False, fill=False) | ||
60 | |||
61 | hbox.show_all() | ||
62 | return hbox, spinner | ||
63 | |||
64 | def gen_combo_widget(self, curr_item, all_item, tooltip=""): | ||
65 | hbox = gtk.HBox(False, 12) | ||
66 | combo = gtk.combo_box_new_text() | ||
67 | hbox.pack_start(combo, expand=False, fill=False) | ||
68 | |||
69 | index = 0 | ||
70 | for item in all_item or []: | ||
71 | combo.append_text(item) | ||
72 | if item == curr_item: | ||
73 | combo.set_active(index) | ||
74 | index += 1 | ||
75 | |||
76 | info = HobInfoButton(tooltip, self) | ||
77 | hbox.pack_start(info, expand=False, fill=False) | ||
78 | |||
79 | hbox.show_all() | ||
80 | return hbox, combo | ||
81 | |||
82 | def entry_widget_select_path_cb(self, action, parent, entry): | ||
83 | dialog = gtk.FileChooserDialog("", parent, | ||
84 | gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER) | ||
85 | text = entry.get_text() | ||
86 | dialog.set_current_folder(text if len(text) > 0 else os.getcwd()) | ||
87 | button = dialog.add_button("Cancel", gtk.RESPONSE_NO) | ||
88 | HobAltButton.style_button(button) | ||
89 | button = dialog.add_button("Open", gtk.RESPONSE_YES) | ||
90 | HobButton.style_button(button) | ||
91 | response = dialog.run() | ||
92 | if response == gtk.RESPONSE_YES: | ||
93 | path = dialog.get_filename() | ||
94 | entry.set_text(path) | ||
95 | |||
96 | dialog.destroy() | ||
97 | |||
98 | def gen_entry_widget(self, content, parent, tooltip="", need_button=True): | ||
99 | hbox = gtk.HBox(False, 12) | ||
100 | entry = gtk.Entry() | ||
101 | entry.set_text(content) | ||
102 | entry.set_size_request(350,30) | ||
103 | |||
104 | if need_button: | ||
105 | table = gtk.Table(1, 10, False) | ||
106 | hbox.pack_start(table, expand=True, fill=True) | ||
107 | table.attach(entry, 0, 9, 0, 1, xoptions=gtk.SHRINK) | ||
108 | image = gtk.Image() | ||
109 | image.set_from_stock(gtk.STOCK_OPEN,gtk.ICON_SIZE_BUTTON) | ||
110 | open_button = gtk.Button() | ||
111 | open_button.set_image(image) | ||
112 | open_button.connect("clicked", self.entry_widget_select_path_cb, parent, entry) | ||
113 | table.attach(open_button, 9, 10, 0, 1, xoptions=gtk.SHRINK) | ||
114 | else: | ||
115 | hbox.pack_start(entry, expand=True, fill=True) | ||
116 | |||
117 | if tooltip != "": | ||
118 | info = HobInfoButton(tooltip, self) | ||
119 | hbox.pack_start(info, expand=False, fill=False) | ||
120 | |||
121 | hbox.show_all() | ||
122 | return hbox, entry | ||