Mercurial > dwindows
comparison gtk/dw.c @ 307:324587c06cea
Use the signal #defines internally so all that is required to change
the signal strings is a header file change.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 31 Mar 2003 08:21:55 +0000 |
parents | d2392cf845e4 |
children | 77105fe19c1f |
comparison
equal
deleted
inserted
replaced
306:9d13efce2894 | 307:324587c06cea |
---|---|
122 | 122 |
123 #define SIGNALMAX 16 | 123 #define SIGNALMAX 16 |
124 | 124 |
125 /* A list of signal forwarders, to account for paramater differences. */ | 125 /* A list of signal forwarders, to account for paramater differences. */ |
126 static SignalList SignalTranslate[SIGNALMAX] = { | 126 static SignalList SignalTranslate[SIGNALMAX] = { |
127 { _configure_event, "configure_event" }, | 127 { _configure_event, DW_SIGNAL_CONFIGURE }, |
128 { _key_press_event, "key_press_event" }, | 128 { _key_press_event, DW_SIGNAL_KEY_PRESS }, |
129 { _button_press_event, "button_press_event" }, | 129 { _button_press_event, DW_SIGNAL_BUTTON_PRESS }, |
130 { _button_release_event, "button_release_event" }, | 130 { _button_release_event, DW_SIGNAL_BUTTON_RELEASE }, |
131 { _motion_notify_event, "motion_notify_event" }, | 131 { _motion_notify_event, DW_SIGNAL_MOTION_NOTIFY }, |
132 { _delete_event, "delete_event" }, | 132 { _delete_event, DW_SIGNAL_DELETE }, |
133 { _expose_event, "expose_event" }, | 133 { _expose_event, DW_SIGNAL_EXPOSE }, |
134 { _activate_event, "activate" }, | 134 { _activate_event, "activate" }, |
135 { _generic_event, "clicked" }, | 135 { _generic_event, DW_SIGNAL_CLICKED }, |
136 { _container_select_event, "container-select" }, | 136 { _container_select_event, DW_SIGNAL_ITEM_ENTER }, |
137 { _container_context_event, "container-context" }, | 137 { _container_context_event, DW_SIGNAL_ITEM_CONTEXT }, |
138 { _tree_context_event, "tree-context" }, | 138 { _tree_context_event, "tree-context" }, |
139 { _item_select_event, "item-select" }, | 139 { _item_select_event, DW_SIGNAL_LIST_SELECT }, |
140 { _tree_select_event, "tree-select" }, | 140 { _tree_select_event, DW_SIGNAL_ITEM_SELECT }, |
141 { _set_focus_event, "set-focus" }, | 141 { _set_focus_event, DW_SIGNAL_SET_FOCUS }, |
142 { _value_changed_event, "value_changed" } | 142 { _value_changed_event, DW_SIGNAL_VALUE_CHANGED } |
143 }; | 143 }; |
144 | 144 |
145 /* Alignment flags */ | 145 /* Alignment flags */ |
146 #define DW_CENTER 0.5f | 146 #define DW_CENTER 0.5f |
147 #define DW_LEFT 0.0f | 147 #define DW_LEFT 0.0f |
1024 | 1024 |
1025 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, FALSE, 2); | 1025 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, FALSE, 2); |
1026 | 1026 |
1027 dwwait = dw_dialog_new((void *)entrywindow); | 1027 dwwait = dw_dialog_new((void *)entrywindow); |
1028 | 1028 |
1029 dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(_dw_ok_func), (void *)dwwait); | 1029 dw_signal_connect(okbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_ok_func), (void *)dwwait); |
1030 | 1030 |
1031 x = (dw_screen_width() - 220)/2; | 1031 x = (dw_screen_width() - 220)/2; |
1032 y = (dw_screen_height() - 110)/2; | 1032 y = (dw_screen_height() - 110)/2; |
1033 | 1033 |
1034 dw_window_set_pos_size(entrywindow, x, y, 220, 110); | 1034 dw_window_set_pos_size(entrywindow, x, y, 220, 110); |
1104 | 1104 |
1105 dw_box_pack_start(buttonbox, nobutton, 50, 30, TRUE, FALSE, 2); | 1105 dw_box_pack_start(buttonbox, nobutton, 50, 30, TRUE, FALSE, 2); |
1106 | 1106 |
1107 dwwait = dw_dialog_new((void *)entrywindow); | 1107 dwwait = dw_dialog_new((void *)entrywindow); |
1108 | 1108 |
1109 dw_signal_connect(yesbutton, "clicked", DW_SIGNAL_FUNC(_dw_yes_func), (void *)dwwait); | 1109 dw_signal_connect(yesbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_yes_func), (void *)dwwait); |
1110 dw_signal_connect(nobutton, "clicked", DW_SIGNAL_FUNC(_dw_no_func), (void *)dwwait); | 1110 dw_signal_connect(nobutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_no_func), (void *)dwwait); |
1111 | 1111 |
1112 x = (dw_screen_width() - 220)/2; | 1112 x = (dw_screen_width() - 220)/2; |
1113 y = (dw_screen_height() - 110)/2; | 1113 y = (dw_screen_height() - 110)/2; |
1114 | 1114 |
1115 dw_window_set_pos_size(entrywindow, x, y, 220, 110); | 1115 dw_window_set_pos_size(entrywindow, x, y, 220, 110); |
7506 if(GTK_IS_SCROLLED_WINDOW(thiswindow)) | 7506 if(GTK_IS_SCROLLED_WINDOW(thiswindow)) |
7507 { | 7507 { |
7508 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); | 7508 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); |
7509 } | 7509 } |
7510 | 7510 |
7511 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, "clicked") == 0) | 7511 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, DW_SIGNAL_CLICKED) == 0) |
7512 { | 7512 { |
7513 thisname = "activate"; | 7513 thisname = "activate"; |
7514 thisfunc = _findsigfunc(thisname); | 7514 thisfunc = _findsigfunc(thisname); |
7515 } | 7515 } |
7516 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-context") == 0) | 7516 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0) |
7517 { | 7517 { |
7518 thisname = "button_press_event"; | 7518 thisname = "button_press_event"; |
7519 thisfunc = _findsigfunc("container-context"); | 7519 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_CONTEXT); |
7520 } | 7520 } |
7521 #if GTK_MAJOR_VERSION > 1 | 7521 #if GTK_MAJOR_VERSION > 1 |
7522 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, "container-context") == 0) | 7522 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0) |
7523 { | 7523 { |
7524 thisfunc = _findsigfunc("tree-context"); | 7524 thisfunc = _findsigfunc("tree-context"); |
7525 | 7525 |
7526 work->window = window; | 7526 work->window = window; |
7527 work->data = data; | 7527 work->data = data; |
7530 gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work); | 7530 gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work); |
7531 gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work); | 7531 gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work); |
7532 DW_MUTEX_UNLOCK; | 7532 DW_MUTEX_UNLOCK; |
7533 return; | 7533 return; |
7534 } | 7534 } |
7535 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, "tree-select") == 0) | 7535 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0) |
7536 { | 7536 { |
7537 work->window = window; | 7537 work->window = window; |
7538 work->data = data; | 7538 work->data = data; |
7539 work->func = sigfunc; | 7539 work->func = sigfunc; |
7540 | 7540 |
7544 g_signal_connect(G_OBJECT(thiswindow), thisname, (GCallback)thisfunc, work); | 7544 g_signal_connect(G_OBJECT(thiswindow), thisname, (GCallback)thisfunc, work); |
7545 DW_MUTEX_UNLOCK; | 7545 DW_MUTEX_UNLOCK; |
7546 return; | 7546 return; |
7547 } | 7547 } |
7548 #else | 7548 #else |
7549 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, "container-context") == 0) | 7549 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0) |
7550 { | 7550 { |
7551 thisfunc = _findsigfunc("tree-context"); | 7551 thisfunc = _findsigfunc("tree-context"); |
7552 | 7552 |
7553 work->window = window; | 7553 work->window = window; |
7554 work->data = data; | 7554 work->data = data; |
7559 gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work); | 7559 gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work); |
7560 gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work); | 7560 gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work); |
7561 DW_MUTEX_UNLOCK; | 7561 DW_MUTEX_UNLOCK; |
7562 return; | 7562 return; |
7563 } | 7563 } |
7564 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, "tree-select") == 0) | 7564 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0) |
7565 { | 7565 { |
7566 if(thisfunc) | 7566 if(thisfunc) |
7567 { | 7567 { |
7568 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-func", (gpointer)thisfunc); | 7568 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-func", (gpointer)thisfunc); |
7569 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-data", (gpointer)work); | 7569 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-data", (gpointer)work); |
7570 } | 7570 } |
7571 thisname = "select-child"; | 7571 thisname = "select-child"; |
7572 } | 7572 } |
7573 #endif | 7573 #endif |
7574 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-select") == 0) | 7574 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_ENTER) == 0) |
7575 { | 7575 { |
7576 thisname = "button_press_event"; | 7576 thisname = "button_press_event"; |
7577 thisfunc = _findsigfunc("container-select"); | 7577 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_ENTER); |
7578 } | 7578 } |
7579 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "tree-select") == 0) | 7579 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0) |
7580 { | 7580 { |
7581 thisname = "select_row"; | 7581 thisname = "select_row"; |
7582 thisfunc = (void *)_container_select_row; | 7582 thisfunc = (void *)_container_select_row; |
7583 } | 7583 } |
7584 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, "item-select") == 0) | 7584 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0) |
7585 { | 7585 { |
7586 thisname = "select_child"; | 7586 thisname = "select_child"; |
7587 thiswindow = GTK_COMBO(thiswindow)->list; | 7587 thiswindow = GTK_COMBO(thiswindow)->list; |
7588 } | 7588 } |
7589 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, "item-select") == 0) | 7589 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0) |
7590 { | 7590 { |
7591 thisname = "select_child"; | 7591 thisname = "select_child"; |
7592 } | 7592 } |
7593 else if(strcmp(signame, "set-focus") == 0) | 7593 else if(strcmp(signame, DW_SIGNAL_SET_FOCUS) == 0) |
7594 { | 7594 { |
7595 thisname = "focus-in-event"; | 7595 thisname = "focus-in-event"; |
7596 if(GTK_IS_COMBO(thiswindow)) | 7596 if(GTK_IS_COMBO(thiswindow)) |
7597 thiswindow = GTK_COMBO(thiswindow)->entry; | 7597 thiswindow = GTK_COMBO(thiswindow)->entry; |
7598 } | 7598 } |
7599 else if(strcmp(signame, "lose-focus") == 0) | 7599 #if 0 |
7600 else if(strcmp(signame, DW_SIGNAL_LOSE_FOCUS) == 0) | |
7600 { | 7601 { |
7601 thisname = "focus-out-event"; | 7602 thisname = "focus-out-event"; |
7602 if(GTK_IS_COMBO(thiswindow)) | 7603 if(GTK_IS_COMBO(thiswindow)) |
7603 thiswindow = GTK_COMBO(thiswindow)->entry; | 7604 thiswindow = GTK_COMBO(thiswindow)->entry; |
7604 } | 7605 } |
7606 #endif | |
7605 else if(GTK_IS_VSCALE(thiswindow) || GTK_IS_HSCALE(thiswindow) || | 7607 else if(GTK_IS_VSCALE(thiswindow) || GTK_IS_HSCALE(thiswindow) || |
7606 GTK_IS_VSCROLLBAR(thiswindow) || GTK_IS_HSCROLLBAR(thiswindow)) | 7608 GTK_IS_VSCROLLBAR(thiswindow) || GTK_IS_HSCROLLBAR(thiswindow)) |
7607 { | 7609 { |
7608 thiswindow = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(thiswindow), "adjustment"); | 7610 thiswindow = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(thiswindow), "adjustment"); |
7609 } | 7611 } |