comparison gtk3/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 ab244c6f9386
children f1c7b03f944d
comparison
equal deleted inserted replaced
985:cfc0777aceb5 986:87dc0f5f96d0
5372 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); 5372 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
5373 } 5373 }
5374 gtk_widget_show(tree); 5374 gtk_widget_show(tree);
5375 free(array); 5375 free(array);
5376 DW_MUTEX_UNLOCK; 5376 DW_MUTEX_UNLOCK;
5377 return TRUE; 5377 return DW_ERROR_NONE;
5378 } 5378 }
5379 5379
5380 /* 5380 /*
5381 * Sets up the container columns. 5381 * Sets up the container columns.
5382 * Parameters: 5382 * Parameters:
5413 5413
5414 _dw_container_setup(handle, newflags, newtitles, count + 1, 1, 1); 5414 _dw_container_setup(handle, newflags, newtitles, count + 1, 1, 1);
5415 5415
5416 if ( newtitles) free(newtitles); 5416 if ( newtitles) free(newtitles);
5417 if ( newflags ) free(newflags); 5417 if ( newflags ) free(newflags);
5418 return TRUE; 5418 return DW_ERROR_NONE;
5419 } 5419 }
5420 5420
5421 /* 5421 /*
5422 * Obtains an icon from a module (or header in GTK). 5422 * Obtains an icon from a module (or header in GTK).
5423 * Parameters: 5423 * Parameters:
7264 * eve: The handle to the event returned by dw_event_new(). 7264 * eve: The handle to the event returned by dw_event_new().
7265 */ 7265 */
7266 int dw_event_reset (HEV eve) 7266 int dw_event_reset (HEV eve)
7267 { 7267 {
7268 if(!eve) 7268 if(!eve)
7269 return FALSE; 7269 return DW_ERROR_NON_INIT;
7270 7270
7271 pthread_mutex_lock (&(eve->mutex)); 7271 pthread_mutex_lock (&(eve->mutex));
7272 pthread_cond_broadcast (&(eve->event)); 7272 pthread_cond_broadcast (&(eve->event));
7273 pthread_cond_init (&(eve->event), NULL); 7273 pthread_cond_init (&(eve->event), NULL);
7274 eve->posted = 0; 7274 eve->posted = 0;
7275 pthread_mutex_unlock (&(eve->mutex)); 7275 pthread_mutex_unlock (&(eve->mutex));
7276 return 0; 7276 return DW_ERROR_NONE;
7277 } 7277 }
7278 7278
7279 /* 7279 /*
7280 * Posts a semaphore created by dw_event_new(). Causing all threads 7280 * Posts a semaphore created by dw_event_new(). Causing all threads
7281 * waiting on this event in dw_event_wait to continue. 7281 * waiting on this event in dw_event_wait to continue.
7283 * eve: The handle to the event returned by dw_event_new(). 7283 * eve: The handle to the event returned by dw_event_new().
7284 */ 7284 */
7285 int dw_event_post (HEV eve) 7285 int dw_event_post (HEV eve)
7286 { 7286 {
7287 if(!eve) 7287 if(!eve)
7288 return FALSE; 7288 return DW_ERROR_NON_INIT;
7289 7289
7290 pthread_mutex_lock (&(eve->mutex)); 7290 pthread_mutex_lock (&(eve->mutex));
7291 pthread_cond_broadcast (&(eve->event)); 7291 pthread_cond_broadcast (&(eve->event));
7292 eve->posted = 1; 7292 eve->posted = 1;
7293 pthread_mutex_unlock (&(eve->mutex)); 7293 pthread_mutex_unlock (&(eve->mutex));
7294 return 0; 7294 return DW_ERROR_NONE;
7295 } 7295 }
7296 7296
7297 /* 7297 /*
7298 * Waits on a semaphore created by dw_event_new(), until the 7298 * Waits on a semaphore created by dw_event_new(), until the
7299 * event gets posted or until the timeout expires. 7299 * event gets posted or until the timeout expires.
7305 int rc; 7305 int rc;
7306 struct timeval now; 7306 struct timeval now;
7307 struct timespec timeo; 7307 struct timespec timeo;
7308 7308
7309 if(!eve) 7309 if(!eve)
7310 return FALSE; 7310 return DW_ERROR_NON_INIT;
7311 7311
7312 if(eve->posted) 7312 if(eve->posted)
7313 return 0; 7313 return DW_ERROR_GENERAL;
7314 7314
7315 pthread_mutex_lock (&(eve->mutex)); 7315 pthread_mutex_lock (&(eve->mutex));
7316 gettimeofday(&now, 0); 7316 gettimeofday(&now, 0);
7317 timeo.tv_sec = now.tv_sec + (timeout / 1000); 7317 timeo.tv_sec = now.tv_sec + (timeout / 1000);
7318 timeo.tv_nsec = now.tv_usec * 1000; 7318 timeo.tv_nsec = now.tv_usec * 1000;
7319 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); 7319 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo);
7320 pthread_mutex_unlock (&(eve->mutex)); 7320 pthread_mutex_unlock (&(eve->mutex));
7321 if(!rc) 7321 if(!rc)
7322 return 1; 7322 return DW_ERROR_NONE;
7323 if(rc == ETIMEDOUT) 7323 if(rc == ETIMEDOUT)
7324 return -1; 7324 return DW_ERROR_TIMEOUT;
7325 return 0; 7325 return DW_ERROR_GENERAL;
7326 } 7326 }
7327 7327
7328 /* 7328 /*
7329 * Closes a semaphore created by dw_event_new(). 7329 * Closes a semaphore created by dw_event_new().
7330 * Parameters: 7330 * Parameters:
7331 * eve: The handle to the event returned by dw_event_new(). 7331 * eve: The handle to the event returned by dw_event_new().
7332 */ 7332 */
7333 int dw_event_close(HEV *eve) 7333 int dw_event_close(HEV *eve)
7334 { 7334 {
7335 if(!eve || !(*eve)) 7335 if(!eve || !(*eve))
7336 return FALSE; 7336 return DW_ERROR_NON_INIT;
7337 7337
7338 pthread_mutex_lock (&((*eve)->mutex)); 7338 pthread_mutex_lock (&((*eve)->mutex));
7339 pthread_cond_destroy (&((*eve)->event)); 7339 pthread_cond_destroy (&((*eve)->event));
7340 pthread_mutex_unlock (&((*eve)->mutex)); 7340 pthread_mutex_unlock (&((*eve)->mutex));
7341 pthread_mutex_destroy (&((*eve)->mutex)); 7341 pthread_mutex_destroy (&((*eve)->mutex));
7342 free(*eve); 7342 free(*eve);
7343 *eve = NULL; 7343 *eve = NULL;
7344 7344
7345 return TRUE; 7345 return DW_ERROR_NONE;
7346 } 7346 }
7347 7347
7348 struct _seminfo { 7348 struct _seminfo {
7349 int fd; 7349 int fd;
7350 int waiting; 7350 int waiting;
8885 /* 8885 /*
8886 * Returns the index to the item in the list currently selected. 8886 * Returns the index to the item in the list currently selected.
8887 * Parameters: 8887 * Parameters:
8888 * handle: Handle to the listbox to be queried. 8888 * handle: Handle to the listbox to be queried.
8889 */ 8889 */
8890 unsigned int dw_listbox_selected(HWND handle) 8890 int dw_listbox_selected(HWND handle)
8891 { 8891 {
8892 GtkWidget *handle2 = handle; 8892 GtkWidget *handle2 = handle;
8893 GtkListStore *store = NULL; 8893 GtkListStore *store = NULL;
8894 int _locked_by_me = FALSE; 8894 int _locked_by_me = FALSE;
8895 unsigned int retval = 0; 8895 unsigned int retval = 0;