Bug 954216 - Add a context menu to the user icon to set and remove it. r=florian

This commit is contained in:
Mayank Kumar 2014-03-04 10:08:23 -05:00
Родитель ff23b4a816
Коммит de0f86671c
5 изменённых файлов: 37 добавлений и 7 удалений

Просмотреть файл

@ -24,12 +24,14 @@ interface imIUserStatusInfo: nsISupports {
// - When called with STATUS_OFFLINE, the aMessage parameter is ignored.
void setStatus(in short aStatus, in AUTF8String aMessage);
/* Will fire an user-icon-changed notificaton. */
// Sets the user icon, or removes it if null is passed as a parameter.
// Will fire a user-icon-changed notificaton.
void setUserIcon(in nsIFile aIconFile);
// Returns the location of the current user icon, or null if no icon is set.
nsIFileURL getUserIcon();
/* The setter will fire an user-display-name-changed notificaton. */
/* The setter will fire a user-display-name-changed notificaton. */
attribute AUTF8String displayName;
void addObserver(in nsIObserver aObserver);

Просмотреть файл

@ -577,7 +577,7 @@ var buddyList = {
switch (aEvent.keyCode) {
case aEvent.DOM_VK_RETURN:
case aEvent.DOM_VK_ENTER:
this.userIconClick();
this.chooseUserIcon();
break;
case aEvent.DOM_VK_TAB:
@ -589,12 +589,12 @@ var buddyList = {
default:
if (aEvent.charCode == aEvent.DOM_VK_SPACE)
this.userIconClick();
this.chooseUserIcon();
break;
}
},
userIconClick: function bl_userIconClick() {
chooseUserIcon: function bl_chooseUserIcon() {
const nsIFilePicker = Components.interfaces.nsIFilePicker;
let fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
@ -606,6 +606,10 @@ var buddyList = {
Services.core.globalUserStatus.setUserIcon(fp.file);
},
removeUserIcon: function bl_removeUserIcon() {
Services.core.globalUserStatus.setUserIcon(null);
},
displayNameClick: function bl_displayNameClick() {
let elt = document.getElementById("displayName");
if (!elt.hasAttribute("editing")) {

Просмотреть файл

@ -48,6 +48,16 @@
<tooltip id="buddyTooltip" type="buddy"
onpopupshowing="return !('_droptarget' in window);"/>
<menupopup id="userIconContextMenu"
onpopupshowing="menus.updateUserIconContextMenuitems();">
<menuitem id="chooseIconMenuItem" label="&chooseIconCmd.label;"
accesskey="&chooseIconCmd.accesskey;"
oncommand="buddyList.chooseUserIcon();" default="true"/>
<menuitem id="removeIconMenuItem" label="&removeIconCmd.label;"
accesskey="&removeIconCmd.accesskey;"
oncommand="buddyList.removeUserIcon();"/>
</menupopup>
<menupopup id="buddyListContextMenu"
onpopupshowing="if (event.target != this) return true; gBuddyListContextMenu = new buddyListContextMenu(this); return gBuddyListContextMenu.shouldDisplay;"
onpopuphiding="if (event.target == this) { gBuddyListContextMenu = null; }">
@ -121,9 +131,9 @@
<toolbox id="mainToolbox">
<toolbar id="statusArea">
<stack id="statusImageStack">
<image id="userIcon" role="button"
<image id="userIcon" role="button" context="userIconContextMenu"
aria-label="&userIcon.label;" tooltiptext="&userIcon.label;"
onclick="buddyList.userIconClick();"
onclick="if (event.button == 0) buddyList.chooseUserIcon();"
onkeypress="buddyList.userIconKeyPress(event);"/>
<button type="menu" id="statusTypeIcon" status="available">
<menupopup id="setStatusTypeMenupopup"

Просмотреть файл

@ -127,6 +127,14 @@ var menus = {
goUpdateCommand("cmd_newtab");
},
updateUserIconContextMenuitems: function menu_updateUserIconContextMenuitems() {
let menuItem = document.getElementById("removeIconMenuItem");
if (Services.core.globalUserStatus.getUserIcon())
menuItem.removeAttribute("disabled");
else
menuItem.setAttribute("disabled", "true");
},
openDialog: function menu_openDialog(aWindowType, aURL) {
let features = "chrome,modal,titlebar,centerscreen";
#ifdef XP_MACOSX

Просмотреть файл

@ -128,6 +128,12 @@
<!ENTITY hideGroupTooltip "Hide">
<!-- Context Menu to add/remove user icon -->
<!ENTITY chooseIconCmd.label "Choose Image…">
<!ENTITY chooseIconCmd.accesskey "C">
<!ENTITY removeIconCmd.label "Remove">
<!ENTITY removeIconCmd.accesskey "R">
<!-- Copied from mozilla/browser/locales/en-US/chrome/browser/baseMenuOverlay.dtd -->
<!-- Mac OS X Window Menu -->
<!ENTITY windowMenu.label "Window">