749
|
1 /*
|
|
2 * This is a plugin to load perl scripts. If you don't enter
|
|
3 * in a name of a script to load it will unload all perl
|
|
4 * scripts. This is just to test that perl is working in gaim
|
|
5 * before the UI comes in. You can use this to start building
|
|
6 * perl scripts, but don't use this for anything real yet.
|
|
7 *
|
|
8 */
|
|
9
|
|
10 #define GAIM_PLUGINS
|
|
11 #include "gaim.h"
|
|
12 #include "pixmaps/add.xpm"
|
|
13 #include "pixmaps/cancel.xpm"
|
|
14
|
|
15 char *name() {
|
|
16 return "Perl Plug";
|
|
17 }
|
|
18
|
|
19 char *description() {
|
|
20 return "Interface for loading perl scripts";
|
|
21 }
|
|
22
|
|
23 int gaim_plugin_init(void *h) {
|
|
24 perl_init();
|
|
25 }
|
|
26
|
|
27 static GtkWidget *config = NULL;
|
|
28 static GtkWidget *entry = NULL;
|
|
29
|
|
30 static void cfdes(GtkWidget *m, gpointer n) {
|
|
31 if (config) gtk_widget_destroy(config);
|
|
32 config = NULL;
|
|
33 }
|
|
34
|
|
35 static void do_load(GtkWidget *m, gpointer n) {
|
|
36 char *file = gtk_entry_get_text(GTK_ENTRY(entry));
|
|
37 if (!file || !strlen(file)) {
|
|
38 perl_end();
|
|
39 perl_init();
|
|
40 return;
|
|
41 }
|
|
42 perl_load_file(file);
|
|
43 gtk_widget_destroy(config);
|
|
44 }
|
|
45
|
|
46 void gaim_plugin_config() {
|
|
47 GtkWidget *frame;
|
|
48 GtkWidget *vbox;
|
|
49 GtkWidget *hbox;
|
|
50 GtkWidget *label;
|
|
51 GtkWidget *ok;
|
|
52 GtkWidget *cancel;
|
|
53
|
|
54 if (config) {
|
|
55 gtk_widget_show(config);
|
|
56 return;
|
|
57 }
|
|
58
|
|
59 config = gtk_window_new(GTK_WINDOW_DIALOG);
|
|
60 gtk_window_set_policy(GTK_WINDOW(config), 0, 0, 1);
|
|
61 gtk_window_set_title(GTK_WINDOW(config), "Gaim - Add Perl Script");
|
|
62 gtk_container_set_border_width(GTK_CONTAINER(config), 5);
|
|
63 gtk_signal_connect(GTK_OBJECT(config), "destroy", GTK_SIGNAL_FUNC(cfdes), 0);
|
|
64 gtk_widget_realize(config);
|
|
65 aol_icon(config->window);
|
|
66
|
|
67 frame = gtk_frame_new("Load Script");
|
|
68 gtk_container_add(GTK_CONTAINER(config), frame);
|
|
69 gtk_widget_show(frame);
|
|
70
|
|
71 vbox = gtk_vbox_new(FALSE, 5);
|
|
72 gtk_container_add(GTK_CONTAINER(frame), vbox);
|
|
73 gtk_widget_show(vbox);
|
|
74
|
|
75 hbox = gtk_hbox_new(FALSE, 5);
|
|
76 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
|
|
77 gtk_widget_show(hbox);
|
|
78
|
|
79 label = gtk_label_new("File Name:");
|
|
80 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
|
|
81 gtk_widget_show(label);
|
|
82
|
|
83 entry = gtk_entry_new();
|
|
84 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
|
|
85 gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(do_load), 0);
|
|
86 gtk_widget_show(entry);
|
|
87
|
|
88 hbox = gtk_hbox_new(TRUE, 10);
|
|
89 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
|
|
90 gtk_widget_show(hbox);
|
|
91
|
|
92 ok = picture_button(config, "Load", add_xpm);
|
|
93 gtk_box_pack_start(GTK_BOX(hbox), ok, FALSE, FALSE, 5);
|
|
94 gtk_signal_connect(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(do_load), 0);
|
|
95
|
|
96 cancel = picture_button(config, "Cancel", cancel_xpm);
|
|
97 gtk_box_pack_start(GTK_BOX(hbox), cancel, FALSE, FALSE, 5);
|
|
98 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(cfdes), 0);
|
|
99
|
|
100 gtk_widget_show(config);
|
|
101 }
|
|
102
|
|
103 void gaim_plugin_remove() {
|
|
104 if (config) gtk_widget_destroy(config);
|
|
105 perl_end();
|
|
106 }
|