From 6d23513890a1201774090440094a11ede0696045 Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 24 Nov 2005 09:53:37 +0000 Subject: 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 --- Build.PL | 1 + lib/LDFM/MainController.pm | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) 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; -- cgit v1.2.3