]> www.fi.muni.cz Git - evince.git/commitdiff
Add a bookmark object to the backend and use it instead of get_values
authorMarco Pesenti Gritti <marco@gnome.org>
Fri, 7 Jan 2005 12:16:43 +0000 (12:16 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Fri, 7 Jan 2005 12:16:43 +0000 (12:16 +0000)
2005-01-07  Marco Pesenti Gritti  <marco@gnome.org>

        * backend/Makefile.am:
        * backend/ev-bookmark.c: (ev_bookmark_type_get_type),
        (ev_bookmark_get_title), (ev_bookmark_set_title),
        (ev_bookmark_get_bookmark_type), (ev_bookmark_set_bookmark_type),
        (ev_bookmark_get_page), (ev_bookmark_set_page),
        (ev_bookmark_get_property), (ev_bookmark_set_property),
        (ev_window_dispose), (ev_bookmark_init), (ev_bookmark_class_init),
        (ev_bookmark_new):
        * backend/ev-bookmark.h:
        * backend/ev-document-bookmarks.c:
        (ev_document_bookmarks_get_bookmark):
        * backend/ev-document-bookmarks.h:
        * pdf/xpdf/pdf-document.cc:
        * shell/ev-sidebar-bookmarks.c: (do_one_iteration):

        Add a bookmark object to the backend and use it instead of get_values

ChangeLog
backend/Makefile.am
backend/ev-bookmark.c [new file with mode: 0644]
backend/ev-bookmark.h [new file with mode: 0644]
backend/ev-document-bookmarks.c
backend/ev-document-bookmarks.h
pdf/xpdf/pdf-document.cc
shell/ev-sidebar-bookmarks.c

index a9ec90e602b85ee805523035161a53ea63ba680d..8d0202202adb719fb537b9808aebb4bf6d409b3d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2005-01-07  Marco Pesenti Gritti  <marco@gnome.org>
+
+       * backend/Makefile.am:
+       * backend/ev-bookmark.c: (ev_bookmark_type_get_type),
+       (ev_bookmark_get_title), (ev_bookmark_set_title),
+       (ev_bookmark_get_bookmark_type), (ev_bookmark_set_bookmark_type),
+       (ev_bookmark_get_page), (ev_bookmark_set_page),
+       (ev_bookmark_get_property), (ev_bookmark_set_property),
+       (ev_window_dispose), (ev_bookmark_init), (ev_bookmark_class_init),
+       (ev_bookmark_new):
+       * backend/ev-bookmark.h:
+       * backend/ev-document-bookmarks.c:
+       (ev_document_bookmarks_get_bookmark):
+       * backend/ev-document-bookmarks.h:
+       * pdf/xpdf/pdf-document.cc:
+       * shell/ev-sidebar-bookmarks.c: (do_one_iteration):
+
+       Add a bookmark object to the backend and use it instead of get_values
+
 2005-01-07  Marco Pesenti Gritti  <marco@gnome.org>
 
        * data/evince-ui.xml:
index e2c32450e489bcca7831151010ab5f45a70b9d15..03a9103348b0f2bb648b9c0b1e78054ab7f81d8a 100644 (file)
@@ -11,6 +11,8 @@ noinst_LTLIBRARIES = libevbackend.la
 
 libevbackend_la_SOURCES=                       \
        ev-backend-marshal.c                    \
+       ev-bookmark.c                           \
+       ev-bookmark.h                           \
        ev-document.c                           \
        ev-document.h                           \
        ev-document-thumbnails.c                \
diff --git a/backend/ev-bookmark.c b/backend/ev-bookmark.c
new file mode 100644 (file)
index 0000000..f28c32b
--- /dev/null
@@ -0,0 +1,254 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/* this file is part of evince, a gnome document viewer
+ *
+ *  Copyright (C) 2005 Red Hat, Inc.
+ *
+ * Evince 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.
+ *
+ * Evince 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ev-bookmark.h"
+
+enum {
+       PROP_0,
+       PROP_TITLE,
+       PROP_TYPE,
+       PROP_PAGE
+};
+
+struct _EvBookmarkPrivate {
+       char *title;
+       EvBookmarkType type;
+       int page;
+};
+
+static GObjectClass *parent_class = NULL;
+
+G_DEFINE_TYPE (EvBookmark, ev_bookmark, G_TYPE_OBJECT)
+
+#define EV_BOOKMARK_GET_PRIVATE(object) \
+       (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_BOOKMARK, EvBookmarkPrivate))
+
+GType
+ev_bookmark_type_get_type (void)
+{
+       static GType type = 0;
+
+       if (G_UNLIKELY (type == 0)) {
+               static const GEnumValue values[] = {
+                       { EV_BOOKMARK_TYPE_TITLE, "EV_BOOKMARK_TYPE_TITLE", "title" },
+                       { EV_BOOKMARK_TYPE_LINK, "EV_BOOKMARK_TYPE_LINK", "link" },
+                       { EV_BOOKMARK_TYPE_EXTERNAL_URI, "EV_BOOKMARK_TYPE_EXTERNAL_URI", "external" },
+                       { 0, NULL, NULL }
+                };
+
+                type = g_enum_register_static ("EvBookmarkType", values);
+        }
+
+        return type;
+}
+
+const char *
+ev_bookmark_get_title (EvBookmark *self)
+{
+       g_return_val_if_fail (EV_IS_BOOKMARK (self), NULL);
+       
+       return self->priv->title;
+}
+
+void
+ev_bookmark_set_title (EvBookmark* self, const char *title)
+{
+       g_assert (EV_IS_BOOKMARK (self));
+       g_assert (title != NULL);
+
+       if (self->priv->title != NULL) {
+               g_free (self->priv->title);
+       }
+
+       self->priv->title = g_strdup (title);
+
+       g_object_notify (G_OBJECT (self), "title");
+}
+
+EvBookmarkType
+ev_bookmark_get_bookmark_type (EvBookmark *self)
+{
+       g_return_val_if_fail (EV_IS_BOOKMARK (self), 0);
+       
+       return self->priv->type;
+}
+
+void
+ev_bookmark_set_bookmark_type (EvBookmark* self, EvBookmarkType type)
+{
+       g_assert (EV_IS_BOOKMARK (self));
+
+       self->priv->type = type;
+
+       g_object_notify (G_OBJECT (self), "type");
+}
+
+int
+ev_bookmark_get_page (EvBookmark *self)
+{
+       g_return_val_if_fail (EV_IS_BOOKMARK (self), 0);
+       
+       return self->priv->page;
+}
+
+void
+ev_bookmark_set_page (EvBookmark* self, int page)
+{
+       g_assert (EV_IS_BOOKMARK (self));
+
+       self->priv->page = page;
+
+       g_object_notify (G_OBJECT (self), "page");
+}
+
+static void
+ev_bookmark_get_property (GObject *object, guint prop_id, GValue *value,
+                         GParamSpec *param_spec)
+{
+       EvBookmark *self;
+
+       self = EV_BOOKMARK (object);
+
+       switch (prop_id) {
+       case PROP_TITLE:
+               g_value_set_string (value, self->priv->title);
+               break;
+       case PROP_TYPE:
+               g_value_set_enum (value, self->priv->type);
+               break;
+       case PROP_PAGE:
+               g_value_set_int (value, self->priv->page);
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+                                                  prop_id,
+                                                  param_spec);
+               break;
+       }
+}
+
+static void
+ev_bookmark_set_property (GObject *object, guint prop_id, const GValue *value,
+                         GParamSpec *param_spec)
+{
+       EvBookmark *self;
+       
+       self = EV_BOOKMARK (object);
+       
+       switch (prop_id) {
+       case PROP_TITLE:
+               ev_bookmark_set_title (self, g_value_get_string (value));
+               break;
+       case PROP_TYPE:
+               ev_bookmark_set_bookmark_type (self, g_value_get_enum (value));
+               break;
+       case PROP_PAGE:
+               ev_bookmark_set_page (self, g_value_get_int (value));
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+                                                  prop_id,
+                                                  param_spec);
+               break;
+       }
+}
+
+static void
+ev_window_dispose (GObject *object)
+{
+       EvBookmarkPrivate *priv;
+
+       g_return_if_fail (EV_IS_BOOKMARK (object));
+
+       priv = EV_BOOKMARK (object)->priv;
+
+       if (priv->title) {
+               g_free (priv->title);
+               priv->title = NULL;
+       }
+
+       G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+ev_bookmark_init (EvBookmark *ev_bookmark)
+{
+       ev_bookmark->priv = EV_BOOKMARK_GET_PRIVATE (ev_bookmark);
+
+       ev_bookmark->priv->type = EV_BOOKMARK_TYPE_TITLE;
+}
+
+static void
+ev_bookmark_class_init (EvBookmarkClass *ev_window_class)
+{
+       GObjectClass *g_object_class;
+
+       parent_class = g_type_class_peek_parent (ev_window_class);
+
+       g_object_class = G_OBJECT_CLASS (ev_window_class);
+       g_object_class->dispose = ev_window_dispose;
+       g_object_class->set_property = ev_bookmark_set_property;
+       g_object_class->get_property = ev_bookmark_get_property;
+
+       g_type_class_add_private (g_object_class, sizeof (EvBookmarkPrivate));
+
+       g_object_class_install_property (g_object_class,
+                                        PROP_TITLE,
+                                        g_param_spec_string ("title",
+                                                             "Bookmark Title",
+                                                             "The bookmark title",
+                                                             NULL,
+                                                             G_PARAM_READWRITE));
+
+       g_object_class_install_property (g_object_class,
+                                        PROP_TYPE,
+                                        g_param_spec_enum  ("type",
+                                                            "Bookmark Type",
+                                                            "The bookmark type",
+                                                            EV_TYPE_BOOKMARK_TYPE,
+                                                            EV_BOOKMARK_TYPE_TITLE,
+                                                            G_PARAM_READWRITE));
+
+       g_object_class_install_property (g_object_class,
+                                        PROP_PAGE,
+                                        g_param_spec_int ("page",
+                                                          "Bookmark Page",
+                                                          "The bookmark page",
+                                                           0,
+                                                           G_MAXINT,
+                                                           0,
+                                                           G_PARAM_READWRITE));
+}
+
+EvBookmark *
+ev_bookmark_new        (const char     *title,
+                EvBookmarkType  type,
+                int             page)
+{
+       return EV_BOOKMARK (g_object_new (EV_TYPE_BOOKMARK,
+                                         "title", title,
+                                         "page", page,
+                                         "type", type,
+                                         NULL));
+}
diff --git a/backend/ev-bookmark.h b/backend/ev-bookmark.h
new file mode 100644 (file)
index 0000000..6b68838
--- /dev/null
@@ -0,0 +1,74 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ *  Copyright (C) 2005 Red Hat, Inc.
+ *
+ * Evince 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.
+ *
+ * Evince 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.
+ */
+
+#ifndef EV_BOOKMARK_H
+#define EV_BOOKMARK_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EvBookmark EvBookmark;
+typedef struct _EvBookmarkClass EvBookmarkClass;
+typedef struct _EvBookmarkPrivate EvBookmarkPrivate;
+
+#define EV_TYPE_BOOKMARK               (ev_bookmark_get_type())
+#define EV_BOOKMARK(object)            (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_BOOKMARK, EvBookmark))
+#define EV_BOOKMARK_CLASS(klass)       (G_TYPE_CHACK_CLASS_CAST((klass), EV_TYPE_BOOKMARK, EvBookmarkClass))
+#define EV_IS_BOOKMARK(object)         (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_BOOKMARK))
+#define EV_IS_BOOKMARK_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_BOOKMARK))
+#define EV_BOOKMARK_GET_CLASS(object)  (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_BOOKMARK, EvBookmarkClass))
+
+#define EV_TYPE_BOOKMARK_TYPE (ev_bookmark_type_get_type ())
+
+typedef enum
+{
+       EV_BOOKMARK_TYPE_TITLE,
+       EV_BOOKMARK_TYPE_LINK,
+       EV_BOOKMARK_TYPE_EXTERNAL_URI
+} EvBookmarkType;
+
+struct _EvBookmark {
+       GObject base_instance;
+       EvBookmarkPrivate *priv;
+};
+
+struct _EvBookmarkClass {
+       GObjectClass base_class;
+};
+
+GType           ev_bookmark_type_get_type       (void);
+GType          ev_bookmark_get_type            (void);
+
+EvBookmark     *ev_bookmark_new                        (const char     *title,
+                                                EvBookmarkType  type,
+                                                int             page);
+const char     *ev_bookmark_get_title          (EvBookmark     *bookmark);
+void           ev_bookmark_set_title           (EvBookmark     *bookmark,
+                                                const char     *title);
+EvBookmarkType  ev_bookmark_get_bookmark_type  (EvBookmark     *bookmark);
+void           ev_bookmark_set_bookmark_type   (EvBookmark     *bookmark,
+                                                EvBookmarkType  type);
+int            ev_bookmark_get_page            (EvBookmark     *bookmark);
+void           ev_bookmark_set_page            (EvBookmark     *bookmark,
+                                                int             page);
+
+G_END_DECLS
+
+#endif /* !EV_BOOKMARK_H */
index 1806cd9ae6dd36353fd5a01d5980e304d94a3fa3..7b0d14189e0a87d7b611468d72b4edf21befc8ea 100644 (file)
@@ -62,20 +62,13 @@ ev_document_bookmarks_begin_read (EvDocumentBookmarks *document_bookmarks)
        return iface->begin_read (document_bookmarks);
 }
 
