[gnome-shell/T27795: 103/138] discoveryFeed: Add Discovery Feed component



commit 0b0823f7823c5f228c80812982a6d1e7cde3d17b
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Wed Jan 31 15:50:44 2018 +0000

    discoveryFeed: Add Discovery Feed component
    
    Also, add integration with the side component.
    
    2019-09-24: move D-Bus interface to XML file.
    
    https://phabricator.endlessm.com/T18601

 .../dbus-interfaces/com.endlessm.DiscoveryFeed.xml | 11 ++++
 data/gnome-shell-dbus-interfaces.gresource.xml     |  1 +
 js/js-resources.gresource.xml                      |  1 +
 js/ui/components/discoveryFeed.js                  | 39 ++++++++++++
 js/ui/main.js                                      |  1 +
 js/ui/sessionMode.js                               |  4 +-
 js/ui/sideComponent.js                             | 16 ++++-
 js/ui/windowManager.js                             | 71 ++++++++++++++--------
 8 files changed, 115 insertions(+), 29 deletions(-)
---
diff --git a/data/dbus-interfaces/com.endlessm.DiscoveryFeed.xml 
b/data/dbus-interfaces/com.endlessm.DiscoveryFeed.xml
new file mode 100644
index 0000000000..2df0c9756c
--- /dev/null
+++ b/data/dbus-interfaces/com.endlessm.DiscoveryFeed.xml
@@ -0,0 +1,11 @@
+<node>
+  <interface name="com.endlessm.DiscoveryFeed">
+    <method name="show">
+      <arg type="u" direction="in" name="timestamp"/>
+    </method>
+    <method name="hide">
+      <arg type="u" direction="in" name="timestamp"/>
+    </method>
+    <property name="Visible" type="b" access="read"/>
+  </interface>
+</node>
diff --git a/data/gnome-shell-dbus-interfaces.gresource.xml b/data/gnome-shell-dbus-interfaces.gresource.xml
index 118a19e74d..cbe44a78d6 100644
--- a/data/gnome-shell-dbus-interfaces.gresource.xml
+++ b/data/gnome-shell-dbus-interfaces.gresource.xml
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource prefix="/org/gnome/shell/dbus-interfaces">
+    <file preprocess="xml-stripblanks">com.endlessm.DiscoveryFeed.xml</file>
     <file preprocess="xml-stripblanks">com.endlessm.Speedwagon.xml</file>
     <file preprocess="xml-stripblanks">net.hadess.SensorProxy.xml</file>
     <file preprocess="xml-stripblanks">net.hadess.SwitcherooControl.xml</file>
diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml
index 8213970de6..f669a2ffb4 100644
--- a/js/js-resources.gresource.xml
+++ b/js/js-resources.gresource.xml
@@ -143,6 +143,7 @@
     <file>ui/appActivation.js</file>
     <file>ui/appIconBar.js</file>
     <file>ui/components/appStore.js</file>
+    <file>ui/components/discoveryFeed.js</file>
     <file>ui/components/trayArea.js</file>
     <file>ui/endlessButton.js</file>
     <file>ui/forceAppExitDialog.js</file>
diff --git a/js/ui/components/discoveryFeed.js b/js/ui/components/discoveryFeed.js
new file mode 100644
index 0000000000..b37e864af4
--- /dev/null
+++ b/js/ui/components/discoveryFeed.js
@@ -0,0 +1,39 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+
+const { GObject } = imports.gi;
+
+const { loadInterfaceXML } = imports.misc.fileUtils;
+
+const Main = imports.ui.main;
+const SideComponent = imports.ui.sideComponent;
+
+const DISCOVERY_FEED_NAME = 'com.endlessm.DiscoveryFeed';
+const DISCOVERY_FEED_PATH = '/com/endlessm/DiscoveryFeed';
+
+const DiscoveryFeedIface = loadInterfaceXML('com.endlessm.DiscoveryFeed');
+
+var DiscoveryFeed = GObject.registerClass(
+class DiscoveryFeed extends SideComponent.SideComponent {
+    _init() {
+        super._init(DiscoveryFeedIface, DISCOVERY_FEED_NAME, DISCOVERY_FEED_PATH);
+    }
+
+    enable() {
+        super.enable();
+        Main.discoveryFeed = this;
+    }
+
+    disable() {
+        super.disable();
+        Main.discoveryFeed = null;
+    }
+
+    callShow(timestamp) {
+        this.proxy.showRemote(timestamp);
+    }
+
+    callHide(timestamp) {
+        this.proxy.hideRemote(timestamp);
+    }
+});
+var Component = DiscoveryFeed;
diff --git a/js/ui/main.js b/js/ui/main.js
index 0ef29e1df0..a2fcf08872 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -90,6 +90,7 @@ var kbdA11yDialog = null;
 var inputMethod = null;
 var introspectService = null;
 var locatePointer = null;
+var discoveryFeed = null;
 var trayArea = null;
 var workspaceMonitor = null;
 let _startDate;
