General Terminal

GtFileDialog

Open a native file or folder dialog

Syntax

Signature
xBool GtFileDialog( ITEM *options, ITEM *result );

Arguments

options is an array with dialog type ("OPEN", "SAVE", or "FOLDER"), title, initial location, filters, and a multiple-selection flag, in that order.

result points to a writable ITEM. The driver can populate it with the acceptance flag, array of selected paths, filter index, and error text, in that order.

Return value

T if a selection was accepted, otherwise F.

Description

Provide a separate result ITEM and release both items when finished. Read the selected paths from result slot 2. Dialog options and the filter index depend on the backend.

Example

gtfiledialog.c
#include "xdev-wtui.h"

#include <stdio.h>

int main( void )
{
   ITEM *options = Array( 2 );
   ITEM *result = ItemNew( NULL );

   ArraySetC( options, 1, "OPEN" );
   ArraySetC( options, 2, "Choose a file" );
   if( GtFileDialog( options, result ) )
   {
      const ITEM *paths = ArrayGetItemPtr( result, 2 );

      for( int64_t i = 1; i <= ArrayLen( paths ); ++i )
         puts( ArrayGetCPtr( paths, ( size_t )i ) );
   }
   ItemRelease( result );
   ItemRelease( options );

   return 0;
}

See also