Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
feat(windows_system): add Launcher APIs (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
halildurmus authored Jun 1, 2023
1 parent d20a87a commit 018299d
Show file tree
Hide file tree
Showing 22 changed files with 2,597 additions and 5 deletions.
7 changes: 4 additions & 3 deletions packages/windows_applicationmodel/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ platforms:

dependencies:
ffi: ^2.0.1
win32: ^5.0.0
windows_foundation: ^0.0.2
windows_system: ^0.0.3
win32: ^5.0.3
windows_foundation: ^0.0.6
windows_storage: ^0.0.2
windows_system: ^0.0.2

dev_dependencies:
test: ^1.24.1
13 changes: 13 additions & 0 deletions packages/windows_system/lib/src/exports.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,25 @@

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

export 'folderlauncheroptions.dart';
export 'ifolderlauncheroptions.dart';
export 'ilauncheroptions.dart';
export 'ilauncheroptions2.dart';
export 'ilauncheroptions3.dart';
export 'ilauncheroptions4.dart';
export 'ilauncheruioptions.dart';
export 'ilauncherviewoptions.dart';
export 'ilaunchuriresult.dart';
export 'iuser.dart';
export 'iuser2.dart';
export 'iuserwatcher.dart';
export 'knownuserproperties.dart';
export 'launcher.dart';
export 'launcheroptions.dart';
export 'launcheruioptions.dart';
export 'launchquerysupportstatus.dart';
export 'launchquerysupporttype.dart';
export 'launchuriresult.dart';
export 'launchuristatus.dart';
export 'power/batterystatus.dart';
export 'power/energysaverstatus.dart';
Expand Down
50 changes: 50 additions & 0 deletions packages/windows_system/lib/src/folderlauncheroptions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

// ignore_for_file: constant_identifier_names, non_constant_identifier_names
// ignore_for_file: unnecessary_import, unused_import

import 'dart:async';
import 'dart:ffi';

import 'package:ffi/ffi.dart';
import 'package:win32/win32.dart' hide DocumentProperties;
import 'package:windows_foundation/internal.dart';
import 'package:windows_foundation/windows_foundation.dart';
import 'package:windows_storage/windows_storage.dart';
import 'package:windows_ui/windows_ui.dart';

import 'ifolderlauncheroptions.dart';
import 'ilauncherviewoptions.dart';

/// Specifies the options to use when launching File Explorer to display the
/// contents of a specific folder by calling the
/// LaunchFolderAsync(IStorageFolder, FolderLauncherOptions) method.
///
/// {@category class}
class FolderLauncherOptions extends IInspectable
implements IFolderLauncherOptions, ILauncherViewOptions {
FolderLauncherOptions() : super(activateClass(_className));
FolderLauncherOptions.fromPtr(super.ptr);

static const _className = 'Windows.System.FolderLauncherOptions';

late final _iFolderLauncherOptions = IFolderLauncherOptions.from(this);

@override
IVector<IStorageItem> get itemsToSelect =>
_iFolderLauncherOptions.itemsToSelect;

late final _iLauncherViewOptions = ILauncherViewOptions.from(this);

@override
ViewSizePreference get desiredRemainingView =>
_iLauncherViewOptions.desiredRemainingView;

@override
set desiredRemainingView(ViewSizePreference value) =>
_iLauncherViewOptions.desiredRemainingView = value;
}
55 changes: 55 additions & 0 deletions packages/windows_system/lib/src/ifolderlauncheroptions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

// ignore_for_file: constant_identifier_names, non_constant_identifier_names
// ignore_for_file: unnecessary_import, unused_import

import 'dart:async';
import 'dart:ffi';

import 'package:ffi/ffi.dart';
import 'package:win32/win32.dart' hide DocumentProperties;
import 'package:windows_foundation/internal.dart';
import 'package:windows_foundation/windows_foundation.dart';
import 'package:windows_storage/windows_storage.dart';

/// @nodoc
const IID_IFolderLauncherOptions = '{bb91c27d-6b87-432a-bd04-776c6f5fb2ab}';

/// {@category interface}
class IFolderLauncherOptions extends IInspectable {
// vtable begins at 6, is 1 entries long.
IFolderLauncherOptions.fromPtr(super.ptr);

factory IFolderLauncherOptions.from(IInspectable interface) =>
IFolderLauncherOptions.fromPtr(
interface.toInterface(IID_IFolderLauncherOptions));

IVector<IStorageItem> get itemsToSelect {
final retValuePtr = calloc<COMObject>();

final hr = ptr.ref.vtable
.elementAt(6)
.cast<
Pointer<
NativeFunction<
HRESULT Function(VTablePointer lpVtbl,
Pointer<COMObject> retValuePtr)>>>()
.value
.asFunction<
int Function(VTablePointer lpVtbl,
Pointer<COMObject> retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr);

if (FAILED(hr)) {
free(retValuePtr);
throw WindowsException(hr);
}

return IVector.fromPtr(retValuePtr,
iterableIid: '{bb8b8418-65d1-544b-b083-6d172f568c73}',
creator: IStorageItem.fromPtr);
}
}
Loading

0 comments on commit 018299d

Please sign in to comment.