30 if (typeof(
Cc) ==
"undefined")
31 var
Cc = Components.classes;
32 if (typeof(
Ci) ==
"undefined")
33 var
Ci = Components.interfaces;
34 if (typeof(
Cr) ==
"undefined")
35 var
Cr = Components.results;
36 if (typeof(
Cu) ==
"undefined")
37 var
Cu = Components.utils;
39 Cu.import(
"resource://app/jsmodules/ArrayConverter.jsm");
47 doPaneLoad:
function() {
50 function forceCheck(
event) {
52 Application.prefs.getValue(
"browser.preferences.instantApply",
true);
53 if (
event.type ==
"dialogcancel" && !instantApply) {
60 self.applyFetcherPreferences();
63 window.addEventListener(
'dialogaccept', forceCheck,
false);
64 window.addEventListener(
'dialogcancel', forceCheck,
false);
67 this.resetFetcherPreferences();
74 moveFetcher:
function(
offset) {
75 var fetcherBox = document.getElementById(
"fetcherListBox");
76 var currentFetcher = fetcherBox.getSelectedItem(0);
78 var fetcherIndex = fetcherBox.getIndexOfItem(currentFetcher);
79 var fLabel = currentFetcher.getAttribute(
"label");
80 var fValue = currentFetcher.value;
81 var fEnabled = currentFetcher.checked;
82 if ( (fetcherIndex > 0) || (
offset > 0) ) {
83 fetcherBox.removeItemAt(fetcherIndex);
84 if (fetcherIndex <= fetcherBox.getRowCount()) {
85 newFetcher = fetcherBox.insertItemAt((fetcherIndex +
offset),
89 newFetcher = fetcherBox.appendItem(fLabel, fValue);
91 newFetcher.setAttribute(
"type",
"checkbox");
92 newFetcher.setAttribute(
"checked", fEnabled);
93 fetcherBox.selectItem(newFetcher);
102 resetFetcherPreferences:
function() {
103 var fetcherBox = document.getElementById(
"fetcherListBox");
106 while(fetcherBox.getRowCount() > 0) {
107 fetcherBox.removeItemAt(0);
110 var albumArtService = Cc[
"@songbirdnest.com/Songbird/album-art-service;1"]
111 .getService(Ci.sbIAlbumArtService);
112 var fetchList = albumArtService.getFetcherList(
113 Ci.sbIAlbumArtFetcherSet.TYPE_ALL,
116 for (var fIndex = 0; fIndex < fetchList.length; fIndex++) {
119 var fetcherCid = fetchList.queryElementAt(fIndex, Ci.nsIVariant);
120 var cFetcher = Cc[fetcherCid].createInstance(Ci.sbIAlbumArtFetcher);
121 var fLabel = cFetcher.name +
" (" + cFetcher.description +
")";
122 var newFetcher = fetcherBox.appendItem(fLabel, fetcherCid);
123 newFetcher.setAttribute(
"type",
"checkbox");
124 newFetcher.setAttribute(
"checked", cFetcher.isEnabled);
126 Cu.reportError(
"Unable to find fetcher: " + err);
135 applyFetcherPreferences:
function() {
136 var fetcherBox = document.getElementById(
"fetcherListBox");
138 var fetcherCount = fetcherBox.getRowCount();
139 var fPref =
"songbird.albumart.";
141 for (var fIndex = 0; fIndex < fetcherCount; fIndex++) {
142 var fetcherItem = fetcherBox.getItemAtIndex(fIndex);
145 var fetcherCid = fetcherItem.value;
146 var cFetcher = Cc[fetcherCid].createInstance(Ci.sbIAlbumArtFetcher);
147 cFetcher.priority = fIndex;
148 cFetcher.isEnabled = fetcherItem.checked;
150 Cu.reportError(
"Unable to update fetcher: " + err);