Mercurial > dwindows
comparison gtk3/dw.c @ 1891:11a16c117748
Fixed build problems with the last GTK3 commit; tested with a live
GTK 3.10 system. Added removal support to dw_box_unpack().
Hopefully this doesn't break builds on earlier version.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 16 Oct 2013 22:05:36 +0000 |
parents | 0f3df50bfc4f |
children | c4a6ef8291be |
comparison
equal
deleted
inserted
replaced
1890:0f3df50bfc4f | 1891:11a16c117748 |
---|---|
2465 int z; | 2465 int z; |
2466 | 2466 |
2467 /* Figure out where in the grid this widget is and remove that row/column */ | 2467 /* Figure out where in the grid this widget is and remove that row/column */ |
2468 if(boxtype == DW_VERT) | 2468 if(boxtype == DW_VERT) |
2469 { | 2469 { |
2470 for(z=0;z<index;z++) | 2470 for(z=0;z<boxcount;z++) |
2471 { | 2471 { |
2472 if(gtk_grid_get_child_at(GTK_GRID(box), 0, z) == handle2) | 2472 if(gtk_grid_get_child_at(GTK_GRID(box), 0, z) == handle2) |
2473 { | 2473 { |
2474 gtk_grid_remove_row(GTK_GRID(box), z); | 2474 gtk_grid_remove_row(GTK_GRID(box), z); |
2475 break; | 2475 break; |
2476 } | 2476 } |
2477 } | 2477 } |
2478 } | 2478 } |
2479 else | 2479 else |
2480 { | 2480 { |
2481 for(z=0;z<index;z++) | 2481 for(z=0;z<boxcount;z++) |
2482 { | 2482 { |
2483 if(gtk_grid_get_child_at(GTK_GRID(box), z, 0) == handle2) | 2483 if(gtk_grid_get_child_at(GTK_GRID(box), z, 0) == handle2) |
2484 { | 2484 { |
2485 gtk_grid_remove_column(GTK_GRID(box), z); | 2485 gtk_grid_remove_column(GTK_GRID(box), z); |
2486 break; | 2486 break; |
8739 { | 8739 { |
8740 /* Only show warning if item is not a box */ | 8740 /* Only show warning if item is not a box */ |
8741 warn = TRUE; | 8741 warn = TRUE; |
8742 } | 8742 } |
8743 | 8743 |
8744 #if !GTK_CHECK_VERSION(3,10,0) | |
8745 /* Do some sanity bounds checking */ | 8744 /* Do some sanity bounds checking */ |
8746 if(index < 0) | 8745 if(index < 0) |
8747 index = 0; | 8746 index = 0; |
8748 if(index > boxcount) | 8747 if(index > boxcount) |
8749 index = boxcount; | 8748 index = boxcount; |
8750 | 8749 |
8750 #if !GTK_CHECK_VERSION(3,10,0) | |
8751 /* Fix the index by taking into account empty cells */ | 8751 /* Fix the index by taking into account empty cells */ |
8752 if(boxtype == DW_VERT) | 8752 if(boxtype == DW_VERT) |
8753 { | 8753 { |
8754 int z; | 8754 int z; |
8755 | 8755 |
8876 /* Check if we are removing a widget from a box */ | 8876 /* Check if we are removing a widget from a box */ |
8877 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box)) | 8877 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box)) |
8878 { | 8878 { |
8879 /* Get the number of items in the box... */ | 8879 /* Get the number of items in the box... */ |
8880 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); | 8880 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); |
8881 #if GTK_CHECK_VERSION(3,10,0) | |
8882 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype")); | |
8883 #endif | |
8881 | 8884 |
8882 if(boxcount > 0) | 8885 if(boxcount > 0) |
8883 { | 8886 { |
8884 /* Decrease the count by 1 */ | 8887 /* Decrease the count by 1 */ |
8885 boxcount--; | 8888 boxcount--; |
8890 { | 8893 { |
8891 g_object_ref(G_OBJECT(handle2)); | 8894 g_object_ref(G_OBJECT(handle2)); |
8892 g_object_set_data(G_OBJECT(handle2), "_dw_refed", GINT_TO_POINTER(1)); | 8895 g_object_set_data(G_OBJECT(handle2), "_dw_refed", GINT_TO_POINTER(1)); |
8893 } | 8896 } |
8894 /* Remove the widget from the box */ | 8897 /* Remove the widget from the box */ |
8898 #if GTK_CHECK_VERSION(3,10,0) | |
8899 /* Figure out where in the grid this widget is and remove that row/column */ | |
8900 if(boxtype == DW_VERT) | |
8901 { | |
8902 int z; | |
8903 | |
8904 for(z=0;z<boxcount;z++) | |
8905 { | |
8906 if(gtk_grid_get_child_at(GTK_GRID(box), 0, z) == handle2) | |
8907 { | |
8908 gtk_grid_remove_row(GTK_GRID(box), z); | |
8909 break; | |
8910 } | |
8911 } | |
8912 } | |
8913 else | |
8914 { | |
8915 int z; | |
8916 | |
8917 for(z=0;z<boxcount;z++) | |
8918 { | |
8919 if(gtk_grid_get_child_at(GTK_GRID(box), z, 0) == handle2) | |
8920 { | |
8921 gtk_grid_remove_column(GTK_GRID(box), z); | |
8922 break; | |
8923 } | |
8924 } | |
8925 } | |
8926 #else | |
8895 gtk_container_remove(GTK_CONTAINER(box), handle2); | 8927 gtk_container_remove(GTK_CONTAINER(box), handle2); |
8928 #endif | |
8896 retcode = DW_ERROR_NONE; | 8929 retcode = DW_ERROR_NONE; |
8897 } | 8930 } |
8898 } | 8931 } |
8899 DW_MUTEX_UNLOCK; | 8932 DW_MUTEX_UNLOCK; |
8900 return retcode; | 8933 return retcode; |
8918 if(GTK_IS_GRID(box)) | 8951 if(GTK_IS_GRID(box)) |
8919 { | 8952 { |
8920 /* Get the number of items in the box... */ | 8953 /* Get the number of items in the box... */ |
8921 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); | 8954 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); |
8922 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype")); | 8955 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype")); |
8956 #if GTK_CHECK_VERSION(3,10,0) | |
8957 GtkWidget *item = (boxtype == DW_VERT) ? gtk_grid_get_child_at(GTK_GRID(box), 0, index) : gtk_grid_get_child_at(GTK_GRID(box), index, 0); | |
8958 #else | |
8923 GtkWidget *item; | 8959 GtkWidget *item; |
8924 | 8960 |
8925 #if !GTK_CHECK_VERSION(3,10,0) | |
8926 /* Fix the index by taking into account empty cells */ | 8961 /* Fix the index by taking into account empty cells */ |
8927 if(boxtype == DW_VERT) | 8962 if(boxtype == DW_VERT) |
8928 { | 8963 { |
8929 int z; | 8964 int z; |
8930 | 8965 |
8953 /* Decrease the count by 1 */ | 8988 /* Decrease the count by 1 */ |
8954 boxcount--; | 8989 boxcount--; |
8955 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount)); | 8990 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount)); |
8956 } | 8991 } |
8957 /* If we haven't incremented the reference count... raise it before removal */ | 8992 /* If we haven't incremented the reference count... raise it before removal */ |
8958 if(g_object_get_data(G_OBJECT(item), "_dw_padding")) | 8993 if(item && g_object_get_data(G_OBJECT(item), "_dw_padding")) |
8959 gtk_widget_destroy(item); | 8994 gtk_widget_destroy(item); |
8960 else | 8995 else if(item) |
8961 { | 8996 { |
8962 if(!g_object_get_data(G_OBJECT(item), "_dw_refed")) | 8997 if(!g_object_get_data(G_OBJECT(item), "_dw_refed")) |
8963 { | 8998 { |
8964 g_object_ref(G_OBJECT(item)); | 8999 g_object_ref(G_OBJECT(item)); |
8965 g_object_set_data(G_OBJECT(item), "_dw_refed", GINT_TO_POINTER(1)); | 9000 g_object_set_data(G_OBJECT(item), "_dw_refed", GINT_TO_POINTER(1)); |
8966 } | 9001 } |
8967 /* Remove the widget from the box */ | 9002 /* Remove the widget from the box */ |
8968 gtk_container_remove(GTK_CONTAINER(box), item); | 9003 gtk_container_remove(GTK_CONTAINER(box), item); |
9004 #if GTK_CHECK_VERSION(3,10,0) | |
9005 if(boxtype == DW_VERT) | |
9006 gtk_grid_remove_row(GTK_GRID(box), index); | |
9007 else | |
9008 gtk_grid_remove_column(GTK_GRID(box), index); | |
9009 #endif | |
8969 retval = item; | 9010 retval = item; |
8970 } | 9011 } |
8971 } | 9012 } |
8972 DW_MUTEX_UNLOCK; | 9013 DW_MUTEX_UNLOCK; |
8973 return retval; | 9014 return retval; |