From 3d48664133d5efb19fc5701167f1b579ffc460ca Mon Sep 17 00:00:00 2001
From: Alex Roitman <shura@gramps-project.org>
Date: Sun, 6 Nov 2005 02:25:24 +0000
Subject: [PATCH] * src/PluginMgr.py: Add the optional argument indicating the
 unsupported status to all registrations. * src/Plugins.py: Reflect
 unsupported status in menus and trees. * src/plugins/BookReport.py: Reflect
 unsupported status. * src/plugins/WebPage.py,
 src/plugins/FtmStyleAncestors.py, src/plugins/FtmStyleDescendants.py: Declare
 unsupported status.

svn: r5362
---
 gramps2/src/PluginMgr.py                   | 49 +++++++++--------
 gramps2/src/Plugins.py                     | 64 +++++++++++++++++-----
 gramps2/src/plugins/FtmStyleAncestors.py   |  3 +-
 gramps2/src/plugins/FtmStyleDescendants.py |  3 +-
 gramps2/src/plugins/WebPage.py             |  1 +
 5 files changed, 82 insertions(+), 38 deletions(-)

diff --git a/gramps2/src/PluginMgr.py b/gramps2/src/PluginMgr.py
index 6f5af5b07..30710db15 100644
--- a/gramps2/src/PluginMgr.py
+++ b/gramps2/src/PluginMgr.py
@@ -183,7 +183,8 @@ def register_tool(
     status=_("Unknown"),
     description=_unavailable,
     author_name=_("Unknown"),
-    author_email=_("Unknown")
+    author_email=_("Unknown"),
+    unsupported=False
     ):
     """
     Register a tool with the plugin system.
@@ -199,19 +200,20 @@ def register_tool(
     if gui_task:
         _register_gui_tool(tool_class,options_class,translated_name,
                            name,category,description,
-                           status,author_name,author_email)
+                           status,author_name,author_email,unsupported)
 
     (junk,cli_task) = divmod(modes-gui_task,2**Tool.MODE_CLI)
     if cli_task:
         _register_cli_tool(name,category,tool_class,options_class,
-                           translated_name)
+                           translated_name,unsupported)
 
 def _register_gui_tool(tool_class,options_class,translated_name,
                        name,category,
                        description=_unavailable,
                        status=_("Unknown"),
                        author_name=_("Unknown"),
-                       author_email=_("Unknown")):
+                       author_email=_("Unknown"),
+                       unsupported=False):
     del_index = -1
     for i in range(0,len(tool_list)):
         val = tool_list[i]
@@ -221,10 +223,10 @@ def _register_gui_tool(tool_class,options_class,translated_name,
         del tool_list[del_index]
     tool_list.append((tool_class,options_class,translated_name,
                       category,name,description,status,
-                      author_name,author_email))
+                      author_name,author_email,unsupported))
 
 def _register_cli_tool(name,category,tool_class,options_class,
-                       translated_name):
+                       translated_name,unsupported=False):
     del_index = -1
     for i in range(0,len(cli_tool_list)):
         val = cli_tool_list[i]
@@ -233,7 +235,7 @@ def _register_cli_tool(name,category,tool_class,options_class,
     if del_index != -1:
         del cli_tool_list[del_index]
     cli_tool_list.append((name,category,tool_class,options_class,
-                          translated_name))
+                          translated_name,unsupported))
 
 #-------------------------------------------------------------------------
 #
@@ -250,7 +252,8 @@ def register_report(
     status=_("Unknown"),
     description=_unavailable,
     author_name=_("Unknown"),
-    author_email=_("Unknown")
+    author_email=_("Unknown"),
+    unsupported=False
     ):
     """
     Registers report for all possible flavors.
@@ -266,27 +269,28 @@ def register_report(
     if standalone_task:
         _register_standalone(report_class,options_class,translated_name,
                         name,category,description,
-                        status,author_name,author_email)
+                        status,author_name,author_email,unsupported)
 
     (junk,book_item_task) = divmod(modes-standalone_task,2**Report.MODE_BKI)
     if book_item_task:
         book_item_category = Report.book_categories[category]
         register_book_item(translated_name,book_item_category,
-                    report_class,options_class,name)
+                    report_class,options_class,name,unsupported)
 
     (junk,command_line_task) = divmod(modes-standalone_task-book_item_task,
                                         2**Report.MODE_CLI)
     if command_line_task:
         _register_cl_report(name,category,report_class,options_class,
-                            translated_name)
+                            translated_name,unsupported)
 
 def _register_standalone(report_class, options_class, translated_name, 
-                    name, category,
-                    description=_unavailable,
-                    status=_("Unknown"),
-                    author_name=_("Unknown"),
-                    author_email=_("Unknown")
-                    ):
+                         name, category,
+                         description=_unavailable,
+                         status=_("Unknown"),
+                         author_name=_("Unknown"),
+                         author_email=_("Unknown"),
+                         unsupported=False
+                         ):
     """Register a report with the plugin system"""
 
     import Report
