This file is indexed.

/usr/share/gtk-doc/html/libanjuta/writing-plugins-sources.html is in libanjuta-dev 2:3.4.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello world advanced plugin</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="Anjuta Developers Reference Manual">
<link rel="up" href="writing-plugins.html" title="Writing plugins">
<link rel="prev" href="writing-plugins-simple.html" title="Hello world plugin">
<link rel="next" href="writing-plugins-build-setup.html" title="Build setup">
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</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="writing-plugins-simple.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="writing-plugins.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></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">Anjuta Developers Reference Manual</th>
<td><a accesskey="n" href="writing-plugins-build-setup.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="writing-plugins-sources"></a>Hello world advanced plugin</h2></div></div></div>
<p>
			We begin by writing the header file hello-world.h. It is a
			standard <span class="type">GObject</span>
			class definition, minus
			the standard macro definitions. You can define the macros if
			you want, but for our hello-world plugin, we don't need it and
			have been removed for simplicity. Notice that our HelloWorldPlugin
			class is derived from abstract <GTKDOCLINK HREF="">
			<span class="type">AnjutaPlugin</span></GTKDOCLINK>
			class. All Anjuta plugins derive from this base class.

			</p>
<pre class="programlisting">
#ifndef _HELLO_WORLD_PLUGIN_
#define _HELLO_WORLD_PLUGIN_

#include &lt;libanjuta/anjuta-plugin.h&gt;

typedef struct {
	AnjutaPlugin parent;
	
	/* Hello world widget */
	GtkWidget *widget;
	
	/* Action group */
	GObject* action_group;
	
	/* UI merge ID. Required to unmerge it later */
	gint uiid;
	
} HelloWorldPlugin;

typedef struct {
	AnjutaPluginClass parent_class;
} HelloWorldPluginClass;

#endif
			</pre>
<p>
		</p>
<p>
			Next implement our plugin in hello-world.c file. We
			will be accessing a Document Manager plugin using
			<span class="type">IAnjutaDocumentManager</span>
			interface, because
			all document manager plugins implement and expose this interface.
			If you use other interfaces, you can include their respective
			<a class="xref" href="plugin-interfaces.html" title="Plugin interfaces"><i>Plugin interfaces</i></a>. For our hello-world plugin
			we begin by including following header files.
			</p>
<pre class="programlisting">
/* Project configuration file */
#include &lt;config.h&gt;

/* Document manager interface */
#include &lt;libanjuta/interfaces/ianjuta-document-manager.h&gt;

/* plugin header file */
#include "hello-world.h"

/* Parent class. Part of standard class definition */
static gpointer parent_class;
			</pre>
<p>
		</p>
<p>
			We have one action in our plugin and here is the callback for that.
			In this function, we are quering
			<span class="type">AnjutaShell</span>
			for a plugin implementing
			<span class="type">IAnjutaDocumentManager</span>
			interface and getting the current Editor. Editor is then checked
			to see if it implements
			<span class="type">IAnjutaFile</span>
			interface,
			using which we deternime filename of currently active editor. If
			the editor doesn't support
			<span class="type">IAnjutaFile</span>
			interface, we show an error dialog.
			</p>
<pre class="programlisting">
static void
on_hello_action_activate (GtkAction *action, HelloWorldPlugin *plugin)
{
	IAnjutaDocument *doc;
	IAnjutaDocumentManager *docman;
	GtkWindow *parent_win;
	gchar *filename;
	
	/* We are using Anjuta widow as parent for displaying the dialog */
	parent_win = GTK_WINDOW (ANJUTA_PLUGIN (plugin)-&gt;shell);
	
	/* Query for object implementing IAnjutaDocumentManager interface */
	docman = anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)-&gt;shell,
	                                     IAnjutaDocumentManager, NULL);
	                                     
	/* Get current document */
	doc = ianjuta_document_manager_get_current_document (docman, NULL);
	filename = ianjuta_document_get_filename (doc, NULL);
		
	/* Display the filename */
	anjuta_util_dialog_info (parent_win,
	                         "Current filename is: %s", filename);
	g_free (filename);
}
			</pre>
<p>
		</p>
<p>
			We then define our action entry. This is required for registering
			actions and UI merging. If your plugin doesn't have UI, they are
			not required. We have only one action, so there is only one entry
			defined. Read <a class="link" href="AnjutaUI.html" title="AnjutaUI"><span class="type">AnjutaUI</span></a>
			and <a href="http://library.gnome.org/devel/gtk/GtkUIManager.html"><span class="type">GtkUIManager</span></a>
			for more details.
			</p>
