[gnome-software] Don't make the hardcoded fallback for popular apps conditional on flatpak



commit 16e2460e01e7c0011176b25d6047afc328ce098a
Author: Richard Hughes <richard hughsie com>
Date:   Mon May 23 14:33:52 2016 +0100

    Don't make the hardcoded fallback for popular apps conditional on flatpak

 src/plugins/Makefile.am                   |    6 +++
 src/plugins/gs-plugin-flatpak.c           |   30 --------------
 src/plugins/gs-plugin-hardcoded-popular.c |   63 +++++++++++++++++++++++++++++
 3 files changed, 69 insertions(+), 30 deletions(-)
---
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 49c1677..9deef91 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -33,6 +33,7 @@ plugin_LTLIBRARIES =                                  \
        libgs_plugin_dummy.la                           \
        libgs_plugin_dpkg.la                            \
        libgs_plugin_hardcoded-blacklist.la             \
+       libgs_plugin_hardcoded-popular.la               \
        libgs_plugin_menu-spec-categories.la            \
        libgs_plugin_menu-spec-refine.la                \
        libgs_plugin_fedora-distro-upgrades.la          \
@@ -218,6 +219,11 @@ libgs_plugin_hardcoded_blacklist_la_LIBADD = $(GS_PLUGIN_LIBS)
 libgs_plugin_hardcoded_blacklist_la_LDFLAGS = -module -avoid-version
 libgs_plugin_hardcoded_blacklist_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
 
+libgs_plugin_hardcoded_popular_la_SOURCES = gs-plugin-hardcoded-popular.c
+libgs_plugin_hardcoded_popular_la_LIBADD = $(GS_PLUGIN_LIBS)
+libgs_plugin_hardcoded_popular_la_LDFLAGS = -module -avoid-version
+libgs_plugin_hardcoded_popular_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
+
 if HAVE_UBUNTU_REVIEWS
 libgs_plugin_ubuntu_reviews_la_SOURCES =               \
        gs-plugin-ubuntu-reviews.c
diff --git a/src/plugins/gs-plugin-flatpak.c b/src/plugins/gs-plugin-flatpak.c
index cc30d2c..bb7cf8d 100644
--- a/src/plugins/gs-plugin-flatpak.c
+++ b/src/plugins/gs-plugin-flatpak.c
@@ -105,36 +105,6 @@ gs_app_set_flatpak_kind (GsApp *app, FlatpakRefKind kind)
                g_assert_not_reached ();
 }
 
-#ifndef HAVE_PACKAGEKIT
-gboolean
-gs_plugin_add_popular (GsPlugin *plugin,
-                      GsAppList *list,
-                      GCancellable *cancellable,
-                      GError **error)
-{
-       guint i;
-       const gchar *apps[] = {
-               "org.gnome.Builder.desktop",
-               "org.gnome.Calculator.desktop",
-               "org.gnome.clocks.desktop",
-               "org.gnome.Dictionary.desktop",
-               "org.gnome.Documents.desktop",
-               "org.gnome.Evince.desktop",
-               "org.gnome.gedit.desktop",
-               "org.gnome.Maps.desktop",
-               "org.gnome.Weather.desktop",
-               NULL };
-
-       /* just add all */
-       for (i = 0; apps[i] != NULL; i++) {
-               g_autoptr(GsApp) app = NULL;
-               app = gs_app_new (apps[i]);
-               gs_app_list_add (list, app);
-       }
-       return TRUE;
-}
-#endif
-
 static void
 gs_plugin_flatpak_changed_cb (GFileMonitor *monitor,
                              GFile *child,
diff --git a/src/plugins/gs-plugin-hardcoded-popular.c b/src/plugins/gs-plugin-hardcoded-popular.c
new file mode 100644
index 0000000..591abe6
--- /dev/null
+++ b/src/plugins/gs-plugin-hardcoded-popular.c
@@ -0,0 +1,63 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2016 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <config.h>
+
+#include <gnome-software.h>
+
+void
+gs_plugin_initialize (GsPlugin *plugin)
+{
+       /* let appstream add applications first */
+       gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "appstream");
+}
+
+gboolean
+gs_plugin_add_popular (GsPlugin *plugin,
+                      GsAppList *list,
+                      GCancellable *cancellable,
+                      GError **error)
+{
+       guint i;
+       const gchar *apps[] = {
+               "org.gnome.Builder.desktop",
+               "org.gnome.Calculator.desktop",
+               "org.gnome.clocks.desktop",
+               "org.gnome.Dictionary.desktop",
+               "org.gnome.Documents.desktop",
+               "org.gnome.Evince.desktop",
+               "org.gnome.gedit.desktop",
+               "org.gnome.Maps.desktop",
+               "org.gnome.Weather.desktop",
+               NULL };
+
+       /* we've already got enough popular apps */
+       if (gs_app_list_length (list) >= 5)
+               return TRUE;
+
+       /* just add all */
+       for (i = 0; apps[i] != NULL; i++) {
+               g_autoptr(GsApp) app = NULL;
+               app = gs_app_new (apps[i]);
+               gs_app_list_add (list, app);
+       }
+       return TRUE;
+}


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