diff options
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/layereditor.py')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/layereditor.py | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/layereditor.py b/bitbake/lib/bb/ui/crumbs/layereditor.py deleted file mode 100644 index f5394a5f52..0000000000 --- a/bitbake/lib/bb/ui/crumbs/layereditor.py +++ /dev/null | |||
@@ -1,153 +0,0 @@ | |||
1 | # | ||
2 | # BitBake Graphical GTK User Interface | ||
3 | # | ||
4 | # Copyright (C) 2011 Intel Corporation | ||
5 | # | ||
6 | # Authored by Joshua Lock <josh@linux.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 gobject | ||
22 | import gtk | ||
23 | from bb.ui.crumbs.configurator import Configurator | ||
24 | from bb.ui.crumbs.hig import CrumbsDialog | ||
25 | |||
26 | class LayerEditor(gtk.Dialog): | ||
27 | """ | ||
28 | Gtk+ Widget for enabling and disabling layers. | ||
29 | Layers are added through using an open dialog to find the layer.conf | ||
30 | Disabled layers are deleted from conf/bblayers.conf | ||
31 | """ | ||
32 | def __init__(self, configurator, parent=None): | ||
33 | gtk.Dialog.__init__(self, "Layers", None, | ||
34 | gtk.DIALOG_DESTROY_WITH_PARENT, | ||
35 | (gtk.STOCK_CLOSE, gtk.RESPONSE_OK)) | ||
36 | |||
37 | # We want to show a little more of the treeview in the default, | ||
38 | # emptier, case | ||
39 | self.set_size_request(-1, 300) | ||
40 | self.set_border_width(6) | ||
41 | self.vbox.set_property("spacing", 0) | ||
42 | self.action_area.set_property("border-width", 6) | ||
43 | |||
44 | self.configurator = configurator | ||
45 | self.newly_added = {} | ||
46 | |||
47 | # Label to inform users that meta is enabled but that you can't | ||
48 | # disable it as it'd be a *bad* idea | ||
49 | msg = "As the core of the build system the <i>meta</i> layer must always be included and therefore can't be viewed or edited here." | ||
50 | lbl = gtk.Label() | ||
51 | lbl.show() | ||
52 | lbl.set_use_markup(True) | ||
53 | lbl.set_markup(msg) | ||
54 | lbl.set_line_wrap(True) | ||
55 | lbl.set_justify(gtk.JUSTIFY_FILL) | ||
56 | self.vbox.pack_start(lbl, expand=False, fill=False, padding=6) | ||
57 | |||
58 | # Create a treeview in which to list layers | ||
59 | # ListStore of Name, Path, Enabled | ||
60 | self.layer_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_BOOLEAN) | ||
61 | self.tv = gtk.TreeView(self.layer_store) | ||
62 | self.tv.set_headers_visible(True) | ||
63 | |||
64 | col0 = gtk.TreeViewColumn('Name') | ||
65 | self.tv.append_column(col0) | ||
66 | col1 = gtk.TreeViewColumn('Path') | ||
67 | self.tv.append_column(col1) | ||
68 | col2 = gtk.TreeViewColumn('Enabled') | ||
69 | self.tv.append_column(col2) | ||
70 | |||
71 | cell0 = gtk.CellRendererText() | ||
72 | col0.pack_start(cell0, True) | ||
73 | col0.set_attributes(cell0, text=0) | ||
74 | cell1 = gtk.CellRendererText() | ||
75 | col1.pack_start(cell1, True) | ||
76 | col1.set_attributes(cell1, text=1) | ||
77 | cell2 = gtk.CellRendererToggle() | ||
78 | cell2.connect("toggled", self._toggle_layer_cb) | ||
79 | col2.pack_start(cell2, True) | ||
80 | col2.set_attributes(cell2, active=2) | ||
81 | |||
82 | self.tv.show() | ||
83 | self.vbox.pack_start(self.tv, expand=True, fill=True, padding=0) | ||
84 | |||
85 | tb = gtk.Toolbar() | ||
86 | tb.set_icon_size(gtk.ICON_SIZE_SMALL_TOOLBAR) | ||
87 | tb.set_style(gtk.TOOLBAR_BOTH) | ||
88 | tb.set_tooltips(True) | ||
89 | tb.show() | ||
90 | icon = gtk.Image() | ||
91 | icon.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_SMALL_TOOLBAR) | ||
92 | icon.show() | ||
93 | tb.insert_item("Add Layer", "Add new layer", None, icon, | ||
94 | self._find_layer_cb, None, -1) | ||
95 | self.vbox.pack_start(tb, expand=False, fill=False, padding=0) | ||
96 | |||
97 | def set_parent_window(self, parent): | ||
98 | self.set_transient_for(parent) | ||
99 | |||
100 | def load_current_layers(self, data): | ||
101 | for layer, path in self.configurator.enabled_layers.items(): | ||
102 | if layer != 'meta': | ||
103 | self.layer_store.append([layer, path, True]) | ||
104 | |||
105 | def save_current_layers(self): | ||
106 | self.configurator.writeLayerConf() | ||
107 | |||
108 | def _toggle_layer_cb(self, cell, path): | ||
109 | name = self.layer_store[path][0] | ||
110 | toggle = not self.layer_store[path][2] | ||
111 | if toggle: | ||
112 | self.configurator.addLayer(name, path) | ||
113 | else: | ||
114 | self.configurator.disableLayer(name) | ||
115 | self.layer_store[path][2] = toggle | ||
116 | |||
117 | def _find_layer_cb(self, button): | ||
118 | self.find_layer(self) | ||
119 | |||
120 | def find_layer(self, parent): | ||
121 | def conf_error(parent, lbl): | ||
122 | dialog = CrumbsDialog(parent, lbl) | ||
123 | dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) | ||
124 | response = dialog.run() | ||
125 | dialog.destroy() | ||
126 | |||
127 | dialog = gtk.FileChooserDialog("Add new layer", parent, | ||
128 | gtk.FILE_CHOOSER_ACTION_OPEN, | ||
129 | (gtk.STOCK_CANCEL, gtk.RESPONSE_NO, | ||
130 | gtk.STOCK_OPEN, gtk.RESPONSE_YES)) | ||
131 | label = gtk.Label("Select the layer.conf of the layer you wish to add") | ||
132 | label.show() | ||
133 | dialog.set_extra_widget(label) | ||
134 | response = dialog.run() | ||
135 | path = dialog.get_filename() | ||
136 | dialog.destroy() | ||
137 | |||
138 | lbl = "<b>Error</b>\nUnable to load layer <i>%s</i> because " % path | ||
139 | if response == gtk.RESPONSE_YES: | ||
140 | # FIXME: verify we've actually got a layer conf? | ||
141 | if path.endswith("layer.conf"): | ||
142 | name, layerpath = self.configurator.addLayerConf(path) | ||
143 | if name and layerpath: | ||
144 | self.newly_added[name] = layerpath | ||
145 | self.layer_store.append([name, layerpath, True]) | ||
146 | return | ||
147 | elif name: | ||
148 | return | ||
149 | else: | ||
150 | lbl += "there was a problem parsing the layer.conf." | ||
151 | else: | ||
152 | lbl += "it is not a layer.conf file." | ||
153 | conf_error(parent, lbl) | ||