[Nautilus-list] Redrawing rows in the eel-image-chooser
- From: Owen Taylor <otaylor redhat com>
- To: nautilus-list eazel com
- Subject: [Nautilus-list] Redrawing rows in the eel-image-chooser
- Date: 03 Aug 2001 10:15:08 -0400
While testing my patch from yesterday, I noticed an annoying behavior,
where when switching themes, half of a row would be redrawn,
it would pause to load the icons, then the other half of the row
would be drawn. The effect is fairly disconcerting.
The following patch flushes the X drawing queue before emitting the
SELECTION_CHANGED signal on the ImageChooser widget to prevent this.
It's possible that it would be better to do the XFlush() in the
code that switches themes, rather than here, since the code
that switches themes _knows_ that it is about to do a slow
synchronous operation.
The use of XFlush() rather than gdk_flush() is because gdk_flush(),
despite the name, really does an XSync(), which is a more expensive
operation than we need here. XFlush() is a pretty cheap operation,
so doing it very unlikely to hurt, XSync() could occasionally take a
fair bit of time.
(Right before where I inserted this, there is a call to
gtk_widget_queue_draw() on the image chooser, which I don't
understand the reason for and may have been a failed attempt to
fix the same problem. Or it might be there for some other reason.
In general, if I was rewriting this widget, I would rewrite it
to do _all_ it's drawing out of its expose handler,
gtk_widget_queue_draw_area() on the areas that change, and
and call gtk_widget_draw() if things needed to be updated
immediately. In GTK+-2.0, you'd optimally do that with
gdk_window_invalidate_rect(), gdk_window_process_updates()
Redrawing in response to updates, as the widget does now, tends
to be a headache, since you _also_ need to have all the same
code to redraw in response to expose events.)
Regards,
Owen
--- eel-1.0.1/eel/eel-image-chooser.c.iconflash Fri Aug 3 10:00:16 2001
+++ eel-1.0.1/eel/eel-image-chooser.c Fri Aug 3 10:02:09 2001
@@ -34,6 +34,7 @@
#include "eel-label.h"
#include "eel-region.h"
#include "eel-viewport.h"
+#include <gdk/gdkx.h>
#include <gtk/gtkclist.h>
#include <gtk/gtkclist.h>
#include <gtk/gtkhbox.h>
@@ -939,6 +940,13 @@
GTK_WIDGET (image_chooser->details->scrolled_window));
}
#endif
+
+ /* The action taken on selecting a row may be expensive, so we
+ * flush pending draw commands to make sure that we don't
+ * end up waiting around with only half of a row drawn.
+ */
+
+ XFlush (GDK_DISPLAY ());
gtk_signal_emit (GTK_OBJECT (image_chooser), image_chooser_signals[SELECTION_CHANGED]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]