[gnome-software] Show the installed application source in the details view
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Show the installed application source in the details view
- Date: Sat, 8 Feb 2014 11:13:20 +0000 (UTC)
commit e8c38bffacf533b321d4802c62d479780cd76d18
Author: Richard Hughes <richard hughsie com>
Date: Fri Feb 7 23:12:10 2014 +0100
Show the installed application source in the details view
This matches the new mockups from Allan, although requires PackageKit from
master to return correct results.
src/gnome-software.ui | 38 +++++++++++++++++++++++++++++
src/gs-app.c | 30 ++++++++++++++++++++++-
src/gs-app.h | 5 +++-
src/gs-shell-details.c | 18 +++++++++++++
src/plugins/gs-plugin-packagekit-refine.c | 4 +++
5 files changed, 93 insertions(+), 2 deletions(-)
---
diff --git a/src/gnome-software.ui b/src/gnome-software.ui
index 9c2d6b5..d202bd1 100644
--- a/src/gnome-software.ui
+++ b/src/gnome-software.ui
@@ -1759,6 +1759,44 @@
<property name="height">1</property>
</packing>
</child>
+
+ <child>
+ <object class="GtkLabel" id="label_details_origin_title">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Source</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_details_origin_value">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="xalign">0</property>
+ <property name="label">Upstream</property>
+ <property name="ellipsize">end</property>
+ <property name="selectable">True</property>
+ <accessibility>
+ <relation target="label_details_origin_title" type="labelled-by"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+
<child>
<object class="GtkLabel" id="label_details_licence_title">
<property name="visible">True</property>
diff --git a/src/gs-app.c b/src/gs-app.c
index ec8c626..369edbe 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2013 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2013-2014 Richard Hughes <richard hughsie com>
* Copyright (C) 2013 Matthias Clasen <mclasen redhat com>
*
* Licensed under the GNU General Public License Version 2
@@ -76,6 +76,7 @@ struct GsAppPrivate
GHashTable *urls;
gchar *licence;
gchar *menu_path;
+ gchar *origin;
gchar *update_version;
gchar *update_version_ui;
gchar *update_details;
@@ -267,6 +268,8 @@ gs_app_to_string (GsApp *app)
g_string_append_printf (str, "\tsummary-missing:\t%s\n", priv->summary_missing);
if (priv->menu_path != NULL && priv->menu_path[0] != '\0')
g_string_append_printf (str, "\tmenu-path:\t%s\n", priv->menu_path);
+ if (priv->origin != NULL && priv->origin[0] != '\0')
+ g_string_append_printf (str, "\torigin:\t%s\n", priv->origin);
if (priv->rating != -1)
g_string_append_printf (str, "\trating:\t%i\n", priv->rating);
if (priv->rating_confidence != -1)
@@ -1130,6 +1133,30 @@ gs_app_set_menu_path (GsApp *app, const gchar *menu_path)
}
/**
+ * gs_app_get_origin:
+ */
+const gchar *
+gs_app_get_origin (GsApp *app)
+{
+ g_return_val_if_fail (GS_IS_APP (app), NULL);
+ return app->priv->origin;
+}
+
+/**
+ * gs_app_set_origin:
+ *
+ * The origin is the original source of the application to show in the UI,
+ * e.g. "Fedora"
+ */
+void
+gs_app_set_origin (GsApp *app, const gchar *origin)
+{
+ g_return_if_fail (GS_IS_APP (app));
+ g_free (app->priv->origin);
+ app->priv->origin = g_strdup (origin);
+}
+
+/**
* gs_app_add_screenshot:
*/
void
@@ -1771,6 +1798,7 @@ gs_app_finalize (GObject *object)
g_free (priv->icon);
g_free (priv->licence);
g_free (priv->menu_path);
+ g_free (priv->origin);
g_ptr_array_unref (priv->sources);
g_ptr_array_unref (priv->source_ids);
g_free (priv->project_group);
diff --git a/src/gs-app.h b/src/gs-app.h
index bcd7bda..c01c35e 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2013 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2013-2014 Richard Hughes <richard hughsie com>
*
* Licensed under the GNU General Public License Version 2
*
@@ -182,6 +182,9 @@ void gs_app_set_licence (GsApp *app,
const gchar *gs_app_get_menu_path (GsApp *app);
void gs_app_set_menu_path (GsApp *app,
const gchar *menu_path);
+const gchar *gs_app_get_origin (GsApp *app);
+void gs_app_set_origin (GsApp *app,
+ const gchar *origin);
GPtrArray *gs_app_get_screenshots (GsApp *app);
void gs_app_add_screenshot (GsApp *app,
GsScreenshot *screenshot);
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 97c62a8..c8d87f3 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -641,6 +641,24 @@ gs_shell_details_refresh_all (GsShellDetails *shell_details)
gtk_label_set_label (GTK_LABEL (widget), tmp);
}
+ /* set the origin */
+ tmp = gs_app_get_origin (priv->app);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
+ "label_details_origin_value"));
+ if (tmp == NULL || tmp[0] == '\0') {
+ /* TRANSLATORS: this is where we don't know the origin of the
+ * application */
+ gtk_label_set_label (GTK_LABEL (widget), _("Unknown"));
+ } else {
+ gtk_label_set_label (GTK_LABEL (widget), tmp);
+ }
+ gtk_widget_set_visible (widget,
+ gs_app_get_state (priv->app) == GS_APP_STATE_INSTALLED);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
+ "label_details_origin_title"));
+ gtk_widget_set_visible (widget,
+ gs_app_get_state (priv->app) == GS_APP_STATE_INSTALLED);
+
/* set the rating */
switch (gs_app_get_id_kind (priv->app)) {
case GS_APP_ID_KIND_WEBAPP:
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index fcdc121..87ac417 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -120,6 +120,7 @@ gs_plugin_packagekit_resolve_packages_app (GPtrArray *packages,
{
GPtrArray *sources;
PkPackage *package;
+ const gchar *data;
const gchar *pkgname;
gchar *tmp;
guint i, j;
@@ -140,6 +141,9 @@ gs_plugin_packagekit_resolve_packages_app (GPtrArray *packages,
switch (pk_package_get_info (package)) {
case GS_APP_STATE_INSTALLED:
number_installed++;
+ data = pk_package_get_data (package);
+ if (g_str_has_prefix (data, "installed:"))
+ gs_app_set_origin (app, data + 10);
break;
case GS_APP_STATE_AVAILABLE:
number_available++;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]