]> www.fi.muni.cz Git - evince.git/commitdiff
Bug #311280
authorMartin Kretzschmar <martink@src.gnome.org>
Sun, 24 Jul 2005 19:00:45 +0000 (19:00 +0000)
committerMartin Kretzschmar <martink@src.gnome.org>
Sun, 24 Jul 2005 19:00:45 +0000 (19:00 +0000)
* pdf/ev-poppler.cc (font_type_to_string): new, returns user readable
name for PopplerFontTypes
(pdf_document_fonts_fill_model): add font type to the detail column

* backend/ev-document-fonts.h: added
EV_DOCUMENT_FONTS_COLUMN_DETAILS.

* shell/ev-properties-fonts.c (font_cell_data_func): glue together
font name and font details, add a little markup.
(ev_properties_fonts_init): use the new cell data func, specify ypad
property for the cell renderer.
(ev_properties_fonts_set_document): add the details column.

ChangeLog
backend/ev-document-fonts.h
pdf/ev-poppler.cc
shell/ev-properties-fonts.c

index c1679cdd2389dfa493ef2bb36643de1f613f7fbb..efcc003ff0ce4ed678fdc3bd9d51af5866ae5365 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2005-07-24  Martin Kretzschmar  <martink@gnome.org>
+
+       Bug #311280
+       
+       * pdf/ev-poppler.cc (font_type_to_string): new, returns user readable
+       name for PopplerFontTypes
+       (pdf_document_fonts_fill_model): add font type to the detail column
+
+       * backend/ev-document-fonts.h: added
+       EV_DOCUMENT_FONTS_COLUMN_DETAILS.
+
+       * shell/ev-properties-fonts.c (font_cell_data_func): glue together
+       font name and font details, add a little markup.
+       (ev_properties_fonts_init): use the new cell data func, specify ypad
+       property for the cell renderer.
+       (ev_properties_fonts_set_document): add the details column.
+
 2005-07-24  Artur Flinta  <aflinta@cvs.gnome.org>
 
         * configure.ac: Added "pl" to ALL_LINGUAS.
index d069b9d83519bdf9445b8bca9c3ecf2022a23666..c9f58f532650ed67f46a73d001c8fcc551226a45 100644 (file)
@@ -46,6 +46,7 @@ typedef struct _EvDocumentFontsIface EvDocumentFontsIface;
 
 enum {
        EV_DOCUMENT_FONTS_COLUMN_NAME,
+       EV_DOCUMENT_FONTS_COLUMN_DETAILS,
        EV_DOCUMENT_FONTS_COLUMN_NUM_COLUMNS
 };
 
index aa33b7f1ba39726b3522fcbd72da5ccbc8522254..be2de7deb2993be1c56e65b878b5a4b7ef106439 100644 (file)
@@ -678,6 +678,30 @@ pdf_document_fonts_scan (EvDocumentFonts *document_fonts,
        return result;
 }
 
+static const char *
+font_type_to_string (PopplerFontType type)
+{
+       switch (type)
+       {
+       case POPPLER_FONT_TYPE_TYPE1:
+               return _("Type 1");
+       case POPPLER_FONT_TYPE_TYPE1C:
+               return _("Type 1C");
+       case POPPLER_FONT_TYPE_TYPE3:
+               return _("Type 3");
+       case POPPLER_FONT_TYPE_TRUETYPE:
+               return _("TrueType");
+       case POPPLER_FONT_TYPE_CID_TYPE0:
+               return _("Type 1 (CID)");
+       case POPPLER_FONT_TYPE_CID_TYPE0C:
+               return _("Type 1C (CID)");
+       case POPPLER_FONT_TYPE_CID_TYPE2:
+               return _("TrueType (CID)");
+       default:
+               return _("Unknown font type ");
+       }
+}
+
 static void
 pdf_document_fonts_fill_model (EvDocumentFonts *document_fonts,
                               GtkTreeModel    *model)
