Synchronize send to external editor buttons

Keep all buttons updated when using a multiple editor tabs mode.
This commit is contained in:
Lawrence Lee 2021-07-25 17:45:20 -07:00
parent a0711ebc8c
commit db7d56c253
4 changed files with 46 additions and 0 deletions

View File

@ -2003,6 +2003,9 @@ void EditorPanel::sendToExternalChanged(int)
index = -1; index = -1;
} }
options.externalEditorIndex = index; options.externalEditorIndex = index;
if (externalEditorChangedSignal) {
externalEditorChangedSignal->emit();
}
} }
void EditorPanel::sendToExternalPressed() void EditorPanel::sendToExternalPressed()
@ -2069,6 +2072,23 @@ void EditorPanel::syncFileBrowser() // synchronize filebrowser with image in E
} }
} }
ExternalEditorChangedSignal * EditorPanel::getExternalEditorChangedSignal()
{
return externalEditorChangedSignal;
}
void EditorPanel::setExternalEditorChangedSignal(ExternalEditorChangedSignal *signal)
{
if (externalEditorChangedSignal) {
externalEditorChangedSignalConnection.disconnect();
}
externalEditorChangedSignal = signal;
if (signal) {
externalEditorChangedSignalConnection = signal->connect(
sigc::mem_fun(*this, &EditorPanel::updateExternalEditorSelection));
}
}
void EditorPanel::histogramProfile_toggled() void EditorPanel::histogramProfile_toggled()
{ {
options.rtSettings.HistogramWorking = toggleHistogramProfile->get_active(); options.rtSettings.HistogramWorking = toggleHistogramProfile->get_active();
@ -2203,6 +2223,18 @@ void EditorPanel::onAppChooserDialogResponse(int responseId)
} }
} }
void EditorPanel::updateExternalEditorSelection()
{
int index = send_to_external->getSelected();
if (index >= 0 && static_cast<unsigned>(index) == options.externalEditors.size()) {
index = -1;
}
if (options.externalEditorIndex != index) {
send_to_external->setSelected(
options.externalEditorIndex >= 0 ? options.externalEditorIndex : options.externalEditors.size());
}
}
void EditorPanel::historyBeforeLineChanged (const rtengine::procparams::ProcParams& params) void EditorPanel::historyBeforeLineChanged (const rtengine::procparams::ProcParams& params)
{ {

View File

@ -38,6 +38,8 @@ template<typename T>
class array2D; class array2D;
} }
using ExternalEditorChangedSignal = sigc::signal<void>;
class BatchQueueEntry; class BatchQueueEntry;
class EditorPanel; class EditorPanel;
class FilePanel; class FilePanel;
@ -66,6 +68,7 @@ class EditorPanel final :
public rtengine::NonCopyable public rtengine::NonCopyable
{ {
public: public:
explicit EditorPanel (FilePanel* filePanel = nullptr); explicit EditorPanel (FilePanel* filePanel = nullptr);
~EditorPanel () override; ~EditorPanel () override;
@ -170,6 +173,10 @@ public:
void openPreviousEditorImage (); void openPreviousEditorImage ();
void syncFileBrowser (); void syncFileBrowser ();
// Signals.
ExternalEditorChangedSignal * getExternalEditorChangedSignal();
void setExternalEditorChangedSignal(ExternalEditorChangedSignal *signal);
void tbTopPanel_1_visible (bool visible); void tbTopPanel_1_visible (bool visible);
bool CheckSidePanelsVisibility(); bool CheckSidePanelsVisibility();
void tbShowHideSidePanels_managestate(); void tbShowHideSidePanels_managestate();
@ -207,6 +214,7 @@ private:
void histogramProfile_toggled (); void histogramProfile_toggled ();
Gtk::AppChooserDialog *getAppChooserDialog(); Gtk::AppChooserDialog *getAppChooserDialog();
void onAppChooserDialogResponse(int resposneId); void onAppChooserDialogResponse(int resposneId);
void updateExternalEditorSelection();
Glib::ustring lastSaveAsFileName; Glib::ustring lastSaveAsFileName;
@ -242,6 +250,8 @@ private:
Gtk::Button* navPrev; Gtk::Button* navPrev;
Glib::RefPtr<Gio::AppInfo> external_editor_info; Glib::RefPtr<Gio::AppInfo> external_editor_info;
std::unique_ptr<Gtk::AppChooserDialog> app_chooser_dialog; std::unique_ptr<Gtk::AppChooserDialog> app_chooser_dialog;
ExternalEditorChangedSignal *externalEditorChangedSignal;
sigc::connection externalEditorChangedSignalConnection;
rtengine::InitialImage *cached_exported_image; rtengine::InitialImage *cached_exported_image;
rtengine::procparams::ProcParams cached_exported_pparams; rtengine::procparams::ProcParams cached_exported_pparams;

View File

@ -250,6 +250,7 @@ void EditWindow::addEditorPanel (EditorPanel* ep, const std::string &name)
{ {
ep->setParent (parent); ep->setParent (parent);
ep->setParentWindow(this); ep->setParentWindow(this);
ep->setExternalEditorChangedSignal(&externalEditorChangedSignal);
// construct closeable tab for the image // construct closeable tab for the image
Gtk::Box* hb = Gtk::manage (new Gtk::Box ()); Gtk::Box* hb = Gtk::manage (new Gtk::Box ());
@ -288,6 +289,7 @@ void EditWindow::remEditorPanel (EditorPanel* ep)
return; // Will crash if destroyed while loading return; // Will crash if destroyed while loading
} }
ep->setExternalEditorChangedSignal(nullptr);
epanels.erase (ep->getFileName()); epanels.erase (ep->getFileName());
filesEdited.erase (ep->getFileName ()); filesEdited.erase (ep->getFileName ());
parent->fpanel->refreshEditedState (filesEdited); parent->fpanel->refreshEditedState (filesEdited);

View File

@ -39,6 +39,8 @@ private:
std::set<Glib::ustring> filesEdited; std::set<Glib::ustring> filesEdited;
std::map<Glib::ustring, EditorPanel*> epanels; std::map<Glib::ustring, EditorPanel*> epanels;
sigc::signal<void> externalEditorChangedSignal;
bool isFullscreen; bool isFullscreen;
bool isClosed; bool isClosed;
bool isMinimized; bool isMinimized;