~gary-lasker/software-center/launcher-integration-for-p

« back to all changes in this revision

Viewing changes to doc/example_plugin.py

  • Committer: Michael Vogt
  • Date: 2011-09-13 12:45:56 UTC
  • Revision ID: michael.vogt@ubuntu.com-20110913124556-x2unce5rmp16o040
* softwarecenter/ui/gtk3/app.py, debian/control:
  - renenable plugin loader 
  - add conflict against older oneconf as the old oneconf plugin
    will crash softwarecenter because of mixing pygtk with pygi
  - load plugins from $SOFTWARE_CENTER_PLUGINS_DIR, 
    /usr/share/software-center/plugins, 
    ~/.local/share/software-center/plugins (LP: #631457)
* doc/example_plugin.py:
  - updated to the gtk3 version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
 
import gtk
 
2
from gi.repository import Gtk, GObject
3
3
import sys
4
4
 
5
5
import softwarecenter.plugin
6
 
from softwarecenter.view.basepane import BasePane
 
6
 
7
7
 
8
8
from gettext import gettext as _
9
9
 
10
 
class ExamplePluginPane(gtk.VBox, BasePane):
11
 
    
12
 
    def __init__(self):
13
 
        gtk.VBox.__init__(self)
14
 
        self.pack_start(gtk.Label("Hello from the example plugin"))
15
 
    
16
 
 
17
10
class ExamplePlugin(softwarecenter.plugin.Plugin):
18
 
    """ mock plugin """
 
11
    """ example plugin that will hide the exhibits banner """
19
12
 
20
 
    VIEW_PAGE_EXAMPLE_PLUGIN = "view-page-example-plugin"
 
13
    def _try_to_hide_banner(self):
 
14
        if not self.app.available_pane.view_initialized:
 
15
            # wait for the pane to fully initialize
 
16
            return True
 
17
        self.app.available_pane.cat_view.vbox.get_children()[0].hide()
 
18
        return False
21
19
 
22
20
    def init_plugin(self):
23
21
        sys.stderr.write("init_plugin\n")
24
 
        self.plugin_view = ExamplePluginPane()
25
 
        self.app.view_manager.register(self.plugin_view, 
26
 
                                       self.VIEW_PAGE_EXAMPLE_PLUGIN)
27
 
 
28
 
        # FIXME: workaround for imperfect apps.py
29
 
        self.plugin_view.apps_filter = None
30
 
 
31
 
        # FIXME: this needs to get better
32
 
        model = self.app.view_switcher.get_model()
33
 
        icon = None
34
 
        parent_iter = None
35
 
        channel = None
36
 
        model.append(parent_iter, [icon,
37
 
                                   _("Example Plugin"), 
38
 
                                   self.VIEW_PAGE_EXAMPLE_PLUGIN, 
39
 
                                   channel, 
40
 
                                   None])
41
 
                     
 
22
 
 
23
        GObject.timeout_add(100, self._try_to_hide_banner)