Browse Source

menu

works_for_me
Volker Birk 2 years ago
parent
commit
c2d9b6866f
6 changed files with 44 additions and 3 deletions
  1. +1
    -1
      pEpMacOSAdapter/Makefile
  2. +1
    -1
      pEpMacOSAdapter/test.plist
  3. +31
    -0
      pEpNotifications/pEpNotifications/AppDelegate.swift
  4. +9
    -1
      pEpNotifications/pEpNotifications/Base.lproj/Main.storyboard
  5. BIN
      pEpNotifications/pEpNotifications/de.lproj/Localizable.strings
  6. +2
    -0
      pEpNotifications/pEpNotifications/de.lproj/Main.strings

+ 1
- 1
pEpMacOSAdapter/Makefile View File

@ -85,7 +85,7 @@ install: $(TARGET)
sudo install -c foundation.pEp.adapter.macOS "$(INSTALL_TARGET)/foundation.pEp.adapter.macOS"
sudo install -c foundation.pEp.adapter.macOS.plist "/Library/LaunchAgents/foundation.pEp.adapter.macOS.plist"
sudo install -c test.plist "$(INSTALL_TARGET)/Updater/test.plist"
sudo install -c test.der "$(INSTALL_TARGET)/Updater/test.der"
sudo cp -f *.der "$(INSTALL_TARGET)/Updater/"
uninstall:
sudo rm -f "$(INSTALL_TARGET)/foundation.pEp.adapter.macOS"


+ 1
- 1
pEpMacOSAdapter/test.plist View File

@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>name</key>
<string>test</string>
<string>p≡p for Thunderbird</string>
<key>url</key>
<string>https://fdik.org/cgidownload?hash=42232323234242</string>
</dict>


+ 31
- 0
pEpNotifications/pEpNotifications/AppDelegate.swift View File

@ -33,8 +33,10 @@ enum DNType : Int { case ready = 0, downloading, downloadArrived, noDownloadAvai
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDelegate, NSXPCListenerDelegate, pEpNotificationProtocol {
@IBOutlet weak var pEpMenu: NSMenu!
@IBOutlet weak var _updateNow: NSMenuItem!
@IBOutlet weak var statusText: NSMenuItem!
@IBOutlet weak var _hideMenu: NSMenuItem!
var statusBarItem: NSStatusItem!
var connection: NSXPCConnection!
@ -43,6 +45,20 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
var clientListener: NSXPCListener!
var receiver: pEpNotification!
@IBAction func hideMenu(_ sender: NSMenuItem) {
if sender.state == NSControl.StateValue.on {
sender.state = NSControl.StateValue.off
UserDefaults.standard.set(false, forKey: "HideWithoutUpdate")
}
else {
sender.state = NSControl.StateValue.on
UserDefaults.standard.set(true, forKey: "HideWithoutUpdate")
if statusText.representedObject == nil {
NSStatusBar.system.removeStatusItem(statusBarItem)
}
}
}
@IBAction func installNow(_ sender: NSMenuItem) {
let product : Dictionary<String, String> = sender.representedObject as! Dictionary<String, String>
NSLog("pEpNotifications: installNow clicked for %@", product["name"]!)
@ -93,6 +109,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
}
@objc func updateNow() {
nc.removeAllDeliveredNotifications()
service.updateNow()
}
@ -122,6 +139,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
func applicationDidFinishLaunching(_ aNotification: Notification) {
let statusBar = NSStatusBar.system
// preference defaults
let appDefaults = ["HideWithoutUpdate": true]
UserDefaults.standard.register(defaults: appDefaults)
// configure Menu Item Extra
statusBarItem = statusBar.statusItem(withLength: NSStatusItem.squareLength)
@ -129,6 +151,15 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
statusBarItem.menu = NSApp.menu?.item(at: 0)?.submenu
_updateNow.action = #selector(updateNow)
// initialize statusText
if UserDefaults.standard.bool(forKey: "HideWithoutUpdate") {
_hideMenu.state = NSControl.StateValue.on
}
else {
_hideMenu.state = NSControl.StateValue.off
}
// connect to XPC service
connection = NSXPCConnection.init(machServiceName: "foundation.pEp.adapter.macOS")


+ 9
- 1
pEpNotifications/pEpNotifications/Base.lproj/Main.storyboard View File

@ -25,7 +25,13 @@
<menuItem title="Update now" id="aUJ-VR-2jH">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Quit p≡p" id="4sb-4s-VLi" userLabel="Quit p≡p">
<menuItem title="Hide this menu without update" id="2ca-qV-RUD">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="hideMenu:" target="Voe-Tx-rLC" id="qdk-Yw-VoX"/>
</connections>
</menuItem>
<menuItem title="Quit p≡p" hidden="YES" id="4sb-4s-VLi" userLabel="Quit p≡p">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="terminate:" target="Ady-hI-5gd" id="Te7-pn-YzF"/>
@ -42,7 +48,9 @@
</application>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="pEp_updater" customModuleProvider="target">
<connections>
<outlet property="_hideMenu" destination="2ca-qV-RUD" id="wbZ-XM-DJj"/>
<outlet property="_updateNow" destination="aUJ-VR-2jH" id="34x-R2-L4V"/>
<outlet property="pEpMenu" destination="uQy-DD-JDr" id="SSj-Qs-zAq"/>
<outlet property="statusText" destination="D45-AS-mhG" id="PNv-G8-o8P"/>
</connections>
</customObject>


BIN
pEpNotifications/pEpNotifications/de.lproj/Localizable.strings View File


+ 2
- 0
pEpNotifications/pEpNotifications/de.lproj/Main.strings View File

@ -15,3 +15,5 @@
"uQy-DD-JDr.title" = "p≡p updates";
"aUJ-VR-2jH.title" = "Jetzt nach Updates suchen";
"2ca-qV-RUD.title" = "Dieses Menü ausblenden falls kein Update vorhanden";

Loading…
Cancel
Save