| Server IP : 182.53.201.61 / Your IP : 216.73.217.175 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/gtk-doc/html/panel-applet/ |
Upload File : |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Porting Applets from the GNOME 1.x interfaces</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Panel Applet Library Reference Manual">
<link rel="up" href="index.html" title="Panel Applet Library Reference Manual">
<link rel="prev" href="multi-applets.html" title="Multiple Applets">
<link rel="next" href="panel-applet.html" title="The Panel Applet Library">
<meta name="generator" content="GTK-Doc V1.12 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="applet-writing.html" title="Writing Applets">
<link rel="chapter" href="applet-porting.html" title="Porting Applets from the GNOME 1.x interfaces">
<link rel="chapter" href="panel-applet.html" title="The Panel Applet Library">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="multi-applets.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td> </td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Panel Applet Library Reference Manual</th>
<td><a accesskey="n" href="panel-applet.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="chapter" title="Porting Applets from the GNOME 1.x interfaces">
<div class="titlepage"><div><div><h2 class="title">
<a name="applet-porting"></a>Porting Applets from the GNOME 1.x interfaces</h2></div></div></div>
<p>In GNOME 1.x the applet interface lived in a header called
<code class="filename">applet-widget.h</code>. The interface was based on GOAD,
the GNOME 1.x object activation framework. A new interface was
designed for GNOME 2.x using the power of bonobo UI embedding and the
new object activation framework, bonobo-activation. The interface is
intended to be easy to use, cruft free, but semantically similar to
the old API in order to make porting relatively painless.</p>
<div class="simplesect" title="Applet Activation">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="applet-porting-activation"></a>Applet Activation</h2></div></div></div>
<p>The first thing to change when porting to the new API is
the header. Include <code class="filename">panel-applet.h</code> instead of
<code class="filename">applet-widget.h</code>.</p>
<p>Next you need to change how the applet is activated.
Browsing through old applet's code, its obvious that this was done in
various ways in the past. The best advice is to hunt out the calls to
applet_widget_init, applet_widget_new and applet_widget_add.
applet_widget_new and applet_widget_add are now effectively merged
into one call panel_applet_new, to which the top-level widget of the
applet should be passed. applet_widget_init is not neccessary anymore.
So the new code should look something like this</p>
<pre class="programlisting">
#include <panel-applet.h>
static BonoboObject *
blah_applet_new ()
{
PanelApplet *applet;
/*
* The old code setting up the applet widgetry
* goes here. So effectively delete calls to
* applet_widget_init and applet_widget_new
* and the replace applet_widget_add with a call
* to panel_applet_new.
*/
applet = panel_applet_new (label);
return BONOBO_OBJECT (panel_applet_get_control (applet));
}
static BonoboObject *
blah_applet_factory (BonoboGenericFactory *this,
const gchar *iid,
gpointer data)
{
BonoboObject *applet = NULL;
if (!strcmp (iid, "OAFIID:BlahApplet"))
applet = blah_applet_new ();
return applet;
}
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:BlahApplet_Factory",
"Blah",
"0",
blah_applet_factory,
NULL)
</pre>
<p>You should use PANEL_APPLET_BONOBO_FACTORY or
PANEL_APPLET_BONOBO_SHLIB_FACTORY depending on whether you want the
applet to be out of process or in process.</p>
</div>
<div class="simplesect" title="Activation files">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="applet-porting-activation-files"></a>Activation files</h2></div></div></div>
<p>The next thing to do may be to port from a
<code class="filename">.gnorba</code> file to a bonobo-activation
<code class="filename">.server</code> file. You no longer need a .desktop file
for applets. A <code class="filename">.gnorba</code> looks something like this
:</p>
<pre class="programlisting">
[blah]
type=exe
repo_id=IDL:GNOME/Applet:1.0
description=Blah
location_info=blah-de-blah
</pre>
<p>Your <code class="filename">.server</code> file should look like
this :</p>
<pre class="programlisting">
<oaf_info>
<oaf_server iid="OAFIID:BlahApplet"
type="exe"
location="blah-de-blah-2">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:Bonobo/GenericFactory:1.0""/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" value="Blah Factory"/>
<oaf_attribute name="description" type="string" value="Blah De Blah"/>
</oaf_server>
<oaf_server iid="OAFIID:BlahApplet"
type="factory"
location="OAFIID:BlahApplet_Factory">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/PanelAppletShell:1.0"/>
<item value="IDL:Bonobo/Control:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" value="Blah Applet"/>
<oaf_attribute name="description" type="string" value="Blah De Blah"/>
<oaf_attribute name="panel:icon" type="string" value="blah-de-blah.png"/>
</oaf_server>
</oaf_info>
</pre>
<p>A lot of this should be copied and pasted. The most
important bit is "panel:icon" which specfies the icon
that should be displayed in the "Add to Panel" dialog.</p>
</div>
<div class="simplesect" title="Context Menu">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="applet-porting-menus"></a>Context Menu</h2></div></div></div>
<p>Most applets also place extra menu items into it context
menu. It might be a good idea to port this next. In GNOME 1.x this was
done using the applet_widget_register_stock_callback API call. In
GNOME 2.x 3 things must be done</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>An xml desription of the popup menu must be
written.</p></li>
<li class="listitem"><p>A description of the verbs must be prepared.
This is basically a list of callbacks to be call when a certain menu
item is clicked in the popup.</p></li>
<li class="listitem"><p>The menu is registered using a call to
panel_applet_setup_menu.</p></li>
</ul></div>
<p>The xml description should look something like this
:</p>
<pre class="programlisting">
static const char fish_menu_xml [] =
"<popup name=\"button3\">\n"
" <menuitem name=\"Properties Item\" verb=\"BlahProperties\" _label=\"Properties ...\"\n"
" pixtype=\"stock\" pixname=\"gtk-properties\"/>\n"
" <menuitem name=\"Help Item\" verb=\"BlahHelp\" _label=\"Help\"\n"
" pixtype=\"stock\" pixname=\"gtk-help\"/>\n"
" <menuitem name=\"About Item\" verb=\"BlahAbout\" _label=\"About ...\"\n"
" pixtype=\"stock\" pixname=\"gnome-stock-about\"/>\n"
"</popup>\n";
</pre>
<p>This could also be in a seperate
<code class="filename">.xml</code> file and loaded with
panel_applet_setup_menu_from_file. The description of the verbs should
look something like :</p>
<pre class="programlisting">
static const BonoboUIVerb fish_menu_verbs [] = {
BONOBO_UI_VERB ("BlahProperties", display_properties_dialog),
BONOBO_UI_VERB ("BlahHelp", display_help_dialog),
BONOBO_UI_VERB ("BlahAbout", display_about_dialog),
BONOBO_UI_VERB_END
};
</pre>
<p>This is just a list of callbacks invoked when the menu
items are clicked. There are other macros you may use other than
BONOBO_UI_VERB - see
<code class="filename">bonobo-ui-component.h</code>.</p>
<p>To actually register the menu you just do something like
:</p>
<pre class="programlisting">
panel_applet_setup_menu (PANEL_APPLET (blah->applet),
blah_menu_xml,
blah_menu_verbs,
blah);
</pre>
<p>The last argument is the user_data argument passed back
to the callbacks.</p>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.12</div>
</body>
</html>