+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.
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)
{
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
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);
+}
{
GTypeInterface base_iface;
+ /* Signals */
+ void (* changed) (EvDocument *document);
+
/* Methods */
gboolean (* load) (EvDocument *document,
const char *uri,
int clip_y,
int clip_width,
int clip_height);
+void ev_document_changed (EvDocument *document);
G_END_DECLS
pdf_document->page_valid = FALSE;
}
+ ev_document_changed (document);
}
static int
//GdkColormap *colormap;
GdkGC *fill;
GdkColor white = { 0, 0xFFFF, 0xFFFF, 0xFFFF }; /* pixel, r, g, b */
+ GdkColormap *colormap;
#ifdef HAVE_LOCALE_H
char *savelocale;
/* 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) {
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);
}
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)
"found",
G_CALLBACK (found_results_callback),
view);
+ g_signal_connect (view->document,
+ "changed",
+ G_CALLBACK (document_changed_callback),
+ view);
}
if (GTK_WIDGET_REALIZED (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);
}
}
}