comparison gtk/dw.c @ 1675:ca5123dc5819

Committed some code for dw_box_remove_at_index() for GTK2... Incomplete, but wanted to commit for later.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 27 Apr 2012 02:47:44 +0000
parents 36a090da4cb1
children 60f8ae42a0be
comparison
equal deleted inserted replaced
1674:923af93e4084 1675:ca5123dc5819
10418 * Returns: 10418 * Returns:
10419 * Handle to the removed item on success, 0 on failure. 10419 * Handle to the removed item on success, 0 on failure.
10420 */ 10420 */
10421 HWND API dw_box_remove_at_index(HWND box, int index) 10421 HWND API dw_box_remove_at_index(HWND box, int index)
10422 { 10422 {
10423 return 0; 10423 HWND retval = 0;
10424 #if 0
10425 int _locked_by_me = FALSE;
10426
10427 DW_MUTEX_LOCK;
10428 /* Check if we are removing a widget from a box */
10429 if(GTK_IS_TABLE(box))
10430 {
10431 /* Get the number of items in the box... */
10432 int boxcount = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(box), "_dw_boxcount"));
10433 int boxtype = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(box), "_dw_boxtype"));
10434 gint pos;
10435
10436 gtk_container_child_get(GTK_CONTAINER(box), handle2, boxtype == DW_VERT ? "top-attach" : "left-attach", &pos, NULL);
10437 gtk_widget_destroy(handle2);
10438
10439 /* If we haven't incremented the reference count... raise it before removal */
10440 if(gtk_object_get_data(GTK_OBJECT(item), "_dw_padding"))
10441 gtk_widget_destroy(item);
10442 else
10443 {
10444 if(!gtk_object_get_data(GTK_OBJECT(item), "_dw_refed"))
10445 {
10446 g_object_ref(G_OBJECT(item));
10447 gtk_object_set_data(GTK_OBJECT(item), "_dw_refed", GINT_TO_POINTER(1));
10448 }
10449 /* Remove the widget from the box */
10450 gtk_container_remove(GTK_CONTAINER(box), item);
10451 retval = item;
10452 }
10453
10454 /* If we are destroying the last item in the box this isn't necessary */
10455 if((pos+1) < boxcount)
10456 {
10457 /* If we need to contract the table, reposition all the children */
10458 gtk_container_forall(GTK_CONTAINER(box),_rearrange_table_destroy, GINT_TO_POINTER(boxtype == DW_VERT ? pos : -(pos+1)));
10459 }
10460
10461 if(boxcount > 0)
10462 {
10463 /* Decrease the count by 1 */
10464 boxcount--;
10465 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount));
10466 }
10467
10468 /* If we aren't trying to resize the table to 0... */
10469 if(boxcount > 0)
10470 {
10471 /* Contract the table to the size we need */
10472 gtk_table_resize(GTK_TABLE(box), boxtype == DW_VERT ? boxcount : 1, boxtype == DW_VERT ? 1 : boxcount);
10473 }
10474 }
10475 else
10476 {
10477 /* Finally destroy the widget */
10478 gtk_widget_destroy(handle2);
10479 }
10480 DW_MUTEX_UNLOCK;
10481 #endif
10482 return retval;
10424 } 10483 }
10425 10484
10426 /* 10485 /*
10427 * Pack windows (widgets) into a box at an arbitrary location. 10486 * Pack windows (widgets) into a box at an arbitrary location.
10428 * Parameters: 10487 * Parameters: