comparison gtk/dw.c @ 1877:60abfe87dc05

Fixes for callbacks getting the correct parameters on GTK2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 09 Aug 2013 09:42:02 +0000
parents 4ca16d418039
children 71780cf68aa2
comparison
equal deleted inserted replaced
1876:4ca16d418039 1877:60abfe87dc05
1541 if(work.window) 1541 if(work.window)
1542 { 1542 {
1543 if(event->button == 3) 1543 if(event->button == 3)
1544 { 1544 {
1545 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work.func; 1545 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work.func;
1546 char *text; 1546 void **params;
1547 int row, col; 1547 int row, col;
1548 1548
1549 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); 1549 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
1550 1550
1551 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row); 1551 params = (void **)gtk_clist_get_row_data(GTK_CLIST(widget), row);
1552 retval = contextfunc(work.window, text, event->x, event->y, work.data, NULL); 1552 retval = contextfunc(work.window, params ? params[0] : NULL, event->x, event->y, work.data, params ? params[1] : NULL);
1553 } 1553 }
1554 } 1554 }
1555 return retval; 1555 return retval;
1556 } 1556 }
1557 1557
1702 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__);
1703 if(work.window) 1703 if(work.window)
1704 { 1704 {
1705 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS) 1705 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS)
1706 { 1706 {
1707 int (*contextfunc)(HWND, char *, void *) = work.func; 1707 int (*contextfunc)(HWND, char *, void *, void *) = work.func;
1708 char *text; 1708 void **params;
1709 int row, col; 1709 int row, col;
1710 1710
1711 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); 1711 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
1712 1712
1713 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row); 1713 params = (void **)gtk_clist_get_row_data(GTK_CLIST(widget), row);
1714 retval = contextfunc(work.window, text, work.data); 1714 retval = contextfunc(work.window, params ? params[0] : NULL, work.data, params ? params[1] : NULL);
1715 gtk_object_set_data(GTK_OBJECT(widget), "_dw_double_click", GINT_TO_POINTER(1)); 1715 gtk_object_set_data(GTK_OBJECT(widget), "_dw_double_click", GINT_TO_POINTER(1));
1716 } 1716 }
1717 } 1717 }
1718 return retval; 1718 return retval;
1719 } 1719 }
1724 int retval = FALSE; 1724 int retval = FALSE;
1725 1725
1726 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__);
1727 if(work.window && event->keyval == VK_RETURN) 1727 if(work.window && event->keyval == VK_RETURN)
1728 { 1728 {
1729 int (*contextfunc)(HWND, char *, void *) = work.func; 1729 int (*contextfunc)(HWND, char *, void *, void *) = work.func;
1730 char *text; 1730 void **params;
1731 1731
1732 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), GTK_CLIST(widget)->focus_row); 1732 params = (void **)gtk_clist_get_row_data(GTK_CLIST(widget), GTK_CLIST(widget)->focus_row);
1733 retval = contextfunc(work.window, text, work.data); 1733 retval = contextfunc(work.window, params ? params[0] : NULL, work.data, params ? params[1] : NULL);
1734 } 1734 }
1735 return retval; 1735 return retval;
1736 } 1736 }
1737 1737
1738 /* Return the logical page id from the physical page id */ 1738 /* Return the logical page id from the physical page id */
1783 } 1783 }
1784 1784
1785 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)
1786 { 1786 {
1787 SignalHandler work = _get_signal_handler(data); 1787 SignalHandler work = _get_signal_handler(data);
1788 char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row); 1788 void **rowdata = (void **)gtk_clist_get_row_data(GTK_CLIST(widget), row);
1789 int (*contextfunc)(HWND, HWND, char *, void *, void *) = work.func; 1789 int (*contextfunc)(HWND, HWND, char *, void *, void *) = work.func;
1790 1790
1791 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__);
1792 if(!work.window) 1792 if(!work.window)
1793 return TRUE; 1793 return TRUE;
1795 if(gtk_object_get_data(GTK_OBJECT(widget), "_dw_double_click")) 1795 if(gtk_object_get_data(GTK_OBJECT(widget), "_dw_double_click"))
1796 { 1796 {
1797 gtk_object_set_data(GTK_OBJECT(widget), "_dw_double_click", GINT_TO_POINTER(0)); 1797 gtk_object_set_data(GTK_OBJECT(widget), "_dw_double_click", GINT_TO_POINTER(0));
1798 return TRUE; 1798 return TRUE;
1799 } 1799 }
1800 return contextfunc(work.window, 0, rowdata, work.data, 0);; 1800 return contextfunc(work.window, 0, rowdata ? rowdata[0] : NULL, work.data, rowdata ? rowdata[1] : NULL);;
1801 } 1801 }
1802 1802
1803 static int _round_value(gfloat val) 1803 static int _round_value(gfloat val)
1804 { 1804 {
1805 int newval = (int)val; 1805 int newval = (int)val;