-
Notifications
You must be signed in to change notification settings - Fork 0
/
unloadShelfTab.mel
142 lines (125 loc) · 4.07 KB
/
unloadShelfTab.mel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// ===========================================================================
// Copyright 2018 Autodesk, Inc. All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
// ===========================================================================
//
//
// Creation Date: 1996
//
//
//<doc>
//<name unloadShelfTab>
//
//<synopsis>
// unloadShelfTab (string $shelfName)
//
//<returns>
// int : 1 = shelf tab was unloaded
// 0 = if shelf tab not unloaded
//
//<description>
// Unloads a shelf layout and tab from the top level shelves,
// and removes its preferences so that it will not be loaded
// again. The user is not prompted for confirmation of the unload.
//
//<flags>
// string $shelfName Name of the shelf tab to unload
//
//<examples>
// unloadShelfTab "Shelf2";
//
//</doc>
global proc int unloadShelfTab(string $shelfName)
{
int $returnStatus = 0;
global string $gShelfForm;
global string $gShelfTopLevel;
setParent $gShelfTopLevel;
string $shelves[] = `tabLayout -q -ca $gShelfTopLevel`;
int $numShelves = size($shelves);
int $indexArr[];
int $index = 0;
int $nItems = 0;
// Bail if there is something really weird going on
if ($numShelves <= 0) return $returnStatus;
// Check for the last shelf
string $ok = (uiRes("m_deleteShelfTab.kOK"));
if (1 == $numShelves) {
confirmDialog -title (uiRes("m_deleteShelfTab.kAlert"))
-button $ok
-defaultButton $ok
-message (uiRes("m_deleteShelfTab.kCannotDelete")) ;
return $returnStatus;
}
// Confirm the delete
if(!`exists shelfLabel_melToUI` ){
source "shelfLabel.mel";
}
// string $msg = (uiRes("m_deleteShelfTab.kDeletionConfirmMsg"));
// string $shelfLabel = `shelfLabel_melToUI $shelfName`;
// string $dlgMsg = `format -s $shelfLabel $msg`;
// string $cancel = (uiRes("m_deleteShelfTab.kCancel"));
//
// if ($cancel == `confirmDialog -title (uiRes("m_deleteShelfTab.kConfirm"))
// -message $dlgMsg -button $ok -button $cancel -defaultButton $ok
// -cancelButton $cancel -dismissString $cancel `)
// {
// return $returnStatus;
// }
// Okay, now we can delete the shelf tab
int $i = 0;
int $nShelves = 0;
int $shelfNum = 0;
// update the preferences.
//
$nShelves = `shelfTabLayout -q -numberOfChildren $gShelfTopLevel`;
for ($shelfNum = 1; $shelfNum <= $nShelves; $shelfNum++) {
if ($shelfName == `optionVar -q ("shelfName" + $shelfNum)`) {
break;
}
}
for ($i = $shelfNum; $i <= $nShelves; $i++) {
string $align = "left";
if ( `optionVar -ex ("shelfAlign" + ($i+1))` )
$align = `optionVar -q ("shelfAlign" + ($i+1))`;
optionVar
-iv ("shelfLoad" + $i) `optionVar -q ("shelfLoad" + ($i+1))`
-sv ("shelfName" + $i) `optionVar -q ("shelfName" + ($i+1))`
-sv ("shelfAlign" + $i) $align
-sv ("shelfFile" + $i) `optionVar -q ("shelfFile" + ($i+1))`;
}
optionVar -remove ("shelfLoad" + $nShelves)
-remove ("shelfName" + $nShelves)
-remove ("shelfAlign" + $nShelves)
-remove ("shelfFile" + $nShelves);
// The optionVars have all been updated, so it's safe to delete and have
// the shelfTabChange() method triggered. See Maya-3288.
//
deleteUI -layout ($gShelfTopLevel + "|" + $shelfName);
string $shelfDirs = `internalVar -userShelfDir`;
string $shelfArray[];
string $PATH_SEPARATOR = `about -win`? ";" : ":";
tokenize($shelfDirs, $PATH_SEPARATOR, $shelfArray);
// for( $i = 0; $i < size($shelfArray); $i++ ) {
// $fileName = ($shelfArray[$i] + "shelf_" + $shelfName + ".mel");
// string $deletedFileName = $fileName + ".deleted";
//
// // Fix for bug #125494. Remove the .deleted file if it already exists.
// //
// if (`filetest -r $deletedFileName`) {
// sysFile -delete $deletedFileName;
// }
//
// if (`file -q -exists $fileName`) {
// sysFile -rename $deletedFileName $fileName;
// break;
// }
// }
// Make sure the new active shelf tab has buttons.
shelfTabChange();
$returnStatus = 1;
return $returnStatus;
}