[gnome-tour/27-adjust-content-if-no-touchpad-is-present] WIP: Adjust page content if no touchpad is present




commit b0dbbd2a48385055660dc82ec492bf972422da8b
Author: Will Thompson <wjt endlessm com>
Date:   Thu Feb 11 09:49:17 2021 +0000

    WIP: Adjust page content if no touchpad is present
    
    Not all systems have touchpads. Show keyboard instructions for
    triggering the overview and switching workspaces if no touchpad is
    present.
    
    For now we assume that all touchpads support three-finger swipes.

 data/resources/style.css |  4 ++--
 meson.build              |  1 +
 src/meson.build          |  1 +
 src/widgets/mod.rs       |  1 +
 src/widgets/window.rs    | 31 +++++++++++++++++++++++++++----
 5 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/data/resources/style.css b/data/resources/style.css
index 1bf6cdd..30efac0 100644
--- a/data/resources/style.css
+++ b/data/resources/style.css
@@ -52,14 +52,14 @@
   .page:nth-child(3) {  }  /* customize */
   /* .page:nth-child(4) { background: linear-gradient(to right, #e66100, #c64600); }  workspaces */
 
-  .page:nth-child(5) { /* up down */
+  .touchpad .page:nth-child(5) { /* up down */
     background: url('/org/gnome/Tour/hand-fg.svg'),
                 url('/org/gnome/Tour/updown-bg.svg');
     background-repeat: no-repeat;
     background-position: center 30%;
     animation: up-and-down 2s ease-in-out infinite alternate;
     }
-  .page:nth-child(6) {   /* left right */
+  .touchpad .page:nth-child(6) {   /* left right */
     background: url('/org/gnome/Tour/hand-fg.svg'),
                 url('/org/gnome/Tour/leftright-bg.svg');
     background-repeat: no-repeat;
diff --git a/meson.build b/meson.build
index 9e29d14..0760303 100644
--- a/meson.build
+++ b/meson.build
@@ -13,6 +13,7 @@ dependency('gio-2.0', version: '>= 2.56')
 dependency('gdk-pixbuf-2.0')
 dependency('gtk+-3.0', version: '>= 3.16')
 dependency('libhandy-1', version: '>= 1')
+#dependency('gnome-settings-daemon')
 
 if get_option('video_path') != ''
   dependency('gstreamer-1.0', version: '>= 1.12')
diff --git a/src/meson.build b/src/meson.build
index 35f2841..d5c513b 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -39,6 +39,7 @@ sources = files(
   'widgets/pages/image.rs',
   'widgets/pages/mod.rs',
   'widgets/pages/welcome.rs',
+  'widgets/gsd.rs',
   'widgets/mod.rs',
   'widgets/paginator.rs',
   'widgets/window.rs',
diff --git a/src/widgets/mod.rs b/src/widgets/mod.rs
index c58dca4..7d5bfdd 100644
--- a/src/widgets/mod.rs
+++ b/src/widgets/mod.rs
@@ -1,3 +1,4 @@
+mod gsd;
 mod pages;
 mod paginator;
 mod window;
diff --git a/src/widgets/window.rs b/src/widgets/window.rs
index 71aedef..4dcd565 100644
--- a/src/widgets/window.rs
+++ b/src/widgets/window.rs
@@ -4,6 +4,7 @@ use gtk::prelude::*;
 use std::cell::RefCell;
 use std::rc::Rc;
 
+use super::gsd::touchpad_is_present;
 use super::pages::{ImagePageWidget, WelcomePageWidget};
 use super::paginator::PaginatorWidget;
 use crate::config::{APP_ID, PROFILE};
@@ -35,6 +36,7 @@ impl Window {
     }
 
     fn init(&mut self) {
+        let has_touchpad = touchpad_is_present();
         self.widget.set_default_size(960, 720);
         self.widget.set_icon_name(Some(APP_ID));
 
@@ -42,6 +44,11 @@ impl Window {
         if PROFILE == "Devel" {
             self.widget.get_style_context().add_class("devel");
         }
+        if has_touchpad {
+            self.widget.get_style_context().add_class("touchpad");
+        } else {
+            self.widget.get_style_context().add_class("no-touchpad");
+        }
         self.paginator
             .borrow_mut()
             .add_page(WelcomePageWidget::new().widget.upcast::<gtk::Widget>());
@@ -78,8 +85,16 @@ impl Window {
         self.paginator.borrow_mut().add_page(
             ImagePageWidget::new(
                 "/org/gnome/Tour/blank.svg",
-                gettext("Up/Down for the Overview"),
-                gettext("On a touchpad, use three-finger vertical swipes. Try it!"),
+                if has_touchpad {
+                    gettext("Up/Down for the Overview")
+                } else {
+                    gettext("Logo+Alt+Up/Down for the Overview")
+                },
+                if has_touchpad {
+                    gettext("On a touchpad, use three-finger vertical swipes. Try it!")
+                } else {
+                    gettext("Write a better string here")
+                },
             )
             .widget
             .upcast::<gtk::Widget>(),
@@ -88,8 +103,16 @@ impl Window {
         self.paginator.borrow_mut().add_page(
             ImagePageWidget::new(
                 "/org/gnome/Tour/blank.svg",
-                gettext("Left/Right for Workspaces"),
-                gettext("On a touchpad, use three-finger horizontal swipes. Try it!"),
+                if has_touchpad {
+                    gettext("Left/Right for Workspaces")
+                } else {
+                    gettext("Logo+Alt+Left/Right for Workspaces")
+                },
+                if has_touchpad {
+                    gettext("On a touchpad, use three-finger horizontal swipes. Try it!")
+                } else {
+                    gettext("Hit some keys. Try it!")
+                },
             )
             .widget
             .upcast::<gtk::Widget>(),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]