Images & Gtk+



Hi,

i'm looking for a widget that can display jpg, png /etc /etc

For now i've write this code:


/*-------------------cut here ------------------------------*/
GtkWidget *create_widget_from_image (gchar *filename, int width, int height)
{
    GtkWidget *pixWidget;
    GdkPixbuf *pixFrontTmp = gdk_pixbuf_new_from_file (filename);
    GdkPixbuf *pixFront;
    GdkPixmap *pixmapFront;
    GdkBitmap *mask;

    pixFront = gdk_pixbuf_scale_simple(pixFrontTmp,
                                       width,
                                       height,
                                       GDK_INTERP_NEAREST);

    gdk_pixbuf_render_pixmap_and_mask(pixFront, &pixmapFront, &mask, 0);
    
    pixWidget = gtk_pixmap_new (pixmapFront, mask);

    gdk_pixmap_unref (pixmapFront);
    gdk_pixbuf_unref(pixFrontTmp);
    gdk_pixbuf_unref(pixFront);

    return pixWidget;
}
/*-------------------cut here ------------------------------*/


The code actualy work, but with this solution i don't know how to add a
popup menu with the right mouse button (i tryed as usualy, but it seems
that that widget don't callback on button signal :( ).

If someone of you has a simple sample code for display a jpg in a GTK+
app let me know :)


I'm looking for a newsgroup where i can read developer talk about GTK,
does it exist? I know that there is this good mailing list, but i love
use slrn :) :) :)

byeZ!

-- 
     .--.     Vanni Brutto
    |o_o |    ICQ 18526701
    |:_/ |    email zanac libero it
   //   \ \   irc nick  VanniB (or Zanac)
  (|     | ) 
 /'\_   _/`\ 
 \___)=(___/      PC Powered By Linux



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