----- Forwarded Message -----
From: David Buchan <pdbuchan yahoo com>
To: gtk-app-devel-list list <gtk-app-devel-list gnome org>
Sent: Tuesday, September 18, 2012 9:05 PM
Subject: GTK window positioning
Hi,
I've made a program that creates two new windows when demanded:
GtkWidget *window1, *scrolled_win1, *textview1;
GtkTextBuffer *buffer1;
GtkWidget *window2, *scrolled_win2, *textview2;
GtkTextBuffer *buffer2;
PangoFontDescription *textview_font1;
PangoFontDescription *textview_font2;
// Create new window to display unfragmented packet.
window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable (GTK_WINDOW (window1), TRUE);
gtk_window_set_position (GTK_WINDOW (window1), GTK_WIN_POS_NONE);
gtk_window_set_title (GTK_WINDOW
(window1), title);
gtk_window_set_default_size (GTK_WINDOW (window1), 1000, 200);
gtk_container_set_border_width (GTK_CONTAINER (window1), 1);
// Create a textview object to display unfragmented packet.
textview1 = gtk_text_view_new ();
buffer1 = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview1));
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview1), TRUE);
textview_font1 = pango_font_description_from_string ("Courier 10 Pitch 12");
gtk_widget_modify_font (textview1, textview_font1);
// Create new window to display fragmented packet.
window2 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable (GTK_WINDOW (window2), TRUE);
gtk_window_set_position (GTK_WINDOW (window2), GTK_WIN_POS_NONE);
gtk_window_set_title (GTK_WINDOW (window2), title);
gtk_window_set_default_size (GTK_WINDOW (window2), 1000,
200);
gtk_container_set_border_width (GTK_CONTAINER (window2), 1);
// Create a textview object to display fragmented packet.
textview2 = gtk_text_view_new ();
buffer2 = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview2));
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview2), TRUE);
textview_font2 = pango_font_description_from_string ("Courier 10 Pitch 12");
gtk_widget_modify_font (textview2, textview_font2);
I then do some stuff and then display the buffers within textviews within scrollbars within windows:
scrolled_win1 = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (scrolled_win1), textview1);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW
(scrolled_win1),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
gtk_container_add (GTK_CONTAINER (window1), scrolled_win1);
gtk_widget_show_all (window1);some text
scrolled_win2 = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (scrolled_win2), textview2);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win2),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
gtk_container_add (GTK_CONTAINER (window2), scrolled_win2);
gtk_widget_show_all
(window2);
I find that the two windows are always placed right on top of each other. I can drag the top one off the one underneath, but I'd like the window manager to choose placements that are separate.
Suggestions? Have I bungled something?
Thanks,
Dave
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome orghttps://mail.gnome.org/mailman/listinfo/gtk-app-devel-list