Mercurial > dwindows
comparison gtk3/dw.c @ 1656:01f59ba51e7f
Take into account empty box cells created by dw_window_destroy() in GTK3
when packing new items with dw_box_pack_at_index().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 10 Apr 2012 11:34:20 +0000 |
parents | c8a0daa53e49 |
children | 36a090da4cb1 |
comparison
equal
deleted
inserted
replaced
1655:de4b88ee7ad8 | 1656:01f59ba51e7f |
---|---|
2423 { | 2423 { |
2424 gtk_mdi_remove(GTK_MDI(mdi), handle); | 2424 gtk_mdi_remove(GTK_MDI(mdi), handle); |
2425 } | 2425 } |
2426 if(GTK_IS_WIDGET(handle)) | 2426 if(GTK_IS_WIDGET(handle)) |
2427 { | 2427 { |
2428 GtkWidget *box, *handle2 = handle; | |
2428 GtkWidget *eventbox = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_eventbox"); | 2429 GtkWidget *eventbox = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_eventbox"); |
2429 | 2430 |
2431 /* Handle the invisible event box if it exists */ | |
2430 if(eventbox && GTK_IS_WIDGET(eventbox)) | 2432 if(eventbox && GTK_IS_WIDGET(eventbox)) |
2431 gtk_widget_destroy(eventbox); | 2433 handle2 = eventbox; |
2432 else | 2434 |
2433 gtk_widget_destroy(handle); | 2435 /* Check if we are removing a widget from a box */ |
2436 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box)) | |
2437 { | |
2438 /* Get the number of items in the box... */ | |
2439 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); | |
2440 | |
2441 if(boxcount > 0) | |
2442 { | |
2443 /* Decrease the count by 1 */ | |
2444 boxcount--; | |
2445 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount)); | |
2446 } | |
2447 } | |
2448 /* Finally destroy the widget */ | |
2449 gtk_widget_destroy(handle2); | |
2434 } | 2450 } |
2435 DW_MUTEX_UNLOCK; | 2451 DW_MUTEX_UNLOCK; |
2436 return 0; | 2452 return 0; |
2437 } | 2453 } |
2438 | 2454 |
8522 /* Do some sanity bounds checking */ | 8538 /* Do some sanity bounds checking */ |
8523 if(index < 0) | 8539 if(index < 0) |
8524 index = 0; | 8540 index = 0; |
8525 if(index > boxcount) | 8541 if(index > boxcount) |
8526 index = boxcount; | 8542 index = boxcount; |
8543 | |
8544 /* Fix the index by taking into account empty cells */ | |
8545 if(boxtype == DW_VERT) | |
8546 { | |
8547 int z; | |
8548 | |
8549 for(z=0;z<index;z++) | |
8550 { | |
8551 if(!gtk_grid_get_child_at(GTK_GRID(box), 0, z)) | |
8552 index++; | |
8553 } | |
8554 } | |
8555 else | |
8556 { | |
8557 int z; | |
8558 | |
8559 for(z=0;z<index;z++) | |
8560 { | |
8561 if(!gtk_grid_get_child_at(GTK_GRID(box), z, 0)) | |
8562 index++; | |
8563 } | |
8564 } | |
8527 | 8565 |
8528 g_object_set_data(G_OBJECT(item), "_dw_table", box); | 8566 g_object_set_data(G_OBJECT(item), "_dw_table", box); |
8529 /* Set the expand attribute on the widgets now instead of the container */ | 8567 /* Set the expand attribute on the widgets now instead of the container */ |
8530 gtk_widget_set_vexpand(item, vsize); | 8568 gtk_widget_set_vexpand(item, vsize); |
8531 gtk_widget_set_valign(item, vsize ? GTK_ALIGN_FILL : GTK_ALIGN_START); | 8569 gtk_widget_set_valign(item, vsize ? GTK_ALIGN_FILL : GTK_ALIGN_START); |