Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/file_selector/file_selector_linux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.4

* Adds `getDirectoryPathWithOptions` and `getDirectoryPathsWithOptions` implementations.

## 0.9.3+3

* Updates to Pigeon 26.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
dependencies:
file_selector_linux:
path: ../
file_selector_platform_interface: ^2.6.0
file_selector_platform_interface: ^2.7.0
flutter:
sdk: flutter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class FileSelectorLinux extends FileSelectorPlatform {
currentFolderPath: options.initialDirectory,
currentName: options.suggestedName,
acceptButtonLabel: options.confirmButtonText,
createFolders: options.canCreateDirectories,
),
);
return paths.isEmpty ? null : FileSaveLocation(paths.first);
Expand All @@ -104,11 +105,22 @@ class FileSelectorLinux extends FileSelectorPlatform {
String? initialDirectory,
String? confirmButtonText,
}) async {
return getDirectoryPathWithOptions(
FileDialogOptions(
initialDirectory: initialDirectory,
confirmButtonText: confirmButtonText,
),
);
}

@override
Future<String?> getDirectoryPathWithOptions(FileDialogOptions options) async {
final List<String> paths = await _hostApi.showFileChooser(
PlatformFileChooserActionType.chooseDirectory,
PlatformFileChooserOptions(
currentFolderPath: initialDirectory,
acceptButtonLabel: confirmButtonText,
currentFolderPath: options.initialDirectory,
acceptButtonLabel: options.confirmButtonText,
createFolders: options.canCreateDirectories,
selectMultiple: false,
),
);
Expand All @@ -120,11 +132,24 @@ class FileSelectorLinux extends FileSelectorPlatform {
String? initialDirectory,
String? confirmButtonText,
}) async {
return getDirectoryPathsWithOptions(
FileDialogOptions(
initialDirectory: initialDirectory,
confirmButtonText: confirmButtonText,
),
);
}

@override
Future<List<String>> getDirectoryPathsWithOptions(
FileDialogOptions options,
) async {
return _hostApi.showFileChooser(
PlatformFileChooserActionType.chooseDirectory,
PlatformFileChooserOptions(
currentFolderPath: initialDirectory,
acceptButtonLabel: confirmButtonText,
currentFolderPath: options.initialDirectory,
acceptButtonLabel: options.confirmButtonText,
createFolders: options.canCreateDirectories,
selectMultiple: true,
),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v26.1.0), do not edit directly.
// Autogenerated from Pigeon (v26.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers

Expand Down Expand Up @@ -97,6 +97,7 @@ class PlatformFileChooserOptions {
this.currentName,
this.acceptButtonLabel,
this.selectMultiple,
this.createFolders,
});

List<PlatformTypeGroup>? allowedFileTypes;
Expand All @@ -112,13 +113,19 @@ class PlatformFileChooserOptions {
/// Nullable because it does not apply to the "save" action.
bool? selectMultiple;

/// Whether to allow new folder creation.
///
/// Nullable because it does not apply to the "open" action.
bool? createFolders;

List<Object?> _toList() {
return <Object?>[
allowedFileTypes,
currentFolderPath,
currentName,
acceptButtonLabel,
selectMultiple,
createFolders,
];
}

Expand All @@ -135,6 +142,7 @@ class PlatformFileChooserOptions {
currentName: result[2] as String?,
acceptButtonLabel: result[3] as String?,
selectMultiple: result[4] as bool?,
createFolders: result[5] as bool?,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ static GtkFileChooserNative* create_dialog(
}
}

const gboolean* create_folders =
ffs_platform_file_chooser_options_get_create_folders(options);
if (create_folders != nullptr) {
gtk_file_chooser_set_create_folders(GTK_FILE_CHOOSER(dialog),
*create_folders);
}

return GTK_FILE_CHOOSER_NATIVE(g_object_ref(dialog));
}

Expand Down
30 changes: 27 additions & 3 deletions packages/file_selector/file_selector_linux/linux/messages.g.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v26.1.0), do not edit directly.
// Autogenerated from Pigeon (v26.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#include "messages.g.h"
Expand Down Expand Up @@ -84,6 +84,7 @@ struct _FfsPlatformFileChooserOptions {
gchar* current_name;
gchar* accept_button_label;
gboolean* select_multiple;
gboolean* create_folders;
};

