summaryrefslogtreecommitdiff
path: root/src/gui_gtk.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-07-26 21:46:51 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-07-26 21:49:06 +0200
commit629bd9dbd099af60812e80f851afb7902fc28c37 (patch)
tree5c2877f36cf48c2e63bfc187fe1990a5d784ddbe /src/gui_gtk.cc
parent35ead0aaa5c7a7d9a17ab3dad65cfb9f0252889b (diff)
Change GuiForm::add_file must_exists argument to flags FILE_OPEN/FILE_SAVE
Diffstat (limited to 'src/gui_gtk.cc')
-rw-r--r--src/gui_gtk.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/gui_gtk.cc b/src/gui_gtk.cc
index a326cea..7510f09 100644
--- a/src/gui_gtk.cc
+++ b/src/gui_gtk.cc
@@ -925,10 +925,10 @@ public:
void add_file(std::string const& id, std::string const& label,
std::string const& value,
std::string const& description,
- bool must_exist,
+ uint8_t flags,
std::vector<Filter> const& filter) override {
values_.emplace_back(new FileValue(id, label, description, value,
- must_exist, filter));
+ flags, filter));
}
std::string get_string(std::string const& id) const override {
@@ -964,7 +964,7 @@ public:
for (auto const& value : values_) {
if (value->id_ == id && value->type_ == FILE) {
auto v = static_cast<FileValue*>(value.get());
- if (v->must_exist_ && v->chooser_) {
+ if ((v->flags_ & FILE_SAVE) == 0 && v->chooser_) {
std::string ret;
auto file = gtk_file_chooser_get_filename(v->chooser_);
if (file) {
@@ -1039,7 +1039,7 @@ public:
}
case FILE: {
auto v = static_cast<FileValue*>(value.get());
- if (v->must_exist_) {
+ if ((v->flags_ & FILE_SAVE) == 0) {
gtk_widget_destroy(value->entry_);
auto button = gtk_file_chooser_button_new(
v->label_.c_str(), GTK_FILE_CHOOSER_ACTION_OPEN);
@@ -1116,7 +1116,7 @@ public:
break;
case FILE: {
auto v = static_cast<FileValue*>(value.get());
- if (v->must_exist_) {
+ if ((v->flags_ & FILE_SAVE) == 0) {
auto file = gtk_file_chooser_get_filename(v->chooser_);
if (file) {
v->value_ = file;
@@ -1181,15 +1181,15 @@ protected:
struct FileValue : public Value {
std::string value_;
- bool must_exist_;
+ uint8_t flags_;
std::vector<Filter> filter_;
GtkFileChooser* chooser_;
FileValue(std::string const& id, std::string const& label,
std::string const& description, std::string const& value,
- bool must_exist, std::vector<Filter> const& filter)
+ uint8_t flags, std::vector<Filter> const& filter)
: Value(FILE, id, label, description), value_(value),
- must_exist_(must_exist), filter_(filter) {
+ flags_(flags), filter_(filter) {
}
};
@@ -1955,6 +1955,10 @@ GuiForm* GuiForm::create(std::string const& title,
}
// static
+uint8_t const GuiForm::FILE_OPEN = 0;
+uint8_t const GuiForm::FILE_SAVE = 1;
+
+// static
GuiFormApply* GuiFormApply::create(std::string const& title,
std::string const& text,
std::string const& apply_button,