[gnome-shell/T27795: 53/138] appStore: Add a new D-Bus service to manage apps and folders on the desktop



commit 9a0b4242d867f53da6181a6cc7584d4fa1fd942c
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Fri Sep 15 18:58:37 2017 +0100

    appStore: Add a new D-Bus service to manage apps and folders on the desktop
    
    This is basically a wrapper around some of the functions if IconGridLayout
    and will be used from GNOME Software to add/remove/list apps from the
    desktop and from the old AppStore (where it draws its name from) to add
    new folders to the desktop.
    
    https://phabricator.endlessm.com/T18781

 data/dbus-interfaces/meson.build                  |  1 +
 data/dbus-interfaces/org.gnome.Shell.AppStore.xml | 26 +++++++++++
 data/gnome-shell-dbus-interfaces.gresource.xml    |  1 +
 js/ui/shellDBus.js                                | 56 +++++++++++++++++++++++
 4 files changed, 84 insertions(+)
---
diff --git a/data/dbus-interfaces/meson.build b/data/dbus-interfaces/meson.build
index c96bbbb4da..107888bec8 100644
--- a/data/dbus-interfaces/meson.build
+++ b/data/dbus-interfaces/meson.build
@@ -1,4 +1,5 @@
 dbus_interfaces = [
+  'org.gnome.Shell.AppStore.xml',
   'org.gnome.Shell.Extensions.xml',
   'org.gnome.Shell.Introspect.xml',
   'org.gnome.Shell.PadOsd.xml',
diff --git a/data/dbus-interfaces/org.gnome.Shell.AppStore.xml 
b/data/dbus-interfaces/org.gnome.Shell.AppStore.xml
new file mode 100644
index 0000000000..bf9c848039
--- /dev/null
+++ b/data/dbus-interfaces/org.gnome.Shell.AppStore.xml
@@ -0,0 +1,26 @@
+<node>
+  <interface name="org.gnome.Shell.AppStore">
+    <method name="AddApplication">
+      <arg type="s" direction="in" name="id" />
+    </method>
+    <method name="AddAppIfNotVisible">
+      <arg type="s" direction="in" name="id" />
+    </method>
+    <method name="RemoveApplication">
+      <arg type="s" direction="in" name="id" />
+    </method>
+    <method name="ListApplications">
+      <arg type="as" direction="out" name="applications" />
+    </method>
+    <method name="AddFolder">
+      <arg type="s" direction="in" name="id" />
+    </method>
+    <method name="RemoveFolder">
+      <arg type="s" direction="in" name="id" />
+    </method>
+    <method name="ResetDesktop" />
+    <signal name="ApplicationsChanged">
+      <arg type="as" name="applications" />
+    </signal>
+  </interface>
+</node>
diff --git a/data/gnome-shell-dbus-interfaces.gresource.xml b/data/gnome-shell-dbus-interfaces.gresource.xml
index 22140c3da3..118a19e74d 100644
--- a/data/gnome-shell-dbus-interfaces.gresource.xml
+++ b/data/gnome-shell-dbus-interfaces.gresource.xml
@@ -39,6 +39,7 @@
     <file preprocess="xml-stripblanks">org.gnome.SettingsDaemon.Power.Screen.xml</file>
     <file preprocess="xml-stripblanks">org.gnome.SettingsDaemon.Rfkill.xml</file>
     <file preprocess="xml-stripblanks">org.gnome.SettingsDaemon.Wacom.xml</file>
+    <file preprocess="xml-stripblanks">org.gnome.Shell.AppStore.xml</file>
     <file preprocess="xml-stripblanks">org.gnome.Shell.AudioDeviceSelection.xml</file>
     <file preprocess="xml-stripblanks">org.gnome.Shell.CalendarServer.xml</file>
     <file preprocess="xml-stripblanks">org.gnome.Shell.ClocksIntegration.xml</file>
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index e750c207f9..ac43ed5991 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -6,6 +6,7 @@ const { Gio, GLib, Meta, Shell } = imports.gi;
 const Config = imports.misc.config;
 const ExtensionDownloader = imports.ui.extensionDownloader;
 const ExtensionUtils = imports.misc.extensionUtils;
+const IconGridLayout = imports.ui.iconGridLayout;
 const Main = imports.ui.main;
 const Screenshot = imports.ui.screenshot;
 
@@ -22,6 +23,8 @@ var GnomeShell = class {
         this._extensionsService = new GnomeShellExtensions();
         this._screenshotService = new Screenshot.ScreenshotService();
 
+        this._appstoreService = new AppStoreService();
+
         this._grabbedAccelerators = new Map();
         this._grabbers = new Map();
 
@@ -375,3 +378,56 @@ var ScreenSaverDBus = class {
             return 0;
     }
 };
+
+const AppStoreIface = loadInterfaceXML('org.gnome.Shell.AppStore');
+
+var AppStoreService = class {
+    constructor() {
+        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(AppStoreIface, this);
+        this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
+
+        IconGridLayout.layout.connect('changed', this._emitApplicationsChanged.bind(this));
+    }
+
+    AddApplication(id) {
+        if (!IconGridLayout.layout.iconIsFolder(id))
+            IconGridLayout.layout.appendIcon(id, IconGridLayout.DESKTOP_GRID_ID);
+    }
+
+    AddAppIfNotVisible(id) {
+        if (IconGridLayout.layout.iconIsFolder(id))
+            return;
+
+        let visibleIcons = IconGridLayout.layout.getIcons(IconGridLayout.DESKTOP_GRID_ID);
+        if (visibleIcons.indexOf(id) == -1)
+            IconGridLayout.layout.appendIcon(id, IconGridLayout.DESKTOP_GRID_ID);
+    }
+
+    RemoveApplication(id) {
+        if (!IconGridLayout.layout.iconIsFolder(id))
+            IconGridLayout.layout.removeIcon(id, false);
+    }
+
+    AddFolder(id) {
+        if (IconGridLayout.layout.iconIsFolder(id))
+            IconGridLayout.layout.appendIcon(id, IconGridLayout.DESKTOP_GRID_ID);
+    }
+
+    RemoveFolder(id) {
+        if (IconGridLayout.layout.iconIsFolder(id))
+            IconGridLayout.layout.removeIcon(id, false);
+    }
+
+    ResetDesktop() {
+        IconGridLayout.layout.resetDesktop();
+    }
+
+    ListApplications() {
+        return IconGridLayout.layout.listApplications();
+    }
+
+    _emitApplicationsChanged() {
+        let allApps = IconGridLayout.layout.listApplications();
+        this._dbusImpl.emit_signal('ApplicationsChanged', GLib.Variant.new('(as)', [allApps]));
+    }
+};


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