5 const Cc = Components.classes;
6 const Ci = Components.interfaces;
7 const Cr = Components.results;
9 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
11 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
12 Components.utils.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
13 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
14 Components.utils.import(
"resource://app/jsmodules/DropHelper.jsm");
15 Components.utils.import(
"resource://app/jsmodules/StringUtils.jsm");
16 Components.utils.import(
"resource://app/jsmodules/WindowUtils.jsm");
18 const CONTRACTID =
"@rsjtdrjgfuzkfg.com/servicepane/folders;1";
22 const LSP =
'http://songbirdnest.com/rdf/library-servicepane#';
23 const SP=
'http://songbirdnest.com/rdf/servicepane#';
34 this._servicePane =
null;
42 XPCOMUtils.generateQI([
Ci.nsIObserver,
43 Ci.sbIServicePaneModule,
44 Ci.sbIServicePaneService,
45 Ci.nsIWindowMediatorListener]);
48 Components.ID(
"{12382b5a-e782-4de5-8b34-a26b82cdeeb8}");
50 "Playlist Folder AddOn Service Pane Service";
54 category:
'service-pane',
65 function pfServicePane_servicePaneInit(sps) {
68 this._servicePane = sps;
71 var
wm = Components.classes[
"@mozilla.org/appshell/window-mediator;1"].
72 getService(Components.interfaces.nsIWindowMediator);
73 var mainWindow = wm.getMostRecentWindow(
"Songbird:Main");
75 this._playlistfolders = mainWindow.playlistfolders;
77 Cc[
'@mozilla.org/observer-service;1'].getService(
Ci.nsIObserverService).
78 addObserver(
this,
'songbird-main-window-presented',
false);
83 function pfServicePane_shutdown() {}
86 function pfServicePane_fillContextMenu(aNode, aContextMenu, aParentWindow) {
87 var libraryMgr =
Cc[
"@songbirdnest.com/Songbird/library/Manager;1"]
88 .getService(
Ci.sbILibraryManager);
91 if ((aNode.id ==
'SB:Playlists') ||
92 (aNode.id.split(
'urn:library:' + libraryMgr.mainLibrary.guid).length > 1) ||
93 (aNode.getAttributeNS(
LSP,
'ListCustomType') ==
'local')) {
94 this.fillNewItemMenu(aNode, aContextMenu, aParentWindow);
99 this.fillFolderMenu(aNode, aContextMenu, aParentWindow);
104 function pfServicePane_fillNewItemMenu(aNode, aContextMenu, aParentWindow) {
105 var sbSvc =
Cc[
"@mozilla.org/intl/stringbundle;1"].
107 var stringBundle = sbSvc.createBundle(
"chrome://songbird/locale/songbird." +
111 var menuitem = aContextMenu.ownerDocument.createElement(
"menuitem");
112 menuitem.setAttribute(
"id",
"menuitem_file_folder");
113 menuitem.setAttribute(
"class",
"menuitem-iconic");
114 menuitem.setAttribute(
"label", stringBundle.
115 GetStringFromName(
"menu.servicepane." +
117 menuitem.setAttribute(
"accesskey", stringBundle.
118 GetStringFromName(
"menu." +
122 menuitem.setAttribute(
"oncommand",
"playlistfolders.servicepane." +
124 aContextMenu.appendChild(menuitem);
128 function pfServicePane_fillFolderMenu(aNode, aContextMenu, aParentWindow) {
129 var sbSvc =
Cc[
"@mozilla.org/intl/stringbundle;1"].
131 var stringBundle = sbSvc.createBundle(
"chrome://songbird/locale/songbird." +
135 var menuitem = aContextMenu.ownerDocument.createElement(
"menuitem");
136 menuitem.setAttribute(
"id",
"menuitem_folder_delete");
137 menuitem.setAttribute(
"class",
"menuitem-iconic");
138 menuitem.setAttribute(
"label", stringBundle.
139 GetStringFromName(
"command.playlist.remove"));
140 menuitem.setAttribute(
"oncommand",
"playlistfolders.servicepane." +
141 "deleteFolder('" + aNode.id +
"');");
142 aContextMenu.appendChild(menuitem);
145 menuitem = aContextMenu.ownerDocument.createElement(
"menuitem");
146 menuitem.setAttribute(
"id",
"menuitem_folder_rename");
147 menuitem.setAttribute(
"class",
"menuitem-iconic");
148 menuitem.setAttribute(
"label", stringBundle.
149 GetStringFromName(
"command.playlist.rename"));
150 menuitem.setAttribute(
"oncommand",
"gServicePane.startEditingNode(document." +
151 "getElementById('" + aNode.id +
"').nodeData);");
152 aContextMenu.appendChild(menuitem);
156 function pfServicePane_onSelectionChanged(aNode, aContainer, aParentWindow) {
160 function pfServicePane__canDropReorder(aNode, aDragSession, aOrientation) {
163 if (aOrientation == 0) {
165 if (aNode.dndAcceptIn) {
166 types = aNode.dndAcceptIn.split(
',');
170 if (aNode.dndAcceptNear) {
171 types = aNode.dndAcceptNear.split(
',');
174 for each (let type
in types) {
175 if (aDragSession.isDataFlavorSupported(type)) {
183 function pfServicePane_canDrop(aNode, aDragSession, aOrientation, aWindow) {
186 let transferable =
Cc[
"@mozilla.org/widget/transferable;1"].
189 aDragSession.getData(transferable, 0);
192 data = data.value.QueryInterface(
Ci.nsISupportsString).data;
193 var isparent =
function(
node, parentid){
194 if (
node.id == parentid){
198 if (isparent(
node.parentNode, parentid)){
204 if (isparent(aNode, data)){
211 if (this._canDropReorder(aNode, aDragSession, aOrientation))
219 function pfServicePane_onDrop(aNode, aDragSession, aOrientation, aWindow) {
222 let transferable =
Cc[
"@mozilla.org/widget/transferable;1"].
225 aDragSession.getData(transferable, 0);
228 data = data.value.QueryInterface(
Ci.nsISupportsString).data;
230 if (aOrientation == 0)
232 this._playlistfolders.servicepane.
236 if (aOrientation > 0)
238 this._playlistfolders.servicepane.
242 if (aOrientation < 0)
244 this._playlistfolders.servicepane.
251 getInternalTransferDataForFlavour(aDragSession,
253 Ci.sbIMediaListTransferContext);
254 var pguid = draggedList.list.guid;
256 if (aOrientation == 0)
258 this._playlistfolders.servicepane.
262 if (aOrientation > 0)
264 this._playlistfolders.servicepane.
268 if (aOrientation < 0)
270 this._playlistfolders.servicepane.
278 function pfServicePane_onDragGesture(aNode, aDataTransfer) {
298 function pfServicePane_onBeforeRename(aNode) {
305 function pfServicePane_onRename(aNode, aNewName) {
306 if (aNode && aNewName) {
307 this._playlistfolders.servicepane.renameFolder(aNode, aNewName);
317 function pfServicePane_observe(subject,
topic, data) {
319 if (
topic ==
'songbird-main-window-presented') {
321 var
wm = Components.classes[
"@mozilla.org/appshell/window-mediator;1"].
322 getService(Components.interfaces.nsIWindowMediator);
323 var mainWindow = wm.getMostRecentWindow(
"Songbird:Main");
324 this._playlistfolders = mainWindow.playlistfolders;
326 Cc[
'@mozilla.org/observer-service;1'].getService(
Ci.nsIObserverService).
prefs removeObserver(PREF_SELECTED_ACTION, this)
getService(Ci.sbIFaceplateManager)
const TYPE_X_SB_TRANSFER_MEDIA_LIST
historySvc addObserver(this, false)
const TYPE_X_PF_TRANSFER_FOLDER