Beispiel #1
0
def get_bundle_identifier_for_path(path):
    """
    Get bundle identifier for the given path.
    """
    bundle_url = 'file://' + os.path.abspath(path)
    return NSBundle.bundleWithURL_(
        NSURL.URLWithString_(bundle_url)).bundleIdentifier()
Beispiel #2
0
 def openUrl(self, url, background=False):
     ws = NSWorkspace.sharedWorkspace()
     option = NSWorkspaceLaunchDefault
     if background:
         option = NSWorkspaceLaunchWithoutActivation
     ws.openURL_options_configuration_error_(NSURL.URLWithString_(url),
                                             option, dict(), None)
Beispiel #3
0
 def goto(self, url, show=True):
     if self._webkit is None:
         raise RuntimeError("needs to be a web window")
     url = NSURL.URLWithString_(url).retain()
     request = NSURLRequest.requestWithURL_(url)
     self._webkit.mainFrame().loadRequest_(request)
     self.show()
Beispiel #4
0
 def sethtml(self, html, url, show=True):
     if self._webkit is None:
         raise RuntimeError("needs to be the web window")
     url = NSURL.URLWithString_(url).retain()
     if isinstance(html, str):
         html = html.decode("utf-8")
     self._webkit.mainFrame().loadHTMLString_baseURL_(html, url)
     self.show()
Beispiel #5
0
 def upload(self, app):
     if app == 'local':
         pass
     else:
         url = CREATE_URL[app] + urlencode(self.CONTENTS, quote_via=quote)
         ws = NSWorkspace.sharedWorkspace()
         ws.openURL_options_configuration_error_(
             NSURL.URLWithString_(url), NSWorkspaceLaunchWithoutActivation,
             None, None)
Beispiel #6
0
    def launchAppByBundlePath(bundlePath, arguments=[]):
        ''' launchAppByBundlePath - Launch app with a given bundle path
            Return True if succeed
        '''
        bundleUrl = NSURL.URLWithString_(bundlePath)
        workspace = AppKit.NSWorkspace.sharedWorkspace()
        arguments_strings = map(lambda a: NSString.stringWithString_(str(a)),
                                arguments)
        arguments = NSDictionary.dictionaryWithDictionary_({
            AppKit.NSWorkspaceLaunchConfigurationArguments:
            NSArray.arrayWithArray_(arguments_strings)
        })

        return workspace.launchApplicationAtURL_options_configuration_error_(
            bundleUrl, AppKit.NSWorkspaceLaunchAllowingClassicStartup,
            arguments, None)
Beispiel #7
0
def ensure_permissions() -> None:
    from ApplicationServices import AXIsProcessTrusted
    from AppKit import NSAlert, NSAlertFirstButtonReturn, NSWorkspace, NSURL
    accessibility_permissions = AXIsProcessTrusted()
    if not accessibility_permissions:
        title = "Missing accessibility permissions"
        info = "To let ActivityWatch capture window titles grant it accessibility permissions. \n If you've already given ActivityWatch accessibility permissions and are still seeing this dialog, try removing and re-adding them."

        alert = NSAlert.new()
        alert.setMessageText_(title)
        alert.setInformativeText_(info)

        ok_button = alert.addButtonWithTitle_("Open accessibility settings")

        alert.addButtonWithTitle_("Close")
        choice = alert.runModal()
        print(choice)
        if choice == NSAlertFirstButtonReturn:
            NSWorkspace.sharedWorkspace().openURL_(
                NSURL.URLWithString_(
                    "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"
                ))
Beispiel #8
0
def open_URL(url):
    """Open the url with launchservices."""
    URL = NSURL.URLWithString_(url)
    LSOpenCFURLRef(URL, None)
Beispiel #9
0
 def helpButtonPressed_(self, sender):
     # open help url
     NSWorkspace.sharedWorkspace().openURL_(NSURL.URLWithString_("Attribution"))
Beispiel #10
0
 def donateButtonPressed_(self, sender):
     NSWorkspace.sharedWorkspace().openURL_(NSURL.URLWithString_("https://paypal.com"))
Beispiel #11
0
 def helpButtonPressed_(self, sender):
     # open help url
     NSWorkspace.sharedWorkspace().openURL_(
         NSURL.URLWithString_(
             "http://code.google.com/p/quotefixformac/wiki/CustomAttribution"
         ))
Beispiel #12
0
 def donateButtonPressed_(self, sender):
     NSWorkspace.sharedWorkspace().openURL_(
         NSURL.URLWithString_(
             "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4UF2KB2BTW6AC"
         ))
 def howToUseMyOwnDomain_(self, sender):
     NSWorkspace.sharedWorkspace().openURL_(NSURL.URLWithString_("http://myownsipdomain.sip2sip.info"))
 def set(self, url):
     if url is not None:
         url = NSURL.URLWithString_(url)
     self._nsObject.setURL_(url)