Changeset 811d1cc for launchers


Ignore:
Timestamp:
May 2, 2019 10:41:25 PM (19 months ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
7aa68c0, b2b047b
Parents:
2af1f68
Message:

Mac OSX Launcher: Moving utils classes to common directory between sub-projects + Swift 4.2 update.

Location:
launchers/macosx
Files:
3 deleted
8 moved

Legend:

Unmodified
Added
Removed
  • launchers/macosx/CommonCode/Utils/Preferences.swift

    r2af1f68 r811d1cc  
    2626
    2727class Preferences  : NSObject {
     28 
     29  enum ShowAsMode {
     30    case bothIcon
     31    case menubarIcon
     32    case dockIcon
     33  }
     34 
    2835  private var prefObject: Dictionary<String,Any> = Dictionary<String,Any>()
    2936  private var prefDict = Dictionary<String,PreferenceRow>()
    3037  private var prefDefaultDict: Dictionary<String,Any> = Dictionary<String,Any>()
    3138 
     39  var notifyOnStatusChange: Bool {
     40    get { return UserDefaults.standard.bool(forKey: "notifyOnStatusChange") }
     41    set { UserDefaults.standard.set(newValue, forKey: "notifyOnStatusChange") }
     42  }
     43 
    3244  var count: Int = 0
    3345 
    3446  // Interface with a string setting in background
    35   var showAsIconMode: PreferencesViewController.ShowAsMode {
     47  var showAsIconMode: ShowAsMode {
    3648    get {
    3749      var mode = self["I2Pref_showAsIconMode"]
     
    4153      switch (mode as! String) {
    4254      case "bothIcon":
    43         return PreferencesViewController.ShowAsMode.bothIcon
     55        return ShowAsMode.bothIcon
    4456      case "dockIcon":
    45         return PreferencesViewController.ShowAsMode.dockIcon
     57        return ShowAsMode.dockIcon
    4658      case "menubarIcon":
    47         return PreferencesViewController.ShowAsMode.menubarIcon
     59        return ShowAsMode.menubarIcon
    4860      default:
    49         return PreferencesViewController.ShowAsMode.bothIcon
     61        return ShowAsMode.bothIcon
    5062      }
    5163    }
     
    8496 
    8597  func syncPref() {
    86     UserDefaults.standard.setPersistentDomain(self.prefObject, forName: APPDOMAIN)
     98    UserDefaults.standard.setPersistentDomain(self.prefObject, forName: Identifiers.applicationDomainId)
    8799    UserDefaults.standard.synchronize()
    88100  }
     
    139151    preferences.count = preferences.prefDict.keys.count
    140152    UserDefaults.standard.register(defaults: defaults)
    141     UserDefaults.standard.setPersistentDomain(preferences.prefObject, forName: APPDOMAIN)
     153    UserDefaults.standard.setPersistentDomain(preferences.prefObject, forName: Identifiers.applicationDomainId)
    142154    UserDefaults.standard.synchronize()
    143155   
     
    167179  private override init() {
    168180    super.init()
    169     let fromDisk = UserDefaults.standard.persistentDomain(forName: APPDOMAIN) ?? Dictionary<String,Any>()
     181    let fromDisk = UserDefaults.standard.persistentDomain(forName: Identifiers.applicationDomainId) ?? Dictionary<String,Any>()
    170182    for (pKey, pVal) in fromDisk {
    171183      if (pKey.starts(with: "I2P")) {
  • launchers/macosx/CommonCode/Utils/ReflectionFunctions.swift

    r2af1f68 r811d1cc  
    2424    let sel = method_getName(m)
    2525    let nameCString = sel_getName(sel)
    26     return String(cString: nameCString!)
     26    return String(cString: nameCString)
    2727  }
    2828 
     
    3333    if methodList != nil && methodCount > 0 {
    3434      enumerateCArray(array: methodList!, count: methodCount) { i, m in
    35         let name = methodName(m: m!) ?? "unknown"
     35        let name = methodName(m: m) ?? "unknown"
    3636        print("#\(i): \(name)")
    3737      }
  • launchers/macosx/CommonCode/Utils/Startup.swift

    r2af1f68 r811d1cc  
    88
    99import Foundation
     10
    1011
    1112class Startup : NSObject {
     
    2223    }
    2324   
    24     var path : CFURL = CFURLCreateWithString(nil, Bundle.main.bundleURL.absoluteString as CFString, nil);
     25    let path : CFURL = CFURLCreateWithString(nil, Bundle.main.bundleURL.absoluteString as CFString, nil);
    2526    print("Path adding to Login Item list is: ", path);
    2627   
     
    5657  func getLoginItem(_ path : CFURL) -> LSSharedFileListItem! {
    5758   
    58     var path : CFURL = CFURLCreateWithString(nil, Bundle.main.bundleURL.absoluteString as CFString, nil);
     59    let path : CFURL = CFURLCreateWithString(nil, Bundle.main.bundleURL.absoluteString as CFString, nil);
    5960   
    6061   
     
    7071    {
    7172     
    72       var nextLoginItem : LSSharedFileListItem = loginItems.object(at: i) as! LSSharedFileListItem; // CFArrayGetValueAtIndex(loginItems, i).;
     73      let nextLoginItem : LSSharedFileListItem = loginItems.object(at: i) as! LSSharedFileListItem; // CFArrayGetValueAtIndex(loginItems, i).;
    7374     
    7475     
  • launchers/macosx/CommonCode/Utils/StringExtensions.swift

    r2af1f68 r811d1cc  
    7373}
    7474
     75/*
     76 * This is functions for comparing version numbers.
     77 * Example usage:
     78 *   "3.0.0" >= "3.0.0.1" // false
     79 *   "3.0.0" > "3.0.0.1" // false
     80 *   "3.0.0" <= "3.0.0.1" // true
     81 *   "3.0.0.1" >= "3.0.0.1" // true
     82 */
     83extension String {
     84 
     85  static func ==(lhs: String, rhs: String) -> Bool {
     86    return lhs.compare(rhs, options: .numeric) == .orderedSame
     87  }
     88 
     89  static func <(lhs: String, rhs: String) -> Bool {
     90    return lhs.compare(rhs, options: .numeric) == .orderedAscending
     91  }
     92 
     93  static func <=(lhs: String, rhs: String) -> Bool {
     94    return lhs.compare(rhs, options: .numeric) == .orderedAscending || lhs.compare(rhs, options: .numeric) == .orderedSame
     95  }
     96 
     97  static func >(lhs: String, rhs: String) -> Bool {
     98    return lhs.compare(rhs, options: .numeric) == .orderedDescending
     99  }
     100 
     101  static func >=(lhs: String, rhs: String) -> Bool {
     102    return lhs.compare(rhs, options: .numeric) == .orderedDescending || lhs.compare(rhs, options: .numeric) == .orderedSame
     103  }
     104 
     105}
     106
Note: See TracChangeset for help on using the changeset viewer.