Comment 23 for bug 540950

Revision history for this message
Eemil Lagerspetz (eemil-lagerspetz) wrote :

I used 169 as a base and separated it into the dockbarx module and the launcher/factory. This has not failed yet, and I have tested it many times. Other applets, for example the deskbar applet, use a similar format: a launcher of less than 200 lines, and multiple imported modules.

I moved dockbarx.py to /usr/lib/python2.6/dist-packages. After that, it can be imported with import dockbarx.
I call the following factory class dockbarx_factory.py:

#!/usr/bin/python

# Copyright 2008, 2009, 2010 Aleksey Shaferov and Matias Sars
#
# DockBar is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DockBar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with dockbar. If not, see <http://www.gnu.org/licenses/>.

import pygtk
pygtk.require('2.0')
import gtk
import gobject
import gnomeapplet
import sys
import dockbarx

def dockbar_factory(applet, iid):
    dockbar = dockbarx.DockBar(applet)
    applet.set_background_widget(applet)
    applet.show_all()
    return True

if len(sys.argv) == 2 and sys.argv[1] == "run-in-window":
    dockbarwin = dockbarx.DockBarWindow()
    dockbarwin.main()
else:
    gnomeapplet.bonobo_factory("OAFIID:GNOME_DockBarXApplet_Factory",
        gnomeapplet.Applet.__gtype__,
        "dockbar applet", "0", dockbar_factory)

Now, this factory class needs to be referenced in the bonobo server description:

--- GNOME_DockBarXApplet.server 2010-04-29 00:00:04.496690000 +0300
+++ GNOME_DockBarXApplet.server.modular 2010-04-29 01:35:30.285671672 +0300
@@ -1,5 +1,5 @@
 <oaf_info>
-<oaf_server iid="OAFIID:GNOME_DockBarXApplet_Factory" type="exe" location="/usr/bin/dockbarx.py">
+<oaf_server iid="OAFIID:GNOME_DockBarXApplet_Factory" type="exe" location="/usr/bin/dockbarx_factory.py">

     <oaf_attribute name="repo_ids" type="stringv">
         <item value="IDL:Bonobo/GenericFactory:1.0"/>

And that's it.