Commit d3e88adf authored by Eisha Chen-yen-su's avatar Eisha Chen-yen-su

MediaViewer: Display image in the media viewer

This adds the ability to display the selected image in the media
viewer.

See https://gitlab.gnome.org/World/fractal/issues/13
parent 4be5c85f
......@@ -8,11 +8,19 @@ use app::App;
impl App {
pub fn connect_media_viewer_headerbar(&self) {
let ui = self.ui.clone();
let op = self.op.clone();
let btn = self.ui.builder
let btn = ui.builder
.get_object::<gtk::Button>("media_viewer_back_button")
.expect("Cant find media_viewer_back_button in ui file.");
btn.connect_clicked(move |_| {
let media_viewport = ui.builder
.get_object::<gtk::Viewport>("media_viewport")
.expect("Cant find media_viewport in ui file.");
if let Some(child) = media_viewport.get_child() {
media_viewport.remove(&child);
}
op.lock().unwrap().set_state(AppState::Chat);
});
}
......
extern crate gtk;
use self::gtk::prelude::*;
use appop::AppOp;
use appop::AppState;
use widgets::image;
use types::Room;
impl AppOp {
pub fn display_media_viewer(&mut self, url: String, room_id: String) {
self.set_state(AppState::MediaViewer);
let media_viewport = self.ui.builder
.get_object::<gtk::Viewport>("media_viewport")
.expect("Cant find media_viewport in ui file.");
let image = image::Image::new(&self.backend,
&url,
None,
image::Thumb(false),
image::Circle(false),
image::Fixed(true));
media_viewport.add(&image.widget);
media_viewport.show_all();
}
}
......@@ -33,6 +33,7 @@ mod account;
mod notifications;
mod state;
mod room;
mod media_viewer;
mod message;
mod directory;
mod notify;
......
......@@ -21,7 +21,6 @@ use util::markup_text;
use std::path::Path;
use appop::AppOp;
use appop::AppState;
use globals;
use widgets;
use widgets::AvatarExt;
......@@ -278,9 +277,11 @@ impl<'a> MessageBox<'a> {
Some((600, 400)), widgets::image::Thumb(false),
widgets::image::Circle(false), widgets::image::Fixed(false));
let room_id = self.room.id.clone();
image.widget.connect_button_press_event(move |_, _| {
let newst = AppState::MediaViewer;
APPOP!(set_state, (newst));
let image_url = url.clone();
let rid = room_id.clone();
APPOP!(display_media_viewer, (image_url, rid));
Inhibit(true)
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment