Problem with GTK+-2.0
- From: Dany Mezher <Dany Mezher irisa fr>
- To: GTKAppDevel <gtk-app-devel-list gnome org>
- Subject: Problem with GTK+-2.0
- Date: Thu, 31 Jul 2003 09:48:51 +0200
Hello,
I am writing a scientific application using glade-2.0 and GTK+-2.0.
I have a problem regarding the "CHILD" window which doesn't seem to bee
sensitive. Here is a samble code.
Any Suggestions???
Regards
Dani MEZHER
=====================================
#include <gtk/gtk.h>
gint NewLevelCurve(GtkWidget *w,void *d)
{
GtkWidget *window1;
GtkWidget *button1;
printf("New Level Curve...\n");
window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window1), "window1");
button1 = gtk_button_new_with_mnemonic ("button1");
gtk_widget_show (button1);
gtk_container_add (GTK_CONTAINER (window1), button1);
g_signal_connect_swapped ((gpointer) button1, "clicked",
G_CALLBACK (gtk_widget_destroy),
GTK_OBJECT (window1));
gtk_widget_show(window1);
return FALSE;
}
GtkWidget *MainWind(int Xmin,int Xmax,int Ymin,int Ymax)
{
GtkWidget *widget;
GtkWidget *vbox1;
GtkWidget *menubar1;
GtkWidget *menuitem1;
GtkWidget *menuitem1_menu;
GtkWidget *new1;
GtkWidget *save_as1;
GtkWidget *separatormenuitem1;
GtkWidget *quit1;
GtkWidget *menuitem4;
GtkWidget *menuitem4_menu;
GtkWidget *about1;
GtkWidget *toolbar1;
GtkWidget *AddLevelCurve;
GtkWidget *SaveLevelCurves;
GtkWidget *ZoomIn;
GtkWidget *ZoomOut;
GtkWidget *Properties;
GtkWidget *Preferences;
GtkWidget *Print;
GtkWidget *table1;
GtkWidget *vruler1;
GtkWidget *hruler1;
GtkWidget *drawingarea1;
GtkWidget *statusbar1;
GtkAccelGroup *accel_group;
accel_group = gtk_accel_group_new ();
widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (widget), "window1");
gtk_window_set_modal (GTK_WINDOW (widget), TRUE);
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox1);
gtk_container_add (GTK_CONTAINER (widget), vbox1);
menubar1 = gtk_menu_bar_new ();
gtk_widget_show (menubar1);
gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0);
menuitem1 = gtk_menu_item_new_with_mnemonic ("_File");
gtk_widget_show (menuitem1);
gtk_container_add (GTK_CONTAINER (menubar1), menuitem1);
menuitem1_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menuitem1_menu);
new1 = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group);
gtk_widget_show (new1);
gtk_container_add (GTK_CONTAINER (menuitem1_menu), new1);
save_as1 = gtk_image_menu_item_new_from_stock ("gtk-save-as",
accel_group);
gtk_widget_show (save_as1);
gtk_container_add (GTK_CONTAINER (menuitem1_menu), save_as1);
separatormenuitem1 = gtk_menu_item_new ();
gtk_widget_show (separatormenuitem1);
gtk_container_add (GTK_CONTAINER (menuitem1_menu),
separatormenuitem1);
gtk_widget_set_sensitive (separatormenuitem1, FALSE);
quit1 = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
gtk_widget_show (quit1);
gtk_container_add (GTK_CONTAINER (menuitem1_menu), quit1);
menuitem4 = gtk_menu_item_new_with_mnemonic ("_Help");
gtk_widget_show (menuitem4);
gtk_container_add (GTK_CONTAINER (menubar1), menuitem4);
menuitem4_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu);
about1 = gtk_menu_item_new_with_mnemonic ("_About");
gtk_widget_show (about1);
gtk_container_add (GTK_CONTAINER (menuitem4_menu), about1);
toolbar1 = gtk_toolbar_new ();
gtk_widget_show (toolbar1);
gtk_box_pack_start (GTK_BOX (vbox1), toolbar1, FALSE, FALSE, 0);
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_BOTH);
AddLevelCurve = gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar1),
"gtk-add",
NULL,
NULL, NULL, NULL, -1);
gtk_widget_show (AddLevelCurve);
SaveLevelCurves = gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar1),
"gtk-save",
NULL,
NULL, NULL, NULL, -1);
gtk_widget_show (SaveLevelCurves);
ZoomIn = gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar1),
"gtk-zoom-in",
NULL,
NULL, NULL, NULL, -1);
gtk_widget_show (ZoomIn);
ZoomOut = gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar1),
"gtk-zoom-out",
NULL,
NULL, NULL, NULL, -1);
gtk_widget_show (ZoomOut);
Properties = gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar1),
"gtk-properties",
NULL,
NULL, NULL, NULL, -1);
gtk_widget_show (Properties);
Preferences = gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar1),
"gtk-preferences",
NULL,
NULL, NULL, NULL, -1);
gtk_widget_show (Preferences);
Print = gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar1),
"gtk-print",
NULL,
NULL, NULL, NULL, -1);
gtk_widget_show (Print);
table1 = gtk_table_new (2, 2, FALSE);
gtk_widget_show (table1);
gtk_box_pack_start (GTK_BOX (vbox1), table1, TRUE, TRUE, 0);
vruler1 = gtk_vruler_new ();
gtk_widget_show (vruler1);
gtk_table_attach (GTK_TABLE (table1), vruler1, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
gtk_ruler_set_range (GTK_RULER (vruler1), Ymax, Ymin, 4.66667,
Ymax-Ymin);
hruler1 = gtk_hruler_new ();
gtk_widget_show (hruler1);
gtk_table_attach (GTK_TABLE (table1), hruler1, 0, 1, 1, 2,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (GTK_FILL), 0, 0);
gtk_ruler_set_range (GTK_RULER (hruler1), Xmin, Xmax, 2.43531,
Xmax-Xmin);
drawingarea1 = gtk_drawing_area_new ();
gtk_widget_show (drawingarea1);
gtk_widget_set_size_request (drawingarea1, (long)((Xmax-Xmin+1)*10),
(long)((Ymax-Ymin+1)*10));
gtk_table_attach (GTK_TABLE (table1), drawingarea1, 0, 1, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (GTK_FILL), 0, 0);
gtk_widget_set_events (drawingarea1, GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK);
statusbar1 = gtk_statusbar_new ();
gtk_widget_show (statusbar1);
gtk_box_pack_start (GTK_BOX (vbox1), statusbar1, FALSE, FALSE, 0);
g_signal_connect((gpointer) widget, "delete_event",
G_CALLBACK(gtk_main_quit),
NULL);
g_signal_connect((gpointer) widget, "destroy_event",
G_CALLBACK(gtk_main_quit),
NULL);
g_signal_connect ((gpointer) new1, "activate",
G_CALLBACK (NewLevelCurve),
NULL);
g_signal_connect_swapped(G_OBJECT(drawingarea1),"motion_notify_event",
G_CALLBACK(GTK_WIDGET_GET_CLASS(vruler1)->motion_notify_event),
G_OBJECT(vruler1));
g_signal_connect_swapped(G_OBJECT(drawingarea1),"motion_notify_event",
G_CALLBACK(GTK_WIDGET_GET_CLASS(hruler1)->motion_notify_event),
G_OBJECT(hruler1));
gtk_window_add_accel_group (GTK_WINDOW (widget), accel_group);
return widget;
}
main(int argc,char **argv)
{
GtkWidget *w;
gtk_init(&argc,&argv);
w=MainWind(-40,40,-30,30);
gtk_widget_show(w);
gtk_main();
}
========================
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]