Example #1
0
bool
FilePicker(const TCHAR *caption, FileDataField &df,
           const TCHAR *help_text)
{
    ComboList combo_list = df.CreateComboList(nullptr);
    if (combo_list.size() == 0)
        return false;

    const TCHAR *extra_caption = nullptr;
#ifdef HAVE_DOWNLOAD_MANAGER
    if (df.GetFileType() != FileType::UNKNOWN &&
            Net::DownloadManager::IsAvailable())
        extra_caption = _("Download");
#endif

    int i = ComboPicker(caption, combo_list, help_text, false, extra_caption);

#ifdef HAVE_DOWNLOAD_MANAGER
    if (i == -2) {
        const auto path = DownloadFilePicker(df.GetFileType());
        if (path.IsNull())
            return false;

        df.ForceModify(path);
        return true;
    }
#endif

    if (i < 0)
        return false;

    const ComboList::Item &item = combo_list[i];
    df.SetFromCombo(item.int_value, item.string_value.c_str());
    return true;
}
Example #2
0
AllocatedPath
FilePicker(const TCHAR *caption, const TCHAR *patterns)
{
    assert(patterns != nullptr);

    FileDataField df;
    df.ScanMultiplePatterns(patterns);
    return FilePicker(caption, df)
           ? df.GetPathFile()
           : nullptr;
}
Example #3
0
bool
FilePicker(const TCHAR *caption, const TCHAR *patterns, TCHAR *buffer)
{
  assert(patterns != nullptr);

  FileDataField df;
  df.ScanMultiplePatterns(patterns);
  if (!FilePicker(caption, df))
    return false;

  _tcscpy(buffer, df.GetAsString());
  return true;
}