/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Check G_BROKEN_FILENAMES. If it's set, then filenames in glib use // the locale encoding. If it's not set, they use UTF-8.
mUseLocaleFilenames = PR_GetEnv("G_BROKEN_FILENAMES") != nullptr;
NS_IMETHODIMP
nsGNOMEShellService::SetDefaultBrowser(bool aForAllUsers) { #ifdef DEBUG if (aForAllUsers)
NS_WARNING( "Setting the default browser for all users is not yet supported"); #endif
// use brandShortName as the application id.
NS_ConvertUTF16toUTF8 id(brandShortName);
nsCOMPtr<nsIGIOMimeApp> appInfo;
rv = giovfs->FindAppFromCommand(mAppPath, getter_AddRefs(appInfo)); if (NS_FAILED(rv)) { // Application was not found in the list of installed applications // provided by OS. Fallback to create appInfo from command and name.
rv = giovfs->CreateAppFromCommand(mAppPath, id, getter_AddRefs(appInfo));
NS_ENSURE_SUCCESS(rv, rv);
}
// set handler for the protocols for (unsignedint i = 0; i < std::size(appProtocols); ++i) {
appInfo->SetAsDefaultForURIScheme(
nsDependentCString(appProtocols[i].name));
}
// set handler for .html and xhtml files and MIME types: // Add mime types for html, xhtml extension and set app to just created // appinfo. for (unsignedint i = 0; i < std::size(appTypes); ++i) {
appInfo->SetAsDefaultForMimeType(
nsDependentCString(appTypes[i].mimeType));
appInfo->SetAsDefaultForFileExtensions(
nsDependentCString(appTypes[i].extensions));
}
}
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); if (prefs) {
(void)prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, true); // Reset the number of times the dialog should be shown // before it is silenced.
(void)prefs->SetIntPref(PREF_DEFAULTBROWSERCHECKCOUNT, 0);
}
return NS_OK;
}
NS_IMETHODIMP
nsGNOMEShellService::GetCanSetDesktopBackground(bool* aResult) { // setting desktop background is currently only supported // for Gnome or desktops using the same GSettings keys if (widget::IsGnomeDesktopEnvironment()) {
*aResult = true; return NS_OK;
}
// Write the background file to the home directory.
nsAutoCString filePath(PR_GetEnv("HOME"));
nsAutoString brandName;
// get the product brand name from localized strings if (nsCOMPtr<nsIStringBundleService> bundleService =
components::StringBundle::Service()) {
nsCOMPtr<nsIStringBundle> brandBundle;
bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle)); if (bundleService) {
brandBundle->GetStringFromName("brandShortName", brandName);
}
}
// build the file name
filePath.Append('/');
filePath.Append(NS_ConvertUTF16toUTF8(brandName));
filePath.AppendLiteral("_wallpaper.png");
// write the image to a file in the home dir
MOZ_TRY(WriteImage(filePath, container));
nsCOMPtr<nsIGSettingsService> gsettings =
do_GetService(NS_GSETTINGSSERVICE_CONTRACTID); if (!gsettings) { return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIGSettingsCollection> backgroundSettings;
gsettings->GetCollectionForSchema(kDesktopBGSchema,
getter_AddRefs(backgroundSettings)); if (!backgroundSettings) { return NS_ERROR_FAILURE;
}
staticvoid ColorToCString(uint32_t aColor, nsCString& aResult) { // The #rrrrggggbbbb format is used to match gdk_color_to_string()
aResult.SetLength(13); char* buf = aResult.BeginWriting(); if (!buf) return;
uint16_t red = COLOR_8_TO_16_BIT((aColor >> 16) & 0xff);
uint16_t green = COLOR_8_TO_16_BIT((aColor >> 8) & 0xff);
uint16_t blue = COLOR_8_TO_16_BIT(aColor & 0xff);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.