comparison plugins/perl/scripts/plugin_action.pl @ 12988:b457aa723bab

[gaim-migrate @ 15341] Perl plugins can now have more than one plugin action. This isn't exactly the nicest way to have done this, as it requires a "global" plugin_actions hash to work, but I couldn't get the cleaner way to work and this is better than nothing. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Sun, 22 Jan 2006 10:29:34 +0000
parents
children
comparison
equal deleted inserted replaced
12987:750968cab201 12988:b457aa723bab
1 $MODULE_NAME = "Plugin Action Test Plugin";
2 use Gaim;
3
4 sub plugin_init {
5 return %PLUGIN_INFO;
6 }
7
8 sub plugin_load {
9 my $plugin = shift;
10 }
11
12 sub plugin_unload {
13 my $plugin = shift;
14 }
15
16 sub fun1 {
17 print "1\n";
18 }
19
20 sub fun2 {
21 print "2\n";
22 }
23
24 sub fun3 {
25 print "3\n";
26 }
27
28 %plugin_actions = (
29 "Action 1" => \&fun1,
30 "Action 2" => \&fun2,
31 "Action 3" => \&fun3
32 # "Action 1" => sub { print "1\n"; },
33 # "Action 2" => sub { print "2\n"; },
34 # "Action 3" => sub { print "3\n"; }
35 );
36
37 sub plugin_action_names {
38 foreach $key (keys %plugin_actions) {
39 push @array, $key;
40 }
41
42 return @array;
43 }
44
45 # All the information Gaim gets about our nifty plugin
46 %PLUGIN_INFO = (
47 perl_api_version => 2,
48 name => "Perl: $MODULE_NAME",
49 version => "0.1",
50 summary => "Test plugin for the Perl interpreter.",
51 description => "Just a basic test plugin template.",
52 author => "Etan Reisner <deryni\@gmail.com>",
53 url => "http://sourceforge.net/users/deryni9/",
54
55 load => "plugin_load",
56 unload => "plugin_unload",
57 plugin_action_sub => "plugin_action_names"
58 );