changeset 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 a3a299455c67
files gtk/dw.c
diffstat 1 files changed, 59 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Tue May 13 05:07:02 2003 +0000
+++ b/gtk/dw.c	Tue May 13 05:32:22 2003 +0000
@@ -7758,6 +7758,29 @@
 	DW_MUTEX_UNLOCK;
 }
 
+/* Get the actual signal window handle not the user window handle
+ * Should mimic the code in dw_signal_connect() below.
+ */
+static HWND _find_signal_window(HWND window, char *signame)
+{
+	HWND thiswindow = window;
+
+	if(GTK_IS_SCROLLED_WINDOW(thiswindow))
+		thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window));
+	else if(GTK_IS_COMBO(thiswindow) && signame && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0)
+		thiswindow = GTK_COMBO(thiswindow)->list;
+	else if(GTK_IS_COMBO(thiswindow) && signame && strcmp(signame, DW_SIGNAL_SET_FOCUS) == 0)
+		thiswindow = GTK_COMBO(thiswindow)->entry;
+	else if(GTK_IS_VSCALE(thiswindow) || GTK_IS_HSCALE(thiswindow) ||
+			GTK_IS_VSCROLLBAR(thiswindow) || GTK_IS_HSCROLLBAR(thiswindow))
+		thiswindow = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_adjustment");
+#if GTK_MAJOR_VERSION > 1
+	else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0)
+		thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow));
+#endif
+	return thiswindow;
+}
+
 /*
  * Add a callback to a window event.
  * Parameters:
@@ -7909,16 +7932,24 @@
  */
 void dw_signal_disconnect_by_name(HWND window, char *signame)
 {
-	int z, count = (int)gtk_object_get_data(GTK_OBJECT(window), "_dw_sigcounter");
-	void *thisfunc  = _findsigfunc(signame);
+	HWND thiswindow;
+	int z, count;
+	void *thisfunc;
+	int _locked_by_me = FALSE;
+
+	DW_MUTEX_LOCK;
+	thiswindow = _find_signal_window(window, signame);
+	count = (int)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter");
+	thisfunc  = _findsigfunc(signame);
 
 	for(z=0;z<count;z++)
 	{
-		SignalHandler sh = _get_signal_handler(window, (gpointer)z);
+		SignalHandler sh = _get_signal_handler(thiswindow, (gpointer)z);
 
 		if(sh.intfunc == thisfunc)
-			_remove_signal_handler(window, z);
-	}
+			_remove_signal_handler(thiswindow, z);
+	}
+	DW_MUTEX_UNLOCK;
 }
 
 /*
@@ -7928,11 +7959,18 @@
  */
 void dw_signal_disconnect_by_window(HWND window)
 {
-	int z, count = (int)gtk_object_get_data(GTK_OBJECT(window), "_dw_sigcounter");
+	HWND thiswindow;
+	int z, count;
+	int _locked_by_me = FALSE;
+
+	DW_MUTEX_LOCK;
+	thiswindow = _find_signal_window(window, NULL);
+	count = (int)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter");
 
 	for(z=0;z<count;z++)
-		_remove_signal_handler(window, z);
-	gtk_object_set_data(GTK_OBJECT(window), "_dw_sigcounter", NULL);
+		_remove_signal_handler(thiswindow, z);
+	gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_sigcounter", NULL);
+	DW_MUTEX_UNLOCK;
 }
 
 /*
@@ -7943,14 +7981,21 @@
  */
 void dw_signal_disconnect_by_data(HWND window, void *data)
 {
-	int z, count = (int)gtk_object_get_data(GTK_OBJECT(window), "_dw_sigcounter");
+	HWND thiswindow;
+	int z, count;
+	int _locked_by_me = FALSE;
+
+	DW_MUTEX_LOCK;
+	thiswindow = _find_signal_window(window, NULL);
+	count = (int)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter");
 
 	for(z=0;z<count;z++)
 	{
-		SignalHandler sh = _get_signal_handler(window, (gpointer)z);
+		SignalHandler sh = _get_signal_handler(thiswindow, (gpointer)z);
 
 		if(sh.data == data)
-			_remove_signal_handler(window, z);
-	}
-}
-
+			_remove_signal_handler(thiswindow, z);
+	}
+	DW_MUTEX_UNLOCK;
+}
+