[gnome-software/wip/hughsie/xdg-app: 37/39] trivial: Split up the origin property into a raw and UI version



commit 7ffd3fbb70ca8df9abb6048712e40c165eccd694
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jan 18 13:14:28 2016 +0000

    trivial: Split up the origin property into a raw and UI version
    
    In the UI we want to show 'Fedora - Updates' but in the other plugins (like
    fedora-provenance) we need to match on the low-level ID.

 src/gs-app.c                              |   30 +++++++++++++++++++++++++++-
 src/gs-app.h                              |    3 ++
 src/gs-shell-details.c                    |    4 ++-
 src/gs-utils.c                            |    2 +-
 src/plugins/gs-plugin-packagekit-refine.c |    5 +--
 5 files changed, 37 insertions(+), 7 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index b0977cb..550b1a2 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -76,6 +76,7 @@ struct _GsApp
        GsAppQuality             licence_quality;
        gchar                   **menu_path;
        gchar                   *origin;
+       gchar                   *origin_ui;
        gchar                   *update_version;
        gchar                   *update_version_ui;
        gchar                   *update_details;
@@ -295,6 +296,8 @@ gs_app_to_string (GsApp *app)
        }
        if (app->origin != NULL && app->origin[0] != '\0')
                g_string_append_printf (str, "\torigin:\t%s\n", app->origin);
+       if (app->origin_ui != NULL && app->origin_ui[0] != '\0')
+               g_string_append_printf (str, "\torigin-ui:\t%s\n", app->origin_ui);
        if (app->rating != -1)
                g_string_append_printf (str, "\trating:\t%i\n", app->rating);
        if (app->rating_confidence != -1)
@@ -1482,8 +1485,7 @@ gs_app_get_origin (GsApp *app)
 /**
  * gs_app_set_origin:
  *
- * The origin is the original source of the application to show in the UI,
- * e.g. "Fedora"
+ * The origin is the original source of the application e.g. "fedora-updates"
  */
 void
 gs_app_set_origin (GsApp *app, const gchar *origin)
@@ -1494,6 +1496,30 @@ gs_app_set_origin (GsApp *app, const gchar *origin)
 }
 
 /**
+ * gs_app_get_origin_ui:
+ */
+const gchar *
+gs_app_get_origin_ui (GsApp *app)
+{
+       g_return_val_if_fail (GS_IS_APP (app), NULL);
+       return app->origin_ui;
+}
+
+/**
+ * gs_app_set_origin_ui:
+ *
+ * The origin is the original source of the application to show in the UI,
+ * e.g. "Fedora"
+ */
+void
+gs_app_set_origin_ui (GsApp *app, const gchar *origin_ui)
+{
+       g_return_if_fail (GS_IS_APP (app));
+       g_free (app->origin_ui);
+       app->origin_ui = g_strdup (origin_ui);
+}
+
+/**
  * gs_app_add_screenshot:
  */
 void
diff --git a/src/gs-app.h b/src/gs-app.h
index 0acf6bb..f57e4a0 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -168,6 +168,9 @@ void                 gs_app_set_menu_path           (GsApp          *app,
 const gchar    *gs_app_get_origin              (GsApp          *app);
 void            gs_app_set_origin              (GsApp          *app,
                                                 const gchar    *origin);
+const gchar    *gs_app_get_origin_ui           (GsApp          *app);
+void            gs_app_set_origin_ui           (GsApp          *app,
+                                                const gchar    *origin_ui);
 GPtrArray      *gs_app_get_screenshots         (GsApp          *app);
 void            gs_app_add_screenshot          (GsApp          *app,
                                                 AsScreenshot   *screenshot);
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index ea7c59e..06dbcff 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -698,7 +698,9 @@ gs_shell_details_refresh_all (GsShellDetails *self)
        }
 
        /* set the origin */
-       tmp = gs_app_get_origin (self->app);
+       tmp = gs_app_get_origin_ui (self->app);
+       if (tmp == NULL)
+               tmp = gs_app_get_origin (self->app);
        if (tmp == NULL || tmp[0] == '\0') {
                /* TRANSLATORS: this is where we don't know the origin of the
                 * application */
diff --git a/src/gs-utils.c b/src/gs-utils.c
index f83efee..ae9c284 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -255,7 +255,7 @@ gs_app_notify_unavailable (GsApp *app, GtkWindow *parent)
        gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), title->str);
 
        /* FIXME: get the URL somehow... */
-       origin_url = g_strdup_printf ("<a href=\"\">%s>/a>", gs_app_get_origin (app));
+       origin_url = g_strdup_printf ("<a href=\"\">%s</a>", gs_app_get_origin (app));
        body = g_string_new ("");
        if (hint & GS_APP_LICENCE_NONFREE) {
                g_string_append_printf (body,
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index c2f982c..f7a2c1b 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -162,11 +162,10 @@ gs_plugin_packagekit_set_origin (GsPlugin *plugin,
                                 const gchar *id)
 {
        const gchar *name;
+       gs_app_set_origin (app, id);
        name = g_hash_table_lookup (plugin->priv->sources, id);
        if (name != NULL)
-               gs_app_set_origin (app, name);
-       else
-               gs_app_set_origin (app, id);
+               gs_app_set_origin_ui (app, name);
 }
 
 static void


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