@@ -687,22 +711,44 @@ pdf_document_fonts_fill_model (EvDocumentFonts *document_fonts,
 
        g_return_if_fail (PDF_IS_DOCUMENT (document_fonts));
 
-       if (iter) {
-               do {
-                       GtkTreeIter list_iter;
-                       const char *name;
+       if (!iter)
+               return;
+
+       do {
+               GtkTreeIter list_iter;
+               const char *name;
+               const char *type;
+               const char *embedded;
+               char *details;
                
-                       name = poppler_fonts_iter_get_name (iter);
-                       if (name == NULL) {
-                               name = _("No name");
-                       }
-
-                       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);
-               } while (poppler_fonts_iter_next (iter));
-       }
+               name = poppler_fonts_iter_get_name (iter);
+
+               if (name == NULL) {
+                       name = _("No name");
+               }
+
+               type = font_type_to_string (
+                       poppler_fonts_iter_get_font_type (iter));
+
+               if (poppler_fonts_iter_is_embedded (iter)) {
+                       if (poppler_fonts_iter_is_subset (iter))
+                               embedded = _("Embedded subset");
+                       else
+                               embedded = _("Embedded");
+               } else {
+                       embedded = _("Not embedded");
+               }
+
+               details = g_markup_printf_escaped ("%s\n%s", type, embedded);
+
+               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,
+                                   EV_DOCUMENT_FONTS_COLUMN_DETAILS, details,
+                                   -1);
+
+               g_free (details);
+       } while (poppler_fonts_iter_next (iter));
 }
 
 static void
index d86e106552409d240d4f1e5169f6e89b4db99822..5a792072b172d31063a46152352071e66e24579a 100644 (file)
@@ -67,6 +67,33 @@ ev_properties_fonts_class_init (EvPropertiesFontsClass *properties_class)
        g_object_class->dispose = ev_properties_fonts_dispose;
 }
 
+static void
+font_cell_data_func (GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                    GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
+{
+       char *name;
+       char *details;
+       char *markup;
+
+       gtk_tree_model_get(model, iter,
+                          EV_DOCUMENT_FONTS_COLUMN_NAME, &name,
+                          EV_DOCUMENT_FONTS_COLUMN_DETAILS, &details,
+                          -1); 
+
+       if (details) {
+               markup = g_strdup_printf ("<b><big>%s</big></b>\n<small>%s</small>",
+                                         name, details);
+       } else {
+               markup = g_strdup_printf ("<b><big>%s</big></b>", name);
+       }
+
+       g_object_set (renderer, "markup", markup, NULL);
+       
+       g_free (markup);
+       g_free (details);
+       g_free (name);
+}
+
 static void
 ev_properties_fonts_init (EvPropertiesFonts *properties)
 {
@@ -90,12 +117,13 @@ ev_properties_fonts_init (EvPropertiesFonts *properties)
        gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
        gtk_tree_view_append_column (GTK_TREE_VIEW (properties->fonts_treeview), column);
 
-       renderer = gtk_cell_renderer_text_new ();
+       renderer = GTK_CELL_RENDERER (g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
+                                                   "ypad", 6, NULL));
        gtk_tree_view_column_pack_start (GTK_TREE_VIEW_COLUMN (column), renderer, FALSE);
-       gtk_tree_view_column_set_title (GTK_TREE_VIEW_COLUMN (column), _("Name"));
-       gtk_tree_view_column_set_attributes (GTK_TREE_VIEW_COLUMN (column), renderer,
-                                            "text", EV_DOCUMENT_FONTS_COLUMN_NAME,
-                                            NULL);
+       gtk_tree_view_column_set_title (GTK_TREE_VIEW_COLUMN (column), _("Font"));
+       gtk_tree_view_column_set_cell_data_func (column, renderer,
+                                                font_cell_data_func,
+                                                NULL, NULL);
 }
 
 static void
@@ -151,7 +179,7 @@ ev_properties_fonts_set_document (EvPropertiesFonts *properties,
        properties->document = document;
 
        list_store = gtk_list_store_new (EV_DOCUMENT_FONTS_COLUMN_NUM_COLUMNS,
-                                        G_TYPE_STRING);
+                                        G_TYPE_STRING, G_TYPE_STRING);
        gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (list_store));
 
        job = ev_job_fonts_new (properties->document);