1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-16 21:23:41 +01:00

Finish the Great Opening Brace Correction.

This commit is contained in:
Doug Kearns
2009-11-09 16:03:00 +11:00
parent 8ef1674c6e
commit a7925705d7
22 changed files with 334 additions and 656 deletions

View File

@@ -25,19 +25,16 @@ AboutHandler.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
newChannel: function (uri)
{
newChannel: function (uri) {
let channel = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService)
.newChannel("chrome://" + name + "/content/about.html", null, null);
channel.originalURI = uri;
return channel;
},
getURIFlags: function (uri) Ci.nsIAboutModule.ALLOW_SCRIPT,
};
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([AboutHandler]);
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([AboutHandler])
// vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -11,8 +11,7 @@ const Name = "Xulmus";
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
const name = Name.toLowerCase();
function CommandLineHandler()
{
function CommandLineHandler() {
this.wrappedJSObject = this;
}
CommandLineHandler.prototype = {
@@ -30,20 +29,17 @@ CommandLineHandler.prototype = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsICommandLineHandler]),
handle: function (commandLine)
{
handle: function (commandLine) {
// TODO: handle remote launches differently?
try
{
try {
this.optionValue = commandLine.handleFlagWithParam(name, false);
}
catch (e)
{
catch (e) {
//"vimperator: option -vimperator requires an argument"
}
}
};
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler]);
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler])
// vim: set ft=javascript fdm=marker sw=4 ts=4 et:

View File

