Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

gtkiconview from model example #198

Open
jpercyasnet opened this issue Oct 19, 2018 · 2 comments
Open

gtkiconview from model example #198

jpercyasnet opened this issue Oct 19, 2018 · 2 comments

Comments

@jpercyasnet
Copy link

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

@jpercyasnet
Copy link
Author

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));

@artonio
Copy link
Contributor

artonio commented Jan 4, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants