diff options
author | Shaun McCance <shaunm@src.gnome.org> | 2003-12-17 01:40:55 +0000 |
---|---|---|
committer | Shaun McCance <shaunm@src.gnome.org> | 2003-12-17 01:40:55 +0000 |
commit | e7e01c5f0fe81a0abe905b429edb03e4443da831 (patch) | |
tree | 271bcb363dfc055f91786050a000b03e366dd8d0 | |
parent | b9c985f183c0beab2d3e0d872f079bdcb9be91b9 (diff) | |
download | yelp-e7e01c5f0fe81a0abe905b429edb03e4443da831.tar.gz |
src/yelp-view-* - Removing.
* src/yelp-view-*
- Removing.
-rw-r--r-- | src/yelp-view-content.c | 573 | ||||
-rw-r--r-- | src/yelp-view-content.h | 57 | ||||
-rw-r--r-- | src/yelp-view-index.c | 559 | ||||
-rw-r--r-- | src/yelp-view-index.h | 55 | ||||
-rw-r--r-- | src/yelp-view-toc.c | 911 | ||||
-rw-r--r-- | src/yelp-view-toc.h | 56 | ||||
-rw-r--r-- | src/yelp-view.c | 137 | ||||
-rw-r--r-- | src/yelp-view.h | 73 |
8 files changed, 0 insertions, 2421 deletions
diff --git a/src/yelp-view-content.c b/src/yelp-view-content.c deleted file mode 100644 index c90c66b5..00000000 --- a/src/yelp-view-content.c +++ /dev/null @@ -1,573 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001-2002 Mikael Hallendal <micke@imendio.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Mikael Hallendal <micke@imendio.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <libgnome/gnome-i18n.h> -#include <gtk/gtktreeview.h> -#include <gtk/gtktreeselection.h> -#include <gtk/gtkscrolledwindow.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkframe.h> - -#include <string.h> - -#include "yelp-html.h" -#include "yelp-marshal.h" -#include "yelp-reader.h" -#include "yelp-scrollkeeper.h" -#include "yelp-util.h" -#include "yelp-uri.h" -#include "yelp-view-content.h" - -#define d(x) - -static void content_init (YelpViewContent *html); -static void content_class_init (YelpViewContentClass *klass); -static void content_html_uri_selected_cb (YelpHtml *html, - YelpURI *uri, - gboolean handled, - YelpViewContent *view); -static void content_html_title_changed_cb (YelpHtml *html, - const gchar *title, - YelpViewContent *view); -static void content_tree_selection_changed_cb (GtkTreeSelection *selection, - YelpViewContent *content); -static void content_reader_data_cb (YelpReader *reader, - const gchar *data, - gint len, - YelpViewContent *view); -static void content_reader_finished_cb (YelpReader *reader, - YelpURI *uri, - YelpViewContent *view); -static void content_reader_error_cb (YelpReader *reader, - GError *error, - YelpViewContent *view); -static GtkTreePath * -content_find_path_from_uri (GtkTreeModel *model, - YelpURI *uri); - -static void content_insert_tree (YelpViewContent *content, - GtkTreeIter *parent, - GNode *node); -static void content_set_tree (YelpViewContent *content, - GNode *node); -static void -content_show_uri (YelpView *view, - YelpURI *uri, - GError **error); - -static YelpHtml * -content_get_html (YelpView *view); - - -struct _YelpViewContentPriv { - GtkWidget *hpaned; - - /* Content tree */ - GtkWidget *tree_sw; - GtkWidget *content_tree; - GtkTreeStore *tree_store; - GNode *doc_tree; - - YelpReader *reader; - - /* Html view */ - YelpHtml *html_view; - GtkWidget *html_widget; - - YelpURI *current_uri; - - gboolean first; -}; - -GType -yelp_view_content_get_type (void) -{ - static GType view_type = 0; - - if (!view_type) - { - static const GTypeInfo view_info = - { - sizeof (YelpViewContentClass), - NULL, - NULL, - (GClassInitFunc) content_class_init, - NULL, - NULL, - sizeof (YelpViewContent), - 0, - (GInstanceInitFunc) content_init, - }; - - view_type = g_type_register_static (YELP_TYPE_VIEW, - "YelpViewContent", - &view_info, 0); - } - - return view_type; -} - - -static void -content_init (YelpViewContent *view) -{ - YelpViewContentPriv *priv; - - priv = g_new0 (YelpViewContentPriv, 1); - view->priv = priv; - - YELP_VIEW (view)->widget = gtk_hpaned_new (); - - priv->content_tree = gtk_tree_view_new (); - priv->tree_store = gtk_tree_store_new (2, - G_TYPE_STRING, - G_TYPE_POINTER); - - gtk_tree_view_set_model (GTK_TREE_VIEW (priv->content_tree), - GTK_TREE_MODEL (priv->tree_store)); - - priv->html_view = yelp_html_new (); - priv->html_widget = yelp_html_get_widget (priv->html_view); - priv->current_uri = NULL; - priv->first = FALSE; - - g_signal_connect (priv->html_view, "uri_selected", - G_CALLBACK (content_html_uri_selected_cb), - view); - g_signal_connect (priv->html_view, "title_changed", - G_CALLBACK (content_html_title_changed_cb), - view); - - priv->reader = yelp_reader_new (); - - g_signal_connect (G_OBJECT (priv->reader), "data", - G_CALLBACK (content_reader_data_cb), - view); - g_signal_connect (G_OBJECT (priv->reader), "finished", - G_CALLBACK (content_reader_finished_cb), - view); - g_signal_connect (G_OBJECT (priv->reader), "error", - G_CALLBACK (content_reader_error_cb), - view); -} - -static void -content_class_init (YelpViewContentClass *klass) -{ - YelpViewClass *view_class = YELP_VIEW_CLASS (klass); - - view_class->show_uri = content_show_uri; - view_class->get_html = content_get_html; -} - -static void -content_html_uri_selected_cb (YelpHtml *html, - YelpURI *uri, - gboolean handled, - YelpViewContent *view) -{ - /* Just propagate the signal to the view */ - d(g_print ("***** URI Clicked: %s [%d]\n", - yelp_uri_to_string (uri), - handled)); - - g_signal_emit_by_name (view, "uri_selected", uri, handled); -} - -static void -content_html_title_changed_cb (YelpHtml *html, - const gchar *title, - YelpViewContent *view) -{ - g_signal_emit_by_name (view, "title_changed", title); -} - -static void -content_tree_selection_changed_cb (GtkTreeSelection *selection, - YelpViewContent *content) -{ - YelpViewContentPriv *priv; - GtkTreeIter iter; - YelpSection *section; - GtkTreeModel *model; - - g_return_if_fail (GTK_IS_TREE_SELECTION (selection)); - g_return_if_fail (YELP_IS_VIEW_CONTENT (content)); - - priv = content->priv; - - if (gtk_tree_selection_get_selected (selection, NULL, &iter)) { - model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->content_tree)); - - gtk_tree_model_get (model, &iter, - 1, §ion, - -1); - - g_signal_emit_by_name (content, "uri_selected", - section->uri, FALSE); - } -} - -static void -content_reader_data_cb (YelpReader *reader, - const gchar *data, - gint len, - YelpViewContent *view) -{ - YelpViewContentPriv *priv; - - g_return_if_fail (YELP_IS_READER (reader)); - g_return_if_fail (YELP_IS_VIEW_CONTENT (view)); - - priv = view->priv; - - if (priv->first) { - yelp_html_clear (priv->html_view); - priv->first = FALSE; - } - - if (len == -1) { - len = strlen (data); - } - - if (len <= 0) { - return; - } - - yelp_html_write (priv->html_view, data, len); -} - -static void -content_reader_finished_cb (YelpReader *reader, - YelpURI *uri, - YelpViewContent *view) -{ - YelpViewContentPriv *priv; - GtkTreePath *path = NULL; - - g_return_if_fail (YELP_IS_READER (reader)); - g_return_if_fail (YELP_IS_VIEW_CONTENT (view)); - - priv = view->priv; - - if (!priv->first) { - yelp_html_close (priv->html_view); - } - - path = content_find_path_from_uri (GTK_TREE_MODEL (priv->tree_store), - uri); - - if (path) { - GtkTreeSelection *selection; - GtkTreePath *parent; - gint i, depth; - - /* Open the correct node in the tree */ - - d(g_print ("Found path\n")); - - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (priv->content_tree)); - - gtk_tree_view_expand_to_path (GTK_TREE_VIEW (priv->content_tree), - path); - - g_signal_handlers_block_by_func ( - selection, - (gpointer) content_tree_selection_changed_cb, - view); - - gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->content_tree), - path, NULL, FALSE); - - g_signal_handlers_unblock_by_func ( - selection, - (gpointer) content_tree_selection_changed_cb, - view); - - gtk_tree_path_free (path); - } else { - gtk_widget_grab_focus (priv->html_widget); - } - - gdk_window_set_cursor (priv->html_widget->window, NULL); -} - -static void -content_reader_error_cb (YelpReader *reader, - GError *error, - YelpViewContent *view) -{ - YelpViewContentPriv *priv; - - g_return_if_fail (YELP_IS_READER (reader)); - g_return_if_fail (YELP_IS_VIEW_CONTENT (view)); - - priv = view->priv; - - /* Popup window */ - - g_warning ("%s\n", error->message); -} - -static GtkTreePath *found_path; - -static gboolean -content_tree_model_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - YelpURI *uri) -{ - YelpSection *section = NULL; - - g_return_val_if_fail (GTK_IS_TREE_MODEL (model), TRUE); - g_return_val_if_fail (uri != NULL, TRUE); - - gtk_tree_model_get (model, iter, - 1, §ion, - -1); - - if (!section) { - return FALSE; - } - - if (yelp_uri_equal (uri, section->uri)) { - found_path = gtk_tree_path_copy (path); - return TRUE; - } - - return FALSE; -} - -static GtkTreePath * -content_find_path_from_uri (GtkTreeModel *model, YelpURI *uri) -{ - found_path = NULL; - - gtk_tree_model_foreach (model, - (GtkTreeModelForeachFunc) content_tree_model_foreach, - uri); - - return found_path; -} - -static void -content_insert_tree (YelpViewContent *content, - GtkTreeIter *parent, - GNode *node) -{ - GtkTreeIter iter; - YelpSection *section; - GNode *child; - - gtk_tree_store_append (content->priv->tree_store, - &iter, parent); - - section = node->data; - gtk_tree_store_set (content->priv->tree_store, - &iter, - 0, section->name, - 1, section, - -1); - - child = node->children; - - while (child) { - content_insert_tree (content, &iter, child); - - child = child->next; - } -} - -static void -content_set_tree (YelpViewContent *content, GNode *node) -{ - GNode *child; - - g_return_if_fail (YELP_IS_VIEW_CONTENT (content)); - g_return_if_fail (node != NULL); - - gtk_tree_store_clear (content->priv->tree_store); - - child = node->children; - - while (child) { - content_insert_tree (content, NULL, child); - child = child->next; - } -} - -static void -content_show_uri (YelpView *view, YelpURI *uri, GError **error) -{ - YelpViewContentPriv *priv; - GNode *node; - GdkCursor *cursor; - gboolean reset_focus = FALSE; - - g_return_if_fail (YELP_IS_VIEW_CONTENT (view)); - g_return_if_fail (uri != NULL); - - priv = YELP_VIEW_CONTENT (view)->priv; - - if (yelp_uri_get_type (uri) == YELP_URI_TYPE_DOCBOOK_XML) { - - if (!priv->current_uri || - !yelp_uri_equal_path (uri, priv->current_uri)) { - /* Try to find it in the scrollkeeper database, - doesn't have to exist here */ - node = yelp_scrollkeeper_get_toc_tree (yelp_uri_get_path (uri)); - - if (node) { - gtk_widget_show (priv->tree_sw); - content_set_tree (YELP_VIEW_CONTENT (view), - node); - - } else { - if (gtk_widget_is_focus (priv->tree_sw)) { - reset_focus = TRUE; - } - - gtk_widget_hide (priv->tree_sw); - } - } - } else { - if (gtk_widget_is_focus (priv->tree_sw)) { - reset_focus = TRUE; - } - - gtk_widget_hide (priv->tree_sw); - - } - - if (reset_focus) { - gtk_widget_child_focus (GTK_WIDGET (view->widget), - GTK_DIR_TAB_FORWARD); - } - - priv->first = TRUE; - - cursor = gdk_cursor_new (GDK_WATCH); - - gdk_window_set_cursor (priv->html_widget->window, cursor); - gdk_cursor_unref (cursor); - - if (priv->current_uri) { - yelp_uri_unref (priv->current_uri); - } - - priv->current_uri = yelp_uri_ref (uri); - - yelp_html_set_base_uri (priv->html_view, uri); - - if (!yelp_reader_start (priv->reader, uri)) { - gchar *loading = _("Loading..."); - - yelp_html_clear (priv->html_view); - - yelp_html_printf (priv->html_view, - "<html><head><meta http-equiv=\"Content-Type\" " - "content=\"text/html; charset=utf-8\">" - "<title>%s</title></head>" - "<body><center>%s</center></body>" - "</html>", - loading, loading); - - yelp_html_close (priv->html_view); - } -} - -YelpView * -yelp_view_content_new (GNode *doc_tree) -{ - YelpViewContent *view; - YelpViewContentPriv *priv; - GtkTreeSelection *selection; - GtkWidget *html_sw; - GtkWidget *frame; - GtkWidget *hpaned; - - view = g_object_new (YELP_TYPE_VIEW_CONTENT, NULL); - priv = view->priv; - - hpaned = YELP_VIEW (view)->widget; - - priv->doc_tree = doc_tree; - - /* Setup the content tree */ - priv->tree_sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->tree_sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - gtk_tree_view_insert_column_with_attributes ( - GTK_TREE_VIEW (priv->content_tree), -1, - _("Section"), gtk_cell_renderer_text_new (), - "text", 0, - NULL); - - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (priv->content_tree)); - - g_signal_connect (selection, "changed", - G_CALLBACK (content_tree_selection_changed_cb), - view); - - gtk_container_add (GTK_CONTAINER (priv->tree_sw), priv->content_tree); - - /* Setup the Html view */ - html_sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (html_sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - - gtk_container_add (GTK_CONTAINER (frame), html_sw); - gtk_container_add (GTK_CONTAINER (html_sw), priv->html_widget); - - - /* Add the tree and html view to the paned */ - gtk_paned_add1 (GTK_PANED (hpaned), priv->tree_sw); - gtk_paned_add2 (GTK_PANED (hpaned), frame); - gtk_paned_set_position (GTK_PANED (hpaned), 175); - - return YELP_VIEW (view); -} - -static YelpHtml * -content_get_html (YelpView *view) -{ - YelpViewContent *content; - YelpViewContentPriv *priv; - - g_return_val_if_fail (YELP_IS_VIEW_CONTENT (view), NULL); - - content = YELP_VIEW_CONTENT (view); - priv = content->priv; - - return YELP_HTML (priv->html_view); -} diff --git a/src/yelp-view-content.h b/src/yelp-view-content.h deleted file mode 100644 index 8997f428..00000000 --- a/src/yelp-view-content.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001-2002 Mikael Hallendal <micke@imendio.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Mikael Hallendal <micke@imendio.com> - */ - -#ifndef __YELP_VIEW_CONTENT_H__ -#define __YELP_VIEW_CONTENT_H__ - -#include <gtk/gtkhpaned.h> -#include <gtk/gtktreemodel.h> - -#include "yelp-section.h" -#include "yelp-uri.h" -#include "yelp-view.h" - -#define YELP_TYPE_VIEW_CONTENT (yelp_view_content_get_type ()) -#define YELP_VIEW_CONTENT(o) (GTK_CHECK_CAST ((o), YELP_TYPE_VIEW_CONTENT, YelpViewContent)) -#define YELP_VIEW_CONTENT_CLASS(k) (GTK_CHECK_FOR_CAST((k), YELP_TYPE_VIEW_CONTENT, YelpViewContentClass)) -#define YELP_IS_VIEW_CONTENT(o) (GTK_CHECK_TYPE ((o), YELP_TYPE_VIEW_CONTENT)) -#define YELP_IS_VIEW_CONTENT_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), YELP_TYPE_VIEW_CONTENT)) - -typedef struct _YelpViewContent YelpViewContent; -typedef struct _YelpViewContentClass YelpViewContentClass; -typedef struct _YelpViewContentPriv YelpViewContentPriv; - -struct _YelpViewContent { - YelpView parent; - - YelpViewContentPriv *priv; -}; - -struct _YelpViewContentClass { - YelpViewClass parent_class; -}; - -GType yelp_view_content_get_type (void); - -YelpView * yelp_view_content_new (GNode *doc_tree); - -#endif /* __YELP_VIEW_CONTENT__ */ diff --git a/src/yelp-view-index.c b/src/yelp-view-index.c deleted file mode 100644 index a850b15d..00000000 --- a/src/yelp-view-index.c +++ /dev/null @@ -1,559 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001-2002 Mikael Hallendal <micke@imendio.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Mikael Hallendal <micke@imendio.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <atk/atk.h> -#include <gtk/gtkaccessible.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkframe.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkscrolledwindow.h> -#include <gtk/gtktreeview.h> -#include <gtk/gtktreeselection.h> -#include <libgnome/gnome-i18n.h> -#include <string.h> - -#include "yelp-index-model.h" -#include "yelp-html.h" -#include "yelp-marshal.h" -#include "yelp-reader.h" -#include "yelp-view-index.h" - -#define d(x) - -static void index_init (YelpViewIndex *view); -static void index_class_init (YelpViewIndexClass *klass); -static void index_index_selection_changed_cb (GtkTreeSelection *selection, - YelpViewIndex *content); -static void index_html_uri_selected_cb (YelpHtml *html, - YelpURI *uri, - gboolean handled, - YelpViewIndex *view); -static void index_entry_changed_cb (GtkEntry *entry, - YelpViewIndex *view); -static void index_entry_activated_cb (GtkEntry *entry, - YelpViewIndex *view); -static void index_entry_text_inserted_cb (GtkEntry *entry, - const gchar *text, - gint length, - gint *position, - YelpViewIndex *view); -static gboolean -index_complete_idle (YelpViewIndex *view); -static gboolean -index_filter_idle (YelpViewIndex *view); -static gchar * -index_complete_func (YelpSection *section); - -static void index_reader_data_cb (YelpReader *reader, - const gchar *data, - gint len, - YelpViewIndex *view); -static void index_reader_finished_cb (YelpReader *reader, - YelpURI *uri, - YelpViewIndex *view); - -static void index_show_uri (YelpView *view, - YelpURI *index_uri, - GError **error); - -static YelpHtml * -index_get_html (YelpView *view); - - -struct _YelpViewIndexPriv { - /* List of keywords */ - GtkWidget *index_view; - YelpIndexModel *model; - - /* Query entry */ - GtkWidget *entry; - - YelpReader *reader; - - /* Html view */ - YelpHtml *html_view; - GtkWidget *html_widget; - - GCompletion *completion; - - guint idle_complete; - guint idle_filter; - - gboolean first; -}; - -GType -yelp_view_index_get_type (void) -{ - static GType view_type = 0; - - if (!view_type) - { - static const GTypeInfo view_info = - { - sizeof (YelpViewIndexClass), - NULL, - NULL, - (GClassInitFunc) index_class_init, - NULL, - NULL, - sizeof (YelpViewIndex), - 0, - (GInstanceInitFunc) index_init, - }; - - view_type = g_type_register_static (YELP_TYPE_VIEW, - "YelpViewIndex", - &view_info, 0); - } - - return view_type; -} - -static void -index_init (YelpViewIndex *view) -{ - YelpViewIndexPriv *priv; - - priv = g_new0 (YelpViewIndexPriv, 1); - view->priv = priv; - YELP_VIEW(view)->widget = gtk_hpaned_new (); - - priv->idle_complete = 0; - priv->idle_filter = 0; - - priv->completion = - g_completion_new ((GCompletionFunc) index_complete_func); - - priv->index_view = gtk_tree_view_new (); - priv->model = yelp_index_model_new (); - - gtk_tree_view_set_model (GTK_TREE_VIEW (priv->index_view), - GTK_TREE_MODEL (priv->model)); - - priv->html_view = yelp_html_new (); - priv->html_widget = yelp_html_get_widget (priv->html_view); - - g_signal_connect (priv->html_view, "uri_selected", - G_CALLBACK (index_html_uri_selected_cb), - view); - - priv->reader = yelp_reader_new (); - - g_signal_connect (G_OBJECT (priv->reader), "data", - G_CALLBACK (index_reader_data_cb), - view); - g_signal_connect (G_OBJECT (priv->reader), "finished", - G_CALLBACK (index_reader_finished_cb), - view); -} - -static void -index_class_init (YelpViewIndexClass *klass) -{ - YelpViewClass *view_class = YELP_VIEW_CLASS (klass); - - view_class->show_uri = index_show_uri; - view_class->get_html = index_get_html; -} - -static void -index_index_selection_changed_cb (GtkTreeSelection *selection, - YelpViewIndex *view) -{ - YelpViewIndexPriv *priv; - GtkTreeIter iter; - YelpSection *section; - - g_return_if_fail (GTK_IS_TREE_SELECTION (selection)); - g_return_if_fail (YELP_IS_VIEW_INDEX (view)); - - priv = view->priv; - - if (gtk_tree_selection_get_selected (selection, NULL, &iter)) { - YelpURI *index_uri; - - gtk_tree_model_get (GTK_TREE_MODEL (priv->model), &iter, - YELP_INDEX_MODEL_COL_SECTION, §ion, - -1); - - d(g_print ("Index View: selection changed: %s\n", - yelp_uri_to_string (section->uri))); - - index_uri = yelp_uri_to_index (section->uri); - - g_signal_emit_by_name (view, "uri_selected", index_uri, FALSE); - - yelp_uri_unref (index_uri); - } -} - -static void -index_html_uri_selected_cb (YelpHtml *html, - YelpURI *uri, - gboolean handled, - YelpViewIndex *view) -{ - YelpURI *index_uri; - - g_return_if_fail (YELP_IS_VIEW_INDEX (view)); - - d(g_print ("Index View: uri selected: %s\n", - yelp_uri_to_string (uri))); - - index_uri = yelp_uri_to_index (uri); - g_signal_emit_by_name (view, "uri_selected", index_uri, handled); - yelp_uri_unref (index_uri); -} - -static void -index_entry_changed_cb (GtkEntry *entry, YelpViewIndex *view) -{ - YelpViewIndexPriv *priv; - - g_return_if_fail (GTK_IS_ENTRY (entry)); - g_return_if_fail (YELP_IS_VIEW_INDEX (view)); - - priv = view->priv; - - d(g_print ("Entry changed\n")); - - if (!priv->idle_filter) { - priv->idle_filter = - g_idle_add ((GSourceFunc) index_filter_idle, view); - } -} - -static void -index_entry_activated_cb (GtkEntry *entry, YelpViewIndex *view) -{ - YelpViewIndexPriv *priv; - gchar *str; - - g_return_if_fail (GTK_IS_ENTRY (entry)); - g_return_if_fail (YELP_IS_VIEW_INDEX (view)); - - priv = view->priv; - - str = (gchar *) gtk_entry_get_text (GTK_ENTRY (priv->entry)); - - yelp_index_model_filter (view->priv->model, str); -} - -static void -index_entry_text_inserted_cb (GtkEntry *entry, - const gchar *text, - gint length, - gint *position, - YelpViewIndex *view) -{ - YelpViewIndexPriv *priv; - - g_return_if_fail (YELP_IS_VIEW_INDEX (view)); - - priv = view->priv; - - if (!priv->idle_complete) { - priv->idle_complete = - g_idle_add ((GSourceFunc) index_complete_idle, view); - } -} - -static gboolean -index_complete_idle (YelpViewIndex *view) -{ - YelpViewIndexPriv *priv; - const gchar *text; - gchar *completed = NULL; - GList *list; - gint text_length; - - g_return_val_if_fail (YELP_IS_VIEW_INDEX (view), FALSE); - - priv = view->priv; - - text = gtk_entry_get_text (GTK_ENTRY (priv->entry)); - - list = g_completion_complete (priv->completion, - (gchar *)text, - &completed); - - if (completed) { - text_length = strlen (text); - - gtk_entry_set_text (GTK_ENTRY (priv->entry), completed); - gtk_editable_set_position (GTK_EDITABLE (priv->entry), - text_length); - gtk_editable_select_region (GTK_EDITABLE (priv->entry), - text_length, -1); - } - - priv->idle_complete = 0; - - return FALSE; -} - -static gboolean -index_filter_idle (YelpViewIndex *view) -{ - YelpViewIndexPriv *priv; - gchar *str; - - g_return_val_if_fail (YELP_IS_VIEW_INDEX (view), FALSE); - - priv = view->priv; - - d(g_print ("Filter idle\n")); - - str = (gchar *) gtk_entry_get_text (GTK_ENTRY (priv->entry)); - - yelp_index_model_filter (view->priv->model, str); - - priv->idle_filter = 0; - - return FALSE; -} - -static gchar * -index_complete_func (YelpSection *section) -{ - return section->name; -} - - -static void -index_reader_data_cb (YelpReader *reader, - const gchar *data, - gint len, - YelpViewIndex *view) -{ - YelpViewIndexPriv *priv; - - g_return_if_fail (YELP_IS_READER (reader)); - g_return_if_fail (YELP_IS_VIEW_INDEX (view)); - - priv = view->priv; - - if (priv->first) { - yelp_html_clear (priv->html_view); - priv->first = FALSE; - } - - if (len == -1) { - len = strlen (data); - } - - if (len <= 0) { - return; - } - - yelp_html_write (priv->html_view, data, len); -} - -static void -index_reader_finished_cb (YelpReader *reader, - YelpURI *uri, - YelpViewIndex *view) -{ - YelpViewIndexPriv *priv; - - g_return_if_fail (YELP_IS_READER (reader)); - g_return_if_fail (YELP_IS_VIEW_INDEX (view)); - - priv = view->priv; - - if (!priv->first) { - yelp_html_close (priv->html_view); - } - - gdk_window_set_cursor (priv->html_widget->window, NULL); - gtk_widget_grab_focus (priv->html_widget); -} - -static void -index_show_uri (YelpView *view, YelpURI *index_uri, GError **error) -{ - YelpViewIndexPriv *priv; - YelpURI *uri; - - g_return_if_fail (YELP_IS_VIEW_INDEX (view)); - g_return_if_fail (index_uri != NULL); - - priv = YELP_VIEW_INDEX (view)->priv; - - d(g_print ("Index show Uri: %s\n", yelp_uri_to_string (index_uri))); - - if (yelp_uri_no_path (index_uri)) { - return; - } - - uri = yelp_uri_from_index (index_uri); - - priv->first = TRUE; - - yelp_html_set_base_uri (priv->html_view, uri); - - if (!yelp_reader_start (priv->reader, uri)) { - gchar *loading = _("Loading..."); - - yelp_html_clear (priv->html_view); - - yelp_html_printf (priv->html_view, - "<html><head><meta http-equiv=\"Content-Type\" " - "content=\"text/html; charset=utf-8\">" - "<title>%s</title></head>" - "<body><center>%s</center></body>" - "</html>", - loading, loading); - - yelp_html_close (priv->html_view); - } - - /* FIXME: Handle the GError */ -/* yelp_html_open_uri (priv->html_view, uri, error); */ -} - -static YelpHtml * -index_get_html (YelpView *view) -{ - YelpViewIndex *index; - YelpViewIndexPriv *priv; - - g_return_val_if_fail (YELP_IS_VIEW_INDEX (view), NULL); - - index = YELP_VIEW_INDEX (view); - priv = index->priv; - - return YELP_HTML (priv->html_view); -} - -YelpView * -yelp_view_index_new (GList *index) -{ - YelpViewIndex *view; - YelpViewIndexPriv *priv; - GtkTreeSelection *selection; - GtkWidget *html_sw; - GtkWidget *list_sw; - GtkWidget *frame; - GtkWidget *box; - GtkWidget *hbox; - GtkWidget *label; - GtkWidget *hpaned; - - view = g_object_new (YELP_TYPE_VIEW_INDEX, NULL); - priv = view->priv; - - hpaned = YELP_VIEW (view)->widget; - - /* Setup the index box */ - box = gtk_vbox_new (FALSE, 0); - - hbox = gtk_hbox_new (FALSE, 0); - - label = gtk_label_new_with_mnemonic (_("_Search for:")); - - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4); - - priv->entry = gtk_entry_new (); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->entry); - - g_signal_connect (priv->entry, "changed", - G_CALLBACK (index_entry_changed_cb), - view); - - gtk_box_pack_end (GTK_BOX (hbox), priv->entry, FALSE, FALSE, 0); - - g_signal_connect (priv->entry, "activate", - G_CALLBACK (index_entry_activated_cb), - view); - - g_signal_connect (priv->entry, "insert-text", - G_CALLBACK (index_entry_text_inserted_cb), - view); - - gtk_box_pack_start (GTK_BOX (box), hbox, - FALSE, FALSE, 0); - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - - list_sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list_sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - gtk_container_add (GTK_CONTAINER (frame), list_sw); - - 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_set_headers_visible (GTK_TREE_VIEW (priv->index_view), - FALSE); - - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (priv->index_view)); - - g_signal_connect (selection, "changed", - G_CALLBACK (index_index_selection_changed_cb), - view); - - gtk_container_add (GTK_CONTAINER (list_sw), priv->index_view); - - gtk_box_pack_end_defaults (GTK_BOX (box), frame); - - /* Setup the Html view */ - html_sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (html_sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - frame = gtk_frame_new (NULL); - gtk_container_add (GTK_CONTAINER (frame), html_sw); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - - gtk_container_add (GTK_CONTAINER (html_sw), priv->html_widget); - - /* Add the tree and html view to the paned */ - gtk_paned_add1 (GTK_PANED (hpaned), box); - gtk_paned_add2 (GTK_PANED (hpaned), frame); - gtk_paned_set_position (GTK_PANED (hpaned), 250); - - d(g_print ("List length: %d\n", g_list_length (index))); - - g_completion_add_items (priv->completion, index); - yelp_index_model_set_words (priv->model, index); - - return YELP_VIEW (view); -} - - diff --git a/src/yelp-view-index.h b/src/yelp-view-index.h deleted file mode 100644 index 474912a8..00000000 --- a/src/yelp-view-index.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001-2002 Mikael Hallendal <micke@imendio.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Mikael Hallendal <micke@imendio.com> - */ - -#ifndef __YELP_VIEW_INDEX_H__ -#define __YELP_VIEW_INDEX_H__ - -#include <gtk/gtkhpaned.h> -#include <gtk/gtktreemodel.h> - -#include "yelp-section.h" -#include "yelp-view.h" - -#define YELP_TYPE_VIEW_INDEX (yelp_view_index_get_type ()) -#define YELP_VIEW_INDEX(o) (GTK_CHECK_CAST ((o), YELP_TYPE_VIEW_INDEX, YelpViewIndex)) -#define YELP_VIEW_INDEX_CLASS(k) (GTK_CHECK_FOR_CAST((k), YELP_TYPE_VIEW_INDEX, YelpViewIndexClass)) -#define YELP_IS_VIEW_INDEX(o) (GTK_CHECK_TYPE ((o), YELP_TYPE_VIEW_INDEX)) -#define YELP_IS_VIEW_INDEX_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), YELP_TYPE_VIEW_INDEX)) - -typedef struct _YelpViewIndex YelpViewIndex; -typedef struct _YelpViewIndexClass YelpViewIndexClass; -typedef struct _YelpViewIndexPriv YelpViewIndexPriv; - -struct _YelpViewIndex { - YelpView parent; - - YelpViewIndexPriv *priv; -}; - -struct _YelpViewIndexClass { - YelpViewClass parent_class; -}; - -GType yelp_view_index_get_type (void); -YelpView * yelp_view_index_new (GList *index); - -#endif /* __YELP_VIEW_INDEX__ */ diff --git a/src/yelp-view-toc.c b/src/yelp-view-toc.c deleted file mode 100644 index ac1135a9..00000000 --- a/src/yelp-view-toc.c +++ /dev/null @@ -1,911 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001-2002 Mikael Hallendal <micke@imendio.com> - * Copyright (C) 2002 Red Hat Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Mikael Hallendal <micke@imendio.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <libgnomevfs/gnome-vfs.h> -#include <libgnome/gnome-i18n.h> -#include <libxml/parser.h> - -#include <stdio.h> -#include <string.h> -#include <stdarg.h> - -#include "yelp-view-toc.h" -#include "yelp-marshal.h" -#include "yelp-util.h" -#include "yelp-html.h" -#include "yelp-scrollkeeper.h" - -#define d(x) - -static void toc_init (YelpViewTOC *html); -static void toc_class_init (YelpViewTOCClass *klass); -static void toc_man_1 (YelpViewTOC *view); -static void toc_man_2 (YelpViewTOC *view, - GNode *root); -static void toc_read_important_docs (YelpViewTOC *view); -static void toc_uri_selected_cb (YelpHtml *html, - YelpURI *uri, - gboolean handled, - YelpViewTOC *view); -static void toc_html_title_changed_cb (YelpHtml *html, - const gchar *title, - YelpViewTOC *view); -static void toc_page_start (YelpViewTOC *view, - const gchar *title, - const gchar *heading); -static void toc_page_end (YelpViewTOC *view); -static void toc_show_uri (YelpView *view, - YelpURI *uri, - GError **error); -static YelpHtml * -toc_get_html (YelpView *view); - - -typedef struct { - char *title; - GList *seriesids; -} YelpImportantDocsSection; - -#define BUFFER_SIZE 4096 - -struct _YelpViewTOCPriv { - YelpHtml *html_view; - GtkWidget *html_widget; - - GNode *doc_tree; - GList *important_sections; -}; - -GType -yelp_view_toc_get_type (void) -{ - static GType view_type = 0; - - if (!view_type) { - static const GTypeInfo view_info = - { - sizeof (YelpViewTOCClass), - NULL, - NULL, - (GClassInitFunc) toc_class_init, - NULL, - NULL, - sizeof (YelpViewTOC), - 0, - (GInstanceInitFunc) toc_init, - }; - - view_type = g_type_register_static (YELP_TYPE_VIEW, - "YelpViewTOC", - &view_info, 0); - } - - return view_type; -} - -static void -toc_init (YelpViewTOC *view) -{ - YelpViewTOCPriv *priv; - - priv = g_new0 (YelpViewTOCPriv, 1); - view->priv = priv; - - toc_read_important_docs (view); - - priv->html_view = yelp_html_new (); - priv->html_widget = yelp_html_get_widget (priv->html_view); - YELP_VIEW (view)->widget = priv->html_widget; - - g_signal_connect (priv->html_view, "uri_selected", - G_CALLBACK (toc_uri_selected_cb), - view); - - g_signal_connect (priv->html_view, "title_changed", - G_CALLBACK (toc_html_title_changed_cb), - view); -} - -static void -toc_class_init (YelpViewTOCClass *klass) -{ - YelpViewClass *view_class = YELP_VIEW_CLASS (klass); - - view_class->show_uri = toc_show_uri; - view_class->get_html = toc_get_html; -} - -#if 0 -static void -toc_write_footer (YelpViewTOC *view) -{ - char *footer="\n" - " </body>\n" - "</html>\n"; - - yelp_html_write (view->priv->html_view, footer, -1); -} -#endif - -static void -toc_start (YelpViewTOC *view) -{ - YelpViewTOCPriv *priv; - GNode *node; - YelpSection *section; -/* char *seriesid; */ - GNode *root; - char *path; - GList *sections; -/* GList *seriesids; */ - gchar *page_title = _("Help Contents"); - gchar *section_gnome = _("GNOME - Desktop"); - gchar *section_additional = _("Additional documents"); - gchar *man_string = _("Manual Pages"); - gchar *info_string = _("Info Pages"); -/* YelpImportantDocsSection *important_section; */ -/* gboolean important_doc_installed = FALSE; */ - - priv = view->priv; - - if (!g_node_first_child (priv->doc_tree)) { - g_warning ("No nodes in tree"); - } - - yelp_html_clear (priv->html_view); - - toc_page_start (view, page_title, page_title); - - sections = priv->important_sections; - -#if 0 - while (sections != NULL) { - important_section = sections->data; - - seriesids = important_section->seriesids; - - /* Check if any of the important documents are installed * - * before trying to write the section topic */ - - for (seriesids = important_section->seriesids; - seriesids; - seriesids = seriesids->next) { - seriesid = seriesids->data; - - if (yelp_scrollkeeper_lookup_seriesid (seriesid)){ - important_doc_installed = TRUE; - } - } - - if (important_doc_installed) { - if (!left_column_started) { - yelp_html_printf (priv->html_view, - COLUMN_LEFT_START); - left_column_started = TRUE; - } - - yelp_html_printf (priv->html_view, - TOC_BLOCK_SEPARATOR - TOC_BLOCK_START - "<h2>%s</h2>", - important_section->title); - } - - seriesids = important_section->seriesids; - - while (seriesids != NULL) { - seriesid = seriesids->data; - - node = yelp_scrollkeeper_lookup_seriesid (seriesid); - - if (node) { - gchar *str_uri; - - section = node->data; - - str_uri = yelp_uri_to_string (section->uri); - - yelp_html_printf (priv->html_view, - "<a href=\"%s\">%s</a>\n", - str_uri, - section->name); - g_free (str_uri); - } - - seriesids = seriesids->next; - } - - if (important_doc_installed) { - yelp_html_printf (priv->html_view, - TOC_BLOCK_END); - if (sections->next) { - yelp_html_printf (priv->html_view, - TOC_BLOCK_SEPARATOR); - } - } - - sections = sections->next; - important_doc_installed = FALSE; - } - - if (left_column_started) { - yelp_html_printf (priv->html_view, COLUMN_END); - } - - - yelp_html_printf (priv->html_view, - COLUMN_RIGHT_START); -#endif - - root = yelp_util_find_toplevel (priv->doc_tree, "scrollkeeper"); - node = g_node_first_child (root); - - yelp_html_printf (priv->html_view, - "<td colspan=\"2\"><h2>%s</h2><ul>", - section_gnome); - - root = yelp_util_find_node_from_name (priv->doc_tree, "GNOME"); - node = g_node_first_child (root); - - while (node) { - section = YELP_SECTION (node->data); - path = yelp_util_node_to_string_path (node); - yelp_html_printf (priv->html_view, - "<li><a href=\"toc:scrollkeeper/%s\">%s</a><br>\n", - path, section->name); - g_free (path); - - node = g_node_next_sibling (node); - } - - yelp_html_printf (priv->html_view,"</ul>"); - - yelp_html_printf (priv->html_view, - "<br><h2>%s</h2><ul>", - section_additional); - - root = yelp_util_find_toplevel (priv->doc_tree, "scrollkeeper"); - node = g_node_first_child (root); - - while (node) { - section = YELP_SECTION (node->data); - if (strcmp (section->name, "GNOME")) { - path = yelp_util_node_to_string_path (node); - yelp_html_printf (priv->html_view, - "<li><a href=\"toc:scrollkeeper/%s\">%s</a><br>\n", - path, section->name); - g_free (path); - - } - node = g_node_next_sibling (node); - } - - if (yelp_util_find_toplevel (priv->doc_tree, "man")) { - yelp_html_printf (priv->html_view, - "<li><a href=\"toc:man\">%s</a><br>\n", - man_string); - } - - if (yelp_util_find_toplevel (priv->doc_tree, "info")) { - yelp_html_printf (priv->html_view, - "<li><a href=\"toc:info\">%s</a><br>\n", - info_string); - } - - yelp_html_printf (priv->html_view, - "</ul></td><td></td></tr>"); - - toc_page_end (view); - - yelp_html_close (priv->html_view); -} - -static char * -toc_full_path_name (YelpViewTOC *view, GNode *node) -{ - char *str, *t; - YelpSection *section; - - section = node->data; - - str = g_strdup (section->name); - - while (node->parent) { - node = node->parent; - - if (node->parent == NULL || - node->parent->data == NULL) { - /* Skip top node */ - break; - } - - section = node->data; - - t = g_strconcat (section->name, "/", str, NULL); - g_free (str); - str = t; - } - return str; -} - -static void -toc_man_emit (YelpViewTOC *view, GNode *first) -{ - YelpViewTOCPriv *priv; - GNode *node, *child; - YelpSection *section; - gboolean got_a_leaf; - char *path, *url; - char *tmp; - int i; - gboolean sub_started = FALSE; - gchar *str_docs = _("Documents"); - gchar *str_subcats = _("Categories"); - - priv = view->priv; - - got_a_leaf = FALSE; - node = first; - do { - if (node->children != NULL) { - if (!sub_started) { - yelp_html_printf (priv->html_view, "<h3>%s</h3>", - str_subcats); - - sub_started = TRUE; - } - - child = node->children; - - section = node->data; - - path = yelp_util_node_to_string_path (node); - yelp_html_printf (priv->html_view, "<a href=\"toc:man/%s\">%s</a><br>\n", path, section->name); - g_free (path); - } else { - got_a_leaf = TRUE; - } - } while ((node = node->next) != NULL); - - if (sub_started) { - yelp_html_printf (priv->html_view, "<br>\n"); - } - - if (got_a_leaf) { - yelp_html_printf (priv->html_view, "<h3>%s</h3>", str_docs); - - yelp_html_write (priv->html_view, - "<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%%\">\n", - -1); - - i = 0; - node = first; - do { - if (node->children == NULL) { - YelpSection *section; - - if (i % 3 == 0) { - if (i == 0) { - yelp_html_write (priv->html_view, - "<tr>\n", - -1); - } else { - yelp_html_write (priv->html_view, - "</tr>\n<tr>\n", - -1); - } - } - - section = node->data; - url = yelp_util_compose_path_url (node->parent, yelp_uri_get_path (section->uri)); - tmp = yelp_uri_to_string (section->uri); - yelp_html_printf (priv->html_view, "<td valign=\"Top\"><a href=\"%s\">%s</a></td>\n", tmp, - section->name); - g_free (url); - g_free (tmp); - i++; - } - } while ((node = node->next) != NULL); - - yelp_html_write (priv->html_view, "</tr>\n", -1); - yelp_html_write (priv->html_view, "</table>\n", -1); - - } -} - -static void -toc_man_2 (YelpViewTOC *view, - GNode *root) -{ - YelpViewTOCPriv *priv; - GNode *first; - gchar *name; - gchar *string = _("Manual pages"); - gchar *title; - - g_return_if_fail (YELP_IS_VIEW_TOC (view)); - - priv = view->priv; - - if (root->children == NULL) { - return; - } - - first = root->children; - - yelp_html_clear (priv->html_view); - - name = toc_full_path_name (view, root); - - title = g_strdup_printf ("%s/%s", string, name); - - toc_page_start (view, title, string); - - yelp_html_printf (priv->html_view, - "<td colspan=\"2\"><h2>%s</h2><ul>", - title); - - g_free (title); - g_free (name); - - toc_man_emit (view, first); - - yelp_html_printf (priv->html_view, - "</td></tr>\n"); - - toc_page_end (view); - - yelp_html_close (priv->html_view); -} - -static void -toc_man_1 (YelpViewTOC *view) -{ - YelpViewTOCPriv *priv; - GNode *root, *node, *child; - YelpSection *section; - char *path; - gchar *string = _("Manual Pages"); - gchar *str_subcats = _("Categories"); - - priv = view->priv; - - root = yelp_util_find_toplevel (priv->doc_tree, "man"); - - if (!root) { - g_warning ("Unable to find man toplevel"); - return; - } - - node = g_node_first_child (root); - - if (!node) { - g_warning ("Unable to find man categories"); - return; - } - - yelp_html_clear (priv->html_view); - - toc_page_start (view, string, string); - - yelp_html_printf (priv->html_view, - "<td colspan=\"2\"><h2>%s</h2><ul>", - str_subcats); - - do { - child = g_node_first_child (node); - - if (child) { - section = YELP_SECTION (node->data); - path = yelp_util_node_to_string_path (node); - - yelp_html_printf (priv->html_view, - "<li><a href=\"toc:man/%s\">%s</a><br>\n", - path, section->name); - - g_free (path); - } - } while ((node = g_node_next_sibling (node))); - - yelp_html_printf (priv->html_view, - "</ul></td></tr>"); - - toc_page_end (view); - - yelp_html_close (priv->html_view); -} - -static void -toc_info (YelpViewTOC *view) -{ - YelpViewTOCPriv *priv; - GNode *root, *node; - YelpSection *section; - gchar *string = _("Info Pages"); - gchar *str_docs = _("Documents"); - - priv = view->priv; - - root = yelp_util_find_toplevel (priv->doc_tree, "info"); - - if (!root) { - g_warning ("Unable to find info toplevel"); - return; - } - - node = g_node_first_child (root); - - if (!node) { - d(g_print ("No first node\n")); - return; - } - - yelp_html_clear (priv->html_view); - - toc_page_start (view, string, string); - - yelp_html_printf (priv->html_view, - "<td colspan=\"2\"><h2>%s</h2><ul>", str_docs); - - do { - gchar *str_uri; - - section = YELP_SECTION (node->data); - - str_uri = yelp_uri_to_string (section->uri); - - yelp_html_printf (priv->html_view, - "<li><a href=\"%s\">%s</a><br>\n", - str_uri, - section->name); - g_free (str_uri); - } while ((node = g_node_next_sibling (node))); - - yelp_html_printf (priv->html_view, - "</ul></td></tr>"); - - toc_page_end (view); - - yelp_html_close (priv->html_view); -} - -static void -toc_read_important_docs (YelpViewTOC *view) -{ - xmlDocPtr doc; - xmlNodePtr node; - xmlNodePtr child; - xmlNodePtr section; - xmlNodePtr title; - xmlChar *prop; - YelpImportantDocsSection *important_section; - - doc = xmlParseFile (DATADIR "/yelp/important_docs.xml"); - if (doc == NULL) { - return; - } - - node = xmlDocGetRootElement (doc); - if (node == NULL) { - xmlFreeDoc(doc); - return; - } - - if (strcmp (node->name, "docs") != 0) { - xmlFreeDoc(doc); - return; - } - - section = node->children; - while (section) { - if (strcmp (section->name, "section") == 0) { - important_section = g_new0 (YelpImportantDocsSection, 1); - child = section->children; - while (child) { - if (strcmp (child->name, "title") == 0) { - title = child->children; - if (title && title->type == XML_TEXT_NODE) - important_section->title = g_strdup (title->content); - } else if (strcmp (child->name, "document") == 0) { - prop = xmlGetProp (child, "seriesid"); - if (prop) { - important_section->seriesids = - g_list_append (important_section->seriesids, g_strdup (prop)); - xmlFree (prop); - } - - } - child = child->next; - - } - view->priv->important_sections = - g_list_append (view->priv->important_sections, - important_section); - } - section = section->next; - } - - xmlFreeDoc(doc); -} - -static void -toc_uri_selected_cb (YelpHtml *html, - YelpURI *uri, - gboolean handled, - YelpViewTOC *view) -{ - g_signal_emit_by_name (view, "uri_selected", uri, FALSE); -} - -static void -toc_html_title_changed_cb (YelpHtml *html, - const gchar *title, - YelpViewTOC *view) -{ - g_signal_emit_by_name (view, "title_changed", title); -} - -static void -toc_page_start (YelpViewTOC *view, const gchar *title, const gchar *heading) -{ - YelpViewTOCPriv *priv; - - g_return_if_fail (YELP_IS_VIEW_TOC (view)); - g_return_if_fail (title != NULL); - g_return_if_fail (heading != NULL); - - priv = view->priv; - - yelp_html_printf (priv->html_view, - "<html>\n" - "<head>\n" - "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n" - "<title>%s</title>\n" - "</head>\n" - "<body marginwidth=\"0\"\n" - "background=\"file:" IMAGEDIR "/bcg.png\" marginheight=\"0\"\n" - "border=\"10\" topmargin=\"0\" leftmargin=\"0\">\n<br><br>" - "<table width=\"100%%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\">\n" - "<tr valign=\"top\">\n" - "<td width=\"75\"></td>\n" - "<td colspan=\"2\"><h1>%s</h1></td>\n" - "</tr>\n" - "<tr valign=\"top\">\n" - "<td width=\"75\"></td>\n", - title, - heading); -} - -static void -toc_page_end (YelpViewTOC *view) -{ - YelpViewTOCPriv *priv; - gchar *str_gnome_is = _("GNOME is"); - gchar *str_fs = _("Free Software"); - gchar *str_copyright = _("(C)"); - - g_return_if_fail (YELP_IS_VIEW_TOC (view)); - - priv = view->priv; - - yelp_html_printf (priv->html_view, - "<tr>\n" - "<td width=\"75\"></td>\n" - "<td colspan=\"2\"></td>\n" - "<td></td></tr>\n" - "<tr valign=\"top\">\n" - "<td width=\"75\"></td>\n" - "</tr>\n" - "</table></body></html>\n", - str_gnome_is, - str_fs, - str_copyright); -} - - -static void -toc_scrollkeeper (YelpViewTOC *view, GNode *root) -{ - YelpViewTOCPriv *priv; - GNode *node, *child; - YelpSection *section; - gboolean got_a_leaf; - char *path; - gchar *name; - gboolean sub_started = FALSE; - gchar *str_docs = _("Documents"); - gchar *str_subcats = _("Categories"); - - priv = view->priv; - - if (root->children == NULL) { - return; - } - - name = toc_full_path_name (view, root); - - yelp_html_clear (priv->html_view); - - toc_page_start (view, name, name); - - yelp_html_printf (priv->html_view, "<td colspan=\"2\">"); - - g_free (name); - - got_a_leaf = FALSE; - node = root->children; - - for (node = root->children; node; node = node->next) { - - if (node->children != NULL) { - if (!sub_started) { - yelp_html_printf (priv->html_view, "<h2>%s</h2><ul>", - str_subcats); - - sub_started = TRUE; - } - - child = node->children; - - section = node->data; - - path = yelp_util_node_to_string_path (node); - - yelp_html_printf (priv->html_view, - "<li><a href=\"toc:scrollkeeper/%s\">%s</a>\n", - path, section->name); - g_free (path); - } else { - got_a_leaf = TRUE; - } - } - - if (sub_started) { - yelp_html_printf (priv->html_view, "</ul><br>\n"); - } - - if (got_a_leaf) { - yelp_html_printf (priv->html_view, - "<h2>%s</h2><ul>", - str_docs); - - for (node = root->children; node; node = node->next) { - if (node->children == NULL) { - gchar *str_uri; - - YelpSection *section; - - section = node->data; - str_uri = yelp_uri_to_string (section->uri); - - yelp_html_printf (priv->html_view, - "<li><a href=\"%s\">%s</a>\n", - str_uri, - section->name); - g_free (str_uri); - } - } - } - - yelp_html_printf (priv->html_view, - "</ul></td></tr>"); - - toc_page_end (view); - - yelp_html_close (priv->html_view); -} - -static void -toc_show_uri (YelpView *view, YelpURI *uri, GError **error) -{ - YelpViewTOCPriv *priv; - GNode *node; - const gchar *path; - - g_return_if_fail (YELP_IS_VIEW_TOC (view)); - - g_assert (yelp_uri_get_type (uri) == YELP_URI_TYPE_TOC); - - priv = YELP_VIEW_TOC(view)->priv; - - yelp_html_set_base_uri (priv->html_view, uri); - - path = yelp_uri_get_path (uri); - - d(g_print ("PATH:[%s]\n", path)); - - if (!strcmp (path, "")) { - toc_start (YELP_VIEW_TOC (view)); - } - else if (strncmp (path, "man", 3) == 0) { - path += 3; - if (path[0] == 0) { - toc_man_1 (YELP_VIEW_TOC (view)); - } else if (path[0] == '/') { - /* Calculate where it should go */ - path++; - - node = yelp_util_string_path_to_node (path, - priv->doc_tree); - if (node) { - toc_man_2 (YELP_VIEW_TOC (view), node); - } else { - g_warning ("Bad path in toc url %s\n", - yelp_uri_to_string (uri)); - } - } - } else if (strcmp (path, "info") == 0) { - toc_info (YELP_VIEW_TOC (view)); - } else if (strncmp (path, "scrollkeeper", strlen ("scrollkeeper")) == 0) { - path = path + strlen ("scrollkeeper"); - if (path[0] == '/') { - /* Calculate where it should go */ - path++; - - node = yelp_util_string_path_to_node (path, - priv->doc_tree); - if (node) { - toc_scrollkeeper (YELP_VIEW_TOC (view), node); - } else { - g_warning ("Bad path in toc url %s\n", - yelp_uri_to_string (uri)); - } - } - } else { - g_warning ("Unknown toc type %s\n", - yelp_uri_to_string (uri)); - } -} - -static YelpHtml * -toc_get_html (YelpView *view) -{ - YelpViewTOC *toc; - YelpViewTOCPriv *priv; - - g_return_val_if_fail (YELP_IS_VIEW_TOC (view), NULL); - - toc = YELP_VIEW_TOC (view); - priv = toc->priv; - - return YELP_HTML (priv->html_view); -} - -YelpView * -yelp_view_toc_new (GNode *doc_tree) -{ - YelpViewTOC *view; - YelpViewTOCPriv *priv; - - view = g_object_new (YELP_TYPE_VIEW_TOC, NULL); - - priv = view->priv; - - priv->doc_tree = doc_tree; - - return YELP_VIEW (view); -} diff --git a/src/yelp-view-toc.h b/src/yelp-view-toc.h deleted file mode 100644 index 9d3c9f4a..00000000 --- a/src/yelp-view-toc.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2001-2002 Mikael Hallendal <micke@imendio.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Mikael Hallendal <micke@imendio.com> - */ - -#ifndef __YELP_VIEW_TOC_H__ -#define __YELP_VIEW_TOC_H__ - -#include <gtk/gtktreemodel.h> -#include <gtk/gtkwidget.h> - -#include "yelp-section.h" -#include "yelp-uri.h" -#include "yelp-view.h" - -#define YELP_TYPE_VIEW_TOC (yelp_view_toc_get_type ()) -#define YELP_VIEW_TOC(o) (GTK_CHECK_CAST ((o), YELP_TYPE_VIEW_TOC, YelpViewTOC)) -#define YELP_VIEW_TOC_CLASS(k)(GTK_CHECK_FOR_CAST((k), YELP_TYPE_VIEW_TOC, YelpViewTOCClass)) -#define YELP_IS_VIEW_TOC(o) (GTK_CHECK_TYPE ((o), YELP_TYPE_VIEW_TOC)) -#define YELP_IS_VIEW_TOC_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), YELP_TYPE_VIEW_TOC)) - -typedef struct _YelpViewTOC YelpViewTOC; -typedef struct _YelpViewTOCClass YelpViewTOCClass; -typedef struct _YelpViewTOCPriv YelpViewTOCPriv; - -struct _YelpViewTOC { - YelpView parent; - - YelpViewTOCPriv *priv; -}; - -struct _YelpViewTOCClass { - YelpViewClass parent_class; -}; - -GType yelp_view_toc_get_type (void); -YelpView *yelp_view_toc_new (GNode *doc_tree); - -#endif /* __YELP_VIEW_TOC__ */ diff --git a/src/yelp-view.c b/src/yelp-view.c deleted file mode 100644 index cbd96c7c..00000000 --- a/src/yelp-view.c +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2002 Mikael Hallendal <micke@imendio.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Mikael Hallendal <micke@imendio.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <atk/atk.h> -#include <gtk/gtkaccessible.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkframe.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkscrolledwindow.h> -#include <gtk/gtktreeview.h> -#include <gtk/gtktreeselection.h> -#include <libgnome/gnome-i18n.h> -#include <string.h> - -#include "yelp-index-model.h" -#include "yelp-html.h" -#include "yelp-marshal.h" -#include "yelp-reader.h" -#include "yelp-view.h" - -#define d(x) - -static void view_init (YelpView *view); -static void view_class_init (YelpViewClass *klass); - -enum { - URI_SELECTED, - TITLE_CHANGED, - LAST_SIGNAL -}; - -static gint signals[LAST_SIGNAL] = { 0 }; - -GType -yelp_view_get_type (void) -{ - static GType view_type = 0; - - if (!view_type) - { - static const GTypeInfo view_info = - { - sizeof (YelpViewClass), - NULL, - NULL, - (GClassInitFunc) view_class_init, - NULL, - NULL, - sizeof (YelpView), - 0, - (GInstanceInitFunc) view_init, - }; - - view_type = g_type_register_static (G_TYPE_OBJECT, - "YelpView", - &view_info, 0); - } - - return view_type; -} - -static void -view_init (YelpView *view) -{ -} - -static void -view_class_init (YelpViewClass *klass) -{ - signals[URI_SELECTED] = - g_signal_new ("uri_selected", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (YelpViewClass, - uri_selected), - NULL, NULL, - yelp_marshal_VOID__POINTER_BOOLEAN, - G_TYPE_NONE, - 2, G_TYPE_POINTER, G_TYPE_BOOLEAN); - - signals[TITLE_CHANGED] = - g_signal_new ("title_changed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (YelpViewClass, - title_changed), - NULL, NULL, - yelp_marshal_VOID__STRING, - G_TYPE_NONE, - 1, G_TYPE_STRING); - - klass->show_uri = NULL; -} - -void -yelp_view_show_uri (YelpView *view, YelpURI *uri, GError **error) -{ - if (YELP_VIEW_GET_CLASS (view)->show_uri) { - YELP_VIEW_GET_CLASS (view)->show_uri (view, uri, error); - } -} - -YelpHtml * -yelp_view_get_html (YelpView *view) -{ - if (YELP_VIEW_GET_CLASS (view)->get_html) { - return YELP_VIEW_GET_CLASS (view)->get_html (view); - } - - return NULL; -} diff --git a/src/yelp-view.h b/src/yelp-view.h deleted file mode 100644 index d968f037..00000000 --- a/src/yelp-view.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2002 Mikael Hallendal <micke@imendio.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Mikael Hallendal <micke@imendio.com> - */ - -#ifndef __YELP_INDEX_H__ -#define __YELP_INDEX_H__ - -#include <gtk/gtkhpaned.h> -#include <gtk/gtktreemodel.h> -#include "yelp-section.h" -#include "yelp-html.h" - -#define YELP_TYPE_VIEW (yelp_view_get_type ()) -#define YELP_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), YELP_TYPE_VIEW, YelpView)) -#define YELP_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), YELP_TYPE_VIEW, YelpViewClass)) -#define YELP_IS_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), YELP_TYPE_VIEW)) -#define YELP_IS_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), YELP_TYPE_VIEW)) -#define YELP_VIEW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), YELP_TYPE_VIEW, YelpViewClass)) - -typedef struct _YelpView YelpView; -typedef struct _YelpViewClass YelpViewClass; -typedef struct _YelpViewPriv YelpViewPriv; - -struct _YelpView { - GObject parent; - - GtkWidget *widget; -}; - -struct _YelpViewClass { - GObjectClass parent_class; - - /* Signals */ - void (*uri_selected) (YelpView *view, - YelpURI *uri, - gboolean handled); - void (*title_changed) (YelpView *view, - const gchar *new_title); - - /* Virtual functions */ - void (*show_uri) (YelpView *view, - YelpURI *uri, - GError **error); - YelpHtml * (*get_html) (YelpView *view); -}; - -GType yelp_view_get_type (void); - -void yelp_view_show_uri (YelpView *view, - YelpURI *uri, - GError **error); - -YelpHtml * yelp_view_get_html (YelpView *view); - -#endif /* __YELP_INDEX__ */ |