From 6feffed9164b0ae353a6a79e1750ea5cfcde7e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Moreno?= Date: Fri, 25 Aug 2017 09:50:36 +0200 Subject: [PATCH] Image preview in a button --- src/app.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app.rs b/src/app.rs index f1dcccaf..ac4fed54 100644 --- a/src/app.rs +++ b/src/app.rs @@ -364,14 +364,20 @@ impl AppOp { fn build_room_msg_image(&self, msg: &backend::Message) -> gtk::Box { let bx = gtk::Box::new(gtk::Orientation::Horizontal, 0); let image = gtk::Image::new(); - println!("image url: {}", msg.thumb); - if let Ok(pixbuf) = Pixbuf::new_from_file_at_size(&msg.thumb, 400, 400) { + + if let Ok(pixbuf) = Pixbuf::new_from_file_at_size(&msg.thumb, 200, 200) { image.set_from_pixbuf(&pixbuf); } - // TODO: add buttons to view full size and download + let viewbtn = gtk::Button::new(); + let url = msg.url.clone(); + viewbtn.connect_clicked(move |_| { + println!("Download and show a dialog: {}", url); + }); - bx.add(&image); + viewbtn.set_image(&image); + + bx.add(&viewbtn); bx }