[gucharmap] chartable: Mark special script and block names in italic
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gucharmap] chartable: Mark special script and block names in italic
- Date: Tue, 6 Oct 2020 16:17:14 +0000 (UTC)
commit 78106773aee01cf111e287c19186a8fd1cfbd89a
Author: Christian Persch <chpe src gnome org>
Date: Tue Oct 6 18:17:08 2020 +0200
chartable: Mark special script and block names in italic
Fixes: https://gitlab.gnome.org/GNOME/gucharmap/-/issues/37
gucharmap/gucharmap-block-chapters-model.c | 10 ++++++++++
gucharmap/gucharmap-chapters-view.c | 1 +
gucharmap/gucharmap-private.h | 1 +
gucharmap/gucharmap-script-chapters-model.c | 16 ++++++++++++++++
4 files changed, 28 insertions(+)
---
diff --git a/gucharmap/gucharmap-block-chapters-model.c b/gucharmap/gucharmap-block-chapters-model.c
index 67fc23e1..ff41049a 100644
--- a/gucharmap/gucharmap-block-chapters-model.c
+++ b/gucharmap/gucharmap-block-chapters-model.c
@@ -29,6 +29,7 @@ enum
{
BLOCK_CHAPTERS_MODEL_ID = 0,
BLOCK_CHAPTERS_MODEL_LABEL = GUCHARMAP_CHAPTERS_MODEL_COLUMN_LABEL,
+ BLOCK_CHAPTERS_MODEL_LABEL_ATTRS = _GUCHARMAP_CHAPTERS_MODEL_COLUMN_LABEL_ATTRS,
BLOCK_CHAPTERS_MODEL_BLOCK,
BLOCK_CHAPTERS_MODEL_UNICODE_BLOCK_PTR,
BLOCK_CHAPTERS_MODEL_NUM_COLUMNS
@@ -62,9 +63,14 @@ gucharmap_block_chapters_model_init (GucharmapBlockChaptersModel *model)
GType types[] = {
G_TYPE_STRING,
G_TYPE_STRING,
+ PANGO_TYPE_ATTR_LIST,
G_TYPE_STRING,
G_TYPE_POINTER
};
+ PangoAttrList *attr_list;
+
+ attr_list = pango_attr_list_new ();
+ pango_attr_list_insert (attr_list, pango_attr_style_new (PANGO_STYLE_ITALIC));
gtk_list_store_set_column_types (store, G_N_ELEMENTS (types), types);
@@ -72,10 +78,13 @@ gucharmap_block_chapters_model_init (GucharmapBlockChaptersModel *model)
gtk_list_store_set (store, &iter,
BLOCK_CHAPTERS_MODEL_ID, "All",
BLOCK_CHAPTERS_MODEL_LABEL, _("All"),
+ BLOCK_CHAPTERS_MODEL_LABEL_ATTRS, attr_list,
BLOCK_CHAPTERS_MODEL_BLOCK, "",
BLOCK_CHAPTERS_MODEL_UNICODE_BLOCK_PTR, NULL,
-1);
+ pango_attr_list_unref (attr_list);
+
for (i = 0; i < G_N_ELEMENTS (unicode_blocks); i++)
{
static gchar block_start[12];
@@ -88,6 +97,7 @@ gucharmap_block_chapters_model_init (GucharmapBlockChaptersModel *model)
gtk_list_store_set (store, &iter,
BLOCK_CHAPTERS_MODEL_ID, block_name,
BLOCK_CHAPTERS_MODEL_LABEL, _(block_name),
+ BLOCK_CHAPTERS_MODEL_LABEL_ATTRS, NULL,
BLOCK_CHAPTERS_MODEL_BLOCK, block_start,
BLOCK_CHAPTERS_MODEL_UNICODE_BLOCK_PTR, unicode_blocks + i,
-1);
diff --git a/gucharmap/gucharmap-chapters-view.c b/gucharmap/gucharmap-chapters-view.c
index f71cc794..9e253e1c 100644
--- a/gucharmap/gucharmap-chapters-view.c
+++ b/gucharmap/gucharmap-chapters-view.c
@@ -66,6 +66,7 @@ gucharmap_chapters_view_init (GucharmapChaptersView *view)
column = priv->column = gtk_tree_view_column_new ();
gtk_tree_view_column_pack_start (column, cell, FALSE);
gtk_tree_view_column_add_attribute (column, cell, "text", GUCHARMAP_CHAPTERS_MODEL_COLUMN_LABEL);
+ gtk_tree_view_column_add_attribute (column, cell, "attributes",
_GUCHARMAP_CHAPTERS_MODEL_COLUMN_LABEL_ATTRS);
gtk_tree_view_append_column (tree_view, column);
selection = gtk_tree_view_get_selection (tree_view);
diff --git a/gucharmap/gucharmap-private.h b/gucharmap/gucharmap-private.h
index a7d6e928..e9416255 100644
--- a/gucharmap/gucharmap-private.h
+++ b/gucharmap/gucharmap-private.h
@@ -28,6 +28,7 @@ G_GNUC_INTERNAL void _gucharmap_intl_ensure_initialized (void);
G_GNUC_INTERNAL gboolean _gucharmap_unicode_has_nameslist_entry (gunichar uc);
+#define _GUCHARMAP_CHAPTERS_MODEL_COLUMN_LABEL_ATTRS (2)
struct _GucharmapChaptersModelPrivate {
GucharmapCodepointList *book_list;
diff --git a/gucharmap/gucharmap-script-chapters-model.c b/gucharmap/gucharmap-script-chapters-model.c
index fe5c5252..c06596fa 100644
--- a/gucharmap/gucharmap-script-chapters-model.c
+++ b/gucharmap/gucharmap-script-chapters-model.c
@@ -27,6 +27,14 @@
#include "gucharmap.h"
#include "gucharmap-private.h"
+static gboolean
+is_special_script (const char *script)
+{
+ return g_str_equal (script, "Common") ||
+ g_str_equal (script, "Inherited") ||
+ g_str_equal (script, "Unknown");
+}
+
static void
gucharmap_script_chapters_model_init (GucharmapScriptChaptersModel *model)
{
@@ -38,7 +46,12 @@ gucharmap_script_chapters_model_init (GucharmapScriptChaptersModel *model)
GType types[] = {
G_TYPE_STRING,
G_TYPE_STRING,
+ PANGO_TYPE_ATTR_LIST,
};
+ PangoAttrList *attr_list;
+
+ attr_list = pango_attr_list_new ();
+ pango_attr_list_insert (attr_list, pango_attr_style_new (PANGO_STYLE_ITALIC));
gtk_list_store_set_column_types (store, G_N_ELEMENTS (types), types);
@@ -49,9 +62,12 @@ gucharmap_script_chapters_model_init (GucharmapScriptChaptersModel *model)
gtk_list_store_set (store, &iter,
GUCHARMAP_CHAPTERS_MODEL_COLUMN_ID, unicode_scripts[i],
GUCHARMAP_CHAPTERS_MODEL_COLUMN_LABEL, _(unicode_scripts[i]),
+ _GUCHARMAP_CHAPTERS_MODEL_COLUMN_LABEL_ATTRS,
+ is_special_script (unicode_scripts[i]) ? attr_list : NULL,
-1);
}
g_free (unicode_scripts);
+ pango_attr_list_unref (attr_list);
chapters_model->priv->sort_column = GUCHARMAP_CHAPTERS_MODEL_COLUMN_LABEL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]