Commit 5e009af2 authored by Eisha Chen-yen-su's avatar Eisha Chen-yen-su

MediaViewer: Move navigation buttons to overlays

See https://gitlab.gnome.org/World/fractal/issues/13
parent 5d341b33
Pipeline #15730 passed with stages
in 29 minutes and 2 seconds
......@@ -5,69 +5,130 @@
<object class="GtkBox" id="media_viewer_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton" id="previous_media_button">
<object class="GtkOverlay">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage">
<object class="GtkScrolledWindow" id="media_scroll">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-previous-symbolic</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport" id="media_viewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<packing>
<property name="index">-1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">18</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="media_scroll">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport" id="media_viewport">
<child type="overlay">
<object class="GtkOverlay" id="previous_media_overlay">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">center</property>
<child>
<placeholder/>
<object class="GtkRevealer" id="previous_media_revealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_type">crossfade</property>
<property name="reveal_child">True</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">18</property>
<child>
<object class="GtkButton" id="previous_media_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="relief">half</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-previous-symbolic</property>
</object>
</child>
<style>
<class name="osd"/>
</style>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="index">-1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="next_media_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<child>
<object class="GtkImage">
<child type="overlay">
<object class="GtkOverlay" id="next_media_overlay">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-next-symbolic</property>
<property name="halign">end</property>
<property name="valign">center</property>
<child>
<object class="GtkRevealer" id="next_media_revealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_type">crossfade</property>
<property name="reveal_child">True</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">18</property>
<child>
<object class="GtkButton" id="next_media_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="relief">half</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-next-symbolic</property>
</object>
</child>
<style>
<class name="osd"/>
</style>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="index">-1</property>
</packing>
</child>
</object>
<packing>
<property name="index">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">18</property>
<property name="position">2</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
......
......@@ -2,6 +2,9 @@ extern crate gtk;
use self::gtk::prelude::*;
use glib;
use std::sync::{Arc, Mutex};
use app::App;
impl App {
......@@ -48,6 +51,83 @@ impl App {
}
pub fn connect_media_viewer_box(&self) {
let ui = self.ui.clone();
let hovered: Arc<Mutex<bool>> = Arc::new(Mutex::new(false));
let previous_media_button = ui.builder
.get_object::<gtk::Button>("previous_media_button")
.expect("Cant find previous_media_button in ui file.");
previous_media_button.connect_enter_notify_event(clone!(hovered => move |_, _| {
*(hovered.lock().unwrap()) = true;
Inhibit(false)
}));
previous_media_button.connect_leave_notify_event(clone!(hovered => move |_, _| {
*(hovered.lock().unwrap()) = false;
Inhibit(false)
}));
let next_media_button = ui.builder
.get_object::<gtk::Button>("next_media_button")
.expect("Cant find next_media_button in ui file.");
next_media_button.connect_enter_notify_event(clone!(hovered => move |_, _| {
*(hovered.lock().unwrap()) = true;
Inhibit(false)
}));
next_media_button.connect_leave_notify_event(clone!(hovered => move |_, _| {
*(hovered.lock().unwrap()) = false;
Inhibit(false)
}));
let media_viewer_box = ui.builder
.get_object::<gtk::Box>("media_viewer_box")
.expect("Cant find media_viewer_box in ui file.");
let source_id: Arc<Mutex<Option<glib::source::SourceId>>> = Arc::new(Mutex::new(None));
media_viewer_box.connect_motion_notify_event(move |_, _| {
{
let mut id = source_id.lock().unwrap();
if let Some(sid) = id.take() {
glib::source::source_remove(sid);
}
}
let previous_media_revealer = ui.builder
.get_object::<gtk::Revealer>("previous_media_revealer")
.expect("Cant find previous_media_revealer in ui file.");
previous_media_revealer.set_reveal_child(true);
let next_media_revealer = ui.builder
.get_object::<gtk::Revealer>("next_media_revealer")
.expect("Cant find next_media_revealer in ui file.");
next_media_revealer.set_reveal_child(true);
let sid = gtk::timeout_add(1000, clone!(ui, hovered, source_id => move || {
if !*hovered.lock().unwrap() {
let previous_media_revealer = ui.builder
.get_object::<gtk::Revealer>("previous_media_revealer")
.expect("Cant find previous_media_revealer in ui file.");
previous_media_revealer.set_reveal_child(false);
let next_media_revealer = ui.builder
.get_object::<gtk::Revealer>("next_media_revealer")
.expect("Cant find next_media_revealer in ui file.");
next_media_revealer.set_reveal_child(false);
}
*(source_id.lock().unwrap()) = None;
gtk::Continue(false)
}));
*(source_id.lock().unwrap()) = Some(sid);
Inhibit(false)
});
let op = self.op.clone();
let previous_media_button = self.ui.builder
.get_object::<gtk::Button>("previous_media_button")
......
......@@ -52,6 +52,16 @@ impl AppOp {
let rooms = self.rooms.clone();
let r = rooms.get(&room_id).unwrap();
let previous_media_revealer = self.ui.builder
.get_object::<gtk::Revealer>("previous_media_revealer")
.expect("Cant find previous_media_revealer in ui file.");
previous_media_revealer.set_reveal_child(false);
let next_media_revealer = self.ui.builder
.get_object::<gtk::Revealer>("next_media_revealer")
.expect("Cant find next_media_revealer in ui file.");
next_media_revealer.set_reveal_child(false);
self.set_state(AppState::MediaViewer);
set_header_title(&self.ui, &name);
......
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