예제 #1
0
 def set_icon(self, file_name):
     try:
         from Cocoa import NSImage, NSWorkspace
         path = (sys._MEIPASS + "/icon.icns/icon.icns") if hasattr(
             sys, "_MEIPASS") else "icon.icns"
         img = NSImage.alloc().initWithContentsOfFile_(str(path))
         NSWorkspace.sharedWorkspace().setIcon_forFile_options_(
             img, str(file_name), 0)
     except ModuleNotFoundError:
         pass  #silent fail writing icon
예제 #2
0
    def __init__(self,
                 paths: list[str],
                 batch_size: int,
                 file_filter: Optional[Callable[[str], bool]],
                 include_mac_packages: bool = False) -> None:
        self.condition = Condition()
        self.paths = paths
        self.batches: list[list[str]] = []
        self.batch_size = batch_size
        self.done = False
        self.errored = False
        self.file_filter = file_filter
        self.batch_buffer_size = 5
        self._pending_batch: list[str] = []
        self._include_mac_packages = include_mac_packages

        if self._include_mac_packages:
            # pylint: disable=useless-suppression
            # pylint: disable=no-name-in-module, import-error
            # noinspection PyUnresolvedReferences
            from Cocoa import NSWorkspace
            self._shared_nsworkspace = NSWorkspace.sharedWorkspace()
            # pylint: enable=useless-suppression
        else:
            self._shared_nsworkspace = None
예제 #3
0
파일: desktop.py 프로젝트: unixorn/salt-osx
def _screenImageOptions(screen):
    '''
    Process an instance of NSScreen, returning its options as a hash
    '''
    workspace = NSWorkspace.sharedWorkspace()
    if screen == NSScreen.mainScreen():
        is_main = True
    else:
        is_main = False

    screen_options = workspace.desktopImageOptionsForScreen_(screen)
    scaling_factor = screen_options.objectForKey_(
        NSWorkspaceDesktopImageScalingKey)  # NSImageScaling : NSNumber
    allow_clipping = screen_options.objectForKey_(
        NSWorkspaceDesktopImageAllowClippingKey)  # NSNumber
    fill_color = screen_options.objectForKey_(
        NSWorkspaceDesktopImageFillColorKey)  # NSColor
    image_url = workspace.desktopImageURLForScreen_(
        screen).absoluteString()  # NSURL
    options_dict = {
        'main': is_main,
        'scaling_factor': scaling_factor,
        'image_url': image_url,
        'allow_clipping': allow_clipping
    }
    if fill_color:
        options_dict['fill_color'] = {
            'r': fill_color.redComponent(),
            'g': fill_color.greenComponent(),
            'b': fill_color.blueComponent()
        }

    return options_dict
예제 #4
0
def add_workspace_notifications(nsw_config):
    # See http://developer.apple.com/documentation/Cocoa/Conceptual/Workspace/Workspace.html
    notification_center = NSWorkspace.sharedWorkspace().notificationCenter()

    for event in nsw_config:
        event_config = nsw_config[event]

        if "class" in event_config:
            obj         = get_handler_object(event_config['class'])
            objc_method = "on%s:" % event
            py_method   = objc_method.replace(":", "_")
            if not hasattr(obj, py_method) or not callable(getattr(obj, py_method)):
                print  >> sys.stderr, \
                    "NSWorkspace Notification %s: handler class %s must define a %s method" % (event, event_config['class'], py_method)
                sys.exit(1)

            notification_center.addObserver_selector_name_object_(obj, objc_method, event, None)
        else:
            handler          = NotificationHandler.new()
            handler.name     = "NSWorkspace Notification %s" % event
            handler.callable = get_callable_for_event(event, event_config, context=handler.name)

            assert(callable(handler.onNotification_))

            notification_center.addObserver_selector_name_object_(handler, "onNotification:", event, None)
            WORKSPACE_HANDLERS[event] = handler
    log_list("Listening for these NSWorkspace notifications: %s", nsw_config.keys())
