mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 398627 - "make icons for "always ask" and "save file" actions in Applications prefpane" (Get rid of icon URL hardcoding) [p=ventnor.bugzilla@yahoo.com.au (Michael Ventnor) r=myk a=blocking-firefox3+]
This commit is contained in:
parent
1eebb259dd
commit
224d43081c
@ -97,14 +97,11 @@ const PREF_FEED_SELECTED_READER = "browser.feeds.handler.default";
|
|||||||
// identifying the "use plugin" action, so we use this constant instead.
|
// identifying the "use plugin" action, so we use this constant instead.
|
||||||
const kActionUsePlugin = 5;
|
const kActionUsePlugin = 5;
|
||||||
|
|
||||||
const ICON_URL_PLUGIN = "chrome://browser/skin/preferences/plugin.png";
|
|
||||||
const ICON_URL_LIVEMARK = "chrome://browser/skin/page-livemarks.png";
|
|
||||||
const ICON_URL_APP = "chrome://browser/skin/preferences/application.png";
|
const ICON_URL_APP = "chrome://browser/skin/preferences/application.png";
|
||||||
// FIXME: come up with icons for the "always ask" and "save file" actions.
|
|
||||||
// Filed as bug 398627.
|
|
||||||
const ICON_URL_ASK = ICON_URL_APP;
|
|
||||||
const ICON_URL_SAVE = ICON_URL_APP;
|
|
||||||
|
|
||||||
|
// For CSS. Can be one of "ask", "save", "plugin" or "feed". If absent, the icon URL
|
||||||
|
// was set by us to a custom handler icon and CSS should not try to override it.
|
||||||
|
const APP_ICON_ATTR_NAME = "appHandlerIcon";
|
||||||
|
|
||||||
//****************************************************************************//
|
//****************************************************************************//
|
||||||
// Utilities
|
// Utilities
|
||||||
@ -1073,8 +1070,12 @@ var gApplicationsPane = {
|
|||||||
item.setAttribute("typeIcon", visibleType.smallIcon);
|
item.setAttribute("typeIcon", visibleType.smallIcon);
|
||||||
item.setAttribute("actionDescription",
|
item.setAttribute("actionDescription",
|
||||||
this._describePreferredAction(visibleType));
|
this._describePreferredAction(visibleType));
|
||||||
item.setAttribute("actionIcon",
|
|
||||||
this._getIconURLForPreferredAction(visibleType));
|
if (!this._setIconClassForPreferredAction(visibleType, item)) {
|
||||||
|
item.setAttribute("actionIcon",
|
||||||
|
this._getIconURLForPreferredAction(visibleType));
|
||||||
|
}
|
||||||
|
|
||||||
this._list.appendChild(item);
|
this._list.appendChild(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1256,7 +1257,7 @@ var gApplicationsPane = {
|
|||||||
label = this._prefsBundle.getString("alwaysAsk");
|
label = this._prefsBundle.getString("alwaysAsk");
|
||||||
askMenuItem.setAttribute("label", label);
|
askMenuItem.setAttribute("label", label);
|
||||||
askMenuItem.setAttribute("tooltiptext", label);
|
askMenuItem.setAttribute("tooltiptext", label);
|
||||||
askMenuItem.setAttribute("image", ICON_URL_ASK);
|
askMenuItem.setAttribute(APP_ICON_ATTR_NAME, "ask");
|
||||||
menuPopup.appendChild(askMenuItem);
|
menuPopup.appendChild(askMenuItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1268,7 +1269,7 @@ var gApplicationsPane = {
|
|||||||
[this._brandShortName]);
|
[this._brandShortName]);
|
||||||
internalMenuItem.setAttribute("label", label);
|
internalMenuItem.setAttribute("label", label);
|
||||||
internalMenuItem.setAttribute("tooltiptext", label);
|
internalMenuItem.setAttribute("tooltiptext", label);
|
||||||
internalMenuItem.setAttribute("image", ICON_URL_LIVEMARK);
|
internalMenuItem.setAttribute(APP_ICON_ATTR_NAME, "feed");
|
||||||
menuPopup.appendChild(internalMenuItem);
|
menuPopup.appendChild(internalMenuItem);
|
||||||
|
|
||||||
// Add a separator to distinguish these items from the helper app items
|
// Add a separator to distinguish these items from the helper app items
|
||||||
@ -1325,7 +1326,7 @@ var gApplicationsPane = {
|
|||||||
this._brandShortName]);
|
this._brandShortName]);
|
||||||
pluginMenuItem.setAttribute("label", label);
|
pluginMenuItem.setAttribute("label", label);
|
||||||
pluginMenuItem.setAttribute("tooltiptext", label);
|
pluginMenuItem.setAttribute("tooltiptext", label);
|
||||||
pluginMenuItem.setAttribute("image", ICON_URL_PLUGIN);
|
pluginMenuItem.setAttribute(APP_ICON_ATTR_NAME, "plugin");
|
||||||
menuPopup.appendChild(pluginMenuItem);
|
menuPopup.appendChild(pluginMenuItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1357,7 +1358,7 @@ var gApplicationsPane = {
|
|||||||
let label = this._prefsBundle.getString("saveFile");
|
let label = this._prefsBundle.getString("saveFile");
|
||||||
saveMenuItem.setAttribute("label", label);
|
saveMenuItem.setAttribute("label", label);
|
||||||
saveMenuItem.setAttribute("tooltiptext", label);
|
saveMenuItem.setAttribute("tooltiptext", label);
|
||||||
saveMenuItem.setAttribute("image", ICON_URL_SAVE);
|
saveMenuItem.setAttribute(APP_ICON_ATTR_NAME, "save");
|
||||||
menuPopup.appendChild(saveMenuItem);
|
menuPopup.appendChild(saveMenuItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1546,8 +1547,10 @@ var gApplicationsPane = {
|
|||||||
// Update the action label and image to reflect the new preferred action.
|
// Update the action label and image to reflect the new preferred action.
|
||||||
typeItem.setAttribute("actionDescription",
|
typeItem.setAttribute("actionDescription",
|
||||||
this._describePreferredAction(handlerInfo));
|
this._describePreferredAction(handlerInfo));
|
||||||
typeItem.setAttribute("actionIcon",
|
if (!this._setIconClassForPreferredAction(handlerInfo, typeItem)) {
|
||||||
this._getIconURLForPreferredAction(handlerInfo));
|
typeItem.setAttribute("actionIcon",
|
||||||
|
this._getIconURLForPreferredAction(handlerInfo));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
chooseApp: function(aEvent) {
|
chooseApp: function(aEvent) {
|
||||||
@ -1637,19 +1640,39 @@ var gApplicationsPane = {
|
|||||||
this._list.selectedItem.getAttribute("type"));
|
this._list.selectedItem.getAttribute("type"));
|
||||||
},
|
},
|
||||||
|
|
||||||
_getIconURLForPreferredAction: function(aHandlerInfo) {
|
_setIconClassForPreferredAction: function(aHandlerInfo, aElement) {
|
||||||
if (aHandlerInfo.alwaysAskBeforeHandling)
|
// If this returns true, the attribute that CSS sniffs for was set to something
|
||||||
return ICON_URL_ASK;
|
// so you shouldn't manually set an icon URI.
|
||||||
|
// This removes the existing actionIcon attribute if any, even if returning false.
|
||||||
|
aElement.removeAttribute("actionIcon");
|
||||||
|
|
||||||
|
if (aHandlerInfo.alwaysAskBeforeHandling) {
|
||||||
|
aElement.setAttribute(APP_ICON_ATTR_NAME, "ask");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
switch (aHandlerInfo.preferredAction) {
|
switch (aHandlerInfo.preferredAction) {
|
||||||
case Ci.nsIHandlerInfo.saveToDisk:
|
case Ci.nsIHandlerInfo.saveToDisk:
|
||||||
return ICON_URL_SAVE;
|
aElement.setAttribute(APP_ICON_ATTR_NAME, "save");
|
||||||
|
return true;
|
||||||
|
|
||||||
case Ci.nsIHandlerInfo.handleInternally:
|
case Ci.nsIHandlerInfo.handleInternally:
|
||||||
if (aHandlerInfo.type == TYPE_MAYBE_FEED)
|
if (aHandlerInfo.type == TYPE_MAYBE_FEED) {
|
||||||
return ICON_URL_LIVEMARK;
|
aElement.setAttribute(APP_ICON_ATTR_NAME, "feed");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kActionUsePlugin:
|
||||||
|
aElement.setAttribute(APP_ICON_ATTR_NAME, "plugin");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
aElement.removeAttribute(APP_ICON_ATTR_NAME);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
_getIconURLForPreferredAction: function(aHandlerInfo) {
|
||||||
|
switch (aHandlerInfo.preferredAction) {
|
||||||
case Ci.nsIHandlerInfo.useSystemDefault:
|
case Ci.nsIHandlerInfo.useSystemDefault:
|
||||||
return this._getIconURLForSystemDefault(aHandlerInfo);
|
return this._getIconURLForSystemDefault(aHandlerInfo);
|
||||||
|
|
||||||
@ -1660,9 +1683,6 @@ var gApplicationsPane = {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kActionUsePlugin:
|
|
||||||
return ICON_URL_PLUGIN;
|
|
||||||
|
|
||||||
// This should never happen, but if preferredAction is set to some weird
|
// This should never happen, but if preferredAction is set to some weird
|
||||||
// value, then fall back to the generic application icon.
|
// value, then fall back to the generic application icon.
|
||||||
default:
|
default:
|
||||||
|
@ -62,6 +62,26 @@ richlistitem {
|
|||||||
min-height: 25px;
|
min-height: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
richlistitem[appHandlerIcon="ask"],
|
||||||
|
menuitem[appHandlerIcon="ask"] {
|
||||||
|
list-style-image: url("chrome://browser/skin/preferences/alwaysAsk.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistitem[appHandlerIcon="save"],
|
||||||
|
menuitem[appHandlerIcon="save"] {
|
||||||
|
list-style-image: url("moz-icon://stock/gtk-save?size=menu");
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistitem[appHandlerIcon="feed"],
|
||||||
|
menuitem[appHandlerIcon="feed"] {
|
||||||
|
list-style-image: url("chrome://browser/skin/page-livemarks.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistitem[appHandlerIcon="plugin"],
|
||||||
|
menuitem[appHandlerIcon="plugin"] {
|
||||||
|
list-style-image: url("chrome://browser/skin/preferences/plugin.png");
|
||||||
|
}
|
||||||
|
|
||||||
.actionsMenu .menulist-icon {
|
.actionsMenu .menulist-icon {
|
||||||
-moz-margin-end: 1px;
|
-moz-margin-end: 1px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
|
@ -61,6 +61,26 @@ richlistitem {
|
|||||||
min-height: 22px;
|
min-height: 22px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
richlistitem[appHandlerIcon="ask"],
|
||||||
|
menuitem[appHandlerIcon="ask"] {
|
||||||
|
list-style-image: url("chrome://browser/skin/preferences/application.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistitem[appHandlerIcon="save"],
|
||||||
|
menuitem[appHandlerIcon="save"] {
|
||||||
|
list-style-image: url("chrome://browser/skin/preferences/application.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistitem[appHandlerIcon="feed"],
|
||||||
|
menuitem[appHandlerIcon="feed"] {
|
||||||
|
list-style-image: url("chrome://browser/skin/page-livemarks.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistitem[appHandlerIcon="plugin"],
|
||||||
|
menuitem[appHandlerIcon="plugin"] {
|
||||||
|
list-style-image: url("chrome://browser/skin/preferences/plugin.png");
|
||||||
|
}
|
||||||
|
|
||||||
.actionsMenu .menulist-icon {
|
.actionsMenu .menulist-icon {
|
||||||
-moz-margin-end: 1px;
|
-moz-margin-end: 1px;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,26 @@ richlistitem {
|
|||||||
min-height: 22px;
|
min-height: 22px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
richlistitem[appHandlerIcon="ask"],
|
||||||
|
menuitem[appHandlerIcon="ask"] {
|
||||||
|
list-style-image: url("chrome://browser/skin/preferences/alwaysAsk.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistitem[appHandlerIcon="save"],
|
||||||
|
menuitem[appHandlerIcon="save"] {
|
||||||
|
list-style-image: url("chrome://browser/skin/preferences/application.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistitem[appHandlerIcon="feed"],
|
||||||
|
menuitem[appHandlerIcon="feed"] {
|
||||||
|
list-style-image: url("chrome://browser/skin/page-livemarks.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistitem[appHandlerIcon="plugin"],
|
||||||
|
menuitem[appHandlerIcon="plugin"] {
|
||||||
|
list-style-image: url("chrome://browser/skin/preferences/plugin.png");
|
||||||
|
}
|
||||||
|
|
||||||
.actionsMenu .menulist-icon {
|
.actionsMenu .menulist-icon {
|
||||||
-moz-margin-end: 3px;
|
-moz-margin-end: 3px;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user