#include "ui/gtk/select_file_dialog_linux_gtk.h"
#include <glib/gi18n.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <algorithm>
#include <cstddef>
#include <memory>
#include <set>
#include <utility>
#include <vector>
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/no_destructor.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "ui/aura/window_observer.h"
#include "ui/base/glib/scoped_gobject.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gtk/gtk_compat.h"
#include "ui/gtk/gtk_ui.h"
#include "ui/gtk/gtk_ui_platform.h"
#include "ui/gtk/gtk_util.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#include "ui/shell_dialogs/select_file_dialog_linux.h"
#include "ui/shell_dialogs/selected_file_info.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"
#include "url/gurl.h"
namespace gtk {
namespace {
const char* GettextPackage() { … }
const char* GtkGettext(const char* str) { … }
const char* GetCancelLabel() { … }
const char* GetOpenLabel() { … }
const char* GetSaveLabel() { … }
void GtkFileChooserSetFilename(GtkFileChooser* dialog,
const base::FilePath& path) { … }
int GtkDialogSelectedFilterIndex(GtkWidget* dialog) { … }
std::string GtkFileChooserGetFilename(GtkWidget* dialog) { … }
std::vector<base::FilePath> GtkFileChooserGetFilenames(GtkWidget* dialog) { … }
}
static const int kPreviewWidth = …;
static const int kPreviewHeight = …;
SelectFileDialogLinuxGtk::DialogState::DialogState() = default;
SelectFileDialogLinuxGtk::DialogState::DialogState(
std::vector<ScopedGSignal> signals,
aura::Window* parent,
base::OnceClosure reenable_parent_events)
: … { … }
SelectFileDialogLinuxGtk::DialogState::DialogState(DialogState&& other) =
default;
SelectFileDialogLinuxGtk::DialogState&
SelectFileDialogLinuxGtk::DialogState::operator=(DialogState&& other) = default;
SelectFileDialogLinuxGtk::DialogState::~DialogState() = default;
SelectFileDialogLinuxGtk::SelectFileDialogLinuxGtk(
Listener* listener,
std::unique_ptr<ui::SelectFilePolicy> policy)
: … { … }
SelectFileDialogLinuxGtk::~SelectFileDialogLinuxGtk() { … }
bool SelectFileDialogLinuxGtk::IsRunning(
gfx::NativeWindow parent_window) const { … }
bool SelectFileDialogLinuxGtk::HasMultipleFileTypeChoicesImpl() { … }
void SelectFileDialogLinuxGtk::OnWindowDestroying(aura::Window* window) { … }
void SelectFileDialogLinuxGtk::SelectFileImpl(
Type type,
const std::u16string& title,
const base::FilePath& default_path,
const FileTypeInfo* file_types,
int file_type_index,
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
const GURL* caller) { … }
void SelectFileDialogLinuxGtk::AddFilters(GtkFileChooser* chooser) { … }
void SelectFileDialogLinuxGtk::FileSelected(GtkWidget* dialog,
const base::FilePath& path) { … }
void SelectFileDialogLinuxGtk::MultiFilesSelected(
GtkWidget* dialog,
const std::vector<base::FilePath>& files) { … }
void SelectFileDialogLinuxGtk::FileNotSelected(GtkWidget* dialog) { … }
GtkWidget* SelectFileDialogLinuxGtk::CreateFileOpenHelper(
const std::string& title,
const base::FilePath& default_path,
gfx::NativeWindow parent) { … }
GtkWidget* SelectFileDialogLinuxGtk::CreateSelectFolderDialog(
Type type,
const std::string& title,
const base::FilePath& default_path,
gfx::NativeWindow parent) { … }
GtkWidget* SelectFileDialogLinuxGtk::CreateFileOpenDialog(
const std::string& title,
const base::FilePath& default_path,
gfx::NativeWindow parent) { … }
GtkWidget* SelectFileDialogLinuxGtk::CreateMultiFileOpenDialog(
const std::string& title,
const base::FilePath& default_path,
gfx::NativeWindow parent) { … }
GtkWidget* SelectFileDialogLinuxGtk::CreateSaveAsDialog(
const std::string& title,
const base::FilePath& default_path,
gfx::NativeWindow parent) { … }
bool SelectFileDialogLinuxGtk::IsCancelResponse(gint response_id) { … }
void SelectFileDialogLinuxGtk::SelectSingleFileHelper(GtkWidget* dialog,
gint response_id,
bool allow_folder) { … }
void SelectFileDialogLinuxGtk::OnSelectSingleFileDialogResponse(
GtkWidget* dialog,
int response_id) { … }
void SelectFileDialogLinuxGtk::OnSelectSingleFolderDialogResponse(
GtkWidget* dialog,
int response_id) { … }
void SelectFileDialogLinuxGtk::OnSelectMultiFileDialogResponse(
GtkWidget* dialog,
int response_id) { … }
void SelectFileDialogLinuxGtk::OnFileChooserDestroy(GtkWidget* dialog) { … }
void SelectFileDialogLinuxGtk::OnUpdatePreview(GtkWidget* chooser) { … }
}