예제 #5
0
파일: crankd.py 프로젝트: ypcat/macdns
def add_workspace_notifications(nsw_config):
    # See http://developer.apple.com/documentation/Cocoa/Conceptual/Workspace/Workspace.html
    notification_center = NSWorkspace.sharedWorkspace().notificationCenter()

    for event in nsw_config:
        event_config = nsw_config[event]

        if "class" in event_config:
            obj         = get_handler_object(event_config['class'])
            objc_method = "on%s:" % event
            py_method   = objc_method.replace(":", "_")
            if not hasattr(obj, py_method) or not callable(getattr(obj, py_method)):
                print  >> sys.stderr, \
                    "NSWorkspace Notification %s: handler class %s must define a %s method" % (event, event_config['class'], py_method)
                sys.exit(1)

            notification_center.addObserver_selector_name_object_(obj, objc_method, event, None)
        else:
            handler          = NSNotificationHandler.new()
            handler.name     = "NSWorkspace Notification %s" % event
            handler.callable = get_callable_for_event(event, event_config, context=handler.name)

            assert(callable(handler.onNotification_))

            notification_center.addObserver_selector_name_object_(handler, "onNotification:", event, None)

    log_list("Listening for these NSWorkspace notifications: %s", nsw_config.keys())
예제 #6
0
def frontmost():
    '''
    Get the name of the frontmost application
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    app = workSpace.frontmostApplication()

    return app.localizedName()
예제 #7
0
파일: desktop.py 프로젝트: unixorn/salt-osx
def frontmost():
    '''
    Get the name of the frontmost application
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    app = workSpace.frontmostApplication()

    return app.localizedName()
예제 #8
0
def add_distributed_notification(event, event_config, dist_center):
    if "class" in event_config:
        obj = get_handler_object(event_config['class'])
        objc_method = "on%s:" % event
        py_method = objc_method.replace(":", "_")

        if not hasattr(obj, py_method) or not callable(getattr(obj,
                                                               py_method)):
            print >> sys.stderr, \
                "NSDistributedNotification %s: handler class %s must define a %s method" % (event, event_config['class'], py_method)
            sys.exit(1)

        dist_center.addObserver_selector_name_object_(obj, objc_method, event,
                                                      None)
    else:
        shouldrm = False
        process_event = {}
        if not event in DISTRIBUTED_IDS:
            DISTRIBUTED_IDS[event] = event_config
            handler = NSNotificationHandler.new()
            handler.name = "NSDistributed %s" % event

            if "process" in event_config:
                notification_center = NSWorkspace.sharedWorkspace(
                ).notificationCenter()
                process_event["process"] = event_config["process"]
                process_event["event"] = event
                process_event["event_config"] = event_config

                logging.info("Adding Process Monitor: %s" %
                             process_event["process"])

                if not event in RELAUNCH_IDS:
                    add_workspace_notification(
                        "NSWorkspaceDidLaunchApplicationNotification",
                        process_event, notification_center)
                    RELAUNCH_IDS[event] = process_event
                else:
                    shouldrm = True

            handler.callable = get_callable_for_event(event,
                                                      event_config,
                                                      context=handler.name)

            assert (callable(handler.onNotification_))

            event_name = event
            if event == '*':
                event_name = None

            if not shouldrm:
                dist_center.addObserver_selector_name_object_(
                    handler, "onNotification:", event_name, None)
            else:
                del DISTRIBUTED_IDS[event]
                dist_center.removeObserver_name_object_(
                    handler, "onNotification", event_name, None)
예제 #9
0
파일: crankd.py 프로젝트: blalor/pymacadmin
def add_workspace_notifications(nsw_config):
    # See http://developer.apple.com/documentation/Cocoa/Conceptual/Workspace/Workspace.html
    notification_center = NSWorkspace.sharedWorkspace().notificationCenter()
    
    for event in nsw_config:
        event_config = nsw_config[event]
        add_workspace_notification(event, event_config, notification_center)
    
    log_list("Listening for these NSWorkspace notifications: %s", nsw_config.keys())
