From e70df82868d7b3a6f17a1ebcedc54b2175749504 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Mon, 4 Dec 2006 22:10:40 +0000 Subject: Version 2.17.3. 2006-12-04 Christian Persch * configure.ac: Version 2.17.3. * embed/mozilla/GtkNSSDialogs.cpp: Use NULL for gtk_label_new instead of "". * lib/ephy-print-utils.c: (ephy_print_utils_page_setup_new_from_key_file): Fix possible invalid free. * lib/widgets/ephy-spinner.c: (ephy_spinner_images_unref), (ephy_spinner_images_load), (ephy_spinner_load_images), (ephy_spinner_expose), (bump_spinner_frame_cb), (ephy_spinner_start), (ephy_spinner_stop): Fix compliance with icon theme spec by skipping the first frame in the animation when in spinning mode. Bug #382207. Try the "process-working" icon first and fall back to "gnome-spinner" when it's not available. * m4/gecko.m4: Updated. 2006-12-04 Luca Ferretti --- lib/widgets/ephy-spinner.c | 88 +++++++++++++++------------------------------- 1 file changed, 28 insertions(+), 60 deletions(-) (limited to 'lib/widgets/ephy-spinner.c') diff --git a/lib/widgets/ephy-spinner.c b/lib/widgets/ephy-spinner.c index dcb0e0ab6..f1c17b763 100644 --- a/lib/widgets/ephy-spinner.c +++ b/lib/widgets/ephy-spinner.c @@ -76,14 +76,13 @@ typedef struct GtkIconSize size; int width; int height; - GdkPixbuf *quiescent_pixbuf; GdkPixbuf **animation_pixbufs; guint n_animation_pixbufs; } EphySpinnerImages; #define LAST_ICON_SIZE GTK_ICON_SIZE_DIALOG + 1 -#define SPINNER_ICON_NAME "gnome-spinner" -#define SPINNER_REST_ICON_NAME "gnome-spinner-rest" +#define SPINNER_ICON_NAME "process-working" +#define SPINNER_FALLBAC_ICON_NAME "gnome-spinner" #define EPHY_SPINNER_IMAGES_INVALID ((EphySpinnerImages *) 0x1) typedef struct @@ -154,8 +153,6 @@ ephy_spinner_images_unref (EphySpinnerImages *images) } g_free (images->animation_pixbufs); - g_object_unref (images->quiescent_pixbuf); - g_free (images); } } @@ -234,7 +231,6 @@ ephy_spinner_images_load (GdkScreen *screen, GtkIconSize icon_size) { EphySpinnerImages *images; - GdkPixbuf *rest_pixbuf = NULL; GdkPixbuf *icon_pixbuf, *pixbuf; GtkIconInfo *icon_info = NULL; int grid_width, grid_height, x, y, requested_size, size, isw, ish, n; @@ -250,44 +246,25 @@ ephy_spinner_images_load (GdkScreen *screen, requested_size = MAX (ish, isw); - /* Load the rest icon */ - icon_info = gtk_icon_theme_lookup_icon (icon_theme, - SPINNER_REST_ICON_NAME, - requested_size, 0); - if (icon_info == NULL) - { - g_warning ("Throbber rest icon not found"); - goto loser; - } - - size = gtk_icon_info_get_base_size (icon_info); - icon = gtk_icon_info_get_filename (icon_info); - if (icon == NULL) goto loser; - - rest_pixbuf = gdk_pixbuf_new_from_file (icon, NULL); - gtk_icon_info_free (icon_info); - icon_info = NULL; - - if (rest_pixbuf == NULL) - { - g_warning ("Could not load spinner rest icon"); - goto loser; - } - - if (size > requested_size) - { - rest_pixbuf = scale_to_size (rest_pixbuf, isw, ish); - } - - /* Load the animation */ + /* Load the animation. The 'rest icon' is the 0th frame */ icon_info = gtk_icon_theme_lookup_icon (icon_theme, SPINNER_ICON_NAME, requested_size, 0); if (icon_info == NULL) { g_warning ("Throbber animation not found"); - goto loser; + + /* If the icon naming spec compliant name wasn't found, try the old name */ + icon_info = gtk_icon_theme_lookup_icon (icon_theme, + SPINNER_FALLBAC_ICON_NAME, + requested_size, 0); + if (icon_info == NULL) + { + g_warning ("Throbber fallback animation not found either"); + goto loser; + } } + g_assert (icon_info != NULL); size = gtk_icon_info_get_base_size (icon_info); icon = gtk_icon_info_get_filename (icon_info); @@ -344,13 +321,13 @@ ephy_spinner_images_load (GdkScreen *screen, images->size = icon_size; images->width = images->height = requested_size; - images->quiescent_pixbuf = rest_pixbuf; images->n_animation_pixbufs = n; images->animation_pixbufs = g_new (GdkPixbuf *, n); for (l = list; l != NULL; l = l->next) { + g_assert (l->data != NULL); images->animation_pixbufs[--n] = l->data; } g_assert (n == 0); @@ -366,10 +343,6 @@ loser: { gtk_icon_info_free (icon_info); } - if (rest_pixbuf) - { - g_object_unref (rest_pixbuf); - } g_slist_foreach (list, (GFunc) g_object_unref, NULL); STOP_PROFILER ("loading spinner animation") @@ -591,7 +564,7 @@ ephy_spinner_load_images (EphySpinner *spinner) STOP_PROFILER ("ephy_spinner_load_images") - details->current_image = 0; + details->current_image = 0; /* 'rest' icon */ details->need_load = FALSE; } @@ -666,23 +639,15 @@ ephy_spinner_expose (GtkWidget *widget, return FALSE; } - if (details->spinning && - images->n_animation_pixbufs > 0) - { - g_assert (details->current_image >= 0 && - details->current_image < images->n_animation_pixbufs); + /* Otherwise |images| will be NULL anyway */ + g_assert (images->n_animation_pixbufs > 0); + + g_assert (details->current_image >= 0 && + details->current_image < images->n_animation_pixbufs); - pixbuf = images->animation_pixbufs[details->current_image]; - } - else - { - pixbuf = images->quiescent_pixbuf; - } + pixbuf = images->animation_pixbufs[details->current_image]; - if (pixbuf == NULL) - { - return FALSE; - } + g_assert (pixbuf != NULL); width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); @@ -727,7 +692,8 @@ bump_spinner_frame_cb (EphySpinner *spinner) details->current_image++; if (details->current_image >= details->images->n_animation_pixbufs) { - details->current_image = 0; + /* the 0th frame is the 'rest' icon */ + details->current_image = MIN (1, details->images->n_animation_pixbufs); } gtk_widget_queue_draw (GTK_WIDGET (spinner)); @@ -753,7 +719,8 @@ ephy_spinner_start (EphySpinner *spinner) details->timer_task == 0 && ephy_spinner_load_images (spinner)) { - details->current_image = 0; + /* the 0th frame is the 'rest' icon */ + details->current_image = MIN (1, details->images->n_animation_pixbufs); details->timer_task = g_timeout_add_full (G_PRIORITY_LOW, @@ -788,6 +755,7 @@ ephy_spinner_stop (EphySpinner *spinner) EphySpinnerDetails *details = spinner->details; details->spinning = FALSE; + details->current_image = 0; if (details->timer_task != 0) { -- cgit v1.2.3