<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_CENTER</property>
- <property name="focus_on_map">True</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<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="left_attach">0</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="left_attach">0</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="left_attach">0</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="left_attach">0</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="left_attach">0</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="left_attach">0</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="left_attach">0</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="left_attach">0</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="left_attach">0</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="left_attach">0</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="left_attach">0</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="left_attach">0</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="left_attach">1</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="left_attach">1</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="left_attach">1</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="left_attach">1</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="left_attach">1</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="left_attach">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">1</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>
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
- <property name="spacing">0</property>
+ <property name="spacing">6</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<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="headers_visible">False</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>
<property name="fill">True</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkLabel" id="font_progress_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"></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</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="tab_expand">False</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>
PopplerPSFile *ps_file;
gchar *password;
+ PopplerFontInfo *font_info;
+ PopplerFontsIter *fonts_iter;
+ int fonts_scanned_pages;
+
PdfDocumentSearch *search;
};
if (pdf_document->document) {
g_object_unref (pdf_document->document);
}
+
+ if (pdf_document->font_info) {
+ poppler_font_info_free (pdf_document->font_info);
+ }
+
+ if (pdf_document->fonts_iter) {
+ poppler_fonts_iter_free (pdf_document->fonts_iter);
+ }
}
static void
iface->set_password = pdf_document_set_password;
}
+static gdouble
+pdf_document_fonts_get_progress (EvDocumentFonts *document_fonts)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document_fonts);
+ int n_pages;
+
+ n_pages = pdf_document_get_n_pages (EV_DOCUMENT (pdf_document));
+
+ return (double)pdf_document->fonts_scanned_pages / (double)n_pages;
+}
+
static gboolean
-pdf_document_fonts_fill_model (EvDocumentFonts *document_fonts,
- GtkTreeModel *model,
- int n_pages)
+pdf_document_fonts_scan (EvDocumentFonts *document_fonts,
+ int n_pages)
{
-#ifdef POPPLER_FONT_INFO
PdfDocument *pdf_document = PDF_DOCUMENT (document_fonts);
- PopplerFontInfo *info;
- PopplerFontsIter *iter;
gboolean result;
g_return_val_if_fail (PDF_IS_DOCUMENT (document_fonts), FALSE);
- info = (PopplerFontInfo *)g_object_get_data (G_OBJECT (model), "font_info");
- if (info == NULL) {
- info = poppler_font_info_new (pdf_document->document);
- g_object_set_data_full (G_OBJECT (model), "font_info",
- (PopplerFontInfo *)info,
- (GDestroyNotify)poppler_font_info_free);
+ if (pdf_document->font_info == NULL) {
+ pdf_document->font_info = poppler_font_info_new (pdf_document->document);
+ }
+
+ if (pdf_document->fonts_iter) {
+ poppler_fonts_iter_free (pdf_document->fonts_iter);
}
- result = poppler_font_info_scan (info, n_pages, &iter);
+ pdf_document->fonts_scanned_pages += n_pages;
+
+ result = poppler_font_info_scan (pdf_document->font_info, n_pages,
+ &pdf_document->fonts_iter);
+ if (!result) {
+ pdf_document->fonts_scanned_pages = 0;
+ poppler_font_info_free (pdf_document->font_info);
+ pdf_document->font_info = NULL;
+ }
+
+ return result;
+}
+
+static void
+pdf_document_fonts_fill_model (EvDocumentFonts *document_fonts,
+ GtkTreeModel *model)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document_fonts);
+ PopplerFontsIter *iter = pdf_document->fonts_iter;
+
+ g_return_if_fail (PDF_IS_DOCUMENT (document_fonts));
if (iter) {
do {
EV_DOCUMENT_FONTS_COLUMN_NAME, name,
-1);
} while (poppler_fonts_iter_next (iter));
- poppler_fonts_iter_free (iter);
}
-
- return result;
-#else
- return FALSE;
-#endif
}
static void
pdf_document_document_fonts_iface_init (EvDocumentFontsIface *iface)
{
iface->fill_model = pdf_document_fonts_fill_model;
+ iface->scan = pdf_document_fonts_scan;
+ iface->get_progress = pdf_document_fonts_get_progress;
}
static gboolean
gtk_label_set_text (GTK_LABEL (widget), text ? text : "");
}
+static void
+update_progress_label (GtkWidget *label, double progress)
+{
+ if (progress > 0) {
+ char *progress_text;
+ progress_text = g_strdup_printf (_("Gathering font information... %3d%%"),
+ (int) (progress * 100));
+ gtk_label_set_text (GTK_LABEL (label), progress_text);
+ g_free (progress_text);
+ } else {
+ gtk_label_set_text (GTK_LABEL (label), "");
+ }
+}
+
static void
job_fonts_finished_cb (EvJob *job, GtkTreeView *tree_view)
{
- GtkTreeModel *model = EV_JOB_FONTS (job)->model;
+ EvDocumentFonts *document_fonts = EV_DOCUMENT_FONTS (job->document);
+ GtkWidget *progress_label;
+ double progress;
+
+ progress_label = g_object_get_data (G_OBJECT (tree_view), "progress_label");
+ progress = ev_document_fonts_get_progress (document_fonts);
+ update_progress_label (progress_label, progress);
if (EV_JOB_FONTS (job)->scan_completed) {
g_signal_handlers_disconnect_by_func
(job, job_fonts_finished_cb, tree_view);
- gtk_tree_view_set_model (tree_view, model);
} else {
- EvJob *new_job = ev_job_fonts_new (job->document, model);
+ EvJob *new_job;
+
+ ev_document_fonts_fill_model (document_fonts,
+ gtk_tree_view_get_model (tree_view));
+ new_job = ev_job_fonts_new (job->document);
ev_job_queue_add_job (job, EV_JOB_PRIORITY_LOW);
g_object_unref (new_job);
}
}
-static void
-fill_fonts_treeview (GtkTreeView *tree_view,
- EvDocument *document)
-{
- GtkListStore *list_store;
- EvJob *job;
-
- list_store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING);
- g_object_set_data_full (G_OBJECT (tree_view), "list_store",
- list_store, g_object_unref);
-
- job = ev_job_fonts_new (document, GTK_TREE_MODEL (list_store));
- g_signal_connect_object (job, "finished",
- G_CALLBACK (job_fonts_finished_cb),
- tree_view, 0);
- ev_job_queue_add_job (job, EV_JOB_PRIORITY_LOW);
- g_object_unref (job);
-}
-
static void
setup_fonts_view (GladeXML *xml, EvDocument *document)
{
- GtkWidget *widget;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkListStore *list_store;
- GtkTreeIter iter;
-
- widget = glade_xml_get_widget (xml, "fonts_treeview");
-
- list_store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING);
- gtk_list_store_append (list_store, &iter);
- gtk_list_store_set (list_store, &iter, FONT_NAME_COL, _("Loading..."), -1);
+ EvJob *job;
+ GtkWidget *tree_view;
+ GtkWidget *progress_label;
- gtk_tree_view_set_model (GTK_TREE_VIEW (widget), GTK_TREE_MODEL (list_store));
- g_object_unref (list_store);
+ tree_view = glade_xml_get_widget (xml, "fonts_treeview");
+ progress_label = glade_xml_get_widget (xml, "font_progress_label");
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);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (GTK_TREE_VIEW_COLUMN (column), renderer, FALSE);
"text", EV_DOCUMENT_FONTS_COLUMN_NAME,
NULL);
- fill_fonts_treeview (GTK_TREE_VIEW (widget), document);
+ list_store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view),
+ GTK_TREE_MODEL (list_store));
+
+ job = ev_job_fonts_new (document);
+ g_object_set_data (G_OBJECT (tree_view), "progress_label",
+ progress_label);
+ g_signal_connect_object (job, "finished",
+ G_CALLBACK (job_fonts_finished_cb),
+ tree_view, 0);
+ ev_job_queue_add_job (job, EV_JOB_PRIORITY_LOW);
+ g_object_unref (job);
}
GtkDialog *