[gnome-software] Move local file basename parsing to UI code



commit c7a8b9ecf37668f7ff86504195b67e1b1778a2fc
Author: Kalev Lember <klember redhat com>
Date:   Fri Jan 4 20:26:53 2019 +0100

    Move local file basename parsing to UI code
    
    This ensures that it works the same for both the local files that
    packagekit handles (.rpm) and flatpak bundles (.flatpak).

 plugins/packagekit/gs-plugin-packagekit-local.c |  3 ---
 src/gs-details-page.c                           | 16 +++++++++++-----
 2 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit-local.c b/plugins/packagekit/gs-plugin-packagekit-local.c
index e82aced0..e517aa8c 100644
--- a/plugins/packagekit/gs-plugin-packagekit-local.c
+++ b/plugins/packagekit/gs-plugin-packagekit-local.c
@@ -135,7 +135,6 @@ gs_plugin_file_to_app (GsPlugin *plugin,
        PkDetails *item;
        g_autoptr(GsPackagekitHelper) helper = gs_packagekit_helper_new (plugin);
        g_autoptr(PkResults) results = NULL;
-       g_autofree gchar *basename = NULL;
        g_autofree gchar *content_type = NULL;
        g_autofree gchar *filename = NULL;
        g_autofree gchar *license_spdx = NULL;
@@ -203,7 +202,6 @@ gs_plugin_file_to_app (GsPlugin *plugin,
                             "invalid package-id: %s", package_id);
                return FALSE;
        }
-       basename = g_path_get_basename (filename);
        gs_app_set_management_plugin (app, "packagekit");
        gs_app_set_kind (app, AS_APP_KIND_GENERIC);
        gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE);
@@ -212,7 +210,6 @@ gs_plugin_file_to_app (GsPlugin *plugin,
        gs_app_set_summary (app, GS_APP_QUALITY_LOWEST,
                            pk_details_get_summary (item));
        gs_app_set_version (app, split[PK_PACKAGE_ID_VERSION]);
-       gs_app_set_origin (app, basename);
        gs_app_add_source (app, split[PK_PACKAGE_ID_NAME]);
        gs_app_add_source_id (app, package_id);
        gs_app_set_description (app, GS_APP_QUALITY_LOWEST,
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 7ba0585b..adb5bb0d 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1046,6 +1046,7 @@ gs_details_page_refresh_all (GsDetailsPage *self)
        guint64 updated;
        guint64 user_integration_bf;
        gboolean show_support_box = FALSE;
+       g_autofree gchar *origin = NULL;
        g_autoptr(GError) error = NULL;
 
        /* change widgets */
@@ -1190,15 +1191,20 @@ gs_details_page_refresh_all (GsDetailsPage *self)
        }
 
        /* set the origin */
-       tmp = gs_app_get_origin_hostname (self->app);
-       if (tmp == NULL)
-               tmp = gs_app_get_origin (self->app);
-       if (tmp == NULL || tmp[0] == '\0') {
+       origin = g_strdup (gs_app_get_origin_hostname (self->app));
+       if (origin == NULL)
+               origin = g_strdup (gs_app_get_origin (self->app));
+       if (origin == NULL) {
+               GFile *local_file = gs_app_get_local_file (self->app);
+               if (local_file != NULL)
+                       origin = g_file_get_basename (local_file);
+       }
+       if (origin == NULL || origin[0] == '\0') {
                /* TRANSLATORS: this is where we don't know the origin of the
                 * application */
                gtk_label_set_label (GTK_LABEL (self->label_details_origin_value), C_("origin", "Unknown"));
        } else {
-               gtk_label_set_label (GTK_LABEL (self->label_details_origin_value), tmp);
+               gtk_label_set_label (GTK_LABEL (self->label_details_origin_value), origin);
        }
 
        /* set MyLanguage kudo */


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