Mercurial > dwindows
comparison gtk/dw.c @ 410:47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
signals won't be removed for widgets that have multiple subparts with
signals attached, like comboboxes and the tree widget. This affects
dw_signal_disconnect_by_window() and dw_signal_disconnect_by_data().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 13 May 2003 05:32:22 +0000 |
parents | 1d7be77cbfb5 |
children | 9ffdbfd83652 |
comparison
equal
deleted
inserted
replaced
409:1d7be77cbfb5 | 410:47273b6a8500 |
---|---|
7756 DW_MUTEX_LOCK; | 7756 DW_MUTEX_LOCK; |
7757 gtk_timeout_remove(id); | 7757 gtk_timeout_remove(id); |
7758 DW_MUTEX_UNLOCK; | 7758 DW_MUTEX_UNLOCK; |
7759 } | 7759 } |
7760 | 7760 |
7761 /* Get the actual signal window handle not the user window handle | |
7762 * Should mimic the code in dw_signal_connect() below. | |
7763 */ | |
7764 static HWND _find_signal_window(HWND window, char *signame) | |
7765 { | |
7766 HWND thiswindow = window; | |
7767 | |
7768 if(GTK_IS_SCROLLED_WINDOW(thiswindow)) | |
7769 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); | |
7770 else if(GTK_IS_COMBO(thiswindow) && signame && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0) | |
7771 thiswindow = GTK_COMBO(thiswindow)->list; | |
7772 else if(GTK_IS_COMBO(thiswindow) && signame && strcmp(signame, DW_SIGNAL_SET_FOCUS) == 0) | |
7773 thiswindow = GTK_COMBO(thiswindow)->entry; | |
7774 else if(GTK_IS_VSCALE(thiswindow) || GTK_IS_HSCALE(thiswindow) || | |
7775 GTK_IS_VSCROLLBAR(thiswindow) || GTK_IS_HSCROLLBAR(thiswindow)) | |
7776 thiswindow = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_adjustment"); | |
7777 #if GTK_MAJOR_VERSION > 1 | |
7778 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0) | |
7779 thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow)); | |
7780 #endif | |
7781 return thiswindow; | |
7782 } | |
7783 | |
7761 /* | 7784 /* |
7762 * Add a callback to a window event. | 7785 * Add a callback to a window event. |
7763 * Parameters: | 7786 * Parameters: |
7764 * window: Window handle of signal to be called back. | 7787 * window: Window handle of signal to be called back. |
7765 * signame: A string pointer identifying which signal to be hooked. | 7788 * signame: A string pointer identifying which signal to be hooked. |
7907 * Parameters: | 7930 * Parameters: |
7908 * window: Window handle of callback to be removed. | 7931 * window: Window handle of callback to be removed. |
7909 */ | 7932 */ |
7910 void dw_signal_disconnect_by_name(HWND window, char *signame) | 7933 void dw_signal_disconnect_by_name(HWND window, char *signame) |
7911 { | 7934 { |
7912 int z, count = (int)gtk_object_get_data(GTK_OBJECT(window), "_dw_sigcounter"); | 7935 HWND thiswindow; |
7913 void *thisfunc = _findsigfunc(signame); | 7936 int z, count; |
7937 void *thisfunc; | |
7938 int _locked_by_me = FALSE; | |
7939 | |
7940 DW_MUTEX_LOCK; | |
7941 thiswindow = _find_signal_window(window, signame); | |
7942 count = (int)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter"); | |
7943 thisfunc = _findsigfunc(signame); | |
7914 | 7944 |
7915 for(z=0;z<count;z++) | 7945 for(z=0;z<count;z++) |
7916 { | 7946 { |
7917 SignalHandler sh = _get_signal_handler(window, (gpointer)z); | 7947 SignalHandler sh = _get_signal_handler(thiswindow, (gpointer)z); |
7918 | 7948 |
7919 if(sh.intfunc == thisfunc) | 7949 if(sh.intfunc == thisfunc) |
7920 _remove_signal_handler(window, z); | 7950 _remove_signal_handler(thiswindow, z); |
7921 } | 7951 } |
7952 DW_MUTEX_UNLOCK; | |
7922 } | 7953 } |
7923 | 7954 |
7924 /* | 7955 /* |
7925 * Removes all callbacks for a given window. | 7956 * Removes all callbacks for a given window. |
7926 * Parameters: | 7957 * Parameters: |
7927 * window: Window handle of callback to be removed. | 7958 * window: Window handle of callback to be removed. |
7928 */ | 7959 */ |
7929 void dw_signal_disconnect_by_window(HWND window) | 7960 void dw_signal_disconnect_by_window(HWND window) |
7930 { | 7961 { |
7931 int z, count = (int)gtk_object_get_data(GTK_OBJECT(window), "_dw_sigcounter"); | 7962 HWND thiswindow; |
7963 int z, count; | |
7964 int _locked_by_me = FALSE; | |
7965 | |
7966 DW_MUTEX_LOCK; | |
7967 thiswindow = _find_signal_window(window, NULL); | |
7968 count = (int)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter"); | |
7932 | 7969 |
7933 for(z=0;z<count;z++) | 7970 for(z=0;z<count;z++) |
7934 _remove_signal_handler(window, z); | 7971 _remove_signal_handler(thiswindow, z); |
7935 gtk_object_set_data(GTK_OBJECT(window), "_dw_sigcounter", NULL); | 7972 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_sigcounter", NULL); |
7973 DW_MUTEX_UNLOCK; | |
7936 } | 7974 } |
7937 | 7975 |
7938 /* | 7976 /* |
7939 * Removes all callbacks for a given window with specified data. | 7977 * Removes all callbacks for a given window with specified data. |
7940 * Parameters: | 7978 * Parameters: |
7941 * window: Window handle of callback to be removed. | 7979 * window: Window handle of callback to be removed. |
7942 * data: Pointer to the data to be compared against. | 7980 * data: Pointer to the data to be compared against. |
7943 */ | 7981 */ |
7944 void dw_signal_disconnect_by_data(HWND window, void *data) | 7982 void dw_signal_disconnect_by_data(HWND window, void *data) |
7945 { | 7983 { |
7946 int z, count = (int)gtk_object_get_data(GTK_OBJECT(window), "_dw_sigcounter"); | 7984 HWND thiswindow; |
7985 int z, count; | |
7986 int _locked_by_me = FALSE; | |
7987 | |
7988 DW_MUTEX_LOCK; | |
7989 thiswindow = _find_signal_window(window, NULL); | |
7990 count = (int)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter"); | |
7947 | 7991 |
7948 for(z=0;z<count;z++) | 7992 for(z=0;z<count;z++) |
7949 { | 7993 { |
7950 SignalHandler sh = _get_signal_handler(window, (gpointer)z); | 7994 SignalHandler sh = _get_signal_handler(thiswindow, (gpointer)z); |
7951 | 7995 |
7952 if(sh.data == data) | 7996 if(sh.data == data) |
7953 _remove_signal_handler(window, z); | 7997 _remove_signal_handler(thiswindow, z); |
7954 } | 7998 } |
7955 } | 7999 DW_MUTEX_UNLOCK; |
7956 | 8000 } |
8001 |