pango r2598 - in trunk: . docs docs/tmpl pango
- From: behdad svn gnome org
- To: svn-commits-list gnome org
- Subject: pango r2598 - in trunk: . docs docs/tmpl pango
- Date: Mon, 21 Apr 2008 20:26:10 +0100 (BST)
Author: behdad
Date: Mon Apr 21 19:26:10 2008
New Revision: 2598
URL: http://svn.gnome.org/viewvc/pango?rev=2598&view=rev
Log:
2008-04-21 Behdad Esfahbod <behdad gnome org>
Bug 511183 â Add pango_attr_type_get_name()
* docs/pango-sections.txt:
* docs/tmpl/text-attributes.sgml:
* pango/pango-attributes.c (pango_attr_type_register),
(pango_attr_type_get_name):
* pango/pango-attributes.h:
* pango/pango.def:
New public API:
pango_attr_type_get_name()
Modified:
trunk/ChangeLog
trunk/docs/pango-sections.txt
trunk/docs/tmpl/text-attributes.sgml
trunk/pango/pango-attributes.c
trunk/pango/pango-attributes.h
trunk/pango/pango.def
Modified: trunk/docs/pango-sections.txt
==============================================================================
--- trunk/docs/pango-sections.txt (original)
+++ trunk/docs/pango-sections.txt Mon Apr 21 19:26:10 2008
@@ -325,6 +325,7 @@
PangoAttrSize
pango_parse_markup
pango_attr_type_register
+pango_attr_type_get_name
pango_attribute_init
pango_attribute_copy
pango_attribute_equal
Modified: trunk/docs/tmpl/text-attributes.sgml
==============================================================================
--- trunk/docs/tmpl/text-attributes.sgml (original)
+++ trunk/docs/tmpl/text-attributes.sgml Mon Apr 21 19:26:10 2008
@@ -195,6 +195,15 @@
@Returns:
+<!-- ##### FUNCTION pango_attr_type_get_name ##### -->
+<para>
+
+</para>
+
+ type:
+ Returns:
+
+
<!-- ##### FUNCTION pango_attribute_init ##### -->
<para>
Modified: trunk/pango/pango-attributes.c
==============================================================================
--- trunk/pango/pango-attributes.c (original)
+++ trunk/pango/pango-attributes.c Mon Apr 21 19:26:10 2008
@@ -54,11 +54,14 @@
gboolean absolute);
+static GHashTable *name_map = NULL;
+
/**
* pango_attr_type_register:
- * @name: an identifier for the type (currently unused.)
+ * @name: an identifier for the type
*
- * Allocate a new attribute type ID.
+ * Allocate a new attribute type ID. The attribute type name can be accessed
+ * later by using pango_attr_type_get_name().
*
* Return value: the new type ID.
**/
@@ -66,8 +69,43 @@
pango_attr_type_register (const gchar *name)
{
static guint current_type = 0x1000000;
+ guint type = current_type++;
+
+ if (name)
+ {
+ if (G_UNLIKELY (!name_map))
+ name_map = g_hash_table_new (NULL, NULL);
+
+ g_hash_table_insert (name_map, GUINT_TO_POINTER (type), (gpointer) g_intern_string (name));
+ }
- return current_type++;
+ return type;
+}
+
+/**
+ * pango_attr_type_get_name:
+ * @type: an attribute type ID to fetch the name for
+ *
+ * Fetches the attribute type name passed in when registering the type using
+ * pango_attr_type_register().
+ *
+ * The returned value is an interned string (see g_intern_string() for what
+ * that means) that should not be modified or freed.
+ *
+ * Return value: the type ID name (which may be %NULL), or %NULL if @type is
+ * a built-in Pango attribute type or invalid.
+ *
+ * Since: 1.22
+ **/
+G_CONST_RETURN char *
+pango_attr_type_get_name (PangoAttrType type)
+{
+ const char *result = NULL;
+
+ if (name_map)
+ result = g_hash_table_lookup (name_map, GUINT_TO_POINTER ((guint) type));
+
+ return result;
}
/**
Modified: trunk/pango/pango-attributes.h
==============================================================================
--- trunk/pango/pango-attributes.h (original)
+++ trunk/pango/pango-attributes.h Mon Apr 21 19:26:10 2008
@@ -176,7 +176,8 @@
PangoFontDescription *desc;
};
-PangoAttrType pango_attr_type_register (const gchar *name);
+PangoAttrType pango_attr_type_register (const gchar *name);
+G_CONST_RETURN char * pango_attr_type_get_name (PangoAttrType type) G_GNUC_CONST;
void pango_attribute_init (PangoAttribute *attr,
const PangoAttrClass *klass);
Modified: trunk/pango/pango.def
==============================================================================
--- trunk/pango/pango.def (original)
+++ trunk/pango/pango.def Mon Apr 21 19:26:10 2008
@@ -39,6 +39,7 @@
pango_attr_style_new
pango_attr_type_get_type
pango_attr_type_register
+ pango_attr_type_get_name
pango_attr_underline_color_new
pango_attr_underline_new
pango_attr_variant_new
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]