summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArik Devens <arik@src.gnome.org>2001-02-26 10:00:16 +0000
committerArik Devens <arik@src.gnome.org>2001-02-26 10:00:16 +0000
commit03dfe78ed9ab00dd9685fce4358d2acd1fe7833f (patch)
treea73188efa5a3c9eee942722ea719924e01bdfcb6
parent8b9ea85e5fffff9c67d2203219eec2634783bb2d (diff)
downloadnautilus-03dfe78ed9ab00dd9685fce4358d2acd1fe7833f.tar.gz
Partial fix for bug 5701. Moved icon stretching to an idle handler to both speed it up a bit and stop it from growing then freezing then jumping to a new size. Will do more after 1.0.
-rw-r--r--ChangeLog14
-rw-r--r--libnautilus-extensions/nautilus-icon-container.c33
-rw-r--r--libnautilus-extensions/nautilus-icon-private.h7
-rw-r--r--libnautilus-private/nautilus-icon-container.c33
-rw-r--r--libnautilus-private/nautilus-icon-private.h7
5 files changed, 84 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 776093467..03df803b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2001-02-26 Arik Devens <arik@eazel.com>
+
+ reviewed by: John Harper <jsh@eazel.com
+
+ Partial fix for bug 5701, Icon stretching is slow and
+ CPU-intensive.
+
+ * libnautilus-extensions/nautilus-icon-container.c:
+ (update_stretch_at_idle), (continue_stretching): Moved the
+ stretching code to an idle handler to speed it up and remove
+ blocking.
+ * libnautilus-extensions/nautilus-icon-private.h: Added three new
+ members to the IconContainerDetails struct for the idle handler.
+
2001-02-26 Dan Mueth <dan@eazel.com>
reviewed by: Maciej Stachowiak <mjs@eazel.com>
diff --git a/libnautilus-extensions/nautilus-icon-container.c b/libnautilus-extensions/nautilus-icon-container.c
index a9e8ecba3..45f3d159a 100644
--- a/libnautilus-extensions/nautilus-icon-container.c
+++ b/libnautilus-extensions/nautilus-icon-container.c
@@ -2287,6 +2287,10 @@ destroy (GtkObject *object)
if (container->details->idle_id != 0) {
gtk_idle_remove (container->details->idle_id);
}
+
+ if (container->details->stretch_idle_id != 0) {
+ gtk_idle_remove (container->details->stretch_idle_id);
+ }
for (i = 0; i < NAUTILUS_N_ELEMENTS (container->details->label_font); i++) {
if (container->details->label_font[i] != NULL)
@@ -2596,9 +2600,8 @@ start_stretching (NautilusIconContainer *container)
return TRUE;
}
-static void
-continue_stretching (NautilusIconContainer *container,
- int window_x, int window_y)
+static gboolean
+update_stretch_at_idle (NautilusIconContainer *container)
{
NautilusIconContainerDetails *details;
NautilusIcon *icon;
@@ -2609,11 +2612,12 @@ continue_stretching (NautilusIconContainer *container,
icon = details->stretch_icon;
if (icon == NULL) {
- return;
+ container->details->stretch_idle_id = 0;
+ return FALSE;
}
gnome_canvas_window_to_world (GNOME_CANVAS (container),
- window_x, window_y,
+ details->window_x, details->window_y,
&world_x, &world_y);
gnome_canvas_w2c (GNOME_CANVAS (container),
world_x, world_y,
@@ -2628,6 +2632,25 @@ continue_stretching (NautilusIconContainer *container,
icon_set_position (icon, world_x, world_y);
icon_set_size (container, icon, stretch_state.icon_size, FALSE);
+
+ container->details->stretch_idle_id = 0;
+
+ return FALSE;
+}
+
+static void
+continue_stretching (NautilusIconContainer *container,
+ int window_x, int window_y)
+{
+
+ g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
+
+ container->details->window_x = window_x;
+ container->details->window_y = window_y;
+
+ if (container->details->stretch_idle_id == 0) {
+ container->details->stretch_idle_id = gtk_idle_add ((GtkFunction) update_stretch_at_idle, container);
+ }
}
static void
diff --git a/libnautilus-extensions/nautilus-icon-private.h b/libnautilus-extensions/nautilus-icon-private.h
index 82657b481..a13e5bd68 100644
--- a/libnautilus-extensions/nautilus-icon-private.h
+++ b/libnautilus-extensions/nautilus-icon-private.h
@@ -157,6 +157,9 @@ struct NautilusIconContainerDetails {
/* Idle ID. */
guint idle_id;
+ /* Idle handler for stretch code */
+ guint stretch_idle_id;
+
/* Timeout for selection in browser mode. */
guint linger_selection_mode_timer_id;
@@ -206,6 +209,10 @@ struct NautilusIconContainerDetails {
/* Ignore the visible area the next time the scroll region is recomputed */
gboolean reset_scroll_region_trigger;
+
+ /* The position we are scaling to on stretch */
+ int window_x;
+ int window_y;
};
/* Private functions shared by mutiple files. */
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index a9e8ecba3..45f3d159a 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -2287,6 +2287,10 @@ destroy (GtkObject *object)
if (container->details->idle_id != 0) {
gtk_idle_remove (container->details->idle_id);
}
+
+ if (container->details->stretch_idle_id != 0) {
+ gtk_idle_remove (container->details->stretch_idle_id);
+ }
for (i = 0; i < NAUTILUS_N_ELEMENTS (container->details->label_font); i++) {
if (container->details->label_font[i] != NULL)
@@ -2596,9 +2600,8 @@ start_stretching (NautilusIconContainer *container)
return TRUE;
}
-static void
-continue_stretching (NautilusIconContainer *container,
- int window_x, int window_y)
+static gboolean
+update_stretch_at_idle (NautilusIconContainer *container)
{
NautilusIconContainerDetails *details;
NautilusIcon *icon;
@@ -2609,11 +2612,12 @@ continue_stretching (NautilusIconContainer *container,
icon = details->stretch_icon;
if (icon == NULL) {
- return;
+ container->details->stretch_idle_id = 0;
+ return FALSE;
}
gnome_canvas_window_to_world (GNOME_CANVAS (container),
- window_x, window_y,
+ details->window_x, details->window_y,
&world_x, &world_y);
gnome_canvas_w2c (GNOME_CANVAS (container),
world_x, world_y,
@@ -2628,6 +2632,25 @@ continue_stretching (NautilusIconContainer *container,
icon_set_position (icon, world_x, world_y);
icon_set_size (container, icon, stretch_state.icon_size, FALSE);
+
+ container->details->stretch_idle_id = 0;
+
+ return FALSE;
+}
+
+static void
+continue_stretching (NautilusIconContainer *container,
+ int window_x, int window_y)
+{
+
+ g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
+
+ container->details->window_x = window_x;
+ container->details->window_y = window_y;
+
+ if (container->details->stretch_idle_id == 0) {
+ container->details->stretch_idle_id = gtk_idle_add ((GtkFunction) update_stretch_at_idle, container);
+ }
}
static void
diff --git a/libnautilus-private/nautilus-icon-private.h b/libnautilus-private/nautilus-icon-private.h
index 82657b481..a13e5bd68 100644
--- a/libnautilus-private/nautilus-icon-private.h
+++ b/libnautilus-private/nautilus-icon-private.h
@@ -157,6 +157,9 @@ struct NautilusIconContainerDetails {
/* Idle ID. */
guint idle_id;
+ /* Idle handler for stretch code */
+ guint stretch_idle_id;
+
/* Timeout for selection in browser mode. */
guint linger_selection_mode_timer_id;
@@ -206,6 +209,10 @@ struct NautilusIconContainerDetails {
/* Ignore the visible area the next time the scroll region is recomputed */
gboolean reset_scroll_region_trigger;
+
+ /* The position we are scaling to on stretch */
+ int window_x;
+ int window_y;
};
/* Private functions shared by mutiple files. */