|
From: Gustavo J. A. M. C. <gu...@us...> - 2002-04-20 16:06:55
|
Update of /cvsroot/numexp/gnumexp/src/nxplot
In directory usw-pr-cvs1:/tmp/cvs-serv5352
Modified Files:
nxpcanvas.c nxpcanvas.h
Log Message:
Created new function nxp_canvas_queue_update();
Call nxp_canvas_queue_update() inside nxp_canvas_add_object().
Index: nxpcanvas.c
===================================================================
RCS file: /cvsroot/numexp/gnumexp/src/nxplot/nxpcanvas.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -U4 -r1.13 -r1.14
--- nxpcanvas.c 13 Apr 2002 16:09:09 -0000 1.13
+++ nxpcanvas.c 20 Apr 2002 16:06:52 -0000 1.14
@@ -9,8 +9,12 @@
PROP_PLOTTER
};
+#define NXP_CANVAS_OVERLAY_PRIORITY G_PRIORITY_LOW
+#define NXP_CANVAS_UPDATE_PRIORITY (GTK_PRIORITY_RESIZE + 1)
+
+
/* static guint signals[LAST_SIGNAL] = { 0 }; */
static NxpCanvasClass *nxp_canvas_class = NULL;
static gpointer parent_class = NULL;
@@ -132,8 +136,10 @@
GTK_WIDGET_SET_FLAGS(GTK_WIDGET(self), GTK_CAN_FOCUS);
GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(self), GTK_DOUBLE_BUFFERED);
self->root = NULL;
+ self->overlay_idle_id = 0;
+ self->update_idle_id = 0;
}
static void nxp_canvas_class_base_init(NxpCanvasClass *class)
{
@@ -174,11 +180,18 @@
if (self->update_sigid) {
g_signal_handler_disconnect(self->plotter, self->update_sigid);
self->update_sigid = 0;
}
+ /* remove overlay drawing idle function */
if (self->overlay_idle_id)
gtk_idle_remove(self->overlay_idle_id);
self->overlay_idle_id = 0;
+
+ /* remove update idle function */
+ if (self->update_idle_id)
+ gtk_idle_remove(self->update_idle_id);
+ self->update_idle_id = 0;
+
/* delete plotter */
if (self->plotter)
g_object_unref(self->plotter);
self->plotter = NULL;
@@ -218,8 +231,13 @@
g_return_if_fail(NXP_IS_CANVAS(self));
g_return_if_fail(IS_NXPLOT(pl));
g_return_if_fail(pl == self->plotter);
+ /* remove update idle function */
+ if (self->update_idle_id)
+ gtk_idle_remove(self->update_idle_id);
+ self->update_idle_id = 0;
+
/* Make sure all overlays are hidden, carefully so that do not try
to hide themselves (they would only end up drawing
themselves). */
for (l = self->overlays; l; l = l->next) {
@@ -334,8 +352,28 @@
g_slist_length(self->drawable_objects));
}
+static gboolean _nxp_canvas_update_idle_func(NxpCanvas *self)
+{
+ g_return_val_if_fail(NXP_IS_CANVAS(self), FALSE);
+ self->update_idle_id = 0;
+ if (self->plotter)
+ nxp_canvas_update(self->plotter, self);
+ return FALSE;
+}
+
+
+void nxp_canvas_queue_update(NxpCanvas *self)
+{
+ if (!self->update_idle_id)
+ self->update_idle_id =
+ gtk_idle_add_priority(NXP_CANVAS_UPDATE_PRIORITY,
+ (GtkFunction) _nxp_canvas_update_idle_func,
+ self);
+}
+
+
void nxp_canvas_add_object(NxpCanvas *self, NxpCanvasObject *object)
{
g_return_if_fail(NXP_IS_CANVAS(self));
g_return_if_fail(NXP_IS_CANVAS_OBJECT(object));
@@ -348,8 +386,9 @@
if (self->plotter)
nxplot_close(self->plotter);
recompute_drawable_objects_list(self);
+ nxp_canvas_queue_update(self);
}
static gint button_press_event(GtkWidget *widget, GdkEventButton *event)
@@ -547,9 +586,8 @@
g_return_if_fail(self->xor_gc);
nxp_canvas_overlay_draw(overlay, GTK_WIDGET(self)->window, self->xor_gc, 0);
}
-#define NXP_CANVAS_OVERLAY_PRIORITY G_PRIORITY_LOW
void nxp_canvas_queue_draw_overlay(NxpCanvas *self, NxpCanvasOverlay *overlay,
gboolean generate_expose)
{
Index: nxpcanvas.h
===================================================================
RCS file: /cvsroot/numexp/gnumexp/src/nxplot/nxpcanvas.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -U4 -r1.9 -r1.10
--- nxpcanvas.h 25 Mar 2002 23:13:30 -0000 1.9
+++ nxpcanvas.h 20 Apr 2002 16:06:52 -0000 1.10
@@ -40,8 +40,9 @@
GSList *overlays;
GdkGC *xor_gc;
gulong update_sigid;
guint overlay_idle_id;
+ guint update_idle_id;
GdkCursor *current_cursor;
};
@@ -67,16 +68,18 @@
double y2);
void nxp_canvas_add_object (NxpCanvas *self,
NxpCanvasObject *object);
+
/* overlay management */
void nxp_canvas_add_overlay (NxpCanvas *self,
NxpCanvasOverlay *overlay);
void nxp_canvas_remove_overlay (NxpCanvas *self,
NxpCanvasOverlay *overlay);
void nxp_canvas_draw_overlay (NxpCanvas *self,
NxpCanvasOverlay *overlay);
+
/* */
void nxp_canvas_redraw_area (NxpCanvas *self,
NxplotRect *area);
void nxp_canvas_set_cursor (NxpCanvas *self,
@@ -84,8 +87,9 @@
void nxp_canvas_get_pointer (NxpCanvas *self,
gint *x,
gint *y,
GdkModifierType *state);
+void nxp_canvas_queue_update (NxpCanvas *self);
|