annotate plugins/perl.c @ 859:75172284a1a7

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