diff --git a/rtdata/languages/default b/rtdata/languages/default
index 538c25b00..4d80f56a9 100644
--- a/rtdata/languages/default
+++ b/rtdata/languages/default
@@ -208,6 +208,7 @@ FILEBROWSER_ZOOMOUTHINT;Decrease thumbnail size.\n\nShortcuts:\n- - Multi
FILECHOOSER_FILTER_ANY;All files
FILECHOOSER_FILTER_COLPROF;Color profiles (*.icc)
FILECHOOSER_FILTER_CURVE;Curve files
+FILECHOOSER_FILTER_EXECUTABLE;Executable files
FILECHOOSER_FILTER_LCP;Lens correction profiles
FILECHOOSER_FILTER_PP;Processing profiles
FILECHOOSER_FILTER_SAME;Same format as current photo
@@ -1782,6 +1783,7 @@ PREFERENCES_EDITORCMDLINE;Custom command line
PREFERENCES_EDITORLAYOUT;Editor layout
PREFERENCES_EXTERNALEDITOR;External Editor
PREFERENCES_EXTERNALEDITOR_CHANGE;Change Application
+PREFERENCES_EXTERNALEDITOR_CHANGE_FILE;Change Executable
PREFERENCES_EXTERNALEDITOR_COLUMN_NAME;Name
PREFERENCES_EXTERNALEDITOR_COLUMN_COMMAND;Command
PREFERENCES_EXTEDITOR_DIR;Output directory
diff --git a/rtgui/externaleditorpreferences.cc b/rtgui/externaleditorpreferences.cc
index 61bf8dc3a..c6ee9b93e 100644
--- a/rtgui/externaleditorpreferences.cc
+++ b/rtgui/externaleditorpreferences.cc
@@ -18,6 +18,11 @@
*/
#include
+#include
+#include
+#include
+#include
+
#include "externaleditorpreferences.h"
#include "multilangmgr.h"
#include "rtimage.h"
@@ -54,11 +59,14 @@ ExternalEditorPreferences::ExternalEditorPreferences():
button_add->set_image(*add_image);
button_remove->set_image(*remove_image);
button_app_chooser = Gtk::make_managed(M("PREFERENCES_EXTERNALEDITOR_CHANGE"));
+ button_file_chooser = Gtk::manage(new Gtk::Button(M("PREFERENCES_EXTERNALEDITOR_CHANGE_FILE")));
button_app_chooser->signal_pressed().connect(sigc::mem_fun(
*this, &ExternalEditorPreferences::openAppChooserDialog));
button_add->signal_pressed().connect(sigc::mem_fun(
*this, &ExternalEditorPreferences::addEditor));
+ button_file_chooser->signal_pressed().connect(sigc::mem_fun(
+ *this, &ExternalEditorPreferences::openFileChooserDialog));
button_remove->signal_pressed().connect(sigc::mem_fun(
*this, &ExternalEditorPreferences::removeSelectedEditors));
@@ -69,6 +77,7 @@ ExternalEditorPreferences::ExternalEditorPreferences():
// Toolbar.
toolbar.set_halign(Gtk::Align::ALIGN_END);
toolbar.add(*button_app_chooser);
+ toolbar.add(*button_file_chooser);
toolbar.add(*button_add);
toolbar.add(*button_remove);
@@ -204,6 +213,38 @@ void ExternalEditorPreferences::onAppChooserDialogResponse(
}
}
+void ExternalEditorPreferences::onFileChooserDialogResponse(
+ int response_id, Gtk::FileChooserDialog *dialog)
+{
+ switch (response_id) {
+ case Gtk::RESPONSE_OK: {
+ dialog->close();
+
+ auto selection = list_view->get_selection()->get_selected_rows();
+ for (const auto &selected : selection) {
+ auto row = *list_model->get_iter(selected);
+ row[model_columns.icon] = Glib::RefPtr(nullptr);
+ row[model_columns.command] =
+#ifdef WIN32
+ '"' + dialog->get_filename() + '"';
+#else
+ Glib::shell_quote(dialog->get_filename());
+#endif
+ }
+
+ break;
+ }
+
+ case Gtk::RESPONSE_CANCEL:
+ case Gtk::RESPONSE_CLOSE:
+ dialog->close();
+ break;
+
+ default:
+ break;
+ }
+}
+
void ExternalEditorPreferences::openAppChooserDialog()
{
if (app_chooser_dialog.get()) {
@@ -221,6 +262,35 @@ void ExternalEditorPreferences::openAppChooserDialog()
app_chooser_dialog->show();
}
+void ExternalEditorPreferences::openFileChooserDialog()
+{
+ if (file_chooser_dialog.get()) {
+ file_chooser_dialog->show();
+ return;
+ }
+
+ file_chooser_dialog.reset(new Gtk::FileChooserDialog(M("PREFERENCES_EXTERNALEDITOR_CHANGE_FILE")));
+
+ const auto exe_filter = Gtk::FileFilter::create();
+ exe_filter->set_name(M("FILECHOOSER_FILTER_EXECUTABLE"));
+ exe_filter->add_custom(Gtk::FILE_FILTER_MIME_TYPE, [](const Gtk::FileFilter::Info &info) {
+ return Gio::content_type_can_be_executable(info.mime_type);
+ });
+ const auto all_filter = Gtk::FileFilter::create();
+ all_filter->set_name(M("FILECHOOSER_FILTER_ANY"));
+ all_filter->add_pattern("*");
+ file_chooser_dialog->add_filter(exe_filter);
+ file_chooser_dialog->add_filter(all_filter);
+
+ file_chooser_dialog->signal_response().connect(sigc::bind(
+ sigc::mem_fun(*this, &ExternalEditorPreferences::onFileChooserDialogResponse),
+ file_chooser_dialog.get()));
+ file_chooser_dialog->set_modal();
+ file_chooser_dialog->add_button(M("GENERAL_CANCEL"), Gtk::RESPONSE_CANCEL);
+ file_chooser_dialog->add_button(M("GENERAL_OPEN"), Gtk::RESPONSE_OK);
+ file_chooser_dialog->show();
+}
+
void ExternalEditorPreferences::removeSelectedEditors()
{
auto selection = list_view->get_selection()->get_selected_rows();
@@ -265,6 +335,7 @@ void ExternalEditorPreferences::updateToolbarSensitivity()
{
bool selected = list_view->get_selection()->count_selected_rows();
button_app_chooser->set_sensitive(selected);
+ button_file_chooser->set_sensitive(selected);
button_remove->set_sensitive(selected);
}
diff --git a/rtgui/externaleditorpreferences.h b/rtgui/externaleditorpreferences.h
index 5761d8b63..34658d942 100644
--- a/rtgui/externaleditorpreferences.h
+++ b/rtgui/externaleditorpreferences.h
@@ -28,6 +28,14 @@
#include "rtappchooserdialog.h"
+namespace Gtk
+{
+
+class FileChooserDialog;
+
+}
+
+
/**
* Widget for editing the external editors options.
*/
@@ -98,8 +106,10 @@ private:
Gtk::Box toolbar; // Contains buttons for editing the list.
Gtk::Button *button_app_chooser;
Gtk::Button *button_add;
+ Gtk::Button *button_file_chooser;
Gtk::Button *button_remove;
std::unique_ptr app_chooser_dialog;
+ std::unique_ptr file_chooser_dialog;
/**
* Inserts a new editor entry after the current selection, or at the end if
@@ -119,10 +129,19 @@ private:
* Closes the dialog and updates the selected entry if an app was chosen.
*/
void onAppChooserDialogResponse(int responseId, RTAppChooserDialog *dialog);
+ /**
+ * Called when the user is done interacting with the file chooser dialog.
+ * Closes the dialog and updates the selected entry if a file was chosen.
+ */
+ void onFileChooserDialogResponse(int responseId, Gtk::FileChooserDialog *dialog);
/**
* Shows the app chooser dialog.
*/
void openAppChooserDialog();
+ /**
+ * Shows the file chooser dialog for picking an executable.
+ */
+ void openFileChooserDialog();
/**
* Removes all selected editors.
*/