Commit b51e78f3 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

make the video configurable

you should be able to configure the video path at build time by passing --video_path=absolute_path which will be played instead of displaying the LOGO
parent a30ffee3
......@@ -4,6 +4,9 @@ version = "0.0.1"
authors = ["Bilal Elmoussaoui <bil.elmoussaoui@gmail.com>"]
edition = "2018"
[features]
video = ["gst_player", "gst"]
[dependencies]
glib = { version = "0.10", features = ["v2_64"] }
gdk = "0.13"
......@@ -18,7 +21,9 @@ anyhow = "1.0"
[dependencies.gst_player]
version = "0.16"
package = "gstreamer-player"
optional = true
[dependencies.gst]
version = "0.16"
package = "gstreamer"
optional = true
......@@ -4,17 +4,18 @@ export MESON_BUILD_ROOT="$1"
export MESON_SOURCE_ROOT="$2"
export CARGO_TARGET_DIR="$MESON_BUILD_ROOT"/target
export CARGO_HOME="$CARGO_TARGET_DIR"/cargo-home
FEATURES="$6"
if [[ $4 = "Devel" ]]
then
echo "DEBUG MODE"
cargo build --manifest-path \
"$MESON_SOURCE_ROOT"/Cargo.toml --verbose && \
"$MESON_SOURCE_ROOT"/Cargo.toml $FEATURES && \
cp "$CARGO_TARGET_DIR"/debug/$5 $3
else
echo "RELEASE MODE"
cargo build --manifest-path \
"$MESON_SOURCE_ROOT"/Cargo.toml --release && \
"$MESON_SOURCE_ROOT"/Cargo.toml $FEATURES --release && \
cp "$CARGO_TARGET_DIR"/release/$5 $3
fi
......@@ -15,10 +15,7 @@
"--socket=fallback-x11",
"--socket=wayland",
"--device=dri",
"--filesystem=xdg-run/dconf",
"--filesystem=~/.config/dconf:ro",
"--talk-name=ca.desrt.dconf",
"--env=DCONF_USER_CONFIG_DIR=.config/dconf"
"--filesystem=home"
],
"build-options" : {
"append-path" : "/usr/lib/sdk/rust-stable/bin",
......
......@@ -2,7 +2,6 @@
<gresources>
<gresource prefix="/org/gnome/Tour/">
<file compressed="true" alias="style.css">resources/style.css</file>
<file alias="welcome.mp4">resources/assets/welcome.mp4</file>
<file compressed="true" alias="activities.svg">resources/assets/activities.svg</file>
<file compressed="true" alias="calendar.svg">resources/assets/calendar.svg</file>
<file compressed="true" alias="search.svg">resources/assets/search.svg</file>
......
......@@ -13,6 +13,11 @@ dependency('gio-2.0', version: '>= 2.56')
dependency('gdk-pixbuf-2.0')
dependency('gtk+-3.0', version: '>= 3.16')
if get_option('video_path') != ''
dependency('gstreamer-1.0', version: '>= 1.12')
dependency('gstreamer-video-1.0', version: '>= 1.12')
dependency('gstreamer-player-1.0', version: '>= 1.12')
endif
glib_compile_resources = find_program('glib-compile-resources', required: true)
desktop_file_validate = find_program('desktop-file-validate', required: false)
......
......@@ -9,3 +9,9 @@ option (
description: 'The build profile for GNOME Tour. One of "default" or "development".'
)
option(
'video_path',
type : 'string',
value: '',
description : 'Sets the absolute path of a welcome video'
)
......@@ -5,3 +5,5 @@ pub static NAME_SUFFIX: &str = @NAME_SUFFIX@;
pub static VERSION: &str = @VERSION@;
pub static GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@;
pub static LOCALEDIR: &str = @LOCALEDIR@;
#[cfg(feature="video")]
pub static VIDEO_PATH: &str = @VIDEO_PATH@;
......@@ -20,7 +20,9 @@ fn main() {
glib::set_prgname(Some("Tour"));
gtk::init().expect("Unable to start GTK3");
#[cfg(feature = "video")]
gst::init().expect("Unable to start gst");
static_resources::init().expect("Failed to initialize the resource file.");
let app = Application::new();
......
......@@ -6,6 +6,7 @@ global_conf.set_quoted('NAME_SUFFIX', name_suffix)
global_conf.set_quoted('VERSION', version + version_suffix)
global_conf.set_quoted('GETTEXT_PACKAGE', gettext_package)
global_conf.set_quoted('LOCALEDIR', localedir)
global_conf.set_quoted('VIDEO_PATH', get_option('video_path'))
config = configure_file(
input: 'config.rs.in',
output: 'config.rs',
......@@ -39,7 +40,6 @@ sources = files(
'widgets/pages/image.rs',
'widgets/pages/mod.rs',
'widgets/pages/welcome.rs',
'widgets/pages/welcome_video.rs',
'widgets/mod.rs',
'widgets/paginator.rs',
'widgets/window.rs',
......@@ -50,6 +50,10 @@ sources = files(
'utils.rs',
)
features = ''
if get_option('video_path') != ''
features = '--features video'
endif
custom_target(
'cargo-build',
build_by_default: true,
......@@ -66,6 +70,7 @@ custom_target(
'@OUTPUT@',
profile,
meson.project_name(),
features
]
)
mod image;
mod welcome;
mod welcome_video;
pub use image::ImagePageWidget;
pub use welcome::WelcomePageWidget;
pub use welcome_video::WelcomeVideoPageWidget;
#[cfg(feature = "video")]
use crate::config;
use gettextrs::gettext;
#[cfg(feature = "video")]
use gio::FileExt;
use gtk::prelude::*;
pub struct WelcomePageWidget {
......@@ -14,6 +18,52 @@ impl WelcomePageWidget {
welcome_page
}
#[cfg(not(feature = "video"))]
fn get_header_widget(&self) -> gtk::Widget {
let icon = glib::get_os_info("LOGO").unwrap_or_else(|| "start-here-symbolic".into());
let logo = gtk::Image::from_icon_name(Some(&icon), gtk::IconSize::Dialog);
logo.set_pixel_size(196);
logo.show();
logo.upcast::<gtk::Widget>()
}
#[cfg(feature = "video")]
fn get_header_widget(&self) -> gtk::Widget {
let dispatcher = gst_player::PlayerGMainContextSignalDispatcher::new(None);
let sink = gst::ElementFactory::make("gtksink", None).expect("Missing dependency: element gtksink is needed (usually, in gstreamer-plugins-good or in gst-plugin-gtk).");
let renderer = gst_player::PlayerVideoOverlayVideoRenderer::with_sink(&sink).upcast();
let player = gst_player::Player::new(Some(&renderer), Some(&dispatcher.upcast::<gst_player::PlayerSignalDispatcher>()));
let video_file = gio::File::new_for_path(config::VIDEO_PATH);
player.set_uri(&video_file.get_uri());
let video_widget = player
.get_pipeline()
.get_property("video-sink")
.unwrap()
.get::<gst::Element>()
.expect("The player of a VideoPlayerWidget should not use the default sink.")
.unwrap()
.get_property("widget")
.unwrap()
.get::<gtk::Widget>()
.unwrap()
.unwrap();
video_widget.set_size_request(-1, 300);
video_widget.set_property("ignore-alpha", &false).unwrap();
video_widget.show();
gtk::idle_add(clone!(@strong player => move || {
player.play();
glib::Continue(true)
}));
video_widget
}
fn init(&self) {
self.widget.set_property_expand(true);
self.widget.set_valign(gtk::Align::Center);
......@@ -23,12 +73,9 @@ impl WelcomePageWidget {
let name = glib::get_os_info("NAME").unwrap_or_else(|| "GNOME".into());
let version = glib::get_os_info("VERSION").unwrap_or_else(|| "3.36".into());
let icon = glib::get_os_info("LOGO").unwrap_or_else(|| "start-here-symbolic".into());
let logo = gtk::Image::from_icon_name(Some(&icon), gtk::IconSize::Dialog);
logo.set_pixel_size(196);
logo.show();
self.widget.add(&logo);
let header = self.get_header_widget();
self.widget.add(&header);
let title = gtk::Label::new(Some(&gettext(format!("Welcome to {} {}", name, version))));
title.set_margin_top(36);
......
use gettextrs::gettext;
use gtk::prelude::*;
// The welcome page with a video instead of a static logo
pub struct WelcomeVideoPageWidget {
pub widget: gtk::Box,
}
impl WelcomeVideoPageWidget {
pub fn new() -> Self {
let widget = gtk::Box::new(gtk::Orientation::Vertical, 0);
let welcome_page = Self { widget };
welcome_page.init();
welcome_page
}
fn init(&self) {
self.widget.set_property_expand(true);
self.widget.set_valign(gtk::Align::Center);
self.widget.set_halign(gtk::Align::Center);
self.widget.set_margin_top(24);
self.widget.set_margin_bottom(24);
let name = glib::get_os_info("NAME").unwrap_or_else(|| "GNOME".into());
let version = glib::get_os_info("VERSION").unwrap_or_else(|| "3.36".into());
let dispatcher = gst_player::PlayerGMainContextSignalDispatcher::new(None);
let sink = gst::ElementFactory::make("gtksink", None).expect("Missing dependency: element gtksink is needed (usually, in gstreamer-plugins-good or in gst-plugin-gtk).");
let renderer = gst_player::PlayerVideoOverlayVideoRenderer::with_sink(&sink).upcast();
let player = gst_player::Player::new(Some(&renderer), Some(&dispatcher.upcast::<gst_player::PlayerSignalDispatcher>()));
player.set_uri("/org/gnome/Tour/welcome.mp4");
let video_widget = player
.get_pipeline()
.get_property("video-sink")
.unwrap()
.get::<gst::Element>()
.expect("The player of a VideoPlayerWidget should not use the default sink.")
.unwrap()
.get_property("widget")
.unwrap()
.get::<gtk::Widget>()
.unwrap()
.unwrap();
video_widget.set_size_request(-1, 720);
video_widget.show();
gtk::idle_add(clone!(@strong player => move || {
player.play();
glib::Continue(false)
}));
self.widget.add(&video_widget);
let title = gtk::Label::new(Some(&gettext(format!("Welcome to {} {}", name, version))));
title.set_margin_top(36);
title.get_style_context().add_class("large-title");
title.show();
self.widget.add(&title);
let text = gtk::Label::new(Some(&gettext("Hi there! Take the tour to learn your way around and discover essential features.")));
text.get_style_context().add_class("body");
text.set_margin_top(12);
text.show();
self.widget.add(&text);
let actions_container = gtk::Box::new(gtk::Orientation::Horizontal, 12);
actions_container.set_halign(gtk::Align::Center);
actions_container.set_margin_top(36);
let skip_tour_btn = gtk::Button::with_label(&gettext("_No Thanks"));
skip_tour_btn.set_property_height_request(40);
skip_tour_btn.set_property_width_request(180);
skip_tour_btn.set_use_underline(true);
skip_tour_btn.set_action_name(Some("app.skip-tour"));
skip_tour_btn.show();
actions_container.add(&skip_tour_btn);
let start_tour_btn = gtk::Button::with_label(&gettext("_Start Tour"));
start_tour_btn.set_property_height_request(40);
start_tour_btn.set_property_width_request(180);
start_tour_btn.set_use_underline(true);
start_tour_btn.set_action_name(Some("app.start-tour"));
start_tour_btn.get_style_context().add_class("suggested-action");
start_tour_btn.show();
actions_container.add(&start_tour_btn);
actions_container.set_focus_child(Some(&start_tour_btn));
actions_container.show();
self.widget.add(&actions_container);
self.widget.show();
}
}
......@@ -4,7 +4,7 @@ use gtk::prelude::*;
use std::cell::RefCell;
use std::rc::Rc;
use super::pages::{ImagePageWidget, WelcomePageWidget, WelcomeVideoPageWidget};
use super::pages::{ImagePageWidget, WelcomePageWidget};
use super::paginator::PaginatorWidget;
use crate::config::{APP_ID, PROFILE};
......@@ -42,7 +42,7 @@ impl Window {
if PROFILE == "Devel" {
self.widget.get_style_context().add_class("devel");
}
self.paginator.borrow_mut().add_page(WelcomeVideoPageWidget::new().widget.upcast::<gtk::Widget>());
self.paginator.borrow_mut().add_page(WelcomePageWidget::new().widget.upcast::<gtk::Widget>());
self.paginator.borrow_mut().add_page(
ImagePageWidget::new(
......
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