summarylogtreecommitdiffstats
path: root/firefox-kde.patch
blob: e1521ef3aff13ded3db8c8c3b308ddc643dbd929 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# HG changeset patch
# User msirringhaus@suse.de
# Date 1559300151 -7200
#      Fri May 31 12:55:51 2019 +0200
# Node ID 54d41b0033b8d649d842a1f862c6fed8b9874dec
# Parent  23d64c5753fda6f201477fe1f2f6cf1fb1657ccc
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

diff --git a/browser/components/preferences/main.js b/browser/components/preferences/main.js
--- a/browser/components/preferences/main.js
+++ b/browser/components/preferences/main.js
@@ -353,16 +353,23 @@ var gMainPane = {
         }, backoffTimes[this._backoffIndex + 1 < backoffTimes.length ? this._backoffIndex++ : backoffTimes.length - 1]);
       };
 
       window.setTimeout(() => {
         window.requestIdleCallback(pollForDefaultBrowser);
       }, 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();
 
     let performanceSettingsLink = document.getElementById(
       "performanceSettingsLearnMore"
     );
     let performanceSettingsUrl =
       Services.urlFormatter.formatURLPref("app.support.baseURL") +
@@ -1365,16 +1372,27 @@ var gMainPane = {
       this._backoffIndex = 0;
 
       let shellSvc = getShellService();
       if (!shellSvc) {
         return;
       }
       try {
         shellSvc.setDefaultBrowser(true, 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) {
         Cu.reportError(ex);
         return;
       }
 
       let isDefault = shellSvc.isDefaultBrowser(false, true);
       let setDefaultPane = document.getElementById("setDefaultPane");
       setDefaultPane.classList.toggle("is-default", isDefault);
diff --git a/browser/components/shell/moz.build b/browser/components/shell/moz.build
--- a/browser/components/shell/moz.build
+++ b/browser/components/shell/moz.build
@@ -31,16 +31,18 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "coco
     ]
 elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
     XPIDL_SOURCES += [
         "nsIGNOMEShellService.idl",
     ]
 
     SOURCES += [
         "nsGNOMEShellService.cpp",
+        "nsKDEShellService.cpp",
+        "nsUnixShellService.cpp",
     ]
     if CONFIG["MOZ_ENABLE_DBUS"]:
         SOURCES += [
             "nsGNOMEShellDBusHelper.cpp",
             "nsGNOMEShellSearchProvider.cpp",
         ]
         include("/ipc/chromium/chromium-config.mozbuild")
 
diff --git a/browser/components/shell/nsKDEShellService.cpp b/browser/components/shell/nsKDEShellService.cpp
new file mode 100644
--- /dev/null
+++ b/browser/components/shell/nsKDEShellService.cpp
@@ -0,0 +1,109 @@
+/* -*- 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 aClaimAllTypes,
+                                     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( aClaimAllTypes ? "ALLTYPES"_ns : "NORMAL"_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
--- /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
--- /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(nsISupports *aOuter, REFNSIID aIID, void **aResult)
+{
+    if( nsKDEUtils::kdeSupport())
+        return nsKDEShellServiceConstructor( aOuter, aIID, aResult );
+    return nsGNOMEShellServiceConstructor( aOuter, aIID, aResult );
+}
diff --git a/browser/components/shell/nsUnixShellService.h b/browser/components/shell/nsUnixShellService.h
new file mode 100644
--- /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____