Setting the background of a gtk_window
- From: Francois Taiani <francois taiani m6net fr>
- To: gnome <gnome-devel-list gnome org>
- Subject: Setting the background of a gtk_window
- Date: Mon, 27 Aug 2001 21:33:29 +0200
Hi everybody,
I sent that question to the gnome-love list, but nobody could answer me,
so I send it here. Here's my question:
I'm trying to set the background of a gtk_window to some program defined
color (i.e. without using any resource file), but that does not work:
The background remains grey (which is the default).
I'using gdk_window_set_background in the following manner, just before
gtk_main, but without sucess:
----
[...]
gtk_widget_show ( a_gtk_window);
gdk_window_set_background ( a_gtk_window->window, newColor ) ;
gtk_main ();
} /* End Of Main */
----
The variable newColor is a GdkColor* that I've allocated with
gtk_widget_get_colormap & gdk_colormap_alloc_color.
I attach the whole small program to this mail, to show what I'm excatly
doing.
Would anyone have an idea of what is wrong in my code ?
Thanks in advance
Francois
/**
* HelloWolrd.c
*
* Francois Taiani <taiani laas fr>
* Time-stamp: <01/08/24 21:43:35 ftaiani>
*
*/
#include <stdlib.h>
#include <gtk/gtk.h>
void destroy (GtkWidget *widget, gpointer data)
{
g_print ("Signal destroy was received.\n");
gtk_main_quit ();
}
int main (int argc, char *argv[])
{
GtkWidget * a_gtk_window ;
GdkColor * newColor ;
GdkColormap * colormap ;
gtk_init (&argc, &argv);
a_gtk_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
newColor = (GdkColor*)malloc(sizeof(GdkColor)) ;
newColor->red = 255 ;
newColor->green = 0 ;
newColor->blue = 0 ;
colormap = gtk_widget_get_colormap (a_gtk_window);
gdk_colormap_alloc_color ( colormap,
newColor,
0, /* is writable ? */
1 ) /* is best match ? */ ;
gtk_signal_connect (GTK_OBJECT (a_gtk_window), "destroy",
GTK_SIGNAL_FUNC (destroy), NULL);
gtk_container_border_width( GTK_CONTAINER (a_gtk_window), 100);
gtk_widget_show ( a_gtk_window);
gdk_window_set_background ( a_gtk_window->window, newColor ) ;
gtk_main ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]