Re: help me!



On Thursday 29 January 2004 09:30, Manoj tr wrote:

The problem is i cand draw that image with the following code

(snip)

you can't just use gdk_draw() on a GtkWindow - your pixbuf will only be drawn 
once, and will be cleared again as soon as the window needs refreshing (which 
it does with its own functions). You should use a GtkDrawingArea and do it 
like the documentation suggests if you want to draw stuff somewhere with 
gdk_draw_foo().

However, in your case it might just be easier to use a GtkImage anyway.

If you haven't read the tutorial at http://www.gtk.org/tutorial/ yet, you 
should definitively do so.


Try something like this:

#include <gtk/gtk.h>

static gboolean
onDelete (GtkWidget *widget, GdkEvent *event, gpointer data)
{
     gtk_main_quit();
     return TRUE;  /* not reached, makes compiler happy */
}

int
main (int argc, char **argv)
{
    GtkWidget *win, *img;

    gtk_init(&argc, &argv);

    win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(win, "delete_event", G_CALLBACK(onDelete), NULL);

    img = gtk_image_new_from_file("/some/where/foo.png");

    gtk_container_add(GTK_CONTAINER(win), img);

    gtk_widget_show_all(win);    

   gtk_main();

   return 0;
}


Cheers
-Tim

PS: And read http://www.catb.org/~esr/faqs/smart-questions.html#bespecific ;-)






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