[devhelp] Book: rename get_keywords() to get_links()



commit 97c465a38425337b7d1bc3da17a523d2ff51621b
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Dec 9 11:17:36 2017 +0100

    Book: rename get_keywords() to get_links()
    
    The function returns all DhLinks part of the book, not only "keywords".
    
    In the XML index file format version 2, there are <keyword> elements.
    But get_links() also returns DhLinks for the <book> and <sub> elements.
    So the name get_keywords() was misleading, for someone looking at a
    *.devhelp2 XML file.

 docs/reference/api-breaks.xml       |    6 ++++++
 docs/reference/devhelp-sections.txt |    2 +-
 src/dh-assistant-view.c             |    2 +-
 src/dh-book.c                       |   18 +++++++++---------
 src/dh-book.h                       |    2 +-
 src/dh-keyword-model.c              |    2 +-
 src/dh-window.c                     |   10 +++++-----
 7 files changed, 24 insertions(+), 18 deletions(-)
---
diff --git a/docs/reference/api-breaks.xml b/docs/reference/api-breaks.xml
index 3e066b6..bf87f12 100644
--- a/docs/reference/api-breaks.xml
+++ b/docs/reference/api-breaks.xml
@@ -180,6 +180,12 @@
           <link linkend="dh-link-get-book-title">dh_link_get_book_title()</link>.
         </para>
       </listitem>
+      <listitem>
+        <para>
+          <code>dh_book_get_keywords()</code> has been renamed to
+          <link linkend="dh-book-get-links">dh_book_get_links()</link>.
+        </para>
+      </listitem>
     </itemizedlist>
   </refsect1>
 </part>
diff --git a/docs/reference/devhelp-sections.txt b/docs/reference/devhelp-sections.txt
index dc2cdc0..1bbdac7 100644
--- a/docs/reference/devhelp-sections.txt
+++ b/docs/reference/devhelp-sections.txt
@@ -28,7 +28,7 @@ dh_assistant_view_get_type
 <FILE>dh-book</FILE>
 DhBook
 dh_book_new
-dh_book_get_keywords
+dh_book_get_links
 dh_book_get_completions
 dh_book_get_tree
 dh_book_get_id
