Mercurial > dwindows
comparison gtk3/dw.c @ 1674:923af93e4084
Implemented dw_box_remove_at_index() for GTK3.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 27 Apr 2012 02:16:09 +0000 |
parents | 36a090da4cb1 |
children | 896f377a47c7 |
comparison
equal
deleted
inserted
replaced
1673:db393069b27d | 1674:923af93e4084 |
---|---|
8701 * Returns: | 8701 * Returns: |
8702 * Handle to the removed item on success, 0 on failure. | 8702 * Handle to the removed item on success, 0 on failure. |
8703 */ | 8703 */ |
8704 HWND API dw_box_remove_at_index(HWND box, int index) | 8704 HWND API dw_box_remove_at_index(HWND box, int index) |
8705 { | 8705 { |
8706 return 0; | 8706 int _locked_by_me = FALSE; |
8707 HWND retval = 0; | |
8708 | |
8709 DW_MUTEX_LOCK; | |
8710 /* Check if we are removing a widget from a box */ | |
8711 if(GTK_IS_GRID(box)) | |
8712 { | |
8713 /* Get the number of items in the box... */ | |
8714 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); | |
8715 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype")); | |
8716 GtkWidget *item; | |
8717 | |
8718 /* Fix the index by taking into account empty cells */ | |
8719 if(boxtype == DW_VERT) | |
8720 { | |
8721 int z; | |
8722 | |
8723 for(z=0;z<index;z++) | |
8724 { | |
8725 if(!gtk_grid_get_child_at(GTK_GRID(box), 0, z)) | |
8726 index++; | |
8727 } | |
8728 item = gtk_grid_get_child_at(GTK_GRID(box), 0, index); | |
8729 } | |
8730 else | |
8731 { | |
8732 int z; | |
8733 | |
8734 for(z=0;z<index;z++) | |
8735 { | |
8736 if(!gtk_grid_get_child_at(GTK_GRID(box), z, 0)) | |
8737 index++; | |
8738 } | |
8739 item = gtk_grid_get_child_at(GTK_GRID(box), index, 0); | |
8740 } | |
8741 | |
8742 if(boxcount > 0) | |
8743 { | |
8744 /* Decrease the count by 1 */ | |
8745 boxcount--; | |
8746 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount)); | |
8747 } | |
8748 /* If we haven't incremented the reference count... raise it before removal */ | |
8749 if(g_object_get_data(G_OBJECT(item), "_dw_padding")) | |
8750 gtk_widget_destroy(item); | |
8751 else | |
8752 { | |
8753 if(!g_object_get_data(G_OBJECT(item), "_dw_refed")) | |
8754 { | |
8755 g_object_ref(G_OBJECT(item)); | |
8756 g_object_set_data(G_OBJECT(item), "_dw_refed", GINT_TO_POINTER(1)); | |
8757 } | |
8758 /* Remove the widget from the box */ | |
8759 gtk_container_remove(GTK_CONTAINER(box), item); | |
8760 retval = item; | |
8761 } | |
8762 } | |
8763 DW_MUTEX_UNLOCK; | |
8764 return retval; | |
8707 } | 8765 } |
8708 | 8766 |
8709 /* | 8767 /* |
8710 * Pack windows (widgets) into a box at an arbitrary location. | 8768 * Pack windows (widgets) into a box at an arbitrary location. |
8711 * Parameters: | 8769 * Parameters: |