예제 #10
0
def add_workspace_notifications(nsw_config):
    # See http://developer.apple.com/documentation/Cocoa/Conceptual/Workspace/Workspace.html
    notification_center = NSWorkspace.sharedWorkspace().notificationCenter()

    for event in nsw_config:
        event_config = nsw_config[event]
        add_workspace_notification(event, event_config, notification_center)

    log_list("Listening for these NSWorkspace notifications: %s",
             nsw_config.keys())
예제 #11
0
def search(query):
    '''
    Reveal the finder and search in Spotlight, with the given query.

    CLI Example::

        salt '*' finder.search 'Documents'
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    status = workSpace.showSearchResultsForQueryString_(query)
    return status
예제 #12
0
def add_workspace_notifications(notification_list):
    notification_center = NSWorkspace.sharedWorkspace().notificationCenter()

    for notification in notification_list:
        handler          = NSNotificationHandler.new()
        handler.name     = "NSWorkspace Notification %s" % notification
        handler.callable = get_callable_for_event(notification, context=handler.name)

        assert(callable(handler.onNotification_))

        notification_center.addObserver_selector_name_object_(handler, "onNotification:", notification, None)
예제 #13
0
파일: finder.py 프로젝트: mafrosis/salt-osx
def search(query):
    '''
    Reveal the finder and search in Spotlight, with the given query.

    CLI Example::

        salt '*' finder.search 'Documents'
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    status = workSpace.showSearchResultsForQueryString_(query)
    return status
예제 #14
0
def launch(application):
    '''
    Open an Application by name.
    This does not need to be the full path to the application, and does not need to have an .app extension.

    CLI Example::

        salt '*' desktop.launch 'TextEdit'
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    status = workSpace.launchApplication_(application)
    return status
예제 #15
0
파일: desktop.py 프로젝트: unixorn/salt-osx
def open_file(path):
    '''
    Open a file in the current users session (using the default application).
    This requires the full path to the file.

    CLI Example::

        salt '*' desktop.open_file '/Users/Shared'
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    status = workSpace.openFile_(path)
    return status
예제 #16
0
파일: desktop.py 프로젝트: unixorn/salt-osx
def launch(application):
    '''
    Open an Application by name.
    This does not need to be the full path to the application, and does not need to have an .app extension.

    CLI Example::

        salt '*' desktop.launch 'TextEdit'
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    status = workSpace.launchApplication_(application)
    return status
예제 #17
0
def open_file(path):
    '''
    Open a file in the current users session (using the default application).
    This requires the full path to the file.

    CLI Example::

        salt '*' desktop.open_file '/Users/Shared'
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    status = workSpace.openFile_(path)
    return status
예제 #18
0
파일: finder.py 프로젝트: mafrosis/salt-osx
def select(path, finder_path=""):
    '''
    Reveal the finder and select the file system object at the given path.
    If the second parameter is specified, a new finder window will be opened at that path.
    Otherwise, an existing finder window will be used.

    CLI Example::

        salt '*' finder.select '/Users/Shared' '/Users'
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    status = workSpace.selectFile_inFileViewerRootedAtPath_(path, finder_path)
    return status
예제 #19
0
def add_workspace_notifications(notification_list):
    notification_center = NSWorkspace.sharedWorkspace().notificationCenter()

    for notification in notification_list:
        handler = NSNotificationHandler.new()
        handler.name = "NSWorkspace Notification %s" % notification
        handler.callable = get_callable_for_event(notification,
                                                  context=handler.name)

        assert (callable(handler.onNotification_))

        notification_center.addObserver_selector_name_object_(
            handler, "onNotification:", notification, None)
예제 #20
0
def select(path, finder_path=""):
    '''
    Reveal the finder and select the file system object at the given path.
    If the second parameter is specified, a new finder window will be opened at that path.
    Otherwise, an existing finder window will be used.

    CLI Example::

        salt '*' finder.select '/Users/Shared' '/Users'
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    status = workSpace.selectFile_inFileViewerRootedAtPath_(path, finder_path)
    return status
