blib/lib/Gtk2/Ex/FileLocator.pm untested

filter: Statementstmt 0.0% 0 / 70 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 101 CC 6 SCAR 26.4
CC
6
Cov
0%
on_child_selection_changed
42.0
INIT_INSTANCE
2.0
get_droppocket
2.0
CRAP 14.0
1 package Gtk2::Ex::FileLocator;
2 use strict;
3 use warnings;
4  
5 use Gtk2;
6 use Glib qw(TRUE FALSE);
7  
8 use Gtk2::Ex::FileLocator::DropPocket;
9 use Gtk2::Ex::FileLocator::PathBar;
10 use Gtk2::Ex::FileLocator::PathnameField;
11 use Gtk2::Ex::FileLocator::RecycleButton;
12  
13 use Glib::Object::Subclass Gtk2::Ex::FileLocator::FileChooser::,
14 properties => [
15 Glib::ParamSpec->boolean(
16 'stdout', 'stdout', 'Output filename to stdout',
17 FALSE, [qw/readable writable/]
18 ),
19 ],
20 ;
21  
22 sub INIT_INSTANCE {
23 my ($this) = @_;
24  
25 $this->{filename} = "";
26  
27 my $hbox = new Gtk2::HBox;
28 $hbox->set_spacing(2);
29  
30 $this->{dropPocket} = new Gtk2::Ex::FileLocator::DropPocket;
31 $hbox->pack_start( $this->{dropPocket}, FALSE, FALSE, 0 );
32  
33 my $vbox = new Gtk2::VBox;
34 $vbox->set_spacing(0);
35  
36 $this->{pathBar} = new Gtk2::Ex::FileLocator::PathBar;
37 $vbox->pack_start( $this->{pathBar}, TRUE, TRUE, 0 );
38  
39 $this->{pathnameField} = new Gtk2::Ex::FileLocator::PathnameField;
40 $vbox->pack_start( $this->{pathnameField}, FALSE, FALSE, 0 );
41  
42 $hbox->pack_start( $vbox, TRUE, TRUE, 0 );
43  
44 $this->{recycleButton} = new Gtk2::Ex::FileLocator::RecycleButton;
45 $hbox->pack_start( $this->{recycleButton}, FALSE, FALSE, 0 );
46  
47 $this->pack_start( $hbox, TRUE, TRUE, 0 );
48  
49 $this->{dropPocket}->signal_connect( 'selection-changed' => \&on_child_selection_changed, $this );
50 $this->{pathBar}->signal_connect( 'selection-changed' => \&on_child_selection_changed, $this );
51 $this->{pathnameField}->signal_connect( 'selection-changedd' => \&on_child_selection_changed, $this );
52 $this->{recycleButton}->signal_connect( 'selection-changed' => \&on_child_selection_changed, $this );
53  
54 $this->{pathnameField}->signal_connect( 'scroll-offset-changed' => sub { $this->{pathBar}->set_scroll_offset( $_[1] ) } );
55 $this->{pathnameField}->signal_connect_after( 'size-request' => sub { $this->{pathBar}->configure_buttons } );
56 }
57  
58 sub on_child_selection_changed {
59 my ( $widget, $this) = @_;
60  
61 my $uri = $widget->get_uri;
62 return unless $uri;
63 #return if ( $this->get_uri || "" ) eq $uri;
64  
65 $this->Debug($this, $widget, $uri);
66  
67 $this->{dropPocket}->set_uri($uri) unless $widget == $this->{dropPocket};
68 $this->{pathBar}->set_uri($uri) unless $widget == $this->{pathBar};
69 $this->{pathnameField}->set_uri($uri) unless $widget == $this->{pathnameField};
70 $this->{recycleButton}->set_uri($uri) unless $widget == $this->{recycleButton};
71  
72 #printf "%s\n", $filename if $this->get('stdout');
73 }
74  
75 sub get_droppocket {
76 my ($this) = @_;
77 return $this->{dropPocket};
78 }
79  
80 sub get_pathbar {
81 my ($this) = @_;
82 return $this->{pathBar};
83 }
84  
85 sub get_pathnamefield {
86 my ($this) = @_;
87 return $this->{pathnameField};
88 }
89  
90 sub get_recyclebutton {
91 my ($this) = @_;
92 return $this->{recycleButton};
93 }
94  
95 1;
96 __END__