Changing of Dock Icon according to global status and changing systray changing to avoid errors if icons are missing.

cusax-fix
Damian Minkov 18 years ago
parent 6a31261fc9
commit 3bcca45fb8

@ -1380,6 +1380,7 @@ javax.swing.event, javax.swing.border"/>
prefix="resources"/>
<zipfileset dir="${resources}/languages/impl/systray"
prefix="resources/languages/impl/systray"/>
<zipfileset src="${lib.mac.noinst}/dock.jar" prefix=""/>
</jar>
</target>

@ -37,6 +37,7 @@ org.osgi.framework.system.packages= org.osgi.framework; ; version=1.3.0, \
org.jdesktop.jdic.desktop; \
com.apple.eio; \
com.apple.cocoa.application; \
com.apple.cocoa.foundation; \
org.xml.sax.helpers; \
javax.crypto; \
javax.crypto.spec; \

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

@ -13,6 +13,9 @@ trayIconWindowsAway=resources/images/impl/systray/systrayIconWindowsAway.png
trayIconWindowsFFC=resources/images/impl/systray/systrayIconWindowsFFC.png
trayIconMacOSX=resources/images/impl/systray/systrayIconMacOSX.png
trayIconMacOSXWhite=resources/images/impl/systray/systrayIconMacOSXWhite.png
dockIconOffline=resources/images/impl/systray/dock-offline.png
dockIconAway=resources/images/impl/systray/dock-away.png
dockIconFFC=resources/images/impl/systray/dock-chatty.png
addContactIcon=resources/images/impl/gui/buttons/addContactIcon.png
statusMenuIcon=resources/images/impl/systray/statusIcon.png
settingsMenuIcon=resources/images/impl/gui/buttons/configureIcon.png

@ -9,6 +9,7 @@
import java.awt.image.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.imageio.*;
@ -104,6 +105,10 @@ public static ImageIcon getImage(String imageID)
BufferedImage image = null;
String path = Resources.getString(imageID);
if(path == null || path.length() == 0)
return null;
try
{
image =
@ -118,6 +123,23 @@ public static ImageIcon getImage(String imageID)
return new ImageIcon(image);
}
/**
* Loads an image url from a given image identifier.
*
* @param imageID The identifier of the image.
* @return The image url for the given identifier.
*/
public static URL getImageURL(String imageID)
{
String path = Resources.getString(imageID);
if(path == null || path.length() == 0)
return null;
return Resources.class.getClassLoader()
.getResource(path);
}
/**
* Returns the application property string corresponding to the given key.

@ -9,6 +9,7 @@
import java.awt.Toolkit;
import java.awt.event.*;
import java.net.*;
import java.util.*;
import java.util.Timer;
@ -16,6 +17,7 @@
import javax.swing.event.*;
import net.java.sip.communicator.impl.systray.*;
import net.java.sip.communicator.impl.systray.mac.*;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
@ -94,6 +96,13 @@ public class SystrayServiceJdicImpl
private ImageIcon envelopeIcon;
private ImageIcon envelopeIconWhite;
/**
* The dock Icons used only in Mac version
*/
private URL dockIconOffline;
private URL dockIconAway;
private URL dockIconFFC;
private boolean initialized = false;
/**
@ -176,6 +185,14 @@ else if (osName.startsWith("Mac OS X"))
menu);
trayIcon.setIconAutoSize(true);
if (osName.startsWith("Mac OS X"))
{
// init dock Icons
dockIconOffline = Resources.getImageURL("dockIconOffline");
dockIconAway = Resources.getImageURL("dockIconAway");
dockIconFFC = Resources.getImageURL("dockIconFFC");
}
//Show/hide the contact list when user clicks on the systray.
trayIcon.addActionListener(new ActionListener()
@ -272,7 +289,7 @@ public void actionPerformed(ActionEvent e)
});
systray.addTrayIcon(trayIcon);
initialized = true;
}
@ -437,55 +454,87 @@ public void setSystrayIcon(int imageType)
return;
String osName = System.getProperty("os.name");
ImageIcon toChangeSystrayIcon = null;
if (imageType == SystrayService.SC_IMG_TYPE)
{
if (osName.startsWith("Mac OS X") && this.menu.isVisible())
{
this.trayIcon.setIcon(logoIconWhite);
this.currentIcon = logoIconWhite;
toChangeSystrayIcon = logoIconWhite;
}
else
{
this.trayIcon.setIcon(logoIcon);
this.currentIcon = logoIcon;
toChangeSystrayIcon = logoIcon;
}
}
else if (imageType == SystrayService.SC_IMG_OFFLINE_TYPE)
{
if (!osName.startsWith("Mac OS X"))
{
this.trayIcon.setIcon(logoIconOffline);
this.currentIcon = logoIconOffline;
toChangeSystrayIcon = logoIconOffline;
}
}
else if (imageType == SystrayService.SC_IMG_AWAY_TYPE)
{
if (!osName.startsWith("Mac OS X"))
{
this.trayIcon.setIcon(logoIconAway);
this.currentIcon = logoIconAway;
toChangeSystrayIcon = logoIconAway;
}
}
else if (imageType == SystrayService.SC_IMG_FFC_TYPE)
{
if (!osName.startsWith("Mac OS X"))
{
this.trayIcon.setIcon(logoIconFFC);
this.currentIcon = logoIconFFC;
toChangeSystrayIcon = logoIconFFC;
}
}
else if (imageType == SystrayService.ENVELOPE_IMG_TYPE)
{
if (osName.startsWith("Mac OS X") && this.menu.isVisible())
{
this.trayIcon.setIcon(envelopeIconWhite);
this.currentIcon = envelopeIconWhite;
toChangeSystrayIcon = envelopeIconWhite;
}
else
{
this.trayIcon.setIcon(envelopeIcon);
this.currentIcon = envelopeIcon;
toChangeSystrayIcon = envelopeIcon;
}
}
if(toChangeSystrayIcon != null)
{
this.trayIcon.setIcon(toChangeSystrayIcon);
this.currentIcon = toChangeSystrayIcon;
}
if (osName.startsWith("Mac OS X"))
{
URL toChangeDockIcon = null;
switch(imageType)
{
case SystrayService.SC_IMG_TYPE:
// online will restore the original image
break;
case SystrayService.SC_IMG_OFFLINE_TYPE :
toChangeDockIcon = dockIconOffline; break;
case SystrayService.SC_IMG_AWAY_TYPE :
toChangeDockIcon = dockIconAway; break;
case SystrayService.SC_IMG_FFC_TYPE :
toChangeDockIcon = dockIconFFC; break;
}
try
{
if(toChangeDockIcon != null)
{
Dock.setDockTileImage(toChangeDockIcon);
}
else
Dock.restoreDockTileImage();
}
catch (Exception e)
{
logger.error("failed to change dock icon", e);
}
}
}

@ -7,6 +7,8 @@ Export-Package: net.java.sip.communicator.service.systray,
net.java.sip.communicator.service.systray.event
Import-Package: org.osgi.framework,
org.jdesktop.jdic.tray,
com.apple.cocoa.application,
com.apple.cocoa.foundation,
net.java.sip.communicator.util,
net.java.sip.communicator.service.configuration,
net.java.sip.communicator.service.protocol,

Loading…
Cancel
Save