Mercurial > pidgin.yaz
comparison src/perl.c @ 1187:6a8e8c06baa5
[gaim-migrate @ 1197]
nsanch did this
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 02 Dec 2000 18:59:07 +0000 |
parents | c61f9c384413 |
children | 728a90516211 |
comparison
equal
deleted
inserted
replaced
1186:c00fc3adfd66 | 1187:6a8e8c06baa5 |
---|---|
74 | 74 |
75 static GList *perl_list = NULL; /* should probably extern this at some point */ | 75 static GList *perl_list = NULL; /* should probably extern this at some point */ |
76 static GList *perl_timeout_handlers = NULL; | 76 static GList *perl_timeout_handlers = NULL; |
77 static GList *perl_event_handlers = NULL; | 77 static GList *perl_event_handlers = NULL; |
78 static PerlInterpreter *my_perl = NULL; | 78 static PerlInterpreter *my_perl = NULL; |
79 static char* last_dir = NULL; | |
79 | 80 |
80 /* dealing with gaim */ | 81 /* dealing with gaim */ |
81 XS(XS_GAIM_register); /* set up hooks for script */ | 82 XS(XS_GAIM_register); /* set up hooks for script */ |
82 XS(XS_GAIM_get_info); /* version, last to attempt signon, protocol */ | 83 XS(XS_GAIM_get_info); /* version, last to attempt signon, protocol */ |
83 XS(XS_GAIM_print); /* lemme figure this one out... */ | 84 XS(XS_GAIM_print); /* lemme figure this one out... */ |
592 perl_timeout_handlers = g_list_append(perl_timeout_handlers, handler); | 593 perl_timeout_handlers = g_list_append(perl_timeout_handlers, handler); |
593 handler->iotag = gtk_timeout_add(timeout, (GtkFunction)perl_timeout, handler); | 594 handler->iotag = gtk_timeout_add(timeout, (GtkFunction)perl_timeout, handler); |
594 XSRETURN_EMPTY; | 595 XSRETURN_EMPTY; |
595 } | 596 } |
596 | 597 |
597 static GtkWidget *config = NULL; | 598 static GtkWidget *config = NULL; |
598 static GtkWidget *entry = NULL; | |
599 | 599 |
600 static void cfdes(GtkWidget *m, gpointer n) { | 600 static void cfdes(GtkWidget *m, gpointer n) { |
601 if (config) gtk_widget_destroy(config); | 601 if (config) gtk_widget_destroy(config); |
602 config = NULL; | 602 config = NULL; |
603 } | 603 } |
604 | 604 |
605 static void do_load(GtkWidget *m, gpointer n) { | 605 static void do_load(GtkWidget *m, gpointer n) { |
606 char *file = gtk_entry_get_text(GTK_ENTRY(entry)); | 606 gchar* file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(config)); |
607 if (!file || !strlen(file)) { | 607 if (!file || !strlen(file)) { |
608 perl_end(); | 608 perl_end(); |
609 perl_init(); | 609 perl_init(); |
610 return; | 610 return; |
611 } | 611 } |
612 | |
613 if (file_is_dir(file, config)) { | |
614 return; | |
615 } | |
616 | |
617 if (last_dir) { | |
618 g_free(last_dir); | |
619 } | |
620 last_dir = g_dirname(file); | |
621 | |
622 debug_printf("Loading perl script: %s\n", file); | |
623 | |
612 perl_load_file(file); | 624 perl_load_file(file); |
613 gtk_widget_destroy(config); | 625 cfdes(config, NULL); |
614 } | 626 } |
615 | 627 |
616 void load_perl_script(GtkWidget *w, gpointer d) | 628 void load_perl_script(GtkWidget *w, gpointer d) |
617 { | 629 { |
618 GtkWidget *frame; | 630 char *buf, *temp; |
619 GtkWidget *vbox; | |
620 GtkWidget *hbox; | |
621 GtkWidget *label; | |
622 GtkWidget *ok; | |
623 GtkWidget *cancel; | |
624 | 631 |
625 if (config) { | 632 if (config) { |
626 gtk_widget_show(config); | 633 gtk_widget_show(config); |
634 gdk_window_raise(config->window); | |
627 return; | 635 return; |
628 } | 636 } |
629 | 637 |
630 config = gtk_window_new(GTK_WINDOW_DIALOG); | 638 /* Below is basically stolen from plugins.c */ |
631 gtk_window_set_policy(GTK_WINDOW(config), TRUE, TRUE, FALSE); | 639 config = gtk_file_selection_new(_("Gaim - Select Perl Script")); |
632 gtk_window_set_wmclass(GTK_WINDOW(config), "perl_script", "Gaim"); | 640 |
633 gtk_window_set_title(GTK_WINDOW(config), "Gaim - Add Perl Script"); | 641 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(config)); |
634 gtk_container_set_border_width(GTK_CONTAINER(config), 5); | 642 |
635 gtk_signal_connect(GTK_OBJECT(config), "destroy", GTK_SIGNAL_FUNC(cfdes), 0); | 643 if (!last_dir) { |
636 gtk_widget_realize(config); | 644 buf = g_strjoin(NULL, g_get_home_dir(), G_DIR_SEPARATOR_S, ".gaim", |
637 aol_icon(config->window); | 645 G_DIR_SEPARATOR_S, NULL); |
638 | 646 } else { |
639 frame = gtk_frame_new("Load Script"); | 647 buf = g_strconcat(last_dir, G_DIR_SEPARATOR_S, NULL); |
640 gtk_container_add(GTK_CONTAINER(config), frame); | 648 } |
641 gtk_widget_show(frame); | 649 |
642 | 650 gtk_file_selection_set_filename(GTK_FILE_SELECTION(config), buf); |
643 vbox = gtk_vbox_new(FALSE, 5); | 651 gtk_file_selection_complete(GTK_FILE_SELECTION(config), "*.pl"); |
644 gtk_container_add(GTK_CONTAINER(frame), vbox); | 652 gtk_signal_connect(GTK_OBJECT(config), "destroy", GTK_SIGNAL_FUNC(cfdes), |
645 gtk_widget_show(vbox); | 653 config); |
646 | 654 |
647 hbox = gtk_hbox_new(FALSE, 5); | 655 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(config)->ok_button), |
648 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); | 656 "clicked", GTK_SIGNAL_FUNC(do_load), NULL); |
649 gtk_widget_show(hbox); | 657 |
650 | 658 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(config)->cancel_button), |
651 label = gtk_label_new("File Name:"); | 659 "clicked", GTK_SIGNAL_FUNC(cfdes), NULL); |
652 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | 660 |
653 gtk_widget_show(label); | 661 g_free(buf); |
654 | |
655 entry = gtk_entry_new(); | |
656 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5); | |
657 gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(do_load), 0); | |
658 gtk_widget_show(entry); | |
659 | |
660 hbox = gtk_hbox_new(TRUE, 10); | |
661 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); | |
662 gtk_widget_show(hbox); | |
663 | |
664 ok = picture_button(config, "Load", add_xpm); | |
665 gtk_box_pack_start(GTK_BOX(hbox), ok, FALSE, FALSE, 5); | |
666 gtk_signal_connect(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(do_load), 0); | |
667 | |
668 cancel = picture_button(config, "Cancel", cancel_xpm); | |
669 gtk_box_pack_start(GTK_BOX(hbox), cancel, FALSE, FALSE, 5); | |
670 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(cfdes), 0); | |
671 | |
672 gtk_widget_show(config); | 662 gtk_widget_show(config); |
663 gdk_window_raise(config->window); | |
673 } | 664 } |
674 | 665 |
675 extern void unload_perl_scripts(GtkWidget *w, gpointer d) | 666 extern void unload_perl_scripts(GtkWidget *w, gpointer d) |
676 { | 667 { |
677 perl_end(); | 668 perl_end(); |