@@ -299,10 +303,11 @@ def _register_standalone(report_class, options_class, translated_name,
     if del_index != -1:
         del report_list[del_index]
     report_list.append((report_class, options_class, translated_name, 
-            category, name, description, status, author_name, author_email))
+                        category, name, description, status,
+                        author_name, author_email, unsupported))
 
 def register_book_item(translated_name, category, report_class,
-                        option_class, name):
+                        option_class, name, unsupported):
     """Register a book item"""
     
     del_index = -1
@@ -314,10 +319,10 @@ def register_book_item(translated_name, category, report_class,
         del bkitems_list[del_index]
 
     bkitems_list.append((translated_name, category, report_class,
-                         option_class, name))
+                         option_class, name, unsupported))
 
 def _register_cl_report(name,category,report_class,options_class,
-                        translated_name):
+                        translated_name,unsupported):
     del_index = -1
     for i in range(0,len(cl_list)):
         val = cl_list[i]
@@ -326,7 +331,7 @@ def _register_cl_report(name,category,report_class,options_class,
     if del_index != -1:
         del cl_list[del_index]
     cl_list.append((name,category,report_class,options_class,
-                    translated_name))
+                    translated_name,unsupported))
 
 #-------------------------------------------------------------------------
 #
diff --git a/gramps2/src/Plugins.py b/gramps2/src/Plugins.py
index a73e92d3d..8c75a29f1 100644
--- a/gramps2/src/Plugins.py
+++ b/gramps2/src/Plugins.py
@@ -69,6 +69,7 @@ import GrampsDisplay
 #-------------------------------------------------------------------------
 REPORTS = 0
 TOOLS   = 1
+UNSUPPORTED = _("Unsupported")
 
 #-------------------------------------------------------------------------
 #
@@ -126,6 +127,7 @@ class PluginDialog:
         
         self.author_name = self.dialog.get_widget("author_name")
         self.author_email = self.dialog.get_widget("author_email")
+        
         self.statbox = self.dialog.get_widget("statbox")
         
         self.apply_button = self.dialog.get_widget("apply")
@@ -194,8 +196,10 @@ class PluginDialog:
         data = self.imap[path]
 
         (report_class,options_class,title,category,name,
-         doc,status,author,email) = data
+         doc,status,author,email,unsupported) = data
         self.description.set_text(doc)
+        if unsupported:
+            status = UNSUPPORTED
         self.status.set_text(status)
         self.title.set_text('<span weight="bold" size="larger">%s</span>' % title)
         self.title.set_use_markup(1)
@@ -220,7 +224,10 @@ class PluginDialog:
         # build the tree items and group together based on the category name
         item_hash = {}
         for plugin in item_list:
-            category = categories[plugin[3]]
+            if plugin[9]:
+                category = UNSUPPORTED
+            else:
+                category = categories[plugin[3]]
             if item_hash.has_key(category):
                 item_hash[category].append(plugin)
             else:
@@ -228,11 +235,22 @@ class PluginDialog:
 
         # add a submenu for each category, and populate it with the
         # GtkTreeItems that are associated with it.
-        key_list = item_hash.keys()
+        key_list = [ item for item in item_hash.keys() if item != UNSUPPORTED]
         key_list.sort()
         key_list.reverse()
         
         prev = None
+        if item_hash.has_key(UNSUPPORTED):
+            key = UNSUPPORTED
+            data = item_hash[key]
+            node = self.store.insert_after(None,prev)
+            self.store.set(node,0,key)
+            next = None
+            data.sort(lambda x,y: cmp(x[2],y[2]))
+            for item in data:
+                next = self.store.insert_after(node,next)
+                ilist.append((next,item))
+                self.store.set(next,0,item[2])
         for key in key_list:
             data = item_hash[key]
             node = self.store.insert_after(None,prev)
