Mercurial > pidgin
annotate src/plugins.c @ 3500:b79894c97bed
[gaim-migrate @ 3563]
a couple prefs fixes. prefs should now save things when you change them (thanks faceprint)
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 14 Sep 2002 03:08:39 +0000 |
parents | cfbdfe334975 |
children | cd938f18f3f8 |
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 * | |
1745 | 29 * Mike is my roomate. I can assure you that he's lazy :-P -- Rob rob@marko.net |
30 * | |
1 | 31 */ |
32 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
176
diff
changeset
|
33 #ifdef HAVE_CONFIG_H |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
34 #include <config.h> |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
176
diff
changeset
|
35 #endif |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
176
diff
changeset
|
36 |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
37 #ifdef GAIM_PLUGINS |
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
38 |
1 | 39 #include <string.h> |
40 #include <sys/time.h> | |
41 | |
42 #include <sys/types.h> | |
43 #include <sys/stat.h> | |
44 | |
45 #include <unistd.h> | |
46 #include <stdio.h> | |
47 #include <stdlib.h> | |
48 #include <gtk/gtk.h> | |
49 #include "gaim.h" | |
50 | |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
51 #include "pixmaps/gnome_add.xpm" |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
52 #include "pixmaps/gnome_remove.xpm" |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
53 #include "pixmaps/gnome_preferences.xpm" |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
54 #include "pixmaps/refresh.xpm" |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
55 #include "pixmaps/cancel.xpm" |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
56 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
57 #define PATHSIZE 1024 /* XXX: stolen from dialogs.c */ |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
58 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
59 |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
60 /* ------------------ Local Variables ------------------------ */ |
1 | 61 |
90 | 62 static GtkWidget *plugin_dialog = NULL; |
63 | |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
64 static GtkWidget *pluglist = NULL; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
65 static GtkWidget *plugtext = NULL; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
66 static GtkWidget *plugwindow = NULL; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
67 static GtkWidget *plugentry = NULL; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
68 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
69 static GtkTooltips *tooltips = NULL; |
1 | 70 |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
71 static GtkWidget *config = NULL; |
403
d6f02d7f78d8
[gaim-migrate @ 413]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
397
diff
changeset
|
72 static guint confighandle = 0; |
2056
5028a07250c7
[gaim-migrate @ 2066]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1911
diff
changeset
|
73 static GtkWidget *reload = NULL; |
5028a07250c7
[gaim-migrate @ 2066]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1911
diff
changeset
|
74 static GtkWidget *unload = NULL; |
2405
6e637ad18494
[gaim-migrate @ 2418]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2393
diff
changeset
|
75 extern char *last_dir; |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
76 |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
77 /* --------------- Function Declarations --------------------- */ |
1 | 78 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
79 void show_plugins(GtkWidget *, gpointer); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
80 |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
81 /* UI button callbacks */ |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
82 static void unload_plugin_cb(GtkWidget *, gpointer); |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
83 static void plugin_reload_cb(GtkWidget *, gpointer); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
84 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
85 static const gchar *plugin_makelistname(GModule *); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
86 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
87 static void destroy_plugins(GtkWidget *, gpointer); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
88 static void load_file(GtkWidget *, gpointer); |
90 | 89 static void load_which_plugin(GtkWidget *, gpointer); |
2494
2c1950c5544a
[gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2405
diff
changeset
|
90 void update_show_plugins(); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
91 static void hide_plugins(GtkWidget *, gpointer); |
3374 | 92 static void clear_plugin_display(); |
93 static struct gaim_plugin *get_selected_plugin(GtkWidget *); | |
94 static void select_plugin(GtkWidget *w, struct gaim_plugin *p); | |
95 static void list_clicked(GtkWidget *, gpointer); | |
90 | 96 |
1 | 97 /* ------------------ Code Below ---------------------------- */ |
98 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
99 static void destroy_plugins(GtkWidget *w, gpointer data) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
100 { |
90 | 101 if (plugin_dialog) |
102 gtk_widget_destroy(plugin_dialog); | |
103 plugin_dialog = NULL; | |
104 } | |
105 | |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
106 static void load_file(GtkWidget *w, gpointer data) |
1 | 107 { |
943
446d7d2cc909
[gaim-migrate @ 953]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
905
diff
changeset
|
108 gchar *buf; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
109 |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
110 if (plugin_dialog) { |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
111 gtk_widget_show(plugin_dialog); |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
112 gdk_window_raise(plugin_dialog->window); |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
113 return; |
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
114 } |
90 | 115 |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
116 plugin_dialog = gtk_file_selection_new(_("Gaim - Plugin List")); |
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
134
diff
changeset
|
117 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
118 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(plugin_dialog)); |
90 | 119 |
1025
84a5d80e52f1
[gaim-migrate @ 1035]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
120 if (!last_dir) |
1163
8f70ecf3e884
[gaim-migrate @ 1173]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1145
diff
changeset
|
121 buf = g_strdup(LIBDIR); |
153
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
122 else |
1025
84a5d80e52f1
[gaim-migrate @ 1035]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
123 buf = g_strconcat(last_dir, G_DIR_SEPARATOR_S, NULL); |
1 | 124 |
90 | 125 gtk_file_selection_set_filename(GTK_FILE_SELECTION(plugin_dialog), buf); |
153
8ed64c704fb0
[gaim-migrate @ 163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
142
diff
changeset
|
126 gtk_file_selection_complete(GTK_FILE_SELECTION(plugin_dialog), "*.so"); |
90 | 127 gtk_signal_connect(GTK_OBJECT(plugin_dialog), "destroy", |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
128 GTK_SIGNAL_FUNC(destroy_plugins), plugin_dialog); |
90 | 129 |
130 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->ok_button), | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
131 "clicked", GTK_SIGNAL_FUNC(load_which_plugin), NULL); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
132 |
90 | 133 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->cancel_button), |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
134 "clicked", GTK_SIGNAL_FUNC(destroy_plugins), NULL); |
90 | 135 |
136 g_free(buf); | |
626
d86cc11faab8
[gaim-migrate @ 636]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
619
diff
changeset
|
137 gtk_widget_show(plugin_dialog); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
138 gdk_window_raise(plugin_dialog->window); |
90 | 139 } |
1 | 140 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
141 static void load_which_plugin(GtkWidget *w, gpointer data) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
142 { |
3466 | 143 const char *file; |
3374 | 144 struct gaim_plugin *p; |
145 | |
146 file = (char *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(plugin_dialog)); | |
1035
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1025
diff
changeset
|
147 if (file_is_dir(file, plugin_dialog)) { |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1025
diff
changeset
|
148 return; |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1025
diff
changeset
|
149 } |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1025
diff
changeset
|
150 |
1710
f42ce672c560
[gaim-migrate @ 1720]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1429
diff
changeset
|
151 if (file) |
3374 | 152 p = load_plugin(file); |
153 else | |
154 p = NULL; | |
142
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
155 |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
156 if (plugin_dialog) |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
157 gtk_widget_destroy(plugin_dialog); |
fbabd28795d2
[gaim-migrate @ 152]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
139
diff
changeset
|
158 plugin_dialog = NULL; |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
159 |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
160 update_show_plugins(); |
3374 | 161 /* Select newly loaded plugin */ |
162 if(p == NULL) | |
163 return; | |
164 select_plugin(pluglist, p); | |
90 | 165 } |
1 | 166 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
167 void show_plugins(GtkWidget *w, gpointer data) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
168 { |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
169 /* most of this code was shamelessly stolen from Glade */ |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
170 GtkWidget *mainvbox; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
171 GtkWidget *tophbox; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
172 GtkWidget *bothbox; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
173 GtkWidget *hbox; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
174 GtkWidget *vbox; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
175 GtkWidget *frame; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
176 GtkWidget *scrolledwindow; |
90 | 177 GtkWidget *label; |
178 GtkWidget *add; | |
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
179 GtkWidget *close; |
3374 | 180 /* stuff needed for GtkTreeView *pluglist */ |
181 GtkListStore *store; | |
182 GtkCellRenderer *renderer; | |
183 GtkTreeViewColumn *column; | |
184 GtkTreeSelection *selection; | |
185 /* needed for GtkTextView *plugtext */ | |
186 GtkTextBuffer *buffer; | |
187 | |
3472 | 188 if (plugwindow) { |
189 gtk_window_present(GTK_WINDOW(plugwindow)); | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
190 return; |
3472 | 191 } |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
192 |
2725
f3c094e78609
[gaim-migrate @ 2738]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
193 GAIM_DIALOG(plugwindow); |
905 | 194 gtk_window_set_wmclass(GTK_WINDOW(plugwindow), "plugins", "Gaim"); |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
195 gtk_widget_realize(plugwindow); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
196 gtk_window_set_title(GTK_WINDOW(plugwindow), _("Gaim - Plugins")); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
197 gtk_signal_connect(GTK_OBJECT(plugwindow), "destroy", GTK_SIGNAL_FUNC(hide_plugins), NULL); |
90 | 198 |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
199 mainvbox = gtk_vbox_new(FALSE, 0); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
200 gtk_container_add(GTK_CONTAINER(plugwindow), mainvbox); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
201 gtk_widget_show(mainvbox); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
202 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
203 /* Build the top */ |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
204 tophbox = gtk_hbox_new(FALSE, 0); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
205 gtk_box_pack_start(GTK_BOX(mainvbox), tophbox, TRUE, TRUE, 0); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
206 gtk_widget_show(tophbox); |
90 | 207 |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
208 /* Left side: frame with list of plugin file names */ |
3025 | 209 frame = gtk_frame_new(_("Loaded Plugins")); |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
210 gtk_box_pack_start(GTK_BOX(tophbox), frame, FALSE, FALSE, 0); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
211 gtk_container_set_border_width(GTK_CONTAINER(frame), 6); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
212 gtk_frame_set_label_align(GTK_FRAME(frame), 0.05, 0.5); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
213 gtk_widget_show(frame); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
214 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
215 scrolledwindow = gtk_scrolled_window_new(NULL, NULL); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
216 gtk_container_add(GTK_CONTAINER(frame), scrolledwindow); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
217 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
218 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
219 gtk_widget_show(scrolledwindow); |
3374 | 220 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow), |
221 GTK_SHADOW_IN); | |
90 | 222 |
3374 | 223 /* Create & show plugin list */ |
224 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); | |
225 pluglist = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | |
226 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(pluglist), FALSE); | |
227 renderer = gtk_cell_renderer_text_new(); | |
228 column = gtk_tree_view_column_new_with_attributes("text", | |
229 renderer, "text", 0, NULL); | |
230 gtk_tree_view_append_column(GTK_TREE_VIEW(pluglist), column); | |
231 gtk_container_add(GTK_CONTAINER(scrolledwindow), pluglist); | |
232 | |
233 g_object_unref(G_OBJECT(store)); | |
234 | |
235 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pluglist)); | |
236 g_signal_connect(G_OBJECT(selection), "changed", | |
237 G_CALLBACK(list_clicked), | |
238 NULL); | |
239 | |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
240 gtk_widget_show(pluglist); |
90 | 241 |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
242 /* Right side: frame with description and the filepath of plugin */ |
3374 | 243 frame = gtk_frame_new(_("Selected Plugin")); |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
244 gtk_box_pack_start(GTK_BOX(tophbox), frame, TRUE, TRUE, 0); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
245 gtk_container_set_border_width(GTK_CONTAINER(frame), 6); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
246 gtk_frame_set_label_align(GTK_FRAME(frame), 0.05, 0.5); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
247 gtk_widget_show(frame); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
248 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
249 vbox = gtk_vbox_new(FALSE, 0); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
250 gtk_container_add(GTK_CONTAINER(frame), vbox); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
251 gtk_widget_show(vbox); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
252 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
253 scrolledwindow = gtk_scrolled_window_new(NULL, NULL); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
254 gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 0); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
255 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
256 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
257 gtk_widget_show(scrolledwindow); |
3374 | 258 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow), |
259 GTK_SHADOW_IN); | |
260 | |
261 /* Create & show the plugin description widget */ | |
262 plugtext = gtk_text_view_new(); | |
263 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(plugtext), GTK_WRAP_WORD); | |
264 gtk_text_view_set_editable(GTK_TEXT_VIEW(plugtext), FALSE); | |
265 gtk_container_add(GTK_CONTAINER(scrolledwindow), plugtext); | |
266 gtk_widget_set_size_request(GTK_WIDGET(plugtext), -1, 200); | |
267 | |
268 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(plugtext)); | |
269 gtk_text_buffer_create_tag(buffer, "bold", "weight", | |
270 PANGO_WEIGHT_BOLD, NULL); | |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
271 gtk_widget_show(plugtext); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
272 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
273 hbox = gtk_hbox_new(FALSE, 5); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
274 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
275 gtk_container_set_border_width(GTK_CONTAINER(hbox), 6); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
276 gtk_widget_show(hbox); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
277 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
278 label = gtk_label_new(_("Filepath:")); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
279 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
280 gtk_widget_show(label); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
281 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
282 plugentry = gtk_entry_new(); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
283 gtk_box_pack_start(GTK_BOX(hbox), plugentry, TRUE, TRUE, 0); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
284 gtk_entry_set_editable(GTK_ENTRY(plugentry), FALSE); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
285 gtk_widget_show(plugentry); |
90 | 286 |
943
446d7d2cc909
[gaim-migrate @ 953]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
905
diff
changeset
|
287 /* Build the bottom button bar */ |
3374 | 288 bothbox = gtk_hbox_new(TRUE, 3); |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
289 gtk_box_pack_start(GTK_BOX(mainvbox), bothbox, FALSE, FALSE, 0); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
290 gtk_container_set_border_width(GTK_CONTAINER(hbox), 5); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
291 gtk_widget_show(bothbox); |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
292 |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
293 if (!tooltips) |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
294 tooltips = gtk_tooltips_new(); |
90 | 295 |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
296 add = picture_button(plugwindow, _("Load"), gnome_add_xpm); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
297 gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(load_file), NULL); |
3374 | 298 gtk_box_pack_start_defaults(GTK_BOX(bothbox), add); |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
299 gtk_tooltips_set_tip(tooltips, add, _("Load a plugin from a file"), ""); |
90 | 300 |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
301 config = picture_button(plugwindow, _("Configure"), gnome_preferences_xpm); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
302 gtk_widget_set_sensitive(config, FALSE); |
3374 | 303 gtk_box_pack_start_defaults(GTK_BOX(bothbox), config); |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
304 gtk_tooltips_set_tip(tooltips, config, _("Configure settings of the selected plugin"), ""); |
90 | 305 |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
306 reload = picture_button(plugwindow, _("Reload"), refresh_xpm); |
2056
5028a07250c7
[gaim-migrate @ 2066]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1911
diff
changeset
|
307 gtk_widget_set_sensitive(reload, FALSE); |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
308 gtk_signal_connect(GTK_OBJECT(reload), "clicked", GTK_SIGNAL_FUNC(plugin_reload_cb), NULL); |
3374 | 309 gtk_box_pack_start_defaults(GTK_BOX(bothbox), reload); |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
310 gtk_tooltips_set_tip(tooltips, reload, _("Reload the selected plugin"), ""); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
311 |
2056
5028a07250c7
[gaim-migrate @ 2066]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1911
diff
changeset
|
312 unload = picture_button(plugwindow, _("Unload"), gnome_remove_xpm); |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
313 gtk_signal_connect(GTK_OBJECT(unload), "clicked", GTK_SIGNAL_FUNC(unload_plugin_cb), pluglist); |
3374 | 314 gtk_box_pack_start_defaults(GTK_BOX(bothbox), unload); |
2056
5028a07250c7
[gaim-migrate @ 2066]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1911
diff
changeset
|
315 gtk_tooltips_set_tip(tooltips, unload, _("Unload the selected plugin"), ""); |
90 | 316 |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
317 close = picture_button(plugwindow, _("Close"), cancel_xpm); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
318 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(hide_plugins), NULL); |
3374 | 319 gtk_box_pack_start_defaults(GTK_BOX(bothbox), close); |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
320 gtk_tooltips_set_tip(tooltips, close, _("Close this window"), ""); |
90 | 321 |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
322 update_show_plugins(); |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
323 gtk_widget_show(plugwindow); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
324 } |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
325 |
2494
2c1950c5544a
[gaim-migrate @ 2507]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2405
diff
changeset
|
326 void update_show_plugins() |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
327 { |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
328 GList *plugs = plugins; |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
329 struct gaim_plugin *p; |
3374 | 330 int pnum = 0; |
331 GtkListStore *store; | |
332 GtkTreeIter iter; | |
333 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
334 if (plugwindow == NULL) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
335 return; |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
336 |
3374 | 337 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(pluglist))); |
338 gtk_list_store_clear(store); | |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
339 while (plugs) { |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
340 p = (struct gaim_plugin *)plugs->data; |
3374 | 341 gtk_list_store_append(store, &iter); |
342 gtk_list_store_set(store, &iter, 0, plugin_makelistname(p->handle), -1); | |
343 gtk_list_store_set(store, &iter, 1, pnum++, -1); | |
943
446d7d2cc909
[gaim-migrate @ 953]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
905
diff
changeset
|
344 plugs = g_list_next(plugs); |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
345 } |
2056
5028a07250c7
[gaim-migrate @ 2066]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1911
diff
changeset
|
346 |
3374 | 347 clear_plugin_display(); |
1 | 348 } |
349 | |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
350 static void unload_plugin_cb(GtkWidget *w, gpointer data) |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
351 { |
3374 | 352 struct gaim_plugin *p; |
353 p = get_selected_plugin(pluglist); | |
354 if(p == NULL) | |
355 return; | |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
356 unload_plugin(p); |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
357 update_show_plugins(); |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
358 } |
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
359 |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
360 static void plugin_reload_cb(GtkWidget *w, gpointer data) |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
361 { |
3374 | 362 struct gaim_plugin *p; |
363 p = get_selected_plugin(pluglist); | |
364 if(p == NULL) | |
365 return; | |
366 p = reload_plugin(p); | |
2393
a7ecfd3f7714
[gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
367 update_show_plugins(); |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
368 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
369 /* Try and reselect the plugin in list */ |
2280
13d5d7e829c9
[gaim-migrate @ 2290]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2274
diff
changeset
|
370 if (!pluglist) |
13d5d7e829c9
[gaim-migrate @ 2290]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2274
diff
changeset
|
371 return; |
3374 | 372 select_plugin(pluglist, p); |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
373 } |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
374 |
3374 | 375 |
376 static void list_clicked(GtkWidget *w, gpointer data) | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
377 { |
3374 | 378 void (*gaim_plugin_config)(); |
379 struct gaim_plugin *p; | |
380 GtkTextBuffer *buffer; | |
381 GtkTextIter iter; | |
382 | |
383 if (confighandle != 0) { | |
384 gtk_signal_disconnect(GTK_OBJECT(config), confighandle); | |
385 confighandle = 0; | |
386 } | |
387 | |
388 p = get_selected_plugin(pluglist); | |
389 if(p == NULL) { /* No selected plugin */ | |
390 clear_plugin_display(); | |
391 return; | |
392 } | |
90 | 393 |
3374 | 394 /* Set text and filepath widgets */ |
395 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(plugtext)); | |
396 gtk_text_buffer_set_text(buffer, "", -1); | |
397 gtk_text_buffer_get_start_iter(buffer, &iter); | |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
398 |
3374 | 399 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "Name:", -1, |
400 "bold", NULL); | |
401 gtk_text_buffer_insert(buffer, &iter, " ", -1); | |
402 gtk_text_buffer_insert(buffer, &iter, (p->name != NULL) ? p->name : "", -1); | |
403 gtk_text_buffer_insert(buffer, &iter, "\n\n", -1); | |
404 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "Description:", -1, | |
405 "bold", NULL); | |
406 gtk_text_buffer_insert(buffer, &iter, "\n", -1); | |
407 gtk_text_buffer_insert(buffer, &iter, | |
408 (p->description != NULL) ? p->description : "", -1); | |
409 | |
410 gtk_entry_set_text(GTK_ENTRY(plugentry), g_module_name(p->handle)); | |
943
446d7d2cc909
[gaim-migrate @ 953]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
905
diff
changeset
|
411 /* Find out if this plug-in has a configuration function */ |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1039
diff
changeset
|
412 if (g_module_symbol(p->handle, "gaim_plugin_config", (gpointer *)&gaim_plugin_config)) { |
403
d6f02d7f78d8
[gaim-migrate @ 413]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
397
diff
changeset
|
413 confighandle = gtk_signal_connect(GTK_OBJECT(config), "clicked", |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
414 GTK_SIGNAL_FUNC(gaim_plugin_config), NULL); |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
415 gtk_widget_set_sensitive(config, TRUE); |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
416 } else { |
403
d6f02d7f78d8
[gaim-migrate @ 413]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
397
diff
changeset
|
417 confighandle = 0; |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
418 gtk_widget_set_sensitive(config, FALSE); |
110
f7c6366ca703
[gaim-migrate @ 120]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
419 } |
2056
5028a07250c7
[gaim-migrate @ 2066]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1911
diff
changeset
|
420 |
5028a07250c7
[gaim-migrate @ 2066]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1911
diff
changeset
|
421 gtk_widget_set_sensitive(reload, TRUE); |
5028a07250c7
[gaim-migrate @ 2066]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1911
diff
changeset
|
422 gtk_widget_set_sensitive(unload, TRUE); |
90 | 423 } |
424 | |
2056
5028a07250c7
[gaim-migrate @ 2066]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1911
diff
changeset
|
425 static void hide_plugins(GtkWidget *w, gpointer data) |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
426 { |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
427 if (plugwindow) |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
428 gtk_widget_destroy(plugwindow); |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
429 plugwindow = NULL; |
425
ae7c762775cd
[gaim-migrate @ 435]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
403
diff
changeset
|
430 config = NULL; |
522
11cbf8b403b6
[gaim-migrate @ 532]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
425
diff
changeset
|
431 confighandle = 0; |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
432 } |
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
433 |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
434 static const gchar *plugin_makelistname(GModule *module) |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
435 { |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
436 static gchar filename[PATHSIZE]; |
3466 | 437 const gchar *filepath = (char *)g_module_name(module); |
438 const char *cp; | |
1911
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
439 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
440 if (filepath == NULL || strlen(filepath) == 0) |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
441 return NULL; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
442 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
443 if ((cp = strrchr(filepath, '/')) == NULL || *++cp == '\0') |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
444 cp = filepath; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
445 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
446 strncpy(filename, cp, sizeof(filename)); |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
447 filename[sizeof(filename) - 1] = '\0'; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
448 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
449 /* Try to pretty name by removing any trailing ".so" */ |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
450 if (strlen(filename) > 3 && |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
451 strncmp(filename + strlen(filename) - 3, ".so", 3) == 0) |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
452 filename[strlen(filename) - 3] = '\0'; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
453 |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
454 return filename; |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
455 } |
db3104dda736
[gaim-migrate @ 1921]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1874
diff
changeset
|
456 |
3374 | 457 static struct gaim_plugin *get_selected_plugin(GtkWidget *w) { |
458 /* Given the pluglist widget, this will return a pointer to the plugin | |
459 * currently selected in the list, and NULL if none is selected. */ | |
460 gint index; | |
461 GList *plugs = plugins; | |
462 GtkTreeSelection *sel; | |
463 GtkTreeIter iter; | |
464 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(w)); | |
465 | |
466 /* Get list index of selected plugin */ | |
467 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(w)); | |
468 if(!gtk_tree_selection_get_selected(sel, &model, &iter)) | |
469 return NULL; | |
470 gtk_tree_model_get(model, &iter, 1, &index, -1); | |
471 | |
472 /* Get plugin entry from index */ | |
473 plugs = g_list_nth(plugins, index); | |
474 if(plugs == NULL) | |
475 return NULL; | |
476 else | |
477 return (struct gaim_plugin *)plugs->data; | |
478 } | |
479 | |
480 static void select_plugin(GtkWidget *w, struct gaim_plugin *p) { | |
481 /* Given the pluglist widget and a plugin, this will try to select | |
482 * entry in the list which corresponds with the plugin. */ | |
483 GtkTreeSelection *sel; | |
484 GtkTreeIter iter; | |
485 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(w)); | |
486 gchar temp[10]; | |
487 | |
488 if(g_list_index(plugins, p) == -1) | |
489 return; | |
490 | |
491 snprintf(temp, 10, "%d", g_list_index(plugins, p)); | |
492 gtk_tree_model_get_iter_from_string(model, | |
493 &iter, temp); | |
494 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(w)); | |
495 gtk_tree_selection_select_iter(sel, &iter); | |
496 } | |
497 | |
498 static void clear_plugin_display() { | |
499 GtkTreeSelection *selection; | |
500 GtkTextBuffer *buffer; | |
501 | |
502 /* Clear the plugin display if nothing's selected */ | |
503 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pluglist)); | |
504 if(gtk_tree_selection_get_selected(selection, NULL, NULL) == FALSE) { | |
505 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(plugtext)); | |
506 gtk_text_buffer_set_text(buffer, "", -1); | |
507 gtk_entry_set_text(GTK_ENTRY(plugentry), ""); | |
508 | |
509 gtk_widget_set_sensitive(config, FALSE); | |
510 gtk_widget_set_sensitive(reload, FALSE); | |
511 gtk_widget_set_sensitive(unload, FALSE); | |
512 } | |
513 } | |
514 | |
515 #endif |