comparison gtk3/dw.c @ 1081:f9232a52367a

Implemented table rearranging on GTK3 allowing dw_box_pack_at_index() to work.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 28 Jun 2011 06:49:19 +0000
parents 27e9a063fbb5
children 173e49c2270f
comparison
equal deleted inserted replaced
1080:27e9a063fbb5 1081:f9232a52367a
8008 exit(exitcode); 8008 exit(exitcode);
8009 } 8009 }
8010 8010
8011 #define DW_EXPAND (GTK_EXPAND | GTK_SHRINK | GTK_FILL) 8011 #define DW_EXPAND (GTK_EXPAND | GTK_SHRINK | GTK_FILL)
8012 8012
8013 /* Internal function that changes the attachment properties in a table. */
8014 void _rearrange_table(GtkWidget *widget, gpointer data)
8015 {
8016 gint pos = GPOINTER_TO_INT(data);
8017 GtkContainer *cont = g_object_get_data(G_OBJECT(widget), "_dw_table");
8018 guint oldpos;
8019
8020 /* Drop out if missing table */
8021 if(!cont)
8022 return;
8023
8024 /* Check orientation */
8025 if(pos < 0)
8026 {
8027 /* Horz */
8028 pos = -(pos + 1);
8029 gtk_container_child_get(cont, widget, "left-attach", &oldpos, NULL);
8030 if(oldpos >= pos)
8031 {
8032 gtk_container_child_set(cont, widget, "left-attach", (oldpos + 1), "right-attach", (oldpos+2), NULL);
8033 }
8034 }
8035 else
8036 {
8037 /* Vert */
8038 gtk_container_child_get(cont, widget, "top-attach", &oldpos, NULL);
8039 if(oldpos >= pos)
8040 {
8041 gtk_container_child_set(cont, widget, "top-attach", (oldpos + 1), "bottom-attach", (oldpos+2), NULL);
8042 }
8043 }
8044 }
8045
8013 /* 8046 /*
8014 * Pack windows (widgets) into a box at an arbitrary location. 8047 * Pack windows (widgets) into a box at an arbitrary location.
8015 * Parameters: 8048 * Parameters:
8016 * box: Window handle of the box to be packed into. 8049 * box: Window handle of the box to be packed into.
8017 * item: Window handle of the item to be back. 8050 * item: Window handle of the item to be back.
8121 x = index; 8154 x = index;
8122 y = 0; 8155 y = 0;
8123 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1); 8156 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1);
8124 } 8157 }
8125 8158
8159 g_object_set_data(G_OBJECT(item), "_dw_table", box);
8160 gtk_container_forall(GTK_CONTAINER(box),_rearrange_table, GINT_TO_POINTER(boxtype == DW_VERT ? index : -(index+1)));
8126 gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad); 8161 gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad);
8127 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1)); 8162 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1));
8128 if(GTK_IS_SCROLLED_WINDOW(item)) 8163 if(GTK_IS_SCROLLED_WINDOW(item))
8129 { 8164 {
8130 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), width); 8165 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), width);
8294 if(boxtype == DW_VERT) 8329 if(boxtype == DW_VERT)
8295 gtk_table_resize(GTK_TABLE(box), boxcount + 1, 1); 8330 gtk_table_resize(GTK_TABLE(box), boxcount + 1, 1);
8296 else 8331 else
8297 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1); 8332 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1);
8298 8333
8334 g_object_set_data(G_OBJECT(item), "_dw_table", box);
8299 gtk_table_attach(GTK_TABLE(box), item, 0, 1, 0, 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad); 8335 gtk_table_attach(GTK_TABLE(box), item, 0, 1, 0, 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad);
8300 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1)); 8336 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1));
8301 if(GTK_IS_SCROLLED_WINDOW(item)) 8337 if(GTK_IS_SCROLLED_WINDOW(item))
8302 { 8338 {
8303 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), width); 8339 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), width);
9689 x = boxcount; 9725 x = boxcount;
9690 y = 0; 9726 y = 0;
9691 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1); 9727 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1);
9692 } 9728 }
9693 9729
9730 g_object_set_data(G_OBJECT(item), "_dw_table", box);
9694 gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad); 9731 gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad);
9695 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1)); 9732 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1));
9696 if(GTK_IS_SCROLLED_WINDOW(item)) 9733 if(GTK_IS_SCROLLED_WINDOW(item))
9697 { 9734 {
9698 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), width); 9735 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), width);