- /*
-  * This function gets the values at a node.  You need to g_free the title.
-  * Additionally, if page is -1, the link doesn't go anywhere.
-  */
-gboolean 
-ev_document_bookmarks_get_values (EvDocumentBookmarks      *document_bookmarks,
-                                 EvDocumentBookmarksIter  *iter,
-                                 char                    **title,
-                                 EvDocumentBookmarksType  *type,
-                                 gint                     *page)
+EvBookmark * 
+ev_document_bookmarks_get_bookmark (EvDocumentBookmarks      *document_bookmarks,
+                                   EvDocumentBookmarksIter  *iter)
 {
        EvDocumentBookmarksIface *iface = EV_DOCUMENT_BOOKMARKS_GET_IFACE (document_bookmarks);
 
-       return iface->get_values (document_bookmarks, iter, title, type, page);
+       return iface->get_bookmark (document_bookmarks, iter);
 }
 
 EvDocumentBookmarksIter *
index 98a53a64325ad509aaf52240eadb5c190a6f109d..6ee36a75448e748cfc66f9abdfafd4bd676614aa 100644 (file)
@@ -32,7 +32,9 @@
 #include <glib-object.h>
 #include <glib.h>
 #include <gdk/gdk.h>
+
 #include "ev-document.h"
+#include "ev-bookmark.h"
 
 G_BEGIN_DECLS
 