@@ -124,8 +124,7 @@ const config = { //{{{
function () { SBSubscribe(); }]
],
focusChange: function ()
{
focusChange: function () {
// Switch to -- PLAYER -- mode for Songbird Media Player.
if (config.isPlayerWindow)
liberator.mode = modes.PLAYER;
@@ -156,19 +155,16 @@ const config = { //{{{
],
// FIXME: tab arg and media tab exception?
stop: function (tab)
{
stop: function (tab) {
SBGetBrowser().mCurrentBrowser.stop();
},
init: function ()
{
init: function () {
// Adding a mode for Player
//modes.addMode("PLAYER"); // Player mode for songbird
// TODO: support 'nrformats'? -> probably not worth it --mst
function incrementURL(count)
{
function incrementURL(count) {
let matches = buffer.URL.match(/(.*?)(\d+)(\D*)$/);
if (!matches)
return void liberator.beep();
@@ -176,8 +172,7 @@ const config = { //{{{
let [, pre, number, post] = matches;
let newNumber = parseInt(number, 10) + count;
let newNumberStr = String(newNumber > 0 ? newNumber : 0);
if (number.match(/^0/)) // add 0009<C-a> should become 0010
{
if (number.match(/^0/)) { // add 0009<C-a> should become 0010
while (newNumberStr.length < number.length)
newNumberStr = "0" + newNumberStr;
}
@@ -185,19 +180,16 @@ const config = { //{{{
liberator.open(pre + newNumberStr + post);
}
function showServicePane(value)
{
function showServicePane(value) {
const key = "splitter.servicepane_splitter.was_collapsed";
gServicePane.open = value;
SBDataSetBoolValue(key, gServicePane.open);
}
function openDisplayPane(id)
{
function openDisplayPane(id) {
if (id == "servicepane")
showServicePane(true);
else
{
else {
let pane = document.getElementById(id);
let manager = Cc['@songbirdnest.com/Songbird/DisplayPane/Manager;1'].getService(Ci.sbIDisplayPaneManager);
let paneinfo = manager.getPaneInfo(pane._lastURL.stringValue);
@@ -209,8 +201,7 @@ const config = { //{{{
}
}
function closeDisplayPane(id)
{
function closeDisplayPane(id) {
if (id == "servicepane")
showServicePane(false);
else
@@ -270,8 +261,7 @@ const config = { //{{{
commands.add(["dpcl[ose]"],
"Close a display pane",
function (args)
{
function (args) {
let arg = args.literalArg;
if (arg in displayPanes)
@@ -289,8 +279,7 @@ const config = { //{{{
// TODO: this should accept a second arg to specify content
commands.add(["displayp[ane]", "dp[ane]", "dpope[n]"],
"Open a display pane",
function (args)
{
function (args) {
let arg = args.literalArg;
if (arg in displayPanes)
@@ -307,10 +296,8 @@ const config = { //{{{
commands.add(["pref[erences]", "prefs"],
"Show " + config.hostApplication + " preferences",
function (args)
{
if (args.bang) // open Songbird settings GUI dialog
{
function (args) {
if (args.bang) { // open Songbird settings GUI dialog
liberator.open("about:config",
(options["newtab"] && options.get("newtab").has("all", "prefs"))
? liberator.NEW_TAB : liberator.CURRENT_TAB);
@@ -332,8 +319,7 @@ const config = { //{{{
"Set the 'work offline' option",
"boolean", true,
{
setter: function (value)
{
setter: function (value) {
const ioService = services.get("io");
ioService.offline = !value;
options.setPref("browser.offline", ioService.offline);

View File

@@ -4,8 +4,8 @@
// given in the LICENSE.txt file included with this file.
function Library() //{{{
{
function Library() { //{{{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -14,8 +14,7 @@ function Library() //{{{
function toJSArray(enum) ArrayConverter.JSArray(enum)
function getArtistsArray()
{
function getArtistsArray() {
return toJSArray(MAIN_LIBRARY.getDistinctValuesForProperty(SBProperties.artistName));
}
@@ -44,8 +43,7 @@ function Library() //{{{
* @param {param} artist The artist name.
* @returns {string[]}
*/
getAlbums: function getAlbums(artist)
{
getAlbums: function getAlbums(artist) {
let albums = toJSArray(MAIN_LIBRARY.getItemsByProperty(SBProperties.artistName, artist))
.map(function (track) track.getProperty(SBProperties.albumName));
return util.Array.uniq(albums);
@@ -59,8 +57,7 @@ function Library() //{{{
* @param {param} album The album name.
* @returns {string[]}
*/
getTracks: function getTracks(artist, album)
{
getTracks: function getTracks(artist, album) {
const properties = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
.createInstance(Ci.sbIMutablePropertyArray);

View File

@@ -4,8 +4,8 @@
// given in the LICENSE.txt file included with this file.
function Player() //{{{
{
function Player() { //{{{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -26,22 +26,18 @@ function Player() //{{{
commandline.registerCallback("cancel", modes.SEARCH_VIEW_FORWARD, function () { player.onSearchCancel(); });
// interval (milliseconds)
function seek(interval, direction)
{
function seek(interval, direction) {
let position = gMM.playbackControl ? gMM.playbackControl.position : 0;
player.seekTo(position + (direction ? interval : -interval));
}
function focusTrack(mediaItem)
{
function focusTrack(mediaItem) {
SBGetBrowser().mediaTab.mediaPage.highlightItem(_SBGetCurrentView().getIndexForItem(mediaItem));
}
var mediaCoreListener = {
onMediacoreEvent: function (event)
{
switch (event.type)
{
onMediacoreEvent: function (event) {
switch (event.type) {
case Ci.sbIMediacoreEvent.BEFORE_TRACK_CHANGE:
liberator.log("Before track changed: " + event.data);
autocommands.trigger("TrackChangePre", { track: event.data });
@@ -193,8 +189,7 @@ function Player() //{{{
["N"], "Find the previous track",
function () { player.searchViewAgain(true);});
for (let i in util.range(0, 6))
{
for (let i in util.range(0, 6)) {
let (rating = i) {
mappings.add([modes.PLAYER],
["<C-" + rating + ">"], "Rate the current media item " + rating,
@@ -208,15 +203,13 @@ function Player() //{{{
commands.add(["f[ilter]"],
"Filter tracks based on keywords {genre/artist/album/track}",
function (args)
{
function (args) {
let library = LibraryUtils.mainLibrary;
let view = LibraryUtils.createStandardMediaListView(LibraryUtils.mainLibrary, args.literalArg);
if (view.length == 0)
liberator.echoerr("No Tracks matching the keywords");
else
{
else {
SBGetBrowser().loadMediaList(LibraryUtils.mainLibrary, null, null, view,
"chrome://songbird/content/mediapages/filtersPage.xul");
// TODO: make this focusTrack work ?
@@ -231,19 +224,15 @@ function Player() //{{{
commands.add(["load"],
"Load a playlist",
function (args)
{
function (args) {
let arg = args.literalArg;
if (arg)
{
if (arg) {
// load the selected playlist/smart playlist
let playlists = player.getPlaylists();
for ([i, list] in Iterator(playlists))
{
if (util.compareIgnoreCase(arg, list.name) == 0)
{
for ([i, list] in Iterator(playlists)) {
if (util.compareIgnoreCase(arg, list.name) == 0) {
SBGetBrowser().loadMediaList(playlists[i]);
focusTrack(_SBGetCurrentView().getItemByIndex(0));
return;
@@ -252,8 +241,7 @@ function Player() //{{{
liberator.echoerr("E475: Invalid argument: " + arg);
}
else
{
else {
// load main library if there are no args
_SBShowMainLibrary();
}
@@ -287,8 +275,7 @@ function Player() //{{{
commands.add(["see[k]"],
"Seek to a track position",
function (args)
{
function (args) {
let arg = args[0];
// intentionally supports 999:99:99
@@ -297,14 +284,12 @@ function Player() //{{{
function ms(t, m) Math.abs(parseInt(t, 10) * { s: 1000, m: 60000, h: 3600000 }[m])
if (/:/.test(arg))
{
if (/:/.test(arg)) {
let [seconds, minutes, hours] = arg.split(":").reverse();
hours = hours || 0;
var value = ms(seconds, "s") + ms(minutes, "m") + ms(hours, "h");
}
else
{
else {
if (!/[smh]/.test(arg.substr(-1)))
arg += "s"; // default to seconds
@@ -321,22 +306,18 @@ function Player() //{{{
commands.add(["mediav[iew]"],
"Change the current media view",
function (args)
{
function (args) {
// FIXME: is this a SB restriction? --djk
if (!gBrowser.currentMediaPage)
return void liberator.echoerr("Exxx: Can only set the media view from the media tab"); // XXX
let arg = args[0];
if (arg)
{
if (arg) {
let pages = player.getMediaPages();
for ([, page] in Iterator(pages))
{
if (util.compareIgnoreCase(arg, page.contentTitle) == 0)
{
for ([, page] in Iterator(pages)) {
if (util.compareIgnoreCase(arg, page.contentTitle) == 0) {
player.loadMediaPage(page, gBrowser.currentMediaListView.mediaList, gBrowser.currentMediaListView);
return;
}
@@ -353,8 +334,7 @@ function Player() //{{{
commands.add(["sort[view]"],
"Sort the current media view",
function (args)
{
function (args) {
player.sortBy(args, true);
});
@@ -362,8 +342,7 @@ function Player() //{{{
// FIXME: use :add -q like cmus? (not very vim-like are it's multi-option commands) --djk
commands.add(["qu[eue]"],
"Queue tracks by artist/album/track",
function (args)
{
function (args) {
// Store the old view
// let prev_view = gMM.status.view;
let library = LibraryUtils.mainLibrary;
@@ -372,8 +351,7 @@ function Player() //{{{
.createInstance(Ci.sbIMutablePropertyArray);
// args
switch (args.length)
{
switch (args.length) {
case 3:
customProps.appendProperty(SBProperties.trackName, args[2]);
case 2:
@@ -396,8 +374,7 @@ function Player() //{{{
// TODO: maybe :vol! could toggle mute on/off? --djk
commands.add(["vol[ume]"],
"Set the volume",
function (args)
{
function (args) {
let arg = args[0];
if (!/^[+-]?\d+$/.test(arg))
@@ -421,18 +398,15 @@ function Player() //{{{
function map(list) list.map(function (i) [i, ""]);
let [artist, album] = [args[0], args[1]];
if (args.completeArg == 0)
{
if (args.completeArg == 0) {
context.title = ["Artists"];
context.completions = map(library.getArtists());
}
else if (args.completeArg == 1)
{
else if (args.completeArg == 1) {
context.title = ["Albums by " + artist];
context.completions = map(library.getAlbums(artist));
}
else if (args.completeArg == 2)
{
else if (args.completeArg == 2) {
context.title = ["Tracks from " + album + " by " + artist];
context.completions = map(library.getTracks(artist, album));
}
@@ -462,53 +436,44 @@ function Player() //{{{
* @property {string} The player volume as a percentage.
*/
get volume() gMM.volumeControl.volume,
set volume(value)
{
set volume(value) {
gMM.volumeControl.volume = value;
},
// FIXME: can't be called from non-media tabs since 840e78
play: function play()
{
play: function play() {
// Check if there is any selection in place, else play first item of the visible view.
if (_SBGetCurrentView().selection.count != 0)
{
if (_SBGetCurrentView().selection.count != 0) {
// Play the selection.
gMM.sequencer.playView(_SBGetCurrentView(), _SBGetCurrentView().getIndexForItem(_SBGetCurrentView().selection.currentMediaItem));
focusTrack(gMM.sequencer.currentItem);
}
else
{
else {
gMM.sequencer.playView(SBGetBrowser().currentMediaListView, 0);
focusTrack(gMM.sequencer.currentItem);
}
},
stop: function stop()
{
stop: function stop() {
gMM.sequencer.stop();
},
next: function next()
{
next: function next() {
gSongbirdWindowController.doCommand("cmd_control_next");
gSongbirdWindowController.doCommand("cmd_find_current_track");
},
previous: function previous()
{
previous: function previous() {
gSongbirdWindowController.doCommand("cmd_control_previous");
gSongbirdWindowController.doCommand("cmd_find_current_track");
},
togglePlayPause: function togglePlayPause()
{
togglePlayPause: function togglePlayPause() {
gSongbirdWindowController.doCommand("cmd_control_playpause");
focusTrack(gMM.sequencer.currentItem);
},
toggleShuffle: function toggleShuffle()
{
toggleShuffle: function toggleShuffle() {
if (gMM.sequencer.mode != gMM.sequencer.MODE_SHUFFLE)
gMM.sequencer.mode = gMM.sequencer.MODE_SHUFFLE;
else
@@ -516,10 +481,8 @@ function Player() //{{{
},
// FIXME: not really toggling - good enough for now.
toggleRepeat: function toggleRepeat()
{
switch (gMM.sequencer.repeatMode)
{
toggleRepeat: function toggleRepeat() {
switch (gMM.sequencer.repeatMode) {
case gMM.sequencer.MODE_REPEAT_NONE:
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ONE;
break;
@@ -542,8 +505,7 @@ function Player() //{{{
* @param {number} interval The time interval (ms) to advance the
* current track.
*/
seekForward: function seekForward(interval)
{
seekForward: function seekForward(interval) {
seek(interval, true);
},
@@ -554,8 +516,7 @@ function Player() //{{{
* @param {number} interval The time interval (ms) to rewind the
* current track.
*/
seekBackward: function seekBackward(interval)
{
seekBackward: function seekBackward(interval) {
seek(interval, false);
},
@@ -564,8 +525,7 @@ function Player() //{{{
*
* @param {number} The new position (ms) in the track.
*/
seekTo: function seekTo(position)
{
seekTo: function seekTo(position) {
// FIXME: if not playing
if (!gMM.playbackControl)
this.play();
@@ -578,32 +538,27 @@ function Player() //{{{
// FIXME: 10% ?
// I think just general increments of say 0.05 might be better --djk
increaseVolume: function increaseVolume()
{
increaseVolume: function increaseVolume() {
gMM.volumeControl.volume = gMM.volumeControl.volume * 1.1;
},
decreaseVolume: function decreaseVolume()
{
decreaseVolume: function decreaseVolume() {
if (gMM.volumeControl.volume == 0)
gMM.volumeControl.volume = 0.1;
else
gMM.volumeControl.volume = gMM.volumeControl.volume * 0.9;
},
focusPlayingTrack :function focusPlayingTrack()
{
focusPlayingTrack :function focusPlayingTrack() {
focusTrack(gMM.sequencer.currentItem);
},
listTracks: function listTracks(view)
{
listTracks: function listTracks(view) {
//let myView = LibraryUtils.createStandardMediaListView(LibraryUtils.mainLibrary, args);
let length = view.length;
let tracksList = [];
for (let i = 0; i < length; i++)
{
for (let i = 0; i < length; i++) {
let mediaItem = view.getItemByIndex(i);
let trackName = mediaItem.getProperty(SBProperties.trackName);
let albumName = mediaItem.getProperty(SBProperties.albumName);
@@ -615,8 +570,7 @@ function Player() //{{{
return tracksList;
},
searchView: function searchView(args)
{
searchView: function searchView(args) {
let currentView = _SBGetCurrentView();
let mediaItemList = currentView.mediaList;
let search = _getSearchString(currentView);
@@ -631,8 +585,7 @@ function Player() //{{{
let mySearchView = LibraryUtils.createStandardMediaListView(mediaItemList, searchString);
if (mySearchView.length)
{
if (mySearchView.length) {
lastSearchView = mySearchView;
lastSearchIndex = 0;
focusTrack(mySearchView.getItemByIndex(lastSearchIndex));
@@ -641,29 +594,23 @@ function Player() //{{{
liberator.echoerr("E486 Pattern not found: " + searchString, commandline.FORCE_SINGLELINE);
},
searchViewAgain: function searchViewAgain(reverse)
{
function echo(str)
{
searchViewAgain: function searchViewAgain(reverse) {
function echo(str) {
setTimeout(function () {
commandline.echo(str, commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES | commandline.FORCE_SINGLELINE);
}, 0);
}
if (reverse)
{
if (lastSearchIndex == 0)
{
if (reverse) {
if (lastSearchIndex == 0) {
lastSearchIndex = lastSearchView.length - 1;
echo("Search hit TOP, continuing at BOTTOM");
}
else
lastSearchIndex = lastSearchIndex - 1;
}
else
{
if (lastSearchIndex == (lastSearchView.length - 1))
{
else {
if (lastSearchIndex == (lastSearchView.length - 1)) {
lastSearchIndex = 0;
echo("Search hit BOTTOM, continuing at TOP");
}
@@ -682,8 +629,7 @@ function Player() //{{{
*
* @param {string} str The contents of the search dialog.
*/
onSearchKeyPress: function (str)
{
onSearchKeyPress: function (str) {
if (options["incsearch"])
this.searchView(str);
},
@@ -693,28 +639,24 @@ function Player() //{{{
*
* @param {string} str The contents of the search dialog.
*/
onSearchSubmit: function (str)
{
onSearchSubmit: function (str) {
this.searchView(str);
},
/**
* The search dialog cancel callback.
*/
onSearchCancel: function ()
{
onSearchCancel: function () {
// TODO: restore the view state if altered by an 'incsearch' search
},
getPlaylists: function getPlaylists()
{
getPlaylists: function getPlaylists() {
let mainLibrary = LibraryUtils.mainLibrary;
let playlists = [mainLibrary];
let listener = {
onEnumerationBegin: function () { },
onEnumerationEnd: function () { },
onEnumeratedItem: function (list, item)
{
onEnumeratedItem: function (list, item) {
// FIXME: why are there null items and duplicates?
if (!playlists.some(function (list) list.name == item.name) && item.name != null)
playlists.push(item);
@@ -728,42 +670,35 @@ function Player() //{{{
},
// Play track at 'row' in 'playlist'
playPlaylist: function playPlaylist(playlist, row)
{
playPlaylist: function playPlaylist(playlist, row) {
gMM.sequencer.playView(playlist.createView(), row);
},
getMediaPages: function getMediaPages()
{
getMediaPages: function getMediaPages() {
let list = gBrowser.currentMediaPage.mediaListView.mediaList;
let pages = services.get("mediaPageManager").getAvailablePages(list);
return ArrayConverter.JSArray(pages).map(function (page) page.QueryInterface(Ci.sbIMediaPageInfo));
},
loadMediaPage: function loadMediaList(page, list, view)
{
loadMediaPage: function loadMediaList(page, list, view) {
services.get("mediaPageManager").setPage(list, page);
gBrowser.loadMediaList(list, null, null, view, null);
},
rateMediaItem: function rateMediaItem(rating)
{
rateMediaItem: function rateMediaItem(rating) {
if (gMM.sequencer.currentItem)
gMM.sequencer.currentItem.setProperty(SBProperties.rating, rating);
},
getUserViewable: function getUserViewable()
{
getUserViewable: function getUserViewable() {
let propManager = services.get("propertyManager");
let propEnumerator = propManager.propertyIDs;
let properties = [];
while (propEnumerator.hasMore())
{
while (propEnumerator.hasMore()) {
let propertyId = propEnumerator.getNext();
if (propManager.getPropertyInfo(propertyId).userViewable)
{
if (propManager.getPropertyInfo(propertyId).userViewable) {
//liberator.dump("propertyId - " + propManager.getPropertyInfo(propertyId).id);
properties.push(propManager.getPropertyInfo(propertyId).displayName);
}
@@ -772,13 +707,11 @@ function Player() //{{{
return properties;
},
sortBy: function sortBy(property, order)
{
sortBy: function sortBy(property, order) {
let pa = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"].createInstance(Ci.sbIMutablePropertyArray);
liberator.dump("Property: " + property);
switch (property.string)
{
switch (property.string) {
case "#":
case "Title":
pa.appendProperty(SBProperties.trackName, "a");