VgaGames4 - dialog man-pages

[.. upper level ..]

vg4->dialog->file_select()

Open a canvas-dialog to select a filename.

SYNTAX
VG_BOOL vg4->dialog->file_select(char *filename, size_t fsize, const char *cvasdir, const struct VG_Position *posdst, struct VG_Hash *hvar, const char *startdir, VG_BOOL textinput, VG_BOOL showhidden)

FUNCTION PARAMETERS
filename For returning selected filename
fsize Size of filenname
cvasdir Directory to load canvasses from, or NULL = use system-canvasses
posdst Canvas-position on window, or NULL = centered
hvar Hash with variable-values (see vg4->canvas->load())
startdir Topmost directory to start selecting filename from: - beginning with /: absolute path - not beginning with /: relative path from current directory - beginning with ~: path beginning from the HOME-directory - NULL: no topmost directory, starting in HOME-directory
textinput Whether creating a new filename or directory is allowed
showhidden Whether show hidden files and directories

RETURN VALUE
Returns boolean: - VG_TRUE: OK - VG_FALSE: Got exit-request

DESCRIPTION
Open a canvas-dialog to select a filename. This function uses following canvas-files (installed below share/vgagames4/canvas/) - file_select.top.cvas: Top-canvas for selecting a file - file_select.input.cvas: Sub-canvas for creating a new directory or file - file_select.overwrite.cvas: Sub-canvas for asking for overwriting an existing file The parameter hvar should contain following variables - key: top:title value: title of top-canvas - key: input:title-dir value: title of sub-canvas for creating a new directory - key: input:title-file value: title of sub-canvas for creating a new file - key: overwrite:title value: title of sub-canvas for asking whether to overwrite If the returned filename is empty, the function was cancelled. If own canvas-files shall be used instead of the system-canvas-files, they must lay in cvasdir or cvasdir/file_select/ and have the same names as the system-canvas-files: - file_select.top.cvas - uses canvas-items: - [CV-TEXT] with name title: text for title - [CV-TEXT] with name current-path: current path - [CV-BUTTON] with name done: for returning without selecting a file - [CV-LIST] with name filelist: for contents of directory - [CV-BUTTON] with name makefile: for creating a new file - [CV-BUTTON] with name makedir: for creating a new directory - uses variables: - key: title value: title of canvas - key: current-path value: current path (will be set automatically) - file_select.input.cvas - uses canvas-items: - [CV-TEXT] with name title: text for title - [CV-INPUT] with name input: for typing a directory-/file-name - uses variables: - key: title value: title of canvas - file_select.overwrite.cvas - uses canvas-items: - [CV-TEXT] with name title: text for title - [CV-TEXT] with name overwrite-file: filename to be overwritten - [CV-BUTTON] with name yes: to confirm - [CV-BUTTON] as a cancel-button - uses variables: - key: title value: title of canvas - key: overwrite-file value: filename to be overwritten (will be set automatically)

EXAMPLE
  struct VG_Hash *hvar;
  char filename[256];

  hvar = vg4->hash->create();

  /* set variables */
  vg4->hash->setstr(hvar, "top:title", "Save settings");
  vg4->hash->setstr(hvar, "input:title-dir", "Create directory");
  vg4->hash->setstr(hvar, "input:title-file", "Create file");
  vg4->hash->setstr(hvar, "overwrite:title", "Overwrite file?");

  /* execute dialog, start selecting from home-directory */
  if (!vg4->dialog->file_select(filename, sizeof(filename), NULL, NULL, hvar, "~", VG_TRUE, VG_FALSE)) {
    /* exit request */
    VG_dest();
    exit(0);
  }

  vg4->hash->destroy(hvar);

  if (*filename != '\0') {  /* not cancelled */
    printf("Filename selected: %s\n", filename);
  }