]> www.fi.muni.cz Git - evince.git/commitdiff
Add a changed event that is emitted when the page content changes. This is
authorMarco Pesenti Gritti <marco@gnome.org>
Fri, 31 Dec 2004 17:10:25 +0000 (17:10 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Fri, 31 Dec 2004 17:10:25 +0000 (17:10 +0000)
2004-12-31  Marco Pesenti Gritti  <marco@gnome.org>

        * backend/ev-document.c: (ev_document_base_init),
        (ev_document_changed):
        * backend/ev-document.h:

        Add a changed event that is emitted when the page content
        changes. This is necessary to deal with the fact that
        in ps backend rendering happen asycrounously.
        This makes the ps backend mostly work.

        * pdf/xpdf/pdf-document.cc:

        Emit changed event

        * ps/gtkgs.c: (set_up_page), (gtk_gs_widget_event),
        (ps_document_set_target):

        Emit changed event

        * shell/ev-view.c: (document_changed_callback),
        (ev_view_set_document), (ev_view_set_page):

        Redraw on the changed signal

ChangeLog
backend/ev-document.c
backend/ev-document.h
pdf/xpdf/pdf-document.cc
ps/gtkgs.c
shell/ev-view.c

index 122293ca84bcae67b12f148e42002812394ceca8..5b7828fabc6d0d0be91385a322a9768d4b891985 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2004-12-31  Marco Pesenti Gritti  <marco@gnome.org>
+
+       * backend/ev-document.c: (ev_document_base_init),
+       (ev_document_changed):
+       * backend/ev-document.h:
+
+       Add a changed event that is emitted when the page content
+       changes. This is necessary to deal with the fact that
+       in ps backend rendering happen asycrounously.
+       This makes the ps backend mostly work.
+
+       * pdf/xpdf/pdf-document.cc:
+
+       Emit changed event
+
+       * ps/gtkgs.c: (set_up_page), (gtk_gs_widget_event),
+       (ps_document_set_target):
+
+       Emit changed event
+
+       * shell/ev-view.c: (document_changed_callback),
+       (ev_view_set_document), (ev_view_set_page):
+
+       Redraw on the changed signal
+
 2004-12-25  Raphael Higino  <raphaelh@cvs.gnome.org>
 
        * configure.ac: Added pt_BR to ALL_LINGUAS.
index 59697bd6a2bc82985306a4d778336a167a4fd9d3..dcc620483dd10729a93884d4fff338395924af19 100644 (file)
 
 static void ev_document_base_init (gpointer g_class);
 
+enum
+{
+       CHANGED,
+       LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
 GType
 ev_document_get_type (void)
 {
@@ -50,7 +58,22 @@ ev_document_get_type (void)
 static void
 ev_document_base_init (gpointer g_class)
 {
+       static gboolean initialized = FALSE;
 
+       if (!initialized)
+       {
+               signals[CHANGED] =
+                       g_signal_new ("changed",
+                                     EV_TYPE_DOCUMENT,
+                                     G_SIGNAL_RUN_LAST,
+                                     G_STRUCT_OFFSET (EvDocumentIface, changed),
+                                     NULL, NULL,
+                                     g_cclosure_marshal_VOID__VOID,
+                                     G_TYPE_NONE,
+                                     0);
+
+               initialized = TRUE;
+       }
 }
 
 gboolean
@@ -128,4 +151,9 @@ ev_document_render (EvDocument  *document,
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
        iface->render (document, clip_x, clip_y, clip_width, clip_height);
 }
-                                   
+
+void
+ev_document_changed (EvDocument *document)
+{
+       g_signal_emit (G_OBJECT (document), signals[CHANGED], 0);
+}                          
index 083bd1ae5829cd4fe949e1356cc44d02b1e3c4cf..0059fd43c91685d28e60b58ce821d9ab725bf5c8 100644 (file)
@@ -42,6 +42,9 @@ struct _EvDocumentIface
 {
        GTypeInterface base_iface;
 
+       /* Signals */
+       void        (* changed)         (EvDocument *document);
+
        /* Methods  */
        gboolean    (* load)            (EvDocument *document,
                                         const char *uri,
@@ -91,6 +94,7 @@ void     ev_document_render          (EvDocument   *document,
                                      int           clip_y,
                                      int           clip_width,
                                      int           clip_height);
+void    ev_document_changed         (EvDocument *document);
 
 G_END_DECLS
 
index e6e72c2774f2afcbb2acd8cf8d16bc93d1fa0b27..24e0b36298e3fd258bff34cced8224d732ffeade 100644 (file)
@@ -204,6 +204,7 @@ pdf_document_set_page (EvDocument  *document,
                pdf_document->page_valid = FALSE;
        }
 
+       ev_document_changed (document);
 }
 
 static int
index ebb29f2341be7c39e6b42d8279d455ab0fc1db44..74d619579f4829cbdc082571088c68e9cd4028da 100644 (file)
@@ -498,6 +498,7 @@ set_up_page(GtkGS * gs)
   //GdkColormap *colormap;
   GdkGC *fill;
   GdkColor white = { 0, 0xFFFF, 0xFFFF, 0xFFFF };   /* pixel, r, g, b */
+  GdkColormap *colormap;
 
 #ifdef HAVE_LOCALE_H
   char *savelocale;
@@ -518,6 +519,8 @@ set_up_page(GtkGS * gs)
     /* clear new pixmap (set to white) */
     fill = gdk_gc_new(gs->pstarget);
     if(fill) {
+      colormap = gdk_drawable_get_colormap(gs->pstarget);
+      gdk_color_alloc (colormap, &white);
       gdk_gc_set_foreground(fill, &white);
 
       if(gs->width > 0 && gs->height > 0) {
@@ -2089,13 +2092,42 @@ ps_document_get_page (EvDocument  *document)
        return gtk_gs_get_current_page (GTK_GS (document));
 }
 
+static gboolean
+gtk_gs_widget_event (GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+       GtkGS *gs = (GtkGS *) data;
+
+       if(event->type != GDK_CLIENT_EVENT)
+               return FALSE;
+
+       if (event->client.message_type == gs_class->page_atom) {
+               gs->busy = FALSE;
+               ev_document_changed (EV_DOCUMENT (gs));
+       }
+
+       return TRUE;
+}
+
 static void
 ps_document_set_target (EvDocument  *document,
-                        GdkDrawable *target)
+                       GdkDrawable *target)
 {
        GtkGS *gs = GTK_GS (document);
+       GtkWidget *widget;
+       gpointer data;
 
        gs->pstarget = target;
+
+       if (gs->pstarget) {
+               gdk_window_get_user_data (gs->pstarget, &data);
+               g_return_if_fail (GTK_IS_WIDGET (data));
+
+               widget = GTK_WIDGET (data);
+               g_signal_connect (widget, "event",
+                                 G_CALLBACK (gtk_gs_widget_event),
+                                 document);
+       }
+
        gtk_gs_goto_page (gs, gs->current_page);
 }
 
index 07fdecd86c5a243b158b48ee8555956d4cfbba95..bde7d33d6b140da9b46e208878dfbd126f2e5263 100644 (file)
@@ -596,6 +596,13 @@ ev_view_new (void)
        return g_object_new (EV_TYPE_VIEW, NULL);
 }
 
+static void
+document_changed_callback (EvDocument *document,
+                          EvView     *view)
+{
+       gtk_widget_queue_draw (GTK_WIDGET (view));
+}
+
 void
 ev_view_set_document (EvView     *view,
                      EvDocument *document)
@@ -624,6 +631,10 @@ ev_view_set_document (EvView     *view,
                                           "found",
                                           G_CALLBACK (found_results_callback),
                                           view);
+                       g_signal_connect (view->document,
+                                         "changed",
+                                         G_CALLBACK (document_changed_callback),
+                                         view);
                 }
 
                if (GTK_WIDGET_REALIZED (view))
@@ -648,9 +659,7 @@ ev_view_set_page (EvView *view,
                        g_signal_emit (view, page_changed_signal, 0);
 
                        view->find_percent_complete = 0.0;
-                       update_find_results (view);
-                       
-                       gtk_widget_queue_draw (GTK_WIDGET (view));
+                       update_find_results (view);     
                }
        }
 }