summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@src.gnome.org>2004-10-10 21:13:12 +0000
committerShaun McCance <shaunm@src.gnome.org>2004-10-10 21:13:12 +0000
commita61a0131aac024d4bcba808eb14fd17ba53b51f0 (patch)
tree016e72b3ae92cd2f5c8f836e5b4fbcc0876e448a
parentefc810987e3db0848804a8cd4d73373f141349cf (diff)
downloadyelp-a61a0131aac024d4bcba808eb14fd17ba53b51f0.tar.gz
- Removed yelp-history, using a simple stack in yelp-window
* src/Makefile.am: * src/yelp-history.c: * src/yelp-history.h: * src/yelp-window.c: - Removed yelp-history, using a simple stack in yelp-window
-rw-r--r--ChangeLog8
-rw-r--r--src/Makefile.am1
-rw-r--r--src/yelp-history.c329
-rw-r--r--src/yelp-history.h68
-rw-r--r--src/yelp-window.c407
5 files changed, 257 insertions, 556 deletions
diff --git a/ChangeLog b/ChangeLog
index 13b9cbc2..df0c1bc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-10-10 Shaun McCance <shaunm@gnome.org>
+
+ * src/Makefile.am:
+ * src/yelp-history.c:
+ * src/yelp-history.h:
+ * src/yelp-window.c:
+ - Removed yelp-history, using a simple stack in yelp-window
+
2004-10-08 Shaun McCance <shaunm@gnome.org>
* src/yelp-window.c:
diff --git a/src/Makefile.am b/src/Makefile.am
index 703da475..8c60ef54 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -83,7 +83,6 @@ yelp_SOURCES = \
yelp-cache.c yelp-cache.h \
yelp-db-pager.c yelp-db-pager.h \
yelp-error.c yelp-error.h \
- yelp-history.c yelp-history.h \
yelp-html-gecko.c yelp-html.h \
yelp-gecko-utils.cpp yelp-gecko-utils.h \
yelp-io-channel.c yelp-io-channel.h \
diff --git a/src/yelp-history.c b/src/yelp-history.c
deleted file mode 100644
index 46656102..00000000
--- a/src/yelp-history.c
+++ /dev/null
@@ -1,329 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * 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 <string.h>
-#include "yelp-history.h"
-
-static void history_init (YelpHistory *history);
-static void history_class_init (YelpHistoryClass *klass);
-static void history_finalize (GObject *object);
-static void history_free_history_list (GList *history_list);
-
-static void history_maybe_emit (YelpHistory *history);
-
-enum {
- FORWARD_EXISTS_CHANGED,
- BACK_EXISTS_CHANGED,
- LAST_SIGNAL
-};
-
-static GObjectClass *parent_class;
-
-static gint signals[LAST_SIGNAL] = { 0 };
-
-struct _YelpHistoryPriv {
- GList *history_list;
- GList *current;
-
- gboolean last_emit_forward;
- gboolean last_emit_back;
-};
-
-GType
-yelp_history_get_type (void)
-{
- static GType history_type = 0;
-
- if (!history_type) {
- static const GTypeInfo history_info = {
- sizeof (YelpHistoryClass),
- NULL,
- NULL,
- (GClassInitFunc) history_class_init,
- NULL,
- NULL,
- sizeof (YelpHistory),
- 0,
- (GInstanceInitFunc) history_init,
- };
-
- history_type = g_type_register_static (G_TYPE_OBJECT,
- "YelpHistory",
- &history_info, 0);
- }
-
- return history_type;
-}
-
-static void
-history_init (YelpHistory *history)
-{
- YelpHistoryPriv *priv;
-
- priv = g_new0 (YelpHistoryPriv, 1);
-
- priv->history_list = NULL;
- priv->current = NULL;
- priv->last_emit_forward = FALSE;
- priv->last_emit_back = FALSE;
- history->priv = priv;
-}
-
-static void
-history_class_init (YelpHistoryClass *klass)
-{
- GObjectClass *object_class;
-
- parent_class = g_type_class_peek_parent (klass);
-
- object_class = (GObjectClass *) klass;
-
- object_class->finalize = history_finalize;
-
- signals[FORWARD_EXISTS_CHANGED] =
- g_signal_new ("forward_exists_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (YelpHistoryClass,
- forward_exists_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE,
- 1, G_TYPE_BOOLEAN);
-
- signals[BACK_EXISTS_CHANGED] =
- g_signal_new ("back_exists_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (YelpHistoryClass,
- back_exists_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE,
- 1, G_TYPE_BOOLEAN);
-}
-
-static void
-history_finalize (GObject *object)
-{
- YelpHistory *history;
- YelpHistoryPriv *priv;
- GList *node;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (YELP_IS_HISTORY (object));
-
- history = YELP_HISTORY (object);
- priv = history->priv;
-
- for (node = priv->history_list; node; node = node->next) {
- g_object_unref (G_OBJECT (node->data));
- }
-
- g_list_free (priv->history_list);
-
- g_free (priv);
-
- history->priv = NULL;
-
- (* parent_class->finalize) (object);
-}
-
-static void
-history_free_history_list (GList *history_list)
-{
- GList *node;
-
- for (node = history_list; node; node = node->next)
- g_free (node->data);
-
- g_list_free (history_list);
-}
-
-static void
-history_maybe_emit (YelpHistory *history)
-{
- YelpHistoryPriv *priv;
-
- g_return_if_fail (history != NULL);
- g_return_if_fail (YELP_IS_HISTORY (history));
-
- priv = history->priv;
-
- if (priv->last_emit_forward != yelp_history_exist_forward (history)) {
- priv->last_emit_forward = yelp_history_exist_forward (history);
-
- g_signal_emit (history,
- signals[FORWARD_EXISTS_CHANGED],
- 0, priv->last_emit_forward);
- }
-
- if (priv->last_emit_back != yelp_history_exist_back (history)) {
- priv->last_emit_back = yelp_history_exist_back (history);
-
- g_signal_emit (history,
- signals[BACK_EXISTS_CHANGED],
- 0, priv->last_emit_back);
- }
-}
-
-void
-yelp_history_goto (YelpHistory *history, const gchar *uri)
-{
- YelpHistoryPriv *priv;
- GList *forward_list;
-
- g_return_if_fail (history != NULL);
- g_return_if_fail (YELP_IS_HISTORY (history));
-
- priv = history->priv;
-
- if (priv->current && priv->current->data) {
- gchar *cur_uri = (gchar *) priv->current->data;
- if (g_str_equal (cur_uri, uri))
- return;
- }
-
- if (yelp_history_exist_forward (history)) {
- forward_list = priv->current->next;
- priv->current->next = NULL;
-
- history_free_history_list (forward_list);
- }
-
- priv->history_list = g_list_append (priv->history_list,
- g_strdup (uri));
-
- priv->current = g_list_last (priv->history_list);
-
- history_maybe_emit (history);
-}
-
-const gchar *
-yelp_history_go_forward (YelpHistory *history)
-{
- YelpHistoryPriv *priv;
-
- g_return_val_if_fail (history != NULL, NULL);
- g_return_val_if_fail (YELP_IS_HISTORY (history), NULL);
-
- priv = history->priv;
-
- if (priv->current->next) {
- priv->current = priv->current->next;
-
- history_maybe_emit (history);
-
- return (const gchar *) priv->current->data;
- }
-
- return NULL;
-}
-
-const gchar *
-yelp_history_go_back (YelpHistory *history)
-{
- YelpHistoryPriv *priv;
-
- g_return_val_if_fail (history != NULL, NULL);
- g_return_val_if_fail (YELP_IS_HISTORY (history), NULL);
-
- priv = history->priv;
-
- if (priv->current->prev) {
- priv->current = priv->current->prev;
-
- history_maybe_emit (history);
-
- return (const gchar *) priv->current->data;
- }
-
- return NULL;
-}
-
-const gchar *
-yelp_history_get_current (YelpHistory *history)
-{
- YelpHistoryPriv *priv;
-
- g_return_val_if_fail (history != NULL, NULL);
- g_return_val_if_fail (YELP_IS_HISTORY (history), NULL);
-
- priv = history->priv;
-
- if (!priv->current)
- return NULL;
-
- return (const gchar *) priv->current->data;
-}
-
-gboolean
-yelp_history_exist_forward (YelpHistory *history)
-{
- YelpHistoryPriv *priv;
-
- g_return_val_if_fail (history != NULL, FALSE);
- g_return_val_if_fail (YELP_IS_HISTORY (history), FALSE);
-
- priv = history->priv;
-
- if (!priv->current) {
- return FALSE;
- }
-
- if (priv->current->next) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-gboolean
-yelp_history_exist_back (YelpHistory *history)
-{
- YelpHistoryPriv *priv;
-
- g_return_val_if_fail (history != NULL, FALSE);
- g_return_val_if_fail (YELP_IS_HISTORY (history), FALSE);
-
- priv = history->priv;
-
- if (!priv->current) {
- return FALSE;
- }
-
- if (priv->current->prev) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-YelpHistory *
-yelp_history_new ()
-{
- return g_object_new (YELP_TYPE_HISTORY, NULL);
-}
diff --git a/src/yelp-history.h b/src/yelp-history.h
deleted file mode 100644
index 09406510..00000000
--- a/src/yelp-history.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * 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_HISTORY_H__
-#define __YELP_HISTORY_H__
-
-#include <glib-object.h>
-
-#define YELP_TYPE_HISTORY (yelp_history_get_type ())
-#define YELP_HISTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), YELP_TYPE_HISTORY, YelpHistory))
-#define YELP_HISTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), YELP_TYPE_HISTORY, YelpHistoryClass))
-#define YELP_IS_HISTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), YELP_TYPE_HISTORY))
-#define YELP_IS_HISTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), YELP_TYPE_HISTORY))
-#define YELP_HISTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), YELP_TYPE_HISTORY, YelpHistoryClass))
-
-typedef struct _YelpHistory YelpHistory;
-typedef struct _YelpHistoryClass YelpHistoryClass;
-typedef struct _YelpHistoryPriv YelpHistoryPriv;
-
-struct _YelpHistory {
- GObject parent;
-
- YelpHistoryPriv *priv;
-};
-
-struct _YelpHistoryClass {
- GObjectClass parent_class;
-
- /* Signals */
- void (*forward_exists_changed) (YelpHistory *history,
- gboolean exists);
- void (*back_exists_changed) (YelpHistory *history,
- gboolean exists);
-};
-
-GType yelp_history_get_type (void);
-YelpHistory * yelp_history_new (void);
-
-void yelp_history_goto (YelpHistory *history,
- const gchar *uri);
-
-const gchar * yelp_history_go_forward (YelpHistory *history);
-const gchar * yelp_history_go_back (YelpHistory *history);
-const gchar * yelp_history_get_current (YelpHistory *history);
-
-gboolean yelp_history_exist_forward (YelpHistory *history);
-gboolean yelp_history_exist_back (YelpHistory *history);
-
-#endif /* __YELP_HISTORY_H__ */
diff --git a/src/yelp-window.c b/src/yelp-window.c
index ef451a1e..696d994a 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -41,7 +41,6 @@
#include "yelp-cache.h"
#include "yelp-db-pager.h"
#include "yelp-error.h"
-#include "yelp-history.h"
#include "yelp-html.h"
#include "yelp-man-pager.h"
#include "yelp-pager.h"
@@ -62,21 +61,20 @@
#define BUFFER_SIZE 16384
+typedef struct {
+ YelpDocInfo *doc_info;
+
+ gchar *frag_id;
+
+ gchar *page_title;
+ gchar *frag_title;
+} YelpHistoryEntry;
+
typedef enum {
YELP_WINDOW_FIND_PREV = 1,
YELP_WINDOW_FIND_NEXT
} YelpFindAction;
-typedef enum {
- YELP_WINDOW_GO_BACK = 1,
- YELP_WINDOW_GO_FORWARD,
- YELP_WINDOW_GO_PREVIOUS,
- YELP_WINDOW_GO_NEXT,
- YELP_WINDOW_GO_TOC,
-
- YELP_WINDOW_GO_HOME
-} YelpHistoryAction;
-
static void window_init (YelpWindow *window);
static void window_class_init (YelpWindowClass *klass);
@@ -91,23 +89,26 @@ static void window_set_sections (YelpWindow *window,
GtkTreeModel *sections);
static void window_do_load (YelpWindow *window,
YelpDocInfo *doc_info,
- gchar *page_id,
- gboolean historyq);
+ gchar *frag_id);
static gboolean window_do_load_pager (YelpWindow *window,
YelpDocInfo *doc_info,
- gchar *page_id,
- gboolean historyq);
+ gchar *frag_id);
static gboolean window_do_load_html (YelpWindow *window,
YelpDocInfo *doc_info,
- gchar *page_id,
- gboolean historyq);
+ gchar *frag_id);
static void window_set_loading (YelpWindow *window);
static void window_handle_page (YelpWindow *window,
YelpPage *page);
static void window_disconnect (YelpWindow *window);
+
+/** Window Callbacks **/
static void yelp_window_destroyed (GtkWidget *window,
gpointer user_data);
+static gboolean window_configure_cb (GtkWidget *widget,
+ GdkEventConfigure *event,
+ gpointer data);
+/** Pager Callbacks **/
static void pager_start_cb (YelpPager *pager,
gpointer user_data);
static void pager_page_cb (YelpPager *pager,
@@ -118,6 +119,7 @@ static void pager_error_cb (YelpPager *pager,
static void pager_finish_cb (YelpPager *pager,
gpointer user_data);
+/** Gecko Callbacks **/
static void html_uri_selected_cb (YelpHtml *html,
gchar *uri,
gboolean handled,
@@ -125,12 +127,15 @@ static void html_uri_selected_cb (YelpHtml *html,
static void html_title_changed_cb (YelpHtml *html,
gchar *title,
gpointer user_data);
+
+/** GtkTreeView Callbacks **/
static void tree_selection_changed_cb (GtkTreeSelection *selection,
YelpWindow *window);
-static void window_add_widget (GtkUIManager *ui_manager,
- GtkWidget *widget,
- GtkWidget *vbox);
+/** UIManager Callbacks **/
+static void window_add_widget (GtkUIManager *ui_manager,
+ GtkWidget *widget,
+ GtkWidget *vbox);
static void window_new_window_cb (GtkAction *action, YelpWindow *window);
static void window_open_location_cb (GtkAction *action, YelpWindow *window);
static void window_close_window_cb (GtkAction *action, YelpWindow *window);
@@ -143,19 +148,14 @@ static void window_go_next_cb (GtkAction *action, YelpWindow *window);
static void window_go_toc_cb (GtkAction *action, YelpWindow *window);
static void window_about_cb (GtkAction *action, YelpWindow *window);
-static gboolean window_configure_cb (GtkWidget *widget,
- GdkEventConfigure *event,
- gpointer data);
+/** History Functions **/
+static void history_push_back (YelpWindow *window);
+static void history_push_forward (YelpWindow *window);
+static void history_clear_forward (YelpWindow *window);
+static YelpHistoryEntry * history_pop_back (YelpWindow *window);
+static YelpHistoryEntry * history_pop_forward (YelpWindow *window);
+static void history_entry_free (YelpHistoryEntry *entry);
-static void window_toggle_history_back (YelpHistory *history,
- gboolean sensitive,
- YelpWindow *window);
-
-static void window_toggle_history_forward (YelpHistory *history,
- gboolean sensitive,
- YelpWindow *window);
-static void window_history_action (YelpWindow *window,
- YelpHistoryAction action);
static void window_find_again_cb (gpointer data,
guint action,
@@ -191,17 +191,18 @@ struct _YelpWindowPriv {
GtkWidget *find_bar;
GtkWidget *find_entry;
YelpHtml *html_view;
-
GtkWidget *side_sw;
+ /* Find in Page */
GtkToolItem *find_prev;
GtkToolItem *find_next;
-
gchar *find_string;
YelpDocInfo *current_doc;
gchar *current_frag;
- YelpHistory *history;
+
+ GSList *history_back;
+ GSList *history_forward;
gulong parse_handler;
gulong start_handler;
@@ -338,18 +339,6 @@ window_init (YelpWindow *window)
priv = g_new0 (YelpWindowPriv, 1);
window->priv = priv;
- priv->history = yelp_history_new ();
-
- g_signal_connect (priv->history,
- "back_exists_changed",
- G_CALLBACK (window_toggle_history_back),
- window);
-
- g_signal_connect (priv->history,
- "forward_exists_changed",
- G_CALLBACK (window_toggle_history_forward),
- window);
-
width = gnome_config_get_int (YELP_CONFIG_WIDTH
"=" YELP_CONFIG_WIDTH_DEFAULT);
height = gnome_config_get_int (YELP_CONFIG_HEIGHT
@@ -377,6 +366,140 @@ window_class_init (YelpWindowClass *klass)
G_TYPE_NONE, 0);
}
+/** History Functions *********************************************************/
+
+static void
+history_push_back (YelpWindow *window)
+{
+ YelpWindowPriv *priv;
+ YelpHistoryEntry *entry;
+ GtkAction *action;
+
+ g_return_if_fail (YELP_IS_WINDOW (window));
+ g_return_if_fail (window->priv->current_doc != NULL);
+
+ priv = window->priv;
+
+ entry = g_new0 (YelpHistoryEntry, 1);
+ entry->doc_info = yelp_doc_info_ref (priv->current_doc);
+ entry->frag_id = g_strdup (priv->current_frag);
+ /* page_title, frag_title */
+
+ priv->history_back = g_slist_prepend (priv->history_back, entry);
+
+ action = gtk_action_group_get_action (priv->action_group, "GoBack");
+ if (action)
+ g_object_set (G_OBJECT (action), "sensitive", TRUE, NULL);
+}
+
+static void
+history_push_forward (YelpWindow *window)
+{
+ YelpWindowPriv *priv;
+ YelpHistoryEntry *entry;
+ GtkAction *action;
+
+ g_return_if_fail (YELP_IS_WINDOW (window));
+ g_return_if_fail (window->priv->current_doc != NULL);
+
+ priv = window->priv;
+
+ entry = g_new0 (YelpHistoryEntry, 1);
+ entry->doc_info = yelp_doc_info_ref (priv->current_doc);
+ entry->frag_id = g_strdup (priv->current_frag);
+ /* page_title, frag_title */
+
+ priv->history_forward = g_slist_prepend (priv->history_forward, entry);
+
+ action = gtk_action_group_get_action (priv->action_group, "GoForward");
+ if (action)
+ g_object_set (G_OBJECT (action), "sensitive", TRUE, NULL);
+}
+
+static void
+history_clear_forward (YelpWindow *window)
+{
+ YelpWindowPriv *priv;
+ GtkAction *action;
+
+ g_return_if_fail (YELP_IS_WINDOW (window));
+ g_return_if_fail (window->priv->current_doc != NULL);
+
+ priv = window->priv;
+
+ if (priv->history_forward) {
+ g_slist_foreach (priv->history_forward,
+ (GFunc) history_entry_free,
+ NULL);
+ g_slist_free (priv->history_forward);
+ priv->history_forward = NULL;
+ }
+ action = gtk_action_group_get_action (priv->action_group, "GoForward");
+ if (action)
+ g_object_set (G_OBJECT (action), "sensitive", FALSE, NULL);
+}
+
+static YelpHistoryEntry *
+history_pop_back (YelpWindow *window)
+{
+ YelpWindowPriv *priv;
+ YelpHistoryEntry *entry;
+ GtkAction *action;
+
+ g_return_val_if_fail (YELP_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (window->priv->history_back != NULL, NULL);
+
+ priv = window->priv;
+
+ entry = (YelpHistoryEntry *) priv->history_back->data;
+ priv->history_back = g_slist_delete_link (priv->history_back,
+ priv->history_back);
+
+ action = gtk_action_group_get_action (priv->action_group, "GoBack");
+ if (action)
+ g_object_set (G_OBJECT (action), "sensitive",
+ priv->history_back ? TRUE : FALSE,
+ NULL);
+ return entry;
+}
+
+static YelpHistoryEntry *
+history_pop_forward (YelpWindow *window)
+{
+ YelpWindowPriv *priv;
+ YelpHistoryEntry *entry;
+ GtkAction *action;
+
+ g_return_val_if_fail (YELP_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (window->priv->history_forward != NULL, NULL);
+
+ priv = window->priv;
+
+ entry = (YelpHistoryEntry *) priv->history_forward->data;
+ priv->history_forward = g_slist_delete_link (priv->history_forward,
+ priv->history_forward);
+
+ action = gtk_action_group_get_action (priv->action_group, "GoForward");
+ if (action)
+ g_object_set (G_OBJECT (action), "sensitive",
+ priv->history_forward ? TRUE : FALSE,
+ NULL);
+ return entry;
+}
+
+static void
+history_entry_free (YelpHistoryEntry *entry)
+{
+ g_return_if_fail (entry != NULL);
+
+ yelp_doc_info_unref (entry->doc_info);
+ g_free (entry->frag_id);
+ g_free (entry->page_title);
+ g_free (entry->frag_title);
+
+ g_free (entry);
+}
+
/******************************************************************************/
GtkWidget *
@@ -449,15 +572,18 @@ yelp_window_load (YelpWindow *window, gchar *uri)
goto done;
}
+ history_push_back (window);
+ history_clear_forward (window);
+
if (priv->current_doc)
yelp_doc_info_unref (priv->current_doc);
if (priv->current_frag)
g_free (priv->current_frag);
priv->current_doc = yelp_doc_info_ref (doc_info);
- priv->current_frag = frag_id;
+ priv->current_frag = g_strdup (frag_id);
- window_do_load (window, doc_info, frag_id, TRUE);
+ window_do_load (window, doc_info, frag_id);
done:
if (priv->current_frag != frag_id)
@@ -475,8 +601,7 @@ yelp_window_get_doc_info (YelpWindow *window)
static void
window_do_load (YelpWindow *window,
YelpDocInfo *doc_info,
- gchar *frag_id,
- gboolean historyq)
+ gchar *frag_id)
{
YelpWindowPriv *priv;
GError *error = NULL;
@@ -488,7 +613,6 @@ window_do_load (YelpWindow *window,
d (printf ("window_do_load\n"));
d (printf (" doc_info = \"%s\"\n", doc_info->uri));
d (printf (" frag_id = \"%s\"\n", frag_id));
- d (printf (" historyq = %s\n", historyq ? "TRUE" : "FALSE"));
priv = window->priv;
@@ -497,13 +621,13 @@ window_do_load (YelpWindow *window,
case YELP_DOC_TYPE_MAN:
case YELP_DOC_TYPE_INFO:
case YELP_DOC_TYPE_TOC:
- handled = window_do_load_pager (window, doc_info, frag_id, historyq);
+ handled = window_do_load_pager (window, doc_info, frag_id);
break;
case YELP_DOC_TYPE_DOCBOOK_SGML:
yelp_set_error (&error, YELP_ERROR_NO_SGML);
break;
case YELP_DOC_TYPE_HTML:
- handled = window_do_load_html (window, doc_info, frag_id, historyq);
+ handled = window_do_load_html (window, doc_info, frag_id);
break;
case YELP_DOC_TYPE_EXTERNAL:
gnome_url_show (doc_info->uri, &error);
@@ -662,12 +786,6 @@ window_populate (YelpWindow *window)
priv->pane,
TRUE, TRUE, 0);
- /*
- gtk_widget_show_all (toolbar);
- gtk_widget_show_all (GTK_WIDGET (gtk_item_factory_get_widget
- (priv->item_factory, "<main>")) );
- */
-
gtk_widget_show_all (yelp_html_get_widget (priv->html_view));
gtk_widget_show (priv->html_pane);
gtk_widget_show (priv->pane);
@@ -766,8 +884,7 @@ window_set_sections (YelpWindow *window,
static gboolean
window_do_load_pager (YelpWindow *window,
YelpDocInfo *doc_info,
- gchar *frag_id,
- gboolean historyq)
+ gchar *frag_id)
{
YelpWindowPriv *priv;
YelpPagerState state;
@@ -785,7 +902,6 @@ window_do_load_pager (YelpWindow *window,
d (printf ("window_do_load_pager\n"));
d (printf (" doc_info = \"%s\"\n", doc_info->uri));
d (printf (" frag_id = \"%s\"\n", frag_id));
- d (printf (" historyq = %s\n", historyq ? "TRUE" : "FALSE"));
priv = window->priv;
@@ -866,9 +982,6 @@ window_do_load_pager (YelpWindow *window,
g_assert_not_reached ();
}
- if (historyq)
- yelp_history_goto (window->priv->history, uri);
-
window_set_sections (window,
yelp_pager_get_sections (doc_info->pager));
@@ -910,8 +1023,7 @@ window_do_load_pager (YelpWindow *window,
static gboolean
window_do_load_html (YelpWindow *window,
YelpDocInfo *doc_info,
- gchar *page_id,
- gboolean historyq)
+ gchar *frag_id)
{
YelpWindowPriv *priv;
GnomeVFSHandle *handle;
@@ -928,10 +1040,7 @@ window_do_load_html (YelpWindow *window,
priv = window->priv;
- uri = yelp_doc_info_get_uri (doc_info, page_id);
-
- if (historyq)
- yelp_history_goto (window->priv->history, uri);
+ uri = yelp_doc_info_get_uri (doc_info, frag_id);
window_set_sections (window, NULL);
@@ -1175,6 +1284,8 @@ window_disconnect (YelpWindow *window)
}
}
+/** Window Callbacks **********************************************************/
+
static void
yelp_window_destroyed (GtkWidget *window,
gpointer user_data)
@@ -1200,6 +1311,22 @@ yelp_window_destroyed (GtkWidget *window,
g_object_unref (priv->side_sw);
}
+static gboolean
+window_configure_cb (GtkWidget *widget,
+ GdkEventConfigure *event,
+ gpointer data)
+{
+ gint width, height;
+ gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
+ gnome_config_set_int (YELP_CONFIG_WIDTH, width);
+ gnome_config_set_int (YELP_CONFIG_HEIGHT, height);
+ gnome_config_sync ();
+
+ return FALSE;
+}
+
+/** Pager Callbacks ***********************************************************/
+
static void
pager_start_cb (YelpPager *pager,
gpointer user_data)
@@ -1280,6 +1407,8 @@ pager_finish_cb (YelpPager *pager,
// FIXME: Remove the URI from the history and go back
}
+/** Gecko Callbacks ***********************************************************/
+
static void
html_uri_selected_cb (YelpHtml *html,
gchar *uri,
@@ -1304,6 +1433,8 @@ html_title_changed_cb (YelpHtml *html,
gtk_window_set_title (GTK_WINDOW (user_data), title);
}
+/** GtkTreeView Callbacks *****************************************************/
+
static void
tree_selection_changed_cb (GtkTreeSelection *selection,
YelpWindow *window)
@@ -1335,7 +1466,7 @@ tree_selection_changed_cb (GtkTreeSelection *selection,
*/
}
-/******************************************************************************/
+/** UIManager Callbacks *******************************************************/
static void
window_add_widget (GtkUIManager *ui_manager,
@@ -1383,17 +1514,57 @@ window_find_cb (GtkAction *action, YelpWindow *window)
static void
window_go_back_cb (GtkAction *action, YelpWindow *window)
{
- d (printf ("window_go_back_cb\n"));
+ YelpWindowPriv *priv;
+ YelpHistoryEntry *entry;
+
g_return_if_fail (YELP_IS_WINDOW (window));
- window_history_action (window, YELP_WINDOW_GO_BACK);
+ g_return_if_fail (window->priv->history_back != NULL);
+
+ priv = window->priv;
+
+ history_push_forward (window);
+
+ entry = history_pop_back (window);
+
+ if (priv->current_doc)
+ yelp_doc_info_unref (priv->current_doc);
+ if (priv->current_frag)
+ g_free (priv->current_frag);
+
+ priv->current_doc = yelp_doc_info_ref (entry->doc_info);
+ priv->current_frag = g_strdup (entry->frag_id);
+
+ window_do_load (window, entry->doc_info, entry->frag_id);
+
+ history_entry_free (entry);
}
static void
window_go_forward_cb (GtkAction *action, YelpWindow *window)
{
- d (printf ("window_go_forward_cb\n"));
+ YelpWindowPriv *priv;
+ YelpHistoryEntry *entry;
+
g_return_if_fail (YELP_IS_WINDOW (window));
- window_history_action (window, YELP_WINDOW_GO_FORWARD);
+ g_return_if_fail (window->priv->history_forward != NULL);
+
+ priv = window->priv;
+
+ history_push_back (window);
+
+ entry = history_pop_forward (window);
+
+ if (priv->current_doc)
+ yelp_doc_info_unref (priv->current_doc);
+ if (priv->current_frag)
+ g_free (priv->current_frag);
+
+ priv->current_doc = yelp_doc_info_ref (entry->doc_info);
+ priv->current_frag = g_strdup (entry->frag_id);
+
+ window_do_load (window, entry->doc_info, entry->frag_id);
+
+ history_entry_free (entry);
}
static void
@@ -1492,87 +1663,7 @@ window_about_cb (GtkAction *action, YelpWindow *window)
gtk_window_present (GTK_WINDOW (about));
}
-static gboolean
-window_configure_cb (GtkWidget *widget,
- GdkEventConfigure *event,
- gpointer data)
-{
- gint width, height;
- gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
- gnome_config_set_int (YELP_CONFIG_WIDTH, width);
- gnome_config_set_int (YELP_CONFIG_HEIGHT, height);
- gnome_config_sync ();
-
- return FALSE;
-}
-
-static void
-window_toggle_history_back (YelpHistory *history,
- gboolean sensitive,
- YelpWindow *window)
-{
- YelpWindowPriv *priv;
- GtkAction *action;
-
- g_return_if_fail (YELP_IS_HISTORY (history));
- g_return_if_fail (YELP_IS_WINDOW (window));
-
- priv = window->priv;
-
- action = gtk_action_group_get_action (priv->action_group, "GoBack");
- if (action)
- g_object_set (G_OBJECT (action), "sensitive", sensitive, NULL);
-}
-
-static void
-window_toggle_history_forward (YelpHistory *history,
- gboolean sensitive,
- YelpWindow *window)
-{
- YelpWindowPriv *priv;
- GtkAction *action;
-
- g_return_if_fail (YELP_IS_HISTORY (history));
- g_return_if_fail (YELP_IS_WINDOW (window));
-
- priv = window->priv;
-
- action = gtk_action_group_get_action (priv->action_group, "GoBack");
- if (action)
- g_object_set (G_OBJECT (action), "sensitive", sensitive, NULL);
-}
-
-static void
-window_history_action (YelpWindow *window,
- YelpHistoryAction action)
-{
- YelpWindowPriv *priv;
- YelpDocInfo *doc_info;
- gchar *uri, *page_id;
-
- g_return_if_fail (YELP_IS_WINDOW (window));
-
- priv = window->priv;
-
- switch (action) {
- case YELP_WINDOW_GO_BACK:
- uri = (gchar *) yelp_history_go_back (priv->history);
- break;
- case YELP_WINDOW_GO_FORWARD:
- uri = (gchar *) yelp_history_go_forward (priv->history);
- break;
- default:
- return;
- }
-
- if (uri) {
- doc_info = yelp_doc_info_get (uri);
- page_id = yelp_uri_get_fragment (uri);
- window_do_load (window, doc_info, page_id, FALSE);
- g_free (page_id);
- g_free (uri);
- }
-}
+/******************************************************************************/
static gboolean
window_find_delete_event_cb (GtkWidget *widget,