@@ -48,13 +50,6 @@ typedef struct _EvDocumentBookmarks          EvDocumentBookmarks;
 typedef struct _EvDocumentBookmarksIface       EvDocumentBookmarksIface;
 typedef struct _EvDocumentBookmarksIter        EvDocumentBookmarksIter;
 
-typedef enum
-{
-       EV_DOCUMENT_BOOKMARKS_TYPE_TITLE,
-       EV_DOCUMENT_BOOKMARKS_TYPE_LINK,
-       EV_DOCUMENT_BOOKMARKS_TYPE_EXTERNAL_URI,
-} EvDocumentBookmarksType;
-
 struct _EvDocumentBookmarksIface
 {
        GTypeInterface base_iface;
@@ -62,11 +57,8 @@ struct _EvDocumentBookmarksIface
        /* Methods  */
        gboolean                 (* has_document_bookmarks) (EvDocumentBookmarks      *document_bookmarks);
        EvDocumentBookmarksIter *(* begin_read)             (EvDocumentBookmarks      *document_bookmarks);
-       gboolean                 (* get_values)             (EvDocumentBookmarks      *document_bookmarks,
-                                                            EvDocumentBookmarksIter  *iter,
-                                                            gchar                   **title,
-                                                            EvDocumentBookmarksType  *type,
-                                                            gint                     *page);
+       EvBookmark              *(* get_bookmark)           (EvDocumentBookmarks      *document_bookmarks,
+                                                            EvDocumentBookmarksIter  *iter);
        EvDocumentBookmarksIter *(* get_child)              (EvDocumentBookmarks      *document_bookmarks,
                                                             EvDocumentBookmarksIter  *iter);
        gboolean                 (* next)                   (EvDocumentBookmarks      *document_bookmarks,
@@ -78,11 +70,8 @@ struct _EvDocumentBookmarksIface
 GType                    ev_document_bookmarks_get_type               (void);
 gboolean                 ev_document_bookmarks_has_document_bookmarks (EvDocumentBookmarks      *document_bookmarks);
 EvDocumentBookmarksIter *ev_document_bookmarks_begin_read             (EvDocumentBookmarks      *document_bookmarks);
-gboolean                 ev_document_bookmarks_get_values             (EvDocumentBookmarks      *document_bookmarks,
-                                                                      EvDocumentBookmarksIter  *iter,
-                                                                      char                    **title,
-                                                                      EvDocumentBookmarksType  *type,
-                                                                      gint                     *page);
+EvBookmark             *ev_document_bookmarks_get_bookmark           (EvDocumentBookmarks      *document_bookmarks,
+                                                                      EvDocumentBookmarksIter  *iter);
 EvDocumentBookmarksIter *ev_document_bookmarks_get_child              (EvDocumentBookmarks      *document_bookmarks,
                                                                       EvDocumentBookmarksIter  *iter);
 gboolean                 ev_document_bookmarks_next                   (EvDocumentBookmarks      *document_bookmarks,
index a4049c664cf6ff510038bb7868a39205227d4ea5..feb009d017a7ee263dd46b23bc48f12088deabea 100644 (file)
@@ -740,14 +740,12 @@ pdf_document_bookmarks_begin_read (EvDocumentBookmarks *document_bookmarks)
        return (EvDocumentBookmarksIter *) iter;
 }
 
-static gboolean
-pdf_document_bookmarks_get_values (EvDocumentBookmarks      *document_bookmarks,
-                                  EvDocumentBookmarksIter  *bookmarks_iter,
-                                  char                    **title,
-                                  EvDocumentBookmarksType  *type,
-                                  gint                     *page)
+static EvBookmark *
+pdf_document_bookmarks_get_bookmark (EvDocumentBookmarks      *document_bookmarks,
+                                    EvDocumentBookmarksIter  *bookmarks_iter)
 {
        PdfDocument *pdf_document = PDF_DOCUMENT (document_bookmarks);
+       EvBookmark *bookmark;
        BookmarksIter *iter = (BookmarksIter *)bookmarks_iter;
        OutlineItem *anItem;
        LinkAction *link_action;
@@ -757,13 +755,11 @@ pdf_document_bookmarks_get_values (EvDocumentBookmarks      *document_bookmarks,
        GString *named_dest;
        Unicode *link_title;
        Ref page_ref;
-       gint page_num = -1;
+       gint page_num = 0;
+       char *title;
 
        g_return_val_if_fail (PDF_IS_DOCUMENT (document_bookmarks), FALSE);
        g_return_val_if_fail (iter != NULL, FALSE);
-       g_return_val_if_fail (title != NULL, FALSE);
-       g_return_val_if_fail (type != NULL, FALSE);
-       g_return_val_if_fail (page != NULL, FALSE);
 
        anItem = (OutlineItem *)iter->items->get(iter->index);
        link_action = anItem->getAction ();
@@ -808,15 +804,16 @@ pdf_document_bookmarks_get_values (EvDocumentBookmarks      *document_bookmarks,
                        g_warning ("Unknown link action type: %d", link_action->getKind ());
                }
 
-               *title = g_strdup (unicode_to_char (anItem, pdf_document->umap));
+               title = g_strdup (unicode_to_char (anItem, pdf_document->umap));
        } else if (link_title) {
-               *title = g_strdup (unicode_to_char (anItem, pdf_document->umap));
+               title = g_strdup (unicode_to_char (anItem, pdf_document->umap));
        }
 
-       *type = EV_DOCUMENT_BOOKMARKS_TYPE_LINK;
-       *page = page_num;
+       bookmark = ev_bookmark_new (title, EV_BOOKMARK_TYPE_LINK, page_num);
 
-       return TRUE;
+       g_free (title);
+
+       return bookmark;
 }
 
 static EvDocumentBookmarksIter *
@@ -1047,7 +1044,7 @@ pdf_document_document_bookmarks_iface_init (EvDocumentBookmarksIface *iface)
 {
        iface->has_document_bookmarks = pdf_document_bookmarks_has_document_bookmarks;
        iface->begin_read = pdf_document_bookmarks_begin_read;
-       iface->get_values = pdf_document_bookmarks_get_values;
+       iface->get_bookmark = pdf_document_bookmarks_get_bookmark;
        iface->get_child = pdf_document_bookmarks_get_child;
        iface->next = pdf_document_bookmarks_next;
        iface->free_iter = pdf_document_bookmarks_free_iter;
index b215e1ed62debc091fa13ff58673c999da0a58ac..6cc2eb0e8ae97780ec7b6b2fc7877631b404be3a 100644 (file)
@@ -207,34 +207,33 @@ static gboolean
 do_one_iteration (EvSidebarBookmarks *ev_sidebar_bookmarks)
 {
        EvSidebarBookmarksPrivate *priv = ev_sidebar_bookmarks->priv;
+       EvBookmark *bookmark;
        IdleStackData *stack_data;
        GtkTreeIter tree_iter;
-       gchar *title = NULL;
-       EvDocumentBookmarksType type;
        EvDocumentBookmarksIter *child_iter;
-       gint page = -1;
+       gint page;
 
        g_assert (priv->idle_stack);
 
        stack_data = (IdleStackData *) priv->idle_stack->data;
 
-       if (! ev_document_bookmarks_get_values (EV_DOCUMENT_BOOKMARKS (priv->current_document),
-                                               stack_data->bookmarks_iter,
-                                               &title,
-                                               &type,
-                                               &page)) {
+       bookmark = ev_document_bookmarks_get_bookmark
+               (EV_DOCUMENT_BOOKMARKS (priv->current_document),
+                stack_data->bookmarks_iter);
+       if (bookmark == NULL) {
                g_warning ("mismatch in model.  No values available at current level.\n");
                return FALSE;
        }
 
+       page = ev_bookmark_get_page (bookmark);
        gtk_tree_store_append (GTK_TREE_STORE (priv->model), &tree_iter, stack_data->tree_iter);
        gtk_tree_store_set (GTK_TREE_STORE (priv->model), &tree_iter,
-                           BOOKMARKS_COLUMN_MARKUP, title,
+                           BOOKMARKS_COLUMN_MARKUP, ev_bookmark_get_title (bookmark),
                            BOOKMARKS_COLUMN_PAGE_NUM, page,
                            /* FIXME: Handle links for real. */
                            BOOKMARKS_COLUMN_PAGE_VALID, (page >= 0),
                            -1);
-       g_free (title);
+       g_object_unref (bookmark);
        
        child_iter = ev_document_bookmarks_get_child (EV_DOCUMENT_BOOKMARKS (priv->current_document),
                                                      stack_data->bookmarks_iter);