From dbe438c1e95c6d2901c282a0c0e204c94114fb75 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Sat, 04 Jun 2005 16:47:07 +0000 Subject: Implement fonts list. Defined out for now, since it depends on a not yet 2005-06-04 Marco Pesenti Gritti * backend/Makefile.am: * backend/ev-document-fonts.c: (ev_document_fonts_get_type), (ev_document_fonts_get_fonts_model): * backend/ev-document-fonts.h: * data/evince-properties.glade: * pdf/ev-poppler.cc: * shell/ev-properties.c: (setup_fonts_view), (ev_properties_new): * shell/ev-properties.h: * shell/ev-window.c: (ev_window_cmd_file_properties): Implement fonts list. Defined out for now, since it depends on a not yet committed poppler patch. --- diff --git a/ChangeLog b/ChangeLog index 460cebc..92ca4ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-06-04 Marco Pesenti Gritti + + * backend/Makefile.am: + * backend/ev-document-fonts.c: (ev_document_fonts_get_type), + (ev_document_fonts_get_fonts_model): + * backend/ev-document-fonts.h: + * data/evince-properties.glade: + * pdf/ev-poppler.cc: + * shell/ev-properties.c: (setup_fonts_view), (ev_properties_new): + * shell/ev-properties.h: + * shell/ev-window.c: (ev_window_cmd_file_properties): + + Implement fonts list. Defined out for now, since it depends + on a not yet committed poppler patch. + Fri Jun 3 21:07:57 2005 Jonathan Blandford * shell/ev-view.c (get_page_extents): other_page isn't necessarily diff --git a/backend/Makefile.am b/backend/Makefile.am index b85f62d..744c932 100644 --- a/backend/Makefile.am +++ b/backend/Makefile.am @@ -17,6 +17,8 @@ libevbackend_la_SOURCES= \ ev-document.h \ ev-document-thumbnails.c \ ev-document-thumbnails.h \ + ev-document-fonts.c \ + ev-document-fonts.h \ ev-document-links.c \ ev-document-links.h \ ev-document-security.c \ diff --git a/backend/ev-document-fonts.c b/backend/ev-document-fonts.c new file mode 100644 index 0000000..9c4d4d6 --- /dev/null +++ b/backend/ev-document-fonts.c @@ -0,0 +1,60 @@ +/* ev-document-fonts.h + * this file is part of evince, a gnome document_fonts viewer + * + * Copyright (C) 2004 Red Hat, Inc. + * + * Author: + * Marco Pesenti Gritti + * + * 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. + */ + +#include "config.h" + +#include "ev-document-fonts.h" +#include "ev-job-queue.h" + +GType +ev_document_fonts_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) + { + static const GTypeInfo our_info = + { + sizeof (EvDocumentFontsIface), + NULL, + NULL, + }; + + type = g_type_register_static (G_TYPE_INTERFACE, + "EvDocumentFonts", + &our_info, (GTypeFlags)0); + } + + return type; +} + +GtkTreeModel * +ev_document_fonts_get_fonts_model (EvDocumentFonts *document_fonts) +{ + EvDocumentFontsIface *iface = EV_DOCUMENT_FONTS_GET_IFACE (document_fonts); + GtkTreeModel *retval; + + retval = iface->get_fonts_model (document_fonts); + + return retval; +} diff --git a/backend/ev-document-fonts.h b/backend/ev-document-fonts.h new file mode 100644 index 0000000..6cb07e2 --- /dev/null +++ b/backend/ev-document-fonts.h @@ -0,0 +1,65 @@ +/* ev-document-fonts.h + * this file is part of evince, a gnome document viewer + * + * Copyright (C) 2004 Red Hat, Inc. + * + * Author: + * Marco Pesenti Gritti + * + * 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_DOCUMENT_FONTS_H +#define EV_DOCUMENT_FONTS_H + +#include +#include +#include + +#include "ev-document.h" +#include "ev-link.h" + +G_BEGIN_DECLS + + +#define EV_TYPE_DOCUMENT_FONTS (ev_document_fonts_get_type ()) +#define EV_DOCUMENT_FONTS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT_FONTS, EvDocumentFonts)) +#define EV_DOCUMENT_FONTS_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT_FONTS, EvDocumentFontsIface)) +#define EV_IS_DOCUMENT_FONTS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT_FONTS)) +#define EV_IS_DOCUMENT_FONTS_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT_FONTS)) +#define EV_DOCUMENT_FONTS_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_DOCUMENT_FONTS, EvDocumentFontsIface)) + +typedef struct _EvDocumentFonts EvDocumentFonts; +typedef struct _EvDocumentFontsIface EvDocumentFontsIface; + +enum { + EV_DOCUMENT_FONTS_COLUMN_NAME, + EV_DOCUMENT_FONTS_COLUMN_NUM_COLUMNS +}; + +struct _EvDocumentFontsIface +{ + GTypeInterface base_iface; + + /* Methods */ + GtkTreeModel *(* get_fonts_model) (EvDocumentFonts *document_fonts); +}; + +GType ev_document_fonts_get_type (void); +GtkTreeModel *ev_document_fonts_get_fonts_model (EvDocumentFonts *document_fonts); + +G_END_DECLS + +#endif diff --git a/data/evince-properties.glade b/data/evince-properties.glade index d900f37..874aff4 100644 --- a/data/evince-properties.glade +++ b/data/evince-properties.glade @@ -760,7 +760,73 @@ True - PDF Properties + General + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + 12 + True + False + 0 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + False + False + False + + + + + 0 + True + True + + + + + False + True + + + + + + True + Fonts False False GTK_JUSTIFY_LEFT diff --git a/pdf/ev-poppler.cc b/pdf/ev-poppler.cc index 7f2330d..a403388 100644 --- a/pdf/ev-poppler.cc +++ b/pdf/ev-poppler.cc @@ -30,6 +30,7 @@ #include "ev-document-find.h" #include "ev-document-misc.h" #include "ev-document-links.h" +#include "ev-document-fonts.h" #include "ev-document-security.h" #include "ev-document-thumbnails.h" @@ -62,6 +63,7 @@ static void pdf_document_document_iface_init (EvDocumentIface static void pdf_document_security_iface_init (EvDocumentSecurityIface *iface); static void pdf_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface); static void pdf_document_document_links_iface_init (EvDocumentLinksIface *iface); +static void pdf_document_document_fonts_iface_init (EvDocumentFontsIface *iface); static void pdf_document_find_iface_init (EvDocumentFindIface *iface); static void pdf_document_ps_exporter_iface_init (EvPSExporterIface *iface); static void pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails, @@ -82,6 +84,8 @@ G_DEFINE_TYPE_WITH_CODE (PdfDocument, pdf_document, G_TYPE_OBJECT, pdf_document_document_thumbnails_iface_init); G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_LINKS, pdf_document_document_links_iface_init); + G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_FONTS, + pdf_document_document_fonts_iface_init); G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_FIND, pdf_document_find_iface_init); G_IMPLEMENT_INTERFACE (EV_TYPE_PS_EXPORTER, @@ -491,6 +495,55 @@ pdf_document_security_iface_init (EvDocumentSecurityIface *iface) iface->set_password = pdf_document_set_password; } +static void +build_fonts_list (PdfDocument *pdf_document, + GtkTreeModel *model, + GtkTreeIter *parent, + PopplerFontsIter *iter) +{ +#ifdef POPPLER_FONT_INFO + do { + GtkTreeIter list_iter; + PopplerIndexIter *child; + char *name; + + name = poppler_fonts_iter_get_name (iter); + gtk_list_store_append (GTK_LIST_STORE (model), &list_iter); + gtk_list_store_set (GTK_LIST_STORE (model), &list_iter, + EV_DOCUMENT_FONTS_COLUMN_NAME, name, + -1); + g_free (name); + } while (poppler_fonts_iter_next (iter)); +#endif +} + +static GtkTreeModel * +pdf_document_fonts_get_fonts_model (EvDocumentFonts *document_fonts) +{ + PdfDocument *pdf_document = PDF_DOCUMENT (document_fonts); + GtkTreeModel *model = NULL; + PopplerFontsIter *iter; + + g_return_val_if_fail (PDF_IS_DOCUMENT (document_fonts), NULL); + + iter = poppler_fonts_iter_new (pdf_document->document); + /* Create the model iff we have items*/ + if (iter != NULL) { + model = (GtkTreeModel *) gtk_list_store_new (EV_DOCUMENT_FONTS_COLUMN_NUM_COLUMNS, + G_TYPE_STRING); + build_fonts_list (pdf_document, model, NULL, iter); + poppler_fonts_iter_free (iter); + } + + return model; +} + +static void +pdf_document_document_fonts_iface_init (EvDocumentFontsIface *iface) +{ + iface->get_fonts_model = pdf_document_fonts_get_fonts_model; +} + static gboolean pdf_document_links_has_document_links (EvDocumentLinks *document_links) { @@ -526,7 +579,6 @@ ev_link_from_action (PopplerAction *action) return link; } - static void build_tree (PdfDocument *pdf_document, GtkTreeModel *model, @@ -582,7 +634,6 @@ pdf_document_links_get_links_model (EvDocumentLinks *document_links) return model; } - static void pdf_document_document_links_iface_init (EvDocumentLinksIface *iface) { @@ -590,7 +641,6 @@ pdf_document_document_links_iface_init (EvDocumentLinksIface *iface) iface->get_links_model = pdf_document_links_get_links_model; } - static GdkPixbuf * make_thumbnail_for_size (PdfDocument *pdf_document, gint page, diff --git a/shell/ev-properties.c b/shell/ev-properties.c index 78c2f14..a8c5a1e 100644 --- a/shell/ev-properties.c +++ b/shell/ev-properties.c @@ -23,6 +23,7 @@ #endif #include "ev-properties.h" +#include "ev-document-fonts.h" #include #include @@ -96,8 +97,29 @@ set_property (GladeXML *xml, Property property, const char *text) gtk_label_set_text (GTK_LABEL (widget), text ? text : ""); } +static void +setup_fonts_view (GladeXML *xml, GtkTreeModel *fonts) +{ + GtkWidget *widget; + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + + widget = glade_xml_get_widget (xml, "fonts_treeview"); + gtk_tree_view_set_model (GTK_TREE_VIEW (widget), fonts); + + column = gtk_tree_view_column_new (); + gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE); + gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column); + + renderer = gtk_cell_renderer_text_new (); + gtk_tree_view_column_pack_start (GTK_TREE_VIEW_COLUMN (column), renderer, FALSE); + gtk_tree_view_column_set_attributes (GTK_TREE_VIEW_COLUMN (column), renderer, + "text", EV_DOCUMENT_FONTS_COLUMN_NAME, + NULL); +} + GtkDialog * -ev_properties_new (EvDocumentInfo *info) +ev_properties_new (EvDocumentInfo *info, GtkTreeModel *fonts) { GladeXML *xml; GtkWidget *dialog; @@ -159,5 +181,9 @@ ev_properties_new (EvDocumentInfo *info) set_property (xml, SECURITY_PROPERTY, info->security); } + if (fonts) { + setup_fonts_view (xml, fonts); + } + return GTK_DIALOG (dialog); } diff --git a/shell/ev-properties.h b/shell/ev-properties.h index 1accd2f..03cd4e3 100644 --- a/shell/ev-properties.h +++ b/shell/ev-properties.h @@ -22,13 +22,14 @@ #define __EV_PROPERTIES_H__ #include "ev-document.h" -#include "ev-window.h" #include +#include G_BEGIN_DECLS -GtkDialog *ev_properties_new (EvDocumentInfo *info); +GtkDialog *ev_properties_new (EvDocumentInfo *info, + GtkTreeModel *fonts); G_END_DECLS diff --git a/shell/ev-window.c b/shell/ev-window.c index 034fa1b..2404001 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -40,6 +40,7 @@ #include "ev-properties.h" #include "ev-document-thumbnails.h" #include "ev-document-links.h" +#include "ev-document-fonts.h" #include "ev-document-types.h" #include "ev-document-find.h" #include "ev-document-security.h" @@ -1188,11 +1189,19 @@ ev_window_cmd_file_print (GtkAction *action, EvWindow *ev_window) static void ev_window_cmd_file_properties (GtkAction *action, EvWindow *ev_window) { + EvDocument *document = ev_window->priv->document; EvDocumentInfo *info; GtkDialog *dialog; + GtkTreeModel *fonts; - info = ev_document_get_info (ev_window->priv->document); - dialog = ev_properties_new (info); + if (EV_IS_DOCUMENT_FONTS (document)) { + fonts = ev_document_fonts_get_fonts_model (EV_DOCUMENT_FONTS (document)); + } else { + fonts = NULL; + } + + info = ev_document_get_info (document); + dialog = ev_properties_new (info, fonts); gtk_dialog_run (dialog); gtk_widget_destroy (GTK_WIDGET (dialog)); ev_document_info_free (info); -- cgit v0.9.1