예제 #21
0
def processes():
    '''
    Get a list of running processes in the user session

    TODO: optional get by bundle ID
    TODO: optional get hidden
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    appList = workSpace.runningApplications()

    names = [app.localizedName() for app in appList]

    names.sort()
    return names
예제 #22
0
class ApplicationDelegate(NSObject):
    def init(self):
        self = super(ApplicationDelegate, self).init()
        self.hotkeys = dict()
        self.key_hooks = list()
        self.register_hotkey('ctrl-alt- ', self.show_launcher)
        self.register_hotkey('fn-alt-q', self.quit)

        return self

    def applicationDidFinishLaunching_(self, _):
        NSLog("applicationDidFinishLaunching_")

        if not axapi.ax_enabled():
            NSLog("Accessibility Permissions not enabled")

            chili.ui.prompt(
                'Accessibility permissions are required for Chili to run.\n' +
                'The Security preferences will now open, Please go to "Privacy" pane and choose "Accessibility" on the left panel.\n'
                + 'Check the box next to Chili and run the app again.')
            chili.open('/System/Library/PreferencePanes/Security.prefPane')
            self.quit()

            return

        try:
            chili.load_user_settings()
        except Exception, e:
            self.alert_exception(e)

        # launcher window view controller
        self.ctrl = LauncherController.alloc().init()
        self.tap = EventTap(self.global_event, self.should_block_event)

        # regsiter for notifications on deactivated apps
        # this is useful for determining the app that was used
        # before the launcher window was popped up
        delegate = lambda notification: self.notification(notification)
        NSWorkspace.sharedWorkspace().notificationCenter() \
            .addObserverForName_object_queue_usingBlock_(
                'NSWorkspaceDidDeactivateApplicationNotification',
                None, None, delegate)

        chili.set_launcher(self.ctrl)

        n = NSUserNotification.alloc().init()
        n.setTitle_('Chili')
        n.setInformativeText_('Ready')
        NSUserNotificationCenter.defaultUserNotificationCenter() \
            .deliverNotification_(n)
예제 #23
0
파일: desktop.py 프로젝트: unixorn/salt-osx
def processes():
    '''
    Get a list of running processes in the user session

    TODO: optional get by bundle ID
    TODO: optional get hidden
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    appList = workSpace.runningApplications()

    names = [app.localizedName() for app in appList]

    names.sort()
    return names
예제 #24
0
파일: crankd.py 프로젝트: blalor/pymacadmin
def add_distributed_notification(event, event_config, dist_center):
    if "class" in event_config:
        obj         = get_handler_object(event_config['class'])
        objc_method = "on%s:" % event
        py_method   = objc_method.replace(":", "_")
        
        if not hasattr(obj, py_method) or not callable(getattr(obj, py_method)):
            print >> sys.stderr, \
                "NSDistributedNotification %s: handler class %s must define a %s method" % (event, event_config['class'], py_method)
            sys.exit(1)
            
        dist_center.addObserver_selector_name_object_(obj, objc_method, event, None)
    else:
        shouldrm = False
        process_event = {}
        if not event in DISTRIBUTED_IDS:
            DISTRIBUTED_IDS[event] = event_config
            handler = NSNotificationHandler.new()
            handler.name = "NSDistributed %s" % event
            
            if "process" in event_config:
                notification_center = NSWorkspace.sharedWorkspace().notificationCenter()
                process_event["process"] = event_config["process"]
                process_event["event"] = event
                process_event["event_config"] = event_config
                
                logging.info("Adding Process Monitor: %s" % process_event["process"])
                
                if not event in RELAUNCH_IDS:
                    add_workspace_notification("NSWorkspaceDidLaunchApplicationNotification", process_event, notification_center)
                    RELAUNCH_IDS[event] = process_event
                else:
                    shouldrm = True
            
            handler.callable = get_callable_for_event(event, event_config, context=handler.name)
            
            assert(callable(handler.onNotification_))
            
            event_name = event
            if event == '*':
                event_name = None
            
            if not shouldrm:
                dist_center.addObserver_selector_name_object_(handler, "onNotification:", event_name, None)
            else:
                del DISTRIBUTED_IDS[event]
                dist_center.removeObserver_name_object_(handler, "onNotification", event_name, None)
