[gnome-software/ADD_SHORTCUT: 1/5] Add plugin support for adding an app shortcut
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/ADD_SHORTCUT: 1/5] Add plugin support for adding an app shortcut
- Date: Wed, 20 Apr 2016 13:51:44 +0000 (UTC)
commit dd4ec0d8e1a1cdf69b07413cb07ecc611339836c
Author: Joaquim Rocha <jrocha endlessm com>
Date: Wed Apr 13 13:36:05 2016 +0200
Add plugin support for adding an app shortcut
Shortcuts can mean e.g. an icon in the desktop or in a favorites area.
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 b7dd9da..746dd89 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -380,6 +380,31 @@ gs_page_launch_app (GsPage *page, GsApp *app)
NULL);
}
+static void
+gs_page_app_shortcut_added_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 add a shortcut to GsApp: %s", error->message);
+ return;
+ }
+}
+
+void
+gs_page_add_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_ADD_SHORTCUT,
+ priv->cancellable,
+ gs_page_app_shortcut_added_cb,
+ NULL);
+}
+
/**
* gs_page_switch_to:
*
diff --git a/src/gs-page.h b/src/gs-page.h
index a06505b..5d49e0b 100644
--- a/src/gs-page.h
+++ b/src/gs-page.h
@@ -61,6 +61,8 @@ void gs_page_update_app (GsPage *page,
GsApp *app);
void gs_page_launch_app (GsPage *page,
GsApp *app);
+void gs_page_add_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 38c840b..bd53233 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -2863,6 +2863,9 @@ gs_plugin_loader_app_action_async (GsPluginLoader *plugin_loader,
case GS_PLUGIN_LOADER_ACTION_UPDATE_CANCEL:
state->function_name = "gs_plugin_update_cancel";
break;
+ case GS_PLUGIN_LOADER_ACTION_ADD_SHORTCUT:
+ state->function_name = "gs_plugin_add_shortcut";
+ break;
default:
g_assert_not_reached ();
break;
diff --git a/src/gs-plugin-loader.h b/src/gs-plugin-loader.h
index 2957079..9abeefc 100644
--- a/src/gs-plugin-loader.h
+++ b/src/gs-plugin-loader.h
@@ -61,6 +61,7 @@ typedef enum {
GS_PLUGIN_LOADER_ACTION_UPGRADE_TRIGGER,
GS_PLUGIN_LOADER_ACTION_LAUNCH,
GS_PLUGIN_LOADER_ACTION_UPDATE_CANCEL,
+ GS_PLUGIN_LOADER_ACTION_ADD_SHORTCUT,
GS_PLUGIN_LOADER_ACTION_LAST
} GsPluginLoaderAction;
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index 0dc9b42..3104482 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -324,6 +324,10 @@ gboolean gs_plugin_launch (GsPlugin *plugin,
GsApp *app,
GCancellable *cancellable,
GError **error);
+gboolean gs_plugin_add_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]