summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/crumbs/layereditor.py
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2011-07-01 15:58:50 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-07-05 14:40:30 +0100
commit4cc291c007103c19779f995e852b37dbad122293 (patch)
tree3447d62ef1ba2eca08137b8e13df58f8a337a453 /bitbake/lib/bb/ui/crumbs/layereditor.py
parent7fc9c3488f7865111ec052d1cab213d216d2b414 (diff)
downloadpoky-4cc291c007103c19779f995e852b37dbad122293.tar.gz
hob: re-designed interaction and implementation
Highlights include: * Atempted GNOME HIG compliance * Simplified UI and interaction model * Sorting and type to find in tree views * Preferences dialog to modify local settings * Dialog to add and remove layers * Search in packages list * Save/Load image recipes The build model has been changed, hob will attempt to build all dependent packages of an image and then use the buildFile server method to build the created image. (Bitbake rev: 48e64acaae4a741b9f5630f426fb4e6142755c2c) Signed-off-by: Joshua Lock <josh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/layereditor.py')
-rw-r--r--bitbake/lib/bb/ui/crumbs/layereditor.py136
1 files changed, 136 insertions, 0 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/layereditor.py b/bitbake/lib/bb/ui/crumbs/layereditor.py
new file mode 100644
index 0000000000..76a2eb536f
--- /dev/null
+++ b/bitbake/lib/bb/ui/crumbs/layereditor.py
@@ -0,0 +1,136 @@
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
21import gobject
22import gtk
23from bb.ui.crumbs.configurator import Configurator
24
25class LayerEditor(gtk.Dialog):
26 """
27 Gtk+ Widget for enabling and disabling layers.
28 Layers are added through using an open dialog to find the layer.conf
29 Disabled layers are deleted from conf/bblayers.conf
30 """
31 def __init__(self, configurator, parent=None):
32 gtk.Dialog.__init__(self, "Layers", None,
33 gtk.DIALOG_DESTROY_WITH_PARENT,
34 (gtk.STOCK_CLOSE, gtk.RESPONSE_OK))
35
36 # We want to show a little more of the treeview in the default,
37 # emptier, case
38 self.set_size_request(-1, 300)
39 self.set_border_width(6)
40 self.vbox.set_property("spacing", 0)
41 self.action_area.set_property("border-width", 6)
42
43 self.configurator = configurator
44 self.newly_added = {}
45
46 # Label to inform users that meta is enabled but that you can't
47 # disable it as it'd be a *bad* idea
48 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."
49 lbl = gtk.Label()
50 lbl.show()
51 lbl.set_use_markup(True)
52 lbl.set_markup(msg)
53 lbl.set_line_wrap(True)
54 lbl.set_justify(gtk.JUSTIFY_FILL)
55 self.vbox.pack_start(lbl, expand=False, fill=False, padding=6)
56
57 # Create a treeview in which to list layers
58 # ListStore of Name, Path, Enabled
59 self.layer_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_BOOLEAN)
60 self.tv = gtk.TreeView(self.layer_store)
61 self.tv.set_headers_visible(True)
62
63 col0 = gtk.TreeViewColumn('Name')
64 self.tv.append_column(col0)
65 col1 = gtk.TreeViewColumn('Path')
66 self.tv.append_column(col1)
67 col2 = gtk.TreeViewColumn('Enabled')
68 self.tv.append_column(col2)
69
70 cell0 = gtk.CellRendererText()
71 col0.pack_start(cell0, True)
72 col0.set_attributes(cell0, text=0)
73 cell1 = gtk.CellRendererText()
74 col1.pack_start(cell1, True)
75 col1.set_attributes(cell1, text=1)
76 cell2 = gtk.CellRendererToggle()
77 cell2.connect("toggled", self._toggle_layer_cb)
78 col2.pack_start(cell2, True)
79 col2.set_attributes(cell2, active=2)
80
81 self.tv.show()
82 self.vbox.pack_start(self.tv, expand=True, fill=True, padding=0)
83
84 tb = gtk.Toolbar()
85 tb.set_icon_size(gtk.ICON_SIZE_SMALL_TOOLBAR)
86 tb.set_style(gtk.TOOLBAR_BOTH)
87 tb.set_tooltips(True)
88 tb.show()
89 icon = gtk.Image()
90 icon.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_SMALL_TOOLBAR)
91 icon.show()
92 tb.insert_item("Add Layer", "Add new layer", None, icon,
93 self._find_layer_cb, None, -1)
94 self.vbox.pack_start(tb, expand=False, fill=False, padding=0)
95
96 def set_parent_window(self, parent):
97 self.set_transient_for(parent)
98
99 def load_current_layers(self, data):
100 for layer, path in self.configurator.enabled_layers.items():
101 if layer != 'meta':
102 self.layer_store.append([layer, path, True])
103
104 def save_current_layers(self):
105 self.configurator.writeLayerConf()
106
107 def _toggle_layer_cb(self, cell, path):
108 name = self.layer_store[path][0]
109 toggle = not self.layer_store[path][2]
110 if toggle:
111 self.configurator.addLayer(name, path)
112 else:
113 self.configurator.disableLayer(name)
114 self.layer_store[path][2] = toggle
115
116 def _find_layer_cb(self, button):
117 self.find_layer(self)
118
119 def find_layer(self, parent):
120 dialog = gtk.FileChooserDialog("Add new layer", parent,
121 gtk.FILE_CHOOSER_ACTION_OPEN,
122 (gtk.STOCK_CANCEL, gtk.RESPONSE_NO,
123 gtk.STOCK_OPEN, gtk.RESPONSE_YES))
124 label = gtk.Label("Select the layer.conf of the layer you wish to add")
125 label.show()
126 dialog.set_extra_widget(label)
127 response = dialog.run()
128 path = dialog.get_filename()
129 dialog.destroy()
130
131 if response == gtk.RESPONSE_YES:
132 # FIXME: verify we've actually got a layer conf?
133 if path.endswith(".conf"):
134 name, layerpath = self.configurator.addLayerConf(path)
135 self.newly_added[name] = layerpath
136 self.layer_store.append([name, layerpath, True])