[gnome-software/ADD_SHORTCUT: 3/5] Add plugin support for removing an app shortcut



commit b11e7d55edf5054900bcb4316080d197c5b2788e
Author: Joaquim Rocha <jrocha endlessm com>
Date:   Wed Apr 13 16:21:19 2016 +0200

    Add plugin support for removing an app shortcut

 src/gs-page.c          |   25 +++++++++++++++++++++++++
 src/gs-page.h          |    2 ++
 src/gs-plugin-loader.c |    3 +++
 src/gs-plugin-loader.h |    1 +
 src/gs-plugin.h        |    4 ++++
 5 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-page.c b/src/gs-page.c
index 746dd89..28984c2 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -405,6 +405,31 @@ gs_page_add_shortcut_to_app (GsPage *page, GsApp *app)
                                           NULL);
 }
 
+static void
+gs_page_app_shortcut_removed_cb (GObject *source,
+                                GAsyncResult *res,
+                                gpointer user_data)
+{
+       GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source);
+       g_autoptr(GError) error = NULL;
+       if (!gs_plugin_loader_app_action_finish (plugin_loader, res, &error)) {
+               g_warning ("failed to remove the shortcut to GsApp: %s", error->message);
+               return;
+       }
+}
+
+void
+gs_page_remove_shortcut_to_app (GsPage *page, GsApp *app)
+{
+       GsPagePrivate *priv = gs_page_get_instance_private (page);
+       gs_plugin_loader_app_action_async (priv->plugin_loader,
+                                          app,
+                                          GS_PLUGIN_LOADER_ACTION_REMOVE_SHORTCUT,
+                                          priv->cancellable,
+                                          gs_page_app_shortcut_removed_cb,
+                                          NULL);
+}
+
 /**
  * gs_page_switch_to:
  *
diff --git a/src/gs-page.h b/src/gs-page.h
index 5d49e0b..e341a3b 100644
--- a/src/gs-page.h
+++ b/src/gs-page.h
@@ -63,6 +63,8 @@ void           gs_page_launch_app                     (GsPage         *page,
                                                         GsApp          *app);
 void            gs_page_add_shortcut_to_app            (GsPage         *page,
                                                         GsApp          *app);
+void            gs_page_remove_shortcut_to_app         (GsPage         *page,
+                                                        GsApp          *app);
 void            gs_page_switch_to                      (GsPage         *page,
                                                         gboolean        scroll_up);
 void            gs_page_setup                          (GsPage         *page,
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index bd53233..4c3385d 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -2866,6 +2866,9 @@ gs_plugin_loader_app_action_async (GsPluginLoader *plugin_loader,
        case GS_PLUGIN_LOADER_ACTION_ADD_SHORTCUT:
                state->function_name = "gs_plugin_add_shortcut";
                break;
+       case GS_PLUGIN_LOADER_ACTION_REMOVE_SHORTCUT:
+               state->function_name = "gs_plugin_remove_shortcut";
+               break;
        default:
                g_assert_not_reached ();
                break;
diff --git a/src/gs-plugin-loader.h b/src/gs-plugin-loader.h
index 9abeefc..4842e23 100644
--- a/src/gs-plugin-loader.h
+++ b/src/gs-plugin-loader.h
@@ -62,6 +62,7 @@ typedef enum {
        GS_PLUGIN_LOADER_ACTION_LAUNCH,
        GS_PLUGIN_LOADER_ACTION_UPDATE_CANCEL,
        GS_PLUGIN_LOADER_ACTION_ADD_SHORTCUT,
+       GS_PLUGIN_LOADER_ACTION_REMOVE_SHORTCUT,
        GS_PLUGIN_LOADER_ACTION_LAST
 } GsPluginLoaderAction;
 
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index 3104482..0d83330 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -328,6 +328,10 @@ gboolean    gs_plugin_add_shortcut                 (GsPlugin       *plugin,
                                                         GsApp          *app,
                                                         GCancellable   *cancellable,
                                                         GError         **error);
+gboolean        gs_plugin_remove_shortcut              (GsPlugin       *plugin,
+                                                        GsApp          *app,
+                                                        GCancellable   *cancellable,
+                                                        GError         **error);
 gboolean        gs_plugin_update_cancel                (GsPlugin       *plugin,
                                                         GsApp          *app,
                                                         GCancellable   *cancellable,


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