From a81325f89569dbdae4bb7c716958721c4412c91b Mon Sep 17 00:00:00 2001 From: raveit65 Date: Sun, 8 Jan 2017 18:49:44 +0100 Subject: Fontviewer: font-model, set a fallback icon if we fail to read the thumbnail In case we fail to read the thumbnail, set the fallback icon instead of just returning. taken from: https://git.gnome.org/browse/gnome-font-viewer/commit/?id=7ed08a3 --- font-viewer/font-model.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/font-viewer/font-model.c b/font-viewer/font-model.c index 5013d451..13dc94ca 100644 --- a/font-viewer/font-model.c +++ b/font-viewer/font-model.c @@ -239,6 +239,14 @@ typedef struct { gchar *font_path; } LoadThumbnailData; +static void +load_thumbnail_data_free (LoadThumbnailData *data) +{ + g_object_unref (data->self); + g_free (data->font_path); + g_slice_free (LoadThumbnailData, data); +} + static void thumbnail_ready_cb (GObject *source, GAsyncResult *res, @@ -300,6 +308,7 @@ pixbuf_async_ready_cb (GObject *source, LoadThumbnailData *data = user_data; GdkPixbuf *pix; GtkTreeIter iter; + GFile *file; pix = gdk_pixbuf_new_from_stream_finish (res, NULL); @@ -310,11 +319,13 @@ pixbuf_async_ready_cb (GObject *source, -1); g_object_unref (pix); + } else { + file = g_file_new_for_path (data->font_path); + set_fallback_icon (data->self, file); + g_object_unref (file); } - g_object_unref (data->self); - g_free (data->font_path); - g_slice_free (LoadThumbnailData, data); + load_thumbnail_data_free (data); } static void @@ -333,6 +344,9 @@ thumb_file_read_async_ready_cb (GObject *source, 128, 128, TRUE, NULL, pixbuf_async_ready_cb, data); g_object_unref (is); + } else { + set_fallback_icon (data->self, G_FILE (source)); + load_thumbnail_data_free (data); } } @@ -416,6 +430,9 @@ ensure_font_list (FontViewModel *self) FcPatternGetString (self->priv->font_list->fonts[i], FC_FILE, 0, &file); font_name = font_utils_get_font_name_for_file (self->priv->library, (const gchar *) file); + if (!font_name) + continue; + gtk_list_store_append (GTK_LIST_STORE (self), &iter); gtk_list_store_set (GTK_LIST_STORE (self), &iter, COLUMN_NAME, font_name, -- cgit v1.2.1