Mercurial > dwindows
comparison gtk/dw.c @ 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 | 2497a806d34e |
children | 98d73c9e81fc |
comparison
equal
deleted
inserted
replaced
985:cfc0777aceb5 | 986:87dc0f5f96d0 |
---|---|
6290 DW_MUTEX_LOCK; | 6290 DW_MUTEX_LOCK; |
6291 clist = gtk_clist_new_with_titles(count, (gchar **)titles); | 6291 clist = gtk_clist_new_with_titles(count, (gchar **)titles); |
6292 if(!clist) | 6292 if(!clist) |
6293 { | 6293 { |
6294 DW_MUTEX_UNLOCK; | 6294 DW_MUTEX_UNLOCK; |
6295 return FALSE; | 6295 return DW_ERROR_GENERAL; |
6296 } | 6296 } |
6297 multi = (int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_multi"); | 6297 multi = (int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_multi"); |
6298 gtk_object_set_data(GTK_OBJECT(handle), "_dw_multi", GINT_TO_POINTER(multi)); | 6298 gtk_object_set_data(GTK_OBJECT(handle), "_dw_multi", GINT_TO_POINTER(multi)); |
6299 | 6299 |
6300 gtk_clist_set_column_auto_resize(GTK_CLIST(clist), 0, TRUE); | 6300 gtk_clist_set_column_auto_resize(GTK_CLIST(clist), 0, TRUE); |
6324 justification = GTK_JUSTIFY_LEFT; | 6324 justification = GTK_JUSTIFY_LEFT; |
6325 gtk_clist_set_column_justification(GTK_CLIST(clist),z,justification); | 6325 gtk_clist_set_column_justification(GTK_CLIST(clist),z,justification); |
6326 } | 6326 } |
6327 | 6327 |
6328 DW_MUTEX_UNLOCK; | 6328 DW_MUTEX_UNLOCK; |
6329 return TRUE; | 6329 return DW_ERROR_NONE; |
6330 } | 6330 } |
6331 | 6331 |
6332 /* | 6332 /* |
6333 * Sets up the container columns. | 6333 * Sets up the container columns. |
6334 * Parameters: | 6334 * Parameters: |
6354 */ | 6354 */ |
6355 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | 6355 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) |
6356 { | 6356 { |
6357 char **newtitles = malloc(sizeof(char *) * (count + 1)); | 6357 char **newtitles = malloc(sizeof(char *) * (count + 1)); |
6358 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 1)); | 6358 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 1)); |
6359 int res; | |
6359 | 6360 |
6360 newtitles[0] = "Filename"; | 6361 newtitles[0] = "Filename"; |
6361 | 6362 |
6362 newflags[0] = DW_CFA_STRINGANDICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; | 6363 newflags[0] = DW_CFA_STRINGANDICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; |
6363 | 6364 |
6364 memcpy(&newtitles[1], titles, sizeof(char *) * count); | 6365 memcpy(&newtitles[1], titles, sizeof(char *) * count); |
6365 memcpy(&newflags[1], flags, sizeof(unsigned long) * count); | 6366 memcpy(&newflags[1], flags, sizeof(unsigned long) * count); |
6366 | 6367 |
6367 _dw_container_setup(handle, newflags, newtitles, count + 1, 1, 1); | 6368 res = _dw_container_setup(handle, newflags, newtitles, count + 1, 1, 1); |
6368 | 6369 |
6369 if ( newtitles) free(newtitles); | 6370 if ( newtitles) free(newtitles); |
6370 if ( newflags ) free(newflags); | 6371 if ( newflags ) free(newflags); |
6371 return TRUE; | 6372 return res; |
6372 } | 6373 } |
6373 | 6374 |
6374 /* | 6375 /* |
6375 * Obtains an icon from a module (or header in GTK). | 6376 * Obtains an icon from a module (or header in GTK). |
6376 * Parameters: | 6377 * Parameters: |
8368 * eve: The handle to the event returned by dw_event_new(). | 8369 * eve: The handle to the event returned by dw_event_new(). |
8369 */ | 8370 */ |
8370 int dw_event_reset (HEV eve) | 8371 int dw_event_reset (HEV eve) |
8371 { | 8372 { |
8372 if(!eve) | 8373 if(!eve) |
8373 return FALSE; | 8374 return DW_ERROR_NON_INIT; |
8374 | 8375 |
8375 pthread_mutex_lock (&(eve->mutex)); | 8376 pthread_mutex_lock (&(eve->mutex)); |
8376 pthread_cond_broadcast (&(eve->event)); | 8377 pthread_cond_broadcast (&(eve->event)); |
8377 pthread_cond_init (&(eve->event), NULL); | 8378 pthread_cond_init (&(eve->event), NULL); |
8378 eve->posted = 0; | 8379 eve->posted = 0; |
8379 pthread_mutex_unlock (&(eve->mutex)); | 8380 pthread_mutex_unlock (&(eve->mutex)); |
8380 return 0; | 8381 return DW_ERROR_NONE; |
8381 } | 8382 } |
8382 | 8383 |
8383 /* | 8384 /* |
8384 * Posts a semaphore created by dw_event_new(). Causing all threads | 8385 * Posts a semaphore created by dw_event_new(). Causing all threads |
8385 * waiting on this event in dw_event_wait to continue. | 8386 * waiting on this event in dw_event_wait to continue. |
8387 * eve: The handle to the event returned by dw_event_new(). | 8388 * eve: The handle to the event returned by dw_event_new(). |
8388 */ | 8389 */ |
8389 int dw_event_post (HEV eve) | 8390 int dw_event_post (HEV eve) |
8390 { | 8391 { |
8391 if(!eve) | 8392 if(!eve) |
8392 return FALSE; | 8393 return DW_ERROR_NON_INIT; |
8393 | 8394 |
8394 pthread_mutex_lock (&(eve->mutex)); | 8395 pthread_mutex_lock (&(eve->mutex)); |
8395 pthread_cond_broadcast (&(eve->event)); | 8396 pthread_cond_broadcast (&(eve->event)); |
8396 eve->posted = 1; | 8397 eve->posted = 1; |
8397 pthread_mutex_unlock (&(eve->mutex)); | 8398 pthread_mutex_unlock (&(eve->mutex)); |
8398 return 0; | 8399 return DW_ERROR_NONE; |
8399 } | 8400 } |
8400 | 8401 |
8401 /* | 8402 /* |
8402 * Waits on a semaphore created by dw_event_new(), until the | 8403 * Waits on a semaphore created by dw_event_new(), until the |
8403 * event gets posted or until the timeout expires. | 8404 * event gets posted or until the timeout expires. |
8409 int rc; | 8410 int rc; |
8410 struct timeval now; | 8411 struct timeval now; |
8411 struct timespec timeo; | 8412 struct timespec timeo; |
8412 | 8413 |
8413 if(!eve) | 8414 if(!eve) |
8414 return FALSE; | 8415 return DW_ERROR_NON_INIT; |
8415 | 8416 |
8416 if(eve->posted) | 8417 if(eve->posted) |
8417 return 0; | 8418 return DW_ERROR_GENERAL; |
8418 | 8419 |
8419 pthread_mutex_lock (&(eve->mutex)); | 8420 pthread_mutex_lock (&(eve->mutex)); |
8420 gettimeofday(&now, 0); | 8421 gettimeofday(&now, 0); |
8421 timeo.tv_sec = now.tv_sec + (timeout / 1000); | 8422 timeo.tv_sec = now.tv_sec + (timeout / 1000); |
8422 timeo.tv_nsec = now.tv_usec * 1000; | 8423 timeo.tv_nsec = now.tv_usec * 1000; |
8423 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); | 8424 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); |
8424 pthread_mutex_unlock (&(eve->mutex)); | 8425 pthread_mutex_unlock (&(eve->mutex)); |
8425 if(!rc) | 8426 if(!rc) |
8426 return 1; | 8427 return DW_ERROR_NONE; |
8427 if(rc == ETIMEDOUT) | 8428 if(rc == ETIMEDOUT) |
8428 return -1; | 8429 return DW_ERROR_TIMEOUT; |
8429 return 0; | 8430 return DW_ERROR_GENERAL; |
8430 } | 8431 } |
8431 | 8432 |
8432 /* | 8433 /* |
8433 * Closes a semaphore created by dw_event_new(). | 8434 * Closes a semaphore created by dw_event_new(). |
8434 * Parameters: | 8435 * Parameters: |
8435 * eve: The handle to the event returned by dw_event_new(). | 8436 * eve: The handle to the event returned by dw_event_new(). |
8436 */ | 8437 */ |
8437 int dw_event_close(HEV *eve) | 8438 int dw_event_close(HEV *eve) |
8438 { | 8439 { |
8439 if(!eve || !(*eve)) | 8440 if(!eve || !(*eve)) |
8440 return FALSE; | 8441 return DW_ERROR_NON_INIT; |
8441 | 8442 |
8442 pthread_mutex_lock (&((*eve)->mutex)); | 8443 pthread_mutex_lock (&((*eve)->mutex)); |
8443 pthread_cond_destroy (&((*eve)->event)); | 8444 pthread_cond_destroy (&((*eve)->event)); |
8444 pthread_mutex_unlock (&((*eve)->mutex)); | 8445 pthread_mutex_unlock (&((*eve)->mutex)); |
8445 pthread_mutex_destroy (&((*eve)->mutex)); | 8446 pthread_mutex_destroy (&((*eve)->mutex)); |
8446 free(*eve); | 8447 free(*eve); |
8447 *eve = NULL; | 8448 *eve = NULL; |
8448 | 8449 |
8449 return TRUE; | 8450 return DW_ERROR_NONE; |
8450 } | 8451 } |
8451 | 8452 |
8452 struct _seminfo { | 8453 struct _seminfo { |
8453 int fd; | 8454 int fd; |
8454 int waiting; | 8455 int waiting; |
10110 /* | 10111 /* |
10111 * Returns the index to the item in the list currently selected. | 10112 * Returns the index to the item in the list currently selected. |
10112 * Parameters: | 10113 * Parameters: |
10113 * handle: Handle to the listbox to be queried. | 10114 * handle: Handle to the listbox to be queried. |
10114 */ | 10115 */ |
10115 unsigned int dw_listbox_selected(HWND handle) | 10116 int dw_listbox_selected(HWND handle) |
10116 { | 10117 { |
10117 GtkWidget *handle2 = handle; | 10118 GtkWidget *handle2 = handle; |
10118 int retval = DW_LIT_NONE; | 10119 int retval = DW_LIT_NONE; |
10119 int _locked_by_me = FALSE; | 10120 int _locked_by_me = FALSE; |
10120 | 10121 |