Class: NSWorkspace

Inherits:
Object show all
Defined in:
ext/accessibility/extras/extras.c,
ext/accessibility/extras/extras.c

Overview

A subset of Cocoa's NSWorkspace class.

See Apple's Developer Reference for documentation on the methods available in this class.

Class Method Summary collapse

Class Method Details

.frontmostApplicationObject



271
272
273
274
275
276
# File 'ext/accessibility/extras/extras.c', line 271

static
VALUE
rb_workspace_frontmost_app(VALUE self)
{
  return wrap_app([[NSWorkspace sharedWorkspace] frontmostApplication]);
}

.launchAppWithBundleIdentifier(bundle_id, opts) ⇒ Object

TODO:

One thing we want to look into is using Launch Services instead of NSWorkspace for app launching. The reason is that we will avoid the problem launching new apps that have not been registered yet. But the big thing is that we can get the PSN for the application, which will allow for more directed input using CGEvents and it also gives us a data structure to wait on that indicates when the app has properly started up.

The additonalEventParamDescriptor option is not supported by the bridge rigt now



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'ext/accessibility/extras/extras.c', line 305

static
VALUE
rb_workspace_launch(VALUE self, VALUE bundle_id, VALUE opts)
{
  NSString*             identifier = unwrap_nsstring(bundle_id);
  NSWorkspaceLaunchOptions options = NUM2INT(rb_hash_lookup(opts, key_opts));

  BOOL result = [[NSWorkspace sharedWorkspace]
	        	 launchAppWithBundleIdentifier:identifier
        		                       options:options
        		additionalEventParamDescriptor:nil
                                      launchIdentifier:nil];

  [identifier release];
  return result ? Qtrue : Qfalse;
}


278
279
280
281
282
283
# File 'ext/accessibility/extras/extras.c', line 278

static
VALUE
rb_workspace_menu_bar_owner(VALUE self)
{
  return wrap_app([[NSWorkspace sharedWorkspace] menuBarOwningApplication]);
}

.runningApplicationsObject



258
259
260
261
262
263
264
265
266
267
268
269
# File 'ext/accessibility/extras/extras.c', line 258

static
VALUE
rb_workspace_running_apps(VALUE self)
{
  NSArray* apps = [[NSWorkspace sharedWorkspace] runningApplications];
  VALUE rb_apps = wrap_array_apps(apps);
  [apps enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
      [obj retain];
    }];
  [apps release];
  return rb_apps;
}

.sharedWorkspaceObject



250
251
252
253
254
255
# File 'ext/accessibility/extras/extras.c', line 250

static
VALUE
rb_workspace_shared(VALUE self)
{
  return self;
}

.showSearchResultsForQueryString(query) ⇒ Object



285
286
287
288
289
290
291
292
# File 'ext/accessibility/extras/extras.c', line 285

static
VALUE
rb_workspace_find(VALUE self, VALUE query)
{
  BOOL result =
    [[NSWorkspace sharedWorkspace] showSearchResultsForQueryString:unwrap_nsstring(query)];
  return (result ? Qtrue : Qfalse);
}