예제 #25
0
def add_workspace_notifications(nsw_config):
    # See http://developer.apple.com/documentation/Cocoa/Conceptual/Workspace/Workspace.html
    notification_center = NSWorkspace.sharedWorkspace().notificationCenter()

    class NotificationHandler(NSObject):
        """Simple object for handling NSNotification events"""
        def __init__(self):
            self.callable = compile(
                'raise NotImplementedError("No callable provided!")')

        def onNotification_(self, the_notification):
            if the_notification.userInfo:
                user_info = the_notification.userInfo()
            else:
                user_info = None
            self.callable(user_info=user_info)

    for event in nsw_config:
        event_config = nsw_config[event]

        if "class" in event_config:
            obj = get_handler_object(event_config['class'])
            objc_method = "on%s:" % event
            py_method = objc_method.replace(":", "_")
            if not hasattr(obj, py_method) or not callable(
                    getattr(obj, py_method)):
                print  >> sys.stderr, \
                    "NSWorkspace Notification %s: handler class %s must define a %s method" % (event, event_config['class'], py_method)
                sys.exit(1)

            notification_center.addObserver_selector_name_object_(
                obj, objc_method, event, None)
        else:
            handler = NotificationHandler.new()
            handler.name = "NSWorkspace Notification %s" % event
            handler.callable = get_callable_for_event(event,
                                                      event_config,
                                                      context=handler.name)

            assert (callable(handler.onNotification_))

            notification_center.addObserver_selector_name_object_(
                handler, "onNotification:", event, None)

    log_list("Listening for these NSWorkspace notifications: %s",
             nsw_config.keys())
예제 #26
0
파일: app.py 프로젝트: twangboy/salt-osx
def force_quit(appname, blocking=False):
    '''
    Force an application to quit aka `Force Quit`.
    Does not block until the application quits.

    :param application:
    :return:
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    applications = workSpace.runningApplications()

    for app in applications:
        if app.localizedName() == appname:
            acknowledged = app.forceTerminate()
            return acknowledged

    return None
예제 #27
0
def open_url(url):
    '''
    Open a URL in the current users session.
    This works with anything that command-k would accept, such as:
    afp, smb, vnc, http

    CLI Example::

        salt '*' desktop.open_url 'afp://server.local'
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    url = NSURL.URLWithString_(url)
    if url is None:
        log.error('Invalid URL given: %s' % url)
        return False

    status = workSpace.openURL_(url)
    return status
예제 #28
0
파일: desktop.py 프로젝트: unixorn/salt-osx
def open_url(url):
    '''
    Open a URL in the current users session.
    This works with anything that command-k would accept, such as:
    afp, smb, vnc, http

    CLI Example::

        salt '*' desktop.open_url 'afp://server.local'
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    url = NSURL.URLWithString_(url)
    if url is None:
        log.error('Invalid URL given: %s' % url)
        return False

    status = workSpace.openURL_(url)
    return status
예제 #29
0
파일: app.py 프로젝트: twangboy/salt-osx
def quit(appname, blocking=False):
    '''
    Ask an application to quit.
    Does not guarantee that the application will quit without user interaction.
    Does not block until the application quits.

    :param application:
    :return:
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    applications = workSpace.runningApplications()

    for app in applications:
        if app.localizedName() == appname:
            acknowledged = app.terminate()
            return acknowledged

    return None
