Mercurial > pidgin
diff src/perl.c @ 798:9dc39872e1f9
[gaim-migrate @ 808]
beginnings of perl interface
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Wed, 30 Aug 2000 18:46:43 +0000 |
| parents | c13e78ae0f86 |
| children | 72f8ac951c11 |
line wrap: on
line diff
--- a/src/perl.c Wed Aug 30 04:31:05 2000 +0000 +++ b/src/perl.c Wed Aug 30 18:46:43 2000 +0000 @@ -43,6 +43,10 @@ #include <fcntl.h> #undef PACKAGE #include <stdio.h> +#include <gtk/gtk.h> +#include "pixmaps/add.xpm" +#include "pixmaps/cancel.xpm" + /* perl module support */ extern void xs_init _((void)); @@ -499,4 +503,91 @@ XSRETURN_EMPTY; } +static GtkWidget *config = NULL; +static GtkWidget *entry = NULL; + +static void cfdes(GtkWidget *m, gpointer n) { + if (config) gtk_widget_destroy(config); + config = NULL; +} + +static void do_load(GtkWidget *m, gpointer n) { + char *file = gtk_entry_get_text(GTK_ENTRY(entry)); + if (!file || !strlen(file)) { + perl_end(); + perl_init(); + return; + } + perl_load_file(file); + gtk_widget_destroy(config); +} + +void load_perl_script(GtkWidget *w, gpointer d) +{ + GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *label; + GtkWidget *ok; + GtkWidget *cancel; + + if (config) { + gtk_widget_show(config); + return; + } + + config = gtk_window_new(GTK_WINDOW_DIALOG); + gtk_window_set_policy(GTK_WINDOW(config), 0, 0, 1); + gtk_window_set_title(GTK_WINDOW(config), "Gaim - Add Perl Script"); + gtk_container_set_border_width(GTK_CONTAINER(config), 5); + gtk_signal_connect(GTK_OBJECT(config), "destroy", GTK_SIGNAL_FUNC(cfdes), 0); + gtk_widget_realize(config); + aol_icon(config->window); + + frame = gtk_frame_new("Load Script"); + gtk_container_add(GTK_CONTAINER(config), frame); + gtk_widget_show(frame); + + vbox = gtk_vbox_new(FALSE, 5); + gtk_container_add(GTK_CONTAINER(frame), vbox); + gtk_widget_show(vbox); + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); + gtk_widget_show(hbox); + + label = gtk_label_new("File Name:"); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); + gtk_widget_show(label); + + entry = gtk_entry_new(); + gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5); + gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(do_load), 0); + gtk_widget_show(entry); + + hbox = gtk_hbox_new(TRUE, 10); + gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); + gtk_widget_show(hbox); + + ok = picture_button(config, "Load", add_xpm); + gtk_box_pack_start(GTK_BOX(hbox), ok, FALSE, FALSE, 5); + gtk_signal_connect(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(do_load), 0); + + cancel = picture_button(config, "Cancel", cancel_xpm); + gtk_box_pack_start(GTK_BOX(hbox), cancel, FALSE, FALSE, 5); + gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(cfdes), 0); + + gtk_widget_show(config); +} + +extern void unload_perl_scripts(GtkWidget *w, gpointer d) +{ + perl_end(); + perl_init(); +} + +extern void list_perl_scripts(GtkWidget *w, gpointer d) +{ + do_error_dialog("Implement me.", "FIXME"); +} #endif /* USE_PERL */