<pre class="programlisting">
static GtkActionEntry actions[] = {
	{
		"ActionFileHelloWorld",                   /* Action name */
		GTK_STOCK_NEW,                            /* Stock icon, if any */
		N_("_Hello world action"),                /* Display label */
		NULL,                                     /* short-cut */
		N_("This is hello world action"),         /* Tooltip */
		G_CALLBACK (on_hello_action_activate)    /* action callback */
	}
};
			</pre>
<p>
		</p>
<p>
			We then implement <span class="emphasis"><em>activate()</em></span> and <span class="emphasis"><em>
			deactivate()</em></span> virtual methods of <a class="link" href="AnjutaPlugin.html" title="AnjutaPlugin">
			<span class="type">AnjutaPlugin</span></a>
			class. They are called when plugin is activated and deactivated
			respectively. We put our UI merging, action registration and
			widgets additions in activate() method and undo them in deactivate()
			method.
			</p>
<pre class="programlisting">
#define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-hello-world.ui"

static void
activate_plugin (AnjutaPlugin *plugin)
{
	GtkWidget *wid;
	AnjutaUI *ui;
	HelloWorldPlugin *hello_plugin;
	GtkActionGroup* action_group;
	
	hello_plugin = (HelloWorldPlugin*) plugin;
	ui = anjuta_shell_get_ui (plugin-&gt;shell, NULL);
	
	/* Create hello plugin widget */
	wid = gtk_label_new ("Hello World Plugin!!");
	hello_plugin-&gt;widget = wid;
	
	/* Add our actions */
	action_group =
	    anjuta_ui_add_action_group_entries (ui, "ActionGroupHello",
	                                        _("Hello world"),
	                                        actions,
	                                        G_N_ELEMENTS (actions),
	                                        plugin);
	hello_plugin-&gt;action_group = action_group;
	
	/* Merge UI */
	hello_plugin-&gt;uiid = anjuta_ui_merge (ui, UI_FILE);
	
	/* Add widget in Shell. Any number of widgets can be added */
	anjuta_shell_add_widget (plugin-&gt;shell, wid,
	                         "AnjutaHelloWorldPlugin",
	                         _("HelloWorldPlugin"),
	                         GTK_STOCK_ABOUT,
	                         ANJUTA_SHELL_PLACEMENT_CENTER,
	                         NULL);
	
	return TRUE; /* FALSE if activation failed */
}

static gboolean
deactivate_plugin (AnjutaPlugin *plugin)
{
	AnjutaUI *ui;
	HelloWorldPlugin *hello_plugin;
	
	hello_plugin = (HelloWorldPlugin*) plugin;
	ui = anjuta_shell_get_ui (plugin-&gt;shell, NULL);
	
	/* Remove widgets from Shell */
	anjuta_shell_remove_widget (plugin-&gt;shell,
	                            hello_plugin-&gt;widget,
	                            NULL);
	/* Unmerge UI */
	anjuta_ui_unmerge (ui, hello_plugin-&gt;uiid);
	
	/* Remove Action groups */
	anjuta_ui_remove_action_group (ui, hello_plugin-&gt;action_group);
	
	/* FALSE if plugin doesn't want to deactivate */
	return TRUE;
}
			</pre>
<p>
		</p>
<p>
			Followed by standard class definition. Notice that activate()
			and deactivate() methods are overridden in class_init() function.
			</p>
<pre class="programlisting">
static void
hello_world_plugin_instance_init (GObject *obj)
{
	HelloWorldPlugin *plugin = (HelloWorldPlugin*) obj;
	plugin-&gt;uiid = 0;
	plugin-&gt;widget = NULL;
	plugin-&gt;action_group = NULL;
}

static void
hello_world_plugin_class_init (GObjectClass *klass) 
{
	AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);

	parent_class = g_type_class_peek_parent (klass);

	plugin_class-&gt;activate = activate_plugin;
	plugin_class-&gt;deactivate = deactivate_plugin;
}

/* This line will change when we implement interfaces */
ANJUTA_PLUGIN_BOILERPLATE (HelloWorldPlugin, hello_world_plugin);

/* This sets up codes to register our plugin */
ANJUTA_SIMPLE_PLUGIN (HelloWorldPlugin, hello_world_plugin);
			</pre>
<p>
			That's it. We can now create the build structure to build it.
		</p>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.18</div>
</body>
</html>