[glib/wip/gdesktopappinfo: 2/7] Add new callback types for sorting strings



commit d4b800505e351094960a277f7497cc67767ef01e
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Sep 19 13:05:46 2013 -0400

    Add new callback types for sorting strings
    
    Add GStringCompareFunc and GStringCompareDataFunc for bindable
    alternatives to GCompareFunc and GCompareDataFunc.

 glib/gstrfuncs.c |   30 ++++++++++++++++++++++++++++++
 glib/gstrfuncs.h |    6 ++++++
 2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index 4fcd91c..b675f24 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -2830,3 +2830,33 @@ g_strv_length (gchar **str_array)
 
   return i;
 }
+
+/**
+ * GStringCompareFunc:
+ * @a: the first string
+ * @b: the second string
+ *
+ * This callback has the signature of strcmp().  This appears as a
+ * parameter to functions that want to perform operations on sorted
+ * lists of strings (either sorting or lookup).
+ *
+ * Often, strcmp() will be the correct function, but it may be desirable
+ * to sort strings in other ways.
+ *
+ * Returns: a value less than, equal to, or greater than 0
+ *
+ * Since: 2.40
+ */
+/**
+ * GStringCompareDataFunc:
+ * @a: the first string
+ * @b: the second string
+ * @user_data: user data
+ *
+ * This is the same as #GStringCompareFunc but it accepts a user_data
+ * parameter.
+ *
+ * Returns: a value less than, equal to, or greater than 0
+ *
+ * Since: 2.40
+ **/
diff --git a/glib/gstrfuncs.h b/glib/gstrfuncs.h
index 510623a..b1fec46 100644
--- a/glib/gstrfuncs.h
+++ b/glib/gstrfuncs.h
@@ -37,6 +37,12 @@
 
 G_BEGIN_DECLS
 
+typedef gint (*GStringCompareFunc)          (const gchar   *a,
+                                             const gchar   *b);
+typedef gint (*GStringCompareDataFunc)      (const gchar   *a,
+                                             const gchar   *b,
+                                             gpointer       user_data);
+
 /* Functions like the ones in <ctype.h> that are not affected by locale. */
 typedef enum {
   G_ASCII_ALNUM  = 1 << 0,


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