~ubuntu-branches/ubuntu/oneiric/gnome-panel/oneiric

« back to all changes in this revision

Viewing changes to doc/reference/panel-applet/html/applet-writing.html

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-05-30 11:04:49 UTC
  • mfrom: (1.3.4 upstream)
  • mto: This revision was merged to the branch mainline in revision 204.
  • Revision ID: james.westby@ubuntu.com-20110530110449-ut1tc5t61rpvf9e3
Tags: upstream-3.0.2
Import upstream version 3.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
 
<html>
3
 
<head>
4
 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
 
<title>Writing Applets</title>
6
 
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7
 
<link rel="home" href="index.html" title="Panel Applet Library Reference Manual">
8
 
<link rel="up" href="index.html" title="Panel Applet Library Reference Manual">
9
 
<link rel="prev" href="index.html" title="Panel Applet Library Reference Manual">
10
 
<link rel="next" href="server-files.html" title="Bonobo Activation .server Files For Applets">
11
 
<meta name="generator" content="GTK-Doc V1.15.1 (XML mode)">
12
 
<link rel="stylesheet" href="style.css" type="text/css">
13
 
</head>
14
 
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15
 
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
16
 
<td><a accesskey="p" href="index.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17
 
<td> </td>
18
 
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
19
 
<th width="100%" align="center">Panel Applet Library Reference Manual</th>
20
 
<td><a accesskey="n" href="server-files.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
21
 
</tr></table>
22
 
<div class="chapter">
23
 
<div class="titlepage"><div><div><h2 class="title">
24
 
<a name="applet-writing"></a>Writing Applets</h2></div></div></div>
25
 
<div class="toc"><dl>
26
 
<dt><span class="sect1"><a href="applet-writing.html#hello-world">Hello World Applet</a></span></dt>
27
 
<dt><span class="sect1"><a href="server-files.html">Bonobo Activation .server Files For Applets</a></span></dt>
28
 
<dt><span class="sect1"><a href="applet-popups.html">Defining a Popup Context Menu</a></span></dt>
29
 
<dt><span class="sect1"><a href="panel-signals.html">Detecting Changes in the Panel.</a></span></dt>
30
 
<dt><span class="sect1"><a href="session-saving.html">Session/Preference Saving.</a></span></dt>
31
 
<dt><span class="sect1"><a href="multi-applets.html">Multiple Applets</a></span></dt>
32
 
</dl></div>
33
 
<p>Writing applets is very simple. You take some boiler plate
34
 
code like below, change a couple of things and write the code that
35
 
implements your widgetry. The hardest part is writing your widgetry -
36
 
and its completely up to yourself how hard that should be.
37
 
    </p>
38
 
<div class="sect1">
39
 
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
40
 
<a name="hello-world"></a>Hello World Applet</h2></div></div></div>
41
 
<p>As usual, following the pointless tradition of starting with
42
 
an example of how get 'Hello World' on the screen in some form, here's
43
 
just about the simplest applet you could write.
44
 
      </p>
45
 
<pre class="programlisting">
46
 
#include &lt;string.h&gt;
47
 
 
48
 
#include &lt;panel-applet.h&gt;
49
 
#include &lt;gtk/gtklabel.h&gt;
50
 
 
51
 
static gboolean
52
 
hello_applet_fill (PanelApplet *applet,
53
 
                   const gchar *iid,
54
 
                   gpointer     data)
55
 
{
56
 
        GtkWidget *label;
57
 
 
58
 
        if (strcmp (iid, "OAFIID:My_HelloApplet") != 0)
59
 
                return FALSE;
60
 
 
61
 
        label = gtk_label_new ("Hello World");
62
 
        gtk_container_add (GTK_CONTAINER (applet), label);
63
 
 
64
 
        gtk_widget_show_all (GTK_WIDGET (applet));
65
 
 
66
 
        return TRUE;
67
 
}
68
 
 
69
 
 
70
 
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:My_HelloApplet_Factory",
71
 
                             PANEL_TYPE_APPLET,
72
 
                             "TheHelloWorldApplet",
73
 
                             "0",
74
 
                             hello_applet_fill,
75
 
                             NULL);
76
 
      </pre>
77
 
<p>The code here is very similar to writing a normal Bonobo
78
 
control. You define a factory using PANEL_APPLET_BONOBO_FACTORY(),
79
 
passing it a factory function like hello_applet_fill().
80
 
      </p>
81
 
<p>libpanel-applet automatically creates a #PanelApplet object
82
 
for you, passing this to your factory method. Here, you should fill
83
 
the applet with your widgets just like a #GtkBin. For example, if you
84
 
were writing a cdplayer applet you would create a #GtkHBox, pack the
85
 
hbox with the cdplayer buttons and in turn add the hbox to the applet.
86
 
      </p>
87
 
</div>
88
 
</div>
89
 
<div class="footer">
90
 
<hr>
91
 
          Generated by GTK-Doc V1.15.1</div>
92
 
</body>
93
 
</html>
 
 
b'\\ No newline at end of file'