GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Sep 22, 2014 6:14 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: gtk_image_set_from_pixbuf does not generate an event?
PostPosted: Tue Oct 08, 2013 7:22 pm 
Offline
Familiar Face

Joined: Tue Oct 08, 2013 6:04 pm
Posts: 13
I have a couple of rather basic questions: It seems that gtk_image_set_from_pixbuf does not generate an event but gtk_image_set_from_file does? (see code below) I'm VERY new to GTK+ but this seems crazy or at least inconsistent. I guess I have to put some kind of event box "around' the image widget to generate an event when it changes? Have I got this wrong?

Edit: I found my problem -- seems there is no need to create a new image -- removing the gtk_image_new_from_pixbuf call fixes things.

Does GTK+ automatically clean up my 'old' image widget when I call gtk_image_new_from_pixbuf or should I destroy it before I call the function? It may be just a wrapper around my image data but I don't want to generate a memory leak.

Code:
void gui_update_output_image(IMAGE *image)
{
   GdkPixbuf *pixbuf;

   // clear any pending events
   while(gtk_events_pending()) gtk_main_iteration();

   pixbuf = gdk_pixbuf_new_from_data
   (
      image->buffer,
      GDK_COLORSPACE_RGB,
      TRUE, 8,         // has alpha (RGBA) RGB is 8 bits per channel
      image->width,
      image->length,
      image->width * 4,   // row stride byte count
      NULL, NULL         // no clean-up function
   );

   output_image = gtk_image_new_from_pixbuf(pixbuf); // <<< MY BUG IS HERE
   gtk_image_set_from_pixbuf(GTK_IMAGE(output_image), pixbuf);

/*
   gtk_image_set_from_file(GTK_IMAGE(output_image),
      "/media/art/C/cnc_image/image_output/display.jpg");
*/
   if(!gtk_events_pending())
   {
      printf("===> NO event is pending at '%s' end\n", __FUNC__);
   }
   
   while(gtk_events_pending()) gtk_main_iteration();
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Google Adsense [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group