]> www.fi.muni.cz Git - evince.git/commitdiff
Implement fonts list. Defined out for now, since it depends on a not yet
authorMarco Pesenti Gritti <mpg@redhat.com>
Sat, 4 Jun 2005 16:47:07 +0000 (16:47 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Sat, 4 Jun 2005 16:47:07 +0000 (16:47 +0000)
2005-06-04  Marco Pesenti Gritti <mpg@redhat.com>

        * 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.

ChangeLog
backend/Makefile.am
backend/ev-document-fonts.c [new file with mode: 0644]
backend/ev-document-fonts.h [new file with mode: 0644]
data/evince-properties.glade
pdf/ev-poppler.cc
shell/ev-properties.c
shell/ev-properties.h
shell/ev-window.c

index 460cebcc347b00ff137a5d99ddcae0e23618452d..92ca4ac06bab711127e551b8ffe773ca859e6244 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2005-06-04  Marco Pesenti Gritti <mpg@redhat.com>
+
+       * 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  <jrb@redhat.com>
 
        * shell/ev-view.c (get_page_extents): other_page isn't necessarily
index b85f62d0c7437e66ee958c327ca5769acd681c3a..744c932d926ed0201618086a1c67c6ca4e53ddec 100644 (file)
@@ -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 (file)
index 0000000..9c4d4d6
--- /dev/null
@@ -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 <mpg@redhat.com>
+ *
+ * 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 (file)
index 0000000..6cb07e2
--- /dev/null
@@ -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 <mpg@redhat.com>
+ *
+ * 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 <glib-object.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#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
index d900f37ae700f059938cabc5ccf3f5715a81495e..874aff42b44fc13195bfcb09f082359ead3cef17 100644 (file)
          <child>
            <widget class="GtkLabel" id="pdf_properties_label">
              <property name="visible">True</property>
-             <property name="label" translatable="yes">PDF Properties</property>
+             <property name="label" translatable="yes">General</property>
+             <property name="use_underline">False</property>
+             <property name="use_markup">False</property>
+             <property name="justify">GTK_JUSTIFY_LEFT</property>
+             <property name="wrap">False</property>
+             <property name="selectable">False</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xpad">0</property>
+             <property name="ypad">0</property>
+             <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+             <property name="width_chars">-1</property>
+             <property name="single_line_mode">False</property>
+             <property name="angle">0</property>
+           </widget>
+           <packing>
+             <property name="type">tab</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkVBox" id="vbox1">
+             <property name="border_width">12</property>
+             <property name="visible">True</property>
+             <property name="homogeneous">False</property>
+             <property name="spacing">0</property>
+
+             <child>
+               <widget class="GtkScrolledWindow" id="scrolledwindow1">
+                 <property name="visible">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                 <property name="shadow_type">GTK_SHADOW_IN</property>
+                 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+                 <child>
+                   <widget class="GtkTreeView" id="fonts_treeview">
+                     <property name="visible">True</property>
+                     <property name="can_focus">True</property>
+                     <property name="headers_visible">True</property>
+                     <property name="rules_hint">False</property>
+                     <property name="reorderable">False</property>
+                     <property name="enable_search">True</property>
+                     <property name="fixed_height_mode">False</property>
+                     <property name="hover_selection">False</property>
+                     <property name="hover_expand">False</property>
+                   </widget>
+                 </child>
+               </widget>
+               <packing>
+                 <property name="padding">0</property>
+                 <property name="expand">True</property>
+                 <property name="fill">True</property>
+               </packing>
+             </child>
+           </widget>
+           <packing>
+             <property name="tab_expand">False</property>
+             <property name="tab_fill">True</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkLabel" id="label1">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">Fonts</property>
              <property name="use_underline">False</property>
              <property name="use_markup">False</property>
              <property name="justify">GTK_JUSTIFY_LEFT</property>
index 7f2330da8755974adfbced7f3efcb1248ee4ecd0..a4033881b314680334ea9c03be6ce426c88eedd4 100644 (file)
@@ -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,
index 78c2f1474aa07ffc219a6d01da4306cf1f52ddbd..a8c5a1ecc155810d500bb12a2db0acdeceea9a02 100644 (file)
@@ -23,6 +23,7 @@
 #endif
 
 #include "ev-properties.h"
+#include "ev-document-fonts.h"
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
@@ -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); 
 }
index 1accd2fe974d626a080602e21216e5f3ce79407e..03cd4e3287e25caeca0f8c6b55a8881aae45cb9a 100644 (file)
 #define __EV_PROPERTIES_H__
 
 #include "ev-document.h"
-#include "ev-window.h"
 
 #include <gtk/gtkdialog.h>
+#include <gtk/gtktreemodel.h>
 
 G_BEGIN_DECLS
 
-GtkDialog *ev_properties_new (EvDocumentInfo *info);
+GtkDialog *ev_properties_new (EvDocumentInfo   *info,
+                             GtkTreeModel     *fonts);
 
 G_END_DECLS
 
index 034fa1b06b54b6dbf76ddff5bd93d852873fd87c..2404001ef4862262c01bbb05543b5798619943ee 100644 (file)
@@ -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);