From 456c0769c5dccb2c8ce312031219624e6edddc5c Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sat, 1 Oct 2005 21:10:56 +0000 Subject: Don't spin unmapped spinners. Slightly decrease the frequency. Might help 2005-10-01 Christian Persch * lib/widgets/ephy-spinner.c: (ephy_spinner_init), (ephy_spinner_start), (ephy_spinner_stop), (ephy_spinner_map), (ephy_spinner_unmap), (ephy_spinner_class_init): Don't spin unmapped spinners. Slightly decrease the frequency. Might help with bug #315232. --- ChangeLog | 9 +++++++++ lib/widgets/ephy-spinner.c | 49 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 70629331b..9576b67dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-10-01 Christian Persch + + * lib/widgets/ephy-spinner.c: (ephy_spinner_init), + (ephy_spinner_start), (ephy_spinner_stop), (ephy_spinner_map), + (ephy_spinner_unmap), (ephy_spinner_class_init): + + Don't spin unmapped spinners. Slightly decrease the frequency. + Might help with bug #315232. + 2005-10-01 Christian Persch * lib/widgets/ephy-location-entry.c: (entry_key_press_cb): diff --git a/lib/widgets/ephy-spinner.c b/lib/widgets/ephy-spinner.c index 1ad7f442b..34876cf95 100644 --- a/lib/widgets/ephy-spinner.c +++ b/lib/widgets/ephy-spinner.c @@ -449,7 +449,7 @@ ephy_spinner_cache_ref (void) /* Spinner implementation */ -#define SPINNER_TIMEOUT 100 /* Milliseconds Per Frame */ +#define SPINNER_TIMEOUT 125 /* ms */ #define EPHY_SPINNER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_SPINNER, EphySpinnerDetails)) @@ -461,6 +461,7 @@ struct _EphySpinnerDetails EphySpinnerImages *images; GList *current_image; guint timer_task; + guint spinning : 1; }; static void ephy_spinner_class_init (EphySpinnerClass *class); @@ -549,8 +550,9 @@ ephy_spinner_init (EphySpinner *spinner) spinner->details->cache = ephy_spinner_cache_ref (); spinner->details->size = GTK_ICON_SIZE_INVALID; + spinner->details->spinning = FALSE; - /* FIXME: icon theme is per-screen, not global */ + /* FIXME: multihead */ spinner->details->icon_theme = gtk_icon_theme_get_default (); g_signal_connect (spinner->details->icon_theme, "changed", G_CALLBACK (icon_theme_changed_cb), spinner); @@ -676,7 +678,12 @@ bump_spinner_frame_cb (EphySpinner *spinner) void ephy_spinner_start (EphySpinner *spinner) { - if (spinner->details->timer_task == 0) + EphySpinnerDetails *details = spinner->details; + + details->spinning = TRUE; + + if (GTK_WIDGET_MAPPED (GTK_WIDGET (spinner)) && + details->timer_task == 0) { if (spinner->details->images != NULL) @@ -712,10 +719,18 @@ ephy_spinner_remove_update_callback (EphySpinner *spinner) void ephy_spinner_stop (EphySpinner *spinner) { + EphySpinnerDetails *details = spinner->details; + + details->spinning = FALSE; + if (spinner->details->timer_task != 0) { ephy_spinner_remove_update_callback (spinner); - gtk_widget_queue_draw (GTK_WIDGET (spinner)); + + if (GTK_WIDGET_MAPPED (GTK_WIDGET (spinner))) + { + gtk_widget_queue_draw (GTK_WIDGET (spinner)); + } } } @@ -768,6 +783,30 @@ ephy_spinner_size_request (GtkWidget *widget, } } +static void +ephy_spinner_map (GtkWidget *widget) +{ + EphySpinner *spinner = EPHY_SPINNER (widget); + EphySpinnerDetails *details = spinner->details; + + GTK_WIDGET_CLASS (parent_class)->map (widget); + + if (details->spinning) + { + ephy_spinner_start (spinner); + } +} + +static void +ephy_spinner_unmap (GtkWidget *widget) +{ + EphySpinner *spinner = EPHY_SPINNER (widget); + + ephy_spinner_remove_update_callback (spinner); + + GTK_WIDGET_CLASS (parent_class)->unmap (widget); +} + static void ephy_spinner_finalize (GObject *object) { @@ -797,6 +836,8 @@ ephy_spinner_class_init (EphySpinnerClass *class) widget_class->expose_event = ephy_spinner_expose; widget_class->size_request = ephy_spinner_size_request; + widget_class->map = ephy_spinner_map; + widget_class->unmap = ephy_spinner_unmap; g_type_class_add_private (object_class, sizeof (EphySpinnerDetails)); } -- cgit v1.2.3