예제 #30
0
파일: app.py 프로젝트: weswhet/salt-osx
def force_quit(appname, blocking=False):
    '''
    Force an application to quit aka `Force Quit`.
    Does not block until the application quits.

    CLI Example::

        salt '*' app.force_quit 'Safari'
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    applications = workSpace.runningApplications()

    for app in applications:
        if app.localizedName() == appname:
            acknowledged = app.forceTerminate()
            return acknowledged

    return None
예제 #31
0
def set_wallpaper(screen_index, path):
    '''
    Set desktop wallpaper for screen at index

    CLI Example:

    .. code-block:: bash

        salt '*' desktop.set_wallpaper 0 '/Library/Desktop Pictures/Solid Colors/Solid Aqua Graphite.png'
    '''
    workspace = NSWorkspace.sharedWorkspace()
    screens = NSScreen.screens()
    screen = screens[screen_index]
    file_url = NSURL.fileURLWithPath_isDirectory_(path, False)
    options = {}

    (status, error) = workspace.setDesktopImageURL_forScreen_options_error_(file_url, screen, options, None)
    return status
예제 #32
0
파일: desktop.py 프로젝트: unixorn/salt-osx
def set_wallpaper(screen_index, path):
    '''
    Set desktop wallpaper for screen at index

    CLI Example:

    .. code-block:: bash

        salt '*' desktop.set_wallpaper 0 '/Library/Desktop Pictures/Solid Colors/Solid Aqua Graphite.png'
    '''
    workspace = NSWorkspace.sharedWorkspace()
    screens = NSScreen.screens()
    screen = screens[screen_index]
    file_url = NSURL.fileURLWithPath_isDirectory_(path, False)
    options = {}

    (status, error) = workspace.setDesktopImageURL_forScreen_options_error_(
        file_url, screen, options, None)
    return status
예제 #33
0
파일: app.py 프로젝트: weswhet/salt-osx
def quit(appname, blocking=False):
    '''
    Ask an application to quit.
    Does not guarantee that the application will quit without user interaction.
    Does not block until the application quits.

    CLI Example::

        salt '*' app.quit 'Safari'
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    applications = workSpace.runningApplications()

    for app in applications:
        if app.localizedName() == appname:
            acknowledged = app.terminate()
            return acknowledged

    return None
예제 #34
0
def add_workspace_notifications(nsw_config):
    # See http://developer.apple.com/documentation/Cocoa/Conceptual/Workspace/Workspace.html
    notification_center = NSWorkspace.sharedWorkspace().notificationCenter()

    class NotificationHandler(NSObject):
        """Simple object for handling NSNotification events"""

        def __init__(self):
            self.callable = compile('raise NotImplementedError("No callable provided!")')

        def onNotification_(self, the_notification):
            if the_notification.userInfo:
                user_info = the_notification.userInfo()
            else:
                user_info = None
            self.callable(user_info=user_info)


    for event in nsw_config:
        event_config = nsw_config[event]

        if "class" in event_config:
            obj         = get_handler_object(event_config['class'])
            objc_method = "on%s:" % event
            py_method   = objc_method.replace(":", "_")
            if not hasattr(obj, py_method) or not callable(getattr(obj, py_method)):
                print  >> sys.stderr, \
                    "NSWorkspace Notification %s: handler class %s must define a %s method" % (event, event_config['class'], py_method)
                sys.exit(1)

            notification_center.addObserver_selector_name_object_(obj, objc_method, event, None)
        else:
            handler          = NotificationHandler.new()
            handler.name     = "NSWorkspace Notification %s" % event
            handler.callable = get_callable_for_event(event, event_config, context=handler.name)

            assert(callable(handler.onNotification_))

            notification_center.addObserver_selector_name_object_(handler, "onNotification:", event, None)

    log_list("Listening for these NSWorkspace notifications: %s", nsw_config.keys())
예제 #35
0
def _screenImageOptions(screen):
    '''
    Process an instance of NSScreen, returning its options as a hash
    '''
    workspace = NSWorkspace.sharedWorkspace()
    if screen == NSScreen.mainScreen():
        is_main = True
    else:
        is_main = False

    screen_options = workspace.desktopImageOptionsForScreen_(screen)
    scaling_factor = screen_options.objectForKey_(NSWorkspaceDesktopImageScalingKey)  # NSImageScaling : NSNumber
    allow_clipping = screen_options.objectForKey_(NSWorkspaceDesktopImageAllowClippingKey)  # NSNumber
    fill_color = screen_options.objectForKey_(NSWorkspaceDesktopImageFillColorKey)  # NSColor
    image_url = workspace.desktopImageURLForScreen_(screen).absoluteString()  # NSURL
    options_dict = {'main': is_main, 'scaling_factor': scaling_factor, 'image_url': image_url,
                    'allow_clipping': allow_clipping}
    if fill_color:
        options_dict['fill_color'] = {'r': fill_color.redComponent(), 'g': fill_color.greenComponent(),
                                      'b': fill_color.blueComponent()}

    return options_dict
