[devhelp/wip/swilmet/misc-improvements] link: sort pages before other link types
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp/wip/swilmet/misc-improvements] link: sort pages before other link types
- Date: Sun, 14 Jun 2015 10:01:36 +0000 (UTC)
commit 5a1d1437f976e7168163e5cfc7bc133ba5c6ffdc
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Jun 14 11:50:12 2015 +0200
link: sort pages before other link types
Before this commit, the g_list_sort() in keyword_model_search_books()
worked by chance. When keyword_model_search_books() has been modified to
use a GQueue, and that elements are pushed on the tail instead of being
prepended, it has changed the order of some equal symbols.
But we want page links before other link types, for symbols with the
same name. For example "GObject" can refer to a page, or a
typedef/struct.
https://bugzilla.gnome.org/show_bug.cgi?id=749797
src/dh-link.c | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/src/dh-link.c b/src/dh-link.c
index f67788b..2f5b13c 100644
--- a/src/dh-link.c
+++ b/src/dh-link.c
@@ -118,6 +118,7 @@ dh_link_compare (gconstpointer a,
DhLink *la = (DhLink *) a;
DhLink *lb = (DhLink *) b;
gint flags_diff;
+ gint diff;
/* Sort deprecated hits last. */
flags_diff = (la->flags & DH_LINK_FLAGS_DEPRECATED) -
@@ -132,8 +133,26 @@ dh_link_compare (gconstpointer a,
if (G_UNLIKELY (!lb->name_collation_key))
lb->name_collation_key = g_utf8_collate_key (lb->name, -1);
- return strcmp (la->name_collation_key,
+ diff = strcmp (la->name_collation_key,
lb->name_collation_key);
+
+ /* For the same names, sort page links before other links. The page is
+ * more important than a symbol (typically contained in that page).
+ */
+ if (diff == 0) {
+ if (la->type == lb->type)
+ return 0;
+
+ if (la->type == DH_LINK_TYPE_PAGE)
+ return -1;
+
+ if (lb->type == DH_LINK_TYPE_PAGE)
+ return 1;
+
+ return 0;
+ }
+
+ return diff;
}
DhLink *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]