changing focus between windows: #2
- From: "frederik jensen" <frederik_jensen get2net dk>
- To: <gtk-list gnome org>
- Subject: changing focus between windows: #2
- Date: Wed, 18 Jul 2001 03:59:42 +0200
/***************************************
Hello gtk-list
Is it possible to determine which window is to be on top
when the program begins? In the example below I would like the
"window 1" to be on top. Of course, I could switch the two calls
for 'create_window', but I am sure there is a function to do
this, ...
I hope that somebody cares to answer.
Thank you.
Frederik Jensen. I am using version 1.2.8
**************************************************************/
#include <stdio.h>
#include <gtk/gtk.h>
GtkWidget *window_1;
GtkWidget *window_2;
gboolean gui_configure_event (GtkWidget *drawing_area,
GdkEventConfigure *event) {
printf ("configure event\n");
}
gboolean gui_expose_event (GtkWidget *widget,
GdkEventExpose *event) {
printf ("expose event\n");
}
gint gui_event_destroy_window (GtkWidget *widget,
GdkEvent *event,
gpointer client_data) {
gtk_main_quit (); return TRUE;
}
GtkWidget *create_window (char *window_name, int width, int height) {
/* WIDGET SET
*/
GtkWidget *window;
GtkWidget *drawing_area;
/* TOP LEVEL
*/
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize (window, width, height);
gtk_window_set_title (GTK_WINDOW (window), window_name);
gtk_widget_set_events (window,
GDK_KEY_PRESS_MASK
| GDK_KEY_RELEASE_MASK);
/* CONNECT WINDOW SIGNALS
*/
gtk_signal_connect (GTK_OBJECT (window),
"delete_event",
(GtkSignalFunc) gui_event_destroy_window,
(gpointer) window);
/* ALLOCATE DRAWING AREA
*/
drawing_area = gtk_drawing_area_new ();
gtk_widget_set_usize (drawing_area, width, height);
/* PACK DRAWING AREA IN WINDOW AND SHOW
*/
gtk_container_add (GTK_CONTAINER (window), drawing_area);
gtk_widget_show (drawing_area);
/* CONNECT CONFIGURE EVENT TO THE DRAWING AREA
*/
gtk_signal_connect (GTK_OBJECT (drawing_area),
"configure_event",
(GtkSignalFunc) gui_configure_event,
NULL);
gtk_signal_connect (GTK_OBJECT (drawing_area),
"expose_event",
(GtkSignalFunc) gui_expose_event,
NULL);
gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK);
/* RETURN
*/
return window;
}
main (int argc, char *argv[]) {
gtk_init (&argc, &argv);
window_1 = create_window ("window 1", 200, 200);
window_2 = create_window ("no 2", 300, 300);
gtk_widget_show (window_1);
gtk_widget_show (window_2);
gtk_main ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]