mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-04-14 10:23:32 +02:00
Added SortView Command
This commit is contained in:
@@ -12,7 +12,8 @@ function Player() // {{{
|
|||||||
//window._SBShowMainLibrary();
|
//window._SBShowMainLibrary();
|
||||||
|
|
||||||
services.add("mediaPageManager", "@songbirdnest.com/Songbird/MediaPageManager;1", Ci.sbIMediaPageManager);
|
services.add("mediaPageManager", "@songbirdnest.com/Songbird/MediaPageManager;1", Ci.sbIMediaPageManager);
|
||||||
|
services.add("propertyManager","@songbirdnest.com/Songbird/Properties/PropertyManager;1", Ci.sbIPropertyManager);
|
||||||
|
|
||||||
// Register Callbacks for searching.
|
// Register Callbacks for searching.
|
||||||
liberator.registerCallback("change", modes.SEARCH_VIEW_FORWARD, function (str) { player.onSearchKeyPress(str); });
|
liberator.registerCallback("change", modes.SEARCH_VIEW_FORWARD, function (str) { player.onSearchKeyPress(str); });
|
||||||
liberator.registerCallback("submit", modes.SEARCH_VIEW_FORWARD, function (str) { player.onSearchSubmit(str); });
|
liberator.registerCallback("submit", modes.SEARCH_VIEW_FORWARD, function (str) { player.onSearchSubmit(str); });
|
||||||
@@ -350,6 +351,14 @@ function Player() // {{{
|
|||||||
literal: 0
|
literal: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
commands.add(["sort[view]"],
|
||||||
|
"Sort the current media view",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
player.sortBy(args, true);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
// FIXME: use :add -q like cmus? (not very vim-like are it's multi-option commands) --djk
|
// FIXME: use :add -q like cmus? (not very vim-like are it's multi-option commands) --djk
|
||||||
commands.add(["qu[eue]"],
|
commands.add(["qu[eue]"],
|
||||||
"Queue tracks by artist/album/track",
|
"Queue tracks by artist/album/track",
|
||||||
@@ -709,6 +718,51 @@ function Player() // {{{
|
|||||||
{
|
{
|
||||||
if (gMM.sequencer.currentItem)
|
if (gMM.sequencer.currentItem)
|
||||||
gMM.sequencer.currentItem.setProperty(SBProperties.rating, rating);
|
gMM.sequencer.currentItem.setProperty(SBProperties.rating, rating);
|
||||||
|
},
|
||||||
|
|
||||||
|
getUserViewable: function getUserViewable()
|
||||||
|
{
|
||||||
|
let propManager = services.get("propertyManager");
|
||||||
|
let propEnumerator = propManager.propertyIDs;
|
||||||
|
let properties = [];
|
||||||
|
|
||||||
|
while (propEnumerator.hasMore())
|
||||||
|
{
|
||||||
|
let propertyID = propEnumerator.getNext();
|
||||||
|
|
||||||
|
if (propManager.getPropertyInfo(propertyID).userViewable)
|
||||||
|
{
|
||||||
|
liberator.dump("PropertyID - "+propManager.getPropertyInfo(propertyID).id);
|
||||||
|
properties.push(propManager.getPropertyInfo(propertyID).displayName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return properties;
|
||||||
|
},
|
||||||
|
|
||||||
|
sortBy: function sortBy(property, order)
|
||||||
|
{
|
||||||
|
let pa = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"].createInstance(Ci.sbIMutablePropertyArray);
|
||||||
|
liberator.dump("Property: "+property);
|
||||||
|
|
||||||
|
switch (property.string)
|
||||||
|
{
|
||||||
|
case "#":
|
||||||
|
case "Title":
|
||||||
|
pa.appendProperty(SBProperties.trackName, 'a');
|
||||||
|
break;
|
||||||
|
case "Rating":
|
||||||
|
pa.appendProperty(SBProperties.rating, 1);
|
||||||
|
break;
|
||||||
|
case "Album":
|
||||||
|
pa.appendProperty(SBProperties.albumName, 'a');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pa.appendProperty(SBProperties.trackName, 'a');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_SBGetCurrentView().setSort(pa);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user