]> www.fi.muni.cz Git - evince.git/blobdiff - libdocument/ev-document.c
[dualscreen] fix crash on ctrl+w and fix control window closing
[evince.git] / libdocument / ev-document.c
index 1747bf1b216255677bcbab98dc20401cb8555bf0..78fb8a08f2de918ee52789a67f56492bde42523b 100644 (file)
@@ -25,6 +25,7 @@
 #include <string.h>
 
 #include "ev-document.h"
+#include "ev-document-misc.h"
 #include "synctex_parser.h"
 
 #define EV_DOCUMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EV_TYPE_DOCUMENT, EvDocumentPrivate))
@@ -419,11 +420,16 @@ ev_document_synctex_backward_search (EvDocument *document,
                 /* We assume that a backward search returns either zero or one result_node */
                 node = synctex_next_result (scanner);
                 if (node != NULL) {
-                        result = g_new (EvSourceLink, 1);
-                        result->filename = synctex_scanner_get_name (scanner,
-                                                                     synctex_node_tag (node));
-                        result->line = synctex_node_line (node);
-                        result->col = synctex_node_column (node);
+                       const gchar *filename;
+
+                       filename = synctex_scanner_get_name (scanner, synctex_node_tag (node));
+                       
+                       if (filename) {
+                               result = g_new (EvSourceLink, 1);
+                               result->filename = filename;
+                               result->line = synctex_node_line (node);
+                               result->col = synctex_node_column (node);
+                       }
                 }
         }
 
@@ -433,9 +439,7 @@ ev_document_synctex_backward_search (EvDocument *document,
 /**
  * ev_document_synctex_forward_search:
  * @document:
- * @filename: the source filename
- * @line: line number in the source file
- * @col: column number in the source file
+ * @source_link:
  *
  * Peforms a Synctex forward search to obtain the area in the document
  * corresponding to the position @line and @column number in the source Tex file
@@ -444,10 +448,8 @@ ev_document_synctex_backward_search (EvDocument *document,
  * the given line in the source file. It must be free with g_free when done
  */
 EvMapping *
-ev_document_synctex_forward_search (EvDocument  *document,
-                                    const gchar *filename,
-                                    gint         line,
-                                    gint         col)
+ev_document_synctex_forward_search (EvDocument   *document,
+                                   EvSourceLink *link)
 {
         EvMapping        *result = NULL;
         synctex_scanner_t scanner;
@@ -458,7 +460,7 @@ ev_document_synctex_forward_search (EvDocument  *document,
         if (!scanner)
                 return NULL;
 
-        if (synctex_display_query (scanner, filename, line, col) > 0) {
+        if (synctex_display_query (scanner, link->filename, link->line, link->col) > 0) {
                 synctex_node_t node;
                 gint           page;
 
@@ -585,6 +587,32 @@ ev_document_render (EvDocument      *document,
        return klass->render (document, rc);
 }
 
+static GdkPixbuf *
+_ev_document_get_thumbnail (EvDocument      *document,
+                           EvRenderContext *rc)
+{
+       cairo_surface_t *surface;
+       GdkPixbuf       *pixbuf;
+
+       surface = ev_document_render (document, rc);
+       pixbuf = ev_document_misc_pixbuf_from_surface (surface);
+       cairo_surface_destroy (surface);
+
+       return pixbuf;
+}
+
+GdkPixbuf *
+ev_document_get_thumbnail (EvDocument      *document,
+                          EvRenderContext *rc)
+{
+       EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
+
+       if (klass->get_thumbnail)
+               return klass->get_thumbnail (document, rc);
+
+       return _ev_document_get_thumbnail (document, rc);
+}
+
 const gchar *
 ev_document_get_uri (EvDocument *document)
 {