[Nautilus-list] [PATCH] Speedier selection for nautilus
- From: Manuel Clos <llanero jazzfree com>
- To: Nautilus <nautilus-list lists eazel com>
- Subject: [Nautilus-list] [PATCH] Speedier selection for nautilus
- Date: Tue, 08 Jan 2002 03:32:52 +0100
Hi all,
after playing with the code to see how it works, I changed the
rubberband to be four single lines instead of a rectangle.
I also tried using a single line forming a rectangle but it was slower
than using four single lines (!).
Anyway I post this simple patch to the list. It is not meant to be
included in nautilus. It is only to show that drawing simple lines is
faster than the full rubberband. All in all, it is also a bit slow, and
it does not follow the mouse as fast as it should.
If you draw a big rectangle with the mouse and the move the mouse in a
little circle to see how fast it is redrawn, you can see that doing the
little circle movement over an icon is slower than doing it without an
icon under the mouse, perhaps this is due to:
- the icons redrawing very slow
- the calculation of the intersections
I will try to look into this.
I also tried modifing the rubberband callback timeout but it seems to be
greatly tuned :)
Darin said that the optimization of drawing only the changed parts is in
libgnomecanvas for gnome2.
Is it better to look at nautilus for gnome2 since working in
libgnomecanvas (gnome 1) is dead anyway?
I can clean the patch if people feel it will be good to have this as an
option under "perfomance" preferences, or just even through gconf.
--
Manuel Clos
llanero jazzfree com
* Si no puedes hacerlo bien, hazlo bonito (Bill Gates)
* If you can't do it well, do it nice (Bill Gates)
--- nautilus-icon-container.c.orig Tue Jan 8 02:55:27 2002
+++ nautilus-icon-container.c Tue Jan 8 03:12:49 2002
@@ -1428,6 +1428,7 @@
double world_x, world_y;
int x_scroll, y_scroll;
ArtDRect selection_rect;
+ int i;
widget = GTK_WIDGET (data);
container = NAUTILUS_ICON_CONTAINER (data);
@@ -1492,11 +1493,37 @@
x2 = MAX (x1 + 1, x2);
y2 = MAX (y1 + 1, y2);
+/*
gnome_canvas_item_set
(band_info->selection_rectangle,
"x1", x1, "y1", y1,
"x2", x2, "y2", y2,
NULL);
+*/
+
+ /* top line */
+ band_info->points[0]->coords[0] = x1;
+ band_info->points[0]->coords[1] = y1;
+ band_info->points[0]->coords[2] = x2;
+ band_info->points[0]->coords[3] = y1;
+
+ /* right line */
+ band_info->points[1]->coords[0] = x2;
+ band_info->points[1]->coords[1] = y1;
+ band_info->points[1]->coords[2] = x2;
+ band_info->points[1]->coords[3] = y2;
+
+ /* bottom line */
+ band_info->points[2]->coords[0] = x1;
+ band_info->points[2]->coords[1] = y2;
+ band_info->points[2]->coords[2] = x2;
+ band_info->points[2]->coords[3] = y2;
+
+ /* left line */
+ band_info->points[3]->coords[0] = x1;
+ band_info->points[3]->coords[1] = y1;
+ band_info->points[3]->coords[2] = x1;
+ band_info->points[3]->coords[3] = y2;
selection_rect.x0 = x1;
selection_rect.y0 = y1;
@@ -1507,6 +1534,16 @@
&band_info->prev_rect,
&selection_rect);
+ for (i = 0; i < 4; i++)
+ {
+ gnome_canvas_item_set
+ (band_info->selection_line[i],
+ "points", band_info->points[i],
+ NULL);
+
+ gnome_canvas_item_raise_to_top (band_info->selection_line[i]);
+ }
+
gnome_canvas_item_raise_to_top (band_info->selection_rectangle);
@@ -1527,6 +1564,7 @@
uint fill_color, outline_color;
char *fill_color_str;
GList *p;
+ int i;
details = container->details;
band_info = &details->rubberband_info;
@@ -1574,7 +1612,24 @@
"outline_color_rgba", outline_color,
"width_pixels", 1,
NULL);
-
+
+ for (i = 0; i < 4; i++)
+ {
+ band_info->points[i] = gnome_canvas_points_new (2);
+ band_info->points[i]->coords[0] = band_info->start_x;
+ band_info->points[i]->coords[1] = band_info->start_y;
+ band_info->points[i]->coords[2] = band_info->start_x;
+ band_info->points[i]->coords[3] = band_info->start_y;
+
+ band_info->selection_line[i] = gnome_canvas_item_new
+ (gnome_canvas_root(GNOME_CANVAS(container)),
+ gnome_canvas_line_get_type (),
+ "points", band_info->points[i],
+ "fill_color", "black",
+ "width_pixels", 1,
+ NULL);
+ }
+
} else {
fill_color_str = nautilus_theme_get_theme_data ("directory", "selection_box_color");
if (fill_color_str == NULL) {
@@ -1594,6 +1649,24 @@
"outline_color", fill_color_str,
"width_pixels", 1,
NULL);
+
+ for (i = 0; i < 4; i++)
+ {
+ band_info->points[i] = gnome_canvas_points_new (2);
+ band_info->points[i]->coords[0] = band_info->start_x;
+ band_info->points[i]->coords[1] = band_info->start_y;
+ band_info->points[i]->coords[2] = band_info->start_x;
+ band_info->points[i]->coords[3] = band_info->start_y;
+
+ band_info->selection_line[i] = gnome_canvas_item_new
+ (gnome_canvas_root(GNOME_CANVAS(container)),
+ gnome_canvas_line_get_type (),
+ "points", band_info->points[i],
+ "fill_color", "black",
+ "width_pixels", 1,
+ NULL);
+ }
+
g_free (fill_color_str);
}
@@ -1609,7 +1682,8 @@
container);
}
- gnome_canvas_item_grab (band_info->selection_rectangle,
+// gnome_canvas_item_grab (band_info->selection_rectangle,
+ gnome_canvas_item_grab (band_info->selection_line[0],
(GDK_POINTER_MOTION_MASK
| GDK_BUTTON_RELEASE_MASK),
NULL, event->time);
@@ -1630,10 +1704,18 @@
band_info->active = FALSE;
/* Destroy this canvas item; the parent will unref it. */
- gnome_canvas_item_ungrab (band_info->selection_rectangle, event->time);
+// gnome_canvas_item_ungrab (band_info->selection_rectangle, event->time);
+ gnome_canvas_item_ungrab (band_info->selection_line[0], event->time);
gtk_object_destroy (GTK_OBJECT (band_info->selection_rectangle));
band_info->selection_rectangle = NULL;
-
+ gtk_object_destroy (GTK_OBJECT (band_info->selection_line[0]));
+ gtk_object_destroy (GTK_OBJECT (band_info->selection_line[1]));
+ gtk_object_destroy (GTK_OBJECT (band_info->selection_line[2]));
+ gtk_object_destroy (GTK_OBJECT (band_info->selection_line[3]));
+ band_info->selection_line[0] = NULL;
+ band_info->selection_line[1] = NULL;
+ band_info->selection_line[2] = NULL;
+ band_info->selection_line[3] = NULL;
gtk_signal_emit (GTK_OBJECT (container),
signals[BAND_SELECT_ENDED]);
--- nautilus-icon-private.h.orig Tue Jan 8 02:55:41 2002
+++ nautilus-icon-private.h Mon Jan 7 17:13:29 2002
@@ -27,6 +27,7 @@
#include "nautilus-entry.h"
#include <eel/eel-glib-extensions.h>
+#include <libgnomeui/gnome-canvas-util.h>
#include "nautilus-icon-container.h"
#include "nautilus-icon-dnd.h"
#include "nautilus-icon-factory.h"
@@ -64,6 +65,9 @@
double start_x, start_y;
GnomeCanvasItem *selection_rectangle;
+
+ GnomeCanvasPoints *points[4];
+ GnomeCanvasItem *selection_line[4];
guint timer_id;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]