+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
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)
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,
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,
gint current_page;
int n_pages;
char *title;
+ char **page_labels;
gboolean uniform;
gint uniform_width;
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++) {
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;
*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)
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,
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)
{
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;
};
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);
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);
}
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
- gpointer data)
+ EvSidebarLinks *sidebar_links)
{
EvLink *link;
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,
GdkPixbuf *loading_icon;
gint i, n_pages;
GtkTreeIter iter;
- gchar *page;
gint width = THUMBNAIL_WIDTH;
gint height = THUMBNAIL_WIDTH;
EvPageCache *page_cache;
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),
}
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);
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));
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);
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)));
}