Re: [gtk-list] Re: rewrite question:how to attach a pixmap to aGtkWindowas the background
- From: Matt Long <matt long wcom com>
- To: gtk-list redhat com
- Cc: tdukes ibmoto com
- Subject: Re: [gtk-list] Re: rewrite question:how to attach a pixmap to aGtkWindowas the background
- Date: Wed, 25 Aug 1999 16:18:18 -0600
I don't know if this will help you much, but I took your source code and
moved these lines:
//create pixmap
style=gtk_widget_get_style(window1);
pixmap=gdk_pixmap_create_from_xpm(window1->window,&mask,&style->bg[GTK_STATE_NORMAL],
"./BACKGROUND.XPM");
gdk_window_set_back_pixmap(window1->window,pixmap,0);
and placed them before the button creation. If you do this, recompil,
and run, you will notice that the backgroud pixmap flashes (e.g. it
appears for a split second) and then all you see is what you described
previously. This is somewhat strange. I tried commenting out different
parts of the code to determine which part(s) may be obfuscating the
pixmap, but was unsuccessful.
Sorry I couldn't be of more help. Maybe someone else has seen this
flicker effect before.
-Matt
Jiang XU wrote:
>
> I have been driven crazy!!
>
> But, first thanks Todd!, at least I can get the GdkWindow.
> But I still can not put the pixmap as the background of the GtkWIndow. It
> doesn't show up!!
> So, I guess I still need Help!!
> Thanks very much!!
>
> The following is the source code (test example), it only include one table and
> one button:
> I use gtk_window_new to create window1 and use gtk_widget_realize to set
> window1->window, then I use gdk_window_set_back_pixmap to set the pixmap as
> the background. but when run the application, it does not show the pixmap. I
> wonder what's wrong!
>
> Need help!!
> Thanks very very much!
>
> #include <sys/stat.h>
> #include <unistd.h>
> #include <string.h>
> #include <gtk/gtk.h>
> #include "interface.h"
>
> GtkWidget*
> create_window1 ()
> {
> GtkWidget *window1;
> GtkWidget *table1;
> GtkWidget *button1;
> GdkPixmap *pixmap;
> GdkBitmap *mask;
> GtkStyle *style;
>
> window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
> gtk_object_set_data (GTK_OBJECT (window1), "window1", window1);
> gtk_widget_set_usize (window1, 640, 480);
> gtk_window_set_title (GTK_WINDOW (window1), "window1");
> //set windows->window, which is GdkWindow
> gtk_widget_realize(window1);
>
> //create table
> table1 = gtk_table_new (10, 10, FALSE);
> gtk_widget_ref (table1);
> gtk_object_set_data_full (GTK_OBJECT (window1), "table1", table1,
> (GtkDestroyNotify) gtk_widget_unref);
> gtk_widget_show (table1);
> gtk_container_add (GTK_CONTAINER (window1), table1);
>
> //create button
> button1 = gtk_button_new_with_label ("button1");
> gtk_widget_ref (button1);
> gtk_object_set_data_full (GTK_OBJECT (window1), "button1", button1,
> (GtkDestroyNotify) gtk_widget_unref);
> gtk_widget_show (button1);
> gtk_table_attach (GTK_TABLE (table1), button1, 4, 5, 8, 9,
> (GtkAttachOptions) (0),
> (GtkAttachOptions) (0), 0, 0);
>
> //create pixmap
> style=gtk_widget_get_style(window1);
>
> pixmap=gdk_pixmap_create_from_xpm(window1->window,&mask,&style->bg[GTK_STATE_NORMAL],"./BACKGROUND.XPM");
>
> gdk_window_set_back_pixmap(window1->window,pixmap,0);
>
> gdk_window_show(window1->window);
>
> return window1;
> }
>
> int main (int argc, char *argv[])
> {
> GtkWidget* window1;
>
> gtk_init(&argc,&argv);
>
> window1=create_window1 ();
>
> gtk_widget_show (window1);
>
> //start gtk+ main loop
> gtk_main ();
> }
>
> Todd Dukes wrote:
>
> > Jiang XU wrote:
> > >
> > > I want to attach a pixmap to a GtkWindow as the background, there is
> > > a function 'gdk_window_set_back_pixmap` , but this function
> > > 'gdk_window_set_back_pixmap` only supports GdkWindow.
> > > But my application is using GtkWindow which let me can add
> > > other widgets to the window.
> > >
> > > So I wonder how I can attach a pixmap to a GtkWindow as the background?
> > > Or, How to get the associate GdkWindow from a GtkWindow, so that I can
> > > use that function?
> > > Or, How to create a GtkWindow from a GdkWindow which is already get a
> > > pixmap background by using that function.
> > > Or, any other way?
> > >
> > > In struct _GtkWidget, there is a parameter called GdkWindow *window.
> > > But, if using 'windows1=gtk_window_new(..)' it won't set that parameter,
> > >
> > > which means windows1->window=NULL, it does not
> > > link to a GdkWindow, and same as button,table.....
> > >
> >
> > I believe you should call
> >
> > gtk_widget_realize ( windows1 );
> >
> > after windows1 = gtk_window_new (...) before you check
> > the value of windows1->window;
> >
> > Todd.
> >
> > --
> > | Todd Dukes E-MAIL: tdukes@ibmoto.com |
> > | Motorola Somerset Phone: (512) 424-8008 |
> > | 6200 Bridgepoint Parkway Building #4 MS OE70 |
> > | Austin, Texas 78730 |
> >
> > --
> > To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]