Commit 3ea23f89 authored by Eisha Chen-yen-su's avatar Eisha Chen-yen-su

UI: Implement the media viewer design

See https://gitlab.gnome.org/World/fractal/issues/13
parent f09dc5a5
......@@ -24,6 +24,7 @@
<file preprocess="xml-stripblanks">ui/account_settings.ui</file>
<file preprocess="xml-stripblanks">ui/password_dialog.ui</file>
<file preprocess="xml-stripblanks">ui/markdown_popover.ui</file>
<file preprocess="xml-stripblanks">ui/media_viewer.ui</file>
<file preprocess="xml-stripblanks">ui/server_chooser_menu.ui</file>
<file preprocess="xml-stripblanks">ui/stickers_popover.ui</file>
<file preprocess="xml-stripblanks">ui/sticker_group.ui</file>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkBox" id="media_viewer_box">
<property name="visible">True</property>
<property name="can_focus">False</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>
<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>
</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">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</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">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-next-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">18</property>
<property name="position">2</property>
</packing>
</child>
</object>
<object class="GtkEntryBuffer" id="zoom_level">
<property name="max_length">4</property>
</object>
<object class="GtkBox" id="media_viewer_headerbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Media viewer</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkButton" id="media_viewer_back_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</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>
<child internal-child="accessible">
<object class="AtkObject" id="media_viewer_back_button-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Back</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton" id="zoom_out_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">zoom-out-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="zoom_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="buffer">zoom_level</property>
<property name="width_chars">5</property>
<property name="max_width_chars">4</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
<property name="input_purpose">digits</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="zoom_in_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">zoom-in-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<style>
<class name="linked"/>
</style>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="media_viewer_menu_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">view-more-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="full_screen_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">view-fullscreen-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</interface>
extern crate gtk;
use self::gtk::prelude::*;
use appop::AppState;
use app::App;
impl App {
pub fn connect_media_viewer_headerbar(&self) {
let op = self.op.clone();
let btn = self.ui.builder
.get_object::<gtk::Button>("media_viewer_back_button")
.expect("Cant find media_viewer_back_button in ui file.");
btn.connect_clicked(move |_| {
op.lock().unwrap().set_state(AppState::Chat);
});
}
pub fn connect_media_viewer_box(&self) {
}
}
......@@ -14,6 +14,7 @@ mod leave_room;
mod load_more;
mod login;
mod markdown;
mod media_viewer;
mod more_members;
mod new_room;
mod room_config;
......@@ -75,6 +76,8 @@ impl App {
self.connect_send();
self.connect_attach();
self.connect_markdown();
self.connect_media_viewer_headerbar();
self.connect_media_viewer_box();
//self.connect_stickers();
self.connect_autocomplete();
self.connect_spellcheck();
......
......@@ -99,13 +99,14 @@ impl App {
.get_object::<gtk::MenuButton>("room_menu_button")
.expect("Can't find back_button in ui file.").set_valign(gtk::Align::Fill);
/* Add account settings view to the main stack */
let stack = ui.builder
.get_object::<gtk::Stack>("main_content_stack")
.expect("Can't find main_content_stack in ui file.");
let stack_header = ui.builder
.get_object::<gtk::Stack>("headerbar_stack")
.expect("Can't find headerbar_stack in ui file.");
/* Add account settings view to the main stack */
let child = ui.builder
.get_object::<gtk::Box>("account_settings_box")
.expect("Can't find account_settings_box in ui file.");
......@@ -115,6 +116,17 @@ impl App {
stack.add_named(&child, "account-settings");
stack_header.add_named(&child_header, "account-settings");
/* Add media viewer to the main stack */
let child = ui.builder
.get_object::<gtk::Box>("media_viewer_box")
.expect("Can't find media_viewer_box in ui file.");
let child_header = ui.builder
.get_object::<gtk::Box>("media_viewer_headerbar")
.expect("Can't find media_viewer_headerbar in ui file.");
stack.add_named(&child, "media-viewer");
stack_header.add_named(&child_header, "media-viewer");
let op = Arc::new(Mutex::new(
AppOp::new(gtk_app.clone(), ui.clone(), apptx, itx)
));
......
......@@ -13,6 +13,7 @@ pub enum AppState {
Directory,
Loading,
AccountSettings,
MediaViewer,
}
......@@ -29,6 +30,7 @@ impl AppOp {
AppState::Directory => "directory",
AppState::Loading => "loading",
AppState::AccountSettings => "account-settings",
AppState::MediaViewer => "media-viewer",
};
self.ui.builder
......@@ -42,6 +44,7 @@ impl AppOp {
AppState::Directory => "back",
AppState::Loading => "login",
AppState::AccountSettings => "account-settings",
AppState::MediaViewer => "media-viewer",
_ => "normal",
};
......
......@@ -23,12 +23,14 @@ use fractal_api::error;
mod globals;
#[macro_use]
mod util;
mod widgets;
mod cache;
mod uibuilder;
mod static_resources;
mod passwd;
#[macro_use]
mod app;
mod widgets;
mod appop;
use app::App;
......
......@@ -56,6 +56,8 @@ impl UI {
.expect("Can't load ui file: password_dialog.ui");
builder.add_from_resource("/org/gnome/Fractal/ui/account_settings.ui")
.expect("Can't load ui file: account_settings.ui");
builder.add_from_resource("/org/gnome/Fractal/ui/media_viewer.ui")
.expect("Can't load ui file: media_viewer.ui");
// Depends on room config
builder.add_from_resource("/org/gnome/Fractal/ui/filechooser.ui")
......
extern crate gtk;
extern crate chrono;
extern crate pango;
extern crate glib;
use app::App;
use self::gtk::prelude::*;
......@@ -18,6 +21,7 @@ use util::markup_text;
use std::path::Path;
use appop::AppOp;
use appop::AppState;
use globals;
use widgets;
use widgets::AvatarExt;
......@@ -275,7 +279,9 @@ impl<'a> MessageBox<'a> {
widgets::image::Circle(false), widgets::image::Fixed(false));
image.widget.connect_button_press_event(move |_, _| {
backend.send(BKCommand::GetMedia(url.clone())).unwrap();
let newst = AppState::MediaViewer;
APPOP!(set_state, (newst));
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