Re: how to set background iamge to Treeview

Em Quinta, 3 de Agosto de 2006 06:22, o cnu_sree escreveu:
> i know using bgcolor we can change the background color.
> but how we can set the image as a background to the tree view
> please help me,
> sree

 Here goes an adaptation of a function I have to set an image background to a 
GtkTextView -- it should work, but if it doesn't, that's the idea. You must 
call this after the GtkTreeView widget has been realized. So, if you want to 
set it right at start, you have to delay it with:
g_signal_connect (G_OBJECT (tree_view), "realize",
		G_CALLBACK (set_help_background_cb), NULL);
(and call it on a "void set_help_background_cb (GtkWidget *, gpointer)")


void gtk_treeview_set_background (GtkTreeView *view, const char *image)
	g_return_if_fail (GTK_WIDGET_REALIZED (GTK_WIDGET (view)));

	GdkWindow *window = gtk_tree_view_get_bin_window (view);

	if (!image) {
		gdk_window_clear (window);

	GError *error = 0;
	GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (image, &error);
	if (!pixbuf) {
		g_warning ("could not open background image: '%s'"
		           " - %s", image, error->message);

	GdkPixmap *pixmap;
	gdk_pixbuf_render_pixmap_and_mask_for_colormap (pixbuf,
		gdk_drawable_get_colormap (GDK_DRAWABLE (window)), &pixmap, NULL, 0);
	g_object_unref (G_OBJECT (pixbuf));

	gdk_window_set_back_pixmap (window, pixmap, FALSE);



Love at first sight is one of the greatest labor-saving devices the
world has ever seen.

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