summaryrefslogtreecommitdiffstats
path: root/ui/macosx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:34:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:34:10 +0000
commite4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc (patch)
tree68cb5ef9081156392f1dd62a00c6ccc1451b93df /ui/macosx
parentInitial commit. (diff)
downloadwireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.tar.xz
wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.zip
Adding upstream version 4.2.2.upstream/4.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ui/macosx')
-rw-r--r--ui/macosx/cocoa_bridge.h26
-rw-r--r--ui/macosx/cocoa_bridge.mm35
-rw-r--r--ui/macosx/macos_compat.h36
-rw-r--r--ui/macosx/sparkle_bridge.h25
-rw-r--r--ui/macosx/sparkle_bridge.m55
5 files changed, 177 insertions, 0 deletions
diff --git a/ui/macosx/cocoa_bridge.h b/ui/macosx/cocoa_bridge.h
new file mode 100644
index 00000000..4665fc29
--- /dev/null
+++ b/ui/macosx/cocoa_bridge.h
@@ -0,0 +1,26 @@
+/** @file
+ *
+ * This code was taken directly from:
+ * https://forum.qt.io/topic/82609/remove-native-mac-menu-items-such-as-show-tab-bar
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef COCOABRIDGE_H
+#define COCOABRIDGE_H
+
+class CocoaBridge
+{
+
+ CocoaBridge() {}
+
+public:
+ static void cleanOSGeneratedMenuItems();
+
+};
+
+#endif // COCOABRIDGE_H
diff --git a/ui/macosx/cocoa_bridge.mm b/ui/macosx/cocoa_bridge.mm
new file mode 100644
index 00000000..909bf223
--- /dev/null
+++ b/ui/macosx/cocoa_bridge.mm
@@ -0,0 +1,35 @@
+/* cocoa_bridge.mm
+ *
+ * This code was taken directly from:
+ * https://forum.qt.io/topic/82609/remove-native-mac-menu-items-such-as-show-tab-bar
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <ui/macosx/cocoa_bridge.h>
+#include <ui/macosx/macos_compat.h>
+
+#import <Cocoa/Cocoa.h>
+
+void CocoaBridge::cleanOSGeneratedMenuItems()
+{
+#ifdef AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER
+ // Remove (don't allow) the "Show Tab Bar" menu item from the "View" menu, if
+ // supported
+
+ if ([NSWindow respondsToSelector:@selector(setAllowsAutomaticWindowTabbing:)])
+ [NSWindow setAllowsAutomaticWindowTabbing: NO];
+#endif
+
+ [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSFullScreenMenuItemEverywhere"];
+
+ // Remove (disable) the "Start Dictation..." and "Emoji & Symbols" menu items
+ // from the "Edit" menu
+
+ [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSDisabledDictationMenuItem"];
+ [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSDisabledCharacterPaletteMenuItem"];
+}
diff --git a/ui/macosx/macos_compat.h b/ui/macosx/macos_compat.h
new file mode 100644
index 00000000..f8b87696
--- /dev/null
+++ b/ui/macosx/macos_compat.h
@@ -0,0 +1,36 @@
+/** @file
+ *
+ * This code was taken directly from:
+ * https://forum.qt.io/topic/82609/remove-native-mac-menu-items-such-as-show-tab-bar
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef MACOS_COMPAT_H
+#define MACOS_COMPAT_H
+
+#import <Cocoa/Cocoa.h>
+
+#if !defined(MAC_OS_X_VERSION_10_9)
+# define MAC_OS_X_VERSION_10_9 1090
+#endif
+
+#if !defined(MAC_OS_X_VERSION_10_10)
+# define MAC_OS_X_VERSION_10_10 101000
+#endif
+
+#if !defined(MAC_OS_X_VERSION_10_12)
+# define MAC_OS_X_VERSION_10_12 101200
+#endif
+
+#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12)
+@interface NSWindow (macOS10_12_SDK)
++ (void)setAllowsAutomaticWindowTabbing:(BOOL)allow;
+@end
+#endif
+
+#endif // MACOS_COMPAT_H
diff --git a/ui/macosx/sparkle_bridge.h b/ui/macosx/sparkle_bridge.h
new file mode 100644
index 00000000..8ba7e4a8
--- /dev/null
+++ b/ui/macosx/sparkle_bridge.h
@@ -0,0 +1,25 @@
+/** @file
+ *
+ * C wrapper for the Sparkle API
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+// XXX We could alternatively do this via C++:
+// https://github.com/sparkle-project/Sparkle/issues/1137
+
+
+#ifndef SPARKLE_BRIDGE_H
+#define SPARKLE_BRIDGE_H
+
+#include <stdbool.h>
+
+void sparkle_software_update_init(const char *url, bool enabled, int interval);
+
+void sparkle_software_update_check(void);
+
+#endif // SPARKLE_BRIDGE_H
diff --git a/ui/macosx/sparkle_bridge.m b/ui/macosx/sparkle_bridge.m
new file mode 100644
index 00000000..7a6509ad
--- /dev/null
+++ b/ui/macosx/sparkle_bridge.m
@@ -0,0 +1,55 @@
+/* sparkle_bridge.m
+ *
+ * C wrapper for the Sparkle API
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <ui/macosx/sparkle_bridge.h>
+
+#import <Cocoa/Cocoa.h>
+
+#import <Sparkle.h>
+
+// https://sparkle-project.org/documentation/customization/
+// Sparkle stores its state in ~/Library/Preferences/org.wireshark.Wireshark.plist.
+// You can check its log output via `log stream | grep -i sparkle`.
+
+// The Sparkle 1 UI provided a sharedUpdater singleton, which is deprecated
+// in Sparkle 2:
+// https://sparkle-project.org/documentation/upgrading/
+// Create our own singleton which uses the updated API.
+// https://sparkle-project.org/documentation/programmatic-setup/
+
+@interface SparkleBridge : NSObject
++ (SPUStandardUpdaterController *)sharedStandardUpdaterController;
+@end
+
+@implementation SparkleBridge
+
++ (SPUStandardUpdaterController *)sharedStandardUpdaterController {
+ static SPUStandardUpdaterController *sharedStandardUpdaterController_ = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ sharedStandardUpdaterController_ = [[SPUStandardUpdaterController alloc] initWithUpdaterDelegate: nil userDriverDelegate: nil];
+ });
+ return sharedStandardUpdaterController_;
+}
+
+@end
+
+void sparkle_software_update_init(const char *url, bool enabled, int interval)
+{
+ [[[SparkleBridge sharedStandardUpdaterController] updater] setAutomaticallyChecksForUpdates: enabled];
+ [[[SparkleBridge sharedStandardUpdaterController] updater] setUpdateCheckInterval: interval];
+ [[[SparkleBridge sharedStandardUpdaterController] updater] setFeedURL: [NSURL URLWithString: [[NSString alloc] initWithUTF8String: url] ]];
+}
+
+void sparkle_software_update_check(void)
+{
+ [[SparkleBridge sharedStandardUpdaterController] checkForUpdates: [[NSApplication sharedApplication] delegate]];
+}