summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@fcb26f47-9200-0410-b104-b98ab5b095f3>2005-11-24 09:53:37 +0000
committerdakkar <dakkar@fcb26f47-9200-0410-b104-b98ab5b095f3>2005-11-24 09:53:37 +0000
commit6d23513890a1201774090440094a11ede0696045 (patch)
tree36dc4603a6f29e09a0fa670390a7694cc1594365
parent r796@narval2: dakkar | 2005-11-19 16:29:11 +0100 (diff)
downloadGtkPerlFileManager-6d23513890a1201774090440094a11ede0696045.tar.gz
GtkPerlFileManager-6d23513890a1201774090440094a11ede0696045.tar.bz2
GtkPerlFileManager-6d23513890a1201774090440094a11ede0696045.zip
r797@narval2: dakkar | 2005-11-19 16:51:31 +0100
prime callback e inizializzazione delle liste git-svn-id: svn://luxion/repos/GtkPerlFileManager/trunk@42 fcb26f47-9200-0410-b104-b98ab5b095f3
-rw-r--r--Build.PL1
-rw-r--r--lib/LDFM/MainController.pm53
2 files changed, 54 insertions, 0 deletions
diff --git a/Build.PL b/Build.PL
index 03675a6..5413932 100644
--- a/Build.PL
+++ b/Build.PL
@@ -12,6 +12,7 @@ my $builder = Module::Build->new(
'perl' => '5.8.3',
'Gtk2' => '1.1.0',
'Gtk2::GladeXML::Simple' => 0,
+ 'Gtk2::Ex::Simple::List' => 0,
'Readonly' => 0,
},
build_requires => {
diff --git a/lib/LDFM/MainController.pm b/lib/LDFM/MainController.pm
index 780a282..9c81ecd 100644
--- a/lib/LDFM/MainController.pm
+++ b/lib/LDFM/MainController.pm
@@ -3,7 +3,9 @@ use utf8;
use warnings;
use strict;
use base 'Gtk2::GladeXML::Simple';
+use Gtk2::Ex::Simple::List;
use Readonly;
+use Path::Class;
our $VERSION = '0.01';
@@ -12,7 +14,58 @@ sub new {
my $self=$class->SUPER::new($params{glade_file});
+ # cambio le liste con qualcosa di piĆ¹ comodo
+ $self->simplify_list('left');
+ $self->simplify_list('right');
+
+ # imposto i path
+ $self->update_list_with_path('left',$ENV{HOME});
+ $self->update_list_with_path('right','/');
+
return $self;
}
+sub simplify_list {
+ my ($self,$side)=@_;
+
+ my $list_name="${side}_list";
+
+ $self->{$list_name}=Gtk2::Ex::Simple::List->new_from_treeview(
+ $self->{$list_name},
+ 'File' => 'text',
+ 'Type' => 'text',
+ 'Size' => 'int',
+ );
+
+ $self->{"${side}_data"}=$self->{$list_name}->{data};
+
+ return;
+}
+
+sub update_list_with_path {
+ my ($self,$side,$path)=@_;
+
+ my $curpath=dir($path)->absolute;
+ $self->{"cur_${side}_path"}=$curpath;
+ $self->{"${side}_path"}->set_text($curpath->stringify);
+
+ my @dir_list=();
+ for my $item ($curpath->children(all=>1)) {
+ my @row=($item->relative($curpath)->stringify);
+ if ($item->isa('Class::Path::Dir')) {
+ push @row,'DIR',0;
+ }
+ else {
+ push @row,'FILE',-s $item;
+ }
+ push @dir_list,[@row];
+ }
+
+ @{$self->{"${side}_data"}}=@dir_list;
+}
+
+sub quit {
+ Gtk2->main_quit;
+}
+
1;