void _gtk_icon_helper_get_size (GtkIconHelper *self, GtkStyleContext *context, gint *width_out, gint *height_out) { cairo_surface_t *surface; gint width, height; width = height = 0; surface = _gtk_icon_helper_ensure_surface (self, context); if (surface != NULL) { width = self->priv->rendered_surface_width; height = self->priv->rendered_surface_height; cairo_surface_destroy (surface); } else if (self->priv->storage_type == GTK_IMAGE_ANIMATION) { width = gdk_pixbuf_animation_get_width (self->priv->animation); height = gdk_pixbuf_animation_get_height (self->priv->animation); } else if (self->priv->icon_size != -1) { ensure_icon_size (self, context, &width, &height); } if (width_out) *width_out = width; if (height_out) *height_out = height; }
static void get_icon_scale_size(GdkPixbufAnimation * icon, GaimBuddyIconSpec * spec, int *width, int *height) { *width = gdk_pixbuf_animation_get_width(icon); *height = gdk_pixbuf_animation_get_height(icon); /* this should eventually get smarter about preserving the aspect ratio when scaling, but gimmie a break, I just woke up */ if (spec && spec->scale_rules & GAIM_ICON_SCALE_DISPLAY) { if (*width < spec->min_width) *width = spec->min_width; else if (*width > spec->max_width) *width = spec->max_width; if (*height < spec->min_height) *height = spec->min_height; else if (*height > spec->max_height) *height = spec->max_height; } /* and now for some arbitrary sanity checks */ if (*width > 100) *width = 100; if (*height > 100) *height = 100; }
void _gtk_icon_helper_get_size (GtkIconHelper *self, GtkStyleContext *context, gint *width_out, gint *height_out) { GdkPixbuf *pix; gint width, height; width = height = 0; pix = _gtk_icon_helper_ensure_pixbuf (self, context); if (pix != NULL) { width = gdk_pixbuf_get_width (pix); height = gdk_pixbuf_get_height (pix); g_object_unref (pix); } else if (self->priv->storage_type == GTK_IMAGE_ANIMATION) { width = gdk_pixbuf_animation_get_width (self->priv->animation); height = gdk_pixbuf_animation_get_height (self->priv->animation); } else if (self->priv->icon_size != -1) { ensure_icon_size (self, context, &width, &height); } if (width_out) *width_out = width; if (height_out) *height_out = height; }
static void get_animation_size(GdkPixbufAnimation * animation, int *w, int *h, int *delay) { GList *frames; int iw, ih, n, i, d = -1; frames = gdk_pixbuf_animation_get_frames(animation); n = gdk_pixbuf_animation_get_num_frames(animation); *w = gdk_pixbuf_animation_get_width(animation); *h = gdk_pixbuf_animation_get_height(animation); for (i = 0; i < n; i++) { GdkPixbufFrame *frame; GdkPixbuf *pixbuf; int tmp; frame = (GdkPixbufFrame *) g_list_nth_data(frames, i); tmp = gdk_pixbuf_frame_get_delay_time(frame); if (tmp > d) d = tmp; pixbuf = gdk_pixbuf_frame_get_pixbuf(frame); iw = gdk_pixbuf_frame_get_x_offset(frame) + gdk_pixbuf_get_width(pixbuf); ih = gdk_pixbuf_frame_get_y_offset(frame) + gdk_pixbuf_get_height(pixbuf); if (iw > *w) *w = iw; if (ih > *h) *h = ih; } if (delay) *delay = d; }
wxSize wxAnimationCtrl::DoGetBestSize() const { if (m_anim && !this->HasFlag(wxAC_NO_AUTORESIZE)) { return wxSize(gdk_pixbuf_animation_get_width(m_anim), gdk_pixbuf_animation_get_height(m_anim)); } return wxSize(100,100); }
void wxAnimationCtrl::FitToAnimation() { if (!m_anim) return; int w = gdk_pixbuf_animation_get_width(m_anim), h = gdk_pixbuf_animation_get_height(m_anim); // update our size to fit animation SetSize(w, h); }
GdkPixbufAnimation* pgpug_animated_icon_compose_from_anim_list (GdkPixbufAnimation * anim, ...) { g_return_val_if_fail (anim != NULL, NULL); g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION (anim), NULL); int width, height; width = gdk_pixbuf_animation_get_width (anim); height = gdk_pixbuf_animation_get_height (anim); g_return_val_if_fail (height == width, NULL); va_list anim_p; va_start (anim_p, anim); //get all animation into an array GPtrArray *anim_array = g_ptr_array_new (); animation_param_entry* p_entry = g_malloc0 (sizeof (animation_param_entry)); p_entry->anim = anim; g_ptr_array_add (anim_array, p_entry); gint anim_pos, param_num = 0; anim_pos = va_arg (anim_p, gint); while (anim_pos >= 0){ gpointer ptr = va_arg (anim_p, gpointer); p_entry = g_malloc (sizeof (animation_param_entry)); param_num += 2; if (!GDK_IS_PIXBUF_ANIMATION (ptr)) { WARN_MSG ("pgpug_animated_icon_compose_from_anim_list: var_arg parameter %d expected GdkPixbufAnimation*", param_num); break; } p_entry->anim = GDK_PIXBUF_ANIMATION (ptr); p_entry->pos = anim_pos; g_ptr_array_add (anim_array, p_entry); anim_pos = va_arg (anim_p, gint); } va_end (anim_p); GdkPixbufAnimation *result; result = compose_animation_from_array ((animation_param_entry**)anim_array->pdata, anim_array->len, width); g_ptr_array_foreach (anim_array, (GFunc)g_free, NULL); g_ptr_array_free (anim_array, TRUE); return result; }
static void img_cell_renderer_anim_get_size( GtkCellRenderer *cell, GtkWidget *widget, GdkRectangle *cell_area, gint *x_off, gint *y_off, gint *width, gint *height ) { /* Private data */ ImgCellRendererAnimPrivate *priv; /* Calculated values */ gboolean calc_off; gint w = 0, h = 0; priv = IMG_CELL_RENDERER_ANIM_GET_PRIVATE( cell ); /* Get image size */ if( priv->anim ) { w = gdk_pixbuf_animation_get_width( priv->anim ); h = gdk_pixbuf_animation_get_height( priv->anim ); } calc_off = ( w > 0 && h > 0 ? TRUE : FALSE ); /* Add padding */ w += (gint)cell->xpad * 2; h += (gint)cell->ypad * 2; /* Calculate offsets */ if( cell_area && calc_off ) { if( x_off ) { gboolean dir; dir = ( gtk_widget_get_direction( widget ) == GTK_TEXT_DIR_LTR ); *x_off = ( dir ? cell->xalign : 1.0 - cell->xalign ) * ( cell_area->width - w ); *x_off = MAX( *x_off, 0 ); } if( y_off ) { *y_off = cell->yalign * ( cell_area->height - h ); *y_off = MAX( *y_off, 0 ); } } else { if( x_off ) *y_off = 0; if( y_off ) *y_off = 0; } /* Return dimensions */ if( width ) *width = w; if( height ) *height = h; }
wxSize wxAnimation::GetSize() const { return wxSize(gdk_pixbuf_animation_get_width(m_pixbuf), gdk_pixbuf_animation_get_height(m_pixbuf)); }
int main (int argc, char *argv[]) { if(argc > 1 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "-H"))) { printf("Ponies for Linux/GTK+ by rabbit\n"); printf("Command list:\n"); printf("No Parameters: Run with the settings used from last run\n"); printf("-h: Display this help\n"); printf("file path: Set new file path to look for pony gif files\n"); printf("ponyname: Sets to run one of the pony type listed\n"); return 0; } for(int i = 1; i < argc; i++) if(*argv[i] == '/') setPonyDirectory(argv[i]); char* ponyDirectory = NULL; char* ponyHomeFile = NULL; ponyHomeFile = malloc((strlen(getenv("HOME"))+ 9) * sizeof(char)); if(!ponyHomeFile) { printf("Could not allocate memory for ponyHomeFile\n"); return 0; } strcpy(ponyHomeFile, getenv("HOME")); strcat(ponyHomeFile,"/.ponies"); ponyDirectory = getPonyDirectory(); if(!ponyDirectory) { free(ponyHomeFile); printf("Error locating pony directory\n"); return 0; } //Initialize GTK+ and set up loggers GError* error = NULL; g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, (GLogFunc) gtk_false, NULL); gtk_init (&argc, &argv); g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, g_log_default_handler, NULL); //For command line commands later, require input on inital load //Normally would close, but hard coded in for easier testing int numberOfPonies = 0; if(argc == 1) { //Read in from ~/.ponies file to find saved settings FILE* ifp = NULL; char buffer[256]; ifp = fopen(ponyHomeFile,"r"); if(!ifp) { free(ponyHomeFile); free(ponyDirectory); printf("Could not open file for reading\n"); return 0; } //fread(buffer, sizeof(char), 256, ifp); while(fgets(buffer, 256, ifp)) if(buffer[0] != '\n') numberOfPonies++; fclose(ifp); numberOfPonies--;//First line is directory } //Not default arguments else { for(int i = 1; i < argc; i++) { if(*argv[i] == '/') continue; numberOfPonies++; } } //Seed the randomizer srand(time(0)); //Number of ponies pony ponyArray[numberOfPonies]; char buffer[256]; FILE* ifp = NULL; ifp = fopen(ponyHomeFile,"r"); if(!ifp) { printf("Could not open ~/.ponies\n"); free(ponyDirectory); free(ponyHomeFile); return 0; } fgets(buffer, 256, ifp);//throw away first line //0 Ponies if(!numberOfPonies) { free(ponyDirectory); free(ponyHomeFile); printf("No ponies in the ~/.ponies file! Add some ponies!\n"); printf("allowable ponies are: "); for(int i = 0; i <= Zecora; i++) printf("%s ", getDirectoryName(i)); return 0; } //Make pony windows for( int i = 0; i < numberOfPonies; i++) { fgets(buffer, 256, ifp); char* temp = NULL; temp = strchr(buffer, '\n'); if(temp) buffer[temp - buffer] = '\0'; ponyArray[i].name = ponyNameFromString(buffer); ponyArray[i].direction = DirNone; ponyArray[i].dragActive = 0; ponyArray[i].speed = SpeedStopped; ponyArray[i].animation = AnimIdle; ponyArray[i].active = 1; ponyArray[i].facing = FaceLeft; //Create animation from file, default is idle_left char* initialPicturePath; initialPicturePath = malloc((strlen(ponyDirectory) + strlen(getDirectoryName(ponyArray[i].name)) + 14) * sizeof(char)); if(!initialPicturePath) { printf("Unable to allocate memory for directory"); continue; } strcpy(initialPicturePath, ponyDirectory); strcat(initialPicturePath, getDirectoryName(ponyArray[i].name)); strcat(initialPicturePath, "/idle_left.gif"); ponyArray[i].pictureanim = gdk_pixbuf_animation_new_from_file (initialPicturePath, &error); free(initialPicturePath); ponyArray[i].image = gtk_image_new_from_animation(ponyArray[i].pictureanim); ponyArray[i].pictureanimit = gdk_pixbuf_animation_get_iter (ponyArray[i].pictureanim, NULL); ponyArray[i].win = gtk_window_new(GTK_WINDOW_TOPLEVEL); //Resize everytime the gif updates g_timeout_add(gdk_pixbuf_animation_iter_get_delay_time(ponyArray[i]. pictureanimit),(GSourceFunc)updateWinSize, &ponyArray[i]); //Name the window the name of the pony being animated gtk_window_set_title(GTK_WINDOW(ponyArray[i].win), getPonyName(ponyArray[i].name)); //Size down the window before showing it gtk_window_set_default_size(GTK_WINDOW(ponyArray[i].win), gdk_pixbuf_animation_get_width(ponyArray[i]. pictureanim), gdk_pixbuf_animation_get_height (ponyArray[i].pictureanim)); //Remove the titlebar gtk_window_set_decorated(GTK_WINDOW(ponyArray[i].win), FALSE); //Set up the signals ponyArray[i].clickEventID = g_signal_connect(G_OBJECT(ponyArray[i].win), "button_press_event", G_CALLBACK(click_event), &ponyArray[i]); ponyArray[i].enterEventID = g_signal_connect(G_OBJECT(ponyArray[i].win), "enter-notify-event", G_CALLBACK(enter_event), &ponyArray[i]); ponyArray[i].leaveEventID = g_signal_connect(G_OBJECT(ponyArray[i].win), "leave-notify-event", G_CALLBACK(enter_event), &ponyArray[i]); gtk_widget_add_events(ponyArray[i].win, GDK_BUTTON_PRESS_MASK); gtk_container_add(GTK_CONTAINER(ponyArray[i].win), GTK_WIDGET(ponyArray[i]. image)); //Get rid of taskbar item gtk_window_set_skip_taskbar_hint(GTK_WINDOW(ponyArray[i].win), TRUE); //Make it so it can't be selected gtk_window_set_accept_focus(GTK_WINDOW(ponyArray[i].win), FALSE); gtk_widget_realize(ponyArray[i].win); //Always on top gtk_window_set_keep_above(GTK_WINDOW(ponyArray[i].win), TRUE); updateWinSize(&ponyArray[i]); if(error != NULL) break; } free(ponyDirectory); free(ponyHomeFile); //Quit out if there were any errors and give a message if( error != NULL) { printf("%s\n",error->message); return 0; } //Make it transparent? /*cr = gdk_cairo_create(win->window); cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0); cairo_set_operator( cr, CAIRO_OPERATOR_SOURCE); cairo_paint(cr); gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(image));*/ //Main loop for( int i = 0; i < numberOfPonies; i++) gtk_widget_show_all(ponyArray[i].win); gtk_main(); return 0; }
void _gtk_icon_helper_get_size (GtkIconHelper *self, GtkStyleContext *context, gint *width_out, gint *height_out) { cairo_surface_t *surface; gint width, height, scale; width = height = 0; /* Certain kinds of images are easy to calculate the size for, these we do immediately to avoid having to potentially load the image data for something that may not yet be visible */ switch (self->priv->storage_type) { case GTK_IMAGE_SURFACE: get_surface_size (self, context, self->priv->orig_surface, &width, &height); break; case GTK_IMAGE_PIXBUF: get_pixbuf_size (self, context, &width, &height, &scale); width = (width + scale - 1) / scale; height = (height + scale - 1) / scale; break; case GTK_IMAGE_ICON_NAME: case GTK_IMAGE_GICON: if (self->priv->pixel_size != -1 || self->priv->force_scale_pixbuf) ensure_icon_size (self, context, &width, &height); break; case GTK_IMAGE_STOCK: case GTK_IMAGE_ICON_SET: case GTK_IMAGE_ANIMATION: case GTK_IMAGE_EMPTY: default: break; } /* Otherwise we load the surface to guarantee we get a size */ if (width == 0) { surface = _gtk_icon_helper_ensure_surface (self, context); if (surface != NULL) { width = self->priv->rendered_surface_width; height = self->priv->rendered_surface_height; cairo_surface_destroy (surface); } else if (self->priv->storage_type == GTK_IMAGE_ANIMATION) { width = gdk_pixbuf_animation_get_width (self->priv->animation); height = gdk_pixbuf_animation_get_height (self->priv->animation); } else if (self->priv->icon_size != GTK_ICON_SIZE_INVALID) { ensure_icon_size (self, context, &width, &height); } } if (width_out) *width_out = width; if (height_out) *height_out = height; }
void gaym_gtkconv_update_thumbnail(GaimConversation * conv, struct fetch_thumbnail_data *thumbnail_data) { GaimGtkConversation *gtkconv; char filename[256]; FILE *file; GError *err = NULL; size_t len; GdkPixbuf *buf; GdkPixbuf *scale; GdkPixmap *pm; GdkBitmap *bm; int scale_width, scale_height; GaimAccount *account; GaimPluginProtocolInfo *prpl_info = NULL; g_return_if_fail(conv != NULL); g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_CHAT); gtkconv = GAIM_GTK_CONVERSATION(conv); GaymChatIcon *icon_data = g_hash_table_lookup(icons, conv); if (!thumbnail_data) return; if (!icon_data->show_icon) return; const char *data = thumbnail_data->pic_data; len = thumbnail_data->pic_data_len; account = gaim_conversation_get_account(conv); if (account && account->gc) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); if (icon_data->anim != NULL) g_object_unref(G_OBJECT(icon_data->anim)); icon_data->anim = NULL; if (icon_data->icon_timer != 0) g_source_remove(icon_data->icon_timer); icon_data->icon_timer = 0; if (icon_data->iter != NULL) g_object_unref(G_OBJECT(icon_data->iter)); icon_data->iter = NULL; if (!gaim_prefs_get_bool ("/gaim/gtk/conversations/im/show_buddy_icons")) return; if (gaim_conversation_get_gc(conv) == NULL) return; /* this is such an evil hack, i don't know why i'm even considering it. we'll do it differently when gdk-pixbuf-loader isn't leaky anymore. */ /* gdk-pixbuf-loader was leaky? is it still? */ g_snprintf(filename, sizeof(filename), "%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d", g_get_tmp_dir(), thumbnail_data->who, getpid()); if (!(file = g_fopen(filename, "wb"))) return; fwrite(data, 1, len, file); fclose(file); icon_data->anim = gdk_pixbuf_animation_new_from_file(filename, &err); /* make sure we remove the file as soon as possible */ g_unlink(filename); if (err) { gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", "Buddy icon error: %s\n", err->message); g_error_free(err); } if (!icon_data->anim) return; if (gdk_pixbuf_animation_is_static_image(icon_data->anim)) { icon_data->iter = NULL; buf = gdk_pixbuf_animation_get_static_image(icon_data->anim); } else { icon_data->iter = gdk_pixbuf_animation_get_iter(icon_data->anim, NULL); /* LEAK */ buf = gdk_pixbuf_animation_iter_get_pixbuf(icon_data->iter); } get_icon_scale_size(icon_data->anim, prpl_info ? &prpl_info->icon_spec : NULL, &scale_width, &scale_height); scale = gdk_pixbuf_scale_simple(buf, MAX(gdk_pixbuf_get_width(buf) * scale_width / gdk_pixbuf_animation_get_width (icon_data->anim), 1), MAX(gdk_pixbuf_get_height(buf) * scale_height / gdk_pixbuf_animation_get_height (icon_data->anim), 1), GDK_INTERP_NEAREST); gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); g_object_unref(G_OBJECT(scale)); icon_data->event = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(icon_data->frame), icon_data->event); gtk_widget_set_size_request(GTK_WIDGET(icon_data->frame), scale_width, scale_height); // g_signal_connect(G_OBJECT(icon_data->event), "button-press-event", // G_CALLBACK(icon_menu), conv); gtk_widget_show(icon_data->event); icon_data->icon = gtk_image_new_from_pixmap(pm, bm); gtk_container_add(GTK_CONTAINER(icon_data->event), icon_data->icon); gtk_widget_show(icon_data->icon); g_object_unref(G_OBJECT(pm)); if (bm) g_object_unref(G_OBJECT(bm)); }
void _gtk_icon_helper_get_size (GtkIconHelper *self, gint *width_out, gint *height_out) { gint width, height, scale; width = height = 0; /* Certain kinds of images are easy to calculate the size for, these we do immediately to avoid having to potentially load the image data for something that may not yet be visible */ switch (gtk_image_definition_get_storage_type (self->priv->def)) { case GTK_IMAGE_SURFACE: get_surface_size (self, gtk_image_definition_get_surface (self->priv->def), &width, &height); break; case GTK_IMAGE_PIXBUF: get_pixbuf_size (self, gtk_widget_get_scale_factor (gtk_css_gadget_get_owner (GTK_CSS_GADGET (self))), gtk_image_definition_get_pixbuf (self->priv->def), gtk_image_definition_get_scale (self->priv->def), &width, &height, &scale); width = (width + scale - 1) / scale; height = (height + scale - 1) / scale; break; case GTK_IMAGE_ANIMATION: { GdkPixbufAnimation *animation = gtk_image_definition_get_animation (self->priv->def); width = gdk_pixbuf_animation_get_width (animation); height = gdk_pixbuf_animation_get_height (animation); break; } case GTK_IMAGE_ICON_NAME: case GTK_IMAGE_GICON: if (self->priv->pixel_size != -1 || self->priv->force_scale_pixbuf) ensure_icon_size (self, &width, &height); break; case GTK_IMAGE_STOCK: case GTK_IMAGE_ICON_SET: case GTK_IMAGE_EMPTY: default: break; } /* Otherwise we load the surface to guarantee we get a size */ if (width == 0) { gtk_icon_helper_ensure_surface (self); if (self->priv->rendered_surface != NULL) { get_surface_size (self, self->priv->rendered_surface, &width, &height); } else if (self->priv->icon_size != GTK_ICON_SIZE_INVALID) { ensure_icon_size (self, &width, &height); } } if (width_out) *width_out = width; if (height_out) *height_out = height; }
void splash_create (gboolean be_verbose) { GtkWidget *frame; GtkWidget *vbox; GdkPixbufAnimation *pixbuf; GdkScreen *screen; g_return_if_fail (splash == NULL); pixbuf = splash_image_load (be_verbose); if (! pixbuf) return; splash = g_slice_new0 (GimpSplash); splash->window = g_object_new (GTK_TYPE_WINDOW, "type", GTK_WINDOW_TOPLEVEL, "type-hint", GDK_WINDOW_TYPE_HINT_SPLASHSCREEN, "title", _("GIMP Startup"), "role", "gimp-startup", "window-position", GTK_WIN_POS_CENTER, "resizable", FALSE, NULL); g_signal_connect_swapped (splash->window, "delete-event", G_CALLBACK (exit), GINT_TO_POINTER (0)); screen = gtk_widget_get_screen (splash->window); splash->width = MIN (gdk_pixbuf_animation_get_width (pixbuf), gdk_screen_get_width (screen)); splash->height = MIN (gdk_pixbuf_animation_get_height (pixbuf), gdk_screen_get_height (screen)); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); gtk_container_add (GTK_CONTAINER (splash->window), frame); gtk_widget_show (frame); vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); /* If the splash image is static, we use a drawing area and set the * image as back pixmap, otherwise a GtkImage is being used. */ if (gdk_pixbuf_animation_is_static_image (pixbuf)) { splash->area = gtk_drawing_area_new (); } else { splash->area = gtk_image_new_from_animation (pixbuf); } gtk_box_pack_start (GTK_BOX (vbox), splash->area, TRUE, TRUE, 0); gtk_widget_show (splash->area); gtk_widget_set_size_request (splash->area, splash->width, splash->height); /* create the pango layouts */ splash->upper = gtk_widget_create_pango_layout (splash->area, ""); splash->lower = gtk_widget_create_pango_layout (splash->area, ""); gimp_pango_layout_set_scale (splash->lower, PANGO_SCALE_SMALL); /* this sets the initial layout positions */ splash_position_layouts (splash, "", "", NULL); splash_average_text_area (splash, gdk_pixbuf_animation_get_static_image (pixbuf), &splash->color); gtk_widget_realize (splash->area); if (gdk_pixbuf_animation_is_static_image (pixbuf)) { GdkPixbuf *static_pixbuf = gdk_pixbuf_animation_get_static_image (pixbuf); GdkPixmap *pixmap; cairo_t *cr; pixmap = gdk_pixmap_new (gtk_widget_get_window (splash->area), splash->width, splash->height, -1); cr = gdk_cairo_create (pixmap); gdk_cairo_set_source_pixbuf (cr, static_pixbuf, 0.0, 0.0); cairo_paint (cr); cairo_destroy (cr); gdk_window_set_back_pixmap (gtk_widget_get_window (splash->area), pixmap, FALSE); g_object_unref (pixmap); } g_object_unref (pixbuf); g_signal_connect_after (splash->area, "expose-event", G_CALLBACK (splash_area_expose), splash); /* add a progress bar */ splash->progress = gtk_progress_bar_new (); gtk_box_pack_end (GTK_BOX (vbox), splash->progress, FALSE, FALSE, 0); gtk_widget_show (splash->progress); gtk_widget_show_now (splash->window); #ifdef STARTUP_TIMER splash->timer = g_timer_new (); #endif }
static void gtk_image_accessible_get_image_size (AtkImage *image, gint *width, gint *height) { GtkWidget* widget; GtkImage *gtk_image; GtkImageType image_type; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (image)); if (widget == NULL) { *height = -1; *width = -1; return; } gtk_image = GTK_IMAGE (widget); image_type = gtk_image_get_storage_type (gtk_image); switch (image_type) { case GTK_IMAGE_PIXBUF: { GdkPixbuf *pixbuf; pixbuf = gtk_image_get_pixbuf (gtk_image); *height = gdk_pixbuf_get_height (pixbuf); *width = gdk_pixbuf_get_width (pixbuf); break; } case GTK_IMAGE_STOCK: case GTK_IMAGE_ICON_SET: case GTK_IMAGE_ICON_NAME: case GTK_IMAGE_GICON: { GtkIconSize size; GtkSettings *settings; settings = gtk_settings_get_for_screen (gtk_widget_get_screen (widget)); g_object_get (gtk_image, "icon-size", &size, NULL); gtk_icon_size_lookup_for_settings (settings, size, width, height); break; } case GTK_IMAGE_ANIMATION: { GdkPixbufAnimation *animation; animation = gtk_image_get_animation (gtk_image); *height = gdk_pixbuf_animation_get_height (animation); *width = gdk_pixbuf_animation_get_width (animation); break; } default: { *height = -1; *width = -1; break; } } }