diff options
author | Mike Kestner <mkestner@src.gnome.org> | 2002-11-01 05:30:57 +0800 |
---|---|---|
committer | Mike Kestner <mkestner@src.gnome.org> | 2002-11-01 05:30:57 +0800 |
commit | 613453b1095e325149b8d37e5731d415e1d5f9bd (patch) | |
tree | 1c0d7f9be4d4a87aa67d8e185ae2bb23d02254b7 /widgets/table/e-table-extras.c | |
parent | ec242d6c30d7bf056c8f59710b8576c942f93583 (diff) | |
download | gsoc2013-evolution-613453b1095e325149b8d37e5731d415e1d5f9bd.tar gsoc2013-evolution-613453b1095e325149b8d37e5731d415e1d5f9bd.tar.gz gsoc2013-evolution-613453b1095e325149b8d37e5731d415e1d5f9bd.tar.bz2 gsoc2013-evolution-613453b1095e325149b8d37e5731d415e1d5f9bd.tar.lz gsoc2013-evolution-613453b1095e325149b8d37e5731d415e1d5f9bd.tar.xz gsoc2013-evolution-613453b1095e325149b8d37e5731d415e1d5f9bd.tar.zst gsoc2013-evolution-613453b1095e325149b8d37e5731d415e1d5f9bd.zip |
merging the gal-2 branch back to the trunk.
merging the gal-2 branch back to the trunk.
svn path=/trunk/; revision=18471
Diffstat (limited to 'widgets/table/e-table-extras.c')
-rw-r--r-- | widgets/table/e-table-extras.c | 62 |
1 files changed, 53 insertions, 9 deletions
diff --git a/widgets/table/e-table-extras.c b/widgets/table/e-table-extras.c index 9c5b5fb935..b3c0efa27c 100644 --- a/widgets/table/e-table-extras.c +++ b/widgets/table/e-table-extras.c @@ -1,5 +1,5 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* +/* * e-table-extras.c - Set of hash table sort of thingies. * Copyright 2000, 2001, Ximian, Inc. * @@ -64,15 +64,25 @@ ete_destroy (GtkObject *object) { ETableExtras *ete = E_TABLE_EXTRAS (object); - g_hash_table_foreach (ete->cells, (GHFunc) cell_hash_free, NULL); - g_hash_table_foreach (ete->compares, (GHFunc) g_free, NULL); - g_hash_table_foreach (ete->searches, (GHFunc) g_free, NULL); - g_hash_table_foreach (ete->pixbufs, (GHFunc) pixbuf_hash_free, NULL); + if (ete->cells) { + g_hash_table_foreach (ete->cells, (GHFunc) cell_hash_free, NULL); + g_hash_table_destroy (ete->cells); + } + + if (ete->compares) { + g_hash_table_foreach (ete->compares, (GHFunc) g_free, NULL); + g_hash_table_destroy (ete->compares); + } + + if (ete->searches) { + g_hash_table_foreach (ete->searches, (GHFunc) g_free, NULL); + g_hash_table_destroy (ete->searches); + } - g_hash_table_destroy (ete->cells); - g_hash_table_destroy (ete->compares); - g_hash_table_destroy (ete->searches); - g_hash_table_destroy (ete->pixbufs); + if (ete->pixbufs) { + g_hash_table_foreach (ete->pixbufs, (GHFunc) pixbuf_hash_free, NULL); + g_hash_table_destroy (ete->pixbufs); + } ete->cells = NULL; ete->compares = NULL; @@ -99,6 +109,40 @@ e_strint_compare(gconstpointer data1, gconstpointer data2) return g_int_compare(GINT_TO_POINTER(int1), GINT_TO_POINTER(int2)); } +/* UTF-8 strncasecmp - not optimized */ + +static gint +g_utf8_strncasecmp (const gchar *s1, + const gchar *s2, + guint n) +{ + gunichar c1, c2; + + g_return_val_if_fail (s1 != NULL && g_utf8_validate (s1, -1, NULL), 0); + g_return_val_if_fail (s2 != NULL && g_utf8_validate (s2, -1, NULL), 0); + + while (n && *s1 && *s2) + { + + n -= 1; + + c1 = g_unichar_tolower (g_utf8_get_char (s1)); + c2 = g_unichar_tolower (g_utf8_get_char (s2)); + + /* Collation is locale-dependent, so this totally fails to do the right thing. */ + if (c1 != c2) + return c1 < c2 ? -1 : 1; + + s1 = g_utf8_next_char (s1); + s2 = g_utf8_next_char (s2); + } + + if (n == 0 || (*s1 == '\0' && *s2 == '\0')) + return 0; + + return *s1 ? 1 : -1; +} + static gboolean e_string_search(gconstpointer haystack, const char *needle) { |