[devhelp] KeywordModel: port to DhProfile and DhBookList
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] KeywordModel: port to DhProfile and DhBookList
- Date: Mon, 30 Apr 2018 18:11:39 +0000 (UTC)
commit 84ca467089fcef79f2f42ec1cb40923729c45a32
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Apr 30 14:55:37 2018 +0200
KeywordModel: port to DhProfile and DhBookList
devhelp/dh-keyword-model.c | 36 +++++++++++++++++++++---------------
devhelp/dh-keyword-model.h | 4 +++-
devhelp/dh-search-context.c | 3 ---
devhelp/dh-sidebar.c | 2 +-
docs/reference/api-breaks.xml | 15 +++++++++++++++
5 files changed, 40 insertions(+), 20 deletions(-)
---
diff --git a/devhelp/dh-keyword-model.c b/devhelp/dh-keyword-model.c
index eb3f491..6367e24 100644
--- a/devhelp/dh-keyword-model.c
+++ b/devhelp/dh-keyword-model.c
@@ -25,7 +25,7 @@
#include "dh-keyword-model.h"
#include <gtk/gtk.h>
#include "dh-book.h"
-#include "dh-book-manager.h"
+#include "dh-book-list.h"
#include "dh-search-context.h"
#include "dh-util-lib.h"
@@ -89,6 +89,7 @@ typedef struct {
} DhKeywordModelPrivate;
typedef struct {
+ DhBookList *book_list;
DhSearchContext *search_context;
const gchar *book_id;
const gchar *skip_book_id;
@@ -449,15 +450,13 @@ search_books (SearchSettings *settings,
guint max_hits,
DhLink **exact_link)
{
- DhBookManager *book_manager;
GList *books;
GList *l;
GQueue *ret;
ret = g_queue_new ();
- book_manager = dh_book_manager_get_singleton ();
- books = dh_book_manager_get_books (book_manager);
+ books = dh_book_list_get_books (settings->book_list);
for (l = books;
l != NULL && ret->length < max_hits;
@@ -493,10 +492,10 @@ search_books (SearchSettings *settings,
}
static GQueue *
-handle_book_id_only (DhSearchContext *search_context,
+handle_book_id_only (DhBookList *book_list,
+ DhSearchContext *search_context,
DhLink **exact_link)
{
- DhBookManager *book_manager;
GList *books;
GList *l;
GQueue *ret;
@@ -509,8 +508,7 @@ handle_book_id_only (DhSearchContext *search_context,
ret = g_queue_new ();
- book_manager = dh_book_manager_get_singleton ();
- books = dh_book_manager_get_books (book_manager);
+ books = dh_book_list_get_books (book_list);
for (l = books; l != NULL; l = l->next) {
DhBook *book = DH_BOOK (l->data);
@@ -559,6 +557,7 @@ handle_book_id_only (DhSearchContext *search_context,
*/
static GQueue *
keyword_model_search (DhKeywordModel *model,
+ DhBookList *book_list,
DhSearchContext *search_context,
DhLink **exact_link)
{
@@ -571,12 +570,13 @@ keyword_model_search (DhKeywordModel *model,
DhLink *other_books_exact_link = NULL;
GQueue *out;
- out = handle_book_id_only (search_context, exact_link);
+ out = handle_book_id_only (book_list, search_context, exact_link);
if (out != NULL)
return out;
out = g_queue_new ();
+ settings.book_list = book_list;
settings.search_context = search_context;
settings.book_id = priv->current_book_id;
settings.skip_book_id = NULL;
@@ -662,10 +662,10 @@ keyword_model_search (DhKeywordModel *model,
* @model: a #DhKeywordModel.
* @search_string: a search query.
* @current_book_id: (nullable): the ID of the book currently shown, or %NULL.
- * @language: (nullable): deprecated, must be %NULL.
+ * @profile: (nullable): a #DhProfile, or %NULL for the default profile.
*
- * Searches in the #DhBookManager the list of #DhLink's that correspond to
- * @search_string, and fills the @model with that list (erasing the previous
+ * Searches in the #DhBookList of @profile the list of #DhLink's that correspond
+ * to @search_string, and fills the @model with that list (erasing the previous
* content).
*
* Attention, when calling this function the @model needs to be disconnected
@@ -688,19 +688,25 @@ DhLink *
dh_keyword_model_filter (DhKeywordModel *model,
const gchar *search_string,
const gchar *current_book_id,
- const gchar *language)
+ DhProfile *profile)
{
DhKeywordModelPrivate *priv;
+ DhBookList *book_list;
DhSearchContext *search_context;
GQueue *new_links = NULL;
DhLink *exact_link = NULL;
g_return_val_if_fail (DH_IS_KEYWORD_MODEL (model), NULL);
g_return_val_if_fail (search_string != NULL, NULL);
- g_return_val_if_fail (language == NULL, NULL);
+ g_return_val_if_fail (profile == NULL || DH_IS_PROFILE (profile), NULL);
priv = dh_keyword_model_get_instance_private (model);
+ if (profile == NULL)
+ profile = dh_profile_get_default ();
+
+ book_list = dh_profile_get_book_list (profile);
+
g_free (priv->current_book_id);
priv->current_book_id = NULL;
@@ -716,7 +722,7 @@ dh_keyword_model_filter (DhKeywordModel *model,
else
priv->current_book_id = g_strdup (current_book_id);
- new_links = keyword_model_search (model, search_context, &exact_link);
+ new_links = keyword_model_search (model, book_list, search_context, &exact_link);
}
clear_links (model);
diff --git a/devhelp/dh-keyword-model.h b/devhelp/dh-keyword-model.h
index 7e97925..4dd0bfa 100644
--- a/devhelp/dh-keyword-model.h
+++ b/devhelp/dh-keyword-model.h
@@ -4,6 +4,7 @@
*
* Copyright (C) 2002 CodeFactory AB
* Copyright (C) 2002 Mikael Hallendal <micke imendio com>
+ * Copyright (C) 2018 Sébastien Wilmet <swilmet gnome org>
*
* Devhelp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
@@ -24,6 +25,7 @@
#include <glib-object.h>
#include <devhelp/dh-link.h>
+#include <devhelp/dh-profile.h>
G_BEGIN_DECLS
@@ -62,7 +64,7 @@ DhKeywordModel *dh_keyword_model_new (void);
DhLink * dh_keyword_model_filter (DhKeywordModel *model,
const gchar *search_string,
const gchar *current_book_id,
- const gchar *language);
+ DhProfile *profile);
G_END_DECLS
diff --git a/devhelp/dh-search-context.c b/devhelp/dh-search-context.c
index 6084e66..63cf8af 100644
--- a/devhelp/dh-search-context.c
+++ b/devhelp/dh-search-context.c
@@ -382,9 +382,6 @@ _dh_search_context_match_book (DhSearchContext *search,
g_return_val_if_fail (search != NULL, FALSE);
g_return_val_if_fail (DH_IS_BOOK (book), FALSE);
- if (!dh_book_get_enabled (book))
- return FALSE;
-
if (search->book_id == NULL)
return TRUE;
diff --git a/devhelp/dh-sidebar.c b/devhelp/dh-sidebar.c
index 9f057e8..f814801 100644
--- a/devhelp/dh-sidebar.c
+++ b/devhelp/dh-sidebar.c
@@ -161,7 +161,7 @@ search_idle_cb (gpointer user_data)
exact_link = dh_keyword_model_filter (priv->hitlist_model,
search_text,
book_id,
- NULL);
+ priv->profile);
gtk_tree_view_set_model (priv->hitlist_view,
GTK_TREE_MODEL (priv->hitlist_model));
diff --git a/docs/reference/api-breaks.xml b/docs/reference/api-breaks.xml
index adcbbe4..2f817fc 100644
--- a/docs/reference/api-breaks.xml
+++ b/docs/reference/api-breaks.xml
@@ -253,4 +253,19 @@
</listitem>
</itemizedlist>
</refsect1>
+
+ <refsect1>
+ <title>3.29.1 -> 3.29.2</title>
+ <itemizedlist>
+ <listitem>
+ <para>
+ The last parameter of
+ <link linkend="dh-keyword-model-filter">dh_keyword_model_filter()</link>
+ has been changed, it is no longer the language (a string, that
+ parameter was deprecated), it is a
+ <link linkend="DhProfile">DhProfile</link>.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </refsect1>
</part>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]