[devhelp] search: Fix searches with "page:" prefix
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] search: Fix searches with "page:" prefix
- Date: Tue, 14 Dec 2010 23:42:51 +0000 (UTC)
commit 74ac942a3e83a009bd75c1b423823d3c3fcad232
Author: Aleksander Morgado <aleksander lanedo com>
Date: Wed Dec 15 00:26:14 2010 +0100
search: Fix searches with "page:" prefix
src/dh-keyword-model.c | 41 ++++++++++++++++++++++-------------------
1 files changed, 22 insertions(+), 19 deletions(-)
---
diff --git a/src/dh-keyword-model.c b/src/dh-keyword-model.c
index 37bd24f..6f249fd 100644
--- a/src/dh-keyword-model.c
+++ b/src/dh-keyword-model.c
@@ -381,41 +381,44 @@ keyword_model_search (DhKeywordModel *model,
DhLink *link;
gboolean found;
gchar *name;
+ gchar *file_name;
link = l->data;
found = FALSE;
+ file_name = (case_sensitive ?
+ g_strdup (dh_link_get_file_name (link)) :
+ g_ascii_strdown (dh_link_get_file_name (link), -1));
+
if (page_id &&
- (dh_link_get_link_type (link) != DH_LINK_TYPE_PAGE &&
- !g_str_has_prefix (dh_link_get_file_name (link), page_filename_prefix))) {
+ (dh_link_get_link_type (link) == DH_LINK_TYPE_PAGE ||
+ !g_str_has_prefix (file_name, page_filename_prefix))) {
+ g_free (file_name);
continue;
}
- if (!case_sensitive) {
- name = g_ascii_strdown (dh_link_get_name (link), -1);
- } else {
- name = g_strdup (dh_link_get_name (link));
- }
+ name = (case_sensitive ?
+ g_strdup (dh_link_get_name (link)) :
+ g_ascii_strdown (dh_link_get_name (link), -1));
- if (!found) {
+ if (stringv[0] == NULL) {
+ /* means only a page was specified, no keyword */
+ if (g_strrstr (file_name, page_id))
+ found = TRUE;
+ } else {
gint i;
- if (stringv[0] == NULL) {
- /* means only a page was specified, no keyword */
- if (g_strrstr (dh_link_get_name(link), page_id))
- found = TRUE;
- } else {
- found = TRUE;
- for (i = 0; stringv[i] != NULL; i++) {
- if (!g_strrstr (name, stringv[i])) {
- found = FALSE;
- break;
- }
+ found = TRUE;
+ for (i = 0; stringv[i] != NULL; i++) {
+ if (!g_strrstr (name, stringv[i])) {
+ found = FALSE;
+ break;
}
}
}
g_free (name);
+ g_free (file_name);
if (found) {
/* Include in the new list. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]