Mercurial > pidgin
annotate doc/SIGNAL-HOWTO.dox @ 25306:7d6866244106
make this togglable via env rather than #define
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Sun, 11 Jan 2009 22:27:23 +0000 |
parents | f3e0b1221765 |
children |
rev | line source |
---|---|
19025
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
1 /** @page signal-howto Signals HOWTO |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
2 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
3 @section Introduction |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
4 The libpurple signals interface is used for general event notification, such |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
5 as plugins being loaded or unloaded, allowing the GUI frontend to respond |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
6 appropriately to changing internal data. Unfortunately, its use is not at all |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
7 obvious from the information in the header files. This document uses code |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
8 snippets from the Pidgin/libpurple plugin systems to illustrate the proper |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
9 use of signals. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
10 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
11 @section overview Overview of Signals |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
12 Signals in libpurple are very similar to those in GTK+. When certain events |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
13 happen, a named signal is "emitted" from a certain object. Emitting the |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
14 signal triggers a series of callbacks that have been "connected" to that |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
15 signal for that object. These callbacks take appropriate action in response |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
16 to the signal. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
17 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
18 @section registering_signal Registering a Signal |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
19 The first step of using a signal is registering it with libpurple so that |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
20 callbacks may be connected to it. This is done using purple_signal_register() |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
21 Here is a slightly modified example from @c purple_plugins_init in |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
22 @c libpurple/plugin.c : |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
23 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
24 @code |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
25 purple_signal_register( purple_plugins_get_handle(), /* Instance */ |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
26 "plugin-load", /* Signal name */ |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
27 purple_marshal_VOID__POINTER,/* Marshal function */ |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
28 NULL, /* Callback return value type */ |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
29 1, /* Number of callback arguments (not including void *data) */ |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
30 purple_value_new(PURPLE_TYPE_SUBTYPE,PURPLE_SUBTYPE_PLUGIN) /* Type of first callback argument */ |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
31 ); |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
32 @endcode |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
33 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
34 @subsection Instance |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
35 A reference to the object from which this signal is emitted, and to which |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
36 potential callbacks should be connected. In this case, it will be the entire |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
37 plugin module emitting the signal. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
38 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
39 @subsection signalname Signal Name |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
40 Unique identifier for the signal itself. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
41 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
42 @subsection therest Callback function definition |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
43 The rest of the arguments specify the form of the callback function. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
44 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
45 @subsubsection marshalfunc Marshal Function |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
46 @c purple_marshal_VOID__POINTER represents the callback function prototype, |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
47 not including a "data" argument, explained later. The form is |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
48 @c purple_marshal_RETURNVALUETYPE__ARG1TYPE_ARG2TYPE_ETC. See signals.h for |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
49 more possible types. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
50 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
51 In this case, the callback will have the form |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
52 @code |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
53 void cb(void *arg1, void *data) |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
54 @endcode |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
55 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
56 If @c purple_marshal_BOOLEAN__POINTER_POINTER_POINTER were specified, it |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
57 would be: |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
58 @code |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
59 gboolean cb(void *arg1, void *arg2, void *arg3, void *data) |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
60 @endcode |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
61 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
62 The @c void @c *data argument at the end of each callback function |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
63 provides the data argument given to purple_signal_connect() . |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
64 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
65 @subsubsection cb_ret_type Callback return value type |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
66 In our case, this is NULL, meaning "returns void". |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
67 @todo This could be described better. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
68 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
69 @subsubsection num_args Number of arguments |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
70 The number of arguments (not including @c data ) that the callback function |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
71 will take. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
72 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
73 @subsubsection type_arg Type of argument |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
74 @c purple_value_new(PURPLE_TYPE_SUBTYPE,PURPLE_SUBTYPE_PLUGIN) specifies that |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
75 the first argument given to the callback will be a @c PurplePlugin* . You |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
76 will need as many "type of argument" arguments to purple_signal_register() as |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
77 you specified in "Number of arguments" above. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
78 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
79 @todo Describe this more. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
80 |
19685
f3e0b1221765
This will silence a few warnings when building the Doxygen docs.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19025
diff
changeset
|
81 @see value.h |
19025
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
82 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
83 @section connect Connecting to the signal |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
84 Once the signal is registered, you can connect callbacks to it. First, you |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
85 must define a callback function, such as this one from gtkplugin.c : |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
86 @code |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
87 static void plugin_load_cb(PurplePlugin *plugin, gpointer data) |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
88 { |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
89 GtkTreeView *view = (GtkTreeView *)data; |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
90 plugin_loading_common(plugin, view, TRUE); |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
91 } |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
92 @endcode |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
93 Note that the callback function prototype matches that specified in the call |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
94 to purple_signal_register() above. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
95 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
96 Once the callback function is defined, you can connect it to the signal. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
97 Again from gtkplugin.c , in @c pidgin_plugin_dialog_show() : |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
98 @code |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
99 purple_signal_connect(purple_plugins_get_handle(), "plugin-load", /* What to connect to */ |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
100 plugin_dialog, /* Object receiving the signal */ |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
101 PURPLE_CALLBACK(plugin_load_cb), /* Callback function */ |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
102 event_view, /* Data to pass to the callback function |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
103 ); |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
104 @endcode |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
105 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
106 The first two arguments ("What to connect to") specify the object emitting |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
107 the signal (the plugin module) and what signal to listen for ("plugin-load"). |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
108 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
109 The object receiving the signal is @c plugin_dialog , the Pidgin plugins |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
110 dialog. When @c plugin_dialog is deleted, then |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
111 @c purple_signals_disconnect_by_handle(plugin_dialog) should be called to |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
112 remove all signal connections it is associated with. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
113 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
114 The callback function is given using a helper macro, and finally the |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
115 @c data argument to be passed to @c plugin_load_cb is given as @c event_view, |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
116 a pointer to the GTK widget that @c plugin_load_cb needs to update. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
117 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
118 @section emit-signal Emitting a signal |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
119 Connecting callbacks to signals is all well and good, but how do you "fire" |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
120 the signal and trigger the callback? At some point, you must "emit" the |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
121 signal, which immediately calls all connected callbacks. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
122 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
123 As seen in @c purple_plugin_load() in plugin.c : |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
124 @code |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
125 purple_signal_emit(purple_plugins_get_handle(), "plugin-load", plugin); |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
126 @endcode |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
127 This causes the signal "plugin-load" to be emitted from the plugin module |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
128 (given by @c purple_plugins_get_handle() ), with the newly loaded plugin as |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
129 the argument to pass to any registered callback functions. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
130 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
131 In our example, @c plugin_load_cb is called immediately as |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
132 @code |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
133 plugin_load_cb(plugin, event_view); |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
134 @endcode |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
135 and does whatever it does. |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
136 |
c3e80350c270
- Added a lovely Doxygen signals tutorial
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
137 */ |