예제 #36
0
 def open(self, path, line):
     from Cocoa import NSWorkspace
     NSWorkspace.sharedWorkspace().openFile_(path)
     return True
예제 #37
0
def labels():
    '''
    Get Finder labels (Not including user defined tags, they are identified by NSURLTagNamesKey)
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    return list(workSpace.fileLabels())
예제 #38
0
파일: __init__.py 프로젝트: bbonf/chili
def launch(app):
    workspace = NSWorkspace.sharedWorkspace()
    workspace.launchApplication_(app)
예제 #39
0
파일: __init__.py 프로젝트: bbonf/chili
def open(file):
    workspace = NSWorkspace.sharedWorkspace()
    workspace.openFile_(file)
예제 #40
0
        # Find the path to the just inserted volume
        path = aNotification.userInfo()["NSDevicePath"]

        for aFile in os.listdir(path):
            if readTheseFiles.match(aFile):
                # Found a readme file, try to open it using the Workspace API

                fullPath = os.path.join(path, aFile)
                success, app, _ = workspace.getInfoForFile_application_type_(fullPath)
                if not success:
                    NSLog("Failed to find application to open file %s", fullPath)
                    return
                workspace.openFile_withApplication_(fullPath, app)


# Create an instance of our notification handler, and ask the workspace
# notification center to tell us when a new volume is mounted.
workspace = NSWorkspace.sharedWorkspace()
notificationCenter = workspace.notificationCenter()
notificationHandler = NotificationHandler.new()
notificationCenter.addObserver_selector_name_object_(
    notificationHandler,
    "handleMountNotification:",
    NSWorkspaceDidMountNotification,
    None,
)

NSLog("Listening for mount notifications....")
AppHelper.runConsoleEventLoop()
예제 #41
0
파일: __init__.py 프로젝트: bbonf/chili
def open_with(file, app):
    workspace = NSWorkspace.sharedWorkspace()
    workspace.openFile_withApplication_(file, app)
예제 #42
0
파일: __init__.py 프로젝트: bbonf/chili
def open_url(url):
    workspace = NSWorkspace.sharedWorkspace()
    workspace.openURL_(NSURL.URLWithString_(url))
예제 #43
0
파일: finder.py 프로젝트: mafrosis/salt-osx
def labels():
    '''
    Get Finder labels (Not including user defined tags, they are identified by NSURLTagNamesKey)
    '''
    workSpace = NSWorkspace.sharedWorkspace()
    return list(workSpace.fileLabels())
예제 #44
0
파일: __init__.py 프로젝트: bbonf/chili
def open_with(file, app):
    workspace = NSWorkspace.sharedWorkspace()
    workspace.openFile_withApplication_(file, app)
예제 #45
0
 def GetForegroundWindow():
     return NSWorkspace.sharedWorkspace().frontmostApplication(
     ).processIdentifier()
예제 #46
0
파일: __init__.py 프로젝트: bbonf/chili
def open(file):
    workspace = NSWorkspace.sharedWorkspace()
    workspace.openFile_(file)
예제 #47
0
파일: __init__.py 프로젝트: bbonf/chili
def open_url(url):
    workspace = NSWorkspace.sharedWorkspace()
    workspace.openURL_(NSURL.URLWithString_(url))
예제 #48
0
	def open(self, path, line):
		from Cocoa import NSWorkspace
		NSWorkspace.sharedWorkspace().openFile_(path)
		return True
예제 #49
0
파일: __init__.py 프로젝트: bbonf/chili
def launch(app):
    workspace = NSWorkspace.sharedWorkspace()
    workspace.launchApplication_(app)