Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
No build reason found for snapshot:x86_64
home:Thaodan:mozilla
MozillaFirefox
0025-Add-KDE-integration-to-Firefox.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0025-Add-KDE-integration-to-Firefox.patch of Package MozillaFirefox
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Martin Sirringhaus <msirringhaus@suse.de> Date: Tue, 8 Aug 2023 16:18:24 +0300 Subject: [PATCH] Add KDE integration to Firefox Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=140751 Bug: https://bugzilla.suse.com/show_bug.cgi?id=170055 How to apply this patch: 1. Import and apply it 2. cp browser/base/content/browser.xul browser/base/content/browser-kde.xul 3. Find editBookmarkPanelDoneButton 4. Replace #ifndef with #ifdef in the line above (this hanges the button order from Gnome-style to KDE-style) 5. hg qrefresh --- browser/components/preferences/main.js | 18 +++ browser/components/shell/moz.build | 2 + .../components/shell/nsKDEShellService.cpp | 108 ++++++++++++++++++ browser/components/shell/nsKDEShellService.h | 32 ++++++ .../components/shell/nsUnixShellService.cpp | 22 ++++ browser/components/shell/nsUnixShellService.h | 15 +++ 6 files changed, 197 insertions(+) create mode 100644 browser/components/shell/nsKDEShellService.cpp create mode 100644 browser/components/shell/nsKDEShellService.h create mode 100644 browser/components/shell/nsUnixShellService.cpp create mode 100644 browser/components/shell/nsUnixShellService.h diff --git a/browser/components/preferences/main.js b/browser/components/preferences/main.js index 2f7d5d7c892228cf26d444b037a6de4472f07df6..7027fc173624be931c815342e91064de3f94a81a 100644 --- a/browser/components/preferences/main.js +++ b/browser/components/preferences/main.js @@ -299,6 +299,13 @@ var gMainPane = { }, backoffTimes[this._backoffIndex]); } + var env = Components.classes["@mozilla.org/process/environment;1"] + .getService(Components.interfaces.nsIEnvironment); + var kde_session = 0; + if (env.get('KDE_FULL_SESSION') == "true") { + kde_session = 1; + } + this.initBrowserContainers(); this.buildContentProcessCountMenuList(); @@ -1771,6 +1778,17 @@ var gMainPane = { try { await shellSvc.setDefaultBrowser(false); + if (kde_session == 1) { + var shellObj = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + shellObj.initWithPath("/usr/bin/kwriteconfig"); + var process = Components.classes["@mozilla.org/process/util;1"] + .createInstance(Components.interfaces.nsIProcess); + process.init(shellObj); + var args = ["--file", "kdeglobals", "--group", "General", "--key", + "BrowserApplication", "firefox"]; + process.run(false, args, args.length); + } } catch (ex) { console.error(ex); return; diff --git a/browser/components/shell/moz.build b/browser/components/shell/moz.build index 8e4858ca84b5c308ff26b4d4f902cbb603df0f92..378976fa6b3d4d2575322a62d712a3200d0c3ef2 100644 --- a/browser/components/shell/moz.build +++ b/browser/components/shell/moz.build @@ -39,6 +39,8 @@ elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": SOURCES += [ "nsGNOMEShellService.cpp", + "nsKDEShellService.cpp", + "nsUnixShellService.cpp", ] if CONFIG["MOZ_ENABLE_DBUS"]: SOURCES += [ diff --git a/browser/components/shell/nsKDEShellService.cpp b/browser/components/shell/nsKDEShellService.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c0799319e4f1e65786e1ac4e01775051339399e6 --- /dev/null +++ b/browser/components/shell/nsKDEShellService.cpp @@ -0,0 +1,108 @@ +/* -*- 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/. */ + +#include "mozilla/ArrayUtils.h" + +#include "nsCOMPtr.h" +#include "nsKDEShellService.h" +#include "nsShellService.h" +#include "nsKDEUtils.h" +#include "nsIPrefService.h" +#include "nsIProcess.h" +#include "nsIFile.h" +#include "nsServiceManagerUtils.h" +#include "nsComponentManagerUtils.h" +#include "nsIMutableArray.h" +#include "nsISupportsPrimitives.h" +#include "nsArrayUtils.h" + +using namespace mozilla; + +nsresult +nsKDEShellService::Init() +{ + if( !nsKDEUtils::kdeSupport()) + return NS_ERROR_NOT_AVAILABLE; + return NS_OK; +} + +NS_IMPL_ISUPPORTS(nsKDEShellService, nsIGNOMEShellService, nsIShellService) + +NS_IMETHODIMP +nsKDEShellService::IsDefaultBrowser(bool aForAllTypes, + bool* aIsDefaultBrowser) +{ + *aIsDefaultBrowser = false; + + nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID ); + if (!command) + return NS_ERROR_FAILURE; + + nsCOMPtr<nsISupportsCString> str = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID ); + if (!str) + return NS_ERROR_FAILURE; + + str->SetData("ISDEFAULTBROWSER"_ns); + command->AppendElement( str ); + + if( nsKDEUtils::command( command )) + *aIsDefaultBrowser = true; + return NS_OK; +} + +NS_IMETHODIMP +nsKDEShellService::SetDefaultBrowser(bool aForAllUsers) +{ + nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID ); + if (!command) + return NS_ERROR_FAILURE; + + nsCOMPtr<nsISupportsCString> cmdstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID ); + nsCOMPtr<nsISupportsCString> paramstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID ); + if (!cmdstr || !paramstr) + return NS_ERROR_FAILURE; + + cmdstr->SetData("SETDEFAULTBROWSER"_ns); + command->AppendElement( cmdstr ); + + paramstr->SetData("ALLTYPES"_ns); + command->AppendElement( paramstr ); + + return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +nsKDEShellService::GetCanSetDesktopBackground(bool* aResult) +{ + *aResult = true; + return NS_OK; +} + +NS_IMETHODIMP +nsKDEShellService::SetDesktopBackground(dom::Element* aElement, + int32_t aPosition, + const nsACString& aImageName) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsKDEShellService::GetDesktopBackgroundColor(PRUint32 *aColor) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsKDEShellService::SetDesktopBackgroundColor(PRUint32 aColor) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsKDEShellService::IsDefaultForScheme(nsTSubstring<char> const& aScheme, bool* aIsDefaultBrowser) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + diff --git a/browser/components/shell/nsKDEShellService.h b/browser/components/shell/nsKDEShellService.h new file mode 100644 index 0000000000000000000000000000000000000000..8b0bb19164352453cfa453dd87c19263160b9ad8 --- /dev/null +++ b/browser/components/shell/nsKDEShellService.h @@ -0,0 +1,32 @@ +/* -*- 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/. */ + +#ifndef nskdeshellservice_h____ +#define nskdeshellservice_h____ + +#include "nsIGNOMEShellService.h" +#include "nsToolkitShellService.h" +#include "nsString.h" +#include "mozilla/Attributes.h" + +class nsKDEShellService final : public nsIGNOMEShellService, + public nsToolkitShellService +{ +public: + nsKDEShellService() : mCheckedThisSession(false) { } + + NS_DECL_ISUPPORTS + NS_DECL_NSISHELLSERVICE + NS_DECL_NSIGNOMESHELLSERVICE + + nsresult Init(); + +private: + ~nsKDEShellService() {} + + bool mCheckedThisSession; +}; + +#endif // nskdeshellservice_h____ diff --git a/browser/components/shell/nsUnixShellService.cpp b/browser/components/shell/nsUnixShellService.cpp new file mode 100644 index 0000000000000000000000000000000000000000..abf266ebdc52e136f495911da3454e69c770c6db --- /dev/null +++ b/browser/components/shell/nsUnixShellService.cpp @@ -0,0 +1,22 @@ +/* -*- 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/. */ + + +#include "nsUnixShellService.h" +#include "nsGNOMEShellService.h" +#include "nsKDEShellService.h" +#include "nsKDEUtils.h" +#include "mozilla/ModuleUtils.h" + +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGNOMEShellService, Init) +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsKDEShellService, Init) + +NS_IMETHODIMP +nsUnixShellServiceConstructor(REFNSIID aIID, void **aResult) +{ + if( nsKDEUtils::kdeSupport()) + return nsKDEShellServiceConstructor( aIID, aResult ); + return nsGNOMEShellServiceConstructor( aIID, aResult ); +} diff --git a/browser/components/shell/nsUnixShellService.h b/browser/components/shell/nsUnixShellService.h new file mode 100644 index 0000000000000000000000000000000000000000..26b5dbac47dd9a8ec1fcb6c93575cca750692735 --- /dev/null +++ b/browser/components/shell/nsUnixShellService.h @@ -0,0 +1,15 @@ +/* -*- 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/. */ + + +#ifndef nsunixshellservice_h____ +#define nsunixshellservice_h____ + +#include "nsIGNOMEShellService.h" + +NS_IMETHODIMP +nsUnixShellServiceConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult); + +#endif // nsunixshellservice_h____
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor