Mercurial > pidgin.yaz
changeset 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 |
files | src/buddy.c src/gaim.h src/perl.c |
diffstat | 3 files changed, 117 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/buddy.c Wed Aug 30 04:31:05 2000 +0000 +++ b/src/buddy.c Wed Aug 30 18:46:43 2000 +0000 @@ -1722,6 +1722,9 @@ GtkWidget *sw; GtkWidget *menu; GtkWidget *findmenu; +#ifdef USE_PERL + GtkWidget *perlmenu; +#endif GtkWidget *setmenu; GtkWidget *menubar; GtkWidget *vbox; @@ -1828,6 +1831,25 @@ #ifdef GAIM_PLUGINS gaim_new_item(menu, _("Plugins"), GTK_SIGNAL_FUNC(show_plugins)); #endif +#ifdef USE_PERL + perlmenu = gtk_menu_new(); + gtk_widget_show(perlmenu); + menuitem = gaim_new_item(menu, _("Perl"), NULL); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), perlmenu); + gtk_widget_show(menuitem); + menuitem = gtk_menu_item_new_with_label(_("Load Script")); + gtk_menu_append(GTK_MENU(perlmenu), menuitem); + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(load_perl_script), NULL); + gtk_widget_show(menuitem); + menuitem = gtk_menu_item_new_with_label(_("Unload All Scripts")); + gtk_menu_append(GTK_MENU(perlmenu), menuitem); + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(unload_perl_scripts), NULL); + gtk_widget_show(menuitem); + menuitem = gtk_menu_item_new_with_label(_("List Scripts")); + gtk_menu_append(GTK_MENU(perlmenu), menuitem); + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(list_perl_scripts), NULL); + gtk_widget_show(menuitem); +#endif menu = gtk_menu_new();
--- a/src/gaim.h Wed Aug 30 04:31:05 2000 +0000 +++ b/src/gaim.h Wed Aug 30 18:46:43 2000 +0000 @@ -401,7 +401,7 @@ #define TYPE_SIGNOFF 4 #define TYPE_KEEPALIVE 5 -#define REVISION "gaim:$Revision: 807 $" +#define REVISION "gaim:$Revision: 808 $" #define FLAPON "FLAPON\r\n\r\n" #define ROAST "Tic/Toc" @@ -738,6 +738,9 @@ extern int perl_load_file(char *); extern void perl_end(); extern int perl_event(enum gaim_event, char *); +extern void load_perl_script(GtkWidget *, gpointer); +extern void unload_perl_scripts(GtkWidget *, gpointer); +extern void list_perl_scripts(GtkWidget *, gpointer); #endif /* Functions in plugins.c */
--- 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 */