[UI] Implement folder and file save routines for the Linux GUI.
This commit is contained in:
parent
1618f43c33
commit
2a232abc09
|
@ -2,7 +2,7 @@
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* Xenia : Xbox 360 Emulator Research Project *
|
* Xenia : Xbox 360 Emulator Research Project *
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* Copyright 2020 Ben Vanik. All rights reserved. *
|
* Copyright 2025 Ben Vanik. All rights reserved. *
|
||||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "xenia/base/assert.h"
|
#include "xenia/base/assert.h"
|
||||||
#include "xenia/base/filesystem.h"
|
#include "xenia/base/filesystem.h"
|
||||||
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/platform_linux.h"
|
#include "xenia/base/platform_linux.h"
|
||||||
#include "xenia/base/string.h"
|
#include "xenia/base/string.h"
|
||||||
#include "xenia/ui/window_gtk.h"
|
#include "xenia/ui/window_gtk.h"
|
||||||
|
@ -43,22 +44,35 @@ GtkFilePicker::GtkFilePicker() = default;
|
||||||
GtkFilePicker::~GtkFilePicker() = default;
|
GtkFilePicker::~GtkFilePicker() = default;
|
||||||
|
|
||||||
bool GtkFilePicker::Show(Window* parent_window) {
|
bool GtkFilePicker::Show(Window* parent_window) {
|
||||||
// TODO(benvanik): FileSaveDialog.
|
std::string title;
|
||||||
assert_true(mode() == Mode::kOpen);
|
GtkFileChooserAction action;
|
||||||
// TODO(benvanik): folder dialogs.
|
std::string confirm_button;
|
||||||
assert_true(type() == Type::kFile);
|
switch (mode()) {
|
||||||
GtkWidget* dialog;
|
case Mode::kOpen:
|
||||||
gint res;
|
title = type() == Type::kFile ? "Open File" : "Open Directory";
|
||||||
|
action = type() == Type::kFile ? GTK_FILE_CHOOSER_ACTION_OPEN
|
||||||
dialog = gtk_file_chooser_dialog_new(
|
: GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
|
||||||
"Open File",
|
confirm_button = "_Open";
|
||||||
|
break;
|
||||||
|
case Mode::kSave:
|
||||||
|
title = "Save File";
|
||||||
|
action = GTK_FILE_CHOOSER_ACTION_SAVE;
|
||||||
|
confirm_button = "_Save";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
XELOGE("GtkFilePicker::Show: Unhandled mode: {}, Type: {}",
|
||||||
|
static_cast<int>(mode()), static_cast<int>(type()));
|
||||||
|
assert_always();
|
||||||
|
}
|
||||||
|
GtkWidget* dialog = gtk_file_chooser_dialog_new(
|
||||||
|
title.c_str(),
|
||||||
parent_window
|
parent_window
|
||||||
? GTK_WINDOW(static_cast<const GTKWindow*>(parent_window)->window())
|
? GTK_WINDOW(dynamic_cast<const GTKWindow*>(parent_window)->window())
|
||||||
: nullptr,
|
: nullptr,
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN, "_Cancel", GTK_RESPONSE_CANCEL, "_Open",
|
action, "_Cancel", GTK_RESPONSE_CANCEL, confirm_button.c_str(),
|
||||||
GTK_RESPONSE_ACCEPT, NULL);
|
GTK_RESPONSE_ACCEPT, NULL);
|
||||||
|
|
||||||
res = gtk_dialog_run(GTK_DIALOG(dialog));
|
gint res = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||||
char* filename;
|
char* filename;
|
||||||
if (res == GTK_RESPONSE_ACCEPT) {
|
if (res == GTK_RESPONSE_ACCEPT) {
|
||||||
GtkFileChooser* chooser = GTK_FILE_CHOOSER(dialog);
|
GtkFileChooser* chooser = GTK_FILE_CHOOSER(dialog);
|
||||||
|
|
Loading…
Reference in New Issue