diff --git a/js/ui/sessionMode.js b/js/ui/sessionMode.js
index e0a72effdd..b75d106160 100644
--- a/js/ui/sessionMode.js
+++ b/js/ui/sessionMode.js
@@ -95,10 +95,10 @@ const _modes = {
         components: Config.HAVE_NETWORKMANAGER
             ? ['networkAgent', 'polkitAgent', 'telepathyClient',
                'keyring', 'autorunManager', 'automountManager',
-               'appStore', 'trayArea']
+               'appStore', 'discoveryFeed', 'trayArea']
             : ['polkitAgent', 'telepathyClient',
                'keyring', 'autorunManager', 'automountManager',
-               'appStore', 'trayArea'],
+               'appStore', 'discoveryFeed', 'trayArea'],
 
         panel: {
             left: ['endlessButton', 'appIcons'],
diff --git a/js/ui/sideComponent.js b/js/ui/sideComponent.js
index 8045d8eb02..6d513c7ef0 100644
--- a/js/ui/sideComponent.js
+++ b/js/ui/sideComponent.js
@@ -22,7 +22,8 @@ function isSideComponentWindow (metaWindow) {
  * @return: whether other windows should be hidden while this one is open
  */
 function shouldHideOtherWindows (metaWindow) {
-    return isSideComponentWindow(metaWindow);
+    return isSideComponentWindow(metaWindow) &&
+        Main.discoveryFeed.launchedFromDesktop;
 };
 
 /**
@@ -32,8 +33,17 @@ function shouldHideOtherWindows (metaWindow) {
  */
 function launchedFromDesktop (metaWindow) {
     return isSideComponentWindow(metaWindow) &&
-        metaWindow.get_wm_class() == 'Eos-app-store' &&
-        Main.appStore.launchedFromDesktop;
+        ((metaWindow.get_wm_class == 'Eos-app-store' && Main.appStore.launchedFromDesktop) ||
+         (isDiscoveryFeedWindow(metaWindow) && Main.discoveryFeed.launchedFromDesktop));
+};
+
+/**
+ * isDiscoveryFeedWindow:
+ * @metaWindow: an instance of #Meta.Window
+ * @return: whether the #Meta.Window is from the DiscoveryFeed application
+ */
+function isDiscoveryFeedWindow (metaWindow) {
+    return metaWindow && (metaWindow.get_wm_class() == 'Com.endlessm.DiscoveryFeed');
 };
 
 var SideComponent = GObject.registerClass(
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 49da6be262..11564552b1 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -1582,18 +1582,28 @@ var WindowManager = class {
         actor.opacity = 255;
         actor.show();
 
-        let endX;
-        if (actor.x <= monitor.x)
-            endX = monitor.x - actor.width;
-        else
-            endX = monitor.x + monitor.width;
+        if (SideComponent.isDiscoveryFeedWindow(actor.meta_window)) {
+            let endY = monitor.y - actor.height;
+            actor.ease({
+                y: endY,
+                duration: WINDOW_ANIMATION_TIME,
+                mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+                onComplete: () => onComplete(shellwm, actor),
+            });
+        } else {
+            let endX;
+            if (actor.x <= monitor.x)
+                endX = monitor.x - actor.width;
+            else
+                endX = monitor.x + monitor.width;
 
-        actor.ease({
-            x: endX,
-            duration: WINDOW_ANIMATION_TIME,
-            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-            onComplete: () => onComplete(shellwm, actor),
-        });
+            actor.ease({
+                x: endX,
+                duration: WINDOW_ANIMATION_TIME,
+                mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+                onComplete: () => onComplete(shellwm, actor),
+            });
+        }
     }
 
     _minimizeWindow(shellwm, actor) {
@@ -1944,21 +1954,34 @@ var WindowManager = class {
             return;
         }
 
-        let origX = actor.x;
-        if (origX == monitor.x) {
-            // the side bar will appear from the left side
-            actor.set_position(monitor.x - actor.width, actor.y);
+        if (SideComponent.isDiscoveryFeedWindow(actor.meta_window)) {
+            // the DiscoveryFeed window will appear from the top center
+            let origY = actor.y;
+            actor.set_position(actor.x, monitor.y - actor.height);
+
+            actor.ease({
+                y: origY,
+                duration: WINDOW_ANIMATION_TIME,
+                mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+                onComplete: this._mapWindowDone.bind(this),
+            });
         } else {
-            // ... from the right side
-            actor.set_position(monitor.x + monitor.width, actor.y);
-        }
+            let origX = actor.x;
+            if (origX == monitor.x) {
+                // the side bar will appear from the left side
+                actor.set_position(monitor.x - actor.width, actor.y);
+            } else {
+                // ... from the right side
+                actor.set_position(monitor.x + monitor.width, actor.y);
+            }
 
-        actor.ease({
-            x: origX,
-            duration: WINDOW_ANIMATION_TIME,
-            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-            onComplete: this._mapWindowDone.bind(this),
-        });
+            actor.ease({
+                x: origX,
+                duration: WINDOW_ANIMATION_TIME,
+                mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+                onComplete: this._mapWindowDone.bind(this),
+            });
+        }
 
         actor.opacity = 255;
         actor.show();


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