diff options
author | Mikael Hallendal <micke@codefactory.se> | 2002-02-25 15:04:54 +0000 |
---|---|---|
committer | Mikael Hallendal <hallski@src.gnome.org> | 2002-02-25 15:04:54 +0000 |
commit | 6752dab7e903accc053bb282f35ede608e67bd7f (patch) | |
tree | 626cee36304685c0d64e93b9af0acb0aeb85baed | |
parent | 4949b5644bee49d7d3da571be7e7084847adb8ed (diff) | |
download | yelp-6752dab7e903accc053bb282f35ede608e67bd7f.tar.gz |
added index-list to arguments.
2002-02-25 Mikael Hallendal <micke@codefactory.se>
* src/yelp-window.c:
(yelp_window_new): added index-list to arguments.
* src/yelp-view-index.c: started to fix (was a copy&paste from
yelp-view-content.
* src/yelp-section.h: added YELP_SECTION_INDEX to YelpSectionType.
* src/yelp-section.c: include string.h, fixes compile warning.
* src/yelp-scrollkeeper.c:
- Basic support for ScrollKeeper index added
- use g_ascii_strcasecmp instead of depricated g_strcasecmp.
Thanks to the wipro guys for notifying.
(ys_parse_index): added/impl.
(ys_parse_index_file): added/impl.
(ys_parse_index_item): added/impl.
(yelp_scrollkeeper_init):
- added GList **index to arguments.
* src/yelp-main.c:
(yelp_main_open_new_window): use g_error
(yelp_main_start): same.
* src/yelp-history.c: include string.h, fixes compile warning.
* src/yelp-base.c: added index-list to priv-struct
(yelp_base_new): call scrollkeeper_init with index-list
(yelp_base_new_window): send the index-list to the new window.
started work on supporting index-search.
-rw-r--r-- | ChangeLog | 32 | ||||
-rw-r--r-- | src/yelp-base.c | 18 | ||||
-rw-r--r-- | src/yelp-history.c | 1 | ||||
-rw-r--r-- | src/yelp-main.c | 10 | ||||
-rw-r--r-- | src/yelp-scrollkeeper.c | 216 | ||||
-rw-r--r-- | src/yelp-scrollkeeper.h | 3 | ||||
-rw-r--r-- | src/yelp-section.c | 1 | ||||
-rw-r--r-- | src/yelp-section.h | 3 | ||||
-rw-r--r-- | src/yelp-view-content.c | 2 | ||||
-rw-r--r-- | src/yelp-view-index.c | 110 | ||||
-rw-r--r-- | src/yelp-view-index.h | 2 | ||||
-rw-r--r-- | src/yelp-window.c | 6 | ||||
-rw-r--r-- | src/yelp-window.h | 3 |
13 files changed, 293 insertions, 114 deletions
@@ -1,3 +1,35 @@ +2002-02-25 Mikael Hallendal <micke@codefactory.se> + + * src/yelp-window.c: + (yelp_window_new): added index-list to arguments. + + * src/yelp-view-index.c: started to fix (was a copy&paste from + yelp-view-content. + + * src/yelp-section.h: added YELP_SECTION_INDEX to YelpSectionType. + + * src/yelp-section.c: include string.h, fixes compile warning. + + * src/yelp-scrollkeeper.c: + - Basic support for ScrollKeeper index added + - use g_ascii_strcasecmp instead of depricated g_strcasecmp. + Thanks to the wipro guys for notifying. + (ys_parse_index): added/impl. + (ys_parse_index_file): added/impl. + (ys_parse_index_item): added/impl. + (yelp_scrollkeeper_init): + - added GList **index to arguments. + + * src/yelp-main.c: + (yelp_main_open_new_window): use g_error + (yelp_main_start): same. + + * src/yelp-history.c: include string.h, fixes compile warning. + + * src/yelp-base.c: added index-list to priv-struct + (yelp_base_new): call scrollkeeper_init with index-list + (yelp_base_new_window): send the index-list to the new window. + 2002-02-22 Kjartan Maraas <kmaraas@gnome.org> * src/yelp-main.c: Remove unsupported #ifdef ENABLE_NLS stuff. diff --git a/src/yelp-base.c b/src/yelp-base.c index b5e87e06..8912c694 100644 --- a/src/yelp-base.c +++ b/src/yelp-base.c @@ -39,9 +39,10 @@ typedef struct { } ForeachData; struct _YelpBasePriv { - GNode *toc_tree; + GNode *toc_tree; - GSList *windows; + GList *index; + GSList *windows; }; @@ -130,12 +131,15 @@ yelp_base_window_finalized_cb (YelpBase *base, YelpWindow *window) YelpBase * yelp_base_new (void) { - YelpBase *base; - gboolean result; + YelpBase *base; + YelpBasePriv *priv; + gboolean result; base = g_object_new (YELP_TYPE_BASE, NULL); - - result = yelp_scrollkeeper_init (base->priv->toc_tree); + priv = base->priv; + + result = yelp_scrollkeeper_init (priv->toc_tree, + &priv->index); result = yelp_man_init (base->priv->toc_tree); result = yelp_info_init (base->priv->toc_tree); @@ -152,7 +156,7 @@ yelp_base_new_window (YelpBase *base) priv = base->priv; - window = yelp_window_new (base->priv->toc_tree); + window = yelp_window_new (priv->toc_tree, priv->index); priv->windows = g_slist_prepend (priv->windows, window); diff --git a/src/yelp-history.c b/src/yelp-history.c index 03e32b5c..ea9bbc1b 100644 --- a/src/yelp-history.c +++ b/src/yelp-history.c @@ -24,6 +24,7 @@ #include <config.h> #endif +#include <string.h> #include "yelp-history.h" static void yelp_history_init (YelpHistory *history); diff --git a/src/yelp-main.c b/src/yelp-main.c index 77794461..67adb5c8 100644 --- a/src/yelp-main.c +++ b/src/yelp-main.c @@ -42,8 +42,8 @@ #define YELP_FACTORY_OAFIID "OAFIID:GNOME_Yelp_Factory" static BonoboObject * yelp_base_factory (BonoboGenericFactory *factory, - const gchar *iid, - gpointer closure); + const gchar *iid, + gpointer closure); static CORBA_Object yelp_main_activate_base (void); static gboolean yelp_main_idle_start (gchar *url); @@ -75,9 +75,8 @@ yelp_main_activate_base () 0, NULL, &ev); if (BONOBO_EX (&ev) || yelp_base == CORBA_OBJECT_NIL) { - g_warning (_("Could not activate Yelp: '%s'"), + g_error (_("Could not activate Yelp: '%s'"), bonobo_exception_get_text (&ev)); - exit (1); } CORBA_exception_free (&ev); @@ -95,8 +94,7 @@ yelp_main_open_new_window (CORBA_Object yelp_base, const gchar *url) GNOME_Yelp_newWindow (yelp_base, url, &ev); if (BONOBO_EX (&ev)) { - g_warning (_("Could not open new window.")); - exit (1); + g_error (_("Could not open new window.")); } CORBA_exception_free (&ev); diff --git a/src/yelp-scrollkeeper.c b/src/yelp-scrollkeeper.c index 229518e2..162efd9e 100644 --- a/src/yelp-scrollkeeper.c +++ b/src/yelp-scrollkeeper.c @@ -41,7 +41,8 @@ static gboolean ys_parse_books (GNode *tree, static gboolean ys_parse_section (GNode *parent, xmlNode *xml_node); static void ys_parse_doc (GNode *parent, - xmlNode *xml_node); + xmlNode *xml_node, + gchar *docid); static void ys_parse_toc_section (GNode *parent, xmlNode *xml_node, const gchar *base_uri); @@ -51,9 +52,19 @@ static gchar * ys_get_xml_docpath (const gchar *command, static gchar * ys_strip_scheme (gchar *original_uri, gchar **scheme); +static gboolean ys_parse_index (GList **index); +static void ys_parse_index_file (GList **index, + const gchar *index_path, + YelpSection *section); +static void ys_parse_index_item (GList **index, + YelpSection *section, + xmlNode *node); + + static gint calls = 0; static GHashTable *seriesid_hash = NULL; +static GHashTable *docid_hash = NULL; static gboolean ys_trim_empty_branches (xmlNode *node) @@ -69,7 +80,7 @@ ys_trim_empty_branches (xmlNode *node) for (child = node->xmlChildrenNode; child; child = next) { next = child->next; - if (!g_strcasecmp (child->name, "sect")) { + if (!g_ascii_strcasecmp (child->name, "sect")) { empty = ys_trim_empty_branches (child); if (empty) { xmlUnlinkNode (child); @@ -79,8 +90,8 @@ ys_trim_empty_branches (xmlNode *node) } for (child = node->xmlChildrenNode; child; child = child->next) { - if (!g_strcasecmp (child->name, "sect") || - !g_strcasecmp (child->name, "doc")) { + if (!g_ascii_strcasecmp (child->name, "sect") || + !g_ascii_strcasecmp (child->name, "doc")) { return FALSE; } } @@ -100,7 +111,7 @@ ys_tree_empty (xmlNode *cl_node) for (node = cl_node; node != NULL; node = next) { next = node->next; - if (!strcmp (node->name, "sect") && + if (!g_ascii_strcasecmp (node->name, "sect") && node->xmlChildrenNode->next != NULL) { ret_val = ys_tree_empty ( node->xmlChildrenNode->next); @@ -110,7 +121,7 @@ ys_tree_empty (xmlNode *cl_node) } } - if (!strcmp (node->name, "doc")) { + if (!g_ascii_strcasecmp (node->name, "doc")) { return FALSE; } } @@ -130,7 +141,7 @@ ys_parse_books (GNode *tree, xmlDoc *doc) node = doc->xmlRootNode; if (!node || !node->name || - g_strcasecmp (node->name, "ScrollKeeperContentsList")) { + g_ascii_strcasecmp (node->name, "ScrollKeeperContentsList")) { g_warning ("Invalid ScrollKeeper XML Contents List!"); return FALSE; } @@ -141,7 +152,7 @@ ys_parse_books (GNode *tree, xmlDoc *doc) NULL, NULL)); for (node = node->xmlChildrenNode; node; node = node->next) { - if (!g_strcasecmp (node->name, "sect")) { + if (!g_ascii_strcasecmp (node->name, "sect")) { success = ys_parse_section (book_node, node); } } @@ -152,14 +163,15 @@ ys_parse_books (GNode *tree, xmlDoc *doc) static gboolean ys_parse_section (GNode *parent, xmlNode *xml_node) { - xmlNode *cur; - xmlChar *xml_str; - gchar *name; - GNode *node; + xmlNode *cur; + xmlChar *xml_str; + gchar *name; + GNode *node; + gchar *docid; /* Find the title */ for (cur = xml_node->xmlChildrenNode; cur; cur = cur->next) { - if (!g_strcasecmp (cur->name, "title")) { + if (!g_ascii_strcasecmp (cur->name, "title")) { xml_str = xmlNodeGetContent (cur); if (xml_str) { @@ -180,11 +192,18 @@ ys_parse_section (GNode *parent, xmlNode *xml_node) NULL, NULL)); for (cur = xml_node->xmlChildrenNode; cur; cur = cur->next) { - if (!g_strcasecmp (cur->name, "sect")) { + if (!g_ascii_strcasecmp (cur->name, "sect")) { ys_parse_section (node, cur); } - else if (!g_strcasecmp (cur->name, "doc")) { - ys_parse_doc (node, cur); + else if (!g_ascii_strcasecmp (cur->name, "doc")) { + + xml_str = xmlGetProp (cur, "docid"); + if (xml_str) { + docid = g_strdup (xml_str); + xmlFree (xml_str); + } + + ys_parse_doc (node, cur, docid); } } @@ -192,42 +211,42 @@ ys_parse_section (GNode *parent, xmlNode *xml_node) } static void -ys_parse_doc (GNode *parent, xmlNode *xml_node) +ys_parse_doc (GNode *parent, xmlNode *xml_node, gchar *docid) { - xmlNode *cur; - xmlChar *xml_str; - gchar *title; - gchar *omf; - gchar *link; - gchar *format; - gchar *docsource; - gchar *docseriesid; - GNode *node; + xmlNode *cur; + xmlChar *xml_str; + gchar *title; + gchar *omf; + gchar *link; + gchar *format; + gchar *docsource; + gchar *docseriesid; + GNode *node; docseriesid = NULL; for (cur = xml_node->xmlChildrenNode; cur; cur = cur->next) { - if (!g_strcasecmp (cur->name, "doctitle")) { + if (!g_ascii_strcasecmp (cur->name, "doctitle")) { xml_str = xmlNodeGetContent (cur); title = g_strdup (xml_str); xmlFree (xml_str); } - else if (!g_strcasecmp (cur->name, "docomf")) { + else if (!g_ascii_strcasecmp (cur->name, "docomf")) { xml_str = xmlNodeGetContent (cur); omf = g_strdup (xml_str); xmlFree (xml_str); } - else if (!g_strcasecmp (cur->name, "docsource")) { + else if (!g_ascii_strcasecmp (cur->name, "docsource")) { xml_str = xmlNodeGetContent (cur); docsource = ys_strip_scheme (xml_str, NULL); link = g_strconcat ("ghelp:", docsource, NULL); xmlFree (xml_str); } - else if (!g_strcasecmp (cur->name, "docformat")) { + else if (!g_ascii_strcasecmp (cur->name, "docformat")) { xml_str = xmlNodeGetContent (cur); format = g_strdup (xml_str); xmlFree (xml_str); } - else if (!g_strcasecmp (cur->name, "docseriesid")) { + else if (!g_ascii_strcasecmp (cur->name, "docseriesid")) { xml_str = xmlNodeGetContent (cur); docseriesid = g_strdup (xml_str); xmlFree (xml_str); @@ -243,13 +262,8 @@ ys_parse_doc (GNode *parent, xmlNode *xml_node) g_hash_table_insert (seriesid_hash, docseriesid, node); } -/* index_location = ys_get_xml_docpath ("scrollkeeper-get-index-from-docpath", */ -/* docsource); */ + g_hash_table_insert (docid_hash, docid, node); -/* if (index_location) { */ -/* g_print ("Found index: %s\n", index_location); */ -/* } */ - g_free (title); g_free (omf); g_free (link); @@ -298,7 +312,7 @@ ys_parse_toc_section (GNode *parent, link, NULL)); for (; next_child != NULL; next_child = next_child->next) { - if (!g_strncasecmp (next_child->name, "tocsect", 7)) { + if (!g_ascii_strncasecmp (next_child->name, "tocsect", 7)) { ys_parse_toc_section (node, next_child, base_uri); } } @@ -361,8 +375,125 @@ ys_strip_scheme(gchar *original_uri, gchar **scheme) return new_uri; } +static gboolean +ys_parse_index (GList **index) +{ + gchar *sk_data_dir = NULL; + gchar *index_dir; + GnomeVFSDirectoryHandle *dir; + GnomeVFSResult result; + GnomeVFSFileInfo *file_info; + GNode *node; + YelpSection *section; + + sk_data_dir = ys_get_xml_docpath ("scrollkeeper-config", + "--pkglocalstatedir"); + + index_dir = g_strdup_printf ("%s/index", sk_data_dir); + + g_free (sk_data_dir); + + result = gnome_vfs_directory_open (&dir, index_dir, + GNOME_VFS_FILE_INFO_DEFAULT); + + if (result != GNOME_VFS_OK) { + g_warning ("Error opening directory: %s\n", index_dir); + return FALSE; + } + + file_info = gnome_vfs_file_info_new (); + + while (gnome_vfs_directory_read_next (dir, file_info) == GNOME_VFS_OK) { + node = g_hash_table_lookup (docid_hash, file_info->name); + + if (node) { + gchar *index_path = g_strdup_printf ("%s/%s", + index_dir, + file_info->name); + + section = (YelpSection *) node->data; + + ys_parse_index_file (index, index_path, section); + + g_free (index_path); + + g_print ("FOUND INDEX FOR: %s/%s\n", + section->uri, file_info->name); + } + } + + g_free (index_dir); + gnome_vfs_file_info_unref (file_info); + + return TRUE; +} + +static void +ys_parse_index_file (GList **index, + const gchar *index_path, + YelpSection *section) +{ + xmlDoc *doc; + xmlNode *node; + + doc = xmlParseFile (index_path); + + if (doc) { + node = doc->xmlRootNode; + + if (!node || !node->name || + g_ascii_strcasecmp (node->name, "indexdoc")) { + g_warning ("Invalid Index file, root node is '%s', it should be 'indexdoc'!", node->name); + return; + } + + for (node = node->xmlChildrenNode; node; node = node->next) { + if (!g_ascii_strcasecmp (node->name, "indexitem")) { + + g_print ("Found an indexitem!\n"); + ys_parse_index_item (index, section, node); + } + } + } +} + +static void +ys_parse_index_item (GList **index, YelpSection *section, xmlNode *node) +{ + xmlNode *cur; + xmlChar *title = NULL; + xmlChar *link = NULL; + YelpSection *index_section; + + for (cur = node->xmlChildrenNode; cur; cur = cur->next) { + if (!g_ascii_strcasecmp (cur->name, "title")) { + title = xmlNodeGetContent (cur); + g_print ("TITLE: %s\n", title); + } + else if (!g_ascii_strcasecmp (cur->name, "link")) { + link = xmlGetProp (cur, "linkid"); + + g_print ("LINK: %s\n", link); + } + else if (!g_ascii_strcasecmp (cur->name, "indexitem")) { + ys_parse_index_item (index, section, cur); + } + } + + if (title && link) { + index_section = yelp_section_new (YELP_SECTION_INDEX, + title, section->uri, + link, NULL); + + *index = g_list_prepend (*index, index_section); + + xmlFree (title); + xmlFree (link); + } +} + gboolean -yelp_scrollkeeper_init (GNode *tree) +yelp_scrollkeeper_init (GNode *tree, GList **index) { gchar *docpath; xmlDoc *doc; @@ -373,6 +504,9 @@ yelp_scrollkeeper_init (GNode *tree) seriesid_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + + docid_hash = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, NULL); doc = NULL; for (node = gnome_i18n_get_language_list ("LC_MESSAGES"); node; node = node->next) { @@ -402,6 +536,8 @@ yelp_scrollkeeper_init (GNode *tree) xmlFreeDoc (doc); } + ys_parse_index (index); + g_print ("Number of script calls: %d\n", calls); return TRUE; @@ -441,7 +577,7 @@ yelp_scrollkeeper_get_toc_tree (const gchar *docpath) return NULL; } - if (g_strcasecmp (doc->xmlRootNode->name, "toc")) { + if (g_ascii_strcasecmp (doc->xmlRootNode->name, "toc")) { g_warning ("Document with wrong root node, got: '%s'", doc->xmlRootNode->name); } diff --git a/src/yelp-scrollkeeper.h b/src/yelp-scrollkeeper.h index 176f82ab..369e91b6 100644 --- a/src/yelp-scrollkeeper.h +++ b/src/yelp-scrollkeeper.h @@ -26,7 +26,8 @@ #include <glib.h> #include <gtk/gtktreestore.h> -gboolean yelp_scrollkeeper_init (GNode *tree); +gboolean yelp_scrollkeeper_init (GNode *tree, + GList **index); GNode * yelp_scrollkeeper_lookup_seriesid (const gchar *seriesid); GNode * yelp_scrollkeeper_get_toc_tree (const gchar *docpath); diff --git a/src/yelp-section.c b/src/yelp-section.c index ace358af..6a038f10 100644 --- a/src/yelp-section.c +++ b/src/yelp-section.c @@ -24,6 +24,7 @@ #include <config.h> #endif +#include "string.h" #include "yelp-section.h" YelpSection * diff --git a/src/yelp-section.h b/src/yelp-section.h index 166074b6..5d7456e1 100644 --- a/src/yelp-section.h +++ b/src/yelp-section.h @@ -30,7 +30,8 @@ typedef struct _YelpSection YelpSection; typedef enum { YELP_SECTION_DOCUMENT_SECTION, YELP_SECTION_DOCUMENT, - YELP_SECTION_CATEGORY + YELP_SECTION_CATEGORY, + YELP_SECTION_INDEX } YelpSectionType; struct _YelpSection { diff --git a/src/yelp-view-content.c b/src/yelp-view-content.c index 1b99a4d3..203738b9 100644 --- a/src/yelp-view-content.c +++ b/src/yelp-view-content.c @@ -117,7 +117,7 @@ yvc_init (YelpViewContent *view) priv->content_tree = gtk_tree_view_new (); priv->tree_store = gtk_tree_store_new (2, - G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_POINTER); gtk_tree_view_set_model (GTK_TREE_VIEW (priv->content_tree), diff --git a/src/yelp-view-index.c b/src/yelp-view-index.c index d6aba069..1bd16cc1 100644 --- a/src/yelp-view-index.c +++ b/src/yelp-view-index.c @@ -30,19 +30,21 @@ #include "yelp-html.h" #include "yelp-view-index.h" -static void yvi_init (YelpViewIndex *view); -static void yvi_class_init (YelpViewIndexClass *klass); -static void yvi_tree_selection_changed_cb (GtkTreeSelection *selection, - YelpViewIndex *content); -static void yvi_url_selected_cb (YelpViewIndex *content, - char *url, - char *base_url, - gboolean handled); +static void yvi_init (YelpViewIndex *view); +static void yvi_class_init (YelpViewIndexClass *klass); +static void yvi_index_selection_changed_cb (GtkTreeSelection *selection, + YelpViewIndex *content); +static void yvi_html_url_selected_cb (YelpViewIndex *content, + char *url, + char *base_url, + gboolean handled); struct _YelpViewIndexPriv { - /* Content tree */ - GtkWidget *content_tree; - GtkTreeModel *tree_model; + GList *index; + + /* List of keywords */ + GtkWidget *index_view; + GtkListStore *list_store; /* Query entry */ GtkWidget *entry; @@ -87,9 +89,18 @@ yvi_init (YelpViewIndex *view) priv = g_new0 (YelpViewIndexPriv, 1); view->priv = priv; - priv->content_tree = gtk_tree_view_new (); - priv->tree_model = NULL; + priv->index_view = gtk_tree_view_new (); + priv->list_store = gtk_list_store_new (2, + G_TYPE_STRING, G_TYPE_POINTER); + + gtk_tree_view_set_model (GTK_TREE_VIEW (priv->index_view), + GTK_TREE_MODEL (priv->list_store)); + priv->html_view = yelp_html_new (); + + g_signal_connect (priv->html_view, "url_selected", + G_CALLBACK (yvi_html_url_selected_cb), + view); } static void @@ -99,36 +110,39 @@ yvi_class_init (YelpViewIndexClass *klass) } static void -yvi_tree_selection_changed_cb (GtkTreeSelection *selection, - YelpViewIndex *content) +yvi_index_selection_changed_cb (GtkTreeSelection *selection, + YelpViewIndex *view) { YelpViewIndexPriv *priv; - GtkTreeIter iter; - YelpSection *section; + GtkTreeIter iter; + YelpSection *section; g_return_if_fail (GTK_IS_TREE_SELECTION (selection)); - g_return_if_fail (YELP_IS_VIEW_INDEX (content)); + g_return_if_fail (YELP_IS_VIEW_INDEX (view)); - priv = content->priv; + priv = view->priv; if (gtk_tree_selection_get_selected (selection, NULL, &iter)) { - gtk_tree_model_get (GTK_TREE_MODEL (priv->tree_model), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (priv->list_store), &iter, 1, §ion, -1); - yelp_html_open_uri (YELP_HTML (priv->html_view), - section->uri, section->reference); + /* FIXME: Emit index:string */ + + yelp_html_open_uri (YELP_HTML (priv->html_view), + section->uri, + section->reference); + +/* g_signal_emit (view, signals[URL_SELECTED], 0, */ +/* section->reference, section->uri, FALSE); */ } - - /* FIXME: Emit section_selected?? */ -/* yelp_history_goto (priv->history, section); */ } static void -yvi_url_selected_cb (YelpViewIndex *content, - char *url, - char *base_url, - gboolean handled) +yvi_html_url_selected_cb (YelpViewIndex *content, + char *url, + char *base_url, + gboolean handled) { g_return_if_fail (YELP_IS_VIEW_INDEX (content)); @@ -138,12 +152,10 @@ yvi_url_selected_cb (YelpViewIndex *content, } GtkWidget * -yelp_view_index_new (GtkTreeModel *tree_model) +yelp_view_index_new (GList *index) { YelpViewIndex *view; YelpViewIndexPriv *priv; - GtkCellRenderer *cell; - GtkTreeViewColumn *column; GtkTreeSelection *selection; GtkWidget *html_sw; GtkWidget *list_sw; @@ -153,7 +165,7 @@ yelp_view_index_new (GtkTreeModel *tree_model) view = g_object_new (YELP_TYPE_VIEW_INDEX, NULL); priv = view->priv; - priv->tree_model = tree_model; + priv->index = index; /* Setup the index box */ box = gtk_vbox_new (FALSE, 0); @@ -168,28 +180,24 @@ yelp_view_index_new (GtkTreeModel *tree_model) GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); -#if 0 - gtk_tree_view_set_model (GTK_TREE_VIEW (priv->content_tree), - tree_model); -#endif - - cell = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Section"), cell, - "text", 0, - NULL); + gtk_tree_view_insert_column_with_attributes ( + GTK_TREE_VIEW (priv->index_view), -1, + _("Section"), gtk_cell_renderer_text_new (), + "text", 0, + NULL); - gtk_tree_view_column_set_sort_column_id (column, 0); - gtk_tree_view_append_column (GTK_TREE_VIEW (priv->content_tree), - column); + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->index_view), + FALSE); selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (priv->content_tree)); + GTK_TREE_VIEW (priv->index_view)); g_signal_connect (selection, "changed", - G_CALLBACK (yvi_tree_selection_changed_cb), + G_CALLBACK (yvi_index_selection_changed_cb), view); - gtk_container_add (GTK_CONTAINER (list_sw), priv->content_tree); + gtk_container_add (GTK_CONTAINER (list_sw), priv->index_view); + gtk_box_pack_end_defaults (GTK_BOX (box), list_sw); /* Setup the Html view */ @@ -201,10 +209,6 @@ yelp_view_index_new (GtkTreeModel *tree_model) gtk_container_add (GTK_CONTAINER (frame), html_sw); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - g_signal_connect_swapped (priv->html_view, "url_selected", - G_CALLBACK (yvi_url_selected_cb), - G_OBJECT (view)); - gtk_container_add (GTK_CONTAINER (html_sw), priv->html_view); /* Add the tree and html view to the paned */ @@ -214,5 +218,3 @@ yelp_view_index_new (GtkTreeModel *tree_model) return GTK_WIDGET (view); } - - diff --git a/src/yelp-view-index.h b/src/yelp-view-index.h index a48ed463..0e031f1c 100644 --- a/src/yelp-view-index.h +++ b/src/yelp-view-index.h @@ -52,6 +52,6 @@ struct _YelpViewIndexClass { }; GType yelp_view_index_get_type (void); -GtkWidget *yelp_view_index_new (GtkTreeModel *tree_model); +GtkWidget *yelp_view_index_new (GList *index); #endif /* __YELP_VIEW_INDEX__ */ diff --git a/src/yelp-window.c b/src/yelp-window.c index 4b901b8d..72a29998 100644 --- a/src/yelp-window.c +++ b/src/yelp-window.c @@ -93,6 +93,7 @@ static gint signals[LAST_SIGNAL] = { 0 }; struct _YelpWindowPriv { GNode *doc_tree; + GList *index; GtkWidget *notebook; @@ -505,7 +506,7 @@ yw_create_toolbar (YelpWindow *window) } GtkWidget * -yelp_window_new (GNode *doc_tree) +yelp_window_new (GNode *doc_tree, GList *index) { YelpWindow *window; YelpWindowPriv *priv; @@ -514,10 +515,11 @@ yelp_window_new (GNode *doc_tree) priv = window->priv; priv->doc_tree = doc_tree; + priv->index = index; priv->toc_view = yelp_view_toc_new (doc_tree); priv->content_view = yelp_view_content_new (doc_tree); - priv->index_view = yelp_view_index_new (NULL); + priv->index_view = yelp_view_index_new (index); g_signal_connect (priv->toc_view, "url_selected", G_CALLBACK (yw_url_selected_cb), diff --git a/src/yelp-window.h b/src/yelp-window.h index b65a6920..0743e277 100644 --- a/src/yelp-window.h +++ b/src/yelp-window.h @@ -53,7 +53,8 @@ struct _YelpWindowClass }; GType yelp_window_get_type (void); -GtkWidget * yelp_window_new (GNode *doc_tree); +GtkWidget * yelp_window_new (GNode *doc_tree, + GList *index); void yelp_window_open_uri (YelpWindow *window, const gchar *str_uri); |