| 1 | package Gtk2::Ex::Email::AAnotebook; | ||
| 2 | |||
| 3 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 0 | ▶ | use Gtk2; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 6 | use Gtk2::Ex::Email::AddressVBox; | ||
| 7 | use Gtk2::Ex::Email::AttachmentVBox; | ||
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | Gtk2::Ex::Email::AAnotebook - Creates a Gtk2::Notebook object for handling addresses and attachments | ||
| 12 | |||
| 13 | =head1 VERSION | ||
| 14 | |||
| 15 | Version 0.0.0 | ||
| 16 | |||
| 17 | =cut | ||
| 18 | |||
| 19 | our $VERSION = '0.0.0'; | ||
| 20 | |||
| 21 | |||
| 22 | =head1 SYNOPSIS | ||
| 23 | |||
| 24 | use Gtk2::Ex::Email::AAnotebook; | ||
| 25 | use Gtk2; | ||
| 26 | use Data::Dumper; | ||
| 27 | |||
| 28 | Gtk2->init; | ||
| 29 | |||
| 30 | my $aanb=Gtk2::Ex::Email::AAnotebook->new(); | ||
| 31 | |||
| 32 | my $vbox=Gtk2::VBox->new; | ||
| 33 | $vbox->show; | ||
| 34 | |||
| 35 | my $notebook=$aanb->notebook; | ||
| 36 | $vbox->pack_start($notebook, 1, 1, 1); | ||
| 37 | |||
| 38 | #get the object for talking to the Gtk2::Ex::Email::AddressVBox | ||
| 39 | my $addressVB=$aanb->getAddressVBox; | ||
| 40 | |||
| 41 | #get the object for talking to the Gtk2::Ex::Email::AttachmentVBox | ||
| 42 | my $attachmentVB=$aanb->getAttachmentVBox; | ||
| 43 | |||
| 44 | #adds a button that calls getAddresses | ||
| 45 | my $button=Gtk2::Button->new; | ||
| 46 | $button->show; | ||
| 47 | my $buttonLabel=Gtk2::Label->new('get addresses'); | ||
| 48 | $buttonLabel->show; | ||
| 49 | $button->add($buttonLabel); | ||
| 50 | $vbox->pack_start($button, 0, 1, 1); | ||
| 51 | $button->signal_connect(clicked=>sub{ | ||
| 52 | my %addresses=$addressVB->getAddresses; | ||
| 53 | print Dumper(\%addresses); | ||
| 54 | } | ||
| 55 | ); | ||
| 56 | |||
| 57 | #adds a button that calls getFiles | ||
| 58 | my $button2=Gtk2::Button->new; | ||
| 59 | $button2->show; | ||
| 60 | my $buttonLabel2=Gtk2::Label->new('get files'); | ||
| 61 | $buttonLabel2->show; | ||
| 62 | $button2->add($buttonLabel2); | ||
| 63 | $vbox->pack_start($button2, 0, 1, 1); | ||
| 64 | $button2->signal_connect(clicked=>sub{ | ||
| 65 | my @files=$attachmentVB->getFiles; | ||
| 66 | print Dumper(\@files); | ||
| 67 | } | ||
| 68 | ); | ||
| 69 | |||
| 70 | my $window=Gtk2::Window->new; | ||
| 71 | $window->add($vbox); | ||
| 72 | $window->show; | ||
| 73 | |||
| 74 | Gtk2->main; | ||
| 75 | |||
| 76 | =head1 METHODS | ||
| 77 | |||
| 78 | =head2 new | ||
| 79 | |||
| 80 | This initiates the object. | ||
| 81 | |||
| 82 | my $anb=Gtk2::Ex::Email::AAnotbook->new(); | ||
| 83 | |||
| 84 | =cut | ||
| 85 | |||
| 86 | sub new{ | ||
| 87 | my $self={error=>undef, | ||
| 88 | perror=>undef, | ||
| 89 | errorString=>undef, | ||
| 90 | gui=>{}, | ||
| 91 | module=>'Gtk2-Ex-Email-AAnotebook', | ||
| 92 | }; | ||
| 93 | bless $self; | ||
| 94 | |||
| 95 | return $self; | ||
| 96 | } | ||
| 97 | |||
| 98 | =head2 getAddressVBox | ||
| 99 | |||
| 100 | This gets object created by Gtk2::Ex::Email::AddressVBox. This | ||
| 101 | should be called after the notebook method is called. | ||
| 102 | |||
| 103 | my $addressVBox=$anb->getAttachmentVBox; | ||
| 104 | |||
| 105 | =cut | ||
| 106 | |||
| 107 | sub getAddressVBox{ | ||
| 108 | my $self=$_[0]; | ||
| 109 | my $function='getAddressVBox'; | ||
| 110 | |||
| 111 | if (!defined($self->{addressVB})) { | ||
| 112 | warn($self->{module}.' '.$function.': Gtk2::Ex::Email::AddressVBox has not been initiated via the notebook method yet'); | ||
| 113 | return undef; | ||
| 114 | } | ||
| 115 | |||
| 116 | return $self->{addressVB}; | ||
| 117 | } | ||
| 118 | |||
| 119 | =head2 getAttachmentVBox | ||
| 120 | |||
| 121 | This gets object created by Gtk2::Ex::Email::AttachmentVBox. This | ||
| 122 | should be called after the notebook method is called. | ||
| 123 | |||
| 124 | my $attachmentVBox=$anb->getAttachmentVBox; | ||
| 125 | |||
| 126 | =cut | ||
| 127 | |||
| 128 | sub getAttachmentVBox{ | ||
| 129 | my $self=$_[0]; | ||
| 130 | my $function='getAttachmentVBox'; | ||
| 131 | |||
| 132 | if (!defined($self->{attachmentVB})) { | ||
| 133 | warn($self->{module}.' '.$function.': Gtk2::Ex::Email::AttachmentVBox has not been initiated via the notebook method yet'); | ||
| 134 | return undef; | ||
| 135 | } | ||
| 136 | |||
| 137 | return $self->{attachmentVB}; | ||
| 138 | } | ||
| 139 | |||
| 140 | =head2 notebook | ||
| 141 | |||
| 142 | This initiates the notebook object and returns it. | ||
| 143 | |||
| 144 | Two optional arguements are taken. The first is the the | ||
| 145 | hash reference that will be used for initiating | ||
| 146 | Gtk2::Ex::Email::AddressVBox and the second is a array | ||
| 147 | reference that will be used for initiating | ||
| 148 | Gtk2::Ex::Email::AttachmentVBox. | ||
| 149 | |||
| 150 | my $notebook=$anb->notebook( \%addresses , \@files); | ||
| 151 | |||
| 152 | =cut | ||
| 153 | |||
| 154 | sub notebook{ | ||
| 155 | my $self=$_[0]; | ||
| 156 | my %addresses; | ||
| 157 | if(defined($_[1])){ | ||
| 158 | %addresses= %{$_[1]}; | ||
| 159 | } | ||
| 160 | my @files; | ||
| 161 | if(defined($_[2])){ | ||
| 162 | @files= %{$_[2]}; | ||
| 163 | } | ||
| 164 | |||
| 165 | #inits the notbook | ||
| 166 | $self->{gui}{notebook}=Gtk2::Notebook->new; | ||
| 167 | $self->{gui}{notebook}->show; | ||
| 168 | |||
| 169 | #creates the scrolled window that will hold the address book | ||
| 170 | $self->{gui}{addressSW}=Gtk2::ScrolledWindow->new; | ||
| 171 | $self->{gui}{addressSW}->show; | ||
| 172 | |||
| 173 | #inits Gtk2::Ex::Email::AddressVBox | ||
| 174 | $self->{addressVB}=Gtk2::Ex::Email::AddressVBox->new; | ||
| 175 | $self->{gui}{addressVBox}=$self->{addressVB}->vbox(\%addresses); | ||
| 176 | |||
| 177 | #puts the address tab in place | ||
| 178 | $self->{gui}{addressLabel}=Gtk2::Label->new('Addresses'); | ||
| 179 | $self->{gui}{addressLabel}->show; | ||
| 180 | $self->{gui}{addressSW}->add_with_viewport($self->{gui}{addressVBox}); | ||
| 181 | $self->{gui}{addressSW}->set_policy('never', 'always'); | ||
| 182 | $self->{gui}{notebook}->append_page($self->{gui}{addressSW}, $self->{gui}{addressLabel}); | ||
| 183 | |||
| 184 | #inits Gtk2::Ex::Email::AttachmentVBox | ||
| 185 | $self->{attachmentVB}=Gtk2::Ex::Email::AttachmentVBox->new; | ||
| 186 | $self->{gui}{attachmentVBox}=$self->{attachmentVB}->vbox(\@files); | ||
| 187 | |||
| 188 | #puts the attachment tab in place | ||
| 189 | $self->{gui}{attachmentLabel}=Gtk2::Label->new('Attachments'); | ||
| 190 | $self->{gui}{attachmentLabel}->show; | ||
| 191 | $self->{gui}{notebook}->append_page($self->{gui}{attachmentVBox}, $self->{gui}{attachmentLabel}); | ||
| 192 | |||
| 193 | return $self->{gui}{notebook}; | ||
| 194 | } | ||
| 195 | |||
| 196 | =head1 AUTHOR | ||
| 197 | |||
| 198 | Zane C. Bowers, C<< <vvelox at vvelox.net> >> | ||
| 199 | |||
| 200 | =head1 BUGS | ||
| 201 | |||
| 202 | Please report any bugs or feature requests to C<bug-gtk2-ex-email-aanotebook at rt.cpan.org>, or through | ||
| 203 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Gtk2-Ex-Email-AAnotebook>. I will be notified, and then you'll | ||
| 204 | automatically be notified of progress on your bug as I make changes. | ||
| 205 | |||
| 206 | |||
| 207 | |||
| 208 | |||
| 209 | =head1 SUPPORT | ||
| 210 | |||
| 211 | You can find documentation for this module with the perldoc command. | ||
| 212 | |||
| 213 | perldoc Gtk2::Ex::Email::AAnotebook | ||
| 214 | |||
| 215 | |||
| 216 | You can also look for information at: | ||
| 217 | |||
| 218 | =over 4 | ||
| 219 | |||
| 220 | =item * RT: CPAN's request tracker | ||
| 221 | |||
| 222 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Gtk2-Ex-Email-AAnotebook> | ||
| 223 | |||
| 224 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 225 | |||
| 226 | L<http://annocpan.org/dist/Gtk2-Ex-Email-AAnotebook> | ||
| 227 | |||
| 228 | =item * CPAN Ratings | ||
| 229 | |||
| 230 | L<http://cpanratings.perl.org/d/Gtk2-Ex-Email-AAnotebook> | ||
| 231 | |||
| 232 | =item * Search CPAN | ||
| 233 | |||
| 234 | L<http://search.cpan.org/dist/Gtk2-Ex-Email-AAnotebook/> | ||
| 235 | |||
| 236 | =back | ||
| 237 | |||
| 238 | |||
| 239 | =head1 ACKNOWLEDGEMENTS | ||
| 240 | |||
| 241 | |||
| 242 | =head1 COPYRIGHT & LICENSE | ||
| 243 | |||
| 244 | Copyright 2009 Zane C. Bowers, all rights reserved. | ||
| 245 | |||
| 246 | This program is free software; you can redistribute it and/or modify it | ||
| 247 | under the same terms as Perl itself. | ||
| 248 | |||
| 249 | |||
| 250 | =cut | ||
| 251 | |||
| 252 | 1; # End of Gtk2::Ex::Email::AAnotebook | ||