aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-06-30 13:01:02 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-06-30 13:01:02 +0800
commitc187a911c8926429946cc385fd5f7c8f0932d3e3 (patch)
tree820b56f0a68786d3576bf11c44341ce479978c73
parent028af9687710c33e977a17039988030a0607d25c (diff)
downloadgsoc2013-evolution-c187a911c8926429946cc385fd5f7c8f0932d3e3.tar
gsoc2013-evolution-c187a911c8926429946cc385fd5f7c8f0932d3e3.tar.gz
gsoc2013-evolution-c187a911c8926429946cc385fd5f7c8f0932d3e3.tar.bz2
gsoc2013-evolution-c187a911c8926429946cc385fd5f7c8f0932d3e3.tar.lz
gsoc2013-evolution-c187a911c8926429946cc385fd5f7c8f0932d3e3.tar.xz
gsoc2013-evolution-c187a911c8926429946cc385fd5f7c8f0932d3e3.tar.zst
gsoc2013-evolution-c187a911c8926429946cc385fd5f7c8f0932d3e3.zip
Do nothing if passed NULL. (e_completion_match_compare): Move the
2001-06-29 Jon Trowbridge <trow@ximian.com> * gal/e-text/e-completion-match.c (e_completion_match_unref): Do nothing if passed NULL. (e_completion_match_compare): Move the sort_major comparison out to make it the primary sort key (followed by score and then sort_minor). (e_completion_match_compare_alpha): Move the sort_major comparison out to make it the primary sort key. svn path=/trunk/; revision=10625
-rw-r--r--widgets/text/e-completion-match.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/widgets/text/e-completion-match.c b/widgets/text/e-completion-match.c
index a3e69cb2ed..cfc7c88cd7 100644
--- a/widgets/text/e-completion-match.c
+++ b/widgets/text/e-completion-match.c
@@ -69,12 +69,13 @@ e_completion_match_ref (ECompletionMatch *match)
void
e_completion_match_unref (ECompletionMatch *match)
{
- g_return_if_fail (match != NULL);
- g_return_if_fail (match->ref > 0);
+ if (match) {
+ g_return_if_fail (match->ref > 0);
- --match->ref;
- if (match->ref == 0) {
- e_completion_match_destroy (match);
+ --match->ref;
+ if (match->ref == 0) {
+ e_completion_match_destroy (match);
+ }
}
}
@@ -128,11 +129,11 @@ e_completion_match_compare (const ECompletionMatch *a, const ECompletionMatch *b
return a ? -1 : 1;
}
- /* Sort the scores high->low. */
- if ( (rv = (b->score > a->score) - (a->score > b->score)) )
+ if ( (rv = (b->sort_major < a->sort_major) - (a->sort_major < b->sort_major)) )
return rv;
- if ( (rv = (b->sort_major < a->sort_major) - (a->sort_major < b->sort_major)) )
+ /* Sort the scores high->low. */
+ if ( (rv = (b->score > a->score) - (a->score > b->score)) )
return rv;
if ( (rv = (b->sort_minor < a->sort_minor) - (a->sort_minor < b->sort_minor)) )
@@ -153,19 +154,18 @@ e_completion_match_compare_alpha (const ECompletionMatch *a, const ECompletionMa
return a ? -1 : 1;
}
+ /* The sort_major trumps everything. */
+ if ( (rv = (b->sort_major < a->sort_major) - (a->sort_major < b->sort_major)) )
+ return rv;
+
/* Sort the scores high->low. */
if ( (rv = (b->score > a->score) - (a->score > b->score)) )
return rv;
- /* When the match text is the same, we use the major and minor fields */
+ /* When the match text is the same, we use the minor fields */
rv2 = strcmp (a->match_text, b->match_text);
- if (!rv2) {
- if ( (rv = (b->sort_major < a->sort_major) - (a->sort_major < b->sort_major)) )
- return rv;
-
- if ( (rv = (b->sort_minor < a->sort_minor) - (a->sort_minor < b->sort_minor)) )
- return rv;
- }
+ if ( !rv2 && (rv = (b->sort_minor < a->sort_minor) - (a->sort_minor < b->sort_minor)) )
+ return rv;
return strcmp (a->menu_text, b->menu_text);
}