changeset 1322:3f1ac800bf65

Initial fix for being able to do container string comparisons instead of pointer on all platforms. Improved on the GTK2 change earlier... where it would do both comparisons with string enabled.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 06 Nov 2011 12:13:13 +0000
parents 7630404386be
children 209d7f5137f2
files gtk/dw.c gtk3/dw.c mac/dw.m os2/dw.c win/dw.c
diffstat 5 files changed, 22 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Sun Nov 06 11:48:24 2011 +0000
+++ b/gtk/dw.c	Sun Nov 06 12:13:13 2011 +0000
@@ -7564,7 +7564,7 @@
    for(z=0;z<rowcount;z++)
    {
       rowdata = gtk_clist_get_row_data(GTK_CLIST(clist), z);
-      if ( (textcomp && rowdata && strcmp(rowdata, text) == 0) || rowdata == text )
+      if ( (textcomp && rowdata && strcmp(rowdata, text) == 0) || (!textcomp && rowdata == text) )
       {
          gfloat pos;
          GtkAdjustment *adj = gtk_clist_get_vadjustment(GTK_CLIST(clist));
@@ -7610,7 +7610,7 @@
    for(z=0;z<rowcount;z++)
    {
       rowdata = gtk_clist_get_row_data(GTK_CLIST(clist), z);
-      if ( (textcomp && rowdata && strcmp(rowdata, text) == 0) || rowdata == text )
+      if ( (textcomp && rowdata && strcmp(rowdata, text) == 0) || (!textcomp && rowdata == text) )
       {
          _dw_unselect(clist);
 
--- a/gtk3/dw.c	Sun Nov 06 11:48:24 2011 +0000
+++ b/gtk3/dw.c	Sun Nov 06 12:13:13 2011 +0000
@@ -6307,7 +6307,7 @@
    return retval;
 }
 
-int _find_iter(GtkListStore *store, GtkTreeIter *iter, char *text)
+int _find_iter(GtkListStore *store, GtkTreeIter *iter, char *text, int textcomp)
 {
    int z, rows = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
    char *thistext;
@@ -6317,7 +6317,7 @@
       if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), iter, NULL, z))
       {
          gtk_tree_model_get(GTK_TREE_MODEL(store), iter, 0, &thistext, -1);
-         if(thistext == text)
+         if((textcomp && thistext && strcmp(thistext, text) == 0) || (!textcomp && thistext == text))
          {
             return TRUE;
          }
@@ -6336,10 +6336,11 @@
 {
    GtkWidget *cont;
    GtkListStore *store = NULL;
-   int _locked_by_me = FALSE;
+   int textcomp, _locked_by_me = FALSE;
 
    DW_MUTEX_LOCK;
    cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
+   textcomp = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_textcomp"));
 
    /* Make sure it is the correct tree type */
    if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
@@ -6349,7 +6350,7 @@
    {
       GtkTreeIter iter;
 
-      if(_find_iter(store, &iter, text))
+      if(_find_iter(store, &iter, text, textcomp))
       {
          GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
 
@@ -6373,10 +6374,11 @@
 {
    GtkWidget *cont;
    GtkListStore *store = NULL;
-   int _locked_by_me = FALSE;
+   int textcomp, _locked_by_me = FALSE;
 
    DW_MUTEX_LOCK;
    cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
+   textcomp = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_textcomp"));
 
    /* Make sure it is the correct tree type */
    if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
@@ -6387,7 +6389,7 @@
       GtkTreeIter iter;
       int rows = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_rowcount"));
 
-      if(_find_iter(store, &iter, text))
+      if(_find_iter(store, &iter, text, textcomp))
       {
          gtk_list_store_remove(store, &iter);
          rows--;
--- a/mac/dw.m	Sun Nov 06 11:48:24 2011 +0000
+++ b/mac/dw.m	Sun Nov 06 12:13:13 2011 +0000
@@ -6261,12 +6261,13 @@
     DWContainer *cont = handle;
     char *thistext;
     int x, count = (int)[cont numberOfRowsInTableView:cont];
+    int textcomp = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_textcomp"));
 
     for(x=0;x<count;x++)
     {
         thistext = [cont getRowTitle:x];
 
-        if(thistext == text)
+        if((textcomp && thistext && strcmp(thistext, text) == 0) || (!textcomp && thistext == text))
         {
             NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x];
 
@@ -6290,12 +6291,13 @@
     DWContainer *cont = handle;
     char *thistext;
     int x, count = (int)[cont numberOfRowsInTableView:cont];
+    int textcomp = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_textcomp"));
 
     for(x=0;x<count;x++)
     {
         thistext = [cont getRowTitle:x];
 
-        if(thistext == text)
+        if((textcomp && thistext && strcmp(thistext, text) == 0) || (!textcomp && thistext == text))
         {
             [cont removeRow:x];
             return;
--- a/os2/dw.c	Sun Nov 06 11:48:24 2011 +0000
+++ b/os2/dw.c	Sun Nov 06 12:13:13 2011 +0000
@@ -8145,10 +8145,11 @@
 {
    RECTL viewport, item;
    PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
+   int textcomp = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_textcomp"));
 
    while(pCore)
    {
-      if((char *)pCore->pszIcon == text)
+      if((textcomp && pCore->pszIcon && strcmp(pCore->pszIcon, text) == 0) || (!textcomp && (char *)pCore->pszIcon == text))
       {
          QUERYRECORDRECT qrr;
          int scrollpixels = 0, midway;
@@ -8182,10 +8183,11 @@
 void API dw_container_delete_row(HWND handle, char *text)
 {
    PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
+   int textcomp = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_textcomp"));
 
    while(pCore)
    {
-      if((char *)pCore->pszIcon == text)
+      if((textcomp && pCore->pszIcon && strcmp(pCore->pszIcon, text) == 0) || (!textcomp && (char *)pCore->pszIcon == text))
       {
          WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)&pCore, MPFROM2SHORT(1, CMA_FREE | CMA_INVALIDATE));
          return;
--- a/win/dw.c	Sun Nov 06 11:48:24 2011 +0000
+++ b/win/dw.c	Sun Nov 06 12:13:13 2011 +0000
@@ -8491,6 +8491,7 @@
 void API dw_container_cursor(HWND handle, char *text)
 {
    int index = ListView_GetNextItem(handle, -1, LVNI_ALL);
+   int textcomp = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_textcomp"));
 
    while ( index != -1 )
    {
@@ -8503,7 +8504,7 @@
 
       ListView_GetItem( handle, &lvi );
 
-      if ( strcmp( (char *)lvi.lParam, text ) == 0 )
+      if ( (textcomp && lvi.lParam && strcmp( (char *)lvi.lParam, text ) == 0) || (!textcomp && (char *)lvi.lParam == text) )
       {
 
          ListView_SetItemState( handle, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED );
@@ -8524,6 +8525,7 @@
 void API dw_container_delete_row(HWND handle, char *text)
 {
    int index = ListView_GetNextItem(handle, -1, LVNI_ALL);
+   int textcomp = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_textcomp"));
 
    while(index != -1)
    {
@@ -8536,7 +8538,7 @@
 
       ListView_GetItem(handle, &lvi);
 
-      if ( strcmp( (char *)lvi.lParam, text ) == 0 )
+      if ( (textcomp && lvi.lParam && strcmp( (char *)lvi.lParam, text ) == 0) || (!textcomp && (char *)lvi.lParam == text) )
       {
          int _index = (int)dw_window_get_data(handle, "_dw_index");