G_DEFINE_TYPE(FfsPlatformFileChooserOptions, ffs_platform_file_chooser_options,
Expand All @@ -97,6 +98,7 @@ static void ffs_platform_file_chooser_options_dispose(GObject* object) {
g_clear_pointer(&self->current_name, g_free);
g_clear_pointer(&self->accept_button_label, g_free);
g_clear_pointer(&self->select_multiple, g_free);
g_clear_pointer(&self->create_folders, g_free);
G_OBJECT_CLASS(ffs_platform_file_chooser_options_parent_class)
->dispose(object);
}
Expand All @@ -112,7 +114,7 @@ static void ffs_platform_file_chooser_options_class_init(
FfsPlatformFileChooserOptions* ffs_platform_file_chooser_options_new(
FlValue* allowed_file_types, const gchar* current_folder_path,
const gchar* current_name, const gchar* accept_button_label,
gboolean* select_multiple) {
gboolean* select_multiple, gboolean* create_folders) {
FfsPlatformFileChooserOptions* self = FFS_PLATFORM_FILE_CHOOSER_OPTIONS(
g_object_new(ffs_platform_file_chooser_options_get_type(), nullptr));
if (allowed_file_types != nullptr) {
Expand Down Expand Up @@ -141,6 +143,12 @@ FfsPlatformFileChooserOptions* ffs_platform_file_chooser_options_new(
} else {
self->select_multiple = nullptr;
}
if (create_folders != nullptr) {
self->create_folders = static_cast<gboolean*>(malloc(sizeof(gboolean)));
*self->create_folders = *create_folders;
} else {
self->create_folders = nullptr;
}
return self;
}

Expand Down Expand Up @@ -174,6 +182,12 @@ gboolean* ffs_platform_file_chooser_options_get_select_multiple(
return self->select_multiple;
}

gboolean* ffs_platform_file_chooser_options_get_create_folders(
FfsPlatformFileChooserOptions* self) {
g_return_val_if_fail(FFS_IS_PLATFORM_FILE_CHOOSER_OPTIONS(self), nullptr);
return self->create_folders;
}

static FlValue* ffs_platform_file_chooser_options_to_list(
FfsPlatformFileChooserOptions* self) {
FlValue* values = fl_value_new_list();
Expand All @@ -194,6 +208,9 @@ static FlValue* ffs_platform_file_chooser_options_to_list(
fl_value_append_take(values, self->select_multiple != nullptr
? fl_value_new_bool(*self->select_multiple)
: fl_value_new_null());
fl_value_append_take(values, self->create_folders != nullptr
? fl_value_new_bool(*self->create_folders)
: fl_value_new_null());
return values;
}

Expand Down Expand Up @@ -226,9 +243,16 @@ ffs_platform_file_chooser_options_new_from_list(FlValue* values) {
select_multiple_value = fl_value_get_bool(value4);
select_multiple = &select_multiple_value;
}
FlValue* value5 = fl_value_get_list_value(values, 5);
gboolean* create_folders = nullptr;
gboolean create_folders_value;
if (fl_value_get_type(value5) != FL_VALUE_TYPE_NULL) {
create_folders_value = fl_value_get_bool(value5);
create_folders = &create_folders_value;
}
return ffs_platform_file_chooser_options_new(
allowed_file_types, current_folder_path, current_name,
accept_button_label, select_multiple);
accept_button_label, select_multiple, create_folders);
}

struct _FfsMessageCodec {
Expand Down
18 changes: 16 additions & 2 deletions packages/file_selector/file_selector_linux/linux/messages.g.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v26.1.0), do not edit directly.
// Autogenerated from Pigeon (v26.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#ifndef PIGEON_MESSAGES_G_H_
Expand Down Expand Up @@ -97,6 +97,7 @@ G_DECLARE_FINAL_TYPE(FfsPlatformFileChooserOptions,
* current_name: field in this object.
* accept_button_label: field in this object.
* select_multiple: field in this object.
* create_folders: field in this object.
*
* Creates a new #PlatformFileChooserOptions object.
*
Expand All @@ -105,7 +106,7 @@ G_DECLARE_FINAL_TYPE(FfsPlatformFileChooserOptions,
FfsPlatformFileChooserOptions* ffs_platform_file_chooser_options_new(
FlValue* allowed_file_types, const gchar* current_folder_path,
const gchar* current_name, const gchar* accept_button_label,
gboolean* select_multiple);
gboolean* select_multiple, gboolean* create_folders);

/**
* ffs_platform_file_chooser_options_get_allowed_file_types
Expand Down Expand Up @@ -164,6 +165,19 @@ const gchar* ffs_platform_file_chooser_options_get_accept_button_label(
gboolean* ffs_platform_file_chooser_options_get_select_multiple(
FfsPlatformFileChooserOptions* object);

/**
* ffs_platform_file_chooser_options_get_create_folders
* @object: a #FfsPlatformFileChooserOptions.
*
* Whether to allow new folder creation.
*
* Nullable because it does not apply to the "open" action.
*
* Returns: the field value.
*/
gboolean* ffs_platform_file_chooser_options_get_create_folders(
FfsPlatformFileChooserOptions* object);

G_DECLARE_FINAL_TYPE(FfsMessageCodec, ffs_message_codec, FFS, MESSAGE_CODEC,
FlStandardMessageCodec)

Expand Down
Loading