comparison gtk3/dw.c @ 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 6bebcfa03b2b
children e4ef8d86dfc4
comparison
equal deleted inserted replaced
1321:7630404386be 1322:3f1ac800bf65
6305 } 6305 }
6306 DW_MUTEX_UNLOCK; 6306 DW_MUTEX_UNLOCK;
6307 return retval; 6307 return retval;
6308 } 6308 }
6309 6309
6310 int _find_iter(GtkListStore *store, GtkTreeIter *iter, char *text) 6310 int _find_iter(GtkListStore *store, GtkTreeIter *iter, char *text, int textcomp)
6311 { 6311 {
6312 int z, rows = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); 6312 int z, rows = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
6313 char *thistext; 6313 char *thistext;
6314 6314
6315 for(z=0;z<rows;z++) 6315 for(z=0;z<rows;z++)
6316 { 6316 {
6317 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), iter, NULL, z)) 6317 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), iter, NULL, z))
6318 { 6318 {
6319 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, 0, &thistext, -1); 6319 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, 0, &thistext, -1);
6320 if(thistext == text) 6320 if((textcomp && thistext && strcmp(thistext, text) == 0) || (!textcomp && thistext == text))
6321 { 6321 {
6322 return TRUE; 6322 return TRUE;
6323 } 6323 }
6324 } 6324 }
6325 } 6325 }
6334 */ 6334 */
6335 void dw_container_cursor(HWND handle, char *text) 6335 void dw_container_cursor(HWND handle, char *text)
6336 { 6336 {
6337 GtkWidget *cont; 6337 GtkWidget *cont;
6338 GtkListStore *store = NULL; 6338 GtkListStore *store = NULL;
6339 int _locked_by_me = FALSE; 6339 int textcomp, _locked_by_me = FALSE;
6340 6340
6341 DW_MUTEX_LOCK; 6341 DW_MUTEX_LOCK;
6342 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 6342 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
6343 textcomp = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_textcomp"));
6343 6344
6344 /* Make sure it is the correct tree type */ 6345 /* Make sure it is the correct tree type */
6345 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER)) 6346 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
6346 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont)); 6347 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
6347 6348
6348 if(store) 6349 if(store)
6349 { 6350 {
6350 GtkTreeIter iter; 6351 GtkTreeIter iter;
6351 6352
6352 if(_find_iter(store, &iter, text)) 6353 if(_find_iter(store, &iter, text, textcomp))
6353 { 6354 {
6354 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter); 6355 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
6355 6356
6356 if(path) 6357 if(path)
6357 { 6358 {
6371 */ 6372 */
6372 void dw_container_delete_row(HWND handle, char *text) 6373 void dw_container_delete_row(HWND handle, char *text)
6373 { 6374 {
6374 GtkWidget *cont; 6375 GtkWidget *cont;
6375 GtkListStore *store = NULL; 6376 GtkListStore *store = NULL;
6376 int _locked_by_me = FALSE; 6377 int textcomp, _locked_by_me = FALSE;
6377 6378
6378 DW_MUTEX_LOCK; 6379 DW_MUTEX_LOCK;
6379 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 6380 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
6381 textcomp = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), "_dw_textcomp"));
6380 6382
6381 /* Make sure it is the correct tree type */ 6383 /* Make sure it is the correct tree type */
6382 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER)) 6384 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
6383 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont)); 6385 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
6384 6386
6385 if(store) 6387 if(store)
6386 { 6388 {
6387 GtkTreeIter iter; 6389 GtkTreeIter iter;
6388 int rows = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_rowcount")); 6390 int rows = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_rowcount"));
6389 6391
6390 if(_find_iter(store, &iter, text)) 6392 if(_find_iter(store, &iter, text, textcomp))
6391 { 6393 {
6392 gtk_list_store_remove(store, &iter); 6394 gtk_list_store_remove(store, &iter);
6393 rows--; 6395 rows--;
6394 } 6396 }
6395 6397