@@ -120,6 +120,7 @@ constexpr const char* STR_OPEN_FILE = "Open File";
120120constexpr const char * STR_OPEN_FILES = " Open Files" ;
121121constexpr const char * STR_SAVE_FILE = " Save File" ;
122122constexpr const char * STR_SELECT_FOLDER = " Select Folder" ;
123+ constexpr const char * STR_SELECT_FOLDERS = " Select Folders" ;
123124constexpr const char * STR_HANDLE_TOKEN = " handle_token" ;
124125constexpr const char * STR_MULTIPLE = " multiple" ;
125126constexpr const char * STR_DIRECTORY = " directory" ;
@@ -149,6 +150,10 @@ template <>
149150void AppendOpenFileQueryTitle<false , true >(DBusMessageIter& iter) {
150151 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &STR_SELECT_FOLDER);
151152}
153+ template <>
154+ void AppendOpenFileQueryTitle<true , true >(DBusMessageIter& iter) {
155+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &STR_SELECT_FOLDERS);
156+ }
152157
153158void AppendSaveFileQueryTitle (DBusMessageIter& iter) {
154159 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &STR_SAVE_FILE);
@@ -1547,8 +1552,6 @@ nfdresult_t NFD_PickFolderN_With_Impl(nfdversion_t version,
15471552 // We haven't needed to bump the interface version yet.
15481553 (void )version;
15491554
1550- (void )args; // Default path not supported for portal backend
1551-
15521555 {
15531556 dbus_uint32_t version;
15541557 const nfdresult_t res = NFD_DBus_GetVersion (version);
@@ -1593,6 +1596,61 @@ nfdresult_t NFD_PickFolderU8_With_Impl(nfdversion_t version,
15931596 const nfdpickfolderu8args_t * args)
15941597 __attribute__((alias(" NFD_PickFolderN_With_Impl" )));
15951598
1599+ nfdresult_t NFD_PickFolderMultipleN (const nfdpathset_t ** outPaths, const nfdnchar_t * defaultPath) {
1600+ nfdpickfoldernargs_t args{};
1601+ args.defaultPath = defaultPath;
1602+ return NFD_PickFolderMultipleN_With_Impl (NFD_INTERFACE_VERSION, outPaths, &args);
1603+ }
1604+
1605+ nfdresult_t NFD_PickFolderMultipleN_With_Impl (nfdversion_t version,
1606+ const nfdpathset_t ** outPaths,
1607+ const nfdpickfoldernargs_t * args) {
1608+ // We haven't needed to bump the interface version yet.
1609+ (void )version;
1610+
1611+ {
1612+ dbus_uint32_t version;
1613+ const nfdresult_t res = NFD_DBus_GetVersion (version);
1614+ if (res != NFD_OKAY) {
1615+ return res;
1616+ }
1617+ if (version < 3 ) {
1618+ NFDi_SetFormattedError (
1619+ " The xdg-desktop-portal installed on this system does not support a folder picker; "
1620+ " at least version 3 of the org.freedesktop.portal.FileChooser interface is "
1621+ " required but the installed interface version is %u." ,
1622+ version);
1623+ return NFD_ERROR;
1624+ }
1625+ }
1626+
1627+ DBusMessage* msg;
1628+ {
1629+ const nfdresult_t res = NFD_DBus_OpenFile<true , true >(msg, nullptr , 0 , args->defaultPath );
1630+ if (res != NFD_OKAY) {
1631+ return res;
1632+ }
1633+ }
1634+
1635+ DBusMessageIter uri_iter;
1636+ const nfdresult_t res = ReadResponseUris (msg, uri_iter);
1637+ if (res != NFD_OKAY) {
1638+ dbus_message_unref (msg);
1639+ return res;
1640+ }
1641+
1642+ *outPaths = msg;
1643+ return NFD_OKAY;
1644+ }
1645+
1646+ nfdresult_t NFD_PickFolderMultipleU8 (const nfdpathset_t ** outPaths, const nfdu8char_t * defaultPath)
1647+ __attribute__((alias(" NFD_PickFolderMultipleN" )));
1648+
1649+ nfdresult_t NFD_PickFolderMultipleU8_With_Impl (nfdversion_t version,
1650+ const nfdpathset_t ** outPaths,
1651+ const nfdpickfolderu8args_t * args)
1652+ __attribute__((alias(" NFD_PickFolderMultipleN_With_Impl" )));
1653+
15961654nfdresult_t NFD_PathSet_GetCount (const nfdpathset_t * pathSet, nfdpathsetsize_t * count) {
15971655 assert (pathSet);
15981656 DBusMessage* msg = const_cast <DBusMessage*>(static_cast <const DBusMessage*>(pathSet));
0 commit comments