Mercurial > pidgin.yaz
comparison gtk/gtkplugin.c @ 20389:e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
to branch 'im.pidgin.rlaager.merging.soc-msnp13-to-svn18164' (head 5b5cde92182d2a922a8e7e6c2308342a5490a8c9)
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 15 Apr 2007 02:10:37 +0000 |
parents | 7d6bd7a4994f |
children |
comparison
equal
deleted
inserted
replaced
19796:21cb7a79ac7f | 20389:e354528c4163 |
---|---|
1 /** | |
2 * @file gtkplugin.c GTK+ Plugins support | |
3 * @ingroup gtkui | |
4 * | |
5 * gaim | |
6 * | |
7 * Gaim is the legal property of its developers, whose names are too numerous | |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 #include "internal.h" | |
26 #include "gtkgaim.h" | |
27 #include "gtkplugin.h" | |
28 #include "gtkpluginpref.h" | |
29 #include "gtkutils.h" | |
30 #include "debug.h" | |
31 #include "prefs.h" | |
32 #include "request.h" | |
33 | |
34 #include <string.h> | |
35 | |
36 #define GAIM_RESPONSE_CONFIGURE 98121 | |
37 | |
38 static void plugin_toggled_stage_two(GaimPlugin *plug, GtkTreeModel *model, | |
39 GtkTreeIter *iter, gboolean unload); | |
40 | |
41 static GtkWidget *expander = NULL; | |
42 static GtkWidget *plugin_dialog = NULL; | |
43 static GtkWidget *plugin_details = NULL; | |
44 static GtkWidget *pref_button = NULL; | |
45 static GHashTable *plugin_pref_dialogs = NULL; | |
46 | |
47 GtkWidget * | |
48 gaim_gtk_plugin_get_config_frame(GaimPlugin *plugin) | |
49 { | |
50 GtkWidget *config = NULL; | |
51 | |
52 g_return_val_if_fail(plugin != NULL, NULL); | |
53 | |
54 if (GAIM_IS_GTK_PLUGIN(plugin) && plugin->info->ui_info | |
55 && GAIM_GTK_PLUGIN_UI_INFO(plugin)->get_config_frame) | |
56 { | |
57 GaimGtkPluginUiInfo *ui_info; | |
58 | |
59 ui_info = GAIM_GTK_PLUGIN_UI_INFO(plugin); | |
60 | |
61 config = ui_info->get_config_frame(plugin); | |
62 | |
63 if (plugin->info->prefs_info | |
64 && plugin->info->prefs_info->get_plugin_pref_frame) | |
65 { | |
66 gaim_debug_warning("gtkplugin", | |
67 "Plugin %s contains both, ui_info and " | |
68 "prefs_info preferences; prefs_info will be " | |
69 "ignored.", plugin->info->name); | |
70 } | |
71 } | |
72 | |
73 if (config == NULL && plugin->info->prefs_info | |
74 && plugin->info->prefs_info->get_plugin_pref_frame) | |
75 { | |
76 GaimPluginPrefFrame *frame; | |
77 | |
78 frame = plugin->info->prefs_info->get_plugin_pref_frame(plugin); | |
79 | |
80 config = gaim_gtk_plugin_pref_create_frame(frame); | |
81 | |
82 /* XXX According to bug #1407047 this broke saving pluging preferences, I'll look at fixing it correctly later. | |
83 gaim_plugin_pref_frame_destroy(frame); | |
84 */ | |
85 } | |
86 | |
87 return config; | |
88 } | |
89 | |
90 void | |
91 gaim_gtk_plugins_save(void) | |
92 { | |
93 gaim_plugins_save_loaded("/gaim/gtk/plugins/loaded"); | |
94 } | |
95 | |
96 static void | |
97 update_plugin_list(void *data) | |
98 { | |
99 GtkListStore *ls = GTK_LIST_STORE(data); | |
100 GtkTreeIter iter; | |
101 GList *probes; | |
102 GaimPlugin *plug; | |
103 | |
104 gtk_list_store_clear(ls); | |
105 gaim_plugins_probe(G_MODULE_SUFFIX); | |
106 | |
107 for (probes = gaim_plugins_get_all(); | |
108 probes != NULL; | |
109 probes = probes->next) | |
110 { | |
111 char *name; | |
112 char *version; | |
113 char *summary; | |
114 char *desc; | |
115 plug = probes->data; | |
116 | |
117 if (plug->info->type == GAIM_PLUGIN_LOADER) { | |
118 GList *cur; | |
119 for (cur = GAIM_PLUGIN_LOADER_INFO(plug)->exts; cur != NULL; | |
120 cur = cur->next) | |
121 gaim_plugins_probe(cur->data); | |
122 continue; | |
123 } else if (plug->info->type != GAIM_PLUGIN_STANDARD || | |
124 (plug->info->flags & GAIM_PLUGIN_FLAG_INVISIBLE)) { | |
125 continue; | |
126 } | |
127 | |
128 gtk_list_store_append (ls, &iter); | |
129 | |
130 name = g_markup_escape_text(plug->info->name ? _(plug->info->name) : g_basename(plug->path), -1); | |
131 version = g_markup_escape_text(plug->info->version, -1); | |
132 summary = g_markup_escape_text(_(plug->info->summary), -1); | |
133 | |
134 desc = g_strdup_printf("<b>%s</b> %s\n%s", name, | |
135 version, | |
136 summary); | |
137 g_free(name); | |
138 g_free(version); | |
139 g_free(summary); | |
140 | |
141 gtk_list_store_set(ls, &iter, | |
142 0, gaim_plugin_is_loaded(plug), | |
143 1, desc, | |
144 2, plug, | |
145 3, gaim_plugin_is_unloadable(plug), | |
146 -1); | |
147 g_free(desc); | |
148 } | |
149 } | |
150 | |
151 static void plugin_loading_common(GaimPlugin *plugin, GtkTreeView *view, gboolean loaded) | |
152 { | |
153 GtkTreeIter iter; | |
154 GtkTreeModel *model = gtk_tree_view_get_model(view); | |
155 | |
156 if (gtk_tree_model_get_iter_first(model, &iter)) { | |
157 do { | |
158 GaimPlugin *plug; | |
159 GtkTreeSelection *sel; | |
160 | |
161 gtk_tree_model_get(model, &iter, 2, &plug, -1); | |
162 | |
163 if (plug != plugin) | |
164 continue; | |
165 | |
166 gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, loaded, -1); | |
167 | |
168 /* If the loaded/unloaded plugin is the selected row, | |
169 * update the pref_button. */ | |
170 sel = gtk_tree_view_get_selection(view); | |
171 if (gtk_tree_selection_get_selected(sel, &model, &iter)) | |
172 { | |
173 gtk_tree_model_get(model, &iter, 2, &plug, -1); | |
174 if (plug == plugin) | |
175 { | |
176 gtk_widget_set_sensitive(pref_button, | |
177 loaded | |
178 && ((GAIM_IS_GTK_PLUGIN(plug) && plug->info->ui_info | |
179 && GAIM_GTK_PLUGIN_UI_INFO(plug)->get_config_frame) | |
180 || (plug->info->prefs_info | |
181 && plug->info->prefs_info->get_plugin_pref_frame))); | |
182 } | |
183 } | |
184 | |
185 break; | |
186 } while (gtk_tree_model_iter_next(model, &iter)); | |
187 } | |
188 } | |
189 | |
190 static void plugin_load_cb(GaimPlugin *plugin, gpointer data) | |
191 { | |
192 GtkTreeView *view = (GtkTreeView *)data; | |
193 plugin_loading_common(plugin, view, TRUE); | |
194 } | |
195 | |
196 static void plugin_unload_cb(GaimPlugin *plugin, gpointer data) | |
197 { | |
198 GtkTreeView *view = (GtkTreeView *)data; | |
199 plugin_loading_common(plugin, view, FALSE); | |
200 } | |
201 | |
202 static void pref_dialog_response_cb(GtkWidget *d, int response, GaimPlugin *plug) | |
203 { | |
204 switch (response) { | |
205 case GTK_RESPONSE_CLOSE: | |
206 case GTK_RESPONSE_DELETE_EVENT: | |
207 g_hash_table_remove(plugin_pref_dialogs, plug); | |
208 if (g_hash_table_size(plugin_pref_dialogs) == 0) { | |
209 g_hash_table_destroy(plugin_pref_dialogs); | |
210 plugin_pref_dialogs = NULL; | |
211 } | |
212 gtk_widget_destroy(d); | |
213 break; | |
214 } | |
215 } | |
216 | |
217 static void plugin_unload_confirm_cb(gpointer *data) | |
218 { | |
219 GaimPlugin *plugin = (GaimPlugin *)data[0]; | |
220 GtkTreeModel *model = (GtkTreeModel *)data[1]; | |
221 GtkTreeIter *iter = (GtkTreeIter *)data[2]; | |
222 | |
223 plugin_toggled_stage_two(plugin, model, iter, TRUE); | |
224 | |
225 g_free(data); | |
226 } | |
227 | |
228 static void plugin_toggled(GtkCellRendererToggle *cell, gchar *pth, gpointer data) | |
229 { | |
230 GtkTreeModel *model = (GtkTreeModel *)data; | |
231 GtkTreeIter *iter = g_new(GtkTreeIter, 1); | |
232 GtkTreePath *path = gtk_tree_path_new_from_string(pth); | |
233 GaimPlugin *plug; | |
234 GtkWidget *dialog = NULL; | |
235 | |
236 gtk_tree_model_get_iter(model, iter, path); | |
237 gtk_tree_path_free(path); | |
238 gtk_tree_model_get(model, iter, 2, &plug, -1); | |
239 | |
240 /* Apparently, GTK+ won't honor the sensitive flag on cell renderers for booleans. */ | |
241 if (gaim_plugin_is_unloadable(plug)) | |
242 { | |
243 g_free(iter); | |
244 return; | |
245 } | |
246 | |
247 if (!gaim_plugin_is_loaded(plug)) | |
248 { | |
249 gaim_gtk_set_cursor(plugin_dialog, GDK_WATCH); | |
250 | |
251 gaim_plugin_load(plug); | |
252 plugin_toggled_stage_two(plug, model, iter, FALSE); | |
253 | |
254 gaim_gtk_clear_cursor(plugin_dialog); | |
255 } | |
256 else | |
257 { | |
258 if (plugin_pref_dialogs != NULL && | |
259 (dialog = g_hash_table_lookup(plugin_pref_dialogs, plug))) | |
260 pref_dialog_response_cb(dialog, GTK_RESPONSE_DELETE_EVENT, plug); | |
261 | |
262 if (plug->dependent_plugins != NULL) | |
263 { | |
264 GString *tmp = g_string_new(_("The following plugins will be unloaded.")); | |
265 GList *l; | |
266 gpointer *cb_data; | |
267 | |
268 for (l = plug->dependent_plugins ; l != NULL ; l = l->next) | |
269 { | |
270 const char *dep_name = (const char *)l->data; | |
271 GaimPlugin *dep_plugin = gaim_plugins_find_with_id(dep_name); | |
272 g_return_if_fail(dep_plugin != NULL); | |
273 | |
274 g_string_append_printf(tmp, "\n\t%s\n", _(dep_plugin->info->name)); | |
275 } | |
276 | |
277 cb_data = g_new(gpointer, 3); | |
278 cb_data[0] = plug; | |
279 cb_data[1] = model; | |
280 cb_data[2] = iter; | |
281 | |
282 gaim_request_action(plugin_dialog, NULL, | |
283 _("Multiple plugins will be unloaded."), | |
284 tmp->str, 0, cb_data, 2, | |
285 _("Unload Plugins"), G_CALLBACK(plugin_unload_confirm_cb), | |
286 _("Cancel"), g_free); | |
287 g_string_free(tmp, TRUE); | |
288 } | |
289 else | |
290 plugin_toggled_stage_two(plug, model, iter, TRUE); | |
291 } | |
292 } | |
293 | |
294 static void plugin_toggled_stage_two(GaimPlugin *plug, GtkTreeModel *model, GtkTreeIter *iter, gboolean unload) | |
295 { | |
296 gchar *name = NULL; | |
297 gchar *description = NULL; | |
298 | |
299 if (unload) | |
300 { | |
301 gaim_gtk_set_cursor(plugin_dialog, GDK_WATCH); | |
302 | |
303 gaim_plugin_unload(plug); | |
304 | |
305 gaim_gtk_clear_cursor(plugin_dialog); | |
306 } | |
307 | |
308 gtk_widget_set_sensitive(pref_button, | |
309 gaim_plugin_is_loaded(plug) | |
310 && ((GAIM_IS_GTK_PLUGIN(plug) && plug->info->ui_info | |
311 && GAIM_GTK_PLUGIN_UI_INFO(plug)->get_config_frame) | |
312 || (plug->info->prefs_info | |
313 && plug->info->prefs_info->get_plugin_pref_frame))); | |
314 | |
315 name = g_markup_escape_text(_(plug->info->name), -1); | |
316 description = g_markup_escape_text(_(plug->info->description), -1); | |
317 | |
318 if (plug->error != NULL) { | |
319 gchar *error = g_markup_escape_text(plug->error, -1); | |
320 gchar *desc; | |
321 gchar *text = g_strdup_printf( | |
322 "<span size=\"larger\">%s %s</span>\n\n" | |
323 "<span weight=\"bold\" color=\"red\">%s</span>\n\n" | |
324 "%s", | |
325 name, plug->info->version, error, description); | |
326 desc = g_strdup_printf("<b>%s</b> %s\n<span weight=\"bold\" color=\"red\"%s</span>", | |
327 plug->info->name, plug->info->version, error); | |
328 gtk_list_store_set(GTK_LIST_STORE (model), iter, | |
329 1, desc, | |
330 -1); | |
331 g_free(desc); | |
332 g_free(error); | |
333 gtk_label_set_markup(GTK_LABEL(plugin_details), text); | |
334 g_free(text); | |
335 } | |
336 g_free(name); | |
337 g_free(description); | |
338 | |
339 | |
340 gtk_list_store_set(GTK_LIST_STORE (model), iter, | |
341 0, gaim_plugin_is_loaded(plug), | |
342 -1); | |
343 g_free(iter); | |
344 | |
345 gaim_gtk_plugins_save(); | |
346 } | |
347 | |
348 static gboolean ensure_plugin_visible(void *data) | |
349 { | |
350 GtkTreeSelection *sel = GTK_TREE_SELECTION(data); | |
351 GtkTreeView *tv = gtk_tree_selection_get_tree_view(sel); | |
352 GtkTreeModel *model = gtk_tree_view_get_model(tv); | |
353 GtkTreePath *path; | |
354 GtkTreeIter iter; | |
355 if (!gtk_tree_selection_get_selected (sel, &model, &iter)) | |
356 return FALSE; | |
357 path = gtk_tree_model_get_path(model, &iter); | |
358 gtk_tree_view_scroll_to_cell(gtk_tree_selection_get_tree_view(sel), path, NULL, FALSE, 0, 0); | |
359 gtk_tree_path_free(path); | |
360 return FALSE; | |
361 } | |
362 | |
363 static void prefs_plugin_sel (GtkTreeSelection *sel, GtkTreeModel *model) | |
364 { | |
365 gchar *buf, *pname, *pdesc, *pauth, *pweb; | |
366 GtkTreeIter iter; | |
367 GValue val; | |
368 GaimPlugin *plug; | |
369 | |
370 if (!gtk_tree_selection_get_selected (sel, &model, &iter)) | |
371 { | |
372 /* Clear the old plugin details */ | |
373 gtk_label_set_markup(GTK_LABEL(plugin_details), ""); | |
374 gtk_widget_set_sensitive(pref_button, FALSE); | |
375 | |
376 /* Collapse and disable the expander widget */ | |
377 gtk_expander_set_expanded(GTK_EXPANDER(expander), FALSE); | |
378 gtk_widget_set_sensitive(expander, FALSE); | |
379 | |
380 return; | |
381 } | |
382 | |
383 gtk_widget_set_sensitive(expander, TRUE); | |
384 | |
385 val.g_type = 0; | |
386 gtk_tree_model_get_value (model, &iter, 2, &val); | |
387 plug = g_value_get_pointer(&val); | |
388 | |
389 pname = g_markup_escape_text(_(plug->info->name), -1); | |
390 pdesc = (plug->info->description) ? | |
391 g_markup_escape_text(_(plug->info->description), -1) : NULL; | |
392 pauth = (plug->info->author) ? | |
393 g_markup_escape_text(_(plug->info->author), -1) : NULL; | |
394 pweb = (plug->info->homepage) ? | |
395 g_markup_escape_text(_(plug->info->homepage), -1) : NULL; | |
396 buf = g_strdup_printf( | |
397 _("%s%s" | |
398 "<span weight=\"bold\">Written by:</span>\t%s\n" | |
399 "<span weight=\"bold\">Website:</span>\t\t%s\n" | |
400 "<span weight=\"bold\">Filename:</span>\t\t%s"), | |
401 pdesc ? pdesc : "", pdesc ? "\n\n" : "", | |
402 pauth ? pauth : "", pweb ? pweb : "", plug->path); | |
403 | |
404 if (plug->error != NULL) | |
405 { | |
406 char *tmp = g_strdup_printf( | |
407 _("%s\n" | |
408 "<span foreground=\"#ff0000\" weight=\"bold\">" | |
409 "Error: %s\n" | |
410 "Check the plugin website for an update." | |
411 "</span>"), | |
412 buf, plug->error); | |
413 g_free(buf); | |
414 buf = tmp; | |
415 } | |
416 | |
417 gtk_widget_set_sensitive(pref_button, | |
418 gaim_plugin_is_loaded(plug) | |
419 && ((GAIM_IS_GTK_PLUGIN(plug) && plug->info->ui_info | |
420 && GAIM_GTK_PLUGIN_UI_INFO(plug)->get_config_frame) | |
421 || (plug->info->prefs_info | |
422 && plug->info->prefs_info->get_plugin_pref_frame))); | |
423 | |
424 gtk_label_set_markup(GTK_LABEL(plugin_details), buf); | |
425 | |
426 /* Make sure the selected plugin is still visible */ | |
427 g_idle_add(ensure_plugin_visible, sel); | |
428 | |
429 | |
430 g_value_unset(&val); | |
431 g_free(buf); | |
432 g_free(pname); | |
433 g_free(pdesc); | |
434 g_free(pauth); | |
435 g_free(pweb); | |
436 } | |
437 | |
438 static void plugin_dialog_response_cb(GtkWidget *d, int response, GtkTreeSelection *sel) | |
439 { | |
440 GaimPlugin *plug; | |
441 GtkWidget *dialog, *box; | |
442 GtkTreeModel *model; | |
443 GValue val; | |
444 GtkTreeIter iter; | |
445 | |
446 switch (response) { | |
447 case GTK_RESPONSE_CLOSE: | |
448 case GTK_RESPONSE_DELETE_EVENT: | |
449 gaim_request_close_with_handle(plugin_dialog); | |
450 gaim_signals_disconnect_by_handle(plugin_dialog); | |
451 gtk_widget_destroy(d); | |
452 if (plugin_pref_dialogs != NULL) { | |
453 g_hash_table_destroy(plugin_pref_dialogs); | |
454 plugin_pref_dialogs = NULL; | |
455 } | |
456 plugin_dialog = NULL; | |
457 break; | |
458 case GAIM_RESPONSE_CONFIGURE: | |
459 if (! gtk_tree_selection_get_selected (sel, &model, &iter)) | |
460 return; | |
461 val.g_type = 0; | |
462 gtk_tree_model_get_value(model, &iter, 2, &val); | |
463 plug = g_value_get_pointer(&val); | |
464 if (plug == NULL) | |
465 break; | |
466 if (plugin_pref_dialogs != NULL && | |
467 g_hash_table_lookup(plugin_pref_dialogs, plug)) | |
468 break; | |
469 box = gaim_gtk_plugin_get_config_frame(plug); | |
470 if (box == NULL) | |
471 break; | |
472 | |
473 dialog = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, GTK_WINDOW(d), | |
474 GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT, | |
475 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
476 NULL); | |
477 if (plugin_pref_dialogs == NULL) | |
478 plugin_pref_dialogs = g_hash_table_new(NULL, NULL); | |
479 | |
480 g_hash_table_insert(plugin_pref_dialogs, plug, dialog); | |
481 | |
482 g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(pref_dialog_response_cb), plug); | |
483 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), box); | |
484 gtk_window_set_role(GTK_WINDOW(dialog), "plugin_config"); | |
485 gtk_window_set_title(GTK_WINDOW(dialog), _(gaim_plugin_get_name(plug))); | |
486 gtk_widget_show_all(dialog); | |
487 g_value_unset(&val); | |
488 break; | |
489 } | |
490 } | |
491 | |
492 static void | |
493 show_plugin_prefs_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column, GtkWidget *dialog) | |
494 { | |
495 GtkTreeSelection *sel; | |
496 GtkTreeIter iter; | |
497 GaimPlugin *plugin; | |
498 GtkTreeModel *model; | |
499 | |
500 sel = gtk_tree_view_get_selection(view); | |
501 | |
502 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) | |
503 return; | |
504 | |
505 gtk_tree_model_get(model, &iter, 2, &plugin, -1); | |
506 | |
507 if (!gaim_plugin_is_loaded(plugin)) | |
508 return; | |
509 | |
510 /* Now show the pref-dialog for the plugin */ | |
511 plugin_dialog_response_cb(dialog, GAIM_RESPONSE_CONFIGURE, sel); | |
512 } | |
513 | |
514 void gaim_gtk_plugin_dialog_show() | |
515 { | |
516 GtkWidget *sw; | |
517 GtkWidget *event_view; | |
518 GtkListStore *ls; | |
519 GtkCellRenderer *rend, *rendt; | |
520 GtkTreeViewColumn *col; | |
521 GtkTreeSelection *sel; | |
522 | |
523 if (plugin_dialog != NULL) { | |
524 gtk_window_present(GTK_WINDOW(plugin_dialog)); | |
525 return; | |
526 } | |
527 | |
528 plugin_dialog = gtk_dialog_new_with_buttons(_("Plugins"), | |
529 NULL, | |
530 GTK_DIALOG_NO_SEPARATOR, | |
531 NULL); | |
532 pref_button = gtk_dialog_add_button(GTK_DIALOG(plugin_dialog), | |
533 _("Configure Pl_ugin"), GAIM_RESPONSE_CONFIGURE); | |
534 gtk_dialog_add_button(GTK_DIALOG(plugin_dialog), | |
535 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); | |
536 gtk_widget_set_sensitive(pref_button, FALSE); | |
537 gtk_window_set_role(GTK_WINDOW(plugin_dialog), "plugins"); | |
538 | |
539 sw = gtk_scrolled_window_new(NULL,NULL); | |
540 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
541 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); | |
542 | |
543 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(plugin_dialog)->vbox), sw, TRUE, TRUE, 0); | |
544 | |
545 ls = gtk_list_store_new(4, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN); | |
546 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), | |
547 1, GTK_SORT_ASCENDING); | |
548 | |
549 update_plugin_list(ls); | |
550 | |
551 event_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
552 | |
553 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(event_view), TRUE); | |
554 | |
555 g_signal_connect(G_OBJECT(event_view), "row-activated", | |
556 G_CALLBACK(show_plugin_prefs_cb), plugin_dialog); | |
557 | |
558 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-load", plugin_dialog, | |
559 GAIM_CALLBACK(plugin_load_cb), event_view); | |
560 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-unload", plugin_dialog, | |
561 GAIM_CALLBACK(plugin_unload_cb), event_view); | |
562 | |
563 rend = gtk_cell_renderer_toggle_new(); | |
564 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (event_view)); | |
565 | |
566 col = gtk_tree_view_column_new_with_attributes (_("Enabled"), | |
567 rend, | |
568 "active", 0, | |
569 NULL); | |
570 gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col); | |
571 gtk_tree_view_column_set_sort_column_id(col, 0); | |
572 g_signal_connect(G_OBJECT(rend), "toggled", | |
573 G_CALLBACK(plugin_toggled), ls); | |
574 | |
575 rendt = gtk_cell_renderer_text_new(); | |
576 g_object_set(rendt, | |
577 "foreground", "#c0c0c0", | |
578 NULL); | |
579 col = gtk_tree_view_column_new_with_attributes (_("Name"), | |
580 rendt, | |
581 "markup", 1, | |
582 "foreground-set", 3, | |
583 NULL); | |
584 #if GTK_CHECK_VERSION(2,6,0) | |
585 gtk_tree_view_column_set_expand (col, TRUE); | |
586 g_object_set(rendt, "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
587 #endif | |
588 gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col); | |
589 gtk_tree_view_column_set_sort_column_id(col, 1); | |
590 g_object_unref(G_OBJECT(ls)); | |
591 gtk_container_add(GTK_CONTAINER(sw), event_view); | |
592 gtk_tree_view_set_search_column(GTK_TREE_VIEW(event_view), 1); | |
593 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(event_view), | |
594 gaim_gtk_tree_view_search_equal_func, NULL, NULL); | |
595 | |
596 expander = gtk_expander_new(_("<b>Plugin Details</b>")); | |
597 gtk_expander_set_use_markup(GTK_EXPANDER(expander), TRUE); | |
598 plugin_details = gtk_label_new(NULL); | |
599 gtk_label_set_line_wrap(GTK_LABEL(plugin_details), TRUE); | |
600 gtk_container_add(GTK_CONTAINER(expander), plugin_details); | |
601 gtk_widget_set_sensitive(expander, FALSE); | |
602 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(plugin_dialog)->vbox), expander, FALSE, FALSE, 0); | |
603 | |
604 g_signal_connect (G_OBJECT (sel), "changed", G_CALLBACK (prefs_plugin_sel), NULL); | |
605 g_signal_connect(G_OBJECT(plugin_dialog), "response", G_CALLBACK(plugin_dialog_response_cb), sel); | |
606 gtk_window_set_default_size(GTK_WINDOW(plugin_dialog), 430, 430); | |
607 gtk_widget_show_all(plugin_dialog); | |
608 } |