duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

cocoa_tools.h (1297B)


      1 // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
      2 // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
      3 
      4 #include <span>
      5 #include <string>
      6 #include <string_view>
      7 #include <optional>
      8 
      9 class Error;
     10 
     11 #ifdef __OBJC__
     12 #import <AppKit/AppKit.h>
     13 #import <Cocoa/Cocoa.h>
     14 
     15 namespace CocoaTools {
     16 NSString* StringViewToNSString(std::string_view str);
     17 
     18 /// Converts NSError to a human-readable string.
     19 std::string NSErrorToString(NSError* error);
     20 }
     21 
     22 #endif
     23 
     24 namespace CocoaTools {
     25 /// Add a handler to be run when macOS changes between dark and light themes
     26 void AddThemeChangeHandler(void* ctx, void(handler)(void* ctx));
     27 
     28 /// Remove a handler previously added using AddThemeChangeHandler with the given context
     29 void RemoveThemeChangeHandler(void* ctx);
     30 
     31 /// Moves a file from one location to another, using NSFileManager.
     32 bool MoveFile(const char* source, const char* destination, Error* error);
     33 
     34 /// Returns the bundle path.
     35 std::optional<std::string> GetBundlePath();
     36 
     37 /// Get the bundle path to the actual application without any translocation fun
     38 std::optional<std::string> GetNonTranslocatedBundlePath();
     39 
     40 /// Launch the given application once this one quits
     41 bool DelayedLaunch(std::string_view file, std::span<const std::string_view> args = {});
     42 } // namespace CocoaTools