[gnome-software/wip/temp/ubuntu-xenial-rebased-corrected: 113/331] Notify Unity launcher when installing



commit 95485dc192ed2460f7ecf900c37b5799b9a0620b
Author: Andrea Azzarone <azzaronea gmail com>
Date:   Fri Feb 19 12:16:03 2016 -0800

    Notify Unity launcher when installing

 src/plugins/com.canonical.Unity.Launcher.xml |   15 +++++++++++++
 src/plugins/gs-plugin-apt.c                  |   29 ++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/com.canonical.Unity.Launcher.xml b/src/plugins/com.canonical.Unity.Launcher.xml
new file mode 100644
index 0000000..b631a2d
--- /dev/null
+++ b/src/plugins/com.canonical.Unity.Launcher.xml
@@ -0,0 +1,15 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
+<node>
+  <interface name='com.canonical.Unity.Launcher'>
+    <method name='AddLauncherItem'>
+      <arg type='s' name='appstream_app_id' direction='in'/>
+      <arg type='s' name='aptdaemon_task' direction='in'/>
+    </method>
+    
+    <method name='UpdateLauncherIconFavoriteState'>
+      <arg type='s' name='icon_uri' direction='in'/>
+      <arg type='b' name='is_sticky' direction='in'/>
+    </method>
+  </interface>
+</node>
diff --git a/src/plugins/gs-plugin-apt.c b/src/plugins/gs-plugin-apt.c
index e14e6cf..81ff64d 100644
--- a/src/plugins/gs-plugin-apt.c
+++ b/src/plugins/gs-plugin-apt.c
@@ -36,6 +36,8 @@ typedef struct {
 } PackageInfo;
 
 
+#include "ubuntu-unity-launcher-proxy.h"
+
 struct GsPluginPrivate {
        gsize            loaded;
        GHashTable      *package_info;
@@ -467,6 +469,30 @@ transaction_finished_cb (GDBusConnection *connection,
        g_main_loop_quit (data->loop);
 }
 
+static void
+notify_unity_launcher (GsApp *app, const gchar *transaction_path)
+{
+       UbuntuUnityLauncher *launcher = NULL;
+
+       g_return_if_fail (GS_IS_APP (app));
+       g_return_if_fail (transaction_path);
+
+       launcher = ubuntu_unity_launcher_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+               G_DBUS_PROXY_FLAGS_NONE,
+               "com.canonical.Unity.Launcher",
+               "/com/canonical/Unity/Launcher",
+               NULL, NULL);
+
+       g_return_if_fail (launcher);
+
+       ubuntu_unity_launcher_call_add_launcher_item (launcher,
+               gs_app_get_id (app),
+               transaction_path,
+               NULL, NULL, NULL);
+
+       g_object_unref (launcher);
+}
+
 static gboolean
 aptd_transaction (GsPlugin *plugin, const gchar *method, GsApp *app, GError **error)
 {
@@ -506,6 +532,9 @@ aptd_transaction (GsPlugin *plugin, const gchar *method, GsApp *app, GError **er
        g_variant_get (result, "(s)", &transaction_path);
        g_variant_unref (result);
 
+       if (!g_strcmp0(method, "InstallPackages"))
+               notify_unity_launcher (app, transaction_path);
+
        loop = g_main_loop_new (NULL, FALSE);
 
        data.plugin = plugin;


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