Changeset 28

Show
Ignore:
Timestamp:
08/25/05 21:21:12 (8 years ago)
Author:
gerhard
Message:

implemented a new plugin type that adds extension menu items and toolbars.
a simple example plugin was added that creates a list of referers in the current wiki

Location:
branches/greitmayr
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • branches/greitmayr/lib/pwiki/PersonalWikiFrame.py

    r25 r28  
    7676             "openWikiWord", "newWikiWord", "openedWikiWord", "savingWikiWord", 
    7777             "savedWikiWord", "renamedWikiWord", "deletedWikiWord", "exit"] ) 
     78        # interface for editor functions menu plugins 
     79        self.editorFunctions = self.pluginManager.registerPluginAPI(("EditorFunctions",1),  
     80                                ["describeMenuItem", "describeToolbarItem"]) 
    7881 
    7982        # load extensions 
     
    670673        EVT_MENU(self, menuID, lambda evt: self.showAboutDialog()) 
    671674 
     675        # get info for any plugin menu items and create them as necessary 
     676        pluginMenu = None 
     677        menuItems = self.editorFunctions.describeMenuItem(self) 
     678        if len(menuItems) > 0: 
     679            pluginMenu = wxMenu() 
     680            for function, item, tooltip in menuItems: 
     681                menuID = wxNewId() 
     682                pluginMenu.Append(menuID, item, tooltip) 
     683                EVT_MENU(self, menuID, lambda evt: function(self)) 
     684                 
    672685        self.mainmenu.Append(wikiMenu, 'W&iki') 
    673686        self.mainmenu.Append(wikiWordMenu, '&Wiki Words') 
    674687        self.mainmenu.Append(historyMenu, '&History') 
    675688        self.mainmenu.Append(formattingMenu, '&Editor') 
     689        if pluginMenu: 
     690            self.mainmenu.Append(pluginMenu, "Pl&ugins") 
    676691        self.mainmenu.Append(helpMenu, 'He&lp') 
    677692 
     
    781796        tb.AddSimpleTool(tbID, icon, "Wikize Selected Word", "Wikize Selected Word") 
    782797        EVT_TOOL(self, tbID, lambda evt: self.keyBindings.makeWikiWord(self.editor)) 
     798 
     799        # get info for any toolbar items and create them as necessary 
     800        toolbarItems = self.editorFunctions.describeToolbarItem(self)     
     801        for function, label, icon, tooltip in toolbarItems: 
     802            tbID = wxNewId() 
     803            tb.AddLabelTool( tbID, label, icon, wxNullBitmap, 0, tooltip) 
     804            EVT_TOOL(self, tbID, lambda evt: function(self)) 
    783805 
    784806        tb.Realize()