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



commit ca542e0243a2c2d260cd32a31cd68ee1ce2230eb
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 9509233..e37d346 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -2826,3 +2826,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]