Redo tabs => spaces indentation change to not lose manual indentation

Revert most JS changes in commit:

    Fri Nov 28 20:12:20 2008 +0000
    Convert all JS style to be uniform, add Eclipse settings bits

Instead, just add 'indent-tabs-mode: nil' to the mode lines and convert
tabs to spaces. The indentation no longer exactly matches the Eclipse
settings, since they differ in some ways from the style we are trying
to achieve.

svn path=/trunk/; revision=97
This commit is contained in:
Owen Taylor 2008-12-01 19:51:43 +00:00
parent 12720e2c90
commit 7b471645f4
7 changed files with 1049 additions and 1045 deletions

View File

@ -1,4 +1,4 @@
/* -*- mode: js2; js2-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*- */
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Signals = imports.signals;
const Clutter = imports.gi.Clutter;
@ -10,11 +10,11 @@ const Tidy = imports.gi.Tidy;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
//TODO - move this into GConf once we're not a plugin anymore
//but have taken over metacity
//This list is taken from GNOME Online popular applications
//http://online.gnome.org/applications
//but with nautilus removed
// TODO - move this into GConf once we're not a plugin anymore
// but have taken over metacity
// This list is taken from GNOME Online popular applications
// http://online.gnome.org/applications
// but with nautilus removed
const DEFAULT_APPLICATIONS = [
'mozilla-firefox.desktop',
'gnome-terminal.desktop',
@ -34,7 +34,7 @@ const DEFAULT_APPLICATIONS = [
'eclipse.desktop',
'openoffice.org-1.9-impress.desktop',
'vncviewer.desktop'
];
];
const APPDISPLAY_NAME_COLOR = new Clutter.Color();
APPDISPLAY_NAME_COLOR.from_pixel(0xffffffff);
@ -53,7 +53,7 @@ function AppDisplayItem(node, width) {
}
AppDisplayItem.prototype = {
_init: function(appinfo, width) {
_init: function(appinfo, width) {
let me = this;
this._appinfo = appinfo;
@ -69,7 +69,8 @@ _init: function(appinfo, width) {
return true;
});
this._bg = new Clutter.Rectangle({ color: APPDISPLAY_BACKGROUND_COLOR,
x: 0, y: 0, width: width, height: APPDISPLAY_HEIGHT });
x: 0, y: 0,
width: width, height: APPDISPLAY_HEIGHT });
this._group.add_actor(this._bg);
this._icon = new Clutter.Texture({ width: 48, height: 48, x: 0, y: 0 });
@ -104,22 +105,23 @@ _init: function(appinfo, width) {
y: this._name.height + 4})
this._group.add_actor(this._comment);
this.actor = this._group;
},
launch: function() {
},
launch: function() {
this._appinfo.launch([], null);
},
appinfo: function () {
},
appinfo: function () {
return this._appinfo;
},
markSelected: function(isSelected) {
},
markSelected: function(isSelected) {
let color;
if (isSelected)
color = APPDISPLAY_SELECTED_BACKGROUND_COLOR;
else
color = APPDISPLAY_BACKGROUND_COLOR;
this._bg.color = color;
}
}
}
};
Signals.addSignalMethods(AppDisplayItem.prototype);
function AppDisplay(x, y, width, height) {
@ -127,7 +129,7 @@ function AppDisplay(x, y, width, height) {
}
AppDisplay.prototype = {
_init : function(x, y, width, height) {
_init : function(x, y, width, height) {
let me = this;
let global = Shell.Global.get();
this._search = '';
@ -143,12 +145,12 @@ _init : function(x, y, width, height) {
this._grid = new Tidy.Grid({x: x, y: y, width: width, height: height});
global.stage.add_actor(this._grid);
this._appset = {}; // Map<appid, appinfo>
this._displayed = {} // Map<appid, AppDisplay>
this._displayed = {}; // Map<appid, AppDisplay>
this._selectedIndex = -1;
this._max_items = this._height / (APPDISPLAY_HEIGHT + APPDISPLAY_PADDING);
},
},
_refreshCache: function() {
_refreshCache: function() {
let me = this;
if (!this._appsStale)
@ -165,22 +167,21 @@ _refreshCache: function() {
this._appset[appid] = appinfo;
}
this._appsStale = false;
},
},
_removeItem: function(appid) {
_removeItem: function(appid) {
let item = this._displayed[appid];
let group = item.actor;
group.destroy();
delete this._displayed[appid];
},
},
_removeAll: function() {
_removeAll: function() {
for (appid in this._displayed)
this._removeItem(appid);
},
},
_setDefaultList: function() {
_setDefaultList: function() {
this._removeAll();
let added = 0;
for (let i = 0; i < DEFAULT_APPLICATIONS.length && added < this._max_items; i++) {
@ -191,15 +192,15 @@ _setDefaultList: function() {
added += 1;
}
}
},
},
_getNDisplayed: function() {
_getNDisplayed: function() {
// Is there a better way to do .size() ?
let c = 0; for (i in this._displayed) { c += 1; };
return c;
},
},
_filterAdd: function(appid) {
_filterAdd: function(appid) {
let me = this;
let appinfo = this._appset[appid];
@ -214,15 +215,15 @@ _filterAdd: function(appid) {
let group = appdisplay.actor;
this._grid.add_actor(group);
this._displayed[appid] = appdisplay;
},
},
_filterRemove: function(appid) {
_filterRemove: function(appid) {
// In the future, do some sort of fade out or other effect here
let item = this._displayed[appid];
this._removeItem(item);
},
},
_appinfoMatches: function(appinfo, search) {
_appinfoMatches: function(appinfo, search) {
if (search == null || search == '')
return true;
let name = appinfo.get_name().toLowerCase();
@ -238,18 +239,18 @@ _appinfoMatches: function(appinfo, search) {
if (exec.indexOf(search) >= 0)
return true;
return false;
},
},
_sortApps: function(appids) {
_sortApps: function(appids) {
let me = this;
return appids.sort(function (a,b) {
let appA = me._appset[a];
let appB = me._appset[b];
return appA.get_name().localeCompare(appB.get_name());
});
},
},
_doSearchFilter: function() {
_doSearchFilter: function() {
this._removeAll();
let matchedApps = [];
for (appid in this._appset) {
@ -265,28 +266,28 @@ _doSearchFilter: function() {
for (let i = 0; i < matchedApps.length; i++) {
this._filterAdd(matchedApps[i]);
}
},
},
_redisplay: function() {
_redisplay: function() {
this._refreshCache();
if (!this._search)
this._setDefaultList();
else
this._doSearchFilter();
},
},
setSearch: function(text) {
setSearch: function(text) {
this._search = text.toLowerCase();
this._redisplay();
},
},
_findDisplayedByIndex: function(index) {
_findDisplayedByIndex: function(index) {
let displayedActors = this._grid.get_children();
let actor = displayedActors[index];
return this._findDisplayedByActor(actor);
},
},
_findDisplayedByActor: function(actor) {
_findDisplayedByActor: function(actor) {
for (appid in this._displayed) {
let item = this._displayed[appid];
if (item.actor == actor) {
@ -294,9 +295,9 @@ _findDisplayedByActor: function(actor) {
}
}
return null;
},
},
searchActivate: function() {
searchActivate: function() {
if (this._selectedIndex != -1) {
let selected = this._findDisplayedByIndex(this._selectedIndex);
selected.launch();
@ -310,9 +311,9 @@ searchActivate: function() {
let selectedMenuItem = this._findDisplayedByActor(selectedActor);
selectedMenuItem.launch();
this.emit('activated');
},
},
_selectIndex: function(index) {
_selectIndex: function(index) {
if (this._selectedIndex != -1) {
let prev = this._findDisplayedByIndex(this._selectedIndex);
log("demarking " + prev);
@ -322,31 +323,31 @@ _selectIndex: function(index) {
let item = this._findDisplayedByIndex(index);
log("marking " + item);
item.markSelected(true);
},
},
selectUp: function() {
selectUp: function() {
let prev = this._selectedIndex-1;
if (prev < 0)
return;
this._selectIndex(prev);
},
},
selectDown: function() {
selectDown: function() {
let next = this._selectedIndex+1;
let nDisplayed = this._getNDisplayed();
if (next >= nDisplayed)
return;
this._selectIndex(next);
},
},
show: function() {
show: function() {
this._redisplay();
this._grid.show();
},
},
hide: function() {
hide: function() {
this._grid.hide();
}
}
Signals.addSignalMethods(AppDisplay.prototype);
}
};
Signals.addSignalMethods(AppDisplay.prototype);

View File

@ -1,4 +1,4 @@
/* -*- mode: js2; js2-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*- */
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Clutter = imports.gi.Clutter;
const Tweener = imports.tweener.tweener;
@ -9,7 +9,7 @@ DEFAULT_BUTTON_COLOR.from_pixel(0xeeddccff);
const DEFAULT_PRESSED_BUTTON_COLOR = new Clutter.Color();
DEFAULT_PRESSED_BUTTON_COLOR.from_pixel(0xccbbaaff);
//Time for animation making the button darker
// Time for animation making the button darker
const ANIMATION_TIME = 0.3;
const NO_OPACITY = 0;
@ -23,8 +23,9 @@ function Button(text, buttonColor, pressedButtonColor, staysPressed, minWidth, m
}
Button.prototype = {
_init : function(text, buttonColor, pressedButtonColor, staysPressed, minWidth, minHeight) {
_init : function(text, buttonColor, pressedButtonColor, staysPressed, minWidth, minHeight) {
let me = this;
this._buttonColor = buttonColor
if (buttonColor == null)
this._buttonColor = DEFAULT_BUTTON_COLOR;
@ -100,9 +101,9 @@ _init : function(text, buttonColor, pressedButtonColor, staysPressed, minWidth,
}
return false;
});
},
},
release : function() {
release : function() {
if (!this._isBetweenPressAndRelease) {
this._active = false;
Tweener.removeTweens(this._pressedBackground);
@ -112,6 +113,5 @@ release : function() {
this._pressedBackground.set_opacity(NO_OPACITY);
}
}
}
}
}
};

View File

@ -1,4 +1,4 @@
/* -*- mode: js2; js2-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*- */
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Clutter = imports.gi.Clutter;
const Shell = imports.gi.Shell;
@ -18,26 +18,26 @@ let overlay = null;
let run_dialog = null;
let wm = null;
//The "FrameTicker" object is an object used to feed new frames to Tweener
//so it can update values and redraw. The default frame ticker for
//Tweener just uses a simple timeout at a fixed frame rate and has no idea
//of "catching up" by dropping frames.
//We substitute it with custom frame ticker here that connects Tweener to
//a Clutter.TimeLine. Now, Clutter.Timeline itself isn't a whole lot more
//sophisticated than a simple timeout at a fixed frame rate, but at least
//it knows how to drop frames. (See HippoAnimationManager for a more
//sophisticated view of continous time updates; even better is to pay
//attention to the vertical vblank and sync to that when possible.)
// The "FrameTicker" object is an object used to feed new frames to Tweener
// so it can update values and redraw. The default frame ticker for
// Tweener just uses a simple timeout at a fixed frame rate and has no idea
// of "catching up" by dropping frames.
//
// We substitute it with custom frame ticker here that connects Tweener to
// a Clutter.TimeLine. Now, Clutter.Timeline itself isn't a whole lot more
// sophisticated than a simple timeout at a fixed frame rate, but at least
// it knows how to drop frames. (See HippoAnimationManager for a more
// sophisticated view of continous time updates; even better is to pay
// attention to the vertical vblank and sync to that when possible.)
//
function ClutterFrameTicker() {
this._init();
}
ClutterFrameTicker.prototype = {
TARGET_FRAME_RATE : 60,
TARGET_FRAME_RATE : 60,
_init : function() {
_init : function() {
// We don't have a finite duration; tweener will tell us to stop
// when we need to stop, so use 1000 seconds as "infinity"
this._timeline = new Clutter.Timeline({ fps: this.TARGET_FRAME_RATE,
@ -49,9 +49,9 @@ _init : function() {
function(timeline, frame) {
me._onNewFrame(frame);
});
},
},
_onNewFrame : function(frame) {
_onNewFrame : function(frame) {
// Unfortunately the interface to to send a new frame to tweener
// is a simple "next frame" and there is no provision for signaling
// that frames have been skipped or just telling it the new time.
@ -69,16 +69,16 @@ _onNewFrame : function(frame) {
this.FRAME_RATE = this.TARGET_FRAME_RATE / delta;
this._frame = frame;
this.emit('prepare-frame');
},
},
start : function() {
start : function() {
this._timeline.start();
},
},
stop : function() {
stop : function() {
this._timeline.stop();
this._frame = 0;
}
}
};
Signals.addSignalMethods(ClutterFrameTicker.prototype);
@ -121,9 +121,9 @@ function start() {
wm = new WindowManager.WindowManager();
}
//Used to go into a mode where all keyboard and mouse input goes to
//the stage. Returns true if we successfully grabbed the keyboard and
//went modal, false otherwise
// Used to go into a mode where all keyboard and mouse input goes to
// the stage. Returns true if we successfully grabbed the keyboard and
// went modal, false otherwise
function startModal() {
let global = Shell.Global.get();

View File

@ -1,4 +1,4 @@
/* -*- mode: js2; js2-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*- */
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Signals = imports.signals;
const Mainloop = imports.mainloop;
@ -23,21 +23,21 @@ SIDESHOW_SEARCH_BG_COLOR.from_pixel(0xffffffff);
const SIDESHOW_TEXT_COLOR = new Clutter.Color();
SIDESHOW_TEXT_COLOR.from_pixel(0xffffffff);
//Time for initial animation going into overlay mode
// Time for initial animation going into overlay mode
const ANIMATION_TIME = 0.5;
//How much to scale the desktop down by in overlay mode
// How much to scale the desktop down by in overlay mode
const DESKTOP_SCALE = 0.75;
//Windows are slightly translucent in the overlay mode
// Windows are slightly translucent in the overlay mode
const WINDOW_OPACITY = 0.9 * 255;
//Define a layout scheme for small window counts. For larger
//counts we fall back to an algorithm. We need more schemes here
//unless we have a really good algorithm.
//Each triplet is [xCenter, yCenter, scale] where the scale
//is relative to the width of the desktop.
// Define a layout scheme for small window counts. For larger
// counts we fall back to an algorithm. We need more schemes here
// unless we have a really good algorithm.
//
// Each triplet is [xCenter, yCenter, scale] where the scale
// is relative to the width of the desktop.
const POSITIONS = {
1: [[0.5, 0.5, 0.8]],
2: [[0.25, 0.5, 0.4], [0.75, 0.5, 0.4]],
@ -51,7 +51,7 @@ function Sideshow(width) {
}
Sideshow.prototype = {
_init : function(width) {
_init : function(width) {
let me = this;
let global = Shell.Global.get();
@ -129,17 +129,17 @@ _init : function(width) {
this._appdisplay.connect('activated', function(appdisplay) {
me.emit('activated');
});
},
},
show: function() {
show: function() {
this._group.show();
this._appdisplay.show();
},
},
hide: function() {
hide: function() {
this._group.hide();
this._appdisplay.hide();
}
}
};
Signals.addSignalMethods(Sideshow.prototype);
@ -148,7 +148,7 @@ function Overlay() {
}
Overlay.prototype = {
_init : function() {
_init : function() {
let me = this;
let global = Shell.Global.get();
@ -179,9 +179,9 @@ _init : function() {
// startup-notification integration at least.
me._deactivate();
});
},
},
_recalculateSize: function () {
_recalculateSize: function () {
let global = Shell.Global.get();
let screenWidth = global.screen_width;
let screenHeight = global.screen_height;
@ -191,11 +191,12 @@ _recalculateSize: function () {
this._desktopHeight = screenHeight * DESKTOP_SCALE;
this._desktopX = screenWidth - this._desktopWidth - 10;
this._desktopY = Panel.PANEL_HEIGHT + (screenHeight - this._desktopHeight - Panel.PANEL_HEIGHT) / 2;
},
},
show : function() {
show : function() {
if (this.visible)
return;
this.visible = true;
let global = Shell.Global.get();
@ -252,11 +253,12 @@ show : function() {
// clones of them, this would obviously no longer be necessary.
global.window_group.hide()
this._group.show();
},
},
hide : function() {
hide : function() {
if (!this.visible)
return;
let global = Shell.Global.get();
this.visible = false;
@ -270,17 +272,17 @@ hide : function() {
this._sideshow.hide();
this._windowClones = [];
},
},
_createDesktopClone : function(w) {
_createDesktopClone : function(w) {
let clone = new Clutter.CloneTexture({ parent_texture: w.get_texture(),
reactive: true,
x: 0,
y: 0 });
this._addDesktop(clone);
},
},
_createDesktopRectangle : function() {
_createDesktopRectangle : function() {
let global = Shell.Global.get();
// In the case when we have a desktop window from the file manager, its height is
// full-screen, i.e. it includes the height of the panel, so we should not subtract
@ -295,9 +297,9 @@ _createDesktopRectangle : function() {
width: global.screen_width,
height: global.screen_height });
this._addDesktop(desktopRectangle);
},
},
_addDesktop : function(desktop) {
_addDesktop : function(desktop) {
let me = this;
this._windowClones.push(desktop);
@ -319,10 +321,10 @@ _addDesktop : function(desktop) {
function() {
me._deactivate();
});
},
},
//windowIndex == 0 => top in stacking order
_computeWindowPosition : function(windowIndex, numberOfWindows) {
// windowIndex == 0 => top in stacking order
_computeWindowPosition : function(windowIndex, numberOfWindows) {
if (numberOfWindows in POSITIONS)
return POSITIONS[numberOfWindows][windowIndex];
@ -338,9 +340,9 @@ _computeWindowPosition : function(windowIndex, numberOfWindows) {
let yCenter = xCenter;
return [xCenter, yCenter, fraction];
},
},
_createWindowClone : function(w, windowIndex, numberOfWindows) {
_createWindowClone : function(w, windowIndex, numberOfWindows) {
let me = this;
// We show the window using "clones" of the texture .. separate
@ -386,14 +388,14 @@ _createWindowClone : function(w, windowIndex, numberOfWindows) {
function(clone, event) {
me._activateWindow(w, event.get_time());
});
},
},
_activateWindow : function(w, time) {
_activateWindow : function(w, time) {
this._deactivate();
w.get_meta_window().activate(time);
},
},
_deactivate : function() {
_deactivate : function() {
Main.hide_overlay();
}
}
};

View File

@ -1,4 +1,4 @@
/* -*- mode: js2; js2-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*- */
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Clutter = imports.gi.Clutter;
const Mainloop = imports.mainloop;
@ -21,7 +21,7 @@ function Panel() {
}
Panel.prototype = {
_init : function() {
_init : function() {
let global = Shell.Global.get();
this._group = new Clutter.Group();
@ -96,11 +96,11 @@ _init : function() {
this._updateClock();
this._startClock();
},
},
// Struts determine the area along each side of the screen that is reserved
// and not available to applications
_setStruts: function() {
// Struts determine the area along each side of the screen that is reserved
// and not available to applications
_setStruts: function() {
let global = Shell.Global.get();
let struts = [
@ -120,9 +120,9 @@ _setStruts: function() {
let workspace = screen.get_workspace_by_index(i);
workspace.set_builtin_struts(struts);
}
},
},
_startClock: function() {
_startClock: function() {
let me = this;
// TODO: this makes the clock updated every 60 seconds, but not necessarily on the minute, so it is inaccurate
Mainloop.timeout_add_seconds(60,
@ -130,14 +130,14 @@ _startClock: function() {
me._updateClock();
return true;
});
},
},
_updateClock: function() {
_updateClock: function() {
this._clock.set_text(new Date().toLocaleFormat("%H:%M"));
return true;
},
},
overlayHidden: function() {
overlayHidden: function() {
this.button.release();
}
}
};

View File

@ -1,4 +1,4 @@
/* -*- mode: js2; js2-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*- */
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Signals = imports.signals;
const Shell = imports.gi.Shell;
@ -75,9 +75,9 @@ RunDialog.prototype = {
return false;
});
},
},
_run : function(command) {
_run : function(command) {
if (command) {
var p = new Shell.Process({'args' : [command]});
try {
@ -89,10 +89,11 @@ _run : function(command) {
}
this.emit('run');
},
},
show : function() {
show : function() {
let me = this;
if (this._group.visible) // Already shown
return false;
@ -114,19 +115,19 @@ show : function() {
global.stage.set_key_focus(this._entry);
return true;
},
},
hide : function() {
hide : function() {
if (!this._group.visible)
return;
this._group.hide();
Main.endModal();
},
},
destroy : function(){
destroy : function(){
this.hide();
this._group.destroy();
}
}
};
Signals.addSignalMethods(RunDialog.prototype);

View File

@ -1,4 +1,4 @@
/* -*- mode: js2; js2-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*- */
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Clutter = imports.gi.Clutter;
const Mainloop = imports.mainloop;
@ -15,7 +15,7 @@ function WindowManager() {
}
WindowManager.prototype = {
_init : function() {
_init : function() {
let me = this;
this._global = Shell.Global.get();
@ -31,9 +31,9 @@ _init : function() {
function(o) {
me.switchWorkspaceDone();
});
},
},
switchWorkspace : function(windows, from, to, direction) {
switchWorkspace : function(windows, from, to, direction) {
/* @direction is the direction that the "camera" moves, so the
* screen contents have to move one screen's worth in the
* opposite direction.
@ -98,9 +98,9 @@ switchWorkspace : function(windows, from, to, direction) {
time: SWITCH_ANIMATION_TIME,
transition: "easeOutBack"
});
},
},
switchWorkspaceDone : function() {
switchWorkspaceDone : function() {
let switchData = this._switchData;
if (!switchData)
return;
@ -120,6 +120,6 @@ switchWorkspaceDone : function() {
switchData.outGroup.destroy();
this._shellwm.completed_switch_workspace();
}
}
};