[gnome-font-viewer] font-model: set a fallback icon if we fail to read the thumbnail
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-font-viewer] font-model: set a fallback icon if we fail to read the thumbnail
- Date: Thu, 3 May 2012 17:37:00 +0000 (UTC)
commit 7ed08a3229c935fe2b56927e167c875db23f86c3
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu May 3 13:30:38 2012 -0400
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.
src/font-model.c | 25 +++++++++++++++++++++----
1 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/font-model.c b/src/font-model.c
index ba6b7b6..faafa42 100644
--- a/src/font-model.c
+++ b/src/font-model.c
@@ -22,7 +22,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
+ */
#include <string.h>
#include <errno.h>
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]