[gnome-software] When installing local packages set the summary and description



commit 03c98fce7d753e1b561104b39a2a9c90849c2e87
Author: Richard Hughes <richard hughsie com>
Date:   Wed Jan 29 11:02:54 2014 +0000

    When installing local packages set the summary and description
    
    In the case of a long multi-line description, use the first line for the summary
    and the rest as the description.

 src/plugins/gs-plugin-packagekit-refresh.c |   30 +++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/gs-plugin-packagekit-refresh.c b/src/plugins/gs-plugin-packagekit-refresh.c
index 0112b21..e45d19c 100644
--- a/src/plugins/gs-plugin-packagekit-refresh.c
+++ b/src/plugins/gs-plugin-packagekit-refresh.c
@@ -171,6 +171,33 @@ out:
 }
 
 /**
+ * gs_plugin_packagekit_refresh_set_text:
+ *
+ * The cases we have to deal with:
+ *  - Single line text, so all to summary
+ *  - Multiple line text, so first line to summary and the rest to description
+ */
+static void
+gs_plugin_packagekit_refresh_set_text (GsApp *app, const gchar *text)
+{
+       gchar *nl;
+       gchar *tmp;
+
+       /* look for newline */
+       tmp = g_strdup (text);
+       nl = g_strstr_len (tmp, -1, "\n");
+       if (nl == NULL) {
+               gs_app_set_summary (app, text);
+               goto out;
+       }
+       *nl = '\0';
+       gs_app_set_summary (app, tmp);
+       gs_app_set_description (app, nl + 1);
+out:
+       g_free (tmp);
+}
+
+/**
  * gs_plugin_refresh:
  */
 gboolean
@@ -234,7 +261,8 @@ gs_plugin_filename_to_app (GsPlugin *plugin,
        gs_app_set_metadata (app, "PackageKit::local-filename", filename);
        gs_app_add_source (app, split[PK_PACKAGE_ID_NAME]);
        gs_app_add_source_id (app, package_id);
-       gs_app_set_description (app, pk_details_get_description (item));
+       gs_plugin_packagekit_refresh_set_text (app,
+                                              pk_details_get_description (item));
        gs_app_set_url (app, GS_APP_URL_KIND_HOMEPAGE, pk_details_get_url (item));
        gs_app_set_size (app, pk_details_get_size (item));
        gs_app_set_licence (app, pk_details_get_license (item));


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