Mercurial > pidgin
annotate src/plugins.c @ 94:9f6ce50ffb78
[gaim-migrate @ 104]
Woohoo, the landing of the plugins. Nearly everything necessary is here. The
only thing missing is that you can't load a plugin without signing on first
(at least, not without some trickery).
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 09 Apr 2000 11:18:25 +0000 |
parents | f3c6cf79f651 |
children | 247f540ea6e1 |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 * ---------------- | |
21 * The Plug-in plug | |
22 * | |
23 * Plugin support is currently being maintained by Mike Saraf | |
24 * msaraf@dwc.edu | |
25 * | |
90 | 26 * Well, I didn't see any work done on it for a while, so I'm going to try |
27 * my hand at it. - Eric warmenhoven@yahoo.com | |
28 * | |
1 | 29 */ |
30 | |
90 | 31 #ifdef GAIM_PLUGINS |
32 | |
1 | 33 #include <string.h> |
34 #include <sys/time.h> | |
35 | |
36 #include <sys/types.h> | |
37 #include <sys/stat.h> | |
38 | |
39 #include <unistd.h> | |
40 #include <stdio.h> | |
41 #include <stdlib.h> | |
42 #include <gtk/gtk.h> | |
43 #include "gaim.h" | |
44 | |
90 | 45 #include <dlfcn.h> |
46 | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
47 /* ------------------ Global Variables ----------------------- */ |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
48 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
49 GList *callbacks = NULL; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
50 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
51 /* ------------------ Local Variables ------------------------ */ |
1 | 52 |
90 | 53 static GtkWidget *plugin_dialog = NULL; |
54 static GList *plugins = NULL; | |
55 | |
56 static GtkWidget *pluglist; | |
57 static GtkWidget *plugtext; | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
58 static GtkWidget *plugwindow; |
1 | 59 |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
60 /* --------------- Function Declarations --------------------- */ |
1 | 61 |
90 | 62 void load_plugin (GtkWidget *, gpointer); |
63 void unload_plugin(GtkWidget *, gpointer); | |
64 void show_plugins (GtkWidget *, gpointer); | |
65 | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
66 void gaim_signal_connect (void *, enum gaim_event, void *, void *); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
67 void gaim_signal_disconnect(void *, enum gaim_event, void *); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
68 |
90 | 69 static void destroy_plugins (GtkWidget *, gpointer); |
70 static void load_which_plugin(GtkWidget *, gpointer); | |
71 static void unload (GtkWidget *, gpointer); | |
72 static void list_clicked (GtkWidget *, struct gaim_plugin *); | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
73 static void update_show_plugins(); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
74 static void hide_plugins (GtkWidget *, gpointer); |
90 | 75 |
1 | 76 /* ------------------ Code Below ---------------------------- */ |
77 | |
90 | 78 static void destroy_plugins(GtkWidget *w, gpointer data) { |
79 if (plugin_dialog) | |
80 gtk_widget_destroy(plugin_dialog); | |
81 plugin_dialog = NULL; | |
82 } | |
83 | |
84 void load_plugin(GtkWidget *w, gpointer data) | |
1 | 85 { |
90 | 86 char *buf = g_malloc(BUF_LEN); |
1 | 87 |
90 | 88 if (!plugin_dialog) { |
89 plugin_dialog = gtk_file_selection_new("Gaim - Plugin List"); | |
90 | |
91 gtk_file_selection_hide_fileop_buttons( | |
92 GTK_FILE_SELECTION(plugin_dialog)); | |
93 | |
94 if(getenv("PLUGIN_DIR") == NULL) { | |
95 g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), PLUGIN_DIR); | |
96 } else { | |
97 g_snprintf(buf, BUF_LEN - 1, "%s/", getenv("PLUGIN_DIR")); | |
98 } | |
1 | 99 |
90 | 100 gtk_file_selection_set_filename(GTK_FILE_SELECTION(plugin_dialog), buf); |
101 gtk_signal_connect(GTK_OBJECT(plugin_dialog), "destroy", | |
102 GTK_SIGNAL_FUNC(destroy_plugins), plugin_dialog); | |
103 | |
104 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->ok_button), | |
105 "clicked", GTK_SIGNAL_FUNC(load_which_plugin), NULL); | |
106 | |
107 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->cancel_button), | |
108 "clicked", GTK_SIGNAL_FUNC(destroy_plugins), NULL); | |
109 | |
110 } | |
111 | |
112 g_free(buf); | |
113 gtk_widget_show(plugin_dialog); | |
114 gdk_window_raise(plugin_dialog->window); | |
115 } | |
1 | 116 |
90 | 117 void load_which_plugin(GtkWidget *w, gpointer data) { |
118 struct gaim_plugin *plug; | |
119 void (*gaim_plugin_init)(); | |
120 char *(*cfunc)(); | |
121 char *error; | |
122 | |
123 plug = g_malloc(sizeof *plug); | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
124 plug->filename = g_strdup(gtk_file_selection_get_filename( |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
125 GTK_FILE_SELECTION(plugin_dialog))); |
90 | 126 /* do NOT OR with RTLD_GLOBAL, otherwise plugins may conflict |
127 * (it's really just a way to work around other people's bad | |
128 * programming, by not using RTLD_GLOBAL :P ) */ | |
129 plug->handle = dlopen(plug->filename, RTLD_LAZY); | |
130 if (!plug->handle) { | |
131 error = dlerror(); | |
132 do_error_dialog(error, "Plugin Error"); | |
133 g_free(plug); | |
134 return; | |
135 } | |
136 | |
137 if (plugin_dialog) | |
138 gtk_widget_destroy(plugin_dialog); | |
139 plugin_dialog = NULL; | |
1 | 140 |
90 | 141 gaim_plugin_init = dlsym(plug->handle, "gaim_plugin_init"); |
142 if ((error = dlerror()) != NULL) { | |
143 do_error_dialog(error, "Plugin Error"); | |
144 dlclose(plug->handle); | |
145 g_free(plug); | |
146 return; | |
147 } | |
148 | |
149 plugins = g_list_append(plugins, plug); | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
150 (*gaim_plugin_init)(plug->handle); |
1 | 151 |
90 | 152 cfunc = dlsym(plug->handle, "name"); |
153 if ((error = dlerror()) == NULL) | |
154 plug->name = (*cfunc)(); | |
155 else | |
156 plug->name = NULL; | |
1 | 157 |
90 | 158 cfunc = dlsym(plug->handle, "description"); |
159 if ((error = dlerror()) == NULL) | |
160 plug->description = (*cfunc)(); | |
161 else | |
162 plug->description = NULL; | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
163 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
164 update_show_plugins(); |
90 | 165 } |
1 | 166 |
90 | 167 void unload_plugin(GtkWidget *w, gpointer data) { |
168 /* FIXME */ | |
1 | 169 } |
170 | |
90 | 171 void show_plugins(GtkWidget *w, gpointer data) { |
172 /* most of this code was shamelessly stolen from prefs.c */ | |
173 GtkWidget *page; | |
174 GtkWidget *topbox; | |
175 GtkWidget *botbox; | |
176 GtkWidget *sw; | |
177 GtkWidget *label; | |
178 GtkWidget *list_item; | |
179 GtkWidget *sw2; | |
180 GtkWidget *add; | |
181 GtkWidget *remove; | |
182 GList *plugs = plugins; | |
183 struct gaim_plugin *p; | |
184 gchar buffer[1024]; | |
185 | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
186 if (plugwindow) return; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
187 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
188 plugwindow = gtk_window_new(GTK_WINDOW_DIALOG); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
189 gtk_widget_realize(plugwindow); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
190 aol_icon(plugwindow->window); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
191 gtk_container_border_width(GTK_CONTAINER(plugwindow), 10); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
192 gtk_window_set_title(GTK_WINDOW(plugwindow), "Gaim - Plugins"); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
193 gtk_widget_set_usize(plugwindow, 400, 250); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
194 gtk_signal_connect(GTK_OBJECT(plugwindow), "destroy", |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
195 GTK_SIGNAL_FUNC(hide_plugins), NULL); |
90 | 196 |
197 page = gtk_vbox_new(FALSE, 0); | |
198 topbox = gtk_hbox_new(FALSE, 0); | |
199 botbox = gtk_hbox_new(FALSE, 0); | |
200 | |
201 sw2 = gtk_scrolled_window_new(NULL, NULL); | |
202 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), | |
203 GTK_POLICY_AUTOMATIC, | |
204 GTK_POLICY_AUTOMATIC); | |
205 | |
206 pluglist = gtk_list_new(); | |
207 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), pluglist); | |
208 gtk_box_pack_start(GTK_BOX(topbox), sw2, TRUE, TRUE, 0); | |
209 | |
210 sw = gtk_scrolled_window_new(NULL, NULL); | |
211 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
212 GTK_POLICY_AUTOMATIC, | |
213 GTK_POLICY_AUTOMATIC); | |
214 | |
215 plugtext = gtk_text_new(NULL, NULL); | |
216 gtk_container_add(GTK_CONTAINER(sw), plugtext); | |
217 gtk_box_pack_start(GTK_BOX(topbox), sw, TRUE, TRUE, 0); | |
218 gtk_text_set_word_wrap(GTK_TEXT(plugtext), TRUE); | |
219 gtk_text_set_editable(GTK_TEXT(plugtext), FALSE); | |
220 | |
221 add = gtk_button_new_with_label("Load Plugin"); | |
222 gtk_signal_connect(GTK_OBJECT(add), "clicked", | |
223 GTK_SIGNAL_FUNC(load_plugin), NULL); | |
224 gtk_box_pack_start(GTK_BOX(botbox), add, TRUE, FALSE, 5); | |
225 | |
226 remove = gtk_button_new_with_label("Unload Plugin"); | |
227 gtk_signal_connect(GTK_OBJECT(remove), "clicked", | |
228 GTK_SIGNAL_FUNC(unload), pluglist); | |
229 gtk_box_pack_start(GTK_BOX(botbox), remove, TRUE, FALSE, 5); | |
230 | |
231 gtk_box_pack_start(GTK_BOX(page), topbox, TRUE, TRUE, 0); | |
232 gtk_box_pack_start(GTK_BOX(page), botbox, FALSE, FALSE, 0); | |
233 | |
234 if (plugs != NULL) { | |
235 p = (struct gaim_plugin *)plugs->data; | |
236 g_snprintf(buffer, sizeof(buffer), "%s", p->filename); | |
237 gtk_text_insert(GTK_TEXT(plugtext), NULL, NULL, NULL, buffer, -1); | |
238 } | |
239 | |
240 while (plugs) { | |
241 p = (struct gaim_plugin *)plugs->data; | |
242 label = gtk_label_new(p->filename); | |
243 list_item = gtk_list_item_new(); | |
244 gtk_container_add(GTK_CONTAINER(list_item), label); | |
245 gtk_signal_connect(GTK_OBJECT(list_item), "select", | |
246 GTK_SIGNAL_FUNC(list_clicked), p); | |
247 gtk_object_set_user_data(GTK_OBJECT(list_item), p); | |
248 | |
249 gtk_widget_show(label); | |
250 gtk_container_add(GTK_CONTAINER(pluglist), list_item); | |
251 gtk_widget_show(list_item); | |
252 | |
253 plugs = plugs->next; | |
254 } | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
255 if (plugins != NULL) |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
256 gtk_list_select_item(GTK_LIST(pluglist), 0); |
90 | 257 |
258 gtk_widget_show(page); | |
259 gtk_widget_show(topbox); | |
260 gtk_widget_show(botbox); | |
261 gtk_widget_show(sw); | |
262 gtk_widget_show(sw2); | |
263 gtk_widget_show(pluglist); | |
264 gtk_widget_show(plugtext); | |
265 gtk_widget_show(add); | |
266 gtk_widget_show(remove); | |
267 | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
268 gtk_container_add(GTK_CONTAINER(plugwindow), page); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
269 gtk_widget_show(plugwindow); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
270 } |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
271 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
272 void update_show_plugins() { |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
273 GList *plugs = plugins; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
274 struct gaim_plugin *p; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
275 GtkWidget *label; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
276 GtkWidget *list_item; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
277 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
278 if (pluglist == NULL) return; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
279 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
280 gtk_list_clear_items(GTK_LIST(pluglist), 0, -1); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
281 while (plugs) { |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
282 p = (struct gaim_plugin *)plugs->data; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
283 label = gtk_label_new(p->filename); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
284 list_item = gtk_list_item_new(); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
285 gtk_container_add(GTK_CONTAINER(list_item), label); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
286 gtk_signal_connect(GTK_OBJECT(list_item), "select", |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
287 GTK_SIGNAL_FUNC(list_clicked), p); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
288 gtk_object_set_user_data(GTK_OBJECT(list_item), p); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
289 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
290 gtk_widget_show(label); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
291 gtk_container_add(GTK_CONTAINER(pluglist), list_item); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
292 gtk_widget_show(list_item); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
293 plugs = plugs->next; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
294 } |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
295 if (plugins != NULL) |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
296 gtk_list_select_item(GTK_LIST(pluglist), 0); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
297 else { |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
298 gtk_text_set_point(GTK_TEXT(plugtext), 0); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
299 gtk_text_forward_delete(GTK_TEXT(plugtext), |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
300 gtk_text_get_length(GTK_TEXT(plugtext))); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
301 } |
1 | 302 } |
303 | |
90 | 304 void unload(GtkWidget *w, gpointer data) { |
305 GList *i; | |
306 struct gaim_plugin *p; | |
307 void (*gaim_plugin_remove)(); | |
308 char *error; | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
309 GList *c = callbacks; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
310 struct gaim_callback *g; |
90 | 311 |
312 i = GTK_LIST(pluglist)->selection; | |
313 | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
314 if (i == NULL) return; |
90 | 315 |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
316 p = gtk_object_get_user_data(GTK_OBJECT(i->data)); |
1 | 317 |
90 | 318 gaim_plugin_remove = dlsym(p->handle, "gaim_plugin_remove"); |
319 if ((error = dlerror()) == NULL) | |
320 (*gaim_plugin_remove)(); | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
321 while (c) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
322 g = (struct gaim_callback *)c->data; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
323 if (g->handle == p->handle) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
324 callbacks = g_list_remove(callbacks, c); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
325 g_free(g); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
326 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
327 c = c->next; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
328 } |
90 | 329 dlclose(p->handle); |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
330 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
331 plugins = g_list_remove(plugins, p); |
90 | 332 g_free(p); |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
333 update_show_plugins(); |
90 | 334 } |
335 | |
336 void list_clicked(GtkWidget *w, struct gaim_plugin *p) { | |
337 gchar buffer[2048]; | |
338 guint text_len; | |
339 | |
340 text_len = gtk_text_get_length(GTK_TEXT(plugtext)); | |
341 gtk_text_set_point(GTK_TEXT(plugtext), 0); | |
342 gtk_text_forward_delete(GTK_TEXT(plugtext), text_len); | |
343 | |
344 g_snprintf(buffer, sizeof buffer, "%s\n%s", p->name, p->description); | |
345 gtk_text_insert(GTK_TEXT(plugtext), NULL, NULL, NULL, buffer, -1); | |
346 } | |
347 | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
348 void hide_plugins(GtkWidget *w, gpointer data) { |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
349 if (plugwindow) |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
350 gtk_widget_destroy(plugwindow); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
351 plugwindow = NULL; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
352 } |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
353 |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
354 void gaim_signal_connect(void *handle, enum gaim_event which, |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
355 void *func, void *data) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
356 struct gaim_callback *call = g_malloc(sizeof *call); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
357 call->handle = handle; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
358 call->event = which; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
359 call->function = func; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
360 call->data = data; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
361 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
362 callbacks = g_list_append(callbacks, call); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
363 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
364 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
365 void gaim_signal_disconnect(void *handle, enum gaim_event which, void *func) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
366 GList *c = callbacks; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
367 struct gaim_callback *g = NULL; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
368 while (c) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
369 g = (struct gaim_callback *)c->data; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
370 if (handle == g->handle && func == g->function) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
371 callbacks = g_list_remove(callbacks, g); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
372 g_free(g); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
373 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
374 c = c->next; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
375 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
376 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
377 |
90 | 378 #endif /* GAIM_PLUGINS */ |