@@ -397,7 +415,10 @@ def build_plugin_menu(item_list,categories,func,top_menu,callback):
     
     hash_data = {}
     for item in item_list:
-        category = categories[item[3]]
+        if item[9]:
+            category = UNSUPPORTED
+        else:
+            category = categories[item[3]]
         if hash_data.has_key(category):
             hash_data[category].append(
                     (item[0],item[1],item[2],item[4],item[3]))
@@ -405,7 +426,8 @@ def build_plugin_menu(item_list,categories,func,top_menu,callback):
             hash_data[category] = [
                     (item[0],item[1],item[2],item[4],item[3])]
 
-    catlist = hash_data.keys()
+    # Sort categories, skipping the unsupported
+    catlist = [item for item in hash_data.keys() if item != UNSUPPORTED]
     catlist.sort()
     for key in catlist:
         entry = gtk.MenuItem(key)
@@ -422,20 +444,34 @@ def build_plugin_menu(item_list,categories,func,top_menu,callback):
             subentry.connect("activate",callback,func,
                              name[0],name[1],name[2],name[3],name[4])
             submenu.append(subentry)
-    top_menu.set_submenu(menu)
 
+    # If there are any unsupported items we add separator
+    # and the unsupported category at the end of the menu
+    if hash_data.has_key(UNSUPPORTED):
+        entry = gtk.MenuItem(None)
+        entry.show()
+        menu.append(entry)
+        key = UNSUPPORTED
+        entry = gtk.MenuItem(key)
+        entry.show()
+        menu.append(entry)
+        submenu = gtk.Menu()
+        submenu.show()
+        entry.set_submenu(submenu)
+        lst = hash_data[key]
+        lst.sort(by_menu_name)
+        for name in lst:
+            subentry = gtk.MenuItem("%s..." % name[2])
+            subentry.show()
+            subentry.connect("activate",callback,func,
+                             name[0],name[1],name[2],name[3],name[4])
+            submenu.append(subentry)
+
+    top_menu.set_submenu(menu)
 
 def by_menu_name(a,b):
     return cmp(a[2],b[2])
 
-#-------------------------------------------------------------------------
-#
-# build_tools_menu
-#
-#-------------------------------------------------------------------------
-#def build_tools_menu(top_menu,callback):
-#    build_menu(top_menu,PluginMgr.tool_list,callback)
-
 #-------------------------------------------------------------------------
 #
 # get_text_doc_menu
diff --git a/gramps2/src/plugins/FtmStyleAncestors.py b/gramps2/src/plugins/FtmStyleAncestors.py
index e6abba0f4..0b150ca7a 100644
--- a/gramps2/src/plugins/FtmStyleAncestors.py
+++ b/gramps2/src/plugins/FtmStyleAncestors.py
@@ -423,5 +423,6 @@ register_report(
     status=(_("Beta")),
     description= _("Produces a textual ancestral report similar to Family Tree Maker."),
     author_name="Donald N. Allingham",
-    author_email="dallingham@users.sourceforge.net"
+    author_email="dallingham@users.sourceforge.net",
+    unsupported=True
     )
diff --git a/gramps2/src/plugins/FtmStyleDescendants.py b/gramps2/src/plugins/FtmStyleDescendants.py
index 81f16b693..19cbfabed 100644
--- a/gramps2/src/plugins/FtmStyleDescendants.py
+++ b/gramps2/src/plugins/FtmStyleDescendants.py
@@ -571,5 +571,6 @@ register_report(
     status = _("Beta"),
     description= _("Produces a textual descendant report similar to Family Tree Maker."),
     author_name="Alex Roitman",
-    author_email="shura@alex.neuro.umn.edu"
+    author_email="shura@alex.neuro.umn.edu",
+    unsupported=True
     )
diff --git a/gramps2/src/plugins/WebPage.py b/gramps2/src/plugins/WebPage.py
index 2d4098c45..e5d40796e 100644
--- a/gramps2/src/plugins/WebPage.py
+++ b/gramps2/src/plugins/WebPage.py
@@ -1980,4 +1980,5 @@ register_report(
                   "or a set of individuals. This report is considered "
                   "to be deprecated. Please migrate to the new "
                   "Narrative Web Page generator."),
+    unsupported=True
     )