[bitbake-devel] [PATCH 7/8] ui/crumbs/layereditor: if layer adding fails show an explanatory dialog

Joshua Lock josh at linux.intel.com
Mon Aug 1 18:30:49 UTC 2011


When adding a layer fails try to explain why to the user.

Signed-off-by: Joshua Lock <josh at linux.intel.com>
---
 lib/bb/ui/crumbs/layereditor.py |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/bb/ui/crumbs/layereditor.py b/lib/bb/ui/crumbs/layereditor.py
index 7c581d6..f5394a5 100644
--- a/lib/bb/ui/crumbs/layereditor.py
+++ b/lib/bb/ui/crumbs/layereditor.py
@@ -21,6 +21,7 @@
 import gobject
 import gtk
 from bb.ui.crumbs.configurator import Configurator
+from bb.ui.crumbs.hig import CrumbsDialog
 
 class LayerEditor(gtk.Dialog):
     """
@@ -117,6 +118,12 @@ class LayerEditor(gtk.Dialog):
         self.find_layer(self)
 
     def find_layer(self, parent):
+        def conf_error(parent, lbl):
+            dialog = CrumbsDialog(parent, lbl)
+            dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
+            response = dialog.run()
+            dialog.destroy()
+
         dialog = gtk.FileChooserDialog("Add new layer", parent,
                                        gtk.FILE_CHOOSER_ACTION_OPEN,
                                        (gtk.STOCK_CANCEL, gtk.RESPONSE_NO,
@@ -128,10 +135,19 @@ class LayerEditor(gtk.Dialog):
         path = dialog.get_filename()
         dialog.destroy()
 
+        lbl = "<b>Error</b>\nUnable to load layer <i>%s</i> because " % path
         if response == gtk.RESPONSE_YES:
             # FIXME: verify we've actually got a layer conf?
-            if path.endswith(".conf"):
+            if path.endswith("layer.conf"):
                 name, layerpath = self.configurator.addLayerConf(path)
-                if name:
+                if name and layerpath:
                     self.newly_added[name] = layerpath
                     self.layer_store.append([name, layerpath, True])
+                    return
+                elif name:
+                    return
+                else:
+                    lbl += "there was a problem parsing the layer.conf."
+            else:
+                lbl += "it is not a layer.conf file."
+            conf_error(parent, lbl)
-- 
1.7.6





More information about the bitbake-devel mailing list