[gnome-software: 1/4] gs-plugin-vfuncs: Remove add/remove shortcut vfuncs and associated code
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 1/4] gs-plugin-vfuncs: Remove add/remove shortcut vfuncs and associated code
- Date: Thu, 16 Dec 2021 09:53:56 +0000 (UTC)
commit 2d813469232b187897e195f294a35a0f52d60bc7
Author: Philip Withnall <pwithnall endlessos org>
Date: Mon Dec 13 16:51:27 2021 +0000
gs-plugin-vfuncs: Remove add/remove shortcut vfuncs and associated code
No plugin provided support for them. This is functionality that
gnome-shell handles; gnome-software shouldn’t be doing it.
All this code was unused with the built-in set of plugins.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
lib/gs-app.c | 2 --
lib/gs-app.h | 3 +-
lib/gs-plugin-loader.c | 2 --
lib/gs-plugin-types.h | 4 ---
lib/gs-plugin-vfuncs.h | 32 --------------------
lib/gs-plugin.c | 12 --------
src/gs-details-page.c | 80 --------------------------------------------------
src/gs-details-page.ui | 23 ---------------
src/gs-page.c | 56 -----------------------------------
src/gs-page.h | 6 ----
10 files changed, 1 insertion(+), 219 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 91cc8d50c..f03c753f7 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -309,8 +309,6 @@ _as_component_quirk_flag_to_string (GsAppQuirk quirk)
return "needs-reboot";
case GS_APP_QUIRK_NOT_REVIEWABLE:
return "not-reviewable";
- case GS_APP_QUIRK_HAS_SHORTCUT:
- return "has-shortcut";
case GS_APP_QUIRK_NOT_LAUNCHABLE:
return "not-launchable";
case GS_APP_QUIRK_NEEDS_USER_ACTION:
diff --git a/lib/gs-app.h b/lib/gs-app.h
index 01db4940f..6a0e98d39 100644
--- a/lib/gs-app.h
+++ b/lib/gs-app.h
@@ -133,7 +133,6 @@ typedef enum {
* @GS_APP_QUIRK_IS_WILDCARD: Matches applications from any plugin
* @GS_APP_QUIRK_NEEDS_REBOOT: A reboot is required after the action
* @GS_APP_QUIRK_NOT_REVIEWABLE: The app is not reviewable
- * @GS_APP_QUIRK_HAS_SHORTCUT: The app has a shortcut in the system
* @GS_APP_QUIRK_NOT_LAUNCHABLE: The app is not launchable (run-able)
* @GS_APP_QUIRK_NEEDS_USER_ACTION: The component requires some kind of user action
* @GS_APP_QUIRK_IS_PROXY: Is a proxy app that operates on other applications
@@ -156,7 +155,7 @@ typedef enum {
GS_APP_QUIRK_IS_WILDCARD = 1 << 3, /* Since: 3.32 */
GS_APP_QUIRK_NEEDS_REBOOT = 1 << 4, /* Since: 3.32 */
GS_APP_QUIRK_NOT_REVIEWABLE = 1 << 5, /* Since: 3.32 */
- GS_APP_QUIRK_HAS_SHORTCUT = 1 << 6, /* Since: 3.32 */
+ /* there’s a hole here where GS_APP_QUIRK_HAS_SHORTCUT used to be */
GS_APP_QUIRK_NOT_LAUNCHABLE = 1 << 7, /* Since: 3.32 */
GS_APP_QUIRK_NEEDS_USER_ACTION = 1 << 8, /* Since: 3.32 */
GS_APP_QUIRK_IS_PROXY = 1 << 9, /* Since: 3.32 */
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index cd9c7e4aa..fea6b7203 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -648,8 +648,6 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper,
case GS_PLUGIN_ACTION_UPGRADE_TRIGGER:
case GS_PLUGIN_ACTION_LAUNCH:
case GS_PLUGIN_ACTION_UPDATE_CANCEL:
- case GS_PLUGIN_ACTION_ADD_SHORTCUT:
- case GS_PLUGIN_ACTION_REMOVE_SHORTCUT:
case GS_PLUGIN_ACTION_INSTALL_REPO:
case GS_PLUGIN_ACTION_REMOVE_REPO:
case GS_PLUGIN_ACTION_ENABLE_REPO:
diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h
index e938ebf23..af29d1069 100644
--- a/lib/gs-plugin-types.h
+++ b/lib/gs-plugin-types.h
@@ -200,8 +200,6 @@ typedef enum {
* @GS_PLUGIN_ACTION_UPGRADE_TRIGGER: Trigger a distro upgrade
* @GS_PLUGIN_ACTION_LAUNCH: Launch an application
* @GS_PLUGIN_ACTION_UPDATE_CANCEL: Cancel the update
- * @GS_PLUGIN_ACTION_ADD_SHORTCUT: Add a shortcut to an application
- * @GS_PLUGIN_ACTION_REMOVE_SHORTCUT: Remove a shortcut to an application
* @GS_PLUGIN_ACTION_GET_UPDATES: Get the list of updates
* @GS_PLUGIN_ACTION_GET_DISTRO_UPDATES: Get the list of distro updates
* @GS_PLUGIN_ACTION_GET_SOURCES: Get the list of sources
@@ -238,8 +236,6 @@ typedef enum {
GS_PLUGIN_ACTION_UPGRADE_TRIGGER,
GS_PLUGIN_ACTION_LAUNCH,
GS_PLUGIN_ACTION_UPDATE_CANCEL,
- GS_PLUGIN_ACTION_ADD_SHORTCUT,
- GS_PLUGIN_ACTION_REMOVE_SHORTCUT,
GS_PLUGIN_ACTION_GET_UPDATES,
GS_PLUGIN_ACTION_GET_DISTRO_UPDATES,
GS_PLUGIN_ACTION_GET_SOURCES,
diff --git a/lib/gs-plugin-vfuncs.h b/lib/gs-plugin-vfuncs.h
index 18ec9545d..41c818f0a 100644
--- a/lib/gs-plugin-vfuncs.h
+++ b/lib/gs-plugin-vfuncs.h
@@ -375,38 +375,6 @@ gboolean gs_plugin_launch (GsPlugin *plugin,
GCancellable *cancellable,
GError **error);
-/**
- * gs_plugin_add_shortcut:
- * @plugin: a #GsPlugin
- * @app: a #GsApp
- * @cancellable: a #GCancellable, or %NULL
- * @error: a #GError, or %NULL
- *
- * Adds a shortcut for the application in a desktop-defined location.
- *
- * Returns: %TRUE for success or if not relevant
- **/
-gboolean gs_plugin_add_shortcut (GsPlugin *plugin,
- GsApp *app,
- GCancellable *cancellable,
- GError **error);
-
-/**
- * gs_plugin_remove_shortcut:
- * @plugin: a #GsPlugin
- * @app: a #GsApp
- * @cancellable: a #GCancellable, or %NULL
- * @error: a #GError, or %NULL
- *
- * Removes a shortcut for the application in a desktop-defined location.
- *
- * Returns: %TRUE for success or if not relevant
- **/
-gboolean gs_plugin_remove_shortcut (GsPlugin *plugin,
- GsApp *app,
- GCancellable *cancellable,
- GError **error);
-
/**
* gs_plugin_update_cancel:
* @plugin: a #GsPlugin
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index ca4d5038b..486aefe3c 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -1679,10 +1679,6 @@ gs_plugin_action_to_function_name (GsPluginAction action)
return "gs_plugin_launch";
if (action == GS_PLUGIN_ACTION_UPDATE_CANCEL)
return "gs_plugin_update_cancel";
- if (action == GS_PLUGIN_ACTION_ADD_SHORTCUT)
- return "gs_plugin_add_shortcut";
- if (action == GS_PLUGIN_ACTION_REMOVE_SHORTCUT)
- return "gs_plugin_remove_shortcut";
if (action == GS_PLUGIN_ACTION_UPDATE)
return "gs_plugin_update";
if (action == GS_PLUGIN_ACTION_DOWNLOAD)
@@ -1763,10 +1759,6 @@ gs_plugin_action_to_string (GsPluginAction action)
return "launch";
if (action == GS_PLUGIN_ACTION_UPDATE_CANCEL)
return "update-cancel";
- if (action == GS_PLUGIN_ACTION_ADD_SHORTCUT)
- return "add-shortcut";
- if (action == GS_PLUGIN_ACTION_REMOVE_SHORTCUT)
- return "remove-shortcut";
if (action == GS_PLUGIN_ACTION_GET_UPDATES)
return "get-updates";
if (action == GS_PLUGIN_ACTION_GET_DISTRO_UPDATES)
@@ -1845,10 +1837,6 @@ gs_plugin_action_from_string (const gchar *action)
return GS_PLUGIN_ACTION_LAUNCH;
if (g_strcmp0 (action, "update-cancel") == 0)
return GS_PLUGIN_ACTION_UPDATE_CANCEL;
- if (g_strcmp0 (action, "add-shortcut") == 0)
- return GS_PLUGIN_ACTION_ADD_SHORTCUT;
- if (g_strcmp0 (action, "remove-shortcut") == 0)
- return GS_PLUGIN_ACTION_REMOVE_SHORTCUT;
if (g_strcmp0 (action, "get-updates") == 0)
return GS_PLUGIN_ACTION_GET_UPDATES;
if (g_strcmp0 (action, "get-distro-updates") == 0)
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 44c2b7689..54bbb2052 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -103,8 +103,6 @@ struct _GsDetailsPage
GtkWidget *label_review_count;
GtkWidget *screenshot_carousel;
GtkWidget *button_details_launch;
- GtkWidget *button_details_add_shortcut;
- GtkWidget *button_details_remove_shortcut;
GtkStack *links_stack;
AdwActionRow *project_website_row;
AdwActionRow *donate_row;
@@ -215,60 +213,6 @@ gs_details_page_set_state (GsDetailsPage *self,
g_object_notify (G_OBJECT (self), "title");
}
-static void
-gs_details_page_update_shortcut_button (GsDetailsPage *self)
-{
- gboolean add_shortcut_func;
- gboolean remove_shortcut_func;
- gboolean has_shortcut;
-
- gtk_widget_set_visible (self->button_details_add_shortcut,
- FALSE);
- gtk_widget_set_visible (self->button_details_remove_shortcut,
- FALSE);
-
- if (gs_app_get_kind (self->app) != AS_COMPONENT_KIND_DESKTOP_APP)
- return;
-
- /* Leave the button hidden if the app can’t be launched by the current
- * user. */
- if (gs_app_has_quirk (self->app, GS_APP_QUIRK_PARENTAL_NOT_LAUNCHABLE))
- return;
-
- /* only consider the shortcut button if the app is installed */
- switch (gs_app_get_state (self->app)) {
- case GS_APP_STATE_INSTALLED:
- case GS_APP_STATE_UPDATABLE:
- case GS_APP_STATE_UPDATABLE_LIVE:
- break;
- default:
- return;
- }
-
- add_shortcut_func =
- gs_plugin_loader_get_plugin_supported (self->plugin_loader,
- "gs_plugin_add_shortcut");
- remove_shortcut_func =
- gs_plugin_loader_get_plugin_supported (self->plugin_loader,
- "gs_plugin_remove_shortcut");
-
- has_shortcut = gs_app_has_quirk (self->app, GS_APP_QUIRK_HAS_SHORTCUT);
-
- if (add_shortcut_func) {
- gtk_widget_set_visible (self->button_details_add_shortcut,
- !has_shortcut || !remove_shortcut_func);
- gtk_widget_set_sensitive (self->button_details_add_shortcut,
- !has_shortcut);
- }
-
- if (remove_shortcut_func) {
- gtk_widget_set_visible (self->button_details_remove_shortcut,
- has_shortcut || !add_shortcut_func);
- gtk_widget_set_sensitive (self->button_details_remove_shortcut,
- has_shortcut);
- }
-}
-
static gboolean
app_has_pending_action (GsApp *app)
{
@@ -1151,8 +1095,6 @@ gs_details_page_refresh_all (GsDetailsPage *self)
break;
}
- gs_details_page_update_shortcut_button (self);
-
/* update progress */
gs_details_page_refresh_progress (self);
@@ -1952,24 +1894,6 @@ gs_details_page_app_launch_button_cb (GtkWidget *widget, GsDetailsPage *self)
gs_page_launch_app (GS_PAGE (self), self->app, self->cancellable);
}
-static void
-gs_details_page_app_add_shortcut_button_cb (GtkWidget *widget,
- GsDetailsPage *self)
-{
- g_autoptr(GCancellable) cancellable = g_cancellable_new ();
- g_set_object (&self->cancellable, cancellable);
- gs_page_shortcut_add (GS_PAGE (self), self->app, self->cancellable);
-}
-
-static void
-gs_details_page_app_remove_shortcut_button_cb (GtkWidget *widget,
- GsDetailsPage *self)
-{
- g_autoptr(GCancellable) cancellable = g_cancellable_new ();
- g_set_object (&self->cancellable, cancellable);
- gs_page_shortcut_remove (GS_PAGE (self), self->app, self->cancellable);
-}
-
static void
gs_details_page_review_response_cb (GtkDialog *dialog,
gint response,
@@ -2291,8 +2215,6 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_review_count);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, screenshot_carousel);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_details_launch);
- gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_details_add_shortcut);
- gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_details_remove_shortcut);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, links_stack);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, project_website_row);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, donate_row);
@@ -2346,8 +2268,6 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
gtk_widget_class_bind_template_callback (widget_class, gs_details_page_app_cancel_button_cb);
gtk_widget_class_bind_template_callback (widget_class, gs_details_page_more_reviews_button_cb);
gtk_widget_class_bind_template_callback (widget_class, gs_details_page_app_launch_button_cb);
- gtk_widget_class_bind_template_callback (widget_class, gs_details_page_app_add_shortcut_button_cb);
- gtk_widget_class_bind_template_callback (widget_class, gs_details_page_app_remove_shortcut_button_cb);
gtk_widget_class_bind_template_callback (widget_class, origin_popover_row_activated_cb);
}
diff --git a/src/gs-details-page.ui b/src/gs-details-page.ui
index cb2d55858..b3bbb498d 100644
--- a/src/gs-details-page.ui
+++ b/src/gs-details-page.ui
@@ -319,29 +319,6 @@
</child>
</object>
</child>
- <child>
- <object class="GtkButton" id="button_details_add_shortcut">
- <property name="visible">False</property>
- <property name="can_focus">True</property>
- <property name="use_underline">True</property>
- <property name="label" translatable="yes"
comments="Translators: A label for a button to add a shortcut to the selected application.">_Add
shortcut</property>
- <property name="valign">center</property>
- <signal name="clicked"
handler="gs_details_page_app_add_shortcut_button_cb"/>
- <style>
- <class name="suggested-action"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="button_details_remove_shortcut">
- <property name="visible">False</property>
- <property name="can_focus">True</property>
- <property name="use_underline">True</property>
- <property name="label" translatable="yes"
comments="Translators: A label for a button to remove a shortcut to the selected application.">Re_move
shortcut</property>
- <property name="valign">center</property>
- <signal name="clicked"
handler="gs_details_page_app_remove_shortcut_button_cb"/>
- </object>
- </child>
</object>
</child>
</object>
diff --git a/src/gs-page.c b/src/gs-page.c
index c9d5803bb..1b17023e5 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -562,62 +562,6 @@ gs_page_launch_app (GsPage *page, GsApp *app, GCancellable *cancellable)
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_job_action_finish (plugin_loader, res, &error)) {
- g_warning ("failed to add a shortcut to GsApp: %s", error->message);
- return;
- }
-}
-
-void
-gs_page_shortcut_add (GsPage *page, GsApp *app, GCancellable *cancellable)
-{
- GsPagePrivate *priv = gs_page_get_instance_private (page);
- g_autoptr(GsPluginJob) plugin_job = NULL;
- plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_ADD_SHORTCUT,
- "interactive", TRUE,
- "app", app,
- NULL);
- gs_plugin_loader_job_process_async (priv->plugin_loader, plugin_job,
- cancellable,
- gs_page_app_shortcut_added_cb,
- 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_job_action_finish (plugin_loader, res, &error)) {
- g_warning ("failed to remove the shortcut to GsApp: %s", error->message);
- return;
- }
-}
-
-void
-gs_page_shortcut_remove (GsPage *page, GsApp *app, GCancellable *cancellable)
-{
- GsPagePrivate *priv = gs_page_get_instance_private (page);
- g_autoptr(GsPluginJob) plugin_job = NULL;
- plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REMOVE_SHORTCUT,
- "interactive", TRUE,
- "app", app,
- NULL);
- gs_plugin_loader_job_process_async (priv->plugin_loader, plugin_job,
- cancellable,
- gs_page_app_shortcut_removed_cb,
- NULL);
-}
-
gboolean
gs_page_is_active (GsPage *page)
{
diff --git a/src/gs-page.h b/src/gs-page.h
index 851c933a1..a42034b59 100644
--- a/src/gs-page.h
+++ b/src/gs-page.h
@@ -56,12 +56,6 @@ void gs_page_update_app (GsPage *page,
void gs_page_launch_app (GsPage *page,
GsApp *app,
GCancellable *cancellable);
-void gs_page_shortcut_add (GsPage *page,
- GsApp *app,
- GCancellable *cancellable);
-void gs_page_shortcut_remove (GsPage *page,
- GsApp *app,
- GCancellable *cancellable);
void gs_page_switch_to (GsPage *page);
void gs_page_switch_from (GsPage *page);
void gs_page_scroll_up (GsPage *page);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]