[gnome-characters/wip/properties: 4/9] libgc: Add accessor to character properties



commit 2621663719d92cbdfbb4acb5835811bc12f443a6
Author: Daiki Ueno <ueno gnu org>
Date:   Mon Feb 9 17:48:01 2015 +0900

    libgc: Add accessor to character properties

 lib/gc.c |   39 +++++++++++++++++++++++++++++++++++++++
 lib/gc.h |    3 +++
 2 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/lib/gc.c b/lib/gc.c
index 3473406..65467c2 100644
--- a/lib/gc.c
+++ b/lib/gc.c
@@ -403,6 +403,45 @@ gc_character_name (gunichar uc)
   return unicode_character_name (uc, buffer);
 }
 
+/**
+ * gc_character_category:
+ * @uc: a UCS-4 character
+ *
+ * Returns: (nullable): character category name of @uc.
+ */
+const gchar *
+gc_character_category (gunichar uc)
+{
+  uc_general_category_t category = uc_general_category (uc);
+  return uc_general_category_long_name (category);
+}
+
+/**
+ * gc_character_script:
+ * @uc: a UCS-4 character
+ *
+ * Returns: (nullable): the name of script which @uc belongs to.
+ */
+const gchar *
+gc_character_script (gunichar uc)
+{
+  const uc_script_t *script = uc_script (uc);
+  return script->name;
+}
+
+/**
+ * gc_character_group:
+ * @uc: a UCS-4 character
+ *
+ * Returns: (nullable): the name of Unicode block which @uc belongs to.
+ */
+const gchar *
+gc_character_block (gunichar uc)
+{
+  const uc_block_t *block = uc_block (uc);
+  return block->name;
+}
+
 G_DEFINE_BOXED_TYPE (GcSearchResult, gc_search_result,
                     g_array_ref, g_array_unref);
 
diff --git a/lib/gc.h b/lib/gc.h
index c784aa4..a35df9d 100644
--- a/lib/gc.h
+++ b/lib/gc.h
@@ -58,6 +58,9 @@ GcSearchResult *gc_search_finish          (GAsyncResult         *result,
                                            GError              **error);
 
 gchar          *gc_character_name         (gunichar              uc);
+const gchar    *gc_character_category     (gunichar              uc);
+const gchar    *gc_character_script       (gunichar              uc);
+const gchar    *gc_character_block        (gunichar              uc);
 
 /* GTK+ support.  gtk_clipboard_get() takes an GdkAtom as the first
    argument, but GdkAtom is not accessible through GI.  */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]