[gnome-builder/wip/chergert/layout] file-search: add symbolic variant hack



commit 081471e50fa04bd651028a10e08fe8aef7065ddc
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jul 5 21:41:55 2017 -0700

    file-search: add symbolic variant hack
    
    Using the symbolic API requires that we pass GIcon around
    everywhere. That is inconvenient and has the potential to
    load a bunch of objects I'd rather avoid.
    
    So this just cheats by adding -symoblic which is usually
    just fine.

 plugins/file-search/gb-file-search-index.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/plugins/file-search/gb-file-search-index.c b/plugins/file-search/gb-file-search-index.c
index 006e21e..bb61fec 100644
--- a/plugins/file-search/gb-file-search-index.c
+++ b/plugins/file-search/gb-file-search-index.c
@@ -336,6 +336,7 @@ gb_file_search_index_populate (GbFileSearchIndex *self,
           g_autofree gchar *escaped = NULL;
           g_autofree gchar *markup = NULL;
           g_autofree gchar *free_me = NULL;
+          g_autofree gchar *free_me_sym = NULL;
           const gchar *filename = match->key;
           const gchar *icon_name = "text-x-generic-symbolic";
           const gchar *content_type;
@@ -351,6 +352,13 @@ gb_file_search_index_populate (GbFileSearchIndex *self,
           if (content_type != NULL)
             icon_name = free_me = g_content_type_get_generic_icon_name (content_type);
 
+          /* Cheat and simply append -symbolic to the name.  This isn't
+           * strictly correct, but seems to work and doesn't require that we
+           * create lots of GIcon instances and pass them around.
+           */
+          if (!g_str_has_suffix (icon_name, "-symbolic"))
+            icon_name = free_me_sym = g_strdup_printf ("%s-symbolic", icon_name);
+
           result = g_object_new (GB_TYPE_FILE_SEARCH_RESULT,
                                  "context", context,
                                  "icon-name", icon_name,


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