diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-01-22 15:37:56 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-01-22 15:38:09 +0000 |
commit | cd9ff3c676a875cc6e30b9bd4057ec93429496b0 (patch) | |
tree | 0dbbd66fbfa2c701d4f2802751425fd4517eb72d /bitbake/lib | |
parent | 0a0e03992cfd5d4e28e638c57b33069c1e2e4cd2 (diff) | |
download | poky-cd9ff3c676a875cc6e30b9bd4057ec93429496b0.tar.gz |
bitbake: crumbs: Add file lost from previous commit
(Bitbake rev: 90aabeb87d6c1f00d6333cc9930626d36b6d9709)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig/parsingwarningsdialog.py | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hig/parsingwarningsdialog.py b/bitbake/lib/bb/ui/crumbs/hig/parsingwarningsdialog.py new file mode 100644 index 0000000000..5cddd65e6b --- /dev/null +++ b/bitbake/lib/bb/ui/crumbs/hig/parsingwarningsdialog.py | |||
@@ -0,0 +1,161 @@ | |||
1 | # | ||
2 | # BitBake Graphical GTK User Interface | ||
3 | # | ||
4 | # Copyright (C) 2011-2012 Intel Corporation | ||
5 | # | ||
6 | # Authored by Cristiana Voicu <cristiana.voicu@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 gtk | ||
22 | import gobject | ||
23 | from bb.ui.crumbs.hobwidget import HobAltButton | ||
24 | from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog | ||
25 | |||
26 | """ | ||
27 | The following are convenience classes for implementing GNOME HIG compliant | ||
28 | BitBake GUI's | ||
29 | In summary: spacing = 12px, border-width = 6px | ||
30 | """ | ||
31 | |||
32 | # | ||
33 | # ParsingWarningsDialog | ||
34 | # | ||
35 | class ParsingWarningsDialog (CrumbsDialog): | ||
36 | |||
37 | def __init__(self, title, warnings, parent, flags, buttons=None): | ||
38 | super(ParsingWarningsDialog, self).__init__(title, parent, flags, buttons) | ||
39 | |||
40 | self.warnings = warnings | ||
41 | self.warning_on = 0 | ||
42 | self.warn_nb = len(warnings) | ||
43 | |||
44 | # create visual elements on the dialog | ||
45 | self.create_visual_elements() | ||
46 | |||
47 | def cancel_button_cb(self, button): | ||
48 | self.destroy() | ||
49 | |||
50 | def previous_button_cb(self, button): | ||
51 | self.warning_on = self.warning_on - 1 | ||
52 | self.refresh_components() | ||
53 | |||
54 | def next_button_cb(self, button): | ||
55 | self.warning_on = self.warning_on + 1 | ||
56 | self.refresh_components() | ||
57 | |||
58 | def refresh_components(self): | ||
59 | lbl = self.warnings[self.warning_on] | ||
60 | #when the warning text has more than 400 chars, it uses a scroll bar | ||
61 | if 0<= len(lbl) < 400: | ||
62 | self.warning_label.set_size_request(320, 230) | ||
63 | self.warning_label.set_use_markup(True) | ||
64 | self.warning_label.set_line_wrap(True) | ||
65 | self.warning_label.set_markup(lbl) | ||
66 | self.warning_label.set_property("yalign", 0.00) | ||
67 | else: | ||
68 | self.textWindow.set_shadow_type(gtk.SHADOW_IN) | ||
69 | self.textWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) | ||
70 | self.msgView = gtk.TextView() | ||
71 | self.msgView.set_editable(False) | ||
72 | self.msgView.set_wrap_mode(gtk.WRAP_WORD) | ||
73 | self.msgView.set_cursor_visible(False) | ||
74 | self.msgView.set_size_request(320, 230) | ||
75 | self.buf = gtk.TextBuffer() | ||
76 | self.buf.set_text(lbl) | ||
77 | self.msgView.set_buffer(self.buf) | ||
78 | self.textWindow.add(self.msgView) | ||
79 | self.msgView.show() | ||
80 | |||
81 | if self.warning_on==0: | ||
82 | self.previous_button.set_sensitive(False) | ||
83 | else: | ||
84 | self.previous_button.set_sensitive(True) | ||
85 | |||
86 | if self.warning_on==self.warn_nb-1: | ||
87 | self.next_button.set_sensitive(False) | ||
88 | else: | ||
89 | self.next_button.set_sensitive(True) | ||
90 | |||
91 | if self.warn_nb>1: | ||
92 | self.heading = "Warning " + str(self.warning_on + 1) + " of " + str(self.warn_nb) | ||
93 | self.heading_label.set_markup('<span weight="bold">%s</span>' % self.heading) | ||
94 | else: | ||
95 | self.heading = "Warning" | ||
96 | self.heading_label.set_markup('<span weight="bold">%s</span>' % self.heading) | ||
97 | |||
98 | self.show_all() | ||
99 | |||
100 | if 0<= len(lbl) < 400: | ||
101 | self.textWindow.hide() | ||
102 | else: | ||
103 | self.warning_label.hide() | ||
104 | |||
105 | def create_visual_elements(self): | ||
106 | self.set_size_request(350, 350) | ||
107 | self.heading_label = gtk.Label() | ||
108 | self.heading_label.set_alignment(0.1, 0) | ||
109 | self.warning_label = gtk.Label() | ||
110 | self.textWindow = gtk.ScrolledWindow() | ||
111 | |||
112 | table = gtk.Table(1, 10, False) | ||
113 | |||
114 | cancel_button = gtk.Button() | ||
115 | cancel_button.set_label("Close") | ||
116 | cancel_button.connect("clicked", self.cancel_button_cb) | ||
117 | cancel_button.set_size_request(110, 30) | ||
118 | |||
119 | self.previous_button = gtk.Button() | ||
120 | image1 = gtk.image_new_from_stock(gtk.STOCK_GO_BACK, gtk.ICON_SIZE_BUTTON) | ||
121 | image1.show() | ||
122 | box = gtk.HBox(False, 6) | ||
123 | box.show() | ||
124 | self.previous_button.add(box) | ||
125 | lbl = gtk.Label("Previous") | ||
126 | lbl.show() | ||
127 | box.pack_start(image1, expand=False, fill=False, padding=3) | ||
128 | box.pack_start(lbl, expand=True, fill=True, padding=3) | ||
129 | self.previous_button.connect("clicked", self.previous_button_cb) | ||
130 | self.previous_button.set_size_request(110, 30) | ||
131 | |||
132 | self.next_button = gtk.Button() | ||
133 | image2 = gtk.image_new_from_stock(gtk.STOCK_GO_FORWARD, gtk.ICON_SIZE_BUTTON) | ||
134 | image2.show() | ||
135 | box = gtk.HBox(False, 6) | ||
136 | box.show() | ||
137 | self.next_button.add(box) | ||
138 | lbl = gtk.Label("Next") | ||
139 | lbl.show() | ||
140 | box.pack_start(lbl, expand=True, fill=True, padding=3) | ||
141 | box.pack_start(image2, expand=False, fill=False, padding=3) | ||
142 | self.next_button.connect("clicked", self.next_button_cb) | ||
143 | self.next_button.set_size_request(110, 30) | ||
144 | |||
145 | #when there more than one warning, we need "previous" and "next" button | ||
146 | if self.warn_nb>1: | ||
147 | self.vbox.pack_start(self.heading_label, expand=False, fill=False) | ||
148 | self.vbox.pack_start(self.warning_label, expand=False, fill=False) | ||
149 | self.vbox.pack_start(self.textWindow, expand=False, fill=False) | ||
150 | table.attach(cancel_button, 6, 7, 0, 1, xoptions=gtk.SHRINK) | ||
151 | table.attach(self.previous_button, 7, 8, 0, 1, xoptions=gtk.SHRINK) | ||
152 | table.attach(self.next_button, 8, 9, 0, 1, xoptions=gtk.SHRINK) | ||
153 | self.vbox.pack_end(table, expand=False, fill=False) | ||
154 | else: | ||
155 | self.vbox.pack_start(self.heading_label, expand=False, fill=False) | ||
156 | self.vbox.pack_start(self.warning_label, expand=False, fill=False) | ||
157 | self.vbox.pack_start(self.textWindow, expand=False, fill=False) | ||
158 | cancel_button = self.add_button("Cancel", gtk.RESPONSE_CANCEL) | ||
159 | HobAltButton.style_button(cancel_button) | ||
160 | |||
161 | self.refresh_components() | ||