summaryrefslogtreecommitdiff
path: root/font-viewer
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2017-01-08 18:49:44 +0100
committerraveit65 <[email protected]>2017-02-17 12:28:22 +0100
commita81325f89569dbdae4bb7c716958721c4412c91b (patch)
treef033a4f73f96e0bfb86c6ab4af6017f73212224f /font-viewer
parentd77ff1f0f14f2b05367fa8101b5621ef5f615c66 (diff)
downloadmate-control-center-a81325f89569dbdae4bb7c716958721c4412c91b.tar.bz2
mate-control-center-a81325f89569dbdae4bb7c716958721c4412c91b.tar.xz
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
Diffstat (limited to 'font-viewer')
-rw-r--r--font-viewer/font-model.c23
1 files 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
@@ -240,6 +240,14 @@ typedef struct {
} 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,
gpointer user_data)
@@ -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,