Skip to content

Commit

Permalink
Fixed image loading when not thumb
Browse files Browse the repository at this point in the history
  • Loading branch information
danigm committed Aug 30, 2017
1 parent 06f63a8 commit d6fed8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,11 @@ pub fn parse_room_message(baseu: &Url, roomid: String, msg: &JsonValue) -> Messa
match mtype {
"m.image" => {
url = String::from(c["url"].as_str().unwrap_or(""));
let t = c["info"]["thumbnail_url"].as_str().unwrap_or("");
thumb = media!(baseu, t).unwrap_or(String::from(""));
let mut t = String::from(c["info"]["thumbnail_url"].as_str().unwrap_or(""));
if t.is_empty() && !url.is_empty() {
t = url.clone();
}
thumb = media!(baseu, &t).unwrap_or(String::from(""));
},
_ => {},
};
Expand Down
4 changes: 3 additions & 1 deletion src/widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ impl<'a> MessageBox<'a> {
let bx = gtk::Box::new(gtk::Orientation::Horizontal, 0);
let image = gtk::Image::new();

if let Ok(pixbuf) = Pixbuf::new_from_file_at_size(&msg.thumb, 200, 200) {
if let Ok(pixbuf) = Pixbuf::new_from_file_at_scale(&msg.thumb, 200, 200, true) {
image.set_from_pixbuf(&pixbuf);
} else {
image.set_from_file(&msg.thumb);
}

let viewbtn = gtk::Button::new();
Expand Down

0 comments on commit d6fed8c

Please sign in to comment.