summaryrefslogtreecommitdiff
path: root/font-viewer
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2017-01-08 19:22:47 +0100
committerraveit65 <[email protected]>2017-02-17 12:28:22 +0100
commite6e8ad42a6a217c7124a71e568a343087e26440f (patch)
tree602fbe2f9c923d835645f735f8a2443d469d4bef /font-viewer
parent37052d6d0b5d63e7be05237e79eea38a8cb564e5 (diff)
downloadmate-control-center-e6e8ad42a6a217c7124a71e568a343087e26440f.tar.bz2
mate-control-center-e6e8ad42a6a217c7124a71e568a343087e26440f.tar.xz
Fontviewer: font-model, use g_utf8_collation_key to sort the model
So that we get the right sort order according to the current locale. Store the collation key in the model to avoid a performance hit. Taken from: https://git.gnome.org/browse/gnome-font-viewer/commit/?id=d6a5278
Diffstat (limited to 'font-viewer')
-rw-r--r--font-viewer/font-model.c21
-rw-r--r--font-viewer/font-model.h1
2 files changed, 14 insertions, 8 deletions
diff --git a/font-viewer/font-model.c b/font-viewer/font-model.c
index 8d2912ab..aeee40d1 100644
--- a/font-viewer/font-model.c
+++ b/font-viewer/font-model.c
@@ -342,7 +342,7 @@ ensure_font_list (FontViewModel *self)
FcObjectSet *os;
gint i;
FcChar8 *file;
- gchar *font_name;
+ gchar *font_name, *collation_key;
GdkPixbuf *pix;
if (self->priv->font_list) {
@@ -375,15 +375,20 @@ ensure_font_list (FontViewModel *self)
continue;
pix = get_fallback_icon ();
+ collation_key = g_utf8_collate_key (font_name, -1);
+
gtk_list_store_insert_with_values (GTK_LIST_STORE (self), NULL, -1,
COLUMN_NAME, font_name,
COLUMN_POINTER, self->priv->font_list->fonts[i],
COLUMN_PATH, file,
COLUMN_ICON, pix,
+ COLUMN_COLLATION_KEY, collation_key,
-1);
ensure_thumbnail (self, (const gchar *) file);
+
g_free (font_name);
+ g_free (collation_key);
g_object_unref (pix);
}
}
@@ -403,20 +408,20 @@ font_view_model_sort_func (GtkTreeModel *model,
GtkTreeIter *b,
gpointer user_data)
{
- gchar *name_a = NULL, *name_b = NULL;
+ gchar *key_a = NULL, *key_b = NULL;
int retval;
gtk_tree_model_get (model, a,
- COLUMN_NAME, &name_a,
+ COLUMN_COLLATION_KEY, &key_a,
-1);
gtk_tree_model_get (model, b,
- COLUMN_NAME, &name_b,
+ COLUMN_COLLATION_KEY, &key_b,
-1);
- retval = g_strcmp0 (name_a, name_b);
+ retval = g_strcmp0 (key_a, key_b);
- g_free (name_a);
- g_free (name_b);
+ g_free (key_a);
+ g_free (key_b);
return retval;
}
@@ -471,7 +476,7 @@ static void
font_view_model_init (FontViewModel *self)
{
GType types[NUM_COLUMNS] =
- { G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING, GDK_TYPE_PIXBUF };
+ { G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING };
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, FONT_VIEW_TYPE_MODEL, FontViewModelPrivate);
diff --git a/font-viewer/font-model.h b/font-viewer/font-model.h
index 10d7f8b0..f4ae79aa 100644
--- a/font-viewer/font-model.h
+++ b/font-viewer/font-model.h
@@ -35,6 +35,7 @@ typedef enum {
COLUMN_POINTER,
COLUMN_PATH,
COLUMN_ICON,
+ COLUMN_COLLATION_KEY,
NUM_COLUMNS
} FontViewModelColumns;