summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorpspjuth <peter.spjuth@gmail.com>2011-04-04 22:04:44 (GMT)
committerpspjuth <peter.spjuth@gmail.com>2011-04-04 22:04:44 (GMT)
commit729b182c73533288d07321d9e0c0bcf92ece3275 (patch)
tree59fa32cb600d581b823ee117849f74e814fd7713 /generic
parent257f68b64daa01121d80bf4bdf9bfdadd30f997d (diff)
downloadtk-729b182c73533288d07321d9e0c0bcf92ece3275.zip
tk-729b182c73533288d07321d9e0c0bcf92ece3275.tar.gz
tk-729b182c73533288d07321d9e0c0bcf92ece3275.tar.bz2
[Bug 723765]: When a slave was removed from grid,
the -in option was not remembered.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkGrid.c40
1 files changed, 40 insertions, 0 deletions
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);