[gnome-software] overview: Avoid featuring same category twice
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] overview: Avoid featuring same category twice
- Date: Mon, 18 Aug 2014 16:32:53 +0000 (UTC)
commit 3293244ffd6e96646e82845aec773a8292aa3f24
Author: Kalev Lember <kalevlember gmail com>
Date: Mon Aug 18 15:07:55 2014 +0200
overview: Avoid featuring same category twice
Don't show apps from the same category twice, first in the "Editor's
Picks" section and then in the "Recommended <category>" section as well.
It can look weird if we have a bunch of games in the "Recommended Games"
section, and then "Editor's Picks" end up being all games too.
src/gs-cmd.c | 1 +
src/gs-plugin-loader-sync.c | 2 ++
src/gs-plugin-loader-sync.h | 1 +
src/gs-plugin-loader.c | 10 +++++++++-
src/gs-plugin-loader.h | 1 +
src/gs-plugin.h | 2 ++
src/gs-shell-overview.c | 2 ++
src/plugins/gs-plugin-appstream.c | 20 ++++++++++++++++----
src/plugins/gs-plugin-dummy.c | 1 +
src/plugins/gs-plugin-moduleset.c | 1 +
10 files changed, 36 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-cmd.c b/src/gs-cmd.c
index 6e27af8..b8272cc 100644
--- a/src/gs-cmd.c
+++ b/src/gs-cmd.c
@@ -331,6 +331,7 @@ main (int argc, char **argv)
refine_flags,
NULL,
NULL,
+ NULL,
&error);
if (list == NULL) {
ret = FALSE;
diff --git a/src/gs-plugin-loader-sync.c b/src/gs-plugin-loader-sync.c
index 44c8df1..94c085c 100644
--- a/src/gs-plugin-loader-sync.c
+++ b/src/gs-plugin-loader-sync.c
@@ -255,6 +255,7 @@ GList *
gs_plugin_loader_get_popular (GsPluginLoader *plugin_loader,
GsPluginRefineFlags flags,
const gchar *category,
+ const gchar *category_exclude,
GCancellable *cancellable,
GError **error)
{
@@ -271,6 +272,7 @@ gs_plugin_loader_get_popular (GsPluginLoader *plugin_loader,
gs_plugin_loader_get_popular_async (plugin_loader,
flags,
category,
+ category_exclude,
cancellable,
(GAsyncReadyCallback) gs_plugin_loader_get_popular_finish_sync,
&helper);
diff --git a/src/gs-plugin-loader-sync.h b/src/gs-plugin-loader-sync.h
index ae9ce79..33771db 100644
--- a/src/gs-plugin-loader-sync.h
+++ b/src/gs-plugin-loader-sync.h
@@ -48,6 +48,7 @@ GList *gs_plugin_loader_get_sources (GsPluginLoader *plugin_loader,
GList *gs_plugin_loader_get_popular (GsPluginLoader *plugin_loader,
GsPluginRefineFlags flags,
const gchar *category,
+ const gchar *category_exclude,
GCancellable *cancellable,
GError **error);
GList *gs_plugin_loader_get_featured (GsPluginLoader *plugin_loader,
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 9338c4f..08eca51 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -449,6 +449,7 @@ gs_plugin_loader_run_popular_plugin (GsPluginLoader *plugin_loader,
const gchar *function_name,
GList **list,
const gchar *category,
+ const gchar *category_exclude,
GCancellable *cancellable,
GError **error)
{
@@ -469,7 +470,7 @@ gs_plugin_loader_run_popular_plugin (GsPluginLoader *plugin_loader,
plugin->name, function_name);
gs_profile_start (plugin_loader->priv->profile, profile_id);
g_assert (error == NULL || *error == NULL);
- ret = plugin_func (plugin, list, category, cancellable, error);
+ ret = plugin_func (plugin, list, category, category_exclude, cancellable, error);
if (!ret)
goto out;
out:
@@ -489,6 +490,7 @@ gs_plugin_loader_run_popular (GsPluginLoader *plugin_loader,
const gchar *function_name,
GsPluginRefineFlags flags,
const gchar *category,
+ const gchar *category_exclude,
GCancellable *cancellable,
GError **error)
{
@@ -523,6 +525,7 @@ gs_plugin_loader_run_popular (GsPluginLoader *plugin_loader,
function_name,
&list,
category,
+ category_exclude,
cancellable,
error);
if (!ret)
@@ -819,6 +822,7 @@ typedef struct {
gchar *value;
gchar *filename;
gchar *popular_category;
+ gchar *popular_category_exclude;
guint cache_age;
GsCategory *category;
GsApp *app;
@@ -838,6 +842,7 @@ gs_plugin_loader_free_async_state (GsPluginLoaderAsyncState *state)
g_free (state->filename);
g_free (state->popular_category);
+ g_free (state->popular_category_exclude);
g_free (state->value);
gs_plugin_list_free (state->list);
g_slice_free (GsPluginLoaderAsyncState, state);
@@ -1254,6 +1259,7 @@ gs_plugin_loader_get_popular_thread_cb (GTask *task,
"gs_plugin_add_popular",
state->flags,
state->popular_category,
+ state->popular_category_exclude,
cancellable,
&error);
if (state->list == NULL) {
@@ -1288,6 +1294,7 @@ void
gs_plugin_loader_get_popular_async (GsPluginLoader *plugin_loader,
GsPluginRefineFlags flags,
const gchar *category,
+ const gchar *category_exclude,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -1302,6 +1309,7 @@ gs_plugin_loader_get_popular_async (GsPluginLoader *plugin_loader,
state = g_slice_new0 (GsPluginLoaderAsyncState);
state->flags = flags;
state->popular_category = g_strdup (category);
+ state->popular_category_exclude = g_strdup (category_exclude);
/* run in a thread */
task = g_task_new (plugin_loader, cancellable, callback, user_data);
diff --git a/src/gs-plugin-loader.h b/src/gs-plugin-loader.h
index b8d219e..98ce88f 100644
--- a/src/gs-plugin-loader.h
+++ b/src/gs-plugin-loader.h
@@ -105,6 +105,7 @@ GList *gs_plugin_loader_get_sources_finish (GsPluginLoader
*plugin_loader,
void gs_plugin_loader_get_popular_async (GsPluginLoader *plugin_loader,
GsPluginRefineFlags flags,
const gchar *category,
+ const gchar *category_exclude,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index a73e883..ee37426 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -125,6 +125,7 @@ typedef gboolean (*GsPluginCategoryFunc) (GsPlugin *plugin,
typedef gboolean (*GsPluginPopularFunc) (GsPlugin *plugin,
GList **list,
const gchar *category,
+ const gchar *category_exclude,
GCancellable *cancellable,
GError **error);
typedef gboolean (*GsPluginResultsFunc) (GsPlugin *plugin,
@@ -207,6 +208,7 @@ gboolean gs_plugin_add_category_apps (GsPlugin *plugin,
gboolean gs_plugin_add_popular (GsPlugin *plugin,
GList **list,
const gchar *category,
+ const gchar *category_exclude,
GCancellable *cancellable,
GError **error);
gboolean gs_plugin_add_featured (GsPlugin *plugin,
diff --git a/src/gs-shell-overview.c b/src/gs-shell-overview.c
index 961fa3c..a57175d 100644
--- a/src/gs-shell-overview.c
+++ b/src/gs-shell-overview.c
@@ -367,6 +367,7 @@ gs_shell_overview_refresh (GsShellOverview *shell, gboolean scroll_up)
gs_plugin_loader_get_popular_async (priv->plugin_loader,
GS_PLUGIN_REFINE_FLAGS_DEFAULT,
NULL,
+ category_of_day,
priv->cancellable,
gs_shell_overview_get_popular_cb,
shell);
@@ -374,6 +375,7 @@ gs_shell_overview_refresh (GsShellOverview *shell, gboolean scroll_up)
gs_plugin_loader_get_popular_async (priv->plugin_loader,
GS_PLUGIN_REFINE_FLAGS_DEFAULT,
category_of_day,
+ NULL,
priv->cancellable,
gs_shell_overview_get_popular_rotating_cb,
shell);
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 06a0419..d3bb30a 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -956,8 +956,9 @@ gs_plugin_appstream_is_app_awesome (GsApp *app)
*/
static gboolean
gs_plugin_add_popular_from_category (GsPlugin *plugin,
- const gchar *category,
GList **list,
+ const gchar *category,
+ const gchar *category_exclude,
GHashTable *ignore_apps,
GError **error)
{
@@ -984,6 +985,8 @@ gs_plugin_add_popular_from_category (GsPlugin *plugin,
continue;
if (!as_app_has_category (item, category))
continue;
+ if (category_exclude != NULL && as_app_has_category (item, category_exclude))
+ continue;
/* add application */
app = gs_app_new (as_app_get_id_full (item));
@@ -1012,6 +1015,7 @@ out:
static gboolean
gs_plugin_add_popular_by_cat (GsPlugin *plugin,
GList **list,
+ const gchar *category_exclude,
GHashTable *ignore_apps,
GCancellable *cancellable,
GError **error)
@@ -1068,8 +1072,9 @@ gs_plugin_add_popular_by_cat (GsPlugin *plugin,
if (g_hash_table_lookup (ignore_cats, tmp) != NULL)
continue;
ret = gs_plugin_add_popular_from_category (plugin,
- tmp,
list,
+ tmp,
+ category_exclude,
ignore_apps,
error);
if (!ret)
@@ -1165,6 +1170,7 @@ gboolean
gs_plugin_add_popular (GsPlugin *plugin,
GList **list,
const gchar *category,
+ const gchar *category_exclude,
GCancellable *cancellable,
GError **error)
{
@@ -1197,7 +1203,12 @@ gs_plugin_add_popular (GsPlugin *plugin,
if (category == NULL) {
/* use category heuristic */
- ret = gs_plugin_add_popular_by_cat (plugin, list, ignore_apps, cancellable, error);
+ ret = gs_plugin_add_popular_by_cat (plugin,
+ list,
+ category_exclude,
+ ignore_apps,
+ cancellable,
+ error);
if (!ret)
goto out;
@@ -1207,8 +1218,9 @@ gs_plugin_add_popular (GsPlugin *plugin,
goto out;
} else {
ret = gs_plugin_add_popular_from_category (plugin,
- category,
list,
+ category,
+ NULL,
ignore_apps,
error);
if (!ret)
diff --git a/src/plugins/gs-plugin-dummy.c b/src/plugins/gs-plugin-dummy.c
index e24db15..e261453 100644
--- a/src/plugins/gs-plugin-dummy.c
+++ b/src/plugins/gs-plugin-dummy.c
@@ -147,6 +147,7 @@ gboolean
gs_plugin_add_popular (GsPlugin *plugin,
GList **list,
const gchar *category,
+ const gchar *category_exclude,
GCancellable *cancellable,
GError **error)
{
diff --git a/src/plugins/gs-plugin-moduleset.c b/src/plugins/gs-plugin-moduleset.c
index 284d1f8..4e0166b 100644
--- a/src/plugins/gs-plugin-moduleset.c
+++ b/src/plugins/gs-plugin-moduleset.c
@@ -102,6 +102,7 @@ gboolean
gs_plugin_add_popular (GsPlugin *plugin,
GList **list,
const gchar *category,
+ const gchar *category_exclude,
GCancellable *cancellable,
GError **error)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]