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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * gaim
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * (at your option) any later version.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * GNU General Public License for more details.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 * ----------------
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21 * The Plug-in plug
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
23 * Plugin support is currently being maintained by Mike Saraf
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
24 * msaraf@dwc.edu
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
25 *
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
26 * Well, I didn't see any work done on it for a while, so I'm going to try
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
27 * my hand at it. - Eric warmenhoven@yahoo.com
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
28 *
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
31 #ifdef GAIM_PLUGINS
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
32
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
33 #include <string.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
34 #include <sys/time.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
36 #include <sys/types.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
37 #include <sys/stat.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
38
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
39 #include <unistd.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40 #include <stdio.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41 #include <stdlib.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42 #include <gtk/gtk.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
43 #include "gaim.h"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
44
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
45 #include <dlfcn.h>
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
52
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
53 static GtkWidget *plugin_dialog = NULL;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
54 static GList *plugins = NULL;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
55
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
56 static GtkWidget *pluglist;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
57 static GtkWidget *plugtext;
92
f3c6cf79f651 [gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 90
diff changeset
58 static GtkWidget *plugwindow;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
59
94
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
60 /* --------------- Function Declarations --------------------- */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
61
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
62 void load_plugin (GtkWidget *, gpointer);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
63 void unload_plugin(GtkWidget *, gpointer);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
64 void show_plugins (GtkWidget *, gpointer);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
69 static void destroy_plugins (GtkWidget *, gpointer);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
70 static void load_which_plugin(GtkWidget *, gpointer);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
71 static void unload (GtkWidget *, gpointer);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
75
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
76 /* ------------------ Code Below ---------------------------- */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
77
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
78 static void destroy_plugins(GtkWidget *w, gpointer data) {
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
79 if (plugin_dialog)
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
80 gtk_widget_destroy(plugin_dialog);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
81 plugin_dialog = NULL;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
82 }
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
83
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
84 void load_plugin(GtkWidget *w, gpointer data)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
85 {
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
86 char *buf = g_malloc(BUF_LEN);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
87
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
88 if (!plugin_dialog) {
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
89 plugin_dialog = gtk_file_selection_new("Gaim - Plugin List");
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
91 gtk_file_selection_hide_fileop_buttons(
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
92 GTK_FILE_SELECTION(plugin_dialog));
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
93
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
94 if(getenv("PLUGIN_DIR") == NULL) {
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
95 g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), PLUGIN_DIR);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
96 } else {
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
97 g_snprintf(buf, BUF_LEN - 1, "%s/", getenv("PLUGIN_DIR"));
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
98 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
99
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
100 gtk_file_selection_set_filename(GTK_FILE_SELECTION(plugin_dialog), buf);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
101 gtk_signal_connect(GTK_OBJECT(plugin_dialog), "destroy",
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
102 GTK_SIGNAL_FUNC(destroy_plugins), plugin_dialog);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
103
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
104 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->ok_button),
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
105 "clicked", GTK_SIGNAL_FUNC(load_which_plugin), NULL);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
106
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
107 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->cancel_button),
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
108 "clicked", GTK_SIGNAL_FUNC(destroy_plugins), NULL);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
109
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
110 }
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
111
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
112 g_free(buf);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
113 gtk_widget_show(plugin_dialog);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
114 gdk_window_raise(plugin_dialog->window);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
115 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
116
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
117 void load_which_plugin(GtkWidget *w, gpointer data) {
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
118 struct gaim_plugin *plug;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
119 void (*gaim_plugin_init)();
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
120 char *(*cfunc)();
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
121 char *error;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
122
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
126 /* do NOT OR with RTLD_GLOBAL, otherwise plugins may conflict
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
127 * (it's really just a way to work around other people's bad
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
128 * programming, by not using RTLD_GLOBAL :P ) */
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
129 plug->handle = dlopen(plug->filename, RTLD_LAZY);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
130 if (!plug->handle) {
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
131 error = dlerror();
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
132 do_error_dialog(error, "Plugin Error");
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
133 g_free(plug);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
134 return;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
135 }
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
136
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
137 if (plugin_dialog)
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
138 gtk_widget_destroy(plugin_dialog);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
139 plugin_dialog = NULL;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
140
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
141 gaim_plugin_init = dlsym(plug->handle, "gaim_plugin_init");
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
142 if ((error = dlerror()) != NULL) {
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
143 do_error_dialog(error, "Plugin Error");
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
144 dlclose(plug->handle);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
145 g_free(plug);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
146 return;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
147 }
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
148
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
151
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
152 cfunc = dlsym(plug->handle, "name");
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
153 if ((error = dlerror()) == NULL)
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
154 plug->name = (*cfunc)();
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
155 else
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
156 plug->name = NULL;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
157
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
158 cfunc = dlsym(plug->handle, "description");
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
159 if ((error = dlerror()) == NULL)
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
160 plug->description = (*cfunc)();
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
161 else
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
165 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
166
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
167 void unload_plugin(GtkWidget *w, gpointer data) {
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
168 /* FIXME */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
169 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
170
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
171 void show_plugins(GtkWidget *w, gpointer data) {
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
172 /* most of this code was shamelessly stolen from prefs.c */
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
173 GtkWidget *page;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
174 GtkWidget *topbox;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
175 GtkWidget *botbox;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
176 GtkWidget *sw;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
177 GtkWidget *label;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
178 GtkWidget *list_item;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
179 GtkWidget *sw2;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
180 GtkWidget *add;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
181 GtkWidget *remove;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
182 GList *plugs = plugins;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
183 struct gaim_plugin *p;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
184 gchar buffer[1024];
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
196
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
197 page = gtk_vbox_new(FALSE, 0);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
198 topbox = gtk_hbox_new(FALSE, 0);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
199 botbox = gtk_hbox_new(FALSE, 0);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
200
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
201 sw2 = gtk_scrolled_window_new(NULL, NULL);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
202 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2),
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
203 GTK_POLICY_AUTOMATIC,
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
204 GTK_POLICY_AUTOMATIC);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
205
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
206 pluglist = gtk_list_new();
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
207 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), pluglist);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
208 gtk_box_pack_start(GTK_BOX(topbox), sw2, TRUE, TRUE, 0);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
209
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
210 sw = gtk_scrolled_window_new(NULL, NULL);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
211 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
212 GTK_POLICY_AUTOMATIC,
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
213 GTK_POLICY_AUTOMATIC);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
214
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
215 plugtext = gtk_text_new(NULL, NULL);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
216 gtk_container_add(GTK_CONTAINER(sw), plugtext);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
217 gtk_box_pack_start(GTK_BOX(topbox), sw, TRUE, TRUE, 0);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
218 gtk_text_set_word_wrap(GTK_TEXT(plugtext), TRUE);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
219 gtk_text_set_editable(GTK_TEXT(plugtext), FALSE);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
220
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
221 add = gtk_button_new_with_label("Load Plugin");
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
222 gtk_signal_connect(GTK_OBJECT(add), "clicked",
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
223 GTK_SIGNAL_FUNC(load_plugin), NULL);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
224 gtk_box_pack_start(GTK_BOX(botbox), add, TRUE, FALSE, 5);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
225
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
226 remove = gtk_button_new_with_label("Unload Plugin");
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
227 gtk_signal_connect(GTK_OBJECT(remove), "clicked",
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
228 GTK_SIGNAL_FUNC(unload), pluglist);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
229 gtk_box_pack_start(GTK_BOX(botbox), remove, TRUE, FALSE, 5);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
230
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
231 gtk_box_pack_start(GTK_BOX(page), topbox, TRUE, TRUE, 0);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
232 gtk_box_pack_start(GTK_BOX(page), botbox, FALSE, FALSE, 0);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
233
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
234 if (plugs != NULL) {
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
235 p = (struct gaim_plugin *)plugs->data;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
236 g_snprintf(buffer, sizeof(buffer), "%s", p->filename);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
237 gtk_text_insert(GTK_TEXT(plugtext), NULL, NULL, NULL, buffer, -1);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
238 }
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
239
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
240 while (plugs) {
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
241 p = (struct gaim_plugin *)plugs->data;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
242 label = gtk_label_new(p->filename);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
243 list_item = gtk_list_item_new();
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
244 gtk_container_add(GTK_CONTAINER(list_item), label);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
245 gtk_signal_connect(GTK_OBJECT(list_item), "select",
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
246 GTK_SIGNAL_FUNC(list_clicked), p);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
247 gtk_object_set_user_data(GTK_OBJECT(list_item), p);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
248
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
249 gtk_widget_show(label);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
250 gtk_container_add(GTK_CONTAINER(pluglist), list_item);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
251 gtk_widget_show(list_item);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
252
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
253 plugs = plugs->next;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
257
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
258 gtk_widget_show(page);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
259 gtk_widget_show(topbox);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
260 gtk_widget_show(botbox);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
261 gtk_widget_show(sw);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
262 gtk_widget_show(sw2);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
263 gtk_widget_show(pluglist);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
264 gtk_widget_show(plugtext);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
265 gtk_widget_show(add);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
266 gtk_widget_show(remove);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
302 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
303
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
304 void unload(GtkWidget *w, gpointer data) {
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
305 GList *i;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
306 struct gaim_plugin *p;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
307 void (*gaim_plugin_remove)();
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
311
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
312 i = GTK_LIST(pluglist)->selection;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
313
92
f3c6cf79f651 [gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 90
diff changeset
314 if (i == NULL) return;
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
317
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
318 gaim_plugin_remove = dlsym(p->handle, "gaim_plugin_remove");
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
319 if ((error = dlerror()) == NULL)
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
332 g_free(p);
92
f3c6cf79f651 [gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 90
diff changeset
333 update_show_plugins();
90
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
334 }
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
335
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
336 void list_clicked(GtkWidget *w, struct gaim_plugin *p) {
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
337 gchar buffer[2048];
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
338 guint text_len;
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
339
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
340 text_len = gtk_text_get_length(GTK_TEXT(plugtext));
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
341 gtk_text_set_point(GTK_TEXT(plugtext), 0);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
342 gtk_text_forward_delete(GTK_TEXT(plugtext), text_len);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
343
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
344 g_snprintf(buffer, sizeof buffer, "%s\n%s", p->name, p->description);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
345 gtk_text_insert(GTK_TEXT(plugtext), NULL, NULL, NULL, buffer, -1);
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
346 }
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
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
f5b305c0d974 [gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
378 #endif /* GAIM_PLUGINS */