changeset 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 923af93e4084
children 007bced14910
files gtk/dw.c
diffstat 1 files changed, 60 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Fri Apr 27 02:16:09 2012 +0000
+++ b/gtk/dw.c	Fri Apr 27 02:47:44 2012 +0000
@@ -10420,7 +10420,66 @@
  */
 HWND API dw_box_remove_at_index(HWND box, int index)
 {
-   return 0;
+   HWND retval = 0;
+#if 0
+   int _locked_by_me = FALSE;
+
+   DW_MUTEX_LOCK;
+   /* Check if we are removing a widget from a box */	      
+   if(GTK_IS_TABLE(box))
+   {
+      /* Get the number of items in the box... */
+      int boxcount = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(box), "_dw_boxcount"));
+      int boxtype = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(box), "_dw_boxtype"));
+      gint pos;
+      
+      gtk_container_child_get(GTK_CONTAINER(box), handle2, boxtype == DW_VERT ? "top-attach" : "left-attach", &pos, NULL);
+      gtk_widget_destroy(handle2);
+
+      /* If we haven't incremented the reference count... raise it before removal */
+      if(gtk_object_get_data(GTK_OBJECT(item), "_dw_padding"))
+         gtk_widget_destroy(item);
+      else
+      {
+         if(!gtk_object_get_data(GTK_OBJECT(item), "_dw_refed"))
+         {
+            g_object_ref(G_OBJECT(item));
+            gtk_object_set_data(GTK_OBJECT(item), "_dw_refed", GINT_TO_POINTER(1));
+         }
+         /* Remove the widget from the box */      
+         gtk_container_remove(GTK_CONTAINER(box), item);
+         retval = item;
+      }
+         
+      /* If we are destroying the last item in the box this isn't necessary */
+      if((pos+1) < boxcount)
+      {
+         /* If we need to contract the table, reposition all the children */
+         gtk_container_forall(GTK_CONTAINER(box),_rearrange_table_destroy, GINT_TO_POINTER(boxtype == DW_VERT ? pos : -(pos+1)));
+      }
+      
+      if(boxcount > 0)
+      {
+         /* Decrease the count by 1 */
+         boxcount--;
+         gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount));
+      }
+      
+      /* If we aren't trying to resize the table to 0... */
+      if(boxcount > 0)
+      {
+         /* Contract the table to the size we need */
+         gtk_table_resize(GTK_TABLE(box), boxtype == DW_VERT ? boxcount : 1, boxtype == DW_VERT ? 1 : boxcount);
+      }
+   }
+   else
+   {
+      /* Finally destroy the widget */      
+      gtk_widget_destroy(handle2);
+   }
+   DW_MUTEX_UNLOCK;
+#endif
+   return retval;
 }
 
 /*