examples icon indicating copy to clipboard operation
examples copied to clipboard

gtkiconview from model example

Open jpercyasnet opened this issue 5 years ago • 2 comments

no luck generating iconview from model. Problem with pixbuf definition. Would be deeply appreciated if some could provide an example.

jpercyasnet avatar Oct 19 '18 16:10 jpercyasnet

after experimenting got it:

let new_model = ListStore::new(&[Pixbuf::static_type(), String::static_type()]); let mut newtoi = to_int1; if newtoi as usize > listnamelen { newtoi = listnamelen as i32 ; } for indexi in (from_int1 - 1)..newtoi { let file_pathx = &listfull[indexi as usize]; let pixbufx = Pixbuf::new_from_file(&file_pathx).unwrap(); let mut pixheight = pixbufx.get_height(); let mut pixwidth = pixbufx.get_width(); if pixheight > pixwidth { pixwidth = icon_int1 * pixwidth / pixheight; pixheight = icon_int1; } else { pixheight = icon_int1 * pixheight / pixwidth; pixwidth = icon_int1; } let pixbuficon = pixbufx.scale_simple(pixwidth, pixheight, gdk_pixbuf::InterpType::Bilinear); new_model.insert_with_values(None, &[VALUE_COL as u32, IS_DIR_COL as u32], &[&pixbuficon, &listname[indexi as usize]]); let progressfr: f64 = (indexi - from_int1 + 2) as f64 / (newtoi - from_int1 +1) as f64; progress_progressbar.set_fraction(progressfr); } // let new_model = // create_and_fill_modelicon(icon_int1, from_int1, to_int1, listfull, listname) // .expect("create_and_fill_model failed"); icon_view.set_model(Some(&new_model));

jpercyasnet avatar Dec 15 '18 04:12 jpercyasnet

was done here, will be merged soon: https://github.com/gtk-rs/examples/pull/281/files

artonio avatar Jan 04 '20 14:01 artonio