[Xfce4-commits] [panel-plugins/xfce4-hardware-monitor-plugin] 23/29: Allow user to configure when monitor scales are grouped by type or not in the visualisation
noreply at xfce.org
noreply at xfce.org
Mon Dec 18 12:45:54 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 dab89691e719eb93b5b46a99a6a8e560e7d6a9d5
Author: OmegaPhil <OmegaPhil at startmail.com>
Date: Tue Dec 12 16:36:44 2017 +0000
Allow user to configure when monitor scales are grouped by type or not in the visualisation
---
src/curve-view.cpp | 11 +-
src/plugin.cpp | 15 ++-
src/plugin.hpp | 5 +-
src/preferences-window.cpp | 49 +++++++-
src/preferences-window.hpp | 5 +
src/ui.glade | 289 ++++++++++++++++++++++++++-------------------
6 files changed, 247 insertions(+), 127 deletions(-)
diff --git a/src/curve-view.cpp b/src/curve-view.cpp
index 3f4b74b..8214ea9 100644
--- a/src/curve-view.cpp
+++ b/src/curve-view.cpp
@@ -286,7 +286,8 @@ void CurveView::do_draw_loop()
monitor_data_needed = false, monitor_data_compact_needed = false,
text_overlay_enabled = plugin->get_viewer_text_overlay_enabled();
- /* Obtain maximum value of all curves in the view on a per monitor type basis,
+ /* Obtain maximum value of all curves in the view on a per monitor type basis
+ * but only when the user wants visualisations to be split by type,
* separately tracking fixed maxes incase all monitors are fixed. Graphs with
* fixed monitors are not supposed to be scaled, but the text overlay still
* needs to refer to a max if there are no normal monitors present
@@ -302,8 +303,12 @@ void CurveView::do_draw_loop()
Glib::ustring mon_type;
for (curve_iterator i = curves.begin(), end = curves.end(); i != end; ++i)
{
- // To get the real type, Monitor* must be dereferrenced too...
- mon_type = typeid(*((*i)->monitor)).name();
+ if (plugin->get_viewer_monitor_type_sync_enabled())
+ {
+ // To get the real type, Monitor* must be dereferenced too...
+ mon_type = typeid(*((*i)->monitor)).name();
+ }
+ else mon_type = "All the same";
// If the monitor type hasn't yet been recorded, zero the maxes
it = monitor_maxes.find(mon_type);
diff --git a/src/plugin.cpp b/src/plugin.cpp
index dfb5af0..4b4e0ea 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -167,7 +167,8 @@ Plugin::Plugin(XfcePanelPlugin *xfce_plugin)
viewer_text_overlay_separator(" "),
viewer_text_overlay_font(""),
viewer_text_overlay_color(0x000000FF),
- viewer_text_overlay_position(CurveView::top_left)
+ viewer_text_overlay_position(CurveView::top_left),
+ viewer_monitor_type_sync_enabled(true)
{
// Search for settings file
XfceRc* settings_ro = NULL;
@@ -206,6 +207,8 @@ Plugin::Plugin(XfcePanelPlugin *xfce_plugin)
"viewer_text_overlay_font", viewer_text_overlay_font.c_str());
viewer_text_overlay_color = xfce_rc_read_int_entry(settings_ro,
"viewer_text_overlay_color", viewer_text_overlay_color);
+ viewer_monitor_type_sync_enabled = xfce_rc_read_bool_entry(settings_ro,
+ "viewer_monitor_type_sync_enabled", viewer_monitor_type_sync_enabled);
// Enum is validated in set_viewer_text_overlay_position
CurveView::TextOverlayPosition text_overlay_position =
@@ -568,6 +571,16 @@ void Plugin::set_viewer_text_overlay_enabled(bool enabled)
viewer_text_overlay_enabled = enabled;
}
+bool Plugin::get_viewer_monitor_type_sync_enabled() const
+{
+ return viewer_monitor_type_sync_enabled;
+}
+
+void Plugin::set_viewer_monitor_type_sync_enabled(bool enabled)
+{
+ viewer_monitor_type_sync_enabled = enabled;
+}
+
const Glib::ustring Plugin::get_viewer_text_overlay_format_string()
{
return viewer_text_overlay_format_string;
diff --git a/src/plugin.hpp b/src/plugin.hpp
index 63c487c..f4aaa3f 100644
--- a/src/plugin.hpp
+++ b/src/plugin.hpp
@@ -71,6 +71,8 @@ public:
void set_viewer_size(const int size);
const Glib::ustring get_viewer_font();
void set_viewer_font(const Glib::ustring font_details);
+ bool get_viewer_monitor_type_sync_enabled() const;
+ void set_viewer_monitor_type_sync_enabled(bool enabled);
bool get_viewer_text_overlay_enabled() const;
void set_viewer_text_overlay_enabled(bool enabled);
const Glib::ustring get_viewer_text_overlay_format_string();
@@ -137,7 +139,8 @@ private:
// data
Glib::ustring icon_path, viewer_type, viewer_font;
- bool viewer_text_overlay_enabled, viewer_text_overlay_use_font;
+ bool viewer_monitor_type_sync_enabled, viewer_text_overlay_enabled,
+ viewer_text_overlay_use_font;
Glib::ustring viewer_text_overlay_format_string, viewer_text_overlay_separator,
viewer_text_overlay_font;
unsigned int viewer_text_overlay_color;
diff --git a/src/preferences-window.cpp b/src/preferences-window.cpp
index cc90ff1..4d3149e 100644
--- a/src/preferences-window.cpp
+++ b/src/preferences-window.cpp
@@ -146,6 +146,12 @@ PreferencesWindow::PreferencesWindow(Plugin &plugin_, monitor_seq monitors)
.connect(sigc::mem_fun(*this,
&PreferencesWindow::on_text_overlay_position_combobox_changed));
+ ui->get_widget("monitor_type_sync_checkbutton",
+ monitor_type_sync_checkbutton);
+ monitor_type_sync_checkbutton->signal_toggled()
+ .connect(sigc::mem_fun(*this,
+ &PreferencesWindow::on_monitor_type_sync_checkbutton_toggled));
+
ui->get_widget("background_colorbutton", background_colorbutton);
background_colorbutton->signal_color_set()
.connect(sigc::mem_fun(*this,
@@ -190,7 +196,7 @@ PreferencesWindow::PreferencesWindow(Plugin &plugin_, monitor_seq monitors)
ui->get_widget("monitor_options", monitor_options);
-
+
static MonitorColumns mc;
monitor_store = Gtk::ListStore::create(mc);
monitor_treeview->set_model(monitor_store);
@@ -261,6 +267,10 @@ PreferencesWindow::PreferencesWindow(Plugin &plugin_, monitor_seq monitors)
text_overlay_position_combobox->set_active(r);
}
+ // Monitor scale sharing per type in the view
+ if (plugin.get_viewer_monitor_type_sync_enabled())
+ monitor_type_sync_checkbutton->set_active();
+
// Make sure background colorbutton is grayed out
background_color_radiobutton->toggled();
@@ -939,6 +949,12 @@ void PreferencesWindow::on_text_overlay_position_combobox_changed()
}
}
+void PreferencesWindow::on_monitor_type_sync_checkbutton_toggled()
+{
+ // Saving
+ save_monitor_type_sync_enabled(monitor_type_sync_checkbutton->get_active());
+}
+
void PreferencesWindow::on_add_button_clicked()
{
Monitor *monitor = run_choose_monitor_window(Glib::ustring());
@@ -1137,6 +1153,37 @@ void PreferencesWindow::save_font_details(Glib::ustring font_details)
}
}
+void PreferencesWindow::save_monitor_type_sync_enabled(bool enabled)
+{
+ plugin.set_viewer_monitor_type_sync_enabled(enabled);
+
+ // Search for a writeable settings file, create one if it doesnt exist */
+ gchar* file = xfce_panel_plugin_save_location(plugin.xfce_plugin, true);
+
+ if (file)
+ {
+ // Opening setting file
+ XfceRc* settings_w = xfce_rc_simple_open(file, false);
+ g_free(file);
+
+ // Ensuring default group is in focus
+ xfce_rc_set_group(settings_w, NULL);
+
+ // Updating configuration
+ xfce_rc_write_bool_entry(settings_w, "monitor_type_sync_enabled", enabled);
+
+ // Close settings file
+ xfce_rc_close(settings_w);
+ }
+ else
+ {
+ // Unable to obtain writeable config file - informing user and exiting
+ std::cerr << _("Unable to obtain writeable config file path in order to"
+ " save monitor type sync enabled setting in "
+ "save_monitor_type_sync_enabled!\n");
+ }
+}
+
void PreferencesWindow::save_text_overlay_font_details(Glib::ustring font_details)
{
plugin.set_viewer_text_overlay_font(font_details);
diff --git a/src/preferences-window.hpp b/src/preferences-window.hpp
index d5d6854..4e69902 100644
--- a/src/preferences-window.hpp
+++ b/src/preferences-window.hpp
@@ -80,6 +80,8 @@ private:
*monitor_column_options, *monitor_flame_options;
Gtk::ColorButton *line_colorbutton, *bar_colorbutton, *vbar_colorbutton,
*column_colorbutton, *flame_colorbutton;
+
+ Gtk::CheckButton *monitor_type_sync_checkbutton;
class MonitorColumns: public Gtk::TreeModel::ColumnRecord
{
@@ -141,6 +143,8 @@ private:
void on_text_overlay_colorbutton_set();
void on_text_overlay_position_combobox_changed();
+ void on_monitor_type_sync_checkbutton_toggled();
+
void on_add_button_clicked();
void on_remove_button_clicked();
void on_change_button_clicked();
@@ -161,6 +165,7 @@ private:
void connect_monitor_colorbutton(Gtk::ColorButton *colorbutton);
void save_font_details(Glib::ustring font_details);
+ void save_monitor_type_sync_enabled(bool enabled);
void save_text_overlay_enabled(bool enabled);
void save_text_overlay_font_details(Glib::ustring font_details);
void save_text_overlay_format_string(const Glib::ustring format_string);
diff --git a/src/ui.glade b/src/ui.glade
index 8f6b5f0..1debdca 100644
--- a/src/ui.glade
+++ b/src/ui.glade
@@ -366,6 +366,21 @@ less than default priority</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkLabel" id="cpu_usage_tag_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -450,18 +465,6 @@ taken by the monitor</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<object class="GtkCheckButton" id="cpu_usage_fixed_max_checkbutton">
<property name="label" translatable="yes">Fixed max (100%)</property>
<property name="visible">True</property>
@@ -476,9 +479,6 @@ is fixed to a maximum value of 100%</property>
<property name="bottom_attach">2</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
</object>
<packing>
<property name="expand">True</property>
@@ -566,6 +566,18 @@ is fixed to a maximum value of 100%</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkLabel" id="load_average_tag_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -650,18 +662,6 @@ taken by the monitor</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<object class="GtkCheckButton" id="load_average_fixed_max_checkbutton">
<property name="label" translatable="yes">Fixed max at</property>
<property name="visible">True</property>
@@ -846,6 +846,21 @@ value</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkLabel" id="disk_usage_tag_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -933,18 +948,6 @@ taken by the monitor</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<object class="GtkCheckButton" id="disk_usage_fixed_max_checkbutton">
<property name="label" translatable="yes">Fixed max
(size of volume)</property>
@@ -962,9 +965,6 @@ on the size of the volume</property>
<property name="bottom_attach">2</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
</object>
</child>
<child type="label">
@@ -1122,6 +1122,18 @@ on the size of the volume</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkLabel" id="disk_stats_tag_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1209,18 +1221,6 @@ taken by the monitor</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<object class="GtkCheckButton" id="disk_stats_fixed_max_checkbutton">
<property name="label" translatable="yes">Fixed max at</property>
<property name="visible">True</property>
@@ -1337,6 +1337,21 @@ maximum value</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkLabel" id="swap_tag_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1421,18 +1436,6 @@ taken by the monitor</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<object class="GtkCheckButton" id="swap_fixed_max_checkbutton">
<property name="label" translatable="yes">Fixed max
(available swap)</property>
@@ -1450,9 +1453,6 @@ on the amount of swap available</property>
<property name="bottom_attach">2</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
</object>
</child>
<child type="label">
@@ -1536,6 +1536,21 @@ on the amount of swap available</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkLabel" id="memory_tag_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1620,18 +1635,6 @@ taken by the monitor</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<object class="GtkCheckButton" id="memory_fixed_max_checkbutton">
<property name="label" translatable="yes">Fixed max
(installed memory)</property>
@@ -1649,9 +1652,6 @@ the amount of RAM available</property>
<property name="bottom_attach">2</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
</object>
</child>
<child type="label">
@@ -1830,6 +1830,18 @@ the amount of RAM available</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkLabel" id="network_load_tag_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1914,18 +1926,6 @@ taken by the monitor</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<object class="GtkCheckButton" id="network_load_fixed_max_checkbutton">
<property name="label" translatable="yes">Fixed max at</property>
<property name="visible">True</property>
@@ -2128,6 +2128,18 @@ is fixed to a user-specified maximum value</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkLabel" id="temperature_tag_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -2212,18 +2224,6 @@ taken by the monitor</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<object class="GtkCheckButton" id="temperature_fixed_max_checkbutton">
<property name="label" translatable="yes">Fixed max at</property>
<property name="visible">True</property>
@@ -2353,6 +2353,18 @@ value</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkLabel" id="fan_speed_tag_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -2437,18 +2449,6 @@ taken by the monitor</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<object class="GtkCheckButton" id="fan_fixed_max_checkbutton">
<property name="label" translatable="yes">Fixed max at</property>
<property name="visible">True</property>
@@ -4016,7 +4016,7 @@ view</property>
<object class="GtkVBox" id="text_overlay_outer_vbox">
<property name="can_focus">False</property>
<child>
- <object class="GtkLabel" id="Text Overlay">
+ <object class="GtkLabel" id="text_overlay_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@@ -4264,6 +4264,53 @@ individual monitor values</property>
<property name="position">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkVBox" id="advanced_outer_vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkExpander" id="advanced_expander">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkCheckButton" id="monitor_type_sync_checkbutton">
+ <property name="label" translatable="yes">Monitors of the same type share the same scale
+(takes effect when the monitors next update)</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Maxima are shared for the same type of monitor,
+so a change in the maximum value for one
+network load monitor (e.g.) will result in any other
+network load monitors changing their scale
+appropriately</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="advanced_expander_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Advanced</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">1</property>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list