diff --git a/src/dh-assistant-view.c b/src/dh-assistant-view.c
index d15fb7f..8b70132 100644
--- a/src/dh-assistant-view.c
+++ b/src/dh-assistant-view.c
@@ -468,7 +468,7 @@ dh_assistant_view_search (DhAssistantView *view,
              books = g_list_next (books)) {
                 GList *l;
 
-                for (l = dh_book_get_keywords (DH_BOOK (books->data));
+                for (l = dh_book_get_links (DH_BOOK (books->data));
                      l && exact_link == NULL;
                      l = l->next) {
                         DhLinkType type;
diff --git a/src/dh-book.c b/src/dh-book.c
index cb10226..b98c401 100644
--- a/src/dh-book.c
+++ b/src/dh-book.c
@@ -66,9 +66,9 @@ typedef struct {
         GNode *tree;
 
         /* List of DhLink*. */
-        GList *keywords;
+        GList *links;
 
-        /* Generated list of keyword completions (gchar*) in the book. */
+        /* Generated list of completions (gchar*) in the book. */
         GList *completions;
 
         /* Monitor of this specific book. */
@@ -112,7 +112,7 @@ dh_book_finalize (GObject *object)
 
         g_clear_object (&priv->index_file);
         _dh_util_free_book_tree (priv->tree);
-        g_list_free_full (priv->keywords, (GDestroyNotify)dh_link_unref);
+        g_list_free_full (priv->links, (GDestroyNotify)dh_link_unref);
         g_list_free_full (priv->completions, g_free);
         g_free (priv->language);
         g_free (priv->title);
@@ -296,7 +296,7 @@ dh_book_new (GFile *index_file)
                                   &priv->id,
                                   &language,
                                   &priv->tree,
-                                  &priv->keywords,
+                                  &priv->links,
                                   &error)) {
                 if (error != NULL) {
                         gchar *path;
@@ -345,7 +345,7 @@ dh_book_new (GFile *index_file)
 }
 
 /**
- * dh_book_get_keywords:
+ * dh_book_get_links:
  * @book: a #DhBook.
  *
  * Returns: (element-type DhLink) (transfer none) (nullable): the list of
@@ -353,7 +353,7 @@ dh_book_new (GFile *index_file)
  * disabled.
  */
 GList *
-dh_book_get_keywords (DhBook *book)
+dh_book_get_links (DhBook *book)
 {
         DhBookPrivate *priv;
 
@@ -361,7 +361,7 @@ dh_book_get_keywords (DhBook *book)
 
         priv = dh_book_get_instance_private (book);
 
-        return priv->enabled ? priv->keywords : NULL;
+        return priv->enabled ? priv->links : NULL;
 }
 
 /**
@@ -386,7 +386,7 @@ dh_book_get_completions (DhBook *book)
         if (priv->completions == NULL) {
                 GList *l;
 
-                for (l = priv->keywords; l != NULL; l = l->next) {
+                for (l = priv->links; l != NULL; l = l->next) {
                         DhLink *link = l->data;
                         gchar *str;
 
@@ -416,7 +416,7 @@ dh_book_get_completions (DhBook *book)
  * #DhLink's of type %DH_LINK_TYPE_BOOK or %DH_LINK_TYPE_PAGE. The other
  * #DhLink's are not contained in the tree. To have a list of
  * <emphasis>all</emphasis> #DhLink's part of the book, you need to call
- * dh_book_get_keywords().
+ * dh_book_get_links().
  *
  * Returns: (transfer none) (nullable): the tree of #DhLink's part of the @book,
  * or %NULL if the book is disabled.
diff --git a/src/dh-book.h b/src/dh-book.h
index 4834b42..d14d544 100644
--- a/src/dh-book.h
+++ b/src/dh-book.h
@@ -48,7 +48,7 @@ GType        dh_book_get_type        (void) G_GNUC_CONST;
 
 DhBook *     dh_book_new             (GFile *index_file);
 
-GList *      dh_book_get_keywords    (DhBook *book);
+GList *      dh_book_get_links       (DhBook *book);
 
 GList *      dh_book_get_completions (DhBook *book);
 
diff --git a/src/dh-keyword-model.c b/src/dh-keyword-model.c
index f2cfa31..ca5e912 100644
--- a/src/dh-keyword-model.c
+++ b/src/dh-keyword-model.c
@@ -442,7 +442,7 @@ keyword_model_search_book (DhBook          *book,
 
         ret = g_queue_new ();
 
-        for (l = dh_book_get_keywords (book);
+        for (l = dh_book_get_links (book);
              l != NULL && ret->length < max_hits;
              l = g_list_next (l)) {
                 DhLink   *link;
diff --git a/src/dh-window.c b/src/dh-window.c
index 35bff17..45987be 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -988,16 +988,16 @@ find_equivalent_local_uri (const gchar *uri)
 
         for (book_node = books; book_node != NULL; book_node = book_node->next) {
                 DhBook *cur_book = DH_BOOK (book_node->data);
-                GList *keywords;
-                GList *keyword_node;
+                GList *links;
+                GList *link_node;
 
                 if (g_strcmp0 (dh_book_get_id (cur_book), book_id) != 0)
                         continue;
 
-                keywords = dh_book_get_keywords (cur_book);
+                links = dh_book_get_links (cur_book);
 
-                for (keyword_node = keywords; keyword_node != NULL; keyword_node = keyword_node->next) {
-                        DhLink *cur_link = keyword_node->data;
+                for (link_node = links; link_node != NULL; link_node = link_node->next) {
+                        DhLink *cur_link = link_node->data;
 
                         if (dh_link_match_relative_url (cur_link, relative_url)) {
                                 local_uri = dh_link_get_uri (cur_link);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]