Esempio n. 1
0
extern "C" NS_GFX_(PRBool) NS_HexToRGB(const nsString& aColorSpec,
                                       nscolor* aResult)
{
  // XXXldb nsStackString<10>
  NS_LossyConvertUCS2toASCII bufferStr(aColorSpec);
  return NS_ASCIIHexToRGB(bufferStr, aResult);
}
Esempio n. 2
0
NS_IMETHODIMP
nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor)
{
  nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);

  nsCAutoString background;
  gconf->GetString(NS_LITERAL_CSTRING(kDesktopColorKey), background);

  if (background.IsEmpty()) {
    *aColor = 0;
    return NS_OK;
  }

  // Chop off the leading '#' character
  background.Cut(0, 1);

  nscolor rgb;
  if (!NS_ASCIIHexToRGB(background, &rgb))
    return NS_ERROR_FAILURE;

  // The result must be in RGB order with the high 8 bits zero.
  *aColor = (NS_GET_R(rgb) << 16 | NS_GET_G(rgb) << 8  | NS_GET_B(rgb));
  return NS_OK;
}