~ubuntu-branches/ubuntu/quantal/padre/quantal

« back to all changes in this revision

Viewing changes to lib/Padre/Wx/Role/Conduit.pm

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2010-12-11 20:56:34 UTC
  • mfrom: (1.3.1 upstream) (13.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20101211205634-sitpxguuf9cct47q
Tags: 0.76.ds1-1
* New upstream release

* bump liborlite (build-)dependency to 1.46
* bump libparse-errorstring-perl-perl (build-)dependency to 0.14
* bump libwx-perl-processstream-perl (build-)dependency to 0.29
* update the list of incomplete manuals

* Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package Padre::Wx::Role::Conduit;
 
2
 
 
3
=pod
 
4
 
 
5
=head1 NAME
 
6
 
 
7
Padre::Wx::Role::Conduit - Role to allows an object to receive Wx events
 
8
 
 
9
=head1 DESCRIPTION
 
10
 
 
11
This is a role that provides the functionality needed to receive Wx thread
 
12
events.
 
13
 
 
14
However, you should only use this role once, in the parent process.
 
15
 
 
16
It is implemented as a role so that the functionality can be used across the
 
17
main process and various testing classes (and will be easier to turn into a
 
18
CPAN spinoff later).
 
19
 
 
20
=cut
 
21
 
 
22
use 5.008;
 
23
use strict;
 
24
use warnings;
 
25
use Padre::Wx ();
 
26
use Padre::Logger;
 
27
 
 
28
our $VERSION = '0.76';
 
29
 
 
30
our $SIGNAL : shared;
 
31
 
 
32
BEGIN {
 
33
        $SIGNAL = Wx::NewEventType();
 
34
}
 
35
 
 
36
my $CONDUIT = undef;
 
37
my $HANDLER = undef;
 
38
 
 
39
sub handler {
 
40
        $HANDLER = $_[1];
 
41
}
 
42
 
 
43
sub conduit_init {
 
44
        TRACE( $_[0] ) if DEBUG;
 
45
        $CONDUIT = $_[0];
 
46
        $HANDLER = $_[1];
 
47
        Wx::Event::EVT_COMMAND( $CONDUIT, -1, $SIGNAL, \&on_signal );
 
48
        return 1;
 
49
}
 
50
 
 
51
sub signal {
 
52
        TRACE( $_[0] ) if DEBUG;
 
53
        $CONDUIT->AddPendingEvent( Wx::PlThreadEvent->new( -1, $SIGNAL, $_[1] ) ) if $CONDUIT;
 
54
}
 
55
 
 
56
# Pass the event through to the event handler
 
57
sub on_signal {
 
58
        TRACE( $_[1] ) if DEBUG;
 
59
        $HANDLER->on_signal( $_[1] ) if $HANDLER;
 
60
        return 1;
 
61
}
 
62
 
 
63
1;
 
64
 
 
65
# Copyright 2008-2010 The Padre development team as listed in Padre.pm.
 
66
# LICENSE
 
67
# This program is free software; you can redistribute it and/or
 
68
# modify it under the same terms as Perl 5 itself.