Re: new window from button



thanks for the list tip. I always forget. I will try what you have suggested.
Take care,
Brad

On 7/3/07, Jonathan Winterflood <jonathan winterflood gmail com> wrote:
You're welcome,

You should probably ask Matias rather than me, it's his example :D
I guess you just forgot to add the list when you replied (reply to all works
best..)

Other than that, the popup doesn't clear the GtkWidget *cbwindow pointer,
therefore a click after closing it will crash here : gtk_widget_show_all
(cbwindow);

You will need to connact a callback to the delete-event of the popup that
clears it.

The point of the example was just creating a window though ;)

Cheers,
Jonathan
PS: Ok, no comment I'm as bad as you when it comes to adding the list :D


On 7/3/07, brad smith < bradleydsmith gmail com> wrote:
>
> Sorry one more thing, the example works fine except for when I push
> the button the other window opens. If I close the new window by the X
> and try to open the window again from the open button on the main
> window I get this error:
> Gtk-Critical**: gtk_widget_show_all: assertion `GTK_IS_WIDGET (widget)`
> failed
>
> Thanks again
> Brad
> On 7/3/07, brad smith <bradleydsmith gmail com> wrote:
> > thanks alot.
> > Take care.
> > Brad
> >
> > On 7/3/07, Jonathan Winterflood < jonathan winterflood gmail com> wrote:
> > > Ok, time to get back on the list
> > >
> > > Brad, here's the example Matias intended to show you (the mailing list
> ate
> > > the attachment it seems)
> > >
> > > </quote who="Matias">
> > > This is how I compile test.c
> > >  gcc -Wall `pkg-config --cflags gtk+-2.0` -o test test.c `pkg-config
> --libs
> > > gtk+-2.0`
> > > </quote>
> > >
> > > Cheers,
> > > Jonathan
> > > ---------- Forwarded message ----------
> > > From: Matí­as Alejandro Torres < torresmat gmail com>
> > > Date: Jul 3, 2007 4:20 PM
> > > Subject: Re: new window from button
> > > To: Jonathan Winterflood < jonathan winterflood gmail com >
> > >
> > > Ok, sorry about that.
> > >
> > > #include <stdlib.h>
> > > #include <gtk/gtk.h>
> > >
> > > void
> > > button_clicked_cb (GtkWidget *button, GtkWindow *parent)
> > > {
> > >     static GtkWidget *cbwindow = NULL;
> > >
> > >     if (!cbwindow)
> > >     /* Windows has not been created yet */
> > >     {
> > >         GtkWidget *text_view;
> > >
> > >         text_view = gtk_text_view_new ();
> > >         gtk_widget_set_size_request (text_view, 200, 150);
> > >
> > >         cbwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
> > >         gtk_window_set_title (GTK_WINDOW (cbwindow), "Callback
> window");
> > >         gtk_window_set_transient_for (GTK_WINDOW
> > > (cbwindow), parent);
> > >         gtk_container_add (GTK_CONTAINER (cbwindow), text_view);
> > >         gtk_container_set_border_width (GTK_CONTAINER
> > > (cbwindow), 12);
> > >
> > >     }
> > >     gtk_widget_show_all (cbwindow);
> > > }
> > >
> > > int
> > > main (gint argc, gchar **argv)
> > > {
> > >     GtkWidget *window;
> > >     GtkWidget *button;
> > >
> > >     gtk_init (&argc, &argv);
> > >
> > >     button = gtk_button_new_from_stock (GTK_STOCK_OPEN);
> > >
> > >     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
> > >     gtk_window_set_title (GTK_WINDOW (window), "Main window");
> > >     gtk_container_add (GTK_CONTAINER (window), button);
> > >     gtk_container_set_border_width (GTK_CONTAINER (window),
> > > 12);
> > >
> > >     /* We connect the signal clicked to a callback function that will
> > > create the window.
> > >      * The Main window is passed to that function (last argument).
> > >      */
> > >     g_signal_connect (G_OBJECT (button), "clicked", (GCallback)
> > > button_clicked_cb, window);
> > >     /* We connect the signal delete_event of the Main window so that
> > >      * the program exits when Main window is clicked.
> > >      */
> > >     g_signal_connect (G_OBJECT (window), "delete-event", (GCallback)
> > > gtk_main_quit, NULL);
> > >
> > >     gtk_widget_show_all (window);
> > >
> > >      gtk_main ();
> > >
> > >     return 0;
> > > }
> >
>
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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