[gucharmap] charmap: Also show compatibility decomposition
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gucharmap] charmap: Also show compatibility decomposition
- Date: Sat, 28 Jan 2017 20:22:03 +0000 (UTC)
commit afbace9788d771f3fd1586d288076b7d6601a9de
Author: Christian Persch <chpe gnome org>
Date: Sat Jan 28 21:21:01 2017 +0100
charmap: Also show compatibility decomposition
But only if it is different from the canonical decomposition.
gucharmap/gucharmap-charmap.c | 36 +++++++++++++++++++++++++++++-------
1 files changed, 29 insertions(+), 7 deletions(-)
---
diff --git a/gucharmap/gucharmap-charmap.c b/gucharmap/gucharmap-charmap.c
index 24fede2..ba0c17e 100644
--- a/gucharmap/gucharmap-charmap.c
+++ b/gucharmap/gucharmap-charmap.c
@@ -515,23 +515,43 @@ insert_heading (GucharmapCharmap *charmap,
}
static void
-conditionally_insert_canonical_decomposition (GucharmapCharmap *charmap,
- GtkTextBuffer *buffer,
- GtkTextIter *iter,
- gunichar uc)
+conditionally_insert_decomposition (GucharmapCharmap *charmap,
+ GtkTextBuffer *buffer,
+ GtkTextIter *iter,
+ gunichar uc,
+ gboolean compat)
{
gunichar decomposition[G_UNICHAR_MAX_DECOMPOSITION_LENGTH];
gsize result_len, i;
result_len = g_unichar_fully_decompose (uc,
- FALSE /* perform canonical decomposition */,
+ compat,
decomposition,
G_N_ELEMENTS (decomposition));
if (result_len == 1)
return;
- gtk_text_buffer_insert (buffer, iter, _("Canonical decomposition:"), -1);
+ /* Only insert compat decomp if different from canonical decomp */
+ if (compat) {
+ gunichar canonical[G_UNICHAR_MAX_DECOMPOSITION_LENGTH];
+ gsize canonical_len;
+
+ canonical_len = g_unichar_fully_decompose (uc,
+ FALSE /* canonical */,
+ canonical,
+ G_N_ELEMENTS (canonical));
+
+ if (canonical_len == result_len &&
+ memcmp (decomposition, canonical, result_len * sizeof (gunichar)) == 0)
+ return;
+ }
+
+ gtk_text_buffer_insert (buffer, iter,
+ compat
+ ? _("Compatibility decomposition:")
+ : _("Canonical decomposition:"),
+ -1);
gtk_text_buffer_insert (buffer, iter, " ", -1);
insert_codepoint (charmap, buffer, iter, decomposition[0]);
@@ -600,7 +620,9 @@ set_details (GucharmapCharmap *charmap,
gucharmap_get_unicode_category_name (uc));
/* canonical decomposition */
- conditionally_insert_canonical_decomposition (charmap, buffer, &iter, uc);
+ conditionally_insert_decomposition (charmap, buffer, &iter, uc, FALSE);
+ /* compatibility decomposition */
+ conditionally_insert_decomposition (charmap, buffer, &iter, uc, TRUE);
/* representations */
if (g_unichar_break_type(uc) != G_UNICODE_BREAK_SURROGATE)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]