summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@src.gnome.org>2003-11-19 05:37:36 +0000
committerShaun McCance <shaunm@src.gnome.org>2003-11-19 05:37:36 +0000
commit991465f49774551c508f26ff9fb9702c757ec1dc (patch)
treedda9a37530f246ee14372b5122ae6f0f0e589e7e
parent8010abca201c80f31f00c9ff9f0a5110bdb34c3b (diff)
downloadyelp-991465f49774551c508f26ff9fb9702c757ec1dc.tar.gz
- Add yelp-toc-pager.[ch] to test-pager build.
* src/Makefile.am: - Add yelp-toc-pager.[ch] to test-pager build. * src/yelp-toc-pager.c: - Make the hashing of OMF files work completely.
-rw-r--r--ChangeLog8
-rw-r--r--src/Makefile.am1
-rw-r--r--src/yelp-toc-pager.c77
3 files changed, 76 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 1518d182..93176e5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
2003-11-18 Shaun McCance <shaunm@gnome.org>
* src/Makefile.am:
+ - Add yelp-toc-pager.[ch] to test-pager build.
+
+ * src/yelp-toc-pager.c:
+ - Make the hashing of OMF files work completely.
+
+2003-11-18 Shaun McCance <shaunm@gnome.org>
+
+ * src/Makefile.am:
* src/yelp-reader.c:
* src/yelp-reader.h:
- Removing YelpReader
diff --git a/src/Makefile.am b/src/Makefile.am
index 69a0f63d..95489bd7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,6 +30,7 @@ test_pager_SOURCES = \
test-pager.c \
yelp-pager.c yelp-pager.h \
yelp-db-pager.c yelp-db-pager.h \
+ yelp-toc-pager.c yelp-toc-pager.h \
yelp-uri.c yelp-uri.h \
yelp-marshal-main.c
diff --git a/src/yelp-toc-pager.c b/src/yelp-toc-pager.c
index 73cd4fa2..16e55756 100644
--- a/src/yelp-toc-pager.c
+++ b/src/yelp-toc-pager.c
@@ -58,6 +58,8 @@ struct _OMF {
xmlChar *language;
gint lang_priority;
+ GSList *categories;
+
xmlChar *omf_file;
xmlChar *xml_file;
};
@@ -75,6 +77,10 @@ const GtkTreeModel * toc_pager_get_sections (YelpPager *pager);
static void toc_read_omf_dir (YelpTocPager *pager,
const gchar *dirstr);
static gboolean toc_process_pending (YelpPager *pager);
+static void toc_hash_omf (YelpTocPager *pager,
+ OMF *omf);
+static void toc_unhash_omf (YelpTocPager *pager,
+ OMF *omf);
static void omf_free (OMF *omf);
@@ -176,6 +182,11 @@ yelp_toc_pager_unpause (YelpTocPager *pager)
{
pager->priv->pause_count = pager->priv->pause_count - 1;
+ if (pager->priv->pause_count < 0) {
+ g_warning (_("YelpTocPager: Pause count is negative."));
+ pager->priv->pause_count = 0;
+ }
+
if (pager->priv->pause_count < 1 && pager->priv->unpause_func) {
gtk_idle_add_priority (G_PRIORITY_LOW,
pager->priv->unpause_func,
@@ -331,6 +342,14 @@ toc_process_pending (YelpPager *pager)
omf->seriesid = seriesid;
}
}
+ if (!xmlStrcmp (omf_cur->name, (xmlChar *) "subject")) {
+ xmlChar *category =
+ xmlGetProp (omf_cur, (const xmlChar *) "category");
+
+ if (category)
+ omf->categories = g_slist_prepend (omf->categories,
+ category);
+ }
if (!xmlStrcmp (omf_cur->name, (xmlChar *) "language")) {
if (omf->language)
xmlFree (omf->language);
@@ -378,18 +397,13 @@ toc_process_pending (YelpPager *pager)
omf_free (omf);
goto done;
} else {
- printf ("replacing %s with %s\n",
- omf_old->omf_file,
- omf->omf_file);
- g_hash_table_insert (priv->seriesid_hash,
- omf->seriesid,
- omf);
+ toc_unhash_omf (YELP_TOC_PAGER (pager), omf_old);
omf_free (omf_old);
+
+ toc_hash_omf (YELP_TOC_PAGER (pager), omf);
}
} else {
- g_hash_table_insert (priv->seriesid_hash,
- omf->seriesid,
- omf);
+ toc_hash_omf (YELP_TOC_PAGER (pager), omf);
}
// priv->seriesid_hash = g_hash_table_new (g_str_hash, g_str_equal);
@@ -400,8 +414,9 @@ toc_process_pending (YelpPager *pager)
g_free (file);
g_slist_free_1 (first);
- if (!priv->omf_pending)
+ if (!priv->omf_pending) {
return FALSE;
+ }
else if (priv->pause_count > 0) {
priv->unpause_func = (GtkFunction) toc_process_pending;
return FALSE;
@@ -411,6 +426,48 @@ toc_process_pending (YelpPager *pager)
}
static void
+toc_hash_omf (YelpTocPager *pager, OMF *omf)
+{
+ GSList *category;
+
+ g_hash_table_insert (pager->priv->seriesid_hash,
+ omf->seriesid,
+ omf);
+
+ for (category = omf->categories; category; category = category->next) {
+ gchar *catstr = (gchar *) category->data;
+ GSList *omfs =
+ (GSList *) g_hash_table_lookup (pager->priv->category_hash,
+ catstr);
+ omfs = g_slist_prepend (omfs, omf);
+
+ g_hash_table_insert (pager->priv->category_hash,
+ catstr, omfs);
+ }
+}
+
+static void
+toc_unhash_omf (YelpTocPager *pager, OMF *omf)
+{
+ GSList *category;
+
+ g_hash_table_remove (pager->priv->seriesid_hash,
+ omf->seriesid);
+
+ for (category = omf->categories; category; category = category->next) {
+ gchar *catstr = (gchar *) category->data;
+ GSList *omfs =
+ (GSList *) g_hash_table_lookup (pager->priv->category_hash,
+ catstr);
+ if (omfs) {
+ omfs = g_slist_remove (omfs, omf);
+ g_hash_table_insert (pager->priv->category_hash,
+ catstr, omfs);
+ }
+ }
+}
+
+static void
omf_free (OMF *omf)
{
if (omf) {