Skip to content
Browse files

Bug 954216 - Add a context menu to the user icon to set and remove it…

…. r=florian
  • Loading branch information...
1 parent ff23b4a commit de0f86671c818aabf102071e54dcd01dcda91885 @mayanktg mayanktg committed Mar 4, 2014
View
6 chat/components/public/imIUserStatusInfo.idl
@@ -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);
View
10 im/content/blist.js
@@ -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")) {
View
14 im/content/blist.xul
@@ -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"
View
8 im/content/menus.js
@@ -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
View
6 im/locales/en-US/chrome/instantbird/instantbird.dtd
@@ -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">

0 comments on commit de0f866

Please sign in to comment.
Something went wrong with that request. Please try again.