filedialog 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/gempush.yml +31 -0
- data/.gitignore +13 -0
- data/.gitmodules +3 -0
- data/.rubocop.yml +19 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +30 -0
- data/LICENSE +674 -0
- data/README.md +22 -0
- data/Rakefile +35 -0
- data/bin/console +25 -0
- data/deps/filedialogbuilddeps.rb +49 -0
- data/deps/nativefiledialog/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
- data/deps/nativefiledialog/.gitignore +181 -0
- data/deps/nativefiledialog/LICENSE +16 -0
- data/deps/nativefiledialog/README.md +180 -0
- data/deps/nativefiledialog/build/dont_run_premake.txt +1 -0
- data/deps/nativefiledialog/build/gmake_linux/Makefile +101 -0
- data/deps/nativefiledialog/build/gmake_linux/nfd.make +192 -0
- data/deps/nativefiledialog/build/gmake_linux/test_opendialog.make +188 -0
- data/deps/nativefiledialog/build/gmake_linux/test_opendialogmultiple.make +188 -0
- data/deps/nativefiledialog/build/gmake_linux/test_pickfolder.make +188 -0
- data/deps/nativefiledialog/build/gmake_linux/test_savedialog.make +188 -0
- data/deps/nativefiledialog/build/gmake_linux_zenity/Makefile +101 -0
- data/deps/nativefiledialog/build/gmake_linux_zenity/nfd.make +192 -0
- data/deps/nativefiledialog/build/gmake_linux_zenity/test_opendialog.make +188 -0
- data/deps/nativefiledialog/build/gmake_linux_zenity/test_opendialogmultiple.make +188 -0
- data/deps/nativefiledialog/build/gmake_linux_zenity/test_pickfolder.make +188 -0
- data/deps/nativefiledialog/build/gmake_linux_zenity/test_savedialog.make +188 -0
- data/deps/nativefiledialog/build/gmake_macosx/Makefile +85 -0
- data/deps/nativefiledialog/build/gmake_macosx/nfd.make +154 -0
- data/deps/nativefiledialog/build/gmake_macosx/test_opendialog.make +150 -0
- data/deps/nativefiledialog/build/gmake_macosx/test_opendialogmultiple.make +150 -0
- data/deps/nativefiledialog/build/gmake_macosx/test_pickfolder.make +150 -0
- data/deps/nativefiledialog/build/gmake_macosx/test_savedialog.make +150 -0
- data/deps/nativefiledialog/build/gmake_windows/Makefile +101 -0
- data/deps/nativefiledialog/build/gmake_windows/nfd.make +192 -0
- data/deps/nativefiledialog/build/gmake_windows/test_opendialog.make +188 -0
- data/deps/nativefiledialog/build/gmake_windows/test_opendialogmultiple.make +188 -0
- data/deps/nativefiledialog/build/gmake_windows/test_pickfolder.make +188 -0
- data/deps/nativefiledialog/build/gmake_windows/test_savedialog.make +188 -0
- data/deps/nativefiledialog/build/premake5.lua +265 -0
- data/deps/nativefiledialog/build/vs2010/NativeFileDialog.sln +78 -0
- data/deps/nativefiledialog/build/vs2010/nfd.vcxproj +168 -0
- data/deps/nativefiledialog/build/vs2010/nfd.vcxproj.filters +20 -0
- data/deps/nativefiledialog/build/vs2010/test_opendialog.vcxproj +182 -0
- data/deps/nativefiledialog/build/vs2010/test_opendialogmultiple.vcxproj +182 -0
- data/deps/nativefiledialog/build/vs2010/test_pickfolder.vcxproj +182 -0
- data/deps/nativefiledialog/build/vs2010/test_savedialog.vcxproj +182 -0
- data/deps/nativefiledialog/build/xcode4/NativeFileDialog.xcworkspace/contents.xcworkspacedata +19 -0
- data/deps/nativefiledialog/build/xcode4/nfd.xcodeproj/project.pbxproj +228 -0
- data/deps/nativefiledialog/build/xcode4/test_opendialog.xcodeproj/project.pbxproj +294 -0
- data/deps/nativefiledialog/build/xcode4/test_opendialogmultiple.xcodeproj/project.pbxproj +294 -0
- data/deps/nativefiledialog/build/xcode4/test_pickfolder.xcodeproj/project.pbxproj +294 -0
- data/deps/nativefiledialog/build/xcode4/test_savedialog.xcodeproj/project.pbxproj +294 -0
- data/deps/nativefiledialog/docs/build.md +39 -0
- data/deps/nativefiledialog/docs/contributing.md +25 -0
- data/deps/nativefiledialog/screens/open_cocoa.png +0 -0
- data/deps/nativefiledialog/screens/open_gtk3.png +0 -0
- data/deps/nativefiledialog/screens/open_win.png +0 -0
- data/deps/nativefiledialog/src/common.h +21 -0
- data/deps/nativefiledialog/src/include/nfd.h +74 -0
- data/deps/nativefiledialog/src/nfd_cocoa.m +286 -0
- data/deps/nativefiledialog/src/nfd_common.c +142 -0
- data/deps/nativefiledialog/src/nfd_common.h +39 -0
- data/deps/nativefiledialog/src/nfd_gtk.c +379 -0
- data/deps/nativefiledialog/src/nfd_win.cpp +762 -0
- data/deps/nativefiledialog/src/nfd_zenity.c +307 -0
- data/deps/nativefiledialog/src/simple_exec.h +218 -0
- data/deps/nativefiledialog/test/test_opendialog.c +29 -0
- data/deps/nativefiledialog/test/test_opendialogmultiple.c +32 -0
- data/deps/nativefiledialog/test/test_pickfolder.c +29 -0
- data/deps/nativefiledialog/test/test_savedialog.c +28 -0
- data/ext/filedialog/extconf.rb +58 -0
- data/ext/filedialog/filedialog.c +118 -0
- data/filedialog.gemspec +48 -0
- data/lib/filedialog.rb +50 -0
- data/lib/filedialog/version.rb +5 -0
- metadata +137 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#include "nfd.h"
|
|
2
|
+
|
|
3
|
+
#include <stdio.h>
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/* this test should compile on all supported platforms */
|
|
8
|
+
|
|
9
|
+
int main( void )
|
|
10
|
+
{
|
|
11
|
+
nfdchar_t *outPath = NULL;
|
|
12
|
+
nfdresult_t result = NFD_OpenDialog( "png,jpg;pdf", NULL, &outPath );
|
|
13
|
+
if ( result == NFD_OKAY )
|
|
14
|
+
{
|
|
15
|
+
puts("Success!");
|
|
16
|
+
puts(outPath);
|
|
17
|
+
free(outPath);
|
|
18
|
+
}
|
|
19
|
+
else if ( result == NFD_CANCEL )
|
|
20
|
+
{
|
|
21
|
+
puts("User pressed cancel.");
|
|
22
|
+
}
|
|
23
|
+
else
|
|
24
|
+
{
|
|
25
|
+
printf("Error: %s\n", NFD_GetError() );
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#include "nfd.h"
|
|
2
|
+
|
|
3
|
+
#include <stdio.h>
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
|
|
6
|
+
/* this test should compile on all supported platforms */
|
|
7
|
+
|
|
8
|
+
int main( void )
|
|
9
|
+
{
|
|
10
|
+
nfdpathset_t pathSet;
|
|
11
|
+
nfdresult_t result = NFD_OpenDialogMultiple( "png,jpg;pdf", NULL, &pathSet );
|
|
12
|
+
if ( result == NFD_OKAY )
|
|
13
|
+
{
|
|
14
|
+
size_t i;
|
|
15
|
+
for ( i = 0; i < NFD_PathSet_GetCount(&pathSet); ++i )
|
|
16
|
+
{
|
|
17
|
+
nfdchar_t *path = NFD_PathSet_GetPath(&pathSet, i);
|
|
18
|
+
printf("Path %i: %s\n", (int)i, path );
|
|
19
|
+
}
|
|
20
|
+
NFD_PathSet_Free(&pathSet);
|
|
21
|
+
}
|
|
22
|
+
else if ( result == NFD_CANCEL )
|
|
23
|
+
{
|
|
24
|
+
puts("User pressed cancel.");
|
|
25
|
+
}
|
|
26
|
+
else
|
|
27
|
+
{
|
|
28
|
+
printf("Error: %s\n", NFD_GetError() );
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#include "nfd.h"
|
|
2
|
+
|
|
3
|
+
#include <stdio.h>
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/* this test should compile on all supported platforms */
|
|
8
|
+
|
|
9
|
+
int main( void )
|
|
10
|
+
{
|
|
11
|
+
nfdchar_t *outPath = NULL;
|
|
12
|
+
nfdresult_t result = NFD_PickFolder( NULL, &outPath );
|
|
13
|
+
if ( result == NFD_OKAY )
|
|
14
|
+
{
|
|
15
|
+
puts("Success!");
|
|
16
|
+
puts(outPath);
|
|
17
|
+
free(outPath);
|
|
18
|
+
}
|
|
19
|
+
else if ( result == NFD_CANCEL )
|
|
20
|
+
{
|
|
21
|
+
puts("User pressed cancel.");
|
|
22
|
+
}
|
|
23
|
+
else
|
|
24
|
+
{
|
|
25
|
+
printf("Error: %s\n", NFD_GetError() );
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#include "nfd.h"
|
|
2
|
+
|
|
3
|
+
#include <stdio.h>
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
|
|
6
|
+
/* this test should compile on all supported platforms */
|
|
7
|
+
|
|
8
|
+
int main( void )
|
|
9
|
+
{
|
|
10
|
+
nfdchar_t *savePath = NULL;
|
|
11
|
+
nfdresult_t result = NFD_SaveDialog( "png,jpg;pdf", NULL, &savePath );
|
|
12
|
+
if ( result == NFD_OKAY )
|
|
13
|
+
{
|
|
14
|
+
puts("Success!");
|
|
15
|
+
puts(savePath);
|
|
16
|
+
free(savePath);
|
|
17
|
+
}
|
|
18
|
+
else if ( result == NFD_CANCEL )
|
|
19
|
+
{
|
|
20
|
+
puts("User pressed cancel.");
|
|
21
|
+
}
|
|
22
|
+
else
|
|
23
|
+
{
|
|
24
|
+
printf("Error: %s\n", NFD_GetError() );
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (C) 2020 Alex Gittemeier
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "mkmf"
|
|
19
|
+
require "os"
|
|
20
|
+
require_relative "../../deps/filedialogbuilddeps"
|
|
21
|
+
|
|
22
|
+
def add_cflags(str)
|
|
23
|
+
$CFLAGS += " " + str
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def add_include(str)
|
|
27
|
+
$CFLAGS += " -I" + str
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def add_libs(str)
|
|
31
|
+
$LOCAL_LIBS += " " + str
|
|
32
|
+
end
|
|
33
|
+
alias add_static_lib add_libs
|
|
34
|
+
|
|
35
|
+
def pkg_config(*args)
|
|
36
|
+
IO.popen(["pkg-config", *args], &read).chomp
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def add_pkg(package)
|
|
40
|
+
add_cflags(pkg_config(package, "--cflags"))
|
|
41
|
+
add_libs(pkg_config(package, "--libs"))
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
project_root = File.join(__dir__, "../..")
|
|
45
|
+
|
|
46
|
+
add_include(File.join(project_root,
|
|
47
|
+
"deps/nativefiledialog/src/include"))
|
|
48
|
+
add_static_lib(File.join(project_root,
|
|
49
|
+
"deps/nativefiledialog/build/lib/Release/x64/libnfd.a"))
|
|
50
|
+
|
|
51
|
+
if OS.linux?
|
|
52
|
+
add_pkg("gtk+-3.0")
|
|
53
|
+
elsif OS.mac?
|
|
54
|
+
add_libs("-framework AppKit")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
FileDialog::BuildDeps::compile_deps
|
|
58
|
+
create_makefile "filedialog/filedialog"
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Copyright (C) 2020 Alex Gittemeier
|
|
2
|
+
//
|
|
3
|
+
// This program is free software: you can redistribute it and/or modify
|
|
4
|
+
// it under the terms of the GNU General Public License as published by
|
|
5
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
// (at your option) any later version.
|
|
7
|
+
//
|
|
8
|
+
// This program is distributed in the hope that it will be useful,
|
|
9
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
// GNU General Public License for more details.
|
|
12
|
+
//
|
|
13
|
+
// You should have received a copy of the GNU General Public License
|
|
14
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
#include <ruby.h>
|
|
17
|
+
#include <nfd.h>
|
|
18
|
+
|
|
19
|
+
static VALUE eFileDialogError;
|
|
20
|
+
|
|
21
|
+
static VALUE FileDialog_s_open_dialog(
|
|
22
|
+
VALUE self, VALUE filter_list, VALUE default_path)
|
|
23
|
+
{
|
|
24
|
+
nfdresult_t rc;
|
|
25
|
+
nfdchar_t *strResult;
|
|
26
|
+
VALUE result;
|
|
27
|
+
|
|
28
|
+
Check_Type(filter_list, T_STRING);
|
|
29
|
+
Check_Type(default_path, T_STRING);
|
|
30
|
+
|
|
31
|
+
rc = NFD_OpenDialog(StringValueCStr(filter_list), StringValueCStr(default_path), &strResult);
|
|
32
|
+
if (rc == NFD_ERROR)
|
|
33
|
+
rb_raise(eFileDialogError, "%s", NFD_GetError());
|
|
34
|
+
else if (rc == NFD_CANCEL)
|
|
35
|
+
return Qnil;
|
|
36
|
+
|
|
37
|
+
result = rb_str_new_cstr(strResult);
|
|
38
|
+
free(strResult);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static VALUE FileDialog_s_open_dialog_multi(
|
|
43
|
+
VALUE self, VALUE filter_list, VALUE default_path)
|
|
44
|
+
{
|
|
45
|
+
nfdresult_t rc;
|
|
46
|
+
nfdpathset_t pathset;
|
|
47
|
+
size_t pathsetCount;
|
|
48
|
+
VALUE result;
|
|
49
|
+
|
|
50
|
+
Check_Type(filter_list, T_STRING);
|
|
51
|
+
Check_Type(default_path, T_STRING);
|
|
52
|
+
|
|
53
|
+
rc = NFD_OpenDialogMultiple(StringValueCStr(filter_list), StringValueCStr(default_path), &pathset);
|
|
54
|
+
if (rc == NFD_ERROR)
|
|
55
|
+
rb_raise(eFileDialogError, "%s", NFD_GetError());
|
|
56
|
+
else if (rc == NFD_CANCEL)
|
|
57
|
+
return Qnil;
|
|
58
|
+
|
|
59
|
+
pathsetCount = NFD_PathSet_GetCount(&pathset);
|
|
60
|
+
result = rb_ary_new_capa(pathsetCount);
|
|
61
|
+
|
|
62
|
+
for (int i = 0; i < pathsetCount; i++)
|
|
63
|
+
rb_ary_push(result, rb_str_new_cstr(NFD_PathSet_GetPath(&pathset, i)));
|
|
64
|
+
|
|
65
|
+
NFD_PathSet_Free(&pathset);
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static VALUE FileDialog_s_save_dialog(
|
|
70
|
+
VALUE self, VALUE filter_list, VALUE default_path)
|
|
71
|
+
{
|
|
72
|
+
nfdresult_t rc;
|
|
73
|
+
nfdchar_t *strResult;
|
|
74
|
+
VALUE result;
|
|
75
|
+
|
|
76
|
+
Check_Type(filter_list, T_STRING);
|
|
77
|
+
Check_Type(default_path, T_STRING);
|
|
78
|
+
|
|
79
|
+
rc = NFD_SaveDialog(StringValueCStr(filter_list), StringValueCStr(default_path), &strResult);
|
|
80
|
+
if (rc == NFD_ERROR)
|
|
81
|
+
rb_raise(eFileDialogError, "%s", NFD_GetError());
|
|
82
|
+
else if (rc == NFD_CANCEL)
|
|
83
|
+
return Qnil;
|
|
84
|
+
|
|
85
|
+
result = rb_str_new_cstr(strResult);
|
|
86
|
+
free(strResult);
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static VALUE FileDialog_s_pick_folder(
|
|
91
|
+
VALUE self, VALUE default_path)
|
|
92
|
+
{
|
|
93
|
+
nfdresult_t rc;
|
|
94
|
+
nfdchar_t *strResult;
|
|
95
|
+
VALUE result;
|
|
96
|
+
|
|
97
|
+
Check_Type(default_path, T_STRING);
|
|
98
|
+
|
|
99
|
+
rc = NFD_PickFolder(StringValueCStr(default_path), &strResult);
|
|
100
|
+
if (rc == NFD_ERROR)
|
|
101
|
+
rb_raise(eFileDialogError, "%s", NFD_GetError());
|
|
102
|
+
else if (rc == NFD_CANCEL)
|
|
103
|
+
return Qnil;
|
|
104
|
+
|
|
105
|
+
result = rb_str_new_cstr(strResult);
|
|
106
|
+
free(strResult);
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
void Init_filedialog() {
|
|
111
|
+
VALUE mFileDialog = rb_define_module("FileDialog");
|
|
112
|
+
eFileDialogError = rb_define_class_under(mFileDialog, "Error", rb_eStandardError);
|
|
113
|
+
|
|
114
|
+
rb_define_module_function(mFileDialog, "open_dialog_native", FileDialog_s_open_dialog, 2);
|
|
115
|
+
rb_define_module_function(mFileDialog, "open_dialog_multi_native", FileDialog_s_open_dialog_multi, 2);
|
|
116
|
+
rb_define_module_function(mFileDialog, "save_dialog_native", FileDialog_s_save_dialog, 2);
|
|
117
|
+
rb_define_module_function(mFileDialog, "pick_folder_native", FileDialog_s_pick_folder, 1);
|
|
118
|
+
}
|
data/filedialog.gemspec
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (C) 2020 Alex Gittemeier
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require_relative "lib/filedialog/version"
|
|
19
|
+
|
|
20
|
+
Gem::Specification.new do |spec|
|
|
21
|
+
spec.name = "filedialog"
|
|
22
|
+
spec.version = FileDialog::VERSION
|
|
23
|
+
spec.license = "GPL-3.0"
|
|
24
|
+
spec.authors = ["Alex Gittemeier"]
|
|
25
|
+
spec.email = ["gittemeier.alex@gmail.com"]
|
|
26
|
+
|
|
27
|
+
spec.summary = "A ruby wrapper for https://github.com/mlabbe/nativefiledialog"
|
|
28
|
+
spec.homepage = "https://github.com/win93/ruby-filedialog"
|
|
29
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
|
30
|
+
|
|
31
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
32
|
+
|
|
33
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
34
|
+
spec.metadata["source_code_uri"] = "https://github.com/win93/ruby-filedialog"
|
|
35
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem CHANGELOG.md URL here."
|
|
36
|
+
|
|
37
|
+
spec.files = Dir.chdir(__dir__) do
|
|
38
|
+
`git ls-files --recurse-submodules -z`.split("\x0").reject do |f|
|
|
39
|
+
f.match(%r{^(test|spec|features)/})
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
spec.bindir = "exe"
|
|
43
|
+
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
|
44
|
+
spec.extensions = ["ext/filedialog/extconf.rb"]
|
|
45
|
+
spec.require_paths = ["lib"]
|
|
46
|
+
|
|
47
|
+
spec.add_dependency "os", "~> 1.0"
|
|
48
|
+
end
|
data/lib/filedialog.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (C) 2020 Alex Gittemeier
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "filedialog/version"
|
|
19
|
+
require "filedialog/filedialog"
|
|
20
|
+
|
|
21
|
+
module FileDialog
|
|
22
|
+
class Error < StandardError; end
|
|
23
|
+
|
|
24
|
+
def self.open_dialog(filter_list, default_path, multiple: false)
|
|
25
|
+
if multiple
|
|
26
|
+
result = open_dialog_multi_native(
|
|
27
|
+
filter_list.encode("UTF-8"), default_path.encode("UTF-8"))
|
|
28
|
+
result.map{|x| x.force_encoding("UTF-8") }
|
|
29
|
+
else
|
|
30
|
+
result = open_dialog_native(
|
|
31
|
+
filter_list.encode("UTF-8"), default_path.encode("UTF-8"))
|
|
32
|
+
result.force_encoding("UTF-8")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.save_dialog(filter_list, default_path)
|
|
37
|
+
result = save_dialog_native(
|
|
38
|
+
filter_list.encode("UTF-8"), default_path.encode("UTF-8"))
|
|
39
|
+
result.force_encoding("UTF-8")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.pick_folder(default_path)
|
|
43
|
+
pick_folder_native(default_path.encode("UTF-8")).force_encoding("UTF-8")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private_class_method :open_dialog_native
|
|
47
|
+
private_class_method :open_dialog_multi_native
|
|
48
|
+
private_class_method :save_dialog_native
|
|
49
|
+
private_class_method :pick_folder_native
|
|
50
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: filedialog
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Alex Gittemeier
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-03-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: os
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.0'
|
|
27
|
+
description:
|
|
28
|
+
email:
|
|
29
|
+
- gittemeier.alex@gmail.com
|
|
30
|
+
executables: []
|
|
31
|
+
extensions:
|
|
32
|
+
- ext/filedialog/extconf.rb
|
|
33
|
+
extra_rdoc_files: []
|
|
34
|
+
files:
|
|
35
|
+
- ".github/workflows/gempush.yml"
|
|
36
|
+
- ".gitignore"
|
|
37
|
+
- ".gitmodules"
|
|
38
|
+
- ".rubocop.yml"
|
|
39
|
+
- Gemfile
|
|
40
|
+
- Gemfile.lock
|
|
41
|
+
- LICENSE
|
|
42
|
+
- README.md
|
|
43
|
+
- Rakefile
|
|
44
|
+
- bin/console
|
|
45
|
+
- deps/filedialogbuilddeps.rb
|
|
46
|
+
- deps/nativefiledialog/.github/ISSUE_TEMPLATE/bug_report.md
|
|
47
|
+
- deps/nativefiledialog/.gitignore
|
|
48
|
+
- deps/nativefiledialog/LICENSE
|
|
49
|
+
- deps/nativefiledialog/README.md
|
|
50
|
+
- deps/nativefiledialog/build/dont_run_premake.txt
|
|
51
|
+
- deps/nativefiledialog/build/gmake_linux/Makefile
|
|
52
|
+
- deps/nativefiledialog/build/gmake_linux/nfd.make
|
|
53
|
+
- deps/nativefiledialog/build/gmake_linux/test_opendialog.make
|
|
54
|
+
- deps/nativefiledialog/build/gmake_linux/test_opendialogmultiple.make
|
|
55
|
+
- deps/nativefiledialog/build/gmake_linux/test_pickfolder.make
|
|
56
|
+
- deps/nativefiledialog/build/gmake_linux/test_savedialog.make
|
|
57
|
+
- deps/nativefiledialog/build/gmake_linux_zenity/Makefile
|
|
58
|
+
- deps/nativefiledialog/build/gmake_linux_zenity/nfd.make
|
|
59
|
+
- deps/nativefiledialog/build/gmake_linux_zenity/test_opendialog.make
|
|
60
|
+
- deps/nativefiledialog/build/gmake_linux_zenity/test_opendialogmultiple.make
|
|
61
|
+
- deps/nativefiledialog/build/gmake_linux_zenity/test_pickfolder.make
|
|
62
|
+
- deps/nativefiledialog/build/gmake_linux_zenity/test_savedialog.make
|
|
63
|
+
- deps/nativefiledialog/build/gmake_macosx/Makefile
|
|
64
|
+
- deps/nativefiledialog/build/gmake_macosx/nfd.make
|
|
65
|
+
- deps/nativefiledialog/build/gmake_macosx/test_opendialog.make
|
|
66
|
+
- deps/nativefiledialog/build/gmake_macosx/test_opendialogmultiple.make
|
|
67
|
+
- deps/nativefiledialog/build/gmake_macosx/test_pickfolder.make
|
|
68
|
+
- deps/nativefiledialog/build/gmake_macosx/test_savedialog.make
|
|
69
|
+
- deps/nativefiledialog/build/gmake_windows/Makefile
|
|
70
|
+
- deps/nativefiledialog/build/gmake_windows/nfd.make
|
|
71
|
+
- deps/nativefiledialog/build/gmake_windows/test_opendialog.make
|
|
72
|
+
- deps/nativefiledialog/build/gmake_windows/test_opendialogmultiple.make
|
|
73
|
+
- deps/nativefiledialog/build/gmake_windows/test_pickfolder.make
|
|
74
|
+
- deps/nativefiledialog/build/gmake_windows/test_savedialog.make
|
|
75
|
+
- deps/nativefiledialog/build/premake5.lua
|
|
76
|
+
- deps/nativefiledialog/build/vs2010/NativeFileDialog.sln
|
|
77
|
+
- deps/nativefiledialog/build/vs2010/nfd.vcxproj
|
|
78
|
+
- deps/nativefiledialog/build/vs2010/nfd.vcxproj.filters
|
|
79
|
+
- deps/nativefiledialog/build/vs2010/test_opendialog.vcxproj
|
|
80
|
+
- deps/nativefiledialog/build/vs2010/test_opendialogmultiple.vcxproj
|
|
81
|
+
- deps/nativefiledialog/build/vs2010/test_pickfolder.vcxproj
|
|
82
|
+
- deps/nativefiledialog/build/vs2010/test_savedialog.vcxproj
|
|
83
|
+
- deps/nativefiledialog/build/xcode4/NativeFileDialog.xcworkspace/contents.xcworkspacedata
|
|
84
|
+
- deps/nativefiledialog/build/xcode4/nfd.xcodeproj/project.pbxproj
|
|
85
|
+
- deps/nativefiledialog/build/xcode4/test_opendialog.xcodeproj/project.pbxproj
|
|
86
|
+
- deps/nativefiledialog/build/xcode4/test_opendialogmultiple.xcodeproj/project.pbxproj
|
|
87
|
+
- deps/nativefiledialog/build/xcode4/test_pickfolder.xcodeproj/project.pbxproj
|
|
88
|
+
- deps/nativefiledialog/build/xcode4/test_savedialog.xcodeproj/project.pbxproj
|
|
89
|
+
- deps/nativefiledialog/docs/build.md
|
|
90
|
+
- deps/nativefiledialog/docs/contributing.md
|
|
91
|
+
- deps/nativefiledialog/screens/open_cocoa.png
|
|
92
|
+
- deps/nativefiledialog/screens/open_gtk3.png
|
|
93
|
+
- deps/nativefiledialog/screens/open_win.png
|
|
94
|
+
- deps/nativefiledialog/src/common.h
|
|
95
|
+
- deps/nativefiledialog/src/include/nfd.h
|
|
96
|
+
- deps/nativefiledialog/src/nfd_cocoa.m
|
|
97
|
+
- deps/nativefiledialog/src/nfd_common.c
|
|
98
|
+
- deps/nativefiledialog/src/nfd_common.h
|
|
99
|
+
- deps/nativefiledialog/src/nfd_gtk.c
|
|
100
|
+
- deps/nativefiledialog/src/nfd_win.cpp
|
|
101
|
+
- deps/nativefiledialog/src/nfd_zenity.c
|
|
102
|
+
- deps/nativefiledialog/src/simple_exec.h
|
|
103
|
+
- deps/nativefiledialog/test/test_opendialog.c
|
|
104
|
+
- deps/nativefiledialog/test/test_opendialogmultiple.c
|
|
105
|
+
- deps/nativefiledialog/test/test_pickfolder.c
|
|
106
|
+
- deps/nativefiledialog/test/test_savedialog.c
|
|
107
|
+
- ext/filedialog/extconf.rb
|
|
108
|
+
- ext/filedialog/filedialog.c
|
|
109
|
+
- filedialog.gemspec
|
|
110
|
+
- lib/filedialog.rb
|
|
111
|
+
- lib/filedialog/version.rb
|
|
112
|
+
homepage: https://github.com/win93/ruby-filedialog
|
|
113
|
+
licenses:
|
|
114
|
+
- GPL-3.0
|
|
115
|
+
metadata:
|
|
116
|
+
homepage_uri: https://github.com/win93/ruby-filedialog
|
|
117
|
+
source_code_uri: https://github.com/win93/ruby-filedialog
|
|
118
|
+
post_install_message:
|
|
119
|
+
rdoc_options: []
|
|
120
|
+
require_paths:
|
|
121
|
+
- lib
|
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
|
+
requirements:
|
|
124
|
+
- - ">="
|
|
125
|
+
- !ruby/object:Gem::Version
|
|
126
|
+
version: 2.3.0
|
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
requirements: []
|
|
133
|
+
rubygems_version: 3.0.3
|
|
134
|
+
signing_key:
|
|
135
|
+
specification_version: 4
|
|
136
|
+
summary: A ruby wrapper for https://github.com/mlabbe/nativefiledialog
|
|
137
|
+
test_files: []
|