[devhelp] BookManager: remove dead code and remove DhLanguage
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] BookManager: remove dead code and remove DhLanguage
- Date: Fri, 29 Dec 2017 18:44:42 +0000 (UTC)
commit db83bca14214feb78442ba78c70054b8e606145c
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Dec 29 19:23:51 2017 +0100
BookManager: remove dead code and remove DhLanguage
All of that is dead code, once the DhBookManager ::language-enabled and
::language-disabled have been removed (see previous commit).
That code contained a bug, see:
https://bugzilla.gnome.org/show_bug.cgi?id=791127
(a failed assertion), so now it is fixed.
DhLanguage was used only internally by DhBookManager. DhBookManager
didn't expose the priv->languages instance variable, it was used only to
send the signals, but the signals were not used.
docs/reference/Makefile.am | 1 -
src/Makefile.am | 2 -
src/dh-book-manager.c | 61 +-------------------
src/dh-book-manager.h | 1 +
src/dh-language.c | 137 --------------------------------------------
src/dh-language.h | 57 ------------------
6 files changed, 2 insertions(+), 257 deletions(-)
---
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index de1f5be..7854955 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -50,7 +50,6 @@ IGNORE_HFILES = \
dh-app.h \
dh-assistant.h \
dh-error.h \
- dh-language.h \
dh-parser.h \
dh-preferences.h \
dh-settings.h \
diff --git a/src/Makefile.am b/src/Makefile.am
index 6603c67..574e80f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,7 +34,6 @@ libdevhelp_public_c_files = \
libdevhelp_private_headers = \
dh-error.h \
- dh-language.h \
dh-parser.h \
dh-preferences.h \
dh-settings.h \
@@ -43,7 +42,6 @@ libdevhelp_private_headers = \
libdevhelp_private_c_files = \
dh-error.c \
- dh-language.c \
dh-parser.c \
dh-preferences.c \
dh-util.c \
diff --git a/src/dh-book-manager.c b/src/dh-book-manager.c
index 983a25a..9765cc5 100644
--- a/src/dh-book-manager.c
+++ b/src/dh-book-manager.c
@@ -5,6 +5,7 @@
* Copyright (C) 2004-2008 Imendio AB
* Copyright (C) 2010 Lanedo GmbH
* Copyright (C) 2012 Thomas Bechtold <toabctl gnome org>
+ * Copyright (C) 2017 Sébastien Wilmet <swilmet gnome org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -23,7 +24,6 @@
#include "config.h"
#include "dh-book-manager.h"
#include "dh-book.h"
-#include "dh-language.h"
#include "dh-link.h"
#include "dh-settings.h"
#include "dh-util.h"
@@ -57,9 +57,6 @@ typedef struct {
/* List of book IDs (gchar*) currently disabled */
GList *books_disabled;
- /* List of DhLanguage* with at least one book enabled */
- GList *languages;
-
guint group_by_language : 1;
} DhBookManagerPrivate;
@@ -181,7 +178,6 @@ dh_book_manager_finalize (GObject *object)
DhBookManager *book_manager = DH_BOOK_MANAGER (object);
DhBookManagerPrivate *priv = dh_book_manager_get_instance_private (book_manager);
- g_list_free_full (priv->languages, g_object_unref);
g_list_free_full (priv->books_disabled, g_free);
if (singleton == book_manager)
@@ -328,52 +324,6 @@ store_books_disabled (DhBookManager *book_manager)
g_settings_set_value (contents_settings, "books-disabled", variant);
}
-static void
-inc_language (DhBookManager *book_manager,
- const gchar *language_name)
-{
- GList *li;
- DhLanguage *language;
- DhBookManagerPrivate *priv = dh_book_manager_get_instance_private (book_manager);
-
- li = g_list_find_custom (priv->languages,
- language_name,
- (GCompareFunc)dh_language_compare_by_name);
-
- /* If already in list, increase count */
- if (li) {
- dh_language_inc_n_books_enabled (li->data);
- return;
- }
-
- /* Add new element to list if not found. Language must start with
- * with n_books_enabled=1. */
- language = dh_language_new (language_name);
- dh_language_inc_n_books_enabled (language);
- priv->languages = g_list_prepend (priv->languages,
- language);
-}
-
-static void
-dec_language (DhBookManager *book_manager,
- const gchar *language_name)
-{
- GList *li;
- DhBookManagerPrivate *priv = dh_book_manager_get_instance_private (book_manager);
-
- /* Language must exist in list */
- li = g_list_find_custom (priv->languages,
- language_name,
- (GCompareFunc)dh_language_compare_by_name);
- g_assert (li != NULL);
-
- /* If language count reaches zero, remove from list */
- if (dh_language_dec_n_books_enabled (li->data)) {
- g_object_unref (li->data);
- priv->languages = g_list_delete_link (priv->languages, li);
- }
-}
-
static GList *
find_book_in_disabled_list (GList *books_disabled,
DhBook *book)
@@ -412,8 +362,6 @@ remove_book (DhBookManager *book_manager,
node = g_list_find (priv->books, book);
if (node != NULL) {
- dec_language (book_manager, dh_book_get_language (book));
-
g_signal_emit (book_manager,
signals[BOOK_DELETED],
0,
@@ -469,8 +417,6 @@ book_enabled_cb (DhBook *book,
store_books_disabled (book_manager);
- inc_language (book_manager, dh_book_get_language (book));
-
g_signal_emit (book_manager,
signals[BOOK_ENABLED],
0,
@@ -497,8 +443,6 @@ book_disabled_cb (DhBook *book,
g_strdup (book_id));
store_books_disabled (book_manager);
- dec_language (book_manager, dh_book_get_language (book));
-
g_signal_emit (book_manager,
signals[BOOK_DISABLED],
0,
@@ -551,9 +495,6 @@ create_book_from_index_file (DhBookManager *book_manager,
book_enabled = !is_book_disabled_in_conf (book_manager, book);
dh_book_set_enabled (book, book_enabled);
- if (book_enabled)
- inc_language (book_manager, dh_book_get_language (book));
-
g_signal_connect_object (book,
"deleted",
G_CALLBACK (book_deleted_cb),
diff --git a/src/dh-book-manager.h b/src/dh-book-manager.h
index 459ba6f..7bf32b0 100644
--- a/src/dh-book-manager.h
+++ b/src/dh-book-manager.h
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2010 Lanedo GmbH
+ * Copyright (C) 2017 Sébastien Wilmet <swilmet gnome org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]