mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-06 16:04:12 +01:00
And xulmus was born.
This commit is contained in:
1146
xulmus/content/bookmarks.js
Executable file
1146
xulmus/content/bookmarks.js
Executable file
File diff suppressed because it is too large
Load Diff
496
xulmus/content/config.js
Executable file
496
xulmus/content/config.js
Executable file
@@ -0,0 +1,496 @@
|
||||
/***** BEGIN LICENSE BLOCK ***** {{{
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@gmx.net>
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
}}} ***** END LICENSE BLOCK *****/
|
||||
|
||||
const config = { //{{{
|
||||
/*** required options, no checks done if they really exist, so be careful ***/
|
||||
name: "Xulmus",
|
||||
hostApplication: "Songbird",
|
||||
//mainWindowID: "mainplayer",
|
||||
/*** optional options, there are checked for existence and a fallback provided ***/
|
||||
features: ["bookmarks", "hints", "marks","history", "quickmarks", "session", "tabs", "windows", "player"],
|
||||
defaults: { guioptions: "rb" },
|
||||
|
||||
guioptions: {
|
||||
m: ["Menubar", ["toolbar-menubar"]],
|
||||
T: ["Toolbar", ["nav-bar"]],
|
||||
B: ["Bookmark bar", ["PersonalToolbar"]]
|
||||
},
|
||||
|
||||
//get visualbellWindow() getBrowser().mPanelContainer,
|
||||
get isPlayerWindow() gBrowser.mCurrentTab._tPos == 0,
|
||||
// focusContent() focuses this widget gSongbirdWindowController takes care of the focus.
|
||||
get mainWindowID() "mainplayer",
|
||||
get visualbellWindow() document.getElementById(this.mainWindowID),
|
||||
|
||||
styleableChrome: "chrome://songbird/content/xul/layoutBaseOverlay.xul",
|
||||
|
||||
autocommands: [["BookmarkAdd", "Triggered after a page is bookmarked"],
|
||||
["ColorScheme", "Triggered after a color scheme has been loaded"],
|
||||
["DOMLoad", "Triggered when a page's DOM content has fully loaded"],
|
||||
["DownloadPost", "Triggered when a download has completed"],
|
||||
["Fullscreen", "Triggered when the browser's fullscreen state changes"],
|
||||
["LocationChange", "Triggered when changing tabs or when naviagtion to a new location"],
|
||||
["PageLoadPre", "Triggered after a page load is initiated"],
|
||||
["PageLoad", "Triggered when a page gets (re)loaded/opened"],
|
||||
["ShellCmdPost", "Triggered after executing a shell command with :!cmd"],
|
||||
["XulmusEnter", "Triggered after Xulmus starts"],
|
||||
["XulmusLeavePre", "Triggered before exiting Xulmus, just before destroying each module"],
|
||||
["XulmusLeave", "Triggered before exiting Xulmus"]],
|
||||
|
||||
dialogs: [
|
||||
["about", "About Songbird",
|
||||
function () { window.openDialog("chrome://browser/content/aboutDialog.xul", "_blank", "chrome,dialog,modal,centerscreen"); }],
|
||||
["addbookmark", "Add bookmark for the current page",
|
||||
function () { PlacesCommandHook.bookmarkCurrentPage(true, PlacesUtils.bookmarksRootId); }],
|
||||
["addons", "Manage Add-ons",
|
||||
function () { window.BrowserOpenAddonsMgr(); }],
|
||||
["bookmarks", "List your bookmarks",
|
||||
function () { window.openDialog("chrome://browser/content/bookmarks/bookmarksPanel.xul", "Bookmarks", "dialog,centerscreen,width=600,height=600"); }],
|
||||
["checkupdates", "Check for updates",
|
||||
function () { window.checkForUpdates(); }],
|
||||
["cleardata", "Clear private data",
|
||||
function () { Cc[GLUE_CID].getService(Ci.nsIBrowserGlue).sanitize(window || null); }],
|
||||
["cookies", "List your cookies",
|
||||
function () { window.toOpenWindowByType("Browser:Cookies", "chrome://browser/content/preferences/cookies.xul", "chrome,dialog=no,resizable"); }],
|
||||
["console", "JavaScript console",
|
||||
function () { window.toJavaScriptConsole(); }],
|
||||
["customizetoolbar", "Customize the Toolbar",
|
||||
function () { window.BrowserCustomizeToolbar(); }],
|
||||
["dominspector", "DOM Inspector",
|
||||
function () { try { window.inspectDOMDocument(content.document); } catch (e) { liberator.echoerr("DOM Inspector extension not installed"); } }],
|
||||
["downloads", "Manage Downloads",
|
||||
function () { window.toOpenWindowByType("Download:Manager", "chrome://mozapps/content/downloads/downloads.xul", "chrome,dialog=no,resizable"); }],
|
||||
["history", "List your history",
|
||||
function () { window.openDialog("chrome://browser/content/history/history-panel.xul", "History", "dialog,centerscreen,width=600,height=600"); }],
|
||||
["import", "Import Preferences, Bookmarks, History, etc. from other browsers",
|
||||
function () { window.BrowserImport(); }],
|
||||
["openfile", "Open the file selector dialog",
|
||||
function () { window.BrowserOpenFileWindow(); }],
|
||||
["pageinfo", "Show information about the current page",
|
||||
function () { window.BrowserPageInfo(); }],
|
||||
["pagesource", "View page source",
|
||||
function () { window.BrowserViewSourceOfDocument(content.document); }],
|
||||
["places", "Places Organizer: Manage your bookmarks and history",
|
||||
function () { PlacesCommandHook.showPlacesOrganizer(ORGANIZER_ROOT_BOOKMARKS); }],
|
||||
["preferences", "Show Firefox preferences dialog",
|
||||
function () { window.openPreferences(); }],
|
||||
["printpreview", "Preview the page before printing",
|
||||
function () { PrintUtils.printPreview(onEnterPrintPreview, onExitPrintPreview); }],
|
||||
["printsetup", "Setup the page size and orientation before printing",
|
||||
function () { PrintUtils.showPageSetup(); }],
|
||||
["print", "Show print dialog",
|
||||
function () { PrintUtils.print(); }],
|
||||
["saveframe", "Save frame to disk",
|
||||
function () { window.saveFrameDocument(); }],
|
||||
["savepage", "Save page to disk",
|
||||
function () { window.saveDocument(window.content.document); }],
|
||||
["searchengines", "Manage installed search engines",
|
||||
function () { window.openDialog("chrome://browser/content/search/engineManager.xul", "_blank", "chrome,dialog,modal,centerscreen"); }],
|
||||
["selectionsource", "View selection source",
|
||||
function () { buffer.viewSelectionSource(); }]
|
||||
],
|
||||
|
||||
//TODO : Write intro.html and tutorial.html
|
||||
// they are sorted by relevance, not alphabetically
|
||||
//helpFiles: [ "intro.html" ],
|
||||
/* "intro.html", "tutorial.html", "starting.html", "browsing.html",
|
||||
"buffer.html", "cmdline.html", "insert.html", "options.html",
|
||||
"pattern.html", "tabs.html", "hints.html", "map.html", "eval.html",
|
||||
"marks.html", "repeat.html", "autocommands.html", "print.html",
|
||||
"gui.html", "styling.html", "message.html", "developer.html",
|
||||
"various.html", "index.html", "version.html"
|
||||
], */
|
||||
|
||||
scripts: [
|
||||
"bookmarks.js",
|
||||
"tabs.js",
|
||||
"player.js",
|
||||
],
|
||||
|
||||
init: function ()
|
||||
{
|
||||
//Adding a mode for Player
|
||||
//modes.addMode("PLAYER"); // Player mode for songbird
|
||||
|
||||
// var artistArray = getArtists();
|
||||
|
||||
// TODO: support 'nrformats'? -> probably not worth it --mst
|
||||
function incrementURL(count)
|
||||
{
|
||||
let matches = buffer.URL.match(/(.*?)(\d+)(\D*)$/);
|
||||
if (!matches)
|
||||
{
|
||||
liberator.beep();
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
while (newNumberStr.length < number.length)
|
||||
newNumberStr = "0" + newNumberStr;
|
||||
}
|
||||
|
||||
liberator.open(pre + newNumberStr + post);
|
||||
}
|
||||
|
||||
// load Xulmus specific modules
|
||||
// FIXME: Why aren't these listed in config.scripts?
|
||||
// FIXME: Why isn't this automatic? -> how would one know which classes to load where? --mst
|
||||
// Something like:
|
||||
// liberator.addModule("search", function Search() { ...
|
||||
// for all modules, or something similar. For modules which
|
||||
// require other modules, well, there's addObserver("load_foo",
|
||||
// or we could just make sure that they're all sourced in order.
|
||||
// The scripts could even just instantiate them themselves.
|
||||
// --Kris
|
||||
liberator.loadModule("search", Search);
|
||||
liberator.loadModule("bookmarks", Bookmarks);
|
||||
liberator.loadModule("history", History);
|
||||
liberator.loadModule("tabs", Tabs);
|
||||
liberator.loadModule("marks", Marks);
|
||||
liberator.loadModule("quickmarks", QuickMarks);
|
||||
liberator.loadModule("hints", Hints);
|
||||
// Load the Player module
|
||||
liberator.loadModule("player", Player);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// STYLES //////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
let img = Image();
|
||||
img.src = "chrome://xulmus/content/xulmus.png";
|
||||
img.onload = function () {
|
||||
styles.addSheet(true, "logo", "chrome://liberator/locale/*",
|
||||
".xulmus-logo {" + <>
|
||||
display: inline-block;
|
||||
background: url({img.src});
|
||||
width: {img.width}px;
|
||||
height: {img.height}px;
|
||||
</> + "}",
|
||||
true);
|
||||
delete img;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
mappings.add([modes.NORMAL],
|
||||
["y"], "Yank current location to the clipboard",
|
||||
function () { util.copyToClipboard(buffer.URL, true); });
|
||||
|
||||
// opening websites
|
||||
mappings.add([modes.NORMAL],
|
||||
["o"], "Open one or more URLs",
|
||||
function () { commandline.open(":", "open ", modes.EX); });
|
||||
|
||||
mappings.add([modes.NORMAL], ["O"],
|
||||
"Open one or more URLs, based on current location",
|
||||
function () { commandline.open(":", "open " + buffer.URL, modes.EX); });
|
||||
|
||||
mappings.add([modes.NORMAL], ["t"],
|
||||
"Open one or more URLs in a new tab",
|
||||
function () { commandline.open(":", "tabopen ", modes.EX); });
|
||||
|
||||
mappings.add([modes.NORMAL], ["t"],
|
||||
"Open one or more URLs in a new tab",
|
||||
function () { commandline.open(":", "tabopen ", modes.EX); });
|
||||
|
||||
mappings.add([modes.NORMAL], ["T"],
|
||||
"Open one or more URLs in a new tab, based on current location",
|
||||
function () { commandline.open(":", "tabopen " + buffer.URL, modes.EX); });
|
||||
|
||||
mappings.add([modes.NORMAL], ["T"],
|
||||
"Open one or more URLs in a new tab, based on current location",
|
||||
function () { commandline.open(":", "tabopen " + buffer.URL, modes.EX); });
|
||||
|
||||
mappings.add([modes.NORMAL],
|
||||
["<C-a>"], "Increment last number in URL",
|
||||
function (count) { incrementURL(count > 1 ? count : 1); },
|
||||
{ flags: Mappings.flags.COUNT });
|
||||
|
||||
mappings.add([modes.NORMAL],
|
||||
["<C-x>"], "Decrement last number in URL",
|
||||
function (count) { incrementURL(-(count > 1 ? count : 1)); },
|
||||
{ flags: Mappings.flags.COUNT });
|
||||
|
||||
|
||||
mappings.add([modes.NORMAL], ["~"],
|
||||
"Open home directory",
|
||||
function () { liberator.open("~"); });
|
||||
|
||||
mappings.add([modes.NORMAL], ["gh"],
|
||||
"Open homepage",
|
||||
function () { BrowserHome(); });
|
||||
|
||||
mappings.add([modes.NORMAL], ["gH"],
|
||||
"Open homepage in a new tab",
|
||||
function ()
|
||||
{
|
||||
let homepages = gHomeButton.getHomePage();
|
||||
liberator.open(homepages, /\bhomepage\b/.test(options["activate"]) ?
|
||||
liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB);
|
||||
});
|
||||
|
||||
|
||||
mappings.add([modes.NORMAL], ["gu"],
|
||||
"Go to parent directory",
|
||||
function (count)
|
||||
{
|
||||
function isDirectory(url)
|
||||
{
|
||||
if (/^file:\/|^\//.test(url))
|
||||
{
|
||||
let file = io.getFile(url);
|
||||
return file.exists() && file.isDirectory();
|
||||
}
|
||||
else
|
||||
{
|
||||
// for all other locations just check if the URL ends with /
|
||||
return /\/$/.test(url);
|
||||
}
|
||||
}
|
||||
|
||||
if (count < 1)
|
||||
count = 1;
|
||||
|
||||
// XXX
|
||||
let url = buffer.URL;
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
if (isDirectory(url))
|
||||
url = url.replace(/^(.*?:)(.*?)([^\/]+\/*)$/, "$1$2/");
|
||||
else
|
||||
url = url.replace(/^(.*?:)(.*?)(\/+[^\/]+)$/, "$1$2/");
|
||||
}
|
||||
url = url.replace(/^(.*:\/+.*?)\/+$/, "$1/"); // get rid of more than 1 / at the end
|
||||
|
||||
if (url == buffer.URL)
|
||||
liberator.beep();
|
||||
else
|
||||
liberator.open(url);
|
||||
},
|
||||
{ flags: Mappings.flags.COUNT });
|
||||
|
||||
mappings.add([modes.NORMAL], ["gU"],
|
||||
"Go to the root of the website",
|
||||
function ()
|
||||
{
|
||||
let uri = content.document.location;
|
||||
if (/(about|mailto):/.test(uri.protocol)) // exclude these special protocols for now
|
||||
{
|
||||
liberator.beep();
|
||||
return;
|
||||
}
|
||||
liberator.open(uri.protocol + "//" + (uri.host || "") + "/");
|
||||
});
|
||||
|
||||
mappings.add([modes.NORMAL], ["<C-l>"],
|
||||
"Redraw the screen",
|
||||
function () { commands.get("redraw").execute("", false); });
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
commands.add(["downl[oads]", "dl"],
|
||||
"Show progress of current downloads",
|
||||
function ()
|
||||
{
|
||||
liberator.open("chrome://mozapps/content/downloads/downloads.xul",
|
||||
options.get("newtab").has("all", "downloads")
|
||||
? liberator.NEW_TAB : liberator.CURRENT_TAB);
|
||||
},
|
||||
{ argCount: "0" });
|
||||
|
||||
commands.add(["o[pen]", "e[dit]"],
|
||||
"Open one or more URLs in the current tab",
|
||||
function (args)
|
||||
{
|
||||
if (args.string)
|
||||
{
|
||||
liberator.open(args.string);
|
||||
}
|
||||
else if (args.bang)
|
||||
BrowserReloadSkipCache();
|
||||
else
|
||||
BrowserReload();
|
||||
},
|
||||
{
|
||||
bang: true,
|
||||
completer: function (context) completion.url(context),
|
||||
literal: 0
|
||||
});
|
||||
|
||||
commands.add(["pref[erences]", "prefs"],
|
||||
"Show " + config.hostApplication + " preferences",
|
||||
function (args)
|
||||
{
|
||||
if (args.bang) // open Firefox settings GUI dialog
|
||||
{
|
||||
liberator.open("about:config",
|
||||
(options["newtab"] && options.get("newtab").has("all", "prefs"))
|
||||
? liberator.NEW_TAB : liberator.CURRENT_TAB);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.openPreferences();
|
||||
}
|
||||
},
|
||||
{
|
||||
argCount: "0",
|
||||
bang: true
|
||||
});
|
||||
|
||||
commands.add(["redr[aw]"],
|
||||
"Redraw the screen",
|
||||
function ()
|
||||
{
|
||||
let wu = window.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIDOMWindowUtils);
|
||||
wu.redraw();
|
||||
modes.show();
|
||||
},
|
||||
{ argCount: "0" });
|
||||
|
||||
// TODO: move sidebar commands to ui.js?
|
||||
commands.add(["sbcl[ose]"],
|
||||
"Close the sidebar window",
|
||||
function ()
|
||||
{
|
||||
if (!document.getElementById("sidebar-box").hidden)
|
||||
toggleSidebar();
|
||||
},
|
||||
{ argCount: "0" });
|
||||
|
||||
commands.add(["sideb[ar]", "sb[ar]", "sbope[n]"],
|
||||
"Open the sidebar window",
|
||||
function (args)
|
||||
{
|
||||
let arg = args.literalArg;
|
||||
|
||||
// focus if the requested sidebar is already open
|
||||
if (document.getElementById("sidebar-title").value == arg)
|
||||
{
|
||||
document.getElementById("sidebar-box").focus();
|
||||
return;
|
||||
}
|
||||
|
||||
let menu = document.getElementById("viewSidebarMenu");
|
||||
|
||||
for (let [,panel] in Iterator(menu.childNodes))
|
||||
{
|
||||
if (panel.label == arg)
|
||||
{
|
||||
panel.doCommand();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
liberator.echoerr("No sidebar " + arg + " found");
|
||||
},
|
||||
{
|
||||
argCount: "1",
|
||||
completer: function (context) completion.sidebar(context),
|
||||
literal: 0
|
||||
});
|
||||
|
||||
commands.add(["winc[lose]", "wc[lose]"],
|
||||
"Close window",
|
||||
function () { window.close(); },
|
||||
{ argCount: "0" });
|
||||
|
||||
commands.add(["wino[pen]", "wo[pen]", "wine[dit]"],
|
||||
"Open one or more URLs in a new window",
|
||||
function (args)
|
||||
{
|
||||
args = args.string;
|
||||
|
||||
if (args)
|
||||
liberator.open(args, liberator.NEW_WINDOW);
|
||||
else
|
||||
liberator.open("about:blank", liberator.NEW_WINDOW);
|
||||
},
|
||||
{
|
||||
completer: function (context) completion.url(context),
|
||||
literal: 0
|
||||
});
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
options.add(["online"],
|
||||
"Set the 'work offline' option",
|
||||
"boolean", true,
|
||||
{
|
||||
setter: function (value)
|
||||
{
|
||||
const ioService = services.get("io");
|
||||
ioService.offline = !value;
|
||||
//gPrefService.setBoolPref("browser.offline", ioService.offline);
|
||||
gPrefs.setBoolPref("browser.offline", ioService.offline);
|
||||
return value;
|
||||
},
|
||||
getter: function () !services.get("io").offline
|
||||
});
|
||||
|
||||
options.add(["titlestring"],
|
||||
"Change the title of the window",
|
||||
"string", "Xulmus",
|
||||
{
|
||||
setter: function (value)
|
||||
{
|
||||
try
|
||||
{
|
||||
let id = this.mainWindowID || "mainplayer";
|
||||
document.getElementById(id).setAttribute("titlemodifier", value);
|
||||
if (window.content.document.title.length > 0)
|
||||
document.title = window.content.document.title + " - " + value;
|
||||
else
|
||||
document.title = value;
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
liberator.log("Couldn't set titlestring", 3);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
});
|
||||
|
||||
options.add(["urlseparator"],
|
||||
"Set the separator regexp used to separate multiple URL args",
|
||||
"string", ",\\s");
|
||||
}
|
||||
//}}}
|
||||
}; //}}}
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
6
xulmus/content/liberator.dtd
Executable file
6
xulmus/content/liberator.dtd
Executable file
@@ -0,0 +1,6 @@
|
||||
|
||||
<!ENTITY liberator.mainWindow "mainplayer">
|
||||
<!ENTITY liberator.name "xulmus">
|
||||
<!ENTITY liberator.statusBefore "statusbar-display">
|
||||
<!ENTITY liberator.statusAfter "">
|
||||
|
||||
219
xulmus/content/player.js
Executable file
219
xulmus/content/player.js
Executable file
@@ -0,0 +1,219 @@
|
||||
//Import Artist List as this can be huge
|
||||
|
||||
var artists = getArtistsArray();
|
||||
|
||||
function Player()
|
||||
{
|
||||
|
||||
// Get the focus to the visible playlist first
|
||||
//window._SBShowMainLibrary();
|
||||
|
||||
mappings.add([modes.PLAYER],
|
||||
["x"], "Play Track",
|
||||
function ()
|
||||
{
|
||||
gMM.sequencer.play();
|
||||
});
|
||||
|
||||
mappings.add([modes.PLAYER],
|
||||
["z"], "Previous Track",
|
||||
function ()
|
||||
{
|
||||
gSongbirdWindowController.doCommand("cmd_control_previous");
|
||||
});
|
||||
|
||||
mappings.add([modes.PLAYER],
|
||||
["c"], "Pause/Unpause Track",
|
||||
function ()
|
||||
{
|
||||
gSongbirdWindowController.doCommand("cmd_control_playpause");
|
||||
});
|
||||
|
||||
mappings.add([modes.PLAYER],
|
||||
["b"], "Next Track",
|
||||
function ()
|
||||
{
|
||||
gSongbirdWindowController.doCommand("cmd_control_next");
|
||||
});
|
||||
|
||||
mappings.add([modes.PLAYER],
|
||||
["v"], "Stop Track",
|
||||
function ()
|
||||
{
|
||||
gMM.sequencer.stop();
|
||||
});
|
||||
|
||||
|
||||
mappings.add([modes.PLAYER],
|
||||
["l"], "Play Media",
|
||||
function ()
|
||||
{
|
||||
commandline.open(":","playmedia ", modes.EX);
|
||||
});
|
||||
|
||||
mappings.add([modes.PLAYER],
|
||||
["s"], "Toggle Shuffle",
|
||||
function ()
|
||||
{
|
||||
if (gMM.sequencer.mode != gMM.sequencer.MODE_SHUFFLE)
|
||||
gMM.sequencer.mode = gMM.sequencer.MODE_SHUFFLE;
|
||||
else
|
||||
gMM.sequencer.mode = gMM.sequencer.MODE_FORWARD;
|
||||
});
|
||||
|
||||
mappings.add([modes.PLAYER],
|
||||
["r"], "Toggle Repeat",
|
||||
function ()
|
||||
{
|
||||
switch(gMM.sequencer.repeatMode)
|
||||
{
|
||||
case gMM.sequencer.MODE_REPEAT_NONE:
|
||||
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ONE;
|
||||
break;
|
||||
case gMM.sequencer.MODE_REPEAT_ONE:
|
||||
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ALL;
|
||||
break;
|
||||
case gMM.sequencer.MODE_REPEAT_ALL:
|
||||
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
|
||||
break;
|
||||
default:
|
||||
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
commands.add(["playmedia"],
|
||||
"PLay Media",
|
||||
function(args)
|
||||
{
|
||||
//Store the old view
|
||||
//var prev_view = gMM.status.view;
|
||||
var library = LibraryUtils.mainLibrary;
|
||||
var mainView = library.createView();
|
||||
var sqncr = gMM.sequencer;
|
||||
var customProps = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
||||
.createInstance(Ci.sbIMutablePropertyArray);
|
||||
|
||||
//args
|
||||
|
||||
if (args.length == 1){
|
||||
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
||||
}
|
||||
else if (args.length == 2){
|
||||
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
||||
customProps.appendProperty(SBProperties.albumName,args[1].toString());
|
||||
}
|
||||
else if (args.length == 3){
|
||||
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
||||
customProps.appendProperty(SBProperties.albumName,args[1].toString());
|
||||
customProps.appendProperty(SBProperties.trackName,args[2].toString());
|
||||
}
|
||||
|
||||
|
||||
sqncr.playView(mainView, mainView.getIndexForItem(library.getItemsByProperties(customProps).queryElementAt(0,Ci.sbIMediaItem)));
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
completer: function(context, args) completion.songCompletion(context, args)
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getArtists()
|
||||
{
|
||||
return this.artists;
|
||||
}
|
||||
|
||||
function getArtistsArray()
|
||||
{
|
||||
|
||||
var list = LibraryUtils.mainLibrary;
|
||||
|
||||
// Create an enumeration listener to count each item
|
||||
var listener = {
|
||||
count: 0,
|
||||
onEnumerationBegin: function(aMediaList) {
|
||||
this.count = 0;
|
||||
},
|
||||
onEnumeratedItem: function(aMediaList, aMediaItem) {
|
||||
this.count++;
|
||||
},
|
||||
onEnumerationEnd: function(aMediaList, aStatusCode) {}
|
||||
};
|
||||
|
||||
var artistCounts = {};
|
||||
var artists = list.getDistinctValuesForProperty(SBProperties.artistName);
|
||||
var artist;
|
||||
var artistArray = [];
|
||||
var i=0;
|
||||
// Count the number of media items for each distinct artist
|
||||
while (artists.hasMore()) {
|
||||
artist = artists.getNext();
|
||||
artistArray[i] = [artist,artist];
|
||||
list.enumerateItemsByProperty(SBProperties.artistName,
|
||||
artist,
|
||||
listener,
|
||||
Ci.sbIMediaList.ENUMERATIONTYPE_LOCKING);
|
||||
artistCounts[artist] = listener.count;
|
||||
i++;
|
||||
}
|
||||
|
||||
//liberator.dump("Count : "+artistCounts.toSource());
|
||||
return artistArray;
|
||||
}
|
||||
|
||||
function getAlbums(artist)
|
||||
{
|
||||
var list = LibraryUtils.mainLibrary;
|
||||
var albumArray = [];
|
||||
var items = list.getItemsByProperty(SBProperties.artistName, artist).enumerate();
|
||||
var i = 0;
|
||||
|
||||
while(items.hasMoreElements()) {
|
||||
album = items.getNext().getProperty(SBProperties.albumName);
|
||||
albumArray[i] = [album, album];
|
||||
i++;
|
||||
}
|
||||
|
||||
return removeDuplicateElement(albumArray);
|
||||
}
|
||||
|
||||
function getTracks(artist,album)
|
||||
{
|
||||
var list = LibraryUtils.mainLibrary;
|
||||
var tracksArray = [];
|
||||
var pa = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
||||
.createInstance(Ci.sbIMutablePropertyArray);
|
||||
var i = 0;
|
||||
|
||||
pa.appendProperty(SBProperties.artistName,artist.toString());
|
||||
pa.appendProperty(SBProperties.albumName,album.toString());
|
||||
var items = list.getItemsByProperties(pa).enumerate();
|
||||
|
||||
while(items.hasMoreElements()) {
|
||||
track = items.getNext().getProperty(SBProperties.trackName);
|
||||
tracksArray[i] = [track, track];
|
||||
i++;
|
||||
}
|
||||
|
||||
return tracksArray;
|
||||
}
|
||||
|
||||
|
||||
function removeDuplicateElement(arrayName)
|
||||
{
|
||||
var newArray=new Array();
|
||||
label:for(var i=0; i<arrayName.length;i++ )
|
||||
{
|
||||
for(var j=0; j<newArray.length;j++ )
|
||||
{
|
||||
if(newArray[j].toString()==arrayName[i].toString())
|
||||
continue label;
|
||||
}
|
||||
newArray[newArray.length] = arrayName[i];
|
||||
}
|
||||
return newArray;
|
||||
}
|
||||
BIN
xulmus/content/xulmus.png
Executable file
BIN
xulmus/content/xulmus.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
88
xulmus/content/xulmus.svg
Executable file
88
xulmus/content/xulmus.svg
Executable file
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="162"
|
||||
height="40"
|
||||
id="svg2"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.46"
|
||||
version="1.0"
|
||||
sodipodi:docbase="/home/maxauthority/code/vimperator"
|
||||
sodipodi:docname="vimperator.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||
inkscape:export-filename="/home/maxauthority/code/vimperator/vimperator.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90">
|
||||
<defs
|
||||
id="defs4">
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="0 : 29 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_z="185 : 29 : 1"
|
||||
inkscape:persp3d-origin="92.5 : 19.333333 : 1"
|
||||
id="perspective2392" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
gridtolerance="10000"
|
||||
guidetolerance="10"
|
||||
objecttolerance="10"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="4.04"
|
||||
inkscape:cx="84.114858"
|
||||
inkscape:cy="55.052209"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
width="185px"
|
||||
height="58px"
|
||||
showgrid="false" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-5.4392018,-9.6624603)">
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:24px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:DejaVu Sans Mono"
|
||||
x="6.2673268"
|
||||
y="29.896835"
|
||||
id="text2229"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan2231"
|
||||
x="6.2673268"
|
||||
y="29.896835">vimperator_</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:24px;font-style:normal;font-weight:normal;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:DejaVu Sans Mono"
|
||||
x="6.4079518"
|
||||
y="53.183945"
|
||||
id="text2233"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan2235"
|
||||
x="6.4079518"
|
||||
y="53.183945">~</tspan></text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
52
xulmus/content/xulmus.xul
Executable file
52
xulmus/content/xulmus.xul
Executable file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://xulmus/skin/xulmus.css" type="text/css"?>
|
||||
|
||||
<overlay id="xulmus"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<menupopup id="viewSidebarMenu">
|
||||
<menuitem observes="xulmus-viewAddonsSidebar" label="Add-ons" accesskey="A"/>
|
||||
<menuitem observes="xulmus-viewConsoleSidebar" label="Console" accesskey="C"/>
|
||||
<menuitem observes="xulmus-viewDownloadsSidebar" label="Downloads" accesskey="D"/>
|
||||
<menuitem observes="xulmus-viewPreferencesSidebar" label="Preferences" accesskey="P"/>
|
||||
</menupopup>
|
||||
|
||||
<broadcasterset id="mainBroadcasterSet">
|
||||
<broadcaster id="xulmus-viewAddonsSidebar"
|
||||
autoCheck="false"
|
||||
type="checkbox"
|
||||
group="sidebar"
|
||||
sidebarurl="chrome://mozapps/content/extensions/extensions.xul"
|
||||
sidebartitle="Add-ons"
|
||||
oncommand="toggleSidebar('xulmus-viewAddonsSidebar');"/>
|
||||
<broadcaster id="xulmus-viewConsoleSidebar"
|
||||
autoCheck="false"
|
||||
type="checkbox"
|
||||
group="sidebar"
|
||||
sidebarurl="chrome://global/content/console.xul"
|
||||
sidebartitle="Console"
|
||||
oncommand="toggleSidebar('xulmus-viewConsoleSidebar');"/>
|
||||
<broadcaster id="xulmus-viewDownloadsSidebar"
|
||||
autoCheck="false"
|
||||
type="checkbox"
|
||||
group="sidebar"
|
||||
sidebarurl="chrome://mozapps/content/downloads/downloads.xul"
|
||||
sidebartitle="Downloads"
|
||||
oncommand="toggleSidebar('xulmus-viewDownloadsSidebar');"/>
|
||||
<broadcaster id="xulmus-viewPreferencesSidebar"
|
||||
autoCheck="false"
|
||||
type="checkbox"
|
||||
group="sidebar"
|
||||
sidebarurl="about:config"
|
||||
sidebartitle="Preferences"
|
||||
oncommand="toggleSidebar('xulmus-viewPreferencesSidebar');"/>
|
||||
</broadcasterset>
|
||||
|
||||
</overlay>
|
||||
|
||||
<!-- vim: set fdm=marker sw=4 ts=4 et: -->
|
||||
Reference in New Issue
Block a user