]> www.fi.muni.cz Git - evince.git/commitdiff
Cr 31 13:27:50 2005 Jonathan Blandford <jrb@redhat.com>
authorJonathan Blandford <jrb@src.gnome.org>
Thu, 31 Mar 2005 18:43:05 +0000 (18:43 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Thu, 31 Mar 2005 18:43:05 +0000 (18:43 +0000)
Cr 31 13:27:50 2005  Jonathan Blandford  <jrb@redhat.com>

        * backend/ev-document.c: (ev_document_get_page_label):
        * backend/ev-document.h:
        * backend/ev-page-cache.c: (_ev_page_cache_new),
        (ev_page_cache_get_page_label):
        * backend/ev-page-cache.h:
        * pdf/ev-poppler.cc:
        * shell/ev-sidebar-links.c: (ev_sidebar_links_construct),
        (links_page_num_func):
        * shell/ev-sidebar-thumbnails.c:
        (ev_sidebar_thumbnails_set_document):
        * shell/ev-view.c: (status_message_from_link),
        (ev_view_motion_notify_event):
        * shell/ev-window.c: (document_supports_sidebar): Add in page
        label support.  It's not perfect yet, but it's the first 'feature'
        in a while.
        Also, fix a bogus comment noticed by crispin.

VS: Modified Files:

ChangeLog
backend/ev-document.c
backend/ev-document.h
backend/ev-page-cache.c
backend/ev-page-cache.h
pdf/ev-poppler.cc
shell/ev-sidebar-links.c
shell/ev-sidebar-thumbnails.c
shell/ev-view.c
shell/ev-window.c

index 940e8550e2e2b15c5645ad0bdc611f79fbfeda72..181e28d04f0cd20c031d6dad0697629c905c4d6b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+Thu Mar 31 13:27:50 2005  Jonathan Blandford  <jrb@redhat.com>
+
+       * backend/ev-document.c: (ev_document_get_page_label):
+       * backend/ev-document.h:
+       * backend/ev-page-cache.c: (_ev_page_cache_new),
+       (ev_page_cache_get_page_label):
+       * backend/ev-page-cache.h:
+       * pdf/ev-poppler.cc:
+       * shell/ev-sidebar-links.c: (ev_sidebar_links_construct),
+       (links_page_num_func):
+       * shell/ev-sidebar-thumbnails.c:
+       (ev_sidebar_thumbnails_set_document):
+       * shell/ev-view.c: (status_message_from_link),
+       (ev_view_motion_notify_event):
+       * shell/ev-window.c: (document_supports_sidebar): Add in page
+       label support.  It's not perfect yet, but it's the first 'feature'
+       in a while.
+        Also, fix a bogus comment noticed by crispin. 
+
 Thu Mar 31 01:21:58 2005  Jonathan Blandford  <jrb@redhat.com>
 
        * Makefile.am: Remove pixbuf backend for now
index 080af0bd7ff18855c5ba4a0df3e763ce255ce2b4..d4d6f20094127f73fb854a29e3281f2f7d8cc0df 100644 (file)
@@ -201,6 +201,19 @@ ev_document_get_page_size   (EvDocument   *document,
        iface->get_page_size (document, page, width, height);
 }
 
+char *
+ev_document_get_page_label(EvDocument    *document,
+                          int             page)
+{
+       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+
+       LOG ("ev_document_get_page_label");
+       if (iface->get_page_label == NULL)
+               return NULL;
+
+       return iface->get_page_label (document, page);
+}
+
 char *
 ev_document_get_text (EvDocument   *document,
                      GdkRectangle *rect)
index 15b2cc95447e776bdee357694a251a94ab6990ae..e5c91b713f7a156a7eb0f977f054a854f5054570 100644 (file)
@@ -79,6 +79,8 @@ struct _EvDocumentIface
                                         int           page,
                                         int          *width,
                                         int          *height);
