Mercurial > dwindows
comparison gtk/dw.c @ 1853:4790589f52a9
Initial commit for new dw_signal_connect_data() function...
Same as dw_signal_connect() but it has an additional callback
parameter that gets called when the callback is being removed.
This allows me to free memory allocated for the data parameter
and prevent memory leaks in godwindows... Tested GTK and Mac.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 27 Feb 2013 19:14:22 +0000 |
parents | ff80ad40a5d6 |
children | c836603d3f14 |
comparison
equal
deleted
inserted
replaced
1852:5f0e4ca14dcd | 1853:4790589f52a9 |
---|---|
1 /* | 1 /* |
2 * Dynamic Windows: | 2 * Dynamic Windows: |
3 * A GTK like cross-platform GUI | 3 * A GTK like cross-platform GUI |
4 * GTK forwarder module for portabilty. | 4 * GTK forwarder module for portabilty. |
5 * | 5 * |
6 * (C) 2000-2012 Brian Smith <brian@dbsoft.org> | 6 * (C) 2000-2013 Brian Smith <brian@dbsoft.org> |
7 * (C) 2003-2011 Mark Hessling <mark@rexx.org> | 7 * (C) 2003-2011 Mark Hessling <mark@rexx.org> |
8 * (C) 2002 Nickolay V. Shmyrev <shmyrev@yandex.ru> | 8 * (C) 2002 Nickolay V. Shmyrev <shmyrev@yandex.ru> |
9 */ | 9 */ |
10 #include "config.h" | 10 #include "config.h" |
11 #include "dw.h" | 11 #include "dw.h" |
175 static gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data); | 175 static gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data); |
176 static gint _tree_expand_event(GtkTreeItem *treeitem, gpointer data); | 176 static gint _tree_expand_event(GtkTreeItem *treeitem, gpointer data); |
177 #endif | 177 #endif |
178 static gint _switch_page_event(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data); | 178 static gint _switch_page_event(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data); |
179 static gint _column_click_event(GtkWidget *widget, gint column_num, gpointer data); | 179 static gint _column_click_event(GtkWidget *widget, gint column_num, gpointer data); |
180 static void _dw_signal_disconnect(gpointer data, GClosure *closure); | |
180 | 181 |
181 /* Embedable Mozilla functions*/ | 182 /* Embedable Mozilla functions*/ |
182 #ifdef USE_GTKMOZEMBED | 183 #ifdef USE_GTKMOZEMBED |
183 void (*_gtk_moz_embed_go_back)(GtkMozEmbed *) = NULL; | 184 void (*_gtk_moz_embed_go_back)(GtkMozEmbed *) = NULL; |
184 void (*_gtk_moz_embed_go_forward)(GtkMozEmbed *) = NULL; | 185 void (*_gtk_moz_embed_go_forward)(GtkMozEmbed *) = NULL; |
1221 return SignalTranslate[z].func; | 1222 return SignalTranslate[z].func; |
1222 } | 1223 } |
1223 return NULL; | 1224 return NULL; |
1224 } | 1225 } |
1225 | 1226 |
1226 static SignalHandler _get_signal_handler(GtkWidget *widget, gpointer data) | 1227 static SignalHandler _get_signal_handler(gpointer data) |
1227 { | 1228 { |
1228 int counter = GPOINTER_TO_INT(data); | 1229 SignalHandler sh = {0}; |
1229 SignalHandler sh; | 1230 |
1230 char text[101] = {0}; | 1231 if(data) |
1231 | 1232 { |
1232 snprintf(text, 100, "_dw_sigwindow%d", counter); | 1233 void **params = (void **)data; |
1233 sh.window = (HWND)gtk_object_get_data(GTK_OBJECT(widget), text); | 1234 int counter = GPOINTER_TO_INT(params[0]); |
1234 snprintf(text, 100, "_dw_sigfunc%d", counter); | 1235 GtkWidget *widget = (GtkWidget *)params[2]; |
1235 sh.func = (void *)gtk_object_get_data(GTK_OBJECT(widget), text); | 1236 char text[101] = {0}; |
1236 snprintf(text, 100, "_dw_intfunc%d", counter); | 1237 |
1237 sh.intfunc = (void *)gtk_object_get_data(GTK_OBJECT(widget), text); | 1238 snprintf(text, 100, "_dw_sigwindow%d", counter); |
1238 snprintf(text, 100, "_dw_sigdata%d", counter); | 1239 sh.window = (HWND)gtk_object_get_data(GTK_OBJECT(widget), text); |
1239 sh.data = gtk_object_get_data(GTK_OBJECT(widget), text); | 1240 snprintf(text, 100, "_dw_sigfunc%d", counter); |
1240 snprintf(text, 100, "_dw_sigcid%d", counter); | 1241 sh.func = (void *)gtk_object_get_data(GTK_OBJECT(widget), text); |
1241 sh.cid = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), text)); | 1242 snprintf(text, 100, "_dw_intfunc%d", counter); |
1242 | 1243 sh.intfunc = (void *)gtk_object_get_data(GTK_OBJECT(widget), text); |
1244 snprintf(text, 100, "_dw_sigdata%d", counter); | |
1245 sh.data = gtk_object_get_data(GTK_OBJECT(widget), text); | |
1246 snprintf(text, 100, "_dw_sigcid%d", counter); | |
1247 sh.cid = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), text)); | |
1248 } | |
1243 return sh; | 1249 return sh; |
1244 } | 1250 } |
1245 | 1251 |
1246 static void _remove_signal_handler(GtkWidget *widget, int counter) | 1252 static void _remove_signal_handler(GtkWidget *widget, int counter) |
1247 { | 1253 { |
1290 gtk_object_set_data(GTK_OBJECT(widget), text, GINT_TO_POINTER(cid)); | 1296 gtk_object_set_data(GTK_OBJECT(widget), text, GINT_TO_POINTER(cid)); |
1291 } | 1297 } |
1292 | 1298 |
1293 static gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data) | 1299 static gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data) |
1294 { | 1300 { |
1295 SignalHandler work = _get_signal_handler((GtkWidget *)window, data); | 1301 SignalHandler work = _get_signal_handler(data); |
1296 int retval = FALSE; | 1302 int retval = FALSE; |
1297 | 1303 |
1298 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1304 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1299 if(work.window) | 1305 if(work.window) |
1300 { | 1306 { |
1305 return retval; | 1311 return retval; |
1306 } | 1312 } |
1307 | 1313 |
1308 static gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) | 1314 static gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
1309 { | 1315 { |
1310 SignalHandler work = _get_signal_handler(widget, data); | 1316 SignalHandler work = _get_signal_handler(data); |
1311 int retval = FALSE; | 1317 int retval = FALSE; |
1312 | 1318 |
1313 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1319 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1314 if(work.window) | 1320 if(work.window) |
1315 { | 1321 { |
1326 return retval; | 1332 return retval; |
1327 } | 1333 } |
1328 | 1334 |
1329 static gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data) | 1335 static gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
1330 { | 1336 { |
1331 SignalHandler work = _get_signal_handler(widget, data); | 1337 SignalHandler work = _get_signal_handler(data); |
1332 int retval = FALSE; | 1338 int retval = FALSE; |
1333 | 1339 |
1334 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1340 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1335 if(work.window) | 1341 if(work.window) |
1336 { | 1342 { |
1347 return retval; | 1353 return retval; |
1348 } | 1354 } |
1349 | 1355 |
1350 static gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) | 1356 static gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) |
1351 { | 1357 { |
1352 SignalHandler work = _get_signal_handler(widget, data); | 1358 SignalHandler work = _get_signal_handler(data); |
1353 int retval = FALSE; | 1359 int retval = FALSE; |
1354 | 1360 |
1355 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1361 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1356 if(work.window) | 1362 if(work.window) |
1357 { | 1363 { |
1380 return retval; | 1386 return retval; |
1381 } | 1387 } |
1382 | 1388 |
1383 static gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) | 1389 static gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) |
1384 { | 1390 { |
1385 SignalHandler work = _get_signal_handler(widget, data); | 1391 SignalHandler work = _get_signal_handler(data); |
1386 int retval = FALSE; | 1392 int retval = FALSE; |
1387 | 1393 |
1388 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1394 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1389 if(work.window) | 1395 if(work.window) |
1390 { | 1396 { |
1395 return retval; | 1401 return retval; |
1396 } | 1402 } |
1397 | 1403 |
1398 static gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data) | 1404 static gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data) |
1399 { | 1405 { |
1400 SignalHandler work = _get_signal_handler(widget, data); | 1406 SignalHandler work = _get_signal_handler(data); |
1401 int retval = FALSE; | 1407 int retval = FALSE; |
1402 | 1408 |
1403 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1409 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1404 if(work.window) | 1410 if(work.window) |
1405 { | 1411 { |
1415 return retval; | 1421 return retval; |
1416 } | 1422 } |
1417 | 1423 |
1418 static gint _generic_event(GtkWidget *widget, gpointer data) | 1424 static gint _generic_event(GtkWidget *widget, gpointer data) |
1419 { | 1425 { |
1420 SignalHandler work = _get_signal_handler(widget, data); | 1426 SignalHandler work = _get_signal_handler(data); |
1421 int retval = FALSE; | 1427 int retval = FALSE; |
1422 | 1428 |
1423 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1429 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1424 if(work.window) | 1430 if(work.window) |
1425 { | 1431 { |
1430 return retval; | 1436 return retval; |
1431 } | 1437 } |
1432 | 1438 |
1433 static gint _activate_event(GtkWidget *widget, gpointer data) | 1439 static gint _activate_event(GtkWidget *widget, gpointer data) |
1434 { | 1440 { |
1435 SignalHandler work = _get_signal_handler(widget, data); | 1441 SignalHandler work = _get_signal_handler(data); |
1436 int retval = FALSE; | 1442 int retval = FALSE; |
1437 | 1443 |
1438 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1444 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1439 if(work.window && !_dw_ignore_click) | 1445 if(work.window && !_dw_ignore_click) |
1440 { | 1446 { |
1446 return retval; | 1452 return retval; |
1447 } | 1453 } |
1448 | 1454 |
1449 static gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) | 1455 static gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) |
1450 { | 1456 { |
1451 SignalHandler work = _get_signal_handler(widget, data); | 1457 SignalHandler work = _get_signal_handler(data); |
1452 int retval = FALSE; | 1458 int retval = FALSE; |
1453 | 1459 |
1454 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1460 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1455 if(work.window) | 1461 if(work.window) |
1456 { | 1462 { |
1461 return retval; | 1467 return retval; |
1462 } | 1468 } |
1463 | 1469 |
1464 static gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) | 1470 static gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) |
1465 { | 1471 { |
1466 SignalHandler work = _get_signal_handler(widget, data); | 1472 SignalHandler work = _get_signal_handler(data); |
1467 int retval = FALSE; | 1473 int retval = FALSE; |
1468 | 1474 |
1469 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1475 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1470 if(work.window) | 1476 if(work.window) |
1471 { | 1477 { |
1481 return retval; | 1487 return retval; |
1482 } | 1488 } |
1483 | 1489 |
1484 static gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data) | 1490 static gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data) |
1485 { | 1491 { |
1486 SignalHandler work = _get_signal_handler(widget, data); | 1492 SignalHandler work = _get_signal_handler(data); |
1487 static int _dw_recursing = 0; | 1493 static int _dw_recursing = 0; |
1488 int retval = FALSE; | 1494 int retval = FALSE; |
1489 | 1495 |
1490 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1496 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1491 if(_dw_recursing) | 1497 if(_dw_recursing) |
1526 return retval; | 1532 return retval; |
1527 } | 1533 } |
1528 | 1534 |
1529 static gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data) | 1535 static gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
1530 { | 1536 { |
1531 SignalHandler work = _get_signal_handler(widget, data); | 1537 SignalHandler work = _get_signal_handler(data); |
1532 int retval = FALSE; | 1538 int retval = FALSE; |
1533 | 1539 |
1534 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1540 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1535 if(work.window) | 1541 if(work.window) |
1536 { | 1542 { |
1549 return retval; | 1555 return retval; |
1550 } | 1556 } |
1551 | 1557 |
1552 static gint _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data) | 1558 static gint _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
1553 { | 1559 { |
1554 SignalHandler work = _get_signal_handler(widget, data); | 1560 SignalHandler work = _get_signal_handler(data); |
1555 int retval = FALSE; | 1561 int retval = FALSE; |
1556 | 1562 |
1557 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1563 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1558 if(work.window) | 1564 if(work.window) |
1559 { | 1565 { |
1612 int retval = FALSE; | 1618 int retval = FALSE; |
1613 | 1619 |
1614 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1620 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1615 if(widget) | 1621 if(widget) |
1616 { | 1622 { |
1617 SignalHandler work = _get_signal_handler(widget, data); | 1623 SignalHandler work = _get_signal_handler(data); |
1618 | 1624 |
1619 if(work.window) | 1625 if(work.window) |
1620 { | 1626 { |
1621 int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = work.func; | 1627 int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = work.func; |
1622 GtkTreeIter iter; | 1628 GtkTreeIter iter; |
1634 return retval; | 1640 return retval; |
1635 } | 1641 } |
1636 | 1642 |
1637 static gint _tree_expand_event(GtkTreeView *widget, GtkTreeIter *iter, GtkTreePath *path, gpointer data) | 1643 static gint _tree_expand_event(GtkTreeView *widget, GtkTreeIter *iter, GtkTreePath *path, gpointer data) |
1638 { | 1644 { |
1639 SignalHandler work = _get_signal_handler((GtkWidget *)widget, data); | 1645 SignalHandler work = _get_signal_handler(data); |
1640 int retval = FALSE; | 1646 int retval = FALSE; |
1641 | 1647 |
1642 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1648 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1643 if(!_dw_ignore_expand && work.window) | 1649 if(!_dw_ignore_expand && work.window) |
1644 { | 1650 { |
1648 return retval; | 1654 return retval; |
1649 } | 1655 } |
1650 #else | 1656 #else |
1651 static gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data) | 1657 static gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data) |
1652 { | 1658 { |
1653 SignalHandler work = _get_signal_handler((GtkWidget *)tree, data); | 1659 SignalHandler work = _get_signal_handler(data); |
1654 GtkWidget *treeroot = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(child), "_dw_tree"); | 1660 GtkWidget *treeroot = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(child), "_dw_tree"); |
1655 int retval = FALSE; | 1661 int retval = FALSE; |
1656 | 1662 |
1657 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1663 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1658 if(treeroot && GTK_IS_TREE(treeroot)) | 1664 if(treeroot && GTK_IS_TREE(treeroot)) |
1673 return retval; | 1679 return retval; |
1674 } | 1680 } |
1675 | 1681 |
1676 static gint _tree_expand_event(GtkTreeItem *treeitem, gpointer data) | 1682 static gint _tree_expand_event(GtkTreeItem *treeitem, gpointer data) |
1677 { | 1683 { |
1678 SignalHandler work = _get_signal_handler((GtkWidget *)treeitem, data); | 1684 SignalHandler work = _get_signal_handler(data); |
1679 int retval = FALSE; | 1685 int retval = FALSE; |
1680 | 1686 |
1681 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1687 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1682 if(!_dw_ignore_expand && work.window) | 1688 if(!_dw_ignore_expand && work.window) |
1683 { | 1689 { |
1688 } | 1694 } |
1689 #endif | 1695 #endif |
1690 | 1696 |
1691 static gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data) | 1697 static gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
1692 { | 1698 { |
1693 SignalHandler work = _get_signal_handler(widget, data); | 1699 SignalHandler work = _get_signal_handler(data); |
1694 int retval = FALSE; | 1700 int retval = FALSE; |
1695 | 1701 |
1696 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1702 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1697 if(work.window) | 1703 if(work.window) |
1698 { | 1704 { |
1712 return retval; | 1718 return retval; |
1713 } | 1719 } |
1714 | 1720 |
1715 static gint _container_enter_event(GtkWidget *widget, GdkEventKey *event, gpointer data) | 1721 static gint _container_enter_event(GtkWidget *widget, GdkEventKey *event, gpointer data) |
1716 { | 1722 { |
1717 SignalHandler work = _get_signal_handler(widget, data); | 1723 SignalHandler work = _get_signal_handler(data); |
1718 int retval = FALSE; | 1724 int retval = FALSE; |
1719 | 1725 |
1720 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1726 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1721 if(work.window && event->keyval == VK_RETURN) | 1727 if(work.window && event->keyval == VK_RETURN) |
1722 { | 1728 { |
1748 } | 1754 } |
1749 | 1755 |
1750 | 1756 |
1751 static gint _switch_page_event(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data) | 1757 static gint _switch_page_event(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data) |
1752 { | 1758 { |
1753 SignalHandler work = _get_signal_handler((GtkWidget *)notebook, data); | 1759 SignalHandler work = _get_signal_handler(data); |
1754 int retval = FALSE; | 1760 int retval = FALSE; |
1755 | 1761 |
1756 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1762 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1757 if(work.window) | 1763 if(work.window) |
1758 { | 1764 { |
1762 return retval; | 1768 return retval; |
1763 } | 1769 } |
1764 | 1770 |
1765 static gint _column_click_event(GtkWidget *widget, gint column_num, gpointer data) | 1771 static gint _column_click_event(GtkWidget *widget, gint column_num, gpointer data) |
1766 { | 1772 { |
1767 SignalHandler work = _get_signal_handler(widget, data); | 1773 SignalHandler work = _get_signal_handler(data); |
1768 int retval = FALSE; | 1774 int retval = FALSE; |
1769 | 1775 |
1770 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1776 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1771 if(work.window) | 1777 if(work.window) |
1772 { | 1778 { |
1776 return retval; | 1782 return retval; |
1777 } | 1783 } |
1778 | 1784 |
1779 static gint _container_select_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) | 1785 static gint _container_select_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) |
1780 { | 1786 { |
1781 SignalHandler work = _get_signal_handler(widget, data); | 1787 SignalHandler work = _get_signal_handler(data); |
1782 char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row); | 1788 char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row); |
1783 int (*contextfunc)(HWND, HWND, char *, void *, void *) = work.func; | 1789 int (*contextfunc)(HWND, HWND, char *, void *, void *) = work.func; |
1784 | 1790 |
1785 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1791 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1786 if(!work.window) | 1792 if(!work.window) |
1817 | 1823 |
1818 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); | 1824 if ( dbgfp != NULL ) _dw_log("%s %d: %s\n",__FILE__,__LINE__,__func__); |
1819 | 1825 |
1820 if (slider || spinbutton || scrollbar) | 1826 if (slider || spinbutton || scrollbar) |
1821 { | 1827 { |
1822 SignalHandler work = _get_signal_handler((GtkWidget *)adjustment, data); | 1828 SignalHandler work = _get_signal_handler(data); |
1823 | 1829 |
1824 if (work.window) | 1830 if (work.window) |
1825 { | 1831 { |
1826 int (*valuechangedfunc)(HWND, int, void *) = work.func; | 1832 int (*valuechangedfunc)(HWND, int, void *) = work.func; |
1827 | 1833 |
6210 gtk_widget_show(hbox); | 6216 gtk_widget_show(hbox); |
6211 | 6217 |
6212 { | 6218 { |
6213 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_item_expand_func"); | 6219 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_item_expand_func"); |
6214 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_item_expand_data"); | 6220 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_item_expand_data"); |
6215 SignalHandler work = _get_signal_handler(tree, mydata); | 6221 void **params = calloc(sizeof(void *), 3): |
6222 SignalHandler work; | |
6223 | |
6224 params[0] = mydata; | |
6225 params[2] = (void *)tree; | |
6226 work = _get_signal_handler(mydata); | |
6216 | 6227 |
6217 if(thisfunc && work.window) | 6228 if(thisfunc && work.window) |
6218 { | 6229 { |
6219 int sigid = _set_signal_handler(newitem, work.window, work.func, work.data, thisfunc); | 6230 gint sigid = _set_signal_handler(newitem, work.window, work.func, work.data, thisfunc); |
6220 gint cid =gtk_signal_connect(GTK_OBJECT(newitem), "expand", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid); | 6231 pointer[0] = GINT_TO_POINTER(sigid); |
6232 gint cid = g_signal_connect_data(G_OBJECT(newitem), "expand", G_CALLBACK(thisfunc), params, _dw_signal_disconnect, 0); | |
6221 _set_signal_handler_id(newitem, sigid, cid); | 6233 _set_signal_handler_id(newitem, sigid, cid); |
6234 } | |
6235 else | |
6236 { | |
6237 free(params); | |
6222 } | 6238 } |
6223 } | 6239 } |
6224 | 6240 |
6225 _dw_ignore_expand = 1; | 6241 _dw_ignore_expand = 1; |
6226 if(parent) | 6242 if(parent) |
6228 subtree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(parent)); | 6244 subtree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(parent)); |
6229 if(!subtree || !GTK_IS_TREE(subtree)) | 6245 if(!subtree || !GTK_IS_TREE(subtree)) |
6230 { | 6246 { |
6231 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_func"); | 6247 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_func"); |
6232 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_data"); | 6248 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_data"); |
6233 SignalHandler work = _get_signal_handler(tree, mydata); | 6249 SignalHandler work = _get_signal_handler(mydata); |
6234 | 6250 |
6235 subtree = gtk_tree_new(); | 6251 subtree = gtk_tree_new(); |
6236 | 6252 |
6237 if(thisfunc && work.window) | 6253 if(thisfunc && work.window) |
6238 { | 6254 { |
6241 _set_signal_handler_id(subtree, sigid, cid); | 6257 _set_signal_handler_id(subtree, sigid, cid); |
6242 } | 6258 } |
6243 | 6259 |
6244 thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_func"); | 6260 thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_func"); |
6245 mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_data"); | 6261 mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_data"); |
6246 work = _get_signal_handler(tree, mydata); | 6262 work = _get_signal_handler(mydata); |
6247 | 6263 |
6248 if(thisfunc && work.window) | 6264 if(thisfunc && work.window) |
6249 { | 6265 { |
6250 int sigid = _set_signal_handler(subtree, work.window, work.func, work.data, thisfunc); | 6266 int sigid = _set_signal_handler(subtree, work.window, work.func, work.data, thisfunc); |
6251 gint cid =gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid); | 6267 gint cid =gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid); |
6356 gtk_widget_show(hbox); | 6372 gtk_widget_show(hbox); |
6357 | 6373 |
6358 { | 6374 { |
6359 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_item_expand_func"); | 6375 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_item_expand_func"); |
6360 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_item_expand_data"); | 6376 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_item_expand_data"); |
6361 SignalHandler work = _get_signal_handler(tree, mydata); | 6377 void **params = calloc(sizeof(void *), 3): |
6378 SignalHandler work; | |
6379 | |
6380 params[0] = mydata; | |
6381 params[2] = (void *)tree; | |
6382 work = _get_signal_handler(mydata); | |
6362 | 6383 |
6363 if(thisfunc && work.window) | 6384 if(thisfunc && work.window) |
6364 { | 6385 { |
6365 int sigid = _set_signal_handler(item, work.window, work.func, work.data, thisfunc); | 6386 gint sigid = _set_signal_handler(item, work.window, work.func, work.data, thisfunc); |
6366 gint cid =gtk_signal_connect(GTK_OBJECT(item), "expand", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid); | 6387 params[0] = GINT_TO_POINTER(sigid); |
6388 gint cid = g_signal_connect_data(G_OBJECT(item), "expand", G_CALLBACK(thisfunc), params, _dw_signal_disconnect, 0); | |
6367 _set_signal_handler_id(item, sigid, cid); | 6389 _set_signal_handler_id(item, sigid, cid); |
6368 } | 6390 } |
6369 } | 6391 } |
6370 | 6392 |
6371 _dw_ignore_expand = 1; | 6393 _dw_ignore_expand = 1; |
6374 subtree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(parent)); | 6396 subtree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(parent)); |
6375 if(!subtree || !GTK_IS_TREE(subtree)) | 6397 if(!subtree || !GTK_IS_TREE(subtree)) |
6376 { | 6398 { |
6377 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_func"); | 6399 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_func"); |
6378 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_data"); | 6400 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_data"); |
6379 SignalHandler work = _get_signal_handler(tree, mydata); | 6401 SignalHandler work = _get_signal_handler(mydata); |
6380 | 6402 |
6381 subtree = gtk_tree_new(); | 6403 subtree = gtk_tree_new(); |
6382 | 6404 |
6383 if(thisfunc && work.window) | 6405 if(thisfunc && work.window) |
6384 { | 6406 { |
6387 _set_signal_handler_id(subtree, sigid, cid); | 6409 _set_signal_handler_id(subtree, sigid, cid); |
6388 } | 6410 } |
6389 | 6411 |
6390 thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_func"); | 6412 thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_func"); |
6391 mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_data"); | 6413 mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_data"); |
6392 work = _get_signal_handler(tree, mydata); | 6414 work = _get_signal_handler(mydata); |
6393 | 6415 |
6394 if(thisfunc && work.window) | 6416 if(thisfunc && work.window) |
6395 { | 6417 { |
6396 int sigid = _set_signal_handler(subtree, work.window, work.func, work.data, thisfunc); | 6418 int sigid = _set_signal_handler(subtree, work.window, work.func, work.data, thisfunc); |
6397 gint cid =gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid); | 6419 gint cid =gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid); |
13464 thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow)); | 13486 thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow)); |
13465 #endif | 13487 #endif |
13466 return thiswindow; | 13488 return thiswindow; |
13467 } | 13489 } |
13468 | 13490 |
13491 /* Internal function to free any allocated signal data.. | |
13492 * and call any required function to free additional memory. | |
13493 */ | |
13494 static void _dw_signal_disconnect(gpointer data, GClosure *closure) | |
13495 { | |
13496 if(data) | |
13497 { | |
13498 void **params = (void **)data; | |
13499 void (*discfunc)(HWND, void *) = params[1]; | |
13500 | |
13501 if(discfunc) | |
13502 { | |
13503 SignalHandler work = _get_signal_handler(data); | |
13504 | |
13505 if(work.window) | |
13506 { | |
13507 discfunc(work.window, work.data); | |
13508 } | |
13509 } | |
13510 free(data); | |
13511 } | |
13512 } | |
13513 | |
13469 /* | 13514 /* |
13470 * Add a callback to a window event. | 13515 * Add a callback to a window event. |
13471 * Parameters: | 13516 * Parameters: |
13472 * window: Window handle of signal to be called back. | 13517 * window: Window handle of signal to be called back. |
13473 * signame: A string pointer identifying which signal to be hooked. | 13518 * signame: A string pointer identifying which signal to be hooked. |
13474 * sigfunc: The pointer to the function to be used as the callback. | 13519 * sigfunc: The pointer to the function to be used as the callback. |
13475 * data: User data to be passed to the handler function. | 13520 * data: User data to be passed to the handler function. |
13476 */ | 13521 */ |
13477 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) | 13522 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) |
13478 { | 13523 { |
13524 dw_signal_connect_data(window, signame, sigfunc, NULL, data); | |
13525 } | |
13526 | |
13527 /* | |
13528 * Add a callback to a window event with a closure callback. | |
13529 * Parameters: | |
13530 * window: Window handle of signal to be called back. | |
13531 * signame: A string pointer identifying which signal to be hooked. | |
13532 * sigfunc: The pointer to the function to be used as the callback. | |
13533 * discfunc: The pointer to the function called when this handler is removed. | |
13534 * data: User data to be passed to the handler function. | |
13535 */ | |
13536 void dw_signal_connect_data(HWND window, char *signame, void *sigfunc, void *discfunc, void *data) | |
13537 { | |
13479 void *thisfunc = _findsigfunc(signame); | 13538 void *thisfunc = _findsigfunc(signame); |
13480 char *thisname = signame; | 13539 char *thisname = signame; |
13481 HWND thiswindow = window; | 13540 HWND thiswindow = window; |
13482 int sigid, _locked_by_me = FALSE; | 13541 int sigid, _locked_by_me = FALSE; |
13542 void **params = calloc(3, sizeof(void *)); | |
13483 gint cid; | 13543 gint cid; |
13544 | |
13545 /* Save the disconnect function pointer */ | |
13546 params[1] = discfunc; | |
13484 | 13547 |
13485 DW_MUTEX_LOCK; | 13548 DW_MUTEX_LOCK; |
13486 /* | 13549 /* |
13487 * If the window we are setting the signal on is a scrolled window we need to get | 13550 * If the window we are setting the signal on is a scrolled window we need to get |
13488 * the "real" widget type. thiswindow is the "real" widget type | 13551 * the "real" widget type. thiswindow is the "real" widget type |
13506 else if (GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0) | 13569 else if (GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0) |
13507 { | 13570 { |
13508 thisfunc = _findsigfunc("tree-context"); | 13571 thisfunc = _findsigfunc("tree-context"); |
13509 | 13572 |
13510 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc); | 13573 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc); |
13511 cid = gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), GINT_TO_POINTER(sigid)); | 13574 cid = g_signal_connect_data(G_OBJECT(thiswindow), "button_press_event", G_CALLBACK(thisfunc), params, _dw_signal_disconnect, 0); |
13512 _set_signal_handler_id(thiswindow, sigid, cid); | 13575 _set_signal_handler_id(thiswindow, sigid, cid); |
13513 | 13576 |
13514 #if 0 | 13577 #if 0 |
13515 sigid = _set_signal_handler(window, window, sigfunc, data, thisfunc); | 13578 sigid = _set_signal_handler(window, window, sigfunc, data, thisfunc); |
13516 cid = gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), (gpointer)sigid); | 13579 cid = gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), (gpointer)sigid); |
13526 | 13589 |
13527 thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow)); | 13590 thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow)); |
13528 thisname = "changed"; | 13591 thisname = "changed"; |
13529 | 13592 |
13530 sigid = _set_signal_handler(treeview, window, sigfunc, data, thisfunc); | 13593 sigid = _set_signal_handler(treeview, window, sigfunc, data, thisfunc); |
13531 cid = g_signal_connect(G_OBJECT(thiswindow), thisname, (GCallback)thisfunc, GINT_TO_POINTER(sigid)); | 13594 params[0] = GINT_TO_POINTER(sigid); |
13595 params[2] = (void *)thiswindow; | |
13596 cid = g_signal_connect_data(G_OBJECT(thiswindow), thisname, (GCallback)thisfunc, params, _dw_signal_disconnect, 0); | |
13532 _set_signal_handler_id(treeview, sigid, cid); | 13597 _set_signal_handler_id(treeview, sigid, cid); |
13533 DW_MUTEX_UNLOCK; | 13598 DW_MUTEX_UNLOCK; |
13534 return; | 13599 return; |
13535 } | 13600 } |
13536 else if (GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_TREE_EXPAND) == 0) | 13601 else if (GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_TREE_EXPAND) == 0) |
13540 #else | 13605 #else |
13541 else if (GTK_IS_TREE(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0) | 13606 else if (GTK_IS_TREE(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0) |
13542 { | 13607 { |
13543 thisfunc = _findsigfunc("tree-context"); | 13608 thisfunc = _findsigfunc("tree-context"); |
13544 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc); | 13609 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc); |
13545 | 13610 params[0] = GINT_TO_POINTER(sigid); |
13611 params[2] = (void *)thiswindow; | |
13546 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_container_context_func", (gpointer)thisfunc); | 13612 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_container_context_func", (gpointer)thisfunc); |
13547 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_container_context_data", GINT_TO_POINTER(sigid)); | 13613 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_container_context_data", params); |
13548 cid = gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), GINT_TO_POINTER(sigid)); | 13614 cid = gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), params); |
13549 _set_signal_handler_id(thiswindow, sigid, cid); | 13615 _set_signal_handler_id(thiswindow, sigid, cid); |
13616 | |
13617 params = calloc(sizeof(void *), 3); | |
13550 sigid = _set_signal_handler(window, window, sigfunc, data, thisfunc); | 13618 sigid = _set_signal_handler(window, window, sigfunc, data, thisfunc); |
13551 cid = gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), GINT_TO_POINTER(sigid)); | 13619 params[0] = GINT_TO_POINTER(sigid); |
13620 params[2] = (void *)thiswindow; | |
13621 cid = gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), params); | |
13552 _set_signal_handler_id(window, sigid, cid); | 13622 _set_signal_handler_id(window, sigid, cid); |
13553 DW_MUTEX_UNLOCK; | 13623 DW_MUTEX_UNLOCK; |
13554 return; | 13624 return; |
13555 } | 13625 } |
13556 else if (GTK_IS_TREE(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0) | 13626 else if (GTK_IS_TREE(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0) |
13557 { | 13627 { |
13558 if(thisfunc) | 13628 if(thisfunc) |
13559 { | 13629 { |
13560 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc); | 13630 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc); |
13631 params[0] = GINT_TO_POINTER(sigid); | |
13561 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_select_child_func", (gpointer)thisfunc); | 13632 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_select_child_func", (gpointer)thisfunc); |
13562 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_select_child_data", GINT_TO_POINTER(sigid)); | 13633 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_select_child_data", GINT_TO_POINTER(sigid)); |
13563 } | 13634 } |
13564 thisname = "select-child"; | 13635 thisname = "select-child"; |
13565 } | 13636 } |
13576 } | 13647 } |
13577 #endif | 13648 #endif |
13578 else if (GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_ENTER) == 0) | 13649 else if (GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_ENTER) == 0) |
13579 { | 13650 { |
13580 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, _container_enter_event); | 13651 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, _container_enter_event); |
13581 cid = gtk_signal_connect(GTK_OBJECT(thiswindow), "key_press_event", GTK_SIGNAL_FUNC(_container_enter_event), GINT_TO_POINTER(sigid)); | 13652 params[0] = GINT_TO_POINTER(sigid); |
13653 params[2] = (void *)thiswindow; | |
13654 cid = g_signal_connect_data(G_OBJECT(thiswindow), "key_press_event", G_CALLBACK(_container_enter_event), params, _dw_signal_disconnect, 0); | |
13582 _set_signal_handler_id(thiswindow, sigid, cid); | 13655 _set_signal_handler_id(thiswindow, sigid, cid); |
13583 | 13656 |
13584 thisname = "button_press_event"; | 13657 thisname = "button_press_event"; |
13585 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_ENTER); | 13658 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_ENTER); |
13586 } | 13659 } |
13632 DW_MUTEX_UNLOCK; | 13705 DW_MUTEX_UNLOCK; |
13633 return; | 13706 return; |
13634 } | 13707 } |
13635 | 13708 |
13636 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc); | 13709 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc); |
13637 cid = gtk_signal_connect(GTK_OBJECT(thiswindow), thisname, GTK_SIGNAL_FUNC(thisfunc),GINT_TO_POINTER(sigid)); | 13710 params[0] = GINT_TO_POINTER(sigid); |
13711 params[2] = (void *)thiswindow; | |
13712 cid = g_signal_connect_data(G_OBJECT(thiswindow), thisname, G_CALLBACK(thisfunc), params, _dw_signal_disconnect, 0); | |
13638 _set_signal_handler_id(thiswindow, sigid, cid); | 13713 _set_signal_handler_id(thiswindow, sigid, cid); |
13639 DW_MUTEX_UNLOCK; | 13714 DW_MUTEX_UNLOCK; |
13640 } | 13715 } |
13641 | 13716 |
13642 /* | 13717 /* |
13644 * Parameters: | 13719 * Parameters: |
13645 * window: Window handle of callback to be removed. | 13720 * window: Window handle of callback to be removed. |
13646 */ | 13721 */ |
13647 void dw_signal_disconnect_by_name(HWND window, char *signame) | 13722 void dw_signal_disconnect_by_name(HWND window, char *signame) |
13648 { | 13723 { |
13649 HWND thiswindow; | |
13650 int z, count; | 13724 int z, count; |
13651 void *thisfunc; | 13725 void *thisfunc; |
13652 int _locked_by_me = FALSE; | 13726 int _locked_by_me = FALSE; |
13653 | 13727 void **params = alloca(sizeof(void *) * 3); |
13654 DW_MUTEX_LOCK; | 13728 |
13655 thiswindow = _find_signal_window(window, signame); | 13729 DW_MUTEX_LOCK; |
13656 count = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter")); | 13730 params[2] = _find_signal_window(window, signame); |
13657 thisfunc = _findsigfunc(signame); | 13731 count = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(params[2]), "_dw_sigcounter")); |
13732 thisfunc = _findsigfunc(signame); | |
13658 | 13733 |
13659 for(z=0;z<count;z++) | 13734 for(z=0;z<count;z++) |
13660 { | 13735 { |
13661 SignalHandler sh = _get_signal_handler(thiswindow, GINT_TO_POINTER(z)); | 13736 SignalHandler sh; |
13737 | |
13738 params[0] = GINT_TO_POINTER(z); | |
13739 sh = _get_signal_handler(params); | |
13662 | 13740 |
13663 if(sh.intfunc == thisfunc) | 13741 if(sh.intfunc == thisfunc) |
13664 _remove_signal_handler(thiswindow, z); | 13742 _remove_signal_handler((HWND)params[2], z); |
13665 } | 13743 } |
13666 DW_MUTEX_UNLOCK; | 13744 DW_MUTEX_UNLOCK; |
13667 } | 13745 } |
13668 | 13746 |
13669 /* | 13747 /* |
13693 * window: Window handle of callback to be removed. | 13771 * window: Window handle of callback to be removed. |
13694 * data: Pointer to the data to be compared against. | 13772 * data: Pointer to the data to be compared against. |
13695 */ | 13773 */ |
13696 void dw_signal_disconnect_by_data(HWND window, void *data) | 13774 void dw_signal_disconnect_by_data(HWND window, void *data) |
13697 { | 13775 { |
13698 HWND thiswindow; | |
13699 int z, count; | 13776 int z, count; |
13700 int _locked_by_me = FALSE; | 13777 int _locked_by_me = FALSE; |
13701 | 13778 void **params = alloca(sizeof(void *) * 3); |
13702 DW_MUTEX_LOCK; | 13779 |
13703 thiswindow = _find_signal_window(window, NULL); | 13780 DW_MUTEX_LOCK; |
13704 count = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter")); | 13781 params[2] = _find_signal_window(window, NULL); |
13782 count = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(params[2]), "_dw_sigcounter")); | |
13705 | 13783 |
13706 for(z=0;z<count;z++) | 13784 for(z=0;z<count;z++) |
13707 { | 13785 { |
13708 SignalHandler sh = _get_signal_handler(thiswindow, GINT_TO_POINTER(z)); | 13786 SignalHandler sh; |
13787 | |
13788 params[0] = GINT_TO_POINTER(z); | |
13789 sh = _get_signal_handler(params); | |
13709 | 13790 |
13710 if(sh.data == data) | 13791 if(sh.data == data) |
13711 _remove_signal_handler(thiswindow, z); | 13792 _remove_signal_handler((HWND)params[2], z); |
13712 } | 13793 } |
13713 DW_MUTEX_UNLOCK; | 13794 DW_MUTEX_UNLOCK; |
13714 } | 13795 } |
13715 | 13796 |
13716 /* | 13797 /* |