LayoutWidget and overlapping widgets



I have created a small Application that displays a GtkTextView object
(contained in a Scrolled Window) and a Button object both in an
LayoutWidget container.

I am trying to make it so the button gets displayed after TextView
object, so the button overlaps the GtkTextView object. 

I have tried using indiviual gtk_show_widet()s and
get_show_widget_all(window) with get_show_widget(button) after. Putting
the function call to display the button after the GtkTextView object in
each case. But still nothing - the TextView object always overlaps the
button. It seems very odd to me. Please help.

Cheers, Aaron





#include <gtk/gtk.h>

void destroy( GtkWidget *widget, gpointer data) {
 gtk_main_quit ();
}
 
int main( int   argc, char *argv[] ) {
 GtkWidget *window, *view, *sw, *fixed, *button;
 GtkTextBuffer *buffer;

 gtk_init (&argc, &argv);
 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
 g_signal_connect (G_OBJECT (window), "destroy",G_CALLBACK (destroy),
NULL);

 /******** setting up the container widgets ********/
 sw = gtk_scrolled_window_new (NULL, NULL);
 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 /********* end of setting up container widgets *****/

 //set up the TextView object and add it to the scrolled window
(sw)widget
 view = gtk_text_view_new ();
 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
 gtk_container_add (GTK_CONTAINER (sw), view);

 //set up the button 
 //initalise the layout and add the sw and button widget 
 button = gtk_button_new_with_label ("Press me");
 fixed = gtk_layout_new (NULL, NULL);
 gtk_layout_set_size( GTK_LAYOUT(fixed),200,200);
 gtk_layout_put (GTK_LAYOUT (fixed), sw, 2, 10);
 gtk_layout_put (GTK_LAYOUT (fixed), button, 12, 20);
 gtk_container_add (GTK_CONTAINER (window), fixed);

 gtk_widget_show_all (window);
 gtk_widget_show (button);

 gtk_main ();

 return 0;
}



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