+       char      * (* get_page_label)  (EvDocument   *document,
+                                        int           page);
        char      * (* get_text)        (EvDocument   *document,
                                         GdkRectangle *rect);
        EvLink    * (* get_link)        (EvDocument   *document,
@@ -111,6 +113,8 @@ void       ev_document_get_page_size (EvDocument    *document,
                                      int            page,
                                      int           *width,
                                      int           *height);
+char      *ev_document_get_page_label(EvDocument    *document,
+                                    int             page);
 char      *ev_document_get_text      (EvDocument    *document,
                                      GdkRectangle  *rect);
 EvLink    *ev_document_get_link      (EvDocument    *document,
index f16ddc553c7b89b103d8f6b123a1a9dcafeeec17..204239476f87c8b74da7f24ffc8f4eed8a3da5f0 100644 (file)
@@ -16,6 +16,7 @@ struct _EvPageCache
        gint current_page;
        int n_pages;
        char *title;
+       char **page_labels;
 
        gboolean uniform;
        gint uniform_width;
@@ -100,6 +101,7 @@ _ev_page_cache_new (EvDocument *document)
        page_cache->uniform = TRUE;
        page_cache->n_pages = ev_document_get_n_pages (document);
        page_cache->title = ev_document_get_title (document);
+       page_cache->page_labels = g_new0 (char *, page_cache->n_pages);
 
        ev_document_set_scale (document, 1.0);
        for (i = 0; i < page_cache->n_pages; i++) {
@@ -107,6 +109,7 @@ _ev_page_cache_new (EvDocument *document)
                gint page_height = 0;
 
                ev_document_get_page_size (document, i, &page_width, &page_height);
+               page_cache->page_labels[i] = ev_document_get_page_label (document, i);
 
                if (i == 0) {
                        page_cache->uniform_width = page_width;
@@ -228,6 +231,19 @@ ev_page_cache_get_size (EvPageCache *page_cache,
                *height = (*height) * scale;
 
 }
+gchar *
+ev_page_cache_get_page_label (EvPageCache *page_cache,
+                             gint         page)
+{
+       g_return_val_if_fail (EV_IS_PAGE_CACHE (page_cache), NULL);
+       g_return_val_if_fail (page >= 0 && page < page_cache->n_pages, NULL);
+
+       if (page_cache->page_labels[page] == NULL)
+               return g_strdup_printf ("%d", page + 1);
+
+       return g_strdup (page_cache->page_labels[page]);
+}
+
 
 gboolean
 ev_page_cache_next_page (EvPageCache *page_cache)
index 9edf67c9869962fba1190ef398e5908d41390f0d..bf5e3d142c0e06d6897352f282fb6d8f5b703cbb 100644 (file)
@@ -39,7 +39,8 @@ void           ev_page_cache_get_size         (EvPageCache *page_cache,
                                               gfloat       scale,
                                               gint        *width,
                                               gint        *height);
-
+char          *ev_page_cache_get_page_label  (EvPageCache  *page_cache,
+                                             gint          page);
 /* Navigation */
 gint           ev_page_cache_get_current_page (EvPageCache *page_cache);
 void           ev_page_cache_set_current_page (EvPageCache *page_cache,
index 6a516727bdbf30d96a19b5c86f0d05b0428336e8..1dd27b70c4747830cf0131e9705c3fc6f619363c 100644 (file)
@@ -261,6 +261,26 @@ pdf_document_get_page_size (EvDocument   *document,
                            width, height);
 }
 
+static char *
+pdf_document_get_page_label (EvDocument *document,
+                            int         page)
+{
+       PopplerPage *poppler_page = NULL;
+       char *label = NULL;
+
+       if (page == -1)
+               poppler_page = PDF_DOCUMENT (document)->page;
+       else
+               poppler_page = poppler_document_get_page (PDF_DOCUMENT (document)->document,
+                                                         page);
+
+       g_object_get (poppler_page,
+                     "label", &label,
+                     NULL);
+
+       return label;
+}
+
 static GList *
 pdf_document_get_links (EvDocument *document)
 {
@@ -359,6 +379,7 @@ pdf_document_document_iface_init (EvDocumentIface *iface)
        iface->get_page = pdf_document_get_page;
        iface->set_scale = pdf_document_set_scale;
        iface->get_page_size = pdf_document_get_page_size;
+       iface->get_page_label = pdf_document_get_page_label;
        iface->get_links = pdf_document_get_links;
        iface->render_pixbuf = pdf_document_render_pixbuf;
 };
index 03ea9e97ca980533197757565bee4e891243efbd..a278034ab743565a556fb2a2906874e705ca3150 100644 (file)
@@ -51,7 +51,7 @@ static void links_page_num_func  (GtkTreeViewColumn *tree_column,
                                  GtkCellRenderer   *cell,
                                  GtkTreeModel      *tree_model,
                                  GtkTreeIter       *iter,
-                                 gpointer           data);
+                                 EvSidebarLinks    *sidebar_links);
 static void update_page_callback (EvPageCache       *page_cache,
                                  gint               current_page,
                                  EvSidebarLinks    *sidebar_links);
@@ -189,7 +189,7 @@ ev_sidebar_links_construct (EvSidebarLinks *ev_sidebar_links)
        gtk_tree_view_column_pack_end (GTK_TREE_VIEW_COLUMN (column), renderer, FALSE);
        gtk_tree_view_column_set_cell_data_func (GTK_TREE_VIEW_COLUMN (column), renderer,
                                                 (GtkTreeCellDataFunc) links_page_num_func,
-                                                NULL, NULL);
+                                                ev_sidebar_links, NULL);
 
        
 }
@@ -207,7 +207,7 @@ links_page_num_func (GtkTreeViewColumn *tree_column,
                     GtkCellRenderer   *cell,
                     GtkTreeModel      *tree_model,
                     GtkTreeIter       *iter,
-                    gpointer           data)
+                    EvSidebarLinks    *sidebar_links)
 {
        EvLink *link;
 
@@ -217,12 +217,19 @@ links_page_num_func (GtkTreeViewColumn *tree_column,
        
        if (link != NULL &&
            ev_link_get_link_type (link) == EV_LINK_TYPE_PAGE) {
-               gchar *markup = g_strdup_printf ("<i>%d</i>", ev_link_get_page (link));
+               gchar *page_label;
+               gchar *page_string;
+
+               page_label = ev_page_cache_get_page_label (sidebar_links->priv->page_cache, ev_link_get_page (link));
+               page_string = g_markup_printf_escaped ("<i>%s</i>", page_label);
+
                g_object_set (cell,
-                             "markup", markup,
+                             "markup", page_string,
                              "visible", TRUE,
                              NULL);
-               g_free (markup);
+
+               g_free (page_label);
+               g_free (page_string);
        } else {
                g_object_set (cell,
                              "visible", FALSE,
index 7bbaa098f2b2c9a983d3be6724613d78a180f22c..b439e4bf7f78337cb6bed7c5c27cd4f12c9c2eb3 100644 (file)
@@ -222,7 +222,6 @@ ev_sidebar_thumbnails_set_document (EvSidebarThumbnails *sidebar_thumbnails,
        GdkPixbuf *loading_icon;
        gint i, n_pages;
        GtkTreeIter iter;
-       gchar *page;
        gint width = THUMBNAIL_WIDTH;
        gint height = THUMBNAIL_WIDTH;
        EvPageCache *page_cache;
@@ -249,18 +248,22 @@ ev_sidebar_thumbnails_set_document (EvSidebarThumbnails *sidebar_thumbnails,
        gtk_list_store_clear (priv->list_store);
        for (i = 0; i < n_pages; i++) {
                EvJob *job;
+               gchar *page_label;
+               gchar *page_string;
 
-               /* FIXME: Bah.  This is still -1 for some reason.  Need to track it down.. */
                job = ev_job_thumbnail_new (priv->document, i, THUMBNAIL_WIDTH);
-               page = g_strdup_printf ("<i>%d</i>", i + 1); /* FIXME: replace with string. */
+               page_label = ev_page_cache_get_page_label (page_cache, i);
+               page_string = g_markup_printf_escaped ("<i>%s</i>", page_label);
+
                gtk_list_store_append (priv->list_store, &iter);
                gtk_list_store_set (priv->list_store, &iter,
-                                   COLUMN_PAGE_STRING, page,
+                                   COLUMN_PAGE_STRING, page_string,
                                    COLUMN_PIXBUF, loading_icon,
                                    COLUMN_THUMBNAIL_SET, FALSE,
                                    COLUMN_JOB, job,
                                    -1);
-               g_free (page);
+               g_free (page_label);
+               g_free (page_string);
                ev_job_queue_add_job (job, EV_JOB_PRIORITY_LOW);
                g_object_set_data_full (G_OBJECT (job), "tree_iter",
                                        gtk_tree_iter_copy (&iter),
index 97e0c549618fa3d754957c318b10235b3e71590c..d1bce99fc8d9735714e5cb4d0ad50a74499ec674 100644 (file)
@@ -701,11 +701,11 @@ ev_view_button_press_event (GtkWidget      *widget,
 }
 
 static char *
-status_message_from_link (EvLink *link)
+status_message_from_link (EvView *view, EvLink *link)
 {
        EvLinkType type;
        char *msg = NULL;
-       int page;
+       char *page_label;
 
        type = ev_link_get_link_type (link);
        
@@ -715,8 +715,9 @@ status_message_from_link (EvLink *link)
                                msg = g_strdup (ev_link_get_title (link));
                        break;
                case EV_LINK_TYPE_PAGE:
-                       page = ev_link_get_page (link);
-                       msg = g_strdup_printf (_("Go to page %d"), page);
+                       page_label = ev_page_cache_get_page_label (view->page_cache, ev_link_get_page (link));
+                       msg = g_strdup_printf (_("Go to page %s"), page_label);
+                       g_free (page_label);
                        break;
                case EV_LINK_TYPE_EXTERNAL_URI:
                        msg = g_strdup (ev_link_get_uri (link));
@@ -874,7 +875,7 @@ ev_view_motion_notify_event (GtkWidget      *widget,
                 if (link) {
                        char *msg;
 
-                       msg = status_message_from_link (link);
+                       msg = status_message_from_link (view, link);
                        ev_view_set_status (view, msg);
                        ev_view_set_cursor (view, EV_VIEW_CURSOR_LINK);
                        g_free (msg);
index 8b3044f1799924563b56ca63750fc06dfc9a1503..96074054fc531d6baaf82a470196672cc87e0e1b 100644 (file)
@@ -495,7 +495,6 @@ update_total_pages (EvWindow *ev_window)
 static gboolean
 document_supports_sidebar (EvDocument *document)
 {
-        /* FIXME: Remove the (TRUE ||) after links are fixed in poppler-glib */
        return (EV_IS_DOCUMENT_THUMBNAILS (document) && (EV_IS_DOCUMENT_LINKS (document)));
 }