Changeset 3095

Show
Ignore:
Timestamp:
07/07/08 18:52:06 (5 years ago)
Author:
nopper
Message:

Code refactoring to avoid passing Core object to plugin costructors

Location:
branch/UmitPlugins
Files:
11 modified

Legend:

Unmodified
Added
Removed
  • branch/UmitPlugins/source-plugins/context-menu/sources/main.py

    r3022 r3095  
    2222import sys 
    2323 
     24from umitPlugin.Core import Core 
     25from umitPlugin.Engine import Plugin 
    2426from higwidgets.higanimates import HIGAnimatedBar 
    25 from umitPlugin.Engine import Plugin 
    2627 
    2728class MenuPlugin(Plugin): 
    28     __type__ = "usual" 
    29      
    30     def start(self, core, reader): 
    31         self.core = core 
     29    def start(self, reader): 
    3230        self.reader = reader 
    3331 
    34         self.id = self.core.connect('ScanHostsView-created', self.__on_created_hosts) 
     32        self.id = Core().connect('ScanHostsView-created', self.__on_created_hosts) 
    3533 
    36     def stop(self, core): 
    37         self.core.disconnect(self.id) 
     34    def stop(self): 
     35        Core().disconnect(self.id) 
    3836 
    3937    def __on_created_hosts(self, core, view): 
  • branch/UmitPlugins/source-plugins/dummy-working/sources/main.py

    r3018 r3095  
    2828 
    2929class Test(Plugin): 
    30     __type__ = "usual" 
    31      
    32     def start(self, core, reader): 
    33         self.core = core 
    34         self.reader = reader 
    35  
     30    def start(self, reader): 
    3631        dialog = HIGAlertDialog( 
    3732            None, 
     
    4338        dialog.run() 
    4439        dialog.destroy() 
    45          
    4640 
    47     def stop(self, core): 
     41    def stop(self): 
    4842        print "Stopping dummy plugin..." 
    4943 
  • branch/UmitPlugins/source-plugins/flow-analyzer/sources/main.py

    r3028 r3095  
    2222import sys 
    2323 
     24from umitPlugin.Core import Core 
     25from umitPlugin.Engine import Plugin 
    2426from higwidgets.higanimates import HIGAnimatedBar 
    25 from umitPlugin.Engine import Plugin 
    2627 
    2728class FlowContainer(gtk.VBox): 
     
    6162 
    6263class FlowPlugin(Plugin): 
    63     __type__ = "usual" 
    64      
    65     def start(self, core, reader): 
    66         self.core = core 
    67         self.reader = reader 
     64    def start(self, reader): 
     65        self.id = Core().connect('ScanNotebookPage-created', self.__on_created) 
    6866 
    69         self.id = self.core.connect('ScanNotebookPage-created', self.__on_created) 
    70  
    71     def stop(self, core): 
    72         self.core.disconnect(self.id) 
     67    def stop(self): 
     68        Core().disconnect(self.id) 
    7369 
    7470    def __on_created(self, core, page): 
  • branch/UmitPlugins/source-plugins/localized-example/sources/main.py

    r3094 r3095  
    2121import gettext 
    2222 
     23from umitPlugin.Core import Core 
    2324from umitPlugin.Engine import Plugin 
    2425from umitPlugin.Atoms import StringFile 
     
    2728 
    2829class Localize(Plugin): 
    29     __type__ = "usual" 
    30      
    31     def start(self, core, reader): 
    32         self.core = core 
    33         self.reader = reader 
    34  
    35         cat = self.reader.bind_translation("localizer") 
     30    def start(self, reader): 
     31        cat = reader.bind_translation("localizer") 
    3632 
    3733        if cat: 
     
    4137        print _("What the hell are you doing?") 
    4238 
    43     def stop(self, core): 
     39    def stop(self): 
    4440        print _("Stopping localize ...") 
    4541 
  • branch/UmitPlugins/source-plugins/system-info-consumer/sources/main.py

    r3003 r3095  
    2121import os 
    2222import gtk 
     23 
     24from umitPlugin.Core import Core 
     25from umitPlugin.Engine import Plugin 
    2326from higwidgets.higdialogs import HIGAlertDialog 
    24 from umitPlugin.Engine import Plugin 
    2527 
    2628# This is the consumer Plugin 
    2729class SystemInfo(Plugin): 
    28     __type__ = "usual" 
    29      
    30     def start(self, core, reader): 
    31         self.core = core 
     30    def start(self, reader): 
    3231        self.reader = reader 
    33  
    34         print "CORE IS", self.core 
    3532 
    3633        self.sysinfo = self.core.get_need(self.reader, 'SystemInfo') 
     
    5653 
    5754 
    58     def stop(self, core): 
     55    def stop(self): 
    5956        pass 
    6057 
  • branch/UmitPlugins/source-plugins/system-info/sources/main.py

    r3003 r3095  
    3333 
    3434class SystemInfo(Plugin): 
    35     __type__ = "usual" 
    36      
    3735    def start(self, core, reader): 
    38         self.core = core 
    39         self.reader = reader 
     36        pass 
    4037 
    4138    def stop(self, core): 
  • branch/UmitPlugins/source-plugins/tabber/sources/main.py

    r3022 r3095  
    2525import tabber.views as views 
    2626 
     27from umitPlugin.Core import Core 
    2728from umitPlugin.Engine import Plugin 
    2829 
    2930class TabberPlugin(Plugin): 
    30     __type__ = "usual" 
    31      
    32     def start(self, core, reader): 
    33         self.core = core 
     31    def start(self, reader): 
    3432        self.reader = reader 
    3533 
    3634        self._paned = paned.UmitPaned() 
    3735 
    38         main = self.core.mainwindow 
     36        main = Core().mainwindow 
    3937        main.vbox.remove(main.scan_notebook) 
    4038        main.vbox.pack_start(self._paned) 
     
    4341        self._paned.show_all() 
    4442 
    45         # No statusbar 
    46         #main.vbox.reorder_child(self.core.get_main_statusbar(), -1) 
    47  
    48     def stop(self, core): 
    49         main = self.core.mainwindow 
     43    def stop(self): 
     44        main = Core().mainwindow 
    5045        self._paned.hide() 
    5146        self._paned.remove_child() 
     
    5348        main.vbox.pack_start(main.scan_notebook) 
    5449 
    55     def get_viewsmod(self): 
    56         return views 
    57     def get_panedmod(self): 
    58         return paned 
    59  
    6050    def get_paned(self): 
    6151        return self._paned 
    6252 
    6353    # Public APIs 
    64     viewsmod = property(get_viewsmod) 
    65     panedmod = property(get_panedmod) 
    6654    paned = property(get_paned) 
    6755 
  • branch/UmitPlugins/source-plugins/terminal-pad/sources/main.py

    r3028 r3095  
    2323import gobject 
    2424 
     25from umitPlugin.Core import Core 
     26from umitPlugin.Engine import Plugin 
     27 
    2528from higwidgets.higtooltips import * 
    2629from higwidgets.hignotebooks import HIGAnimatedTabLabel 
    27 from umitPlugin.Engine import Plugin 
    2830 
    2931class TerminalPage(gtk.Bin): 
     
    5557 
    5658class TerminalPlugin(Plugin): 
    57     __type__ = "usual" 
    58      
    59     def start(self, core, reader): 
    60         self.core = core 
     59    def start(self, reader): 
    6160        self.reader = reader 
    6261 
     
    7069 
    7170        # Append our item 
    72         self.core.get_main_toolbar().insert(self.item, -1) 
     71        Core().get_main_toolbar().insert(self.item, -1) 
    7372        self.item.connect('clicked', self.__on_create_page) 
    7473        self.item.show_all() 
    7574 
    76     def stop(self, core): 
    77         self.core.get_main_toolbar().remove(self.item) 
     75    def stop(self): 
     76        Core().get_main_toolbar().remove(self.item) 
    7877 
    7978    def __on_create_page(self, widget): 
    80         nb = self.core.get_main_scan_notebook() 
     79        nb = Core().get_main_scan_notebook() 
    8180 
    8281        widget = TerminalPage() 
     
    8988 
    9089    def __on_close_page(self, widget, page): 
    91         nb = self.core.get_main_scan_notebook() 
     90        nb = Core().get_main_scan_notebook() 
    9291        idx = gtk.Notebook.page_num(nb, page) 
    9392 
  • branch/UmitPlugins/source-plugins/tray-icon/sources/main.py

    r3003 r3095  
    2525 
    2626class TrayPlugin(Plugin): 
    27     __type__ = "usual" 
    28      
    29     def start(self, core, reader): 
    30         self.core = core 
     27    def start(self, reader): 
    3128        self.reader = reader 
    3229 
     
    3431        self.icon.connect('popup-menu', self.__on_right_click) 
    3532 
    36     def stop(self, core): 
     33    def stop(self): 
    3734        self.icon.set_visible(False) 
    3835        self.icon = None 
    39  
    40         self.core = None 
    41         self.reader = None 
    4236 
    4337    def __on_right_click(self, w, evt, evt_time): 
  • branch/UmitPlugins/source-plugins/umit-console/sources/main.py

    r3093 r3095  
    2929 
    3030from umitCore.I18N import _ 
     31from umitPlugin.Core import Core 
    3132from umitPlugin.Engine import Plugin 
    3233from umitPlugin.Atoms import Singleton 
     
    164165 
    165166class ConsolePlugin(Plugin): 
    166     __type__ = "usual" 
    167      
    168     def start(self, core, reader): 
    169         self.core = core 
     167    def start(self, reader): 
    170168        self.reader = reader 
    171169 
    172         tabber = self.core.get_need(self.reader, 'Tabber') 
     170        tabber = Core().get_need(self.reader, 'Tabber') 
    173171        tabber.paned.add_view(paned.PANE_BOTTOM, ConsoleView()) 
    174172 
    175     def stop(self, core): 
     173    def stop(self): 
    176174        pass 
    177175 
  • branch/UmitPlugins/umitPlugin/Tree.py

    r3090 r3095  
    491491                #try: 
    492492                inst = plug() 
    493                 inst.start(Core(), pkg) 
     493                inst.start(pkg) 
    494494 
    495495                ret.append(inst) 
     
    520520        for inst in self.instances[pkg]: 
    521521            try: 
    522                 inst.stop(Core()) 
     522                inst.stop() 
    523523            except Exception, err: 
    524524                log.critical("Error while stopping %s from %s:" % (inst, pkg))