Help on GnomeCanvasImage



I'm writing a game and am using the GnomeCanvas and GnomeCanvasItem functions
significantly. In this code snippet, I'm trying to add a GnomeCanvasImage
to my GnomeCanvas. I get no compiler or run-time errors. But the image
never gets displayed. What am I doing wrong?

(Oh, BTW, the gdk_init() and gdk_imlib_init() functions automatically
get called when I do a gnome_init(), right?)

void
draw_board                              (GnomeCanvas            *canvas)
{
  GtkWidget             *board;
  GdkImlibImage         *board_image;

  gtk_widget_push_visual(gdk_imlib_get_visual());
  gtk_widget_push_colormap(gdk_imlib_get_colormap());

  board_image = gdk_imlib_load_image("gchch/gchch-board.png");
  if (!board_image)
    g_warning ("Couldn't find pixmap file: %s", "gchch-board.png");
  gdk_flush();

  gtk_widget_pop_visual();
  gtk_widget_pop_colormap();

  board = gnome_canvas_item_new (gnome_canvas_root(canvas),
                                 GNOME_TYPE_CANVAS_IMAGE,
                                 "image", board_image,
                                 "x", 0, "y", 0, "width", 400, "height", 400,
                                 "anchor", GTK_ANCHOR_NW,
                                 NULL);
  gtk_widget_show(board); // Actually not needed because the CanvasItem is
                          // is visible by default.
}


|      LOBAN AMAAN RAHMAN  <-- anagram of -->   AHA! AN ABNORMAL MAN!      |
|   Snail: MSC #763, Caltech, Pasadena, CA 91126, USA. ** 1-626-395-1407   |
|     Wired: loban@earthling.net, loban@caltech.edu, http://i.am/loban     |
|        (Do 'finger loban@its' or my PGP public key and more info)        |



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