summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--generic/tkGrid.c40
-rw-r--r--tests/grid.test60
3 files changed, 106 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 30150b8..d7b9eb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2011-04-04 Peter Spjuth <peter.spjuth@gmail.com>
+ * tests/grid.test:
+ * generic/tkGrid.c: [Bug 723765]: When a slave was removed from grid,
+ the -in option was not remembered.
+
+2011-04-04 Peter Spjuth <peter.spjuth@gmail.com>
+
* doc/labelframe.n:
* doc/frame.n:
* generic/tkFrame.c: [Bug 2997657]: Removed -container from labelframe
diff --git a/generic/tkGrid.c b/generic/tkGrid.c
index 29848a8..4a38f16 100644
--- a/generic/tkGrid.c
+++ b/generic/tkGrid.c
@@ -167,6 +167,7 @@ typedef struct Gridder {
struct Gridder *slavePtr; /* First in list of slaves managed inside this
* window (NULL means no grid slaves). */
GridMaster *masterDataPtr; /* Additional data for geometry master. */
+ Tcl_Obj *in; /* Store master name when removed. */
int column, row; /* Location in the grid (starting from
* zero). */
int numCols, numRows; /* Number of columns or rows this slave spans.
@@ -654,12 +655,31 @@ GridForgetRemoveCommand(
slavePtr->padTop = 0;
slavePtr->iPadX = 0;
slavePtr->iPadY = 0;
+ if (slavePtr->in != NULL) {
+ Tcl_DecrRefCount(slavePtr->in);
+ slavePtr->in = NULL;
+ }
slavePtr->doubleBw = 2*Tk_Changes(tkwin)->border_width;
if (slavePtr->flags & REQUESTED_RELAYOUT) {
Tcl_CancelIdleCall(ArrangeGrid, (ClientData) slavePtr);
}
slavePtr->flags = 0;
slavePtr->sticky = 0;
+ } else {
+ /*
+ * When removing, store name of master to be able to
+ * restore it later, even if the master is recreated.
+ */
+
+ if (slavePtr->in != NULL) {
+ Tcl_DecrRefCount(slavePtr->in);
+ slavePtr->in = NULL;
+ }
+ if (slavePtr->masterPtr != NULL) {
+ slavePtr->in = Tcl_NewStringObj(
+ Tk_PathName(slavePtr->masterPtr->tkwin), -1);
+ Tcl_IncrRefCount(slavePtr->in);
+ }
}
Tk_ManageGeometry(slave, NULL, (ClientData) NULL);
if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
@@ -2420,6 +2440,7 @@ GetGrid(
gridPtr->flags = 0;
gridPtr->sticky = 0;
gridPtr->size = 0;
+ gridPtr->in = NULL;
gridPtr->masterDataPtr = NULL;
Tcl_SetHashValue(hPtr, gridPtr);
Tk_CreateEventHandler(tkwin, StructureNotifyMask,
@@ -2762,6 +2783,9 @@ DestroyGrid(
}
ckfree((char *) gridPtr->masterDataPtr);
}
+ if (gridPtr->in != NULL) {
+ Tcl_DecrRefCount(gridPtr->in);
+ }
ckfree((char *) gridPtr);
}
@@ -2919,6 +2943,22 @@ ConfigureSlaves(
return TCL_ERROR;
}
if (masterPtr == NULL) {
+ /*
+ * Is there any saved -in from a removed slave?
+ * If there is, it becomes default for -in.
+ * If the stored master does not exist, just ignore it.
+ */
+
+ struct Gridder *slavePtr = GetGrid(slave);
+ if (slavePtr->in != NULL) {
+ if (TkGetWindowFromObj(interp, slave, slavePtr->in, &parent)
+ == TCL_OK) {
+ masterPtr = GetGrid(parent);
+ InitMasterData(masterPtr);
+ }
+ }
+ }
+ if (masterPtr == NULL) {
parent = Tk_Parent(slave);
if (parent != NULL) {
masterPtr = GetGrid(parent);
diff --git a/tests/grid.test b/tests/grid.test
index d6e3e88..a300799 100644
--- a/tests/grid.test
+++ b/tests/grid.test
@@ -1952,6 +1952,66 @@ test grid-21.7 {anchor} {
{37 60 225 150}]
grid_reset 21.7
+test grid-22.1 {remove: basic argument checking} {
+ list [catch {grid remove foo} msg] $msg
+} {1 {bad window path name "foo"}}
+
+test grid-22.2 {remove} {
+ button .c
+ grid [button .b]
+ set a [grid slaves .]
+ grid remove .b .c
+ lappend a [grid slaves .]
+ set a
+} {.b {}}
+grid_reset 22.2
+
+test grid-22.3 {remove} {
+ button .c
+ grid .c -row 2 -column 2 -rowspan 2 -columnspan 2 -padx 3 -pady 4 -sticky ns
+ grid remove .c
+ grid .c -row 0 -column 0
+ grid info .c
+} {-in . -column 0 -row 0 -columnspan 2 -rowspan 2 -ipadx 0 -ipady 0 -padx 3 -pady 4 -sticky ns}
+grid_reset 22.3
+
+test grid-22.3.1 {remove} {
+ frame .a
+ button .c
+ grid .c -in .a -row 2 -column 2 -rowspan 2 -columnspan 2 -padx {3 5} -pady {4 7} -sticky ns
+ grid remove .c
+ grid .c -row 0 -column 0
+ grid info .c
+} {-in .a -column 0 -row 0 -columnspan 2 -rowspan 2 -ipadx 0 -ipady 0 -padx {3 5} -pady {4 7} -sticky ns}
+grid_reset 22.3.1
+
+test grid-22.4 {remove, calling Tk_UnmaintainGeometry} {
+ frame .f -bd 2 -relief raised
+ place .f -x 10 -y 20 -width 200 -height 100
+ frame .f2 -width 50 -height 30 -bg red
+ grid .f2 -in .f
+ update
+ set x [winfo ismapped .f2]
+ grid remove .f2
+ place .f -x 30
+ update
+ lappend x [winfo ismapped .f2]
+} {1 0}
+grid_reset 22.4
+
+test grid-22.5 {remove} {
+ frame .a
+ button .c
+ grid .c -in .a -row 2 -column 2 -rowspan 2 -columnspan 2 -padx {3 5} -pady {4 7} -sticky ns
+ grid remove .c
+ # If .a was destroyed while remembered by the removed .c, make sure it
+ # is ignored.
+ destroy .a
+ grid .c -row 0 -column 0
+ grid info .c
+} {-in . -column 0 -row 0 -columnspan 2 -rowspan 2 -ipadx 0 -ipady 0 -padx {3 5} -pady {4 7} -sticky ns}
+grid_reset 22.5
+
# cleanup
cleanupTests
return