[Xfce4-commits] [panel-plugins/xfce4-hardware-monitor-plugin] 05/29: Monitor colours should change as soon as the colour button is set
noreply at xfce.org
noreply at xfce.org
Mon Dec 18 12:45:36 CET 2017
This is an automated email from the git hooks/post-receive script.
o m e g a p h i l p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository panel-plugins/xfce4-hardware-monitor-plugin.
commit 2f1a15758013c4b2913698f85866a4ca65567a42
Author: OmegaPhil <OmegaPhil at startmail.com>
Date: Sun Nov 19 20:47:17 2017 +0000
Monitor colours should change as soon as the colour button is set
In order to change a monitor's colour in the visualisation, you
need to select a monitor on the Devices tab, set the colour via the
Colour button at the bottom, then use the Change button and OK the
dialog that pops up.
The way the UI is made, it suggests the colour should update
as soon as the Colour dialog is OK'd, but it looks like it never
did - this has now been fixed.
Reported by alwayseverything at mail.com in #13803 /
https://bugzilla.xfce.org/show_bug.cgi?id=13803
---
src/plugin.cpp | 29 +++++++++++++----------------
src/plugin.hpp | 8 +++++++-
src/preferences-window.cpp | 3 +++
3 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/src/plugin.cpp b/src/plugin.cpp
index 9fdacc8..54e78f2 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -323,47 +323,44 @@ void Plugin::set_view(View *v)
view->attach(*i);
}
-void Plugin::viewer_type_listener(const Glib::ustring viewer_type)
+void Plugin::viewer_type_listener(const Glib::ustring viewer_type,
+ bool force_update)
{
+ // Debug code
+ //std::cout << "Plugin::viewer_type_listener called!\n";
+
+ /* Setting viewer type, force_update allows resetting the view even when the
+ * type is already correct */
if (viewer_type == "curve")
{
- // Setting view to CurveView if it isnt already
- if (!dynamic_cast<CurveView *>(view.get()))
+ if (force_update || !dynamic_cast<CurveView *>(view.get()))
set_view(new CurveView);
}
else if (viewer_type == "bar")
{
- // Setting view to horizontal BarView if it isnt already
// It gets tricky here because them BarView can render 2 viewers.
// Thus, we much also check the oriententation
BarView *bar_view = dynamic_cast<BarView *>(view.get());
- if (!(bar_view && bar_view->is_horizontal()) )
+ if (force_update || !(bar_view && bar_view->is_horizontal()) )
set_view(new BarView);
}
else if (viewer_type == "vbar")
{
- // Setting view to vertical BarView if it isnt already
// Same situation as with "bar"
BarView *bar_view = dynamic_cast<BarView *>(view.get());
- if (!(bar_view && !bar_view->is_horizontal()) )
+ if (force_update || !(bar_view && !bar_view->is_horizontal()) )
set_view(new BarView(false));
}
else if (viewer_type == "text") {
-
- // Setting view to TextView if it isnt already
- if (!dynamic_cast<TextView *>(view.get()))
+ if (force_update || !dynamic_cast<TextView *>(view.get()))
set_view(new TextView);
}
else if (viewer_type == "flame") {
-
- // Setting view to FlameView if it isnt already
- if (!dynamic_cast<FlameView *>(view.get()))
+ if (force_update || !dynamic_cast<FlameView *>(view.get()))
set_view(new FlameView);
}
else if (viewer_type == "column") {
-
- // Setting view to ColumnView if it isnt already
- if (!dynamic_cast<ColumnView *>(view.get()))
+ if (force_update || !dynamic_cast<ColumnView *>(view.get()))
set_view(new ColumnView);
}
diff --git a/src/plugin.hpp b/src/plugin.hpp
index 3f71617..445b64e 100644
--- a/src/plugin.hpp
+++ b/src/plugin.hpp
@@ -85,7 +85,13 @@ public:
const CurveView::TextOverlayPosition get_viewer_text_overlay_position();
void set_viewer_text_overlay_position(CurveView::TextOverlayPosition
position);
- void viewer_type_listener(const Glib::ustring viewer_type);
+
+ /* Force update allows for this to be called to essentially reload the view
+ * e.g. when line colour is updated, despite the fact the viewer type hasn't
+ * changed */
+ void viewer_type_listener(const Glib::ustring viewer_type,
+ bool force_update=false);
+
void background_color_listener(unsigned int background_color);
void use_background_color_listener(gboolean use_background_color);
diff --git a/src/preferences-window.cpp b/src/preferences-window.cpp
index 122cb71..fdb1022 100644
--- a/src/preferences-window.cpp
+++ b/src/preferences-window.cpp
@@ -1043,6 +1043,9 @@ void PreferencesWindow::on_monitor_colorbutton_set(Gtk::ColorButton *colorbutton
Glib::ustring mon_dir = (*(*i)[mc.monitor]).get_settings_dir();
sync_conf_with_colorbutton(mon_dir, "color", colorbutton);
+
+ // Forcing an update of the view to have the new colour applied
+ plugin.viewer_type_listener(plugin.get_viewer_type(), true);
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list