Mercurial > dwindows
comparison mac/dw.m @ 986:87dc0f5f96d0
Fix return type of dw_listbox_selected() to be "int" instead of "unsigned int" to allow -1 return.
Changed return values of a number of functions to be consistent across platforms and use the defines.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 07 May 2011 05:14:06 +0000 |
parents | 6abf763838c6 |
children | 6de00477d627 |
comparison
equal
deleted
inserted
replaced
985:cfc0777aceb5 | 986:87dc0f5f96d0 |
---|---|
4068 /* | 4068 /* |
4069 * Returns the index to the item in the list currently selected. | 4069 * Returns the index to the item in the list currently selected. |
4070 * Parameters: | 4070 * Parameters: |
4071 * handle: Handle to the listbox to be queried. | 4071 * handle: Handle to the listbox to be queried. |
4072 */ | 4072 */ |
4073 unsigned int API dw_listbox_selected(HWND handle) | 4073 int API dw_listbox_selected(HWND handle) |
4074 { | 4074 { |
4075 id object = handle; | 4075 id object = handle; |
4076 | 4076 |
4077 if([object isMemberOfClass:[DWComboBox class]]) | 4077 if([object isMemberOfClass:[DWComboBox class]]) |
4078 { | 4078 { |
5223 [cont addTableColumn:column]; | 5223 [cont addTableColumn:column]; |
5224 [cont addColumn:column andType:(int)flags[z]]; | 5224 [cont addColumn:column andType:(int)flags[z]]; |
5225 [column release]; | 5225 [column release]; |
5226 } | 5226 } |
5227 DW_MUTEX_UNLOCK; | 5227 DW_MUTEX_UNLOCK; |
5228 return TRUE; | 5228 return DW_ERROR_NONE; |
5229 } | 5229 } |
5230 | 5230 |
5231 /* | 5231 /* |
5232 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. | 5232 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. |
5233 * Parameters: | 5233 * Parameters: |
5252 dw_container_setup(handle, newflags, newtitles, count + 1, 0); | 5252 dw_container_setup(handle, newflags, newtitles, count + 1, 0); |
5253 [cont setFilesystem:YES]; | 5253 [cont setFilesystem:YES]; |
5254 | 5254 |
5255 free(newtitles); | 5255 free(newtitles); |
5256 free(newflags); | 5256 free(newflags); |
5257 return TRUE; | 5257 return DW_ERROR_NONE; |
5258 } | 5258 } |
5259 | 5259 |
5260 /* | 5260 /* |
5261 * Allocates memory used to populate a container. | 5261 * Allocates memory used to populate a container. |
5262 * Parameters: | 5262 * Parameters: |
8281 * eve: The handle to the event returned by dw_event_new(). | 8281 * eve: The handle to the event returned by dw_event_new(). |
8282 */ | 8282 */ |
8283 int dw_event_reset (HEV eve) | 8283 int dw_event_reset (HEV eve) |
8284 { | 8284 { |
8285 if(!eve) | 8285 if(!eve) |
8286 return FALSE; | 8286 return DW_ERROR_NON_INIT; |
8287 | 8287 |
8288 pthread_mutex_lock (&(eve->mutex)); | 8288 pthread_mutex_lock (&(eve->mutex)); |
8289 pthread_cond_broadcast (&(eve->event)); | 8289 pthread_cond_broadcast (&(eve->event)); |
8290 pthread_cond_init (&(eve->event), NULL); | 8290 pthread_cond_init (&(eve->event), NULL); |
8291 eve->posted = 0; | 8291 eve->posted = 0; |
8292 pthread_mutex_unlock (&(eve->mutex)); | 8292 pthread_mutex_unlock (&(eve->mutex)); |
8293 return 0; | 8293 return DW_ERROR_NONE; |
8294 } | 8294 } |
8295 | 8295 |
8296 /* | 8296 /* |
8297 * Posts a semaphore created by dw_event_new(). Causing all threads | 8297 * Posts a semaphore created by dw_event_new(). Causing all threads |
8298 * waiting on this event in dw_event_wait to continue. | 8298 * waiting on this event in dw_event_wait to continue. |
8322 int rc; | 8322 int rc; |
8323 struct timeval now; | 8323 struct timeval now; |
8324 struct timespec timeo; | 8324 struct timespec timeo; |
8325 | 8325 |
8326 if(!eve) | 8326 if(!eve) |
8327 return FALSE; | 8327 return DW_ERROR_NON_INIT; |
8328 | 8328 |
8329 if(eve->posted) | 8329 if(eve->posted) |
8330 return 0; | 8330 return DW_ERROR_GENERAL; |
8331 | 8331 |
8332 pthread_mutex_lock (&(eve->mutex)); | 8332 pthread_mutex_lock (&(eve->mutex)); |
8333 gettimeofday(&now, 0); | 8333 gettimeofday(&now, 0); |
8334 timeo.tv_sec = now.tv_sec + (timeout / 1000); | 8334 timeo.tv_sec = now.tv_sec + (timeout / 1000); |
8335 timeo.tv_nsec = now.tv_usec * 1000; | 8335 timeo.tv_nsec = now.tv_usec * 1000; |
8336 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); | 8336 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); |
8337 pthread_mutex_unlock (&(eve->mutex)); | 8337 pthread_mutex_unlock (&(eve->mutex)); |
8338 if(!rc) | 8338 if(!rc) |
8339 return 1; | 8339 return DW_ERROR_NONE; |
8340 if(rc == ETIMEDOUT) | 8340 if(rc == ETIMEDOUT) |
8341 return -1; | 8341 return DW_ERROR_TIMEOUT; |
8342 return 0; | 8342 return DW_ERROR_GENERAL; |
8343 } | 8343 } |
8344 | 8344 |
8345 /* | 8345 /* |
8346 * Closes a semaphore created by dw_event_new(). | 8346 * Closes a semaphore created by dw_event_new(). |
8347 * Parameters: | 8347 * Parameters: |
8348 * eve: The handle to the event returned by dw_event_new(). | 8348 * eve: The handle to the event returned by dw_event_new(). |
8349 */ | 8349 */ |
8350 int dw_event_close(HEV *eve) | 8350 int dw_event_close(HEV *eve) |
8351 { | 8351 { |
8352 if(!eve || !(*eve)) | 8352 if(!eve || !(*eve)) |
8353 return FALSE; | 8353 return DW_ERROR_NON_INIT; |
8354 | 8354 |
8355 pthread_mutex_lock (&((*eve)->mutex)); | 8355 pthread_mutex_lock (&((*eve)->mutex)); |
8356 pthread_cond_destroy (&((*eve)->event)); | 8356 pthread_cond_destroy (&((*eve)->event)); |
8357 pthread_mutex_unlock (&((*eve)->mutex)); | 8357 pthread_mutex_unlock (&((*eve)->mutex)); |
8358 pthread_mutex_destroy (&((*eve)->mutex)); | 8358 pthread_mutex_destroy (&((*eve)->mutex)); |
8359 free(*eve); | 8359 free(*eve); |
8360 *eve = NULL; | 8360 *eve = NULL; |
8361 | 8361 |
8362 return TRUE; | 8362 return DW_ERROR_NONE; |
8363 } | 8363 } |
8364 | 8364 |
8365 struct _seminfo { | 8365 struct _seminfo { |
8366 int fd; | 8366 int fd; |
8367 int waiting; | 8367 int waiting; |