From 8b011541f85e4fa277cf8d33236526252f4794c8 Mon Sep 17 00:00:00 2001 From: Jonas Keller Date: Wed, 9 Aug 2023 22:25:57 +0200 Subject: [PATCH 1/2] Make apply work for multiple displays - add a map to keep track of the dirty state of every display - display_name, (isDirty, file) - on apply, iterate over the map to save everything to config --- src/NWindow.cc | 17 +++++++++++++---- src/NWindow.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/NWindow.cc b/src/NWindow.cc index 1c2efd7..d18a167 100644 --- a/src/NWindow.cc +++ b/src/NWindow.cc @@ -199,9 +199,15 @@ void NWindow::apply_bg () { Glib::ustring thedisp = this->select_display.get_active_data(); Gdk::Color bgcolor = this->button_bgcolor.get_color(); - // save - if (saveToConfig) - Config::get_instance()->set_bg(thedisp, file, mode, bgcolor); + for(std::map>::iterator i = m_dirty_displays.begin(); i != m_dirty_displays.end(); ++i) + { + if (saveToConfig) + Config::get_instance()->set_bg((*i).first, (*i).second.second, mode, bgcolor); + + // remove dirty flag + (*i).second.first = false; + (*i).second.second = ""; + } // tell the bg setter to forget about the first pixmap bg_setter->clear_first_pixmaps(); @@ -298,7 +304,9 @@ bool NWindow::set_bg(const Glib::ustring file) { // set it bg_setter->set_bg(thedisp, file, mode, bgcolor); - return bg_setter->save_to_config(); + bool dirty = bg_setter->save_to_config(); + m_dirty_displays[thedisp] = {dirty, file}; + return dirty; } // leethax destructor @@ -369,6 +377,7 @@ void NWindow::setup_select_boxes() { for (std::map::const_iterator i = map_displays.begin(); i != map_displays.end(); i++) { this->select_display.add_image_row( video_display_icon, (*i).second, (*i).first, false); + m_dirty_displays[(*i).first] = {false, ""}; } return; diff --git a/src/NWindow.h b/src/NWindow.h index cfad9fb..3e8bf14 100644 --- a/src/NWindow.h +++ b/src/NWindow.h @@ -59,6 +59,7 @@ class NWindow : public Gtk::Window { Gtk::ColorButton button_bgcolor; bool m_dirty; // set if the user double clicks to preview but forgets to press apply + std::map> m_dirty_displays; void setup_select_boxes(); From 3c272a79b77f0c55c21f0178621ee506b73cc59f Mon Sep 17 00:00:00 2001 From: Jonas Keller Date: Thu, 10 Aug 2023 22:28:20 +0200 Subject: [PATCH 2/2] Ignore xin_-1 when saving to config --- src/NWindow.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/NWindow.cc b/src/NWindow.cc index d18a167..b18b8d0 100644 --- a/src/NWindow.cc +++ b/src/NWindow.cc @@ -201,8 +201,9 @@ void NWindow::apply_bg () { for(std::map>::iterator i = m_dirty_displays.begin(); i != m_dirty_displays.end(); ++i) { - if (saveToConfig) - Config::get_instance()->set_bg((*i).first, (*i).second.second, mode, bgcolor); + auto disp = (*i).first; + if (saveToConfig && disp != "xin_-1") + Config::get_instance()->set_bg(disp, (*i).second.second, mode, bgcolor); // remove dirty flag (*i).second.first = false;