mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 870011 - Allow user to restore customized toolbars and panels to their default states without a restart. r=mconley.
This commit is contained in:
parent
437e466e20
commit
ce2573c749
@ -1420,6 +1420,24 @@ let CustomizableUIInternal = {
|
||||
reset: function() {
|
||||
Services.prefs.clearUserPref(kPrefCustomizationState);
|
||||
LOG("State reset");
|
||||
|
||||
// Reset placements to make restoring default placements possible.
|
||||
gPlacements = new Map();
|
||||
// Clear the saved state to ensure that defaults will be used.
|
||||
gSavedState = null;
|
||||
// Restore the state for each area to its defaults
|
||||
for (let [area, defaultPlacements] of gDefaultPlacements) {
|
||||
this.restoreStateForArea(area);
|
||||
}
|
||||
|
||||
// Rebuild each registered area (across windows) to reflect the state that
|
||||
// was reset above.
|
||||
for (let [areaId, areaNodes] of gBuildAreas) {
|
||||
let placements = gPlacements.get(areaId);
|
||||
for (let areaNode of areaNodes) {
|
||||
this.buildArea(areaId, placements, areaNode);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_addParentFlex: function(aElement) {
|
||||
|
@ -124,23 +124,7 @@ CustomizeMode.prototype = {
|
||||
deck.addEventListener("transitionend", function customizeTransitionEnd() {
|
||||
deck.removeEventListener("transitionend", customizeTransitionEnd);
|
||||
|
||||
// Add drag-and-drop event handlers to all of the customizable areas.
|
||||
self.areas = [];
|
||||
for (let area of CustomizableUI.areas) {
|
||||
let target = CustomizableUI.getCustomizeTargetForArea(area, window);
|
||||
target.addEventListener("dragstart", self);
|
||||
target.addEventListener("dragover", self);
|
||||
target.addEventListener("dragexit", self);
|
||||
target.addEventListener("drop", self);
|
||||
target.addEventListener("dragend", self);
|
||||
for (let child of target.children) {
|
||||
if (self.isCustomizableItem(child)) {
|
||||
self.wrapToolbarItem(child, getPlaceForItem(child));
|
||||
}
|
||||
}
|
||||
self.areas.push(target);
|
||||
}
|
||||
|
||||
self._wrapToolbarItems();
|
||||
self.populatePalette();
|
||||
self.dispatchToolboxEvent("customizationready");
|
||||
});
|
||||
@ -195,18 +179,7 @@ CustomizeMode.prototype = {
|
||||
documentElement.removeAttribute("customize-exiting");
|
||||
});
|
||||
|
||||
for (let target of this.areas) {
|
||||
for (let toolbarItem of target.children) {
|
||||
if (this.isWrappedToolbarItem(toolbarItem)) {
|
||||
this.unwrapToolbarItem(toolbarItem);
|
||||
}
|
||||
}
|
||||
target.removeEventListener("dragstart", this);
|
||||
target.removeEventListener("dragover", this);
|
||||
target.removeEventListener("dragexit", this);
|
||||
target.removeEventListener("drop", this);
|
||||
target.removeEventListener("dragend", this);
|
||||
}
|
||||
this._unwrapToolbarItems();
|
||||
|
||||
if (this._changed) {
|
||||
// XXXmconley: At first, it seems strange to also persist the old way with
|
||||
@ -446,6 +419,41 @@ CustomizeMode.prototype = {
|
||||
return toolbarItem;
|
||||
},
|
||||
|
||||
_wrapToolbarItems: function() {
|
||||
let window = this.window;
|
||||
// Add drag-and-drop event handlers to all of the customizable areas.
|
||||
this.areas = [];
|
||||
for (let area of CustomizableUI.areas) {
|
||||
let target = CustomizableUI.getCustomizeTargetForArea(area, window);
|
||||
target.addEventListener("dragstart", this);
|
||||
target.addEventListener("dragover", this);
|
||||
target.addEventListener("dragexit", this);
|
||||
target.addEventListener("drop", this);
|
||||
target.addEventListener("dragend", this);
|
||||
for (let child of target.children) {
|
||||
if (this.isCustomizableItem(child)) {
|
||||
this.wrapToolbarItem(child, getPlaceForItem(child));
|
||||
}
|
||||
}
|
||||
this.areas.push(target);
|
||||
}
|
||||
},
|
||||
|
||||
_unwrapToolbarItems: function() {
|
||||
for (let target of this.areas) {
|
||||
for (let toolbarItem of target.children) {
|
||||
if (this.isWrappedToolbarItem(toolbarItem)) {
|
||||
this.unwrapToolbarItem(toolbarItem);
|
||||
}
|
||||
}
|
||||
target.removeEventListener("dragstart", this);
|
||||
target.removeEventListener("dragover", this);
|
||||
target.removeEventListener("dragexit", this);
|
||||
target.removeEventListener("drop", this);
|
||||
target.removeEventListener("dragend", this);
|
||||
}
|
||||
},
|
||||
|
||||
persistCurrentSets: function() {
|
||||
let document = this.document;
|
||||
let toolbars = document.querySelectorAll("toolbar[customizable='true']");
|
||||
@ -459,7 +467,25 @@ CustomizeMode.prototype = {
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
this.depopulatePalette();
|
||||
this._unwrapToolbarItems();
|
||||
|
||||
CustomizableUI.reset();
|
||||
|
||||
this._wrapToolbarItems();
|
||||
this.populatePalette();
|
||||
|
||||
let document = this.document;
|
||||
let toolbars = document.querySelectorAll("toolbar[customizable='true']");
|
||||
for (let toolbar of toolbars) {
|
||||
let set = toolbar.currentSet;
|
||||
toolbar.removeAttribute("currentset");
|
||||
LOG("[RESET] Removing currentset of " + toolbar.id);
|
||||
// Persist the currentset attribute directly on hardcoded toolbars.
|
||||
document.persist(toolbar.id, "currentset");
|
||||
}
|
||||
|
||||
this.resetButton.hidden = CustomizableUI.inDefaultState;
|
||||
},
|
||||
|
||||
onWidgetMoved: function(aWidgetId, aArea, aOldPosition, aNewPosition) {
|
||||
|
Loading…
Reference in New Issue
Block a user