Hello all, I am trying to get a panel with progressive zomming working, like OS X dock but with gtk (I bet I am not the first one) I have a function that populates the panel and assign the event. Basically I create an event box (docklet), create an image (image) out of a pixmap and put it inside the container (docklet) then I connect the signals: g_signal_connect(G_OBJECT(docklet), "enter_notify_event",(GCallback)zoomin, image); g_signal_connect(G_OBJECT(docklet), "leave_notify_event",(GCallback)zoomout, image); g_signal_connect(G_OBJECT(docklet), "button_press_event", (GCallback)launchapp, application); my zoomin callback looks like this: static void zoomin(GtkWidget *widget, GdkEventButton *event, gpointer data) { int steps, step_size, i, zoom_width, zoom_height; /* GdkImage *image = data; */ GdkPixbuf *zoomer; if (debug) { g_print("We are zooming in\n"); } steps = 8; step_size = 8; zoom_width = 64; zoom_height = 64; for ( i = 0; i < steps ; i++ ) { zoomer = gdk_pixbuf_new_from_data ((gpointer)data, GDK_COLORSPACE_RGB, TRUE, 8, 64,64, 0, NULL, NULL); /* zoomer = gdk_pixbuf_get_from_image(NULL, image, NULL, -1, -1, 0, 0, 64, 64); */ zoom_width = zoom_width + step_size; zoom_height = zoom_height + step_size; usleep(100000); gtk_image_set_from_pixbuf(data, gdk_pixbuf_scale_simple(zoomer, zoom_width, zoom_height, GDK_INTERP_BILINEAR)); if (debug) { g_print("zoom_width = %d , zoom_height = %d\n", zoom_width, zoom_height); } } } now to my 2 problems. first, the zoom works, however it doesn't do the smooth zoom I was hoping for, it goes from the minimun size to the maximun size altho I see from the debug that zoom_height and zoom_width are set to the right values but the image is not being updated. I put the usleep there to actually see if it was going so fast that I was not able to see the magnification because of that. second, I though that gpointer data was a pointer to my GdkImage but GdkImage *image = data; zoomer = gdk_pixbuf_get_from_image(NULL, image, NULL, -1, -1, 0, 0, 64, 64); result in errors at run time: (gDock:772): GdkPixbuf-CRITICAL **: file gdk-pixbuf-scale.c: line 235 (gdk_pixbu f_scale_simple): assertion `src != NULL' failed (gDock:772): Gdk-CRITICAL **: file gdkpixbuf-drawable.c: line 1346 (gdk_pixbuf_g et_from_image): assertion `GDK_IS_IMAGE (src)' failed zoom_width = 72 , zoom_height = 72 and if I try to use the zoomer = gdk_pixbuf_new_from_data ((gpointer)data, GDK_COLORSPACE_RGB, TRUE, 8, 64,64, 0, NULL, NULL); when the zoom actually occurs I get a corrupted image, grey background with vertical color lines. for the first problem I could write the function so it only magnifies one step at the time, but that would take a toll in the CPU that I am trying to avoid. for the second problerm I am sure it is something that I am doing wrong in both cases. Could someone give me a pointer as to what I am doing wrong. Thank you.
Attachment:
signature.asc
Description: This is a digitally signed message part