summaryrefslogtreecommitdiff
path: root/font-viewer
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2017-01-08 17:46:15 +0100
committerraveit65 <[email protected]>2017-02-17 12:28:22 +0100
commitc67f9e98c102a579271dcf549db6ef5ae600901a (patch)
tree8edd3ab8ab185f8b34dce162ba0da3f05db38ef4 /font-viewer
parentd936cb03dd2f88b68ce60ce5fb7ac9698180c662 (diff)
downloadmate-control-center-c67f9e98c102a579271dcf549db6ef5ae600901a.tar.bz2
mate-control-center-c67f9e98c102a579271dcf549db6ef5ae600901a.tar.xz
Fontviewer: font-model: set a fallback icon if we fail thumbnailing the font file
taken from: https://git.gnome.org/browse/gnome-font-viewer/commit/?id=a244951
Diffstat (limited to 'font-viewer')
-rw-r--r--font-viewer/font-model.c57
1 files changed, 46 insertions, 11 deletions
diff --git a/font-viewer/font-model.c b/font-viewer/font-model.c
index 64db8660..6681b842 100644
--- a/font-viewer/font-model.c
+++ b/font-viewer/font-model.c
@@ -98,6 +98,8 @@ create_thumbnail (GIOSchedulerJob *job,
}
else
{
+ mate_desktop_thumbnail_factory_create_failed_thumbnail (factory,
+ uri, (time_t) mtime);
g_simple_async_result_set_op_res_gboolean (result, FALSE);
}
@@ -203,19 +205,51 @@ thumbnail_ready_cb (GObject *source,
gpointer user_data)
{
FontViewModel *self = user_data;
- gboolean result;
gchar *path;
GFile *file;
- result = gd_queue_thumbnail_job_for_file_finish (G_ASYNC_RESULT (res));
+ gd_queue_thumbnail_job_for_file_finish (G_ASYNC_RESULT (res));
+ file = G_FILE (source);
+ path = g_file_get_path (file);
+ ensure_thumbnail (self, path);
- if (result) {
- file = G_FILE (source);
- path = g_file_get_path (file);
- ensure_thumbnail (self, path);
+ g_free (path);
+}
- g_free (path);
- }
+static void
+set_fallback_icon (FontViewModel *self,
+ GFile *file)
+{
+ GtkTreeIter iter;
+ GtkIconTheme *icon_theme;
+ GtkIconInfo *icon_info;
+ GdkPixbuf *pix;
+ gchar *path;
+ GIcon *icon = NULL;
+
+ icon_theme = gtk_icon_theme_get_default ();
+ icon = g_content_type_get_icon ("application/x-font-ttf");
+ icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon,
+ 128, GTK_ICON_LOOKUP_GENERIC_FALLBACK);
+ g_object_unref (icon);
+
+ if (!icon_info)
+ return;
+
+ pix = gtk_icon_info_load_icon (icon_info, NULL);
+ gtk_icon_info_free (icon_info);
+
+ if (!pix)
+ return;
+
+ path = g_file_get_path (file);
+ if (font_view_model_get_iter_for_file (self, path, &iter))
+ gtk_list_store_set (GTK_LIST_STORE (self), &iter,
+ COLUMN_ICON, pix,
+ -1);
+
+ g_free (path);
+ g_object_unref (pix);
}
static void
@@ -277,10 +311,11 @@ ensure_thumbnail (FontViewModel *self,
G_FILE_QUERY_INFO_NONE,
NULL, NULL);
- if (!info)
- goto out;
- if (g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED))
+ if (!info ||
+ g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED)) {
+ set_fallback_icon (self, file);
goto out;
+ }
thumb_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
if (thumb_path)