static EphySpinnerImages * ephy_spinner_images_load (GdkScreen *screen, GtkIconTheme *icon_theme, GtkIconSize icon_size) { EphySpinnerImages *images; GdkPixbuf *icon_pixbuf, *pixbuf; GtkIconInfo *icon_info = NULL; int grid_width, grid_height, x, y, requested_size, size, isw, ish, n; const char *icon; GSList *list = NULL, *l; LOG ("EphySpinnerCacheData loading for screen %p at size %d", screen, icon_size); START_PROFILER ("loading spinner animation") if (!gtk_icon_size_lookup_for_settings (gtk_settings_get_for_screen (screen), icon_size, &isw, &ish)) goto loser; requested_size = MAX (ish, isw); /* 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"); /* If the icon naming spec compliant name wasn't found, try the old name */ icon_info = gtk_icon_theme_lookup_icon (icon_theme, SPINNER_FALLBACK_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); if (icon == NULL) goto loser; icon_pixbuf = gdk_pixbuf_new_from_file (icon, NULL); gtk_icon_info_free (icon_info); icon_info = NULL; if (icon_pixbuf == NULL) { g_warning ("Could not load the spinner file"); goto loser; } grid_width = gdk_pixbuf_get_width (icon_pixbuf); grid_height = gdk_pixbuf_get_height (icon_pixbuf); n = 0; for (y = 0; y < grid_height; y += size) { for (x = 0; x < grid_width ; x += size) { pixbuf = extract_frame (icon_pixbuf, x, y, size); if (pixbuf) { list = g_slist_prepend (list, pixbuf); ++n; } else { g_warning ("Cannot extract frame (%d, %d) from the grid\n", x, y); } } } g_object_unref (icon_pixbuf); if (list == NULL) goto loser; g_assert (n > 0); if (size > requested_size) { for (l = list; l != NULL; l = l->next) { l->data = scale_to_size (l->data, isw, ish); } } /* Now we've successfully got all the data */ images = g_new (EphySpinnerImages, 1); images->ref_count = 1; images->size = icon_size; images->width = images->height = requested_size; 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); g_slist_free (list); STOP_PROFILER ("loading spinner animation") return images; loser: if (icon_info) { gtk_icon_info_free (icon_info); } g_slist_foreach (list, (GFunc) g_object_unref, NULL); STOP_PROFILER ("loading spinner animation") return NULL; }
static VALUE rg_base_size(VALUE self) { return INT2NUM(gtk_icon_info_get_base_size(_SELF(self))); }