Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
i made a code that creates thumbnails of pictures using the iconview widget. problem is, when opening many (20++) pictures (2000++px x 2000++px) it turns out to be slow. is there a way to open a folder even if the pictures are still loading? would progressive loading help?
my @selection_list = (); my $liststore = Gtk2::ListStore->new("Glib::String","Glib::String","Gt +k2::Gdk::Pixbuf","Glib::Int","Glib::Int","Gtk2::Gdk::Pixbuf"); my $iconview = Gtk2::IconView->new_with_model($liststore); sub browse_files { # SEARCH FOR FOLDERS # $iconview->set('visible',0); my $path = $_[0]; my $new_path = $path; print $path , "\n"; use Encode; opendir my $dh, $path or warn "Error: $!"; my @files = grep !/^\.\.?$/, readdir $dh; closedir $dh; @files = map { decode( 'utf8', "$path/".$_ ) } sort @files; my @files_t=(); foreach my $file (@files) { $file =~ s|//|/|g; (my $text = $file ) =~ s|^.*/||g; if (-d $file) { my $folder_pixbuf_t = Gtk2::Gdk::Pixbuf->new_from_file("ic +ons/folder_green.png"); my $rowiter = $liststore->append; $liststore->set_value($rowiter,0,substr($file,length($path +)+1,length($file) - length($path))); $liststore->set_value($rowiter,1,$file); $liststore->set_value($rowiter,2,$folder_pixbuf_t); $liststore->set_value($rowiter,3,1); $liststore->set_value($rowiter,4,0); push @files_t, $file; } } foreach my $file (@files) { $file =~ s|//|/|g; (my $text = $file ) =~ s|^.*/||g; if( uc($file) =~ /.*\.(PNG|JPG|GIF|JPEG)$/ ){ my $isselected = 0; foreach my $x_t (@selection_list){ if($file eq $x_t){ $isselected=1; } } my $folder_pixbuf_t = Gtk2::Gdk::Pixbuf->new_from_file_at_ +scale($file,100,100,1); my $backup_pixbuf_t = $folder_pixbuf_t->copy; my $rowiter = $liststore->append; if($isselected==1){ my $bookmark_t = Gtk2::Gdk::Pixbuf->new_from_file("ico +ns/bookmarks2.png"); $bookmark_t->composite($folder_pixbuf_t,0,0,22,22,0,0, +1,1,'nearest',255); } $liststore->set_value($rowiter,0,substr($file,length($path +)+1,length($file) - length($path))); $liststore->set_value($rowiter,1,$file); $liststore->set_value($rowiter,2,$folder_pixbuf_t); $liststore->set_value($rowiter,3,0); if($isselected==1){ $liststore->set_value($rowiter,4,1); }else{ $liststore->set_value($rowiter,4,0); } $liststore->set_value($rowiter,5,$backup_pixbuf_t); push @files_t, $file; } } $iconview->set('visible',1); return @files_t; }

In reply to how to speed up image file loading with gtk2 iconview? by renegadex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-25 00:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found