[gnome-software] Show the source label when no provenance or when there are duplicates
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Show the source label when no provenance or when there are duplicates
- Date: Thu, 14 Jul 2016 11:52:19 +0000 (UTC)
commit 81a2af97959dcdf9fb3ea43dbd5791ff3f525956
Author: Richard Hughes <richard hughsie com>
Date: Thu Jul 14 10:49:54 2016 +0100
Show the source label when no provenance or when there are duplicates
src/gs-app-row.c | 12 +++++++++++-
src/gs-app-row.h | 2 ++
src/gs-shell-installed.c | 2 ++
src/gs-shell-search.c | 37 +++++++++++++++++++++++++++++++++++++
4 files changed, 52 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index 79cda47..e3ad56f 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -55,6 +55,7 @@ typedef struct
gboolean show_folders;
gboolean show_buttons;
gboolean show_sandbox;
+ gboolean show_source;
gboolean show_codec;
gboolean show_update;
gboolean selectable;
@@ -330,7 +331,7 @@ gs_app_row_refresh (GsAppRow *app_row)
}
/* where did this app come from */
- if (!priv->show_update) {
+ if (priv->show_source) {
tmp = gs_app_get_origin_hostname (priv->app);
if (tmp != NULL) {
g_autofree gchar *origin_tmp = NULL;
@@ -752,6 +753,15 @@ gs_app_row_set_show_sandbox (GsAppRow *app_row, gboolean show_sandbox)
}
void
+gs_app_row_set_show_source (GsAppRow *app_row, gboolean show_source)
+{
+ GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
+
+ priv->show_source = show_source;
+ gs_app_row_refresh (app_row);
+}
+
+void
gs_app_row_set_show_codec (GsAppRow *app_row, gboolean show_codec)
{
GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
diff --git a/src/gs-app-row.h b/src/gs-app-row.h
index 8633acf..a39377d 100644
--- a/src/gs-app-row.h
+++ b/src/gs-app-row.h
@@ -50,6 +50,8 @@ void gs_app_row_set_show_buttons (GsAppRow *app_row,
gboolean show_buttons);
void gs_app_row_set_show_sandbox (GsAppRow *app_row,
gboolean show_sandbox);
+void gs_app_row_set_show_source (GsAppRow *app_row,
+ gboolean show_source);
void gs_app_row_set_show_codec (GsAppRow *app_row,
gboolean show_codec);
void gs_app_row_set_show_update (GsAppRow *app_row,
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index 6dfcc5d..804c8d7 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -155,6 +155,8 @@ gs_shell_installed_add_app (GsShellInstalled *self, GsApp *app)
gs_app_row_set_colorful (GS_APP_ROW (app_row), FALSE);
gs_app_row_set_show_folders (GS_APP_ROW (app_row), TRUE);
gs_app_row_set_show_buttons (GS_APP_ROW (app_row), TRUE);
+ gs_app_row_set_show_source (GS_APP_ROW (app_row),
+ !gs_app_has_quirk (app, AS_APP_QUIRK_PROVENANCE));
g_signal_connect (app_row, "button-clicked",
G_CALLBACK (gs_shell_installed_app_remove_cb), self);
g_signal_connect_object (app, "notify::state",
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index 8725066..07c9c53 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -91,6 +91,40 @@ gs_shell_search_waiting_cancel (GsShellSearch *self)
self->waiting_id = 0;
}
+static gboolean
+_gs_app_list_is_duplicate (GsAppList *list, GsApp *app)
+{
+ guint i;
+ GsApp *tmp;
+
+ for (i = 0; i < gs_app_list_length (list); i++) {
+ tmp = gs_app_list_index (list, i);
+
+ /* ignore if the same object */
+ if (app == tmp)
+ continue;
+
+ /* ignore with the same source */
+ if (g_strcmp0 (gs_app_get_origin_hostname (tmp),
+ gs_app_get_origin_hostname (app)) == 0) {
+ continue;
+ }
+
+ /* same D-Bus ID */
+ if (g_strcmp0 (gs_app_get_id_no_prefix (tmp),
+ gs_app_get_id_no_prefix (app)) == 0) {
+ return TRUE;
+ }
+
+ /* same name */
+ if (g_strcmp0 (gs_app_get_name (tmp),
+ gs_app_get_name (app)) == 0) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
static void
gs_shell_search_get_search_cb (GObject *source_object,
GAsyncResult *res,
@@ -135,6 +169,9 @@ gs_shell_search_get_search_cb (GObject *source_object,
app = gs_app_list_index (list, i);
app_row = gs_app_row_new (app);
gs_app_row_set_show_sandbox (GS_APP_ROW (app_row), TRUE);
+ gs_app_row_set_show_source (GS_APP_ROW (app_row),
+ !gs_app_has_quirk (app, AS_APP_QUIRK_PROVENANCE) ||
+ _gs_app_list_is_duplicate (list, app));
g_signal_connect (app_row, "button-clicked",
G_CALLBACK (gs_shell_search_app_row_clicked_cb),
self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]