On Mon, 8 Dec 2008 12:32:55 -0500zentara <zentara1@xxxxxxxxxxxxx> wrote: >On Mon, 8 Dec 2008 12:13:41 +0530>"Harinandan S" <harinandans@xxxxxxxxx> wrote:>>>I want to set a background pixmap of only one window. I tried example rc>>file but that sets background of all windows to the same image. I also tried>>calling>>gtk_widget_set_name (ui_home_window,"home window");>>>in my rc file. I also loaded the rc file but I'm not seeing any changes. I>>was able to set the same pixmap to all windows but how to set it only for>>one window?>>>>Regards,>>Harinandan S>>See Tadej Borovšak's response to a similar question a few days ago,>for a c example.>>I'm only good at Perl, and this is how you would do it in Perl.>The mainwindow has the default pixmap theme, but the toplevel>has a custom background image. Time to try some c. :-) Here is a c version of my Perl example.----------------------- cut ------------------------------------------ #include <gtk/gtk.h> /* exit callback */gint delete_event( ){ gtk_main_quit (); return FALSE;} void callback( ){ GtkWidget *window1; GtkWidget *button1; GtkStyle *style; GdkPixbuf *buf; GdkPixmap *map = NULL; /* Create a new toplevel window */ window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (window1, 350, 350); gtk_container_set_border_width (GTK_CONTAINER (window1), 100); gtk_window_set_title (GTK_WINDOW (window1), "Custom Pixmap"); g_signal_connect (G_OBJECT (window1), "delete_event", G_CALLBACK (delete_event), NULL); buf = gdk_pixbuf_new_from_file( "test.png", NULL ); /*gdk_pixbuf_render_pixmap_and_mask( buf, &map, &mask, 10 ); */ /*gdk_window_shape_combine_mask( window->window, mask, 0, 0 );*/ gtk_widget_set_app_paintable( window1, TRUE ); gdk_pixbuf_render_pixmap_and_mask(buf, &map, NULL, 255); style = gtk_style_copy(gtk_widget_get_style(window1)); style->bg_pixmap[GTK_STATE_NORMAL] = map; gtk_widget_set_style(window1, style); /* add a button */ button1 = gtk_button_new_with_label ("Just for Looks"); gtk_widget_set_size_request (button1, 50, 50); gtk_container_add (GTK_CONTAINER (window1), button1); gtk_widget_show (button1); gtk_widget_show (window1);} int main( int argc, char *argv[] ){ GtkWidget *window; GtkWidget *button; GtkWidget *box1; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Pixmap themes overrides"); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete_event), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); box1 = gtk_hbox_new (FALSE, 0); /* Put the box into the main window. */ gtk_container_add (GTK_CONTAINER (window), box1); /* Creates a new button */ button = gtk_button_new_with_label ("Launch Toplevel"); /* Now when the button is clicked, we call the "callback" function * with a pointer to "button 1" as its argument */ g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (callback), (gpointer) NULL); /* Instead of gtk_container_add, we pack this button into the invisible * box, which has been packed into the window. */ gtk_box_pack_start (GTK_BOX(box1), button, TRUE, TRUE, 0); gtk_widget_show (button); gtk_widget_show (box1); gtk_widget_show (window); gtk_main (); return 0;} ------------------- cut --------------------------------------------- zentara -- I'm not really a human, but I play one on earth.http://zentara.net/Remember_How_Lucky_You_Are.html _______________________________________________gtk-list mailing listgtk-list@xxxxxxxxxxxxx://mail.gnome.org/mailman/listinfo/gtk-list