Pb with CLIST and Pixmaps ...



Hi,

I would like to create a CLIST with 2 columns: one for some
text, and one for pixmaps.

The problem I have is that the pixmaps are not visible !

The pixmap file is OK because I used it for an other GTK program
that works fine and that doesn't use CLIST. I'm using
GTK 1.2.2.

I couldn't find any clue in the tutorial, in the reference guide
or in the gtk-list archive, so please HELP !!!

This is the program:
The first function open the pixmap file and return the pixmap
widget. And the second one creates a window with a clist in it.

When I run it, the window opens, the clist is shown with the
titles and the text, but no pixmap ! I get no error and no
warning.



==================================
[#include .... ]

GtkWidget*
create_pixmap                          (GtkWidget       *widget,
                                        gchar           *filename)
{
  GdkColormap *colormap;
  GdkPixmap *gdkpixmap;
  GdkBitmap *mask;
  GtkWidget *pixmap;
  struct stat s;
  gint status;

  // check if the file exists
  status = stat (filename, &s);
  if (status == 0 && S_ISREG (s.st_mode))
    {
      colormap = gtk_widget_get_colormap (widget);
      gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL,
colormap, &mask,NULL, filename);

      if (gdkpixmap == NULL)
	return NULL;

      pixmap = gtk_pixmap_new (gdkpixmap, mask);
      
      gdk_pixmap_unref (gdkpixmap);
      gdk_bitmap_unref (mask);
      return pixmap;
    }
  else
    {
      g_print ("Couldn't find pixmap file: %s", filename);
      return NULL;
    }
}


int
main (int argc, char *argv[])
{
  GtkWidget *window1;
  GtkWidget *clist;
  GtkWidget *pixmap;
  gchar *clist_title[3]={"Frame Number","Images",NULL};
  gchar *buf[1][2]={{"Frame number 1 :","no image ..."}};
  gint row;


  gtk_set_locale ();
  gtk_init (&argc, &argv);

  // create main window
  window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_usize (window1, 500, 300);
  gtk_window_set_policy (GTK_WINDOW (window1), TRUE, TRUE, FALSE);

  // create the clist with 2 columns and titles
  clist = gtk_clist_new_with_titles (2, (gchar**) clist_title);
  gtk_clist_set_row_height(GTK_CLIST (clist),100);  
 
  // add the text in the next raw
  row=gtk_clist_append(GTK_CLIST(clist),buf[0]);
 
  // create the pixmap for the second column
  pixmap = create_pixmap (window1, "pixmap.xpm");
  if (pixmap == NULL)
    g_error ("Couldn't create pixmap");
  gtk_widget_show (pixmap);

  // put the pixmap into the second column of the first raw
  gtk_clist_set_pixmap (GTK_CLIST(clist), row, 1, (GdkPixmap *)
pixmap, NULL);

  
  // put the clist into the main window and show it
  gtk_container_add (GTK_CONTAINER (window1), clist);
  gtk_widget_show (clist);
  gtk_widget_show (window1);

  gtk_main ();
  return 0;
}
===========================================



Thanks a lot,

  Quentin Delamarre.

-- 
==================================================================
Quentin Delamarre  --  projet RobotVis  --  INRIA Sophia-Antipolis
email: mailto:Quentin.Delamarre@sophia.inria.fr           (France)
URL: http://www.inria.fr/robotvis/personnel/qdelam/qdelam-eng.html
==================================================================



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