[gnome-software/gnome-3-10] Do not show local applications without icons, names or comments



commit 8a1126a1598cb040535c743261f130b984a931f8
Author: Richard Hughes <richard hughsie com>
Date:   Fri Oct 11 19:54:52 2013 +0100

    Do not show local applications without icons, names or comments

 src/plugins/gs-plugin-datadir-apps.c |   45 ++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 21 deletions(-)
---
diff --git a/src/plugins/gs-plugin-datadir-apps.c b/src/plugins/gs-plugin-datadir-apps.c
index 40cd8b9..71da090 100644
--- a/src/plugins/gs-plugin-datadir-apps.c
+++ b/src/plugins/gs-plugin-datadir-apps.c
@@ -158,17 +158,14 @@ gs_plugin_datadir_apps_extract_desktop_data (GsPlugin *plugin,
        if (!ret)
                goto out;
 
-       /* create a new cache entry */
-       cache_item = g_slice_new0 (GsPluginDataDirAppsCacheItem);
-
        /* get desktop name */
        name = g_key_file_get_locale_string (key_file,
                                             G_KEY_FILE_DESKTOP_GROUP,
                                             G_KEY_FILE_DESKTOP_KEY_NAME,
                                             NULL,
                                             NULL);
-       if (name != NULL && name[0] != '\0')
-               cache_item->name = g_strdup (name);
+       if (name == NULL || name[0] == '\0')
+               goto out;
 
        /* get desktop summary */
        comment = g_key_file_get_locale_string (key_file,
@@ -176,33 +173,39 @@ gs_plugin_datadir_apps_extract_desktop_data (GsPlugin *plugin,
                                                G_KEY_FILE_DESKTOP_KEY_COMMENT,
                                                NULL,
                                                NULL);
-       if (comment != NULL && comment[0] != '\0')
-               cache_item->summary = g_strdup (comment);
+       if (comment == NULL || comment[0] == '\0')
+               goto out;
 
        /* get desktop icon */
        icon = g_key_file_get_string (key_file,
                                      G_KEY_FILE_DESKTOP_GROUP,
                                      G_KEY_FILE_DESKTOP_KEY_ICON,
                                      NULL);
+       if (icon == NULL)
+               goto out;
 
        /* set pixbuf */
-       if (icon != NULL) {
-               if (icon[0] == '/') {
-                       pixbuf = gdk_pixbuf_new_from_file_at_size (icon,
-                                                                  plugin->pixbuf_size,
-                                                                  plugin->pixbuf_size,
-                                                                  NULL);
-               } else {
-                       pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
-                                                          icon,
+       if (icon[0] == '/') {
+               pixbuf = gdk_pixbuf_new_from_file_at_size (icon,
+                                                          plugin->pixbuf_size,
                                                           plugin->pixbuf_size,
-                                                          GTK_ICON_LOOKUP_USE_BUILTIN |
-                                                          GTK_ICON_LOOKUP_FORCE_SIZE,
                                                           NULL);
-               }
+       } else {
+               pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                                  icon,
+                                                  plugin->pixbuf_size,
+                                                  GTK_ICON_LOOKUP_USE_BUILTIN |
+                                                  GTK_ICON_LOOKUP_FORCE_SIZE,
+                                                  NULL);
        }
-       if (pixbuf != NULL)
-               cache_item->pixbuf = g_object_ref (pixbuf);
+       if (pixbuf == NULL)
+               goto out;
+
+       /* create a new cache entry */
+       cache_item = g_slice_new0 (GsPluginDataDirAppsCacheItem);
+       cache_item->name = g_strdup (name);
+       cache_item->summary = g_strdup (comment);
+       cache_item->pixbuf = g_object_ref (pixbuf);
 
        /* set new id */
        basename = g_path_get_basename (desktop_file);


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