Can't get image to display!



Hi -

I know this has a really, really simple answer, but...

  1. I have a GTK+ file viewer application that needs to handle multiple
     different image file types (.jpg, .png, proprietary, etc etc)

  2. When the user clicks the "File, Open" menu option, I pop up a
     GtkFileSelection dialog and get the filename.

  3. In my "file_open_cb" callback, I do the following:

  // Deallocate old pixbuf, image
  if (this->pixbuf)
  {
    gdk_pixbuf_unref (this->pixbuf);
    this->pixbuf = NULL;
  }
  if (this->hbx_image)
  {
    gtk_widget_destroy (this->hbx_image);
    this->hbx_image = NULL;
  }

  // Allocate new pixbuf
  this->pixbuf = gdk_pixbuf_new_from_file (this->fname, NULL);

  // Allocate new image
  this->hbx_image = gtk_image_new_from_pixbuf (this->pixbuf);

  // Force display
  gtk_widget_show (this->hbx_image);
//  gdk_window_process_all_updates ();
//  gdk_window_invalidate_rect (
//    this->main_window->window,
//    &this->main_window->allocation,
//    TRUE);

  4. I've tried different permutations of "gtk_widget_show()"
     and "gdk_window_invalidate_rect()", to no avail.  I always
     see a grey canvas - the image never redisplays.

Any ideas what I'm doing wrong???

Thanx in advance .. PSM







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]