Mon, 18 Sep 2000 19:13:27 +0000
[gaim-migrate @ 938]
Yo
| 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 | } | |
| 25 | ||
| 26 | static GtkWidget *config = NULL; | |
| 27 | static GtkWidget *entry = NULL; | |
| 28 | ||
| 29 | static void cfdes(GtkWidget *m, gpointer n) { | |
| 30 | if (config) gtk_widget_destroy(config); | |
| 31 | config = NULL; | |
| 32 | } | |
| 33 | ||
| 34 | static void do_load(GtkWidget *m, gpointer n) { | |
| 35 | char *file = gtk_entry_get_text(GTK_ENTRY(entry)); | |
| 36 | if (!file || !strlen(file)) { | |
| 37 | perl_end(); | |
| 38 | perl_init(); | |
| 39 | return; | |
| 40 | } | |
| 41 | perl_load_file(file); | |
| 42 | gtk_widget_destroy(config); | |
| 43 | } | |
| 44 | ||
| 45 | void gaim_plugin_config() { | |
| 46 | GtkWidget *frame; | |
| 47 | GtkWidget *vbox; | |
| 48 | GtkWidget *hbox; | |
| 49 | GtkWidget *label; | |
| 50 | GtkWidget *ok; | |
| 51 | GtkWidget *cancel; | |
| 52 | ||
| 53 | if (config) { | |
| 54 | gtk_widget_show(config); | |
| 55 | return; | |
| 56 | } | |
| 57 | ||
| 58 | config = gtk_window_new(GTK_WINDOW_DIALOG); | |
| 59 | gtk_window_set_policy(GTK_WINDOW(config), 0, 0, 1); | |
| 60 | gtk_window_set_title(GTK_WINDOW(config), "Gaim - Add Perl Script"); | |
| 61 | gtk_container_set_border_width(GTK_CONTAINER(config), 5); | |
| 62 | gtk_signal_connect(GTK_OBJECT(config), "destroy", GTK_SIGNAL_FUNC(cfdes), 0); | |
| 63 | gtk_widget_realize(config); | |
| 64 | aol_icon(config->window); | |
| 65 | ||
| 66 | frame = gtk_frame_new("Load Script"); | |
| 67 | gtk_container_add(GTK_CONTAINER(config), frame); | |
| 68 | gtk_widget_show(frame); | |
| 69 | ||
| 70 | vbox = gtk_vbox_new(FALSE, 5); | |
| 71 | gtk_container_add(GTK_CONTAINER(frame), vbox); | |
| 72 | gtk_widget_show(vbox); | |
| 73 | ||
| 74 | hbox = gtk_hbox_new(FALSE, 5); | |
| 75 | gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); | |
| 76 | gtk_widget_show(hbox); | |
| 77 | ||
| 78 | label = gtk_label_new("File Name:"); | |
| 79 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
| 80 | gtk_widget_show(label); | |
| 81 | ||
| 82 | entry = gtk_entry_new(); | |
| 83 | gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5); | |
| 84 | gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(do_load), 0); | |
| 85 | gtk_widget_show(entry); | |
| 86 | ||
| 87 | hbox = gtk_hbox_new(TRUE, 10); | |
| 88 | gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); | |
| 89 | gtk_widget_show(hbox); | |
| 90 | ||
| 91 | ok = picture_button(config, "Load", add_xpm); | |
| 92 | gtk_box_pack_start(GTK_BOX(hbox), ok, FALSE, FALSE, 5); | |
| 93 | gtk_signal_connect(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(do_load), 0); | |
| 94 | ||
| 95 | cancel = picture_button(config, "Cancel", cancel_xpm); | |
| 96 | gtk_box_pack_start(GTK_BOX(hbox), cancel, FALSE, FALSE, 5); | |
| 97 | gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(cfdes), 0); | |
| 98 | ||
| 99 | gtk_widget_show(config); | |
| 100 | } | |
| 101 | ||
| 102 | void gaim_plugin_remove() { | |
| 103 | if (config) gtk_widget_destroy(config); | |
| 104 | } |