comparison gtk3/dw.c @ 1890:0f3df50bfc4f

Untested GTK3 change to use the new gtk_grid_remove_*() which were introduced in version 3.10. I don't have 3.10 installed yet, but will test this code soon. These allow me to remove a crude work-around in earlier versions that skipped over empty grid spaces. In 3.10 and later the grid should contract and remove the unused rows/columns. Might need a similar change in dw_box_unpack().
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 08 Oct 2013 18:30:39 +0000
parents 09860ba329a4
children 11a16c117748
comparison
equal deleted inserted replaced
1889:fef27d312696 1890:0f3df50bfc4f
2458 /* Check if we are removing a widget from a box */ 2458 /* Check if we are removing a widget from a box */
2459 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box)) 2459 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box))
2460 { 2460 {
2461 /* Get the number of items in the box... */ 2461 /* Get the number of items in the box... */
2462 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); 2462 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount"));
2463 #if GTK_CHECK_VERSION(3,10,0)
2464 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype"));
2465 int z;
2466
2467 /* Figure out where in the grid this widget is and remove that row/column */
2468 if(boxtype == DW_VERT)
2469 {
2470 for(z=0;z<index;z++)
2471 {
2472 if(gtk_grid_get_child_at(GTK_GRID(box), 0, z) == handle2)
2473 {
2474 gtk_grid_remove_row(GTK_GRID(box), z);
2475 break;
2476 }
2477 }
2478 }
2479 else
2480 {
2481 for(z=0;z<index;z++)
2482 {
2483 if(gtk_grid_get_child_at(GTK_GRID(box), z, 0) == handle2)
2484 {
2485 gtk_grid_remove_column(GTK_GRID(box), z);
2486 break;
2487 }
2488 }
2489 }
2490 #endif
2463 2491
2464 if(boxcount > 0) 2492 if(boxcount > 0)
2465 { 2493 {
2466 /* Decrease the count by 1 */ 2494 /* Decrease the count by 1 */
2467 boxcount--; 2495 boxcount--;
8711 { 8739 {
8712 /* Only show warning if item is not a box */ 8740 /* Only show warning if item is not a box */
8713 warn = TRUE; 8741 warn = TRUE;
8714 } 8742 }
8715 8743
8744 #if !GTK_CHECK_VERSION(3,10,0)
8716 /* Do some sanity bounds checking */ 8745 /* Do some sanity bounds checking */
8717 if(index < 0) 8746 if(index < 0)
8718 index = 0; 8747 index = 0;
8719 if(index > boxcount) 8748 if(index > boxcount)
8720 index = boxcount; 8749 index = boxcount;
8738 { 8767 {
8739 if(!gtk_grid_get_child_at(GTK_GRID(box), z, 0)) 8768 if(!gtk_grid_get_child_at(GTK_GRID(box), z, 0))
8740 index++; 8769 index++;
8741 } 8770 }
8742 } 8771 }
8772 #endif
8743 8773
8744 g_object_set_data(G_OBJECT(item), "_dw_table", box); 8774 g_object_set_data(G_OBJECT(item), "_dw_table", box);
8745 /* Set the expand attribute on the widgets now instead of the container */ 8775 /* Set the expand attribute on the widgets now instead of the container */
8746 gtk_widget_set_vexpand(item, vsize); 8776 gtk_widget_set_vexpand(item, vsize);
8747 gtk_widget_set_valign(item, vsize ? GTK_ALIGN_FILL : GTK_ALIGN_START); 8777 gtk_widget_set_valign(item, vsize ? GTK_ALIGN_FILL : GTK_ALIGN_START);
8890 /* Get the number of items in the box... */ 8920 /* Get the number of items in the box... */
8891 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); 8921 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount"));
8892 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype")); 8922 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype"));
8893 GtkWidget *item; 8923 GtkWidget *item;
8894 8924
8925 #if !GTK_CHECK_VERSION(3,10,0)
8895 /* Fix the index by taking into account empty cells */ 8926 /* Fix the index by taking into account empty cells */
8896 if(boxtype == DW_VERT) 8927 if(boxtype == DW_VERT)
8897 { 8928 {
8898 int z; 8929 int z;
8899 8930
8913 if(!gtk_grid_get_child_at(GTK_GRID(box), z, 0)) 8944 if(!gtk_grid_get_child_at(GTK_GRID(box), z, 0))
8914 index++; 8945 index++;
8915 } 8946 }
8916 item = gtk_grid_get_child_at(GTK_GRID(box), index, 0); 8947 item = gtk_grid_get_child_at(GTK_GRID(box), index, 0);
8917 } 8948 }
8949 #endif
8918 8950
8919 if(boxcount > 0) 8951 if(boxcount > 0)
8920 { 8952 {
8921 /* Decrease the count by 1 */ 8953 /* Decrease the count by 1 */
8922 boxcount--; 8954 boxcount--;