From dccf9855895c5f35bb0899bbd9c093baef02efc7 Mon Sep 17 00:00:00 2001 From: Martin Kretzschmar Date: Sun, 24 Jul 2005 19:00:45 +0000 Subject: 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. --- diff --git a/ChangeLog b/ChangeLog index c1679cd..efcc003 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2005-07-24 Martin Kretzschmar + + 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 * configure.ac: Added "pl" to ALL_LINGUAS. diff --git a/backend/ev-document-fonts.h b/backend/ev-document-fonts.h index d069b9d..c9f58f5 100644 --- a/backend/ev-document-fonts.h +++ b/backend/ev-document-fonts.h @@ -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 }; diff --git a/pdf/ev-poppler.cc b/pdf/ev-poppler.cc index aa33b7f..be2de7d 100644 --- a/pdf/ev-poppler.cc +++ b/pdf/ev-poppler.cc @@ -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 diff --git a/shell/ev-properties-fonts.c b/shell/ev-properties-fonts.c index d86e106..5a79207 100644 --- a/shell/ev-properties-fonts.c +++ b/shell/ev-properties-fonts.c @@ -68,6 +68,33 @@ ev_properties_fonts_class_init (EvPropertiesFontsClass *properties_class) } 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 ("%s\n%s", + name, details); + } else { + markup = g_strdup_printf ("%s", 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) { GladeXML *xml; @@ -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); -- cgit v0.9.1