[SCM] calf/master: + Big Bull: replace flat plugin menu with hierarchical one

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:37:39 UTC 2013


The following commit has been merged in the master branch:
commit 6549d6787072cf7bbfc9578396fdfbd4a4a872cb
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Sat Sep 27 23:24:00 2008 +0000

    + Big Bull: replace flat plugin menu with hierarchical one
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@308 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/bigbull/lv2.py b/bigbull/lv2.py
index 71332cb..5bc3ffd 100644
--- a/bigbull/lv2.py
+++ b/bigbull/lv2.py
@@ -218,6 +218,24 @@ class LV2DB:
         #fn = "/usr/lib/lv2/lv2core.lv2/lv2.ttl"
         #parseTTL(fn, file(fn).read(), self.manifests)
         self.plugins = self.manifests.getByType(lv2 + "Plugin")
+        self.categories = set()
+        self.category_paths = []
+        self.add_category_recursive([], lv2 + "Plugin")
+        
+    def add_category_recursive(self, tree_pos, category):
+        cat_name = self.manifests.getProperty(category, rdfs + "label", single = True, optional = True)
+        self.category_paths.append(((tree_pos + [cat_name])[1:], category))
+        self.categories.add(category)
+        items = self.manifests.byPredicate[rdfs + "subClassOf"]
+        for subj in items:
+            if subj in self.categories:
+                continue
+            for o in items[subj]:
+                if o == category and subj not in self.categories:
+                    self.add_category_recursive(list(tree_pos) + [cat_name], subj)
+        
+    def get_categories(self):
+        return self.category_paths
         
     def getPluginList(self):
         return self.plugins
diff --git a/bigbull/mainwin.py b/bigbull/mainwin.py
index d31ff81..9312424 100755
--- a/bigbull/mainwin.py
+++ b/bigbull/mainwin.py
@@ -90,9 +90,33 @@ class App:
         self.file_menu = add_submenu(self.menu_bar, "_File")
         add_option(self.file_menu, "_Exit", self.exit)
         self.plugin_menu = add_submenu(self.menu_bar, "_Plugins")
+        self.submenus = dict()
+        self.category_to_path = dict()
+        for (path, uri) in self.lv2db.get_categories():
+            if path == []:
+                continue;
+            parent_menu = self.plugin_menu
+            parent_path = "/".join(path[:-1])
+            if parent_path in self.submenus:
+                parent_menu = self.submenus[parent_path]
+            self.submenus["/".join(path)] = add_submenu(parent_menu, path[-1])
+            self.category_to_path[uri] = path
         for uri in self.lv2db.getPluginList():
             plugin = self.lv2db.getPluginInfo(uri)
-            add_option(self.plugin_menu, plugin.name, self.cgraph.add_module_cb, (plugin, None, None))
+            parent_menu = self.plugin_menu
+            best_path = self.get_best_category(plugin)
+            if best_path in self.submenus:
+                parent_menu = self.submenus[best_path]
+            add_option(parent_menu, plugin.name, self.cgraph.add_module_cb, (plugin, None, None))
+        
+    def get_best_category(self, plugin):
+        max_len = -1
+        best_path = []
+        for path in [self.category_to_path[c] for c in plugin.classes if c in self.category_to_path]:
+            if len(path) > max_len:
+                best_path = path
+                max_len = len(path)
+        return "/".join(best_path)
         
     def exit(self, data):
         self.window.destroy()

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list