[Xfce4-commits] [panel-plugins/xfce4-hardware-monitor-plugin] 01/01: Implement changes recommended by clang static analysis
noreply at xfce.org
noreply at xfce.org
Fri Jan 12 18:51:39 CET 2018
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 930810d241121e2ec170c813e77ef60f4a96d3c4
Author: OmegaPhil <OmegaPhil at startmail.com>
Date: Fri Jan 12 17:51:33 2018 +0000
Implement changes recommended by clang static analysis
---
src/bar-view.cpp | 32 ++--
src/bar-view.hpp | 9 +-
src/canvas-view.cpp | 68 +++----
src/canvas-view.hpp | 2 +-
src/choose-monitor-window.cpp | 52 ++---
src/choose-monitor-window.hpp | 2 +-
src/column-view.cpp | 28 +--
src/column-view.hpp | 6 +-
src/curve-view.cpp | 22 +--
src/curve-view.hpp | 4 +-
src/flame-view.cpp | 28 ++-
src/flame-view.hpp | 7 +-
src/i18n.hpp | 2 +-
src/monitor-impls.cpp | 427 ++++++++++++++++++++----------------------
src/monitor-impls.hpp | 91 +++++----
src/monitor.hpp | 6 +-
src/plugin.cpp | 60 +++---
src/plugin.hpp | 14 +-
src/preferences-window.cpp | 43 +++--
src/preferences-window.hpp | 18 +-
src/text-view.cpp | 18 +-
src/text-view.hpp | 2 +-
src/value-history.cpp | 4 +-
src/value-history.hpp | 2 +-
src/view.cpp | 7 +-
src/view.hpp | 6 +-
26 files changed, 465 insertions(+), 495 deletions(-)
diff --git a/src/bar-view.cpp b/src/bar-view.cpp
index 688ba03..ad775f2 100644
--- a/src/bar-view.cpp
+++ b/src/bar-view.cpp
@@ -26,10 +26,10 @@
#include "monitor.hpp"
-Bar::Bar(Monitor *m, unsigned int c, bool horizontal)
- : monitor(m), old_value(0), new_value(0), fill_color(c)
+Bar::Bar(Monitor *monitor_, unsigned int fill_color_, bool horizontal_)
+ : monitor(monitor_), old_value(0), new_value(0), fill_color(fill_color_),
+ horizontal(horizontal_)
{
- this->horizontal = horizontal;
}
Bar::~Bar()
@@ -68,9 +68,8 @@ unsigned int outlineified(unsigned int color)
return (r << 24) | (g << 16) | (b << 8) | (color & 0xff);
}
-void Bar::draw(Gnome::Canvas::Canvas &canvas,
- Plugin *plugin, int width, int height, int no, int total,
- double time_offset, double max)
+void Bar::draw(Gnome::Canvas::Canvas &canvas, int width, int height, int no,
+ int total, double time_offset, double max)
{
unsigned int outline_color = outlineified(fill_color);
@@ -192,10 +191,9 @@ double Bar::get_max_value()
// class BarView
//
-BarView::BarView(bool _horizontal)
- : CanvasView(false), draws_since_update(0)
+BarView::BarView(Plugin &plugin_, bool horizontal_)
+ : CanvasView(false, plugin_), draws_since_update(0), horizontal(horizontal_)
{
- horizontal = _horizontal;
}
BarView::~BarView()
@@ -224,7 +222,7 @@ void BarView::do_attach(Monitor *monitor)
Glib::ustring dir = monitor->get_settings_dir();
// Search for settings file
- gchar* file = xfce_panel_plugin_lookup_rc_file(plugin->xfce_plugin);
+ gchar* file = xfce_panel_plugin_lookup_rc_file(plugin.xfce_plugin);
if (file)
{
@@ -239,7 +237,7 @@ void BarView::do_attach(Monitor *monitor)
if (xfce_rc_has_entry(settings_ro, "color"))
{
fill_color = xfce_rc_read_int_entry(settings_ro, "color",
- plugin->get_fg_color());
+ plugin.get_fg_color());
color_missing = false;
}
@@ -252,10 +250,10 @@ void BarView::do_attach(Monitor *monitor)
if (color_missing)
{
// Setting color
- fill_color = plugin->get_fg_color();
+ fill_color = plugin.get_fg_color();
// Search for a writeable settings file, create one if it doesnt exist
- file = xfce_panel_plugin_save_location(plugin->xfce_plugin, true);
+ file = xfce_panel_plugin_save_location(plugin.xfce_plugin, true);
if (file)
{
@@ -285,13 +283,15 @@ void BarView::do_attach(Monitor *monitor)
void BarView::do_detach(Monitor *monitor)
{
for (bar_iterator i = bars.begin(), end = bars.end(); i != end; ++i)
+ {
if ((*i)->monitor == monitor) {
delete *i;
bars.erase(i);
return;
}
+ }
- g_assert_not_reached();
+ g_assert_not_reached(); // NOLINT
}
void BarView::do_draw_loop()
@@ -311,8 +311,10 @@ void BarView::do_draw_loop()
* second is the max */
for (std::list<std::pair<Bar*, double>>::iterator i = bars_and_maxes.begin(),
end = bars_and_maxes.end(); i != end; ++i)
- i->first->draw(*canvas, plugin, width(), height(), no++, total, time_offset,
+ {
+ i->first->draw(*canvas, width(), height(), no++, total, time_offset,
i->second);
+ }
++draws_since_update;
}
diff --git a/src/bar-view.hpp b/src/bar-view.hpp
index 762935b..6b524d8 100644
--- a/src/bar-view.hpp
+++ b/src/bar-view.hpp
@@ -38,12 +38,11 @@
class Bar
{
public:
- Bar(Monitor *monitor, unsigned int fill_color, bool horizontal = false);
+ Bar(Monitor *monitor_, unsigned int fill_color_, bool horizontal_ = false);
~Bar();
- void draw(Gnome::Canvas::Canvas &canvas,
- Plugin *plugin, int width, int height, int no, int total,
- double time_offset, double max);
+ void draw(Gnome::Canvas::Canvas &canvas, int width, int height, int no,
+ int total, double time_offset, double max);
double get_max_value();
void update();
@@ -61,7 +60,7 @@ private:
class BarView: public CanvasView
{
public:
- BarView(bool horizontal = true);
+ BarView(Plugin &plugin_, bool horizontal_ = true);
~BarView();
virtual bool is_horizontal();
diff --git a/src/canvas-view.cpp b/src/canvas-view.cpp
index f4c4cd9..f5f4fd1 100644
--- a/src/canvas-view.cpp
+++ b/src/canvas-view.cpp
@@ -33,17 +33,17 @@
#include "ucompose.hpp"
-int const CanvasView::draw_interval = 100;
-int const CanvasView::draw_iterations = 10;
+int const CanvasView::draw_interval = 100; // NOLINT - thinks static initialisation is redundant?
+int const CanvasView::draw_iterations = 10; // NOLINT - thinks static initialisation is redundant?
// Text overlay format string substitution codes
-const Glib::ustring CanvasView::monitor_full = "%M";
-const Glib::ustring CanvasView::monitor_compact = "%m";
-const Glib::ustring CanvasView::graph_max_full = "%A";
-const Glib::ustring CanvasView::graph_max_compact = "%a";
+const Glib::ustring CanvasView::monitor_full = "%M"; // NOLINT - intialisation may throw
+const Glib::ustring CanvasView::monitor_compact = "%m"; // NOLINT - intialisation may throw
+const Glib::ustring CanvasView::graph_max_full = "%A"; // NOLINT - intialisation may throw
+const Glib::ustring CanvasView::graph_max_compact = "%a"; // NOLINT - intialisation may throw
-CanvasView::CanvasView(bool keeps_history)
- : View(keeps_history), text_overlay(NULL)
+CanvasView::CanvasView(bool keeps_history, Plugin &plugin_)
+ : View(keeps_history, plugin_), text_overlay(NULL), size(0)
{
}
@@ -57,7 +57,7 @@ void CanvasView::do_display()
{
// canvas creation magic
canvas.reset(new Gnome::Canvas::CanvasAA);
- plugin->get_container().add(*canvas);
+ plugin.get_container().add(*canvas);
draw_timer = Glib::signal_timeout()
.connect(sigc::mem_fun(*this, &CanvasView::draw_loop), draw_interval);
@@ -72,11 +72,11 @@ void CanvasView::do_update()
//std::cout << "In CanvasView::do_update!" << std::endl;
// Size is maintained in plugin
- size = plugin->get_viewer_size();
+ size = plugin.get_viewer_size();
/* Ensure that the widget's requested size is being honoured on every
* call */
- plugin->set_viewer_size(size);
+ plugin.set_viewer_size(size);
// Ensure the canvas is shown
resize_canvas();
@@ -117,10 +117,7 @@ int CanvasView::width() const
<< ((plugin->horizontal()) ? size : plugin->get_size())
<< std::endl;*/
- if (plugin->horizontal())
- return size;
- else
- return plugin->get_size();
+ return (plugin.horizontal()) ? size : plugin.get_size();
}
int CanvasView::height() const
@@ -130,10 +127,7 @@ int CanvasView::height() const
<< ((plugin->horizontal()) ? plugin->get_size() : size)
<< std::endl;*/
- if (plugin->horizontal())
- return plugin->get_size();
- else
- return size;
+ return (plugin.horizontal()) ? plugin.get_size(): size;
}
void CanvasView::resize_canvas()
@@ -177,10 +171,10 @@ std::list<std::pair<T*, double>> CanvasView::process_mon_maxes_text_overlay(
Glib::ustring max_formatted, max_formatted_compact, monitor_data,
monitor_data_compact, overlay_text, per_type_overlay_text,
text_overlay_format_string, tag_string,
- separator_string = plugin->get_viewer_text_overlay_separator();
+ separator_string = plugin.get_viewer_text_overlay_separator();
bool graph_max_needed = false, graph_max_compact_needed = false,
monitor_data_needed = false, monitor_data_compact_needed = false,
- text_overlay_enabled = plugin->get_viewer_text_overlay_enabled();
+ text_overlay_enabled = plugin.get_viewer_text_overlay_enabled();
/* Obtain maximum value of all curves/flames/bars etc in the view on a per
* monitor type basis but only when the user wants visualisations to be split
@@ -200,7 +194,7 @@ std::list<std::pair<T*, double>> CanvasView::process_mon_maxes_text_overlay(
for (typename std::list<T*>::iterator i = graph_elements.begin(),
end = graph_elements.end(); i != end; ++i)
{
- if (plugin->get_viewer_monitor_type_sync_enabled())
+ if (plugin.get_viewer_monitor_type_sync_enabled())
{
// To get the real type, Monitor* must be dereferenced too...
mon_type = typeid(*((*i)->monitor)).name();
@@ -212,10 +206,10 @@ std::list<std::pair<T*, double>> CanvasView::process_mon_maxes_text_overlay(
if (it == monitor_maxes.end())
monitor_maxes[mon_type] = std::make_pair(0, 0);
- if (!(*i)->monitor->fixed_max()
+ if (!(*i)->monitor->has_fixed_max()
&& (*i)->get_max_value() > monitor_maxes[mon_type].first)
monitor_maxes[mon_type].first = (*i)->get_max_value();
- else if ((*i)->monitor->fixed_max()
+ else if ((*i)->monitor->has_fixed_max()
&& (*i)->monitor->max() > monitor_maxes[mon_type].second)
{
// Debug code
@@ -254,7 +248,7 @@ std::list<std::pair<T*, double>> CanvasView::process_mon_maxes_text_overlay(
* type-based loop is still the best way */
if (text_overlay_enabled)
{
- text_overlay_format_string = plugin->get_viewer_text_overlay_format_string();
+ text_overlay_format_string = plugin.get_viewer_text_overlay_format_string();
/* Glib::ustring::npos is the strange way C++ flags as a failure to find a
* string */
@@ -403,19 +397,19 @@ std::list<std::pair<T*, double>> CanvasView::process_mon_maxes_text_overlay(
/* Setting/fixing changed font and colour - doing it here since the
* CanvasView updates so frequently that its not worth also setting it
* directly from the UI etc */
- Glib::ustring font_details = plugin->get_viewer_text_overlay_font();
+ Glib::ustring font_details = plugin.get_viewer_text_overlay_font();
if (font_details.empty())
font_details = "Sans 8";
if (text_overlay->property_font() != font_details)
text_overlay->property_font() = font_details;
- unsigned int color = plugin->get_viewer_text_overlay_color();
+ unsigned int color = plugin.get_viewer_text_overlay_color();
if (text_overlay->property_fill_color_rgba() != color)
text_overlay->property_fill_color_rgba() = color;
// Positioning text
int x, y;
- text_overlay_calc_position(x, y, plugin->get_viewer_text_overlay_position());
+ text_overlay_calc_position(x, y, plugin.get_viewer_text_overlay_position());
if (text_overlay->property_x() != x)
text_overlay->property_x() = x;
if (text_overlay->property_y() != y)
@@ -441,33 +435,33 @@ void CanvasView::text_overlay_calc_position(int& x, int& y,
break;
case top_center:
- x = (plugin->get_width() - text_overlay->property_text_width()) / 2;
+ x = (plugin.get_width() - text_overlay->property_text_width()) / 2;
y = 0;
break;
case top_right:
- x = plugin->get_width() - text_overlay->property_text_width();
+ x = plugin.get_width() - text_overlay->property_text_width();
y = 0;
break;
case center:
- x = (plugin->get_width() - text_overlay->property_text_width()) / 2;
- y = (plugin->get_height() - text_overlay->property_text_height()) / 2;
+ x = (plugin.get_width() - text_overlay->property_text_width()) / 2;
+ y = (plugin.get_height() - text_overlay->property_text_height()) / 2;
break;
case bottom_left:
x = 0;
- y = plugin->get_height() - text_overlay->property_text_height();
+ y = plugin.get_height() - text_overlay->property_text_height();
break;
case bottom_center:
- x = (plugin->get_width() - text_overlay->property_text_width()) / 2;
- y = plugin->get_height() - text_overlay->property_text_height();
+ x = (plugin.get_width() - text_overlay->property_text_width()) / 2;
+ y = plugin.get_height() - text_overlay->property_text_height();
break;
case bottom_right:
- x = plugin->get_width() - text_overlay->property_text_width();
- y = plugin->get_height() - text_overlay->property_text_height();
+ x = plugin.get_width() - text_overlay->property_text_width();
+ y = plugin.get_height() - text_overlay->property_text_height();
break;
default:
diff --git a/src/canvas-view.hpp b/src/canvas-view.hpp
index c6137dd..5cedafb 100644
--- a/src/canvas-view.hpp
+++ b/src/canvas-view.hpp
@@ -49,7 +49,7 @@ public:
NUM_TEXT_OVERLAY_POSITIONS
};
- CanvasView(bool keeps_history);
+ CanvasView(bool keeps_history, Plugin &plugin_);
~CanvasView();
/* Used to locate monitor type of interest in monitor_maxes during
diff --git a/src/choose-monitor-window.cpp b/src/choose-monitor-window.cpp
index 91dc52c..8028dad 100644
--- a/src/choose-monitor-window.cpp
+++ b/src/choose-monitor-window.cpp
@@ -33,10 +33,10 @@
// Static intialisation
-ChooseMonitorWindow::NetworkInterfacesNamesCols ChooseMonitorWindow::nc;
+ChooseMonitorWindow::NetworkInterfacesNamesCols ChooseMonitorWindow::nc; // NOLINT - initialisation may throw
-ChooseMonitorWindow::ChooseMonitorWindow(Plugin& plugin, Gtk::Window &parent)
- : plugin_priv(plugin)
+ChooseMonitorWindow::ChooseMonitorWindow(Plugin &plugin_, Gtk::Window &parent) // NOLINT - thinks all the private variables aren't initialised, can't tell with the get_widget usage
+ : plugin(plugin_)
{
// Now we are forced to use top-level widgets this is much more over the top...
std::vector<Glib::ustring> objects(22);
@@ -438,7 +438,7 @@ ChooseMonitorWindow::ChooseMonitorWindow(Plugin& plugin, Gtk::Window &parent)
(*iter)[nc.interface_type] = NetworkLoadMonitor::
interface_type_to_string(interface_type, false);
(*iter)[nc.interface_name] = NetworkLoadMonitor::
- get_interface_name(interface_type, plugin_priv.xfce_plugin);
+ get_interface_name(interface_type, plugin.xfce_plugin);
}
// Setup network direction combobox
@@ -567,7 +567,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
{
// Set up monitor
// Search for settings file
- gchar* file = xfce_panel_plugin_lookup_rc_file(plugin_priv.xfce_plugin);
+ gchar* file = xfce_panel_plugin_lookup_rc_file(plugin.xfce_plugin);
if (file)
{
// Loading settings
@@ -633,8 +633,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
Glib::ustring mount_dir = xfce_rc_read_entry(settings_ro,
"mount_dir", "");
mount_dir_entry->set_text(mount_dir);
- bool show_free = xfce_rc_read_bool_entry(settings_ro,
- "show_free", false);
+ bool show_free = xfce_rc_read_bool_entry(settings_ro, "show_free", false);
show_free_checkbutton->set_active(show_free);
disk_usage_tag->set_text(tag);
disk_usage_text_overlay_checkbutton->set_active(add_to_text_overlay);
@@ -702,7 +701,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
disk_stats_max_spinbutton->set_value(max);
// Debug code
- /*plugin_priv.debug_log(
+ /*plugin.debug_log(
String::ucompose("XFCE4 Hardware Monitor Plugin: "
"ChooseMonitorWindow::run, disk stats monitor max "
"value: %1", max));*/
@@ -802,7 +801,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
direction = NetworkLoadMonitor::all_data;
}
- switch (direction)
+ switch (direction) // NOLINT - complaining about NUM_DIRECTIONS
{
case NetworkLoadMonitor::all_data:
network_direction_combobox->set_active(0);
@@ -986,7 +985,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
cpu_usage_incl_low_checkbutton->get_active(),
cpu_usage_incl_iowait_checkbutton->get_active(),
cpu_tag->get_text(),
- cpu_usage_text_overlay_checkbutton->get_active(), plugin_priv);
+ cpu_usage_text_overlay_checkbutton->get_active(), plugin);
else
mon = new CpuUsageMonitor(
cpu_usage_fixed_max_checkbutton->get_active(),
@@ -994,7 +993,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
cpu_usage_incl_low_checkbutton->get_active(),
cpu_usage_incl_iowait_checkbutton->get_active(),
cpu_tag->get_text(),
- cpu_usage_text_overlay_checkbutton->get_active(), plugin_priv);
+ cpu_usage_text_overlay_checkbutton->get_active(), plugin);
}
else if (memory_usage_radiobutton->get_active())
{
@@ -1002,7 +1001,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
int(memory_refresh_delay_spinbutton->get_value() * 1000),
memory_fixed_max_checkbutton->get_active(),
memory_usage_tag->get_text(),
- memory_text_overlay_checkbutton->get_active(), plugin_priv);
+ memory_text_overlay_checkbutton->get_active(), plugin);
}
else if (swap_usage_radiobutton->get_active())
{
@@ -1010,7 +1009,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
int(swap_refresh_delay_spinbutton->get_value() * 1000),
swap_fixed_max_checkbutton->get_active(),
swap_usage_tag->get_text(),
- swap_text_overlay_checkbutton->get_active(), plugin_priv);
+ swap_text_overlay_checkbutton->get_active(), plugin);
}
else if (load_average_radiobutton->get_active())
{
@@ -1019,7 +1018,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
load_average_fixed_max_checkbutton->get_active(),
load_average_max_spinbutton->get_value(),
load_average_tag->get_text(),
- load_average_text_overlay_checkbutton->get_active(), plugin_priv);
+ load_average_text_overlay_checkbutton->get_active(), plugin);
}
else if (disk_usage_radiobutton->get_active())
{
@@ -1054,7 +1053,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
int(disk_usage_refresh_delay_spinbutton->get_value() * 1000),
disk_usage_fixed_max_checkbutton->get_active(),
disk_usage_tag->get_text(),
- disk_usage_text_overlay_checkbutton->get_active(), plugin_priv);
+ disk_usage_text_overlay_checkbutton->get_active(), plugin);
}
else if (disk_stats_radiobutton->get_active())
{
@@ -1098,8 +1097,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
disk_stats_fixed_max_checkbutton->get_active(),
disk_stats_max_spinbutton->get_value(),
disk_stats_tag->get_text(),
- disk_stats_text_overlay_checkbutton->get_active(),
- plugin_priv);
+ disk_stats_text_overlay_checkbutton->get_active(), plugin);
}
else if (network_load_radiobutton->get_active())
{
@@ -1146,7 +1144,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
network_load_fixed_max_checkbutton->get_active(),
network_load_max_spinbutton->get_value(),
network_load_tag->get_text(),
- network_load_text_overlay_checkbutton->get_active(), plugin_priv);
+ network_load_text_overlay_checkbutton->get_active(), plugin);
}
else if (temperature_radiobutton->get_active())
{
@@ -1155,7 +1153,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
temperature_fixed_max_checkbutton->get_active(),
temperature_max_spinbutton->get_value(),
temperature_tag->get_text(),
- temperature_text_overlay_checkbutton->get_active(), plugin_priv);
+ temperature_text_overlay_checkbutton->get_active(), plugin);
}
else if (fan_speed_radiobutton->get_active())
{
@@ -1163,7 +1161,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
int(fan_speed_refresh_delay_spinbutton->get_value() * 1000),
fan_fixed_max_checkbutton->get_active(),
fan_max_spinbutton->get_value(), fan_speed_tag->get_text(),
- fan_text_overlay_checkbutton->get_active(), plugin_priv);
+ fan_text_overlay_checkbutton->get_active(), plugin);
}
else if (generic_radiobutton->get_active())
{
@@ -1180,8 +1178,10 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
dir = GenericMonitor::positive;
else if (generic_change_in_value_negative_radiobutton->get_active())
dir = GenericMonitor::negative;
- else if (generic_change_in_value_both_radiobutton->get_active())
- dir = GenericMonitor::both;
+
+ /* generic_change_in_value_both_radiobutton - done it this way to satisfy
+ * clang */
+ else dir = GenericMonitor::both;
// Making sure that the path passed is valid
if (!Glib::file_test(file_path, Glib::FILE_TEST_EXISTS))
@@ -1303,7 +1303,7 @@ Monitor *ChooseMonitorWindow::run(const Glib::ustring &mon_dir)
generic_max_spinbutton->get_value(),
generic_tag->get_text(),
generic_text_overlay_checkbutton->get_active(),
- plugin_priv);
+ plugin);
}
return mon;
@@ -1432,7 +1432,7 @@ void ChooseMonitorWindow::on_network_interface_name_edited(
// Setting and saving the real value
NetworkLoadMonitor::set_interface_name(inter_type, new_text);
- gchar* file = xfce_panel_plugin_save_location(plugin_priv.xfce_plugin, true);
+ gchar* file = xfce_panel_plugin_save_location(plugin.xfce_plugin, true);
if (file)
{
XfceRc* settings_w = xfce_rc_simple_open(file, false);
@@ -1475,7 +1475,7 @@ void ChooseMonitorWindow::on_network_interfaces_restore_defaults_button_clicked(
}
// Updating storage vector and saving
- gchar* file = xfce_panel_plugin_save_location(plugin_priv.xfce_plugin, true);
+ gchar* file = xfce_panel_plugin_save_location(plugin.xfce_plugin, true);
if (file)
{
XfceRc* settings_w = xfce_rc_simple_open(file, false);
@@ -1552,7 +1552,7 @@ void ChooseMonitorWindow::on_generic_refresh_delay_default_button_clicked()
GenericMonitor::update_interval_default / 1000);
}
-bool ChooseMonitorWindow::on_closed(GdkEventAny *)
+bool ChooseMonitorWindow::on_closed(GdkEventAny *) // NOLINT - unused parameter
{
window->hide();
return false;
diff --git a/src/choose-monitor-window.hpp b/src/choose-monitor-window.hpp
index 11a0011..9985296 100644
--- a/src/choose-monitor-window.hpp
+++ b/src/choose-monitor-window.hpp
@@ -134,7 +134,7 @@ private:
*generic_change_in_value_negative_radiobutton,
*generic_change_in_value_both_radiobutton;
- Plugin& plugin_priv;
+ Plugin& plugin;
// For disk statistics device name combobox
class DiskStatsDeviceNameCols: public Gtk::TreeModel::ColumnRecord
diff --git a/src/column-view.cpp b/src/column-view.cpp
index 3b9a625..a216988 100644
--- a/src/column-view.cpp
+++ b/src/column-view.cpp
@@ -26,8 +26,8 @@
#include "pixbuf-drawing.hpp"
-ColumnGraph::ColumnGraph(Monitor *m, unsigned int c)
- : monitor(m), value_history(m), remaining_draws(0), color(c)
+ColumnGraph::ColumnGraph(Monitor *monitor_, unsigned int color_)
+ : monitor(monitor_), value_history(monitor_), remaining_draws(0), color(color_)
{
}
@@ -40,8 +40,8 @@ void ColumnGraph::update(unsigned int max_samples)
remaining_draws = CanvasView::draw_iterations;
}
-void ColumnGraph::draw(Gnome::Canvas::Canvas &canvas, Plugin *plugin, int width,
- int height, double max)
+void ColumnGraph::draw(Gnome::Canvas::Canvas &canvas, int width, int height,
+ double max)
{
if (remaining_draws <= 0)
return;
@@ -77,7 +77,7 @@ void ColumnGraph::draw(Gnome::Canvas::Canvas &canvas, Plugin *plugin, int width,
* the monitor has a fixed max (variable maxes should not normally be used
* with monitors like the CPU usage monitor, although the user can configure
* this nowadays) */
- if (monitor->fixed_max())
+ if (monitor->has_fixed_max())
max = monitor->max();
if (max <= 0)
@@ -145,10 +145,10 @@ double ColumnGraph::get_max_value()
// class ColumnView
//
-int const ColumnView::pixels_per_sample = 2;
+int const ColumnView::pixels_per_sample = 2; // NOLINT - thinks static initialisation is a dupe declaration
-ColumnView::ColumnView()
- : CanvasView(true)
+ColumnView::ColumnView(Plugin &plugin_)
+ : CanvasView(true, plugin_)
{
}
@@ -179,7 +179,7 @@ void ColumnView::do_attach(Monitor *monitor)
Glib::ustring dir = monitor->get_settings_dir();
// Search for settings file
- gchar* file = xfce_panel_plugin_lookup_rc_file(plugin->xfce_plugin);
+ gchar* file = xfce_panel_plugin_lookup_rc_file(plugin.xfce_plugin);
if (file)
{
@@ -192,7 +192,7 @@ void ColumnView::do_attach(Monitor *monitor)
if (xfce_rc_has_entry(settings_ro, "color"))
{
color = xfce_rc_read_int_entry(settings_ro, "color",
- plugin->get_fg_color());
+ plugin.get_fg_color());
color_missing = false;
}
@@ -205,10 +205,10 @@ void ColumnView::do_attach(Monitor *monitor)
if (color_missing)
{
// Setting color
- color = plugin->get_fg_color();
+ color = plugin.get_fg_color();
// Search for a writeable settings file, create one if it doesnt exist
- file = xfce_panel_plugin_save_location(plugin->xfce_plugin, true);
+ file = xfce_panel_plugin_save_location(plugin.xfce_plugin, true);
if (file)
{
@@ -244,7 +244,7 @@ void ColumnView::do_detach(Monitor *monitor)
return;
}
- g_assert_not_reached();
+ g_assert_not_reached(); // NOLINT
}
void ColumnView::do_draw_loop()
@@ -259,5 +259,5 @@ void ColumnView::do_draw_loop()
* ColumnGraph, second is the max */
for (std::list<std::pair<ColumnGraph*, double>>::iterator i =
columns_and_maxes.begin(), end = columns_and_maxes.end(); i != end; ++i)
- i->first->draw(*canvas, plugin, width(), height(), i->second);
+ i->first->draw(*canvas, width(), height(), i->second);
}
diff --git a/src/column-view.hpp b/src/column-view.hpp
index 945e433..1eec747 100644
--- a/src/column-view.hpp
+++ b/src/column-view.hpp
@@ -40,11 +40,11 @@
class ColumnGraph
{
public:
- ColumnGraph(Monitor *monitor, unsigned int color);
+ ColumnGraph(Monitor *monitor_, unsigned int color_);
void update(unsigned int max_samples); // Gather info from monitor
void draw(Gnome::Canvas::Canvas &canvas, // Redraw columns on canvas
- Plugin *plugin, int width, int height, double max);
+ int width, int height, double max);
double get_max_value(); // Used to get overall max across columns
Monitor *monitor;
@@ -62,7 +62,7 @@ private:
class ColumnView: public CanvasView
{
public:
- ColumnView();
+ ColumnView(Plugin &plugin_);
~ColumnView();
static int const pixels_per_sample;
diff --git a/src/curve-view.cpp b/src/curve-view.cpp
index b449aa5..190f99e 100644
--- a/src/curve-view.cpp
+++ b/src/curve-view.cpp
@@ -32,8 +32,8 @@
#include "value-history.hpp"
-Curve::Curve(Monitor *m, unsigned int c)
- : monitor(m), value_history(m), remaining_draws(0), color(c)
+Curve::Curve(Monitor *monitor_, unsigned int color_)
+ : monitor(monitor_), value_history(monitor_), remaining_draws(0), color(color_)
{}
void Curve::update(unsigned int max_samples)
@@ -89,7 +89,7 @@ void Curve::draw(Gnome::Canvas::Canvas &canvas, int width, int height,
* the monitor has a fixed max (variable maxes should not normally be used
* with monitors like the CPU usage monitor, although the user can configure
* this nowadays) */
- if (monitor->fixed_max())
+ if (monitor->has_fixed_max())
max = monitor->max();
if (max <= 0)
@@ -141,10 +141,10 @@ double Curve::get_max_value()
// class CurveView
//
-int const CurveView::pixels_per_sample = 2;
+int const CurveView::pixels_per_sample = 2; // NOLINT - thinks static intialisation is a dupe declaration
-CurveView::CurveView()
- : CanvasView(true)
+CurveView::CurveView(Plugin &plugin_)
+ : CanvasView(true, plugin_)
{
}
@@ -174,7 +174,7 @@ void CurveView::do_attach(Monitor *monitor)
Glib::ustring dir = monitor->get_settings_dir();
// Search for settings file
- gchar* file = xfce_panel_plugin_lookup_rc_file(plugin->xfce_plugin);
+ gchar* file = xfce_panel_plugin_lookup_rc_file(plugin.xfce_plugin);
if (file)
{
@@ -187,7 +187,7 @@ void CurveView::do_attach(Monitor *monitor)
if (xfce_rc_has_entry(settings_ro, "color"))
{
color = xfce_rc_read_int_entry(settings_ro, "color",
- plugin->get_fg_color());
+ plugin.get_fg_color());
color_missing = false;
}
@@ -200,10 +200,10 @@ void CurveView::do_attach(Monitor *monitor)
if (color_missing)
{
// Setting color
- color = plugin->get_fg_color();
+ color = plugin.get_fg_color();
// Search for a writeable settings file, create one if it doesnt exist
- file = xfce_panel_plugin_save_location(plugin->xfce_plugin, true);
+ file = xfce_panel_plugin_save_location(plugin.xfce_plugin, true);
if (file)
{
@@ -239,7 +239,7 @@ void CurveView::do_detach(Monitor *monitor)
return;
}
- g_assert_not_reached();
+ g_assert_not_reached(); // NOLINT
}
void CurveView::do_draw_loop()
diff --git a/src/curve-view.hpp b/src/curve-view.hpp
index e18725f..b9369ee 100644
--- a/src/curve-view.hpp
+++ b/src/curve-view.hpp
@@ -38,7 +38,7 @@
class Curve
{
public:
- Curve(Monitor *monitor, unsigned int color);
+ Curve(Monitor *monitor_, unsigned int color_);
void update(unsigned int max_samples); // Gather info from monitor
void draw(Gnome::Canvas::Canvas &canvas, // Redraw curve on canvas
@@ -59,7 +59,7 @@ private:
class CurveView: public CanvasView
{
public:
- CurveView();
+ CurveView(Plugin &plugin_);
~CurveView();
static int const pixels_per_sample;
diff --git a/src/flame-view.cpp b/src/flame-view.cpp
index 8772dba..333b3a0 100644
--- a/src/flame-view.cpp
+++ b/src/flame-view.cpp
@@ -28,12 +28,11 @@
#include "monitor.hpp"
-Flame::Flame(Monitor *m, unsigned int c)
- : monitor(m), value(0), next_refuel(0), color(c)
+Flame::Flame(Monitor *monitor_, unsigned int color_)
+ : monitor(monitor_), value(0), next_refuel(0), color(color_), max(0), cooling(0)
{}
-void Flame::update(Gnome::Canvas::Canvas &canvas,
- Plugin *plugin, int width, int height, int no, int total)
+void Flame::update(Gnome::Canvas::Canvas &canvas, int width, int height)
{
// Then make sure layer is correctly setup
if (flame.get() == 0)
@@ -102,7 +101,7 @@ void Flame::update(Gnome::Canvas::Canvas &canvas,
unsigned int random_between(unsigned int min, unsigned int max)
{
- return min + std::rand() % (max - min);
+ return min + std::rand() % (max - min); // NOLINT - insufficiently random, but this not for cryptography
}
void Flame::recompute_fuel(double overall_max)
@@ -214,8 +213,8 @@ double Flame::get_max_value()
// class FlameView
//
-FlameView::FlameView()
- : CanvasView(false)
+FlameView::FlameView(Plugin &plugin_)
+ : CanvasView(false, plugin_)
{
}
@@ -229,12 +228,9 @@ void FlameView::do_update()
{
CanvasView::do_update();
- int total = flames.size();
- int no = 0;
-
for (flame_iterator i = flames.begin(), end = flames.end(); i != end; ++i) {
Flame &flame = **i;
- flame.update(*canvas, plugin, width(), height(), no++, total);
+ flame.update(*canvas, width(), height());
}
}
@@ -248,7 +244,7 @@ void FlameView::do_attach(Monitor *monitor)
Glib::ustring dir = monitor->get_settings_dir();
// Search for settings file
- gchar* file = xfce_panel_plugin_lookup_rc_file(plugin->xfce_plugin);
+ gchar* file = xfce_panel_plugin_lookup_rc_file(plugin.xfce_plugin);
if (file)
{
@@ -261,7 +257,7 @@ void FlameView::do_attach(Monitor *monitor)
if (xfce_rc_has_entry(settings_ro, "color"))
{
color = xfce_rc_read_int_entry(settings_ro, "color",
- plugin->get_fg_color());
+ plugin.get_fg_color());
color_missing = false;
}
@@ -274,10 +270,10 @@ void FlameView::do_attach(Monitor *monitor)
if (color_missing)
{
// Setting color
- color = plugin->get_fg_color();
+ color = plugin.get_fg_color();
// Search for a writeable settings file, create one if it doesnt exist
- file = xfce_panel_plugin_save_location(plugin->xfce_plugin, true);
+ file = xfce_panel_plugin_save_location(plugin.xfce_plugin, true);
if (file)
{
@@ -313,7 +309,7 @@ void FlameView::do_detach(Monitor *monitor)
return;
}
- g_assert_not_reached();
+ g_assert_not_reached(); // NOLINT
}
void FlameView::do_draw_loop()
diff --git a/src/flame-view.hpp b/src/flame-view.hpp
index ea9d76a..afa746d 100644
--- a/src/flame-view.hpp
+++ b/src/flame-view.hpp
@@ -40,12 +40,11 @@
class Flame
{
public:
- Flame(Monitor *monitor, unsigned int color);
+ Flame(Monitor *monitor_, unsigned int color_);
void burn(double overall_max);
double get_max_value();
- void update(Gnome::Canvas::Canvas &canvas,
- Plugin *plugin, int width, int height, int no, int total);
+ void update(Gnome::Canvas::Canvas &canvas, int width, int height);
Monitor *monitor;
@@ -66,7 +65,7 @@ private:
class FlameView: public CanvasView
{
public:
- FlameView();
+ FlameView(Plugin &plugin_);
~FlameView();
private:
diff --git a/src/i18n.hpp b/src/i18n.hpp
index d234fd2..922c61c 100644
--- a/src/i18n.hpp
+++ b/src/i18n.hpp
@@ -36,7 +36,7 @@
#endif
//#define _(x) dgettext (GETTEXT_PACKAGE, x)
-#define _(x) gettext (x)
+#define _(x) gettext (x) // NOLINT
#define N_(x) x
#endif
diff --git a/src/monitor-impls.cpp b/src/monitor-impls.cpp
index dd058dc..d4328d8 100644
--- a/src/monitor-impls.cpp
+++ b/src/monitor-impls.cpp
@@ -237,9 +237,9 @@ load_monitors(XfceRc *settings_ro, Plugin& plugin)
else if (inter == "slip")
inter_type = NetworkLoadMonitor::serial_link;
- // In the original form, only one wireless interface was available
- else if (inter == "wlan")
- inter_type = NetworkLoadMonitor::wireless_first;
+ /* In the original form, only one wireless interface was available.
+ * Final option is 'wlan', doing it this way to satisfy clang */
+ else inter_type = NetworkLoadMonitor::wireless_first;
// Search for a writeable settings file, create one if it doesnt exist
gchar* file = xfce_panel_plugin_save_location(plugin.xfce_plugin, true);
@@ -260,7 +260,7 @@ load_monitors(XfceRc *settings_ro, Plugin& plugin)
else
{
// Unable to obtain writeable config file - informing user
- std::cerr << _("Unable to obtain writeable config file path in order"
+ std::cerr << _("Unable to obtain writeable config file path in order" // NOLINT
" to remove deprecated configuration in "
"load_monitors!\n");
}
@@ -285,7 +285,7 @@ load_monitors(XfceRc *settings_ro, Plugin& plugin)
inter_direction >= NetworkLoadMonitor::NUM_DIRECTIONS)
{
std::cerr << Glib::ustring::compose(
- _("Network monitor for interface '%1' is being loaded "
+ _("Network monitor for interface '%1' is being loaded " // NOLINT
"with an invalid direction (%2) - resetting to all "
"data!\n"),
NetworkLoadMonitor::interface_type_to_string(inter_type, false),
@@ -368,7 +368,7 @@ load_monitors(XfceRc *settings_ro, Plugin& plugin)
dir >= GenericMonitor::NUM_DIRECTIONS)
{
std::cerr << Glib::ustring::compose(
- _("Generic Monitor %1 associated with file '%2' is "
+ _("Generic Monitor %1 associated with file '%2' is " // NOLINT
"being loaded with an invalid value change direction "
"(%3) - resetting to positive!\n"),
data_source_name_long, file_path, dir);
@@ -429,7 +429,7 @@ T &operator <<(T& os, const Precision &p)
Precision precision(int n)
{
- Precision p;
+ Precision p; // NOLINT - initialisation is done just below...
p.n = n;
return p;
}
@@ -437,7 +437,7 @@ Precision precision(int n)
// for getting max no. of decimal digits
Precision decimal_digits(double val, int n)
{
- Precision p;
+ Precision p; // NOLINT - initialisation is done just below...
if (val == 0)
p.n = 1;
@@ -453,7 +453,7 @@ Precision decimal_digits(double val, int n)
return p;
}
-Glib::ustring format_duration_to_string(long duration)
+Glib::ustring format_duration_to_string(int64_t duration)
{
/* This is intended to summarise a user-customisable time period for long
* monitor descriptions, breaking millisecond duration into hours, minutes,
@@ -485,7 +485,7 @@ Glib::ustring format_duration_to_string(long duration)
{
if (hours == 1)
return "h";
- else if (minutes == 1)
+ else if (minutes == 1) // NOLINT - else after return, happy with this
return "m";
else
return "s";
@@ -494,7 +494,7 @@ Glib::ustring format_duration_to_string(long duration)
return duration_string;
}
-Glib::ustring format_bytes_per_duration(long duration, int expected_duration,
+Glib::ustring format_bytes_per_duration(int64_t duration, int expected_duration,
double bytes, bool compact)
{
Glib::ustring format;
@@ -517,7 +517,7 @@ Glib::ustring format_bytes_per_duration(long duration, int expected_duration,
return String::ucompose(format, decimal_digits(val, 3), val,
compact ? "" : format_duration_to_string(expected_duration));
}
- else if (val >= 1024 * 1024)
+ else if (val >= 1024 * 1024) // NOLINT - else after return, happy with this
{
val /= 1024 * 1024;
format = compact ? _("%1M%2") : "%1 MB/%2";
@@ -544,27 +544,27 @@ Glib::ustring format_bytes_per_duration(long duration, int expected_duration,
// class CpuUsageMonitor
//
// Static initialisation
-int const CpuUsageMonitor::max_no_cpus = GLIBTOP_NCPU;
-int const CpuUsageMonitor::update_interval_default = 1000;
+int const CpuUsageMonitor::max_no_cpus = GLIBTOP_NCPU; // NOLINT - thinks static initialisation is a dupe declaration
+int const CpuUsageMonitor::update_interval_default = 1000; // NOLINT - thinks static initialisation is a dupe declaration
-CpuUsageMonitor::CpuUsageMonitor(bool fixed_max, bool incl_low_prio,
- bool incl_iowait, int interval,
+CpuUsageMonitor::CpuUsageMonitor(bool fixed_max_, bool incl_low_prio_,
+ bool incl_iowait_, int interval,
const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin)
: Monitor(tag_string, add_to_text_overlay, interval, plugin), cpu_no(all_cpus),
- fixed_max_priv(fixed_max), incl_low_prio_priv(incl_low_prio),
- incl_iowait_priv(incl_iowait), total_time(0), nice_time(0), idle_time(0),
+ fixed_max(fixed_max_), incl_low_prio(incl_low_prio_),
+ incl_iowait(incl_iowait_), total_time(0), nice_time(0), idle_time(0),
iowait_time(0)
{}
-CpuUsageMonitor::CpuUsageMonitor(int cpu, bool fixed_max, bool incl_low_prio,
- bool incl_iowait, int interval,
+CpuUsageMonitor::CpuUsageMonitor(int cpu_no_, bool fixed_max_, bool incl_low_prio_,
+ bool incl_iowait_, int interval,
const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin)
- : Monitor(tag_string, add_to_text_overlay, interval, plugin), cpu_no(cpu),
- fixed_max_priv(fixed_max), incl_low_prio_priv(incl_low_prio),
- incl_iowait_priv(incl_iowait), total_time(0), nice_time(0), idle_time(0),
+ : Monitor(tag_string, add_to_text_overlay, interval, plugin), cpu_no(cpu_no_),
+ fixed_max(fixed_max_), incl_low_prio(incl_low_prio_),
+ incl_iowait(incl_iowait_), total_time(0), nice_time(0), idle_time(0),
iowait_time(0)
{
if (cpu_no < 0 || cpu_no >= max_no_cpus)
@@ -573,7 +573,7 @@ CpuUsageMonitor::CpuUsageMonitor(int cpu, bool fixed_max, bool incl_low_prio,
double CpuUsageMonitor::do_measure()
{
- glibtop_cpu cpu;
+ glibtop_cpu cpu; // NOLINT - initialisation just below...
glibtop_get_cpu(&cpu);
@@ -607,44 +607,37 @@ double CpuUsageMonitor::do_measure()
// Count nice and iowait if the user desires
double res = double(dtotal - didle);
- if (!incl_low_prio_priv)
+ if (!incl_low_prio)
res -= double(dnice);
- if (!incl_iowait_priv)
+ if (!incl_iowait)
res -= double(diowait);
res /= double(dtotal);
- if (res > 0)
- return res;
- else
- return 0;
-}
-
-bool CpuUsageMonitor::fixed_max()
-{
- return fixed_max_priv;
+ return (res > 0) ? res : 0;
}
-Glib::ustring CpuUsageMonitor::format_value(double val, bool compact)
+Glib::ustring CpuUsageMonitor::format_value(double val, bool compact) // NOLINT - unused parameter
{
return String::ucompose(_("%1%%"), precision(1), 100 * val);
}
Glib::ustring CpuUsageMonitor::get_name()
{
- if (cpu_no == all_cpus)
- return _("All processors");
- else
- return String::ucompose(_("Processor no. %1"), cpu_no + 1);
+ return (cpu_no == all_cpus) ? _("All processors")
+ : String::ucompose(_("Processor no. %1"), cpu_no + 1);
}
Glib::ustring CpuUsageMonitor::get_short_name()
{
- if (cpu_no == all_cpus)
- // must be short
- return _("CPU");
- else
- // note to translators: %1 is the cpu no, e.g. "CPU 1"
- return String::ucompose(_("CPU %1"), cpu_no + 1);
+ /* Must be short
+ * Note to translators: %1 is the cpu no, e.g. "CPU 1" */
+ return (cpu_no == all_cpus) ? _("CPU") : String::ucompose(_("CPU %1"),
+ cpu_no + 1);
+}
+
+bool CpuUsageMonitor::has_fixed_max()
+{
+ return fixed_max;
}
double CpuUsageMonitor::max()
@@ -662,11 +655,11 @@ void CpuUsageMonitor::save(XfceRc *settings_w)
xfce_rc_write_entry(settings_w, "type", "cpu_usage");
xfce_rc_write_int_entry(settings_w, "cpu_no", cpu_no);
xfce_rc_write_bool_entry(settings_w, "include_low_priority",
- incl_low_prio_priv);
+ incl_low_prio);
xfce_rc_write_bool_entry(settings_w, "include_iowait",
- incl_iowait_priv);
+ incl_iowait);
xfce_rc_write_int_entry(settings_w, "update_interval", update_interval());
- xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max_priv);
+ xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max);
xfce_rc_write_entry(settings_w, "tag", tag.c_str());
xfce_rc_write_bool_entry(settings_w, "add_to_text_overlay",
add_to_text_overlay);
@@ -681,35 +674,26 @@ int CpuUsageMonitor::update_interval()
// class SwapUsageMonitor
//
// Static initialisation
-int const SwapUsageMonitor::update_interval_default = 10 * 1000;
+int const SwapUsageMonitor::update_interval_default = 10 * 1000; // NOLINT - thinks static initialisation is redundant...
-SwapUsageMonitor::SwapUsageMonitor(int interval, bool fixed_max,
+SwapUsageMonitor::SwapUsageMonitor(int interval, bool fixed_max_,
const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin)
: Monitor(tag_string, add_to_text_overlay, interval, plugin), max_value(0),
- fixed_max_priv(fixed_max)
+ fixed_max(fixed_max_)
{
}
double SwapUsageMonitor::do_measure()
{
- glibtop_swap swp;
+ glibtop_swap swp; // NOLINT - initialised just below...
glibtop_get_swap(&swp);
// User-specified max is not allowed here, so this is fine
max_value = swp.total;
- if (swp.total > 0)
- return swp.used;
- else
- return 0;
-
-}
-
-bool SwapUsageMonitor::fixed_max()
-{
- return fixed_max_priv;
+ return (swp.total > 0) ? swp.used : 0;
}
Glib::ustring SwapUsageMonitor::format_value(double val, bool compact)
@@ -732,6 +716,11 @@ Glib::ustring SwapUsageMonitor::get_short_name()
return _("Swap");
}
+bool SwapUsageMonitor::has_fixed_max()
+{
+ return fixed_max;
+}
+
double SwapUsageMonitor::max()
{
return max_value;
@@ -746,7 +735,7 @@ void SwapUsageMonitor::save(XfceRc *settings_w)
xfce_rc_set_group(settings_w, dir.c_str());
xfce_rc_write_entry(settings_w, "type", "swap_usage");
xfce_rc_write_int_entry(settings_w, "update_interval", update_interval());
- xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max_priv);
+ xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max);
xfce_rc_write_entry(settings_w, "tag", tag.c_str());
xfce_rc_write_bool_entry(settings_w, "add_to_text_overlay",
add_to_text_overlay);
@@ -761,26 +750,26 @@ int SwapUsageMonitor::update_interval()
// class LoadAverageMonitor
//
// Static initialisation
-int const LoadAverageMonitor::update_interval_default = 30 * 1000;
+int const LoadAverageMonitor::update_interval_default = 30 * 1000; // NOLINT - thinks static initialisation is redundant...
-LoadAverageMonitor::LoadAverageMonitor(int interval, bool fixed_max, double max,
+LoadAverageMonitor::LoadAverageMonitor(int interval, bool fixed_max_, double max,
const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin)
: Monitor(tag_string, add_to_text_overlay, interval, plugin), max_value(max),
- fixed_max_priv(fixed_max)
+ fixed_max(fixed_max_)
{
}
double LoadAverageMonitor::do_measure()
{
- glibtop_loadavg loadavg;
+ glibtop_loadavg loadavg; // NOLINT - initialised just below...
glibtop_get_loadavg (&loadavg);
double val = loadavg.loadavg[0];
// Only alter max_value if the monitor doesn't have a user-specified fixed max
- if (!fixed_max_priv)
+ if (!fixed_max)
{
max_value *= max_decay; // reduce gradually
@@ -791,18 +780,10 @@ double LoadAverageMonitor::do_measure()
max_value = val * 1.05;
}
- if (max_value > 0)
- return val;
- else
- return 0;
+ return (max_value > 0) ? val : 0;
}
-bool LoadAverageMonitor::fixed_max()
-{
- return fixed_max_priv;
-}
-
-Glib::ustring LoadAverageMonitor::format_value(double val, bool compact)
+Glib::ustring LoadAverageMonitor::format_value(double val, bool compact) // NOLINT - unused parameter
{
return String::ucompose("%1", precision(1), val);
}
@@ -819,6 +800,11 @@ Glib::ustring LoadAverageMonitor::get_short_name()
return _("Load");
}
+bool LoadAverageMonitor::has_fixed_max()
+{
+ return fixed_max;
+}
+
double LoadAverageMonitor::max()
{
return max_value;
@@ -837,7 +823,7 @@ void LoadAverageMonitor::save(XfceRc *settings_w)
/* Only save the max if it is a user-set fixed max, otherwise effectively
* reset it
* No support for floats - stringifying */
- if (fixed_max_priv)
+ if (fixed_max)
{
Glib::ustring setting = String::ucompose("%1", max_value);
xfce_rc_write_entry(settings_w, "max", setting.c_str());
@@ -859,34 +845,26 @@ int LoadAverageMonitor::update_interval()
// class MemoryUsageMonitor
//
// Static initialisation
-int const MemoryUsageMonitor::update_interval_default = 10 * 1000;
+int const MemoryUsageMonitor::update_interval_default = 10 * 1000; // NOLINT - thinks static initialisation is redundant...
-MemoryUsageMonitor::MemoryUsageMonitor(int interval, bool fixed_max,
+MemoryUsageMonitor::MemoryUsageMonitor(int interval, bool fixed_max_,
const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin)
: Monitor(tag_string, add_to_text_overlay, interval, plugin), max_value(0),
- fixed_max_priv(fixed_max)
+ fixed_max(fixed_max_)
{
}
double MemoryUsageMonitor::do_measure()
{
- glibtop_mem mem;
+ glibtop_mem mem; // NOLINT - initialisation just below...
glibtop_get_mem (&mem);
// User-specified max is not allowed here, so this is fine
max_value = mem.total;
- if (mem.total > 0)
- return mem.used - (mem.buffer + mem.cached);
- else
- return 0;
-}
-
-bool MemoryUsageMonitor::fixed_max()
-{
- return fixed_max_priv;
+ return (mem.total > 0) ? mem.used - (mem.buffer + mem.cached) : 0;
}
Glib::ustring MemoryUsageMonitor::format_value(double val, bool compact)
@@ -909,6 +887,11 @@ Glib::ustring MemoryUsageMonitor::get_short_name()
return _("Mem.");
}
+bool MemoryUsageMonitor::has_fixed_max()
+{
+ return fixed_max;
+}
+
double MemoryUsageMonitor::max()
{
return max_value;
@@ -923,7 +906,7 @@ void MemoryUsageMonitor::save(XfceRc *settings_w)
xfce_rc_set_group(settings_w, dir.c_str());
xfce_rc_write_entry(settings_w, "type", "memory_usage");
xfce_rc_write_int_entry(settings_w, "update_interval", update_interval());
- xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max_priv);
+ xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max);
xfce_rc_write_entry(settings_w, "tag", tag.c_str());
xfce_rc_write_bool_entry(settings_w, "add_to_text_overlay",
add_to_text_overlay);
@@ -938,20 +921,20 @@ int MemoryUsageMonitor::update_interval()
// class DiskUsageMonitor
//
// Static initialisation
-int const DiskUsageMonitor::update_interval_default = 60 * 1000;
+int const DiskUsageMonitor::update_interval_default = 60 * 1000; // NOLINT - thinks static initialisation is a dupe declaration...
-DiskUsageMonitor::DiskUsageMonitor(const std::string &dir, bool free,
- int interval, bool fixed_max,
+DiskUsageMonitor::DiskUsageMonitor(const std::string &mount_dir, bool show_free,
+ int interval, bool fixed_max_,
const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin)
: Monitor(tag_string, add_to_text_overlay, interval, plugin), max_value(0),
- fixed_max_priv(fixed_max), mount_dir(dir), show_free(free)
+ fixed_max(fixed_max_), mount_dir(mount_dir), show_free(show_free)
{
}
double DiskUsageMonitor::do_measure()
{
- glibtop_fsusage fsusage;
+ glibtop_fsusage fsusage; // NOLINT - initialised just below...
glibtop_get_fsusage(&fsusage, mount_dir.c_str());
@@ -976,11 +959,6 @@ double DiskUsageMonitor::do_measure()
return v;
}
-bool DiskUsageMonitor::fixed_max()
-{
- return fixed_max_priv;
-}
-
Glib::ustring DiskUsageMonitor::format_value(double val, bool compact)
{
Glib::ustring format;
@@ -990,7 +968,7 @@ Glib::ustring DiskUsageMonitor::format_value(double val, bool compact)
format = compact ? _("%1G") : _("%1 GB");
return String::ucompose(format, decimal_digits(val, 3), val);
}
- else if (val >= 1024 * 1024) {
+ else if (val >= 1024 * 1024) { // NOLINT - doesn't like all the returns
val /= 1024 * 1024;
format = compact ? _("%1M") : _("%1 MB");
return String::ucompose(format, decimal_digits(val, 3), val);
@@ -1016,6 +994,11 @@ Glib::ustring DiskUsageMonitor::get_short_name()
return String::ucompose("%1", mount_dir);
}
+bool DiskUsageMonitor::has_fixed_max()
+{
+ return fixed_max;
+}
+
double DiskUsageMonitor::max()
{
return max_value;
@@ -1032,7 +1015,7 @@ void DiskUsageMonitor::save(XfceRc *settings_w)
xfce_rc_write_entry(settings_w, "mount_dir", mount_dir.c_str());
xfce_rc_write_bool_entry(settings_w, "show_free", show_free);
xfce_rc_write_int_entry(settings_w, "update_interval", update_interval());
- xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max_priv);
+ xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max);
xfce_rc_write_entry(settings_w, "tag", tag.c_str());
xfce_rc_write_bool_entry(settings_w, "add_to_text_overlay",
add_to_text_overlay);
@@ -1047,25 +1030,25 @@ int DiskUsageMonitor::update_interval()
// class DiskStatsMonitor
//
// Static initialisation
-const Glib::ustring& DiskStatsMonitor::diskstats_path = "/proc/diskstats";
+const Glib::ustring& DiskStatsMonitor::diskstats_path = "/proc/diskstats"; // NOLINT - could throw, supposed redundant declaration
/* Used for working out read/write data rate - apparently the kernel always
* considers this the sector size for a volume:
* https://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux#comment669172_239010measures volume sectors */
-const int DiskStatsMonitor::SECTOR_SIZE = 512;
+const int DiskStatsMonitor::SECTOR_SIZE = 512; // NOLINT - supposed redundant declaration
-int const DiskStatsMonitor::update_interval_default = 1000;
+int const DiskStatsMonitor::update_interval_default = 1000; // NOLINT - supposed redundant declaration
// No stats allow for negative values, so using that to detect no previous value
DiskStatsMonitor::DiskStatsMonitor(const Glib::ustring &device_name,
const Stat &stat_to_monitor,
- int interval, bool fixed_max, double max,
+ int interval, bool fixed_max_, double max,
const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin)
: Monitor(tag_string, add_to_text_overlay, interval, plugin),
device_name(device_name), stat_to_monitor(stat_to_monitor),
- previous_value(-1), max_value(max), fixed_max_priv(fixed_max),
- time_stamp_secs(0), time_stamp_usecs(0)
+ previous_value(-1), max_value(max), fixed_max(fixed_max_),
+ time_difference(0), time_stamp_secs(0), time_stamp_usecs(0)
{
}
@@ -1088,12 +1071,12 @@ bool DiskStatsMonitor::convert_to_rate()
std::vector<Glib::ustring> DiskStatsMonitor::current_device_names()
{
// Fetching current disk stats
- std::map<Glib::ustring, std::vector<unsigned long int> > parsed_stats =
+ std::map<Glib::ustring, std::vector<uint64_t> > parsed_stats =
parse_disk_stats();
// Generating sorted list of available devices
std::vector<Glib::ustring> devices_list;
- for (std::map<Glib::ustring, std::vector<unsigned long int> >::iterator it
+ for (std::map<Glib::ustring, std::vector<uint64_t> >::iterator it
= parsed_stats.begin(); it != parsed_stats.end(); ++it)
{
devices_list.push_back(it->first);
@@ -1118,9 +1101,9 @@ double DiskStatsMonitor::do_measure()
/* Returning 0 if device is not available - this is not an error since the
* device may be hotpluggable */
- std::map<Glib::ustring, std::vector<unsigned long int> > disk_stats =
+ std::map<Glib::ustring, std::vector<uint64_t> > disk_stats =
parse_disk_stats();
- std::map<Glib::ustring, std::vector<unsigned long int> >::iterator it =
+ std::map<Glib::ustring, std::vector<uint64_t> >::iterator it =
disk_stats.find(device_name);
if (it == disk_stats.end())
{
@@ -1171,7 +1154,7 @@ double DiskStatsMonitor::do_measure()
* sample
* Time of call used to get at a precise data rate, like the network load
* monitor does - every rate measurement should be precise */
- struct timeval tv;
+ struct timeval tv; // NOLINT - initialised just below...
if (gettimeofday(&tv, 0) == 0) {
time_difference =
(tv.tv_sec - time_stamp_secs) * 1000 +
@@ -1188,7 +1171,7 @@ double DiskStatsMonitor::do_measure()
}
// Only altering the max_value if there is no user-specified fixed max
- if (!fixed_max_priv)
+ if (!fixed_max)
{
/* Note - max_value is no longer used to determine the graph max for
* Curves - the actual maxima stored in the ValueHistories are used */
@@ -1205,11 +1188,6 @@ double DiskStatsMonitor::do_measure()
return val;
}
-bool DiskStatsMonitor::fixed_max()
-{
- return fixed_max_priv;
-}
-
Glib::ustring DiskStatsMonitor::format_value(double val, bool compact)
{
// For read and write data rates, return in appropriate scaled units
@@ -1219,7 +1197,7 @@ Glib::ustring DiskStatsMonitor::format_value(double val, bool compact)
return format_bytes_per_duration(time_difference, update_interval_priv, val,
compact);
}
- else
+ else // NOLINT - doesn't like mulitple returns
{
/* Remember users can define the monitoring interval, so the time unit must
* be calculated specially */
@@ -1242,12 +1220,17 @@ Glib::ustring DiskStatsMonitor::get_short_name()
return device_name + "-" + stat_to_string(stat_to_monitor, true);
}
+bool DiskStatsMonitor::has_fixed_max()
+{
+ return fixed_max;
+}
+
double DiskStatsMonitor::max()
{
return max_value;
}
-std::map<Glib::ustring, std::vector<unsigned long int> >
+std::map<Glib::ustring, std::vector<uint64_t> >
DiskStatsMonitor::parse_disk_stats()
{
Glib::ustring device_stats;
@@ -1262,19 +1245,19 @@ DiskStatsMonitor::parse_disk_stats()
std::cerr << Glib::ustring::compose(_("Unable to parse disk stats from '%1' "
"due to error '%2'\n"),
"/proc/diskstats", e.what());
- return std::map<Glib::ustring, std::vector<unsigned long int> >();
+ return std::map<Glib::ustring, std::vector<uint64_t> >();
}
/* Preparing regex to use in splitting out stats
* Example line:
* 8 16 sdb 16710337 4656786 7458292624 49395796 15866670 4083490 5442473656 53095516 0 24513196 102484768 */
Glib::RefPtr<Glib::Regex> split_stats_regex = Glib::Regex::create(
- "^\\s+(\\d+)\\s+(\\d+)\\s([\\w-]+)\\s(\\d+)\\s(\\d+)\\s(\\d+)\\s(\\d+)\\s"
+ "^\\s+(\\d+)\\s+(\\d+)\\s([\\w-]+)\\s(\\d+)\\s(\\d+)\\s(\\d+)\\s(\\d+)\\s" // NOLINT - C++11
"(\\d+)\\s(\\d+)\\s(\\d+)\\s(\\d+)\\s(\\d+)\\s(\\d+)\\s(\\d+)$",
Glib::REGEX_OPTIMIZE);
// Splitting out stats into devices
- std::map<Glib::ustring, std::vector<unsigned long int> > parsed_stats;
+ std::map<Glib::ustring, std::vector<uint64_t> > parsed_stats;
std::stringstream device_stats_stream(device_stats);
Glib::ustring device_name, single_dev_stats;
Glib::MatchInfo match_info;
@@ -1300,7 +1283,7 @@ DiskStatsMonitor::parse_disk_stats()
* Source data is stored in kernel source include/linux/genhd.h dis_stats
* struct, printing out to file is done in block/genhd.c:diskstats_show,
* some are actually unsigned ints */
- std::vector<unsigned long int> device_parsed_stats;
+ std::vector<uint64_t> device_parsed_stats;
device_name = match_info.fetch(3);
/* Debug code
@@ -1313,7 +1296,7 @@ DiskStatsMonitor::parse_disk_stats()
for (int i = 4; i<match_info.get_match_count(); ++i)
{
- unsigned long int stat = 0;
+ uint64_t stat = 0;
/* Stringstreams are not trivially reusable! Hence creating a new one
* each time... */
@@ -1348,11 +1331,11 @@ void DiskStatsMonitor::save(XfceRc *settings_w)
xfce_rc_write_entry(settings_w, "type", "disk_statistics");
xfce_rc_write_entry(settings_w, "disk_stats_device", device_name.c_str());
xfce_rc_write_int_entry(settings_w, "disk_stats_stat", int(stat_to_monitor));
- xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max_priv);
+ xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max);
/* Only save the max if it is a user-set fixed max, otherwise effectively
* reset it */
- xfce_rc_write_int_entry(settings_w, "max", fixed_max_priv ? int(max_value) : 0);
+ xfce_rc_write_int_entry(settings_w, "max", fixed_max ? int(max_value) : 0);
xfce_rc_write_int_entry(settings_w, "update_interval", update_interval());
xfce_rc_write_entry(settings_w, "tag", tag.c_str());
@@ -1370,7 +1353,7 @@ Glib::ustring DiskStatsMonitor::stat_to_string(const DiskStatsMonitor::Stat &sta
{
Glib::ustring stat_str;
- switch(stat)
+ switch(stat) // NOLINT - complains about NUM_STATS not being handled...
{
case num_reads_completed:
if (short_ver)
@@ -1466,19 +1449,21 @@ int DiskStatsMonitor::update_interval()
* non-declaration statements here either, so can't directly populate the
* defaults vector... the main type names vector isn't initialised here as the
* associated function loads and saves settings */
-int const NetworkLoadMonitor::update_interval_default = 1000;
-std::vector<Glib::ustring> NetworkLoadMonitor::interface_type_names = std::vector<Glib::ustring>(NUM_INTERFACE_TYPES);
-std::vector<Glib::ustring> NetworkLoadMonitor::interface_type_names_default = initialise_default_interface_names();
+int const NetworkLoadMonitor::update_interval_default = 1000; // NOLINT - static initialisation considered a dupe declaration
+std::vector<Glib::ustring> NetworkLoadMonitor::interface_type_names = std::vector<Glib::ustring>(NUM_INTERFACE_TYPES); // NOLINT - may throw
+std::vector<Glib::ustring> NetworkLoadMonitor::interface_type_names_default = initialise_default_interface_names(); // NOLINT - may throw
-bool NetworkLoadMonitor::interface_names_configured = false;
+bool NetworkLoadMonitor::interface_names_configured = false; // NOLINT - static initialisation considered dupe declaration...
-NetworkLoadMonitor::NetworkLoadMonitor(InterfaceType &inter_type, Direction dir,
- int interval, bool fixed_max, double max,
+NetworkLoadMonitor::NetworkLoadMonitor(InterfaceType &interface_type,
+ Direction dir, int interval,
+ bool fixed_max_, double max,
const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin)
: Monitor(tag_string, add_to_text_overlay, interval, plugin), max_value(max),
- fixed_max_priv(fixed_max), byte_count(0), time_stamp_secs(0),
- time_stamp_usecs(0), interface_type(inter_type), direction(dir)
+ fixed_max(fixed_max_), byte_count(0), time_stamp_secs(0),
+ time_stamp_usecs(0), time_difference(0), interface_type(interface_type),
+ direction(dir)
{
}
@@ -1711,7 +1696,7 @@ const Glib::ustring NetworkLoadMonitor::direction_to_string(const Direction dire
{
Glib::ustring direction_str;
- switch(direction)
+ switch(direction) // NOLINT - complains about NUM_DIRECTIONS not being handled...
{
case all_data:
direction_str = _("All data");
@@ -1731,7 +1716,7 @@ const Glib::ustring NetworkLoadMonitor::direction_to_string(const Direction dire
double NetworkLoadMonitor::do_measure()
{
- glibtop_netload netload;
+ glibtop_netload netload; // NOLINT - initialised just below...
/* Obtaining interface name - this can change after monitor is instantiated
* hence fetching each time */
@@ -1758,7 +1743,7 @@ double NetworkLoadMonitor::do_measure()
byte_count = measured_bytes;
// Only altering max_value if there is no user-specified max
- if (!fixed_max_priv)
+ if (!fixed_max)
{
/* Note - max_value is no longer used to determine the graph max for
* Curves and Columns - the actual maxima stored in the ValueHistories are
@@ -1785,7 +1770,7 @@ double NetworkLoadMonitor::do_measure()
}
// Calculate time difference in msecs between last sample and current sample
- struct timeval tv;
+ struct timeval tv; // NOLINT - initialised just below...
if (gettimeofday(&tv, 0) == 0) {
time_difference =
(tv.tv_sec - time_stamp_secs) * 1000 +
@@ -1801,11 +1786,6 @@ double NetworkLoadMonitor::do_measure()
return val;
}
-bool NetworkLoadMonitor::fixed_max()
-{
- return fixed_max_priv;
-}
-
Glib::ustring NetworkLoadMonitor::format_value(double val, bool compact)
{
return format_bytes_per_duration(time_difference, update_interval_priv, val,
@@ -1861,6 +1841,11 @@ Glib::ustring NetworkLoadMonitor::get_short_name()
return str;
}
+bool NetworkLoadMonitor::has_fixed_max()
+{
+ return fixed_max;
+}
+
std::vector<Glib::ustring> NetworkLoadMonitor::initialise_default_interface_names()
{
std::vector<Glib::ustring> inter_type_names_default = std::
@@ -1878,7 +1863,7 @@ std::vector<Glib::ustring> NetworkLoadMonitor::initialise_default_interface_name
bool NetworkLoadMonitor::interface_exists(const Glib::ustring &interface_name)
{
- glibtop_netlist buf;
+ glibtop_netlist buf; // NOLINT - initialised just below...
char **devices;
int i;
bool found_device = false;
@@ -1906,7 +1891,7 @@ const Glib::ustring NetworkLoadMonitor::interface_type_to_string(const Interface
{
Glib::ustring interface_type_str;
- switch(type)
+ switch(type) // NOLINT - NUM_INTERFACE_TYPES not taken into account...
{
case ethernet_first:
if (short_ver)
@@ -2014,11 +1999,11 @@ void NetworkLoadMonitor::save(XfceRc *settings_w)
xfce_rc_write_int_entry(settings_w, "interface_type", int(interface_type));
xfce_rc_write_int_entry(settings_w, "interface_direction",
int(direction));
- xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max_priv);
+ xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max);
/* Only save the max if it is a user-set fixed max, otherwise effectively
* reset it */
- xfce_rc_write_int_entry(settings_w, "max", fixed_max_priv ? int(max_value) : 0);
+ xfce_rc_write_int_entry(settings_w, "max", fixed_max ? int(max_value) : 0);
xfce_rc_write_int_entry(settings_w, "update_interval", update_interval());
xfce_rc_write_entry(settings_w, "tag", tag.c_str());
@@ -2071,7 +2056,7 @@ void NetworkLoadMonitor::save_interfaces(XfceRc *settings_w)
interface_type_names[wireless_third].c_str());
}
-void NetworkLoadMonitor::set_interface_name(InterfaceType type, const Glib::ustring interface_name)
+void NetworkLoadMonitor::set_interface_name(InterfaceType type, const Glib::ustring &interface_name)
{
interface_type_names[type] = interface_name;
}
@@ -2115,7 +2100,7 @@ Sensors &Sensors::instance()
return s;
}
-Sensors::FeatureInfoSequence Sensors::get_features(std::string base)
+Sensors::FeatureInfoSequence Sensors::get_features(const std::string &base)
{
FeatureInfoSequence vec;
@@ -2137,7 +2122,7 @@ Sensors::FeatureInfoSequence Sensors::get_features(std::string base)
char *desc = sensors_get_label(chip, feature);
if (desc) {
info.description = desc;
- std::free(desc);
+ std::free(desc); // NOLINT - C library, so free etc
}
vec.push_back(info);
@@ -2184,10 +2169,7 @@ double Sensors::get_value(int chip_no, int feature_no)
double res;
- if (sensors_get_value(&chips[chip_no], feature_no, &res) == 0)
- return res;
- else
- return 0;
+ return (sensors_get_value(&chips[chip_no], feature_no, &res) == 0) ? res : 0;
#else
return 0;
#endif
@@ -2199,16 +2181,16 @@ double Sensors::get_value(int chip_no, int feature_no)
// class TemperatureMonitor
//
// Static initialisation
-double const Sensors::invalid_max = -1000000;
+double const Sensors::invalid_max = -1000000; // NOLINT - static initialisation is supposedly a duplicate declaration...
-int const TemperatureMonitor::update_interval_default = 20 * 1000;
+int const TemperatureMonitor::update_interval_default = 20 * 1000; // NOLINT - static initialisation is supposedly a duplicate declaration...
-TemperatureMonitor::TemperatureMonitor(int no, int interval, bool fixed_max,
+TemperatureMonitor::TemperatureMonitor(int no, int interval, bool fixed_max_,
double max,
const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin)
: Monitor(tag_string, add_to_text_overlay, interval, plugin), sensors_no(no),
- max_value(max), fixed_max_priv(fixed_max)
+ max_value(max), fixed_max(fixed_max_)
{
Sensors::FeatureInfo info
= Sensors::instance().get_temperature_features()[sensors_no];
@@ -2227,19 +2209,13 @@ double TemperatureMonitor::do_measure()
double val = Sensors::instance().get_value(chip_no, feature_no);
// Only altering max_value if there is no user-specified max
- if (!fixed_max_priv && val > max_value)
+ if (!fixed_max && val > max_value)
max_value = val;
return val;
}
-bool TemperatureMonitor::fixed_max()
-{
- return fixed_max_priv;
-}
-
-
-Glib::ustring TemperatureMonitor::format_value(double val, bool compact)
+Glib::ustring TemperatureMonitor::format_value(double val, bool compact) // NOLINT - unused parameters
{
// %2 contains the degree sign (the following 'C' stands for Celsius)
return String::ucompose(_("%1%2C"), decimal_digits(val, 3), val, "\xc2\xb0");
@@ -2247,12 +2223,10 @@ Glib::ustring TemperatureMonitor::format_value(double val, bool compact)
Glib::ustring TemperatureMonitor::get_name()
{
- if (!description.empty())
- // %2 is a descriptive string from sensors.conf
- return String::ucompose(_("Temperature %1: \"%2\""),
- sensors_no + 1, description);
- else
- return String::ucompose(_("Temperature %1"), sensors_no + 1);
+ // %2 is a descriptive string from sensors.conf
+ return (!description.empty()) ?
+ String::ucompose(_("Temperature %1: \"%2\""), sensors_no + 1, description)
+ : String::ucompose(_("Temperature %1"), sensors_no + 1);
}
Glib::ustring TemperatureMonitor::get_short_name()
@@ -2261,6 +2235,11 @@ Glib::ustring TemperatureMonitor::get_short_name()
return String::ucompose(_("Temp. %1"), sensors_no + 1);
}
+bool TemperatureMonitor::has_fixed_max()
+{
+ return fixed_max;
+}
+
double TemperatureMonitor::max()
{
return max_value;
@@ -2276,12 +2255,12 @@ void TemperatureMonitor::save(XfceRc *settings_w)
xfce_rc_write_entry(settings_w, "type", "temperature");
xfce_rc_write_int_entry(settings_w, "temperature_no", sensors_no);
xfce_rc_write_int_entry(settings_w, "update_interval", update_interval());
- xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max_priv);
+ xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max);
/* Only save the max if it is a user-set fixed max, otherwise effectively
* reset it
* No support for floats - stringifying */
- if (fixed_max_priv)
+ if (fixed_max)
{
Glib::ustring setting = String::ucompose("%1", max_value);
xfce_rc_write_entry(settings_w, "max", setting.c_str());
@@ -2303,13 +2282,13 @@ int TemperatureMonitor::update_interval()
// class FanSpeedMonitor
//
// Static initialisation
-int const FanSpeedMonitor::update_interval_default = 20 * 1000;
+int const FanSpeedMonitor::update_interval_default = 20 * 1000; // NOLINT - static initialisation treated as duplicate declaration...
-FanSpeedMonitor::FanSpeedMonitor(int no, int interval, bool fixed_max,
+FanSpeedMonitor::FanSpeedMonitor(int no, int interval, bool fixed_max_,
double max, const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin)
: Monitor(tag_string, add_to_text_overlay, interval, plugin), sensors_no(no),
- max_value(max), fixed_max_priv(fixed_max)
+ max_value(max), fixed_max(fixed_max_)
{
Sensors::FeatureInfo info
= Sensors::instance().get_fan_features()[sensors_no];
@@ -2328,18 +2307,13 @@ double FanSpeedMonitor::do_measure()
double val = Sensors::instance().get_value(chip_no, feature_no);
// Only altering max value if there is no user-specified max
- if (!fixed_max_priv && val > max_value)
+ if (!fixed_max && val > max_value)
max_value = val;
return val;
}
-bool FanSpeedMonitor::fixed_max()
-{
- return fixed_max_priv;
-}
-
-Glib::ustring FanSpeedMonitor::format_value(double val, bool compact)
+Glib::ustring FanSpeedMonitor::format_value(double val, bool compact) // NOLINT - unused parameter
{
// rpm is rotations per minute
return String::ucompose(_("%1 rpm"), val, val);
@@ -2347,12 +2321,10 @@ Glib::ustring FanSpeedMonitor::format_value(double val, bool compact)
Glib::ustring FanSpeedMonitor::get_name()
{
- if (!description.empty())
- // %2 is a descriptive string from sensors.conf
- return String::ucompose(_("Fan %1 speed: \"%2\""),
- sensors_no + 1, description);
- else
- return String::ucompose(_("Fan %1 speed"), sensors_no + 1);
+ // %2 is a descriptive string from sensors.conf
+ return (!description.empty()) ?
+ String::ucompose(_("Fan %1 speed: \"%2\""), sensors_no + 1, description)
+ : String::ucompose(_("Fan %1 speed"), sensors_no + 1);
}
Glib::ustring FanSpeedMonitor::get_short_name()
@@ -2360,6 +2332,11 @@ Glib::ustring FanSpeedMonitor::get_short_name()
return String::ucompose(_("Fan %1"), sensors_no + 1);
}
+bool FanSpeedMonitor::has_fixed_max()
+{
+ return fixed_max;
+}
+
double FanSpeedMonitor::max()
{
return max_value;
@@ -2375,12 +2352,12 @@ void FanSpeedMonitor::save(XfceRc *settings_w)
xfce_rc_write_entry(settings_w, "type", "fan_speed");
xfce_rc_write_int_entry(settings_w, "fan_no", sensors_no);
xfce_rc_write_int_entry(settings_w, "update_interval", update_interval());
- xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max_priv);
+ xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max);
/* Only save the max if it is a user-set fixed max, otherwise effectively
* reset it
* No support for floats - stringifying */
- if (fixed_max_priv)
+ if (fixed_max)
{
Glib::ustring setting = String::ucompose("%1", max_value);
xfce_rc_write_entry(settings_w, "max", setting.c_str());
@@ -2402,27 +2379,27 @@ int FanSpeedMonitor::update_interval()
// class GenericMonitor
//
// Static initialisation
-int const GenericMonitor::update_interval_default = 1000;
+int const GenericMonitor::update_interval_default = 1000; // NOLINT - static initialisation treated as duplicate declaration...
-GenericMonitor::GenericMonitor(const Glib::ustring &file_path,
- const bool value_from_contents,
+GenericMonitor::GenericMonitor(const Glib::ustring &file_path_,
+ const bool value_from_contents_,
const Glib::ustring ®ex_string,
- const bool follow_change,
- const ValueChangeDirection dir,
- const Glib::ustring &data_source_name_long,
- const Glib::ustring &data_source_name_short,
- const Glib::ustring &units_long,
- const Glib::ustring &units_short,
- int interval, bool fixed_max, double max,
+ const bool follow_change_,
+ const ValueChangeDirection dir_,
+ const Glib::ustring &data_source_name_long_,
+ const Glib::ustring &data_source_name_short_,
+ const Glib::ustring &units_long_,
+ const Glib::ustring &units_short_,
+ int interval, bool fixed_max_, double max,
const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin)
: Monitor(tag_string, add_to_text_overlay, interval, plugin), max_value(max),
- fixed_max_priv(fixed_max), previous_value(std::numeric_limits<double>::min()),
- file_path(file_path), value_from_contents(value_from_contents),
- follow_change(follow_change), dir(dir),
- data_source_name_long(data_source_name_long),
- data_source_name_short(data_source_name_short), units_long(units_long),
- units_short(units_short)
+ fixed_max(fixed_max_), previous_value(std::numeric_limits<double>::min()),
+ file_path(file_path_), value_from_contents(value_from_contents_),
+ follow_change(follow_change_), dir(dir_),
+ data_source_name_long(data_source_name_long_),
+ data_source_name_short(data_source_name_short_), units_long(units_long_),
+ units_short(units_short_)
{
// Compiling regex if provided (at this stage its already been validated)
if (regex_string != "")
@@ -2511,7 +2488,7 @@ double GenericMonitor::do_measure()
}
}
- double return_value;
+ double return_value = 0;
if (follow_change)
{
/* User has requested to diff the data to make a rate of change
@@ -2522,7 +2499,7 @@ double GenericMonitor::do_measure()
/* Returning desired stat, based on whether the user wants only positive
* changes, negative changes, or both reported (these are intended for views
* that don't have a negative axis) */
- switch (dir)
+ switch (dir) // NOLINT - NUM_DIRECTIONS not accounted for...
{
case positive:
return_value = val - previous_value;
@@ -2545,7 +2522,7 @@ double GenericMonitor::do_measure()
return_value = val;
// Only altering max_value if there is no user-specified fixed max
- if (!fixed_max_priv)
+ if (!fixed_max)
{
/* Note - max_value is no longer used to determine the graph max for
* Curves and Columns - the actual maxima stored in the ValueHistories are
@@ -2565,11 +2542,6 @@ double GenericMonitor::do_measure()
return return_value;
}
-bool GenericMonitor::fixed_max()
-{
- return fixed_max_priv;
-}
-
Glib::ustring GenericMonitor::format_value(double val, bool compact)
{
return Glib::ustring::compose("%1%2", val,
@@ -2587,6 +2559,11 @@ Glib::ustring GenericMonitor::get_short_name()
return data_source_name_short;
}
+bool GenericMonitor::has_fixed_max()
+{
+ return fixed_max;
+}
+
double GenericMonitor::max()
{
return max_value;
@@ -2612,12 +2589,12 @@ void GenericMonitor::save(XfceRc *settings_w)
xfce_rc_write_entry(settings_w, "units_long", units_long.c_str());
xfce_rc_write_entry(settings_w, "units_short", units_short.c_str());
xfce_rc_write_int_entry(settings_w, "update_interval", update_interval());
- xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max_priv);
+ xfce_rc_write_bool_entry(settings_w, "fixed_max", fixed_max);
/* Only save the max if it is a user-set fixed max, otherwise effectively
* reset it
* No support for floats - stringifying */
- if (fixed_max_priv)
+ if (fixed_max)
{
Glib::ustring setting = String::ucompose("%1", max_value);
xfce_rc_write_entry(settings_w, "max", setting.c_str());
diff --git a/src/monitor-impls.hpp b/src/monitor-impls.hpp
index 2021ef0..f5acb02 100644
--- a/src/monitor-impls.hpp
+++ b/src/monitor-impls.hpp
@@ -50,20 +50,20 @@ class CpuUsageMonitor: public Monitor
public:
// Monitor all CPUs
- CpuUsageMonitor(bool fixed_max, bool incl_low_prio, bool incl_iowait,
+ CpuUsageMonitor(bool fixed_max_, bool incl_low_prio_, bool incl_iowait_,
int interval, const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin);
// Monitor only CPU no.
- CpuUsageMonitor(int cpu_no, bool fixed_max, bool incl_low_prio,
- bool incl_iowait, int interval,
+ CpuUsageMonitor(int cpu_no_, bool fixed_max_, bool incl_low_prio_,
+ bool incl_iowait_, int interval,
const Glib::ustring &tag_string, bool add_to_text_overlay,
Plugin& plugin);
- virtual bool fixed_max();
virtual Glib::ustring format_value(double val, bool compact = false);
virtual Glib::ustring get_name();
virtual Glib::ustring get_short_name();
+ virtual bool has_fixed_max();
virtual double max();
virtual void save(XfceRc *settings_w);
@@ -82,10 +82,10 @@ private:
static int const all_cpus = -1;
int cpu_no;
- bool fixed_max_priv;
+ bool fixed_max;
// Define whether these are included in CPU time or not
- bool incl_low_prio_priv, incl_iowait_priv;
+ bool incl_low_prio, incl_iowait;
// we need to save these values to compute the difference next time the
// monitor is updated
@@ -96,13 +96,13 @@ private:
class SwapUsageMonitor: public Monitor
{
public:
- SwapUsageMonitor(int interval, bool fixed_max, const Glib::ustring &tag_string,
+ SwapUsageMonitor(int interval, bool fixed_max_, const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin);
- virtual bool fixed_max();
virtual Glib::ustring format_value(double val, bool compact = false);
virtual Glib::ustring get_name();
virtual Glib::ustring get_short_name();
+ virtual bool has_fixed_max();
virtual double max();
virtual void save(XfceRc *settings_w);
virtual int update_interval();
@@ -115,7 +115,7 @@ public:
private:
virtual double do_measure();
- bool fixed_max_priv;
+ bool fixed_max;
guint64 max_value; // maximum available swap
};
@@ -123,14 +123,14 @@ private:
class LoadAverageMonitor: public Monitor
{
public:
- LoadAverageMonitor(int interval, bool fixed_max, double max,
+ LoadAverageMonitor(int interval, bool fixed_max_, double max,
const Glib::ustring &tag_string, bool add_to_text_overlay,
Plugin& plugin);
- virtual bool fixed_max();
virtual Glib::ustring format_value(double val, bool compact = false);
virtual Glib::ustring get_name();
virtual Glib::ustring get_short_name();
+ virtual bool has_fixed_max();
virtual double max();
virtual void save(XfceRc *settings_w);
virtual int update_interval();
@@ -143,7 +143,7 @@ public:
private:
virtual double do_measure();
- bool fixed_max_priv;
+ bool fixed_max;
/* Recent max load average, i.e. processes running or waiting to run on all
* cores */
@@ -154,14 +154,14 @@ private:
class MemoryUsageMonitor: public Monitor
{
public:
- MemoryUsageMonitor(int interval, bool fixed_max,
+ MemoryUsageMonitor(int interval, bool fixed_max_,
const Glib::ustring &tag_string, bool add_to_text_overlay,
Plugin& plugin);
- virtual bool fixed_max();
virtual Glib::ustring format_value(double val, bool compact = false);
virtual Glib::ustring get_name();
virtual Glib::ustring get_short_name();
+ virtual bool has_fixed_max();
virtual double max();
virtual void save(XfceRc *settings_w);
virtual int update_interval();
@@ -174,7 +174,7 @@ public:
private:
virtual double do_measure();
- bool fixed_max_priv;
+ bool fixed_max;
guint64 max_value; // Maximum available physical RAM
};
@@ -183,13 +183,13 @@ class DiskUsageMonitor: public Monitor
{
public:
DiskUsageMonitor(const std::string &mount_dir, bool show_free, int interval,
- bool fixed_max, const Glib::ustring &tag_string,
+ bool fixed_max_, const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin);
- virtual bool fixed_max();
virtual Glib::ustring format_value(double val, bool compact= false);
virtual Glib::ustring get_name();
virtual Glib::ustring get_short_name();
+ virtual bool has_fixed_max();
virtual double max(); // Fixed at size of the relevant volume
virtual void save(XfceRc *settings_w);
virtual int update_interval();
@@ -205,7 +205,7 @@ private:
guint64 max_value; // Maximum available bytes in relevant volume
std::string mount_dir;
- bool fixed_max_priv, show_free;
+ bool fixed_max, show_free;
};
class DiskStatsMonitor: public Monitor
@@ -231,14 +231,14 @@ public:
};
DiskStatsMonitor(const Glib::ustring &device_name, const Stat &stat_to_monitor,
- int interval, bool fixed_max, double max,
+ int interval, bool fixed_max_, double max,
const Glib::ustring &tag_string, bool add_to_text_overlay,
Plugin& plugin);
- virtual bool fixed_max();
virtual Glib::ustring format_value(double val, bool compact=false);
virtual Glib::ustring get_name();
virtual Glib::ustring get_short_name();
+ virtual bool has_fixed_max();
virtual double max();
virtual void save(XfceRc *settings_w);
virtual int update_interval();
@@ -262,9 +262,9 @@ private:
/* Reads the diskstats file and returns a vector of each device, containing a
* vector of reported stats. Note that unordered_map is C++11 */
- static std::map<Glib::ustring, std::vector<unsigned long int> > parse_disk_stats();
+ static std::map<Glib::ustring, std::vector<uint64_t> > parse_disk_stats();
- bool fixed_max_priv;
+ bool fixed_max;
Glib::ustring device_name;
guint64 max_value;
double previous_value;
@@ -307,14 +307,14 @@ public:
};
NetworkLoadMonitor(InterfaceType &interface_type,
- Direction dir, int interval, bool fixed_max, double max,
+ Direction dir, int interval, bool fixed_max_, double max,
const Glib::ustring &tag_string,
bool add_to_text_overlay, Plugin& plugin);
- virtual bool fixed_max();
virtual Glib::ustring format_value(double val, bool compact = false);
virtual Glib::ustring get_name();
virtual Glib::ustring get_short_name();
+ virtual bool has_fixed_max();
virtual double max();
/*
@@ -341,7 +341,7 @@ public:
XfcePanelPlugin *xfce_plugin);
static Glib::ustring get_default_interface_name(InterfaceType type);
static void set_interface_name(InterfaceType type,
- const Glib::ustring interface_name);
+ const Glib::ustring &interface_name);
static const Glib::ustring interface_type_to_string(const InterfaceType type,
bool short_ver);
static bool interface_exists(const Glib::ustring& interface_name);
@@ -361,10 +361,7 @@ private:
static std::vector<Glib::ustring> initialise_default_interface_names();
static void configure_interface_names(XfcePanelPlugin *xfce_plugin);
- XfcePanelPlugin *xfce_plugin; // Needed to allow do_measure to call
- // get_interface_name(xfce_plugin)
-
- bool fixed_max_priv;
+ bool fixed_max;
guint64 max_value; // maximum measured capacity of line
long int time_difference; // no. of msecs. between the last two calls
@@ -394,14 +391,14 @@ class TemperatureMonitor: public Monitor
public:
// no. in the temperature features
- TemperatureMonitor(int no, int interval, bool fixed_max, double max,
+ TemperatureMonitor(int no, int interval, bool fixed_max_, double max,
const Glib::ustring &tag_string, bool add_to_text_overlay,
Plugin& plugin);
- virtual bool fixed_max();
virtual Glib::ustring format_value(double val, bool compact = false);
virtual Glib::ustring get_name();
virtual Glib::ustring get_short_name();
+ virtual bool has_fixed_max();
virtual double max();
virtual void save(XfceRc *settings_w);
virtual int update_interval();
@@ -415,7 +412,7 @@ private:
virtual double do_measure();
double max_value;
- bool fixed_max_priv;
+ bool fixed_max;
int chip_no, feature_no, sensors_no;
std::string description;
};
@@ -426,14 +423,14 @@ class FanSpeedMonitor: public Monitor
public:
// no. in the fan features
- FanSpeedMonitor(int no, int interval, bool fixed_max, double max,
+ FanSpeedMonitor(int no, int interval, bool fixed_max_, double max,
const Glib::ustring &tag_string, bool add_to_text_overlay,
Plugin& plugin);
- virtual bool fixed_max();
virtual Glib::ustring format_value(double val, bool compact = false);
virtual Glib::ustring get_name();
virtual Glib::ustring get_short_name();
+ virtual bool has_fixed_max();
virtual double max();
virtual void save(XfceRc *settings_w);
virtual int update_interval();
@@ -447,7 +444,7 @@ private:
virtual double do_measure();
double max_value;
- bool fixed_max_priv;
+ bool fixed_max;
int chip_no, feature_no, sensors_no;
std::string description;
};
@@ -465,23 +462,23 @@ public:
NUM_DIRECTIONS
};
- GenericMonitor(const Glib::ustring &file_path,
- const bool value_from_contents,
+ GenericMonitor(const Glib::ustring &file_path_,
+ const bool value_from_contents_,
const Glib::ustring ®ex_string,
- const bool follow_change,
- const ValueChangeDirection dir,
- const Glib::ustring &data_source_name_long,
- const Glib::ustring &data_source_name_short,
- const Glib::ustring &units_long,
- const Glib::ustring &units_short,
- int interval, bool fixed_max, double max,
+ const bool follow_change_,
+ const ValueChangeDirection dir_,
+ const Glib::ustring &data_source_name_long_,
+ const Glib::ustring &data_source_name_short_,
+ const Glib::ustring &units_long_,
+ const Glib::ustring &units_short_,
+ int interval, bool fixed_max_, double max,
const Glib::ustring &tag_string, bool add_to_text_overlay,
Plugin& plugin);
- virtual bool fixed_max();
virtual Glib::ustring format_value(double val, bool compact=false);
virtual Glib::ustring get_name();
virtual Glib::ustring get_short_name();
+ virtual bool has_fixed_max();
virtual double max();
virtual void save(XfceRc *settings_w);
virtual int update_interval();
@@ -498,7 +495,7 @@ private:
Glib::ustring file_path, data_source_name_long,
data_source_name_short, units_long, units_short, tag;
- bool fixed_max_priv, follow_change, value_from_contents;
+ bool fixed_max, follow_change, value_from_contents;
ValueChangeDirection dir;
Glib::RefPtr<Glib::Regex> regex;
};
@@ -530,7 +527,7 @@ private:
~Sensors();
// get a list of available features that contains base (e.g. "temp")
- FeatureInfoSequence get_features(std::string base);
+ FeatureInfoSequence get_features(const std::string &base);
#if HAVE_LIBSENSORS
std::vector<sensors_chip_name> chips;
diff --git a/src/monitor.hpp b/src/monitor.hpp
index bbcc332..66a24cd 100644
--- a/src/monitor.hpp
+++ b/src/monitor.hpp
@@ -88,9 +88,6 @@ public:
// The max value that the monitor may attain
virtual double max() = 0;
- // Indicate whether the monitor's max is fixed or not
- virtual bool fixed_max() = 0;
-
/* Convert float to string which represents an actual number with the
* appropriate unit */
virtual Glib::ustring format_value(double val, bool compact = false) = 0;
@@ -101,6 +98,9 @@ public:
// Return a short name
virtual Glib::ustring get_short_name() = 0;
+ // Indicate whether the monitor's max is fixed or not
+ virtual bool has_fixed_max() = 0;
+
/* The interval between updates in milliseconds, user configurable
* The default value is static per monitor implementation as you can't have
* static virtual members */
diff --git a/src/plugin.cpp b/src/plugin.cpp
index 0c454cd..2830414 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -86,7 +86,7 @@ extern "C" void plugin_construct(XfcePanelPlugin* xfce_plugin)
}
// Does not need C linkage as its called via a function pointer?
-void plugin_free(XfcePanelPlugin* xfce_plugin, Plugin* plugin)
+void plugin_free(XfcePanelPlugin* xfce_plugin, Plugin* plugin) // NOLINT - unused parameter
{
// Called by 'free-data' signal
delete plugin;
@@ -149,8 +149,8 @@ gboolean size_changed(XfcePanelPlugin* xfce_plugin, gint size, Plugin* plugin)
* */
-Plugin::Plugin(XfcePanelPlugin *xfce_plugin)
- : xfce_plugin(xfce_plugin),
+Plugin::Plugin(XfcePanelPlugin *xfce_plugin_)
+ : xfce_plugin(xfce_plugin_),
// Setting defaults
icon_path("/usr/share/pixmaps/xfce4-hardware-monitor-plugin.png"),
@@ -166,6 +166,7 @@ Plugin::Plugin(XfcePanelPlugin *xfce_plugin)
viewer_text_overlay_format_string("%a %m"),
viewer_text_overlay_separator(" "),
viewer_text_overlay_font(""),
+ viewer_text_overlay_use_font(false),
viewer_text_overlay_color(0x000000FF),
viewer_text_overlay_position(CanvasView::top_left),
viewer_monitor_type_sync_enabled(true)
@@ -254,8 +255,8 @@ Plugin::Plugin(XfcePanelPlugin *xfce_plugin)
* in the plugin but the plugin pointer, swapped results in the signal
* handler getting the plugin reference first - the plugin pointer is
* passed next, but since the handler only takes one parameter this is
- * discarded */
- // Providing About option
+ * discarded
+ * Providing About option */
g_signal_connect_swapped(xfce_plugin, "about", G_CALLBACK(display_about),
this);
@@ -319,20 +320,20 @@ Plugin::~Plugin()
}
}
-void Plugin::set_view(View *v)
+void Plugin::set_view(View *view_)
{
if (view.get())
for (monitor_iter i = monitors.begin(), end = monitors.end(); i != end; ++i)
view->detach(*i);
- view.reset(v);
- view->display(*this);
+ view.reset(view_);
+ view->display();
for (monitor_iter i = monitors.begin(), end = monitors.end(); i != end; ++i)
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
@@ -343,7 +344,7 @@ void Plugin::viewer_type_listener(const Glib::ustring viewer_type,
if (viewer_type == "curve")
{
if (force_update || !dynamic_cast<CurveView *>(view.get()))
- set_view(new CurveView);
+ set_view(new CurveView(*this));
}
else if (viewer_type == "bar")
{
@@ -351,26 +352,26 @@ void Plugin::viewer_type_listener(const Glib::ustring viewer_type,
// Thus, we much also check the oriententation
BarView *bar_view = dynamic_cast<BarView *>(view.get());
if (force_update || !(bar_view && bar_view->is_horizontal()) )
- set_view(new BarView);
+ set_view(new BarView(*this));
}
else if (viewer_type == "vbar")
{
// Same situation as with "bar"
BarView *bar_view = dynamic_cast<BarView *>(view.get());
if (force_update || !(bar_view && !bar_view->is_horizontal()) )
- set_view(new BarView(false));
+ set_view(new BarView(*this, false));
}
else if (viewer_type == "text") {
if (force_update || !dynamic_cast<TextView *>(view.get()))
- set_view(new TextView);
+ set_view(new TextView(*this));
}
else if (viewer_type == "flame") {
if (force_update || !dynamic_cast<FlameView *>(view.get()))
- set_view(new FlameView);
+ set_view(new FlameView(*this));
}
else if (viewer_type == "column") {
if (force_update || !dynamic_cast<ColumnView *>(view.get()))
- set_view(new ColumnView);
+ set_view(new ColumnView(*this));
}
// Make sure the view sets the background
@@ -521,7 +522,7 @@ void Plugin::set_viewer_size(const int size)
// See header file viewer_size_configured notes
// Obtaining current widget dimensions
- GtkRequisition req_size;
+ GtkRequisition req_size; // NOLINT - initialisation just below...
gtk_widget_size_request(GTK_WIDGET(xfce_plugin), &req_size);
/*
@@ -557,7 +558,7 @@ const Glib::ustring Plugin::get_viewer_font()
return viewer_font;
}
-void Plugin::set_viewer_font(const Glib::ustring font_details)
+void Plugin::set_viewer_font(const Glib::ustring &font_details)
{
viewer_font = font_details;
}
@@ -587,7 +588,8 @@ const Glib::ustring Plugin::get_viewer_text_overlay_format_string()
return viewer_text_overlay_format_string;
}
-void Plugin::set_viewer_text_overlay_format_string(const Glib::ustring format_string)
+void Plugin::set_viewer_text_overlay_format_string(
+ const Glib::ustring &format_string)
{
viewer_text_overlay_format_string = format_string;
}
@@ -597,7 +599,7 @@ const Glib::ustring Plugin::get_viewer_text_overlay_separator() const
return viewer_text_overlay_separator;
}
-void Plugin::set_viewer_text_overlay_separator(const Glib::ustring separator)
+void Plugin::set_viewer_text_overlay_separator(const Glib::ustring &separator)
{
viewer_text_overlay_separator = separator;
}
@@ -617,7 +619,7 @@ const Glib::ustring Plugin::get_viewer_text_overlay_font()
return viewer_text_overlay_font;
}
-void Plugin::set_viewer_text_overlay_font(const Glib::ustring font_details)
+void Plugin::set_viewer_text_overlay_font(const Glib::ustring &font_details)
{
viewer_text_overlay_font = font_details;
}
@@ -730,16 +732,16 @@ void Plugin::remove_monitor(Monitor *monitor)
delete monitor;
}
-void Plugin::replace_monitor(Monitor *prev_mon, Monitor *new_mon)
+void Plugin::replace_monitor(Monitor *prev_monitor, Monitor *new_monitor)
{
// Locating monitor of interest
- monitor_iter i = std::find(monitors.begin(), monitors.end(), prev_mon);
+ monitor_iter i = std::find(monitors.begin(), monitors.end(), prev_monitor);
assert(i != monitors.end());
// Basic configuration
//add_sync_for(new_mon);
- *i = new_mon;
- new_mon->set_settings_dir(prev_mon->get_settings_dir());
+ *i = new_monitor;
+ new_monitor->set_settings_dir(prev_monitor->get_settings_dir());
// Search for a writeable settings file, create one if it doesnt exist
gchar* file = xfce_panel_plugin_save_location(xfce_plugin, true);
@@ -751,7 +753,7 @@ void Plugin::replace_monitor(Monitor *prev_mon, Monitor *new_mon)
g_free(file);
// Saving settings
- new_mon->save(settings_w);
+ new_monitor->save(settings_w);
// Close settings file
xfce_rc_close(settings_w);
@@ -765,13 +767,13 @@ void Plugin::replace_monitor(Monitor *prev_mon, Monitor *new_mon)
// Reattach monitor if its attached to the current view
if (view.get()) {
- view->detach(prev_mon);
- view->attach(new_mon);
+ view->detach(prev_monitor);
+ view->attach(new_monitor);
}
// Deleting previous monitor
- //remove_sync_for(prev_mon);
- delete prev_mon;
+ //remove_sync_for(prev_monitor);
+ delete prev_monitor;
}
/*
diff --git a/src/plugin.hpp b/src/plugin.hpp
index a8169e0..21c7e31 100644
--- a/src/plugin.hpp
+++ b/src/plugin.hpp
@@ -51,7 +51,7 @@ class View;
class Plugin: public Gtk::EventBox
{
public:
- Plugin(XfcePanelPlugin *xfce_plugin);
+ Plugin(XfcePanelPlugin *xfce_plugin_);
~Plugin();
Gtk::Container &get_container();
@@ -59,7 +59,7 @@ public:
unsigned int get_fg_color(); // return varying foreground colours
int get_size() const; // in pixels
bool horizontal() const; // whether we're in horizontal mode
- void set_view(View *view); // use this view to monitor
+ void set_view(View *view_); // use this view to monitor
/* The following have been created to access properties that used to
* be publically available through GConf, but are private data in the
@@ -70,19 +70,19 @@ public:
int get_viewer_size() const;
void set_viewer_size(const int size);
const Glib::ustring get_viewer_font();
- void set_viewer_font(const Glib::ustring font_details);
+ 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();
- void set_viewer_text_overlay_format_string(const Glib::ustring format_string);
+ void set_viewer_text_overlay_format_string(const Glib::ustring &format_string);
const Glib::ustring get_viewer_text_overlay_separator() const;
- void set_viewer_text_overlay_separator(const Glib::ustring separator);
+ void set_viewer_text_overlay_separator(const Glib::ustring &separator);
bool get_viewer_text_overlay_use_font() const;
void set_viewer_text_overlay_use_font(bool enabled);
const Glib::ustring get_viewer_text_overlay_font();
- void set_viewer_text_overlay_font(const Glib::ustring font_details);
+ void set_viewer_text_overlay_font(const Glib::ustring &font_details);
const unsigned int get_viewer_text_overlay_color() const;
void set_viewer_text_overlay_color(const unsigned int color);
const CanvasView::TextOverlayPosition get_viewer_text_overlay_position();
@@ -92,7 +92,7 @@ public:
/* 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,
+ void viewer_type_listener(const Glib::ustring &viewer_type,
bool force_update=false);
void background_color_listener(unsigned int background_color);
diff --git a/src/preferences-window.cpp b/src/preferences-window.cpp
index 2843f96..df85e09 100644
--- a/src/preferences-window.cpp
+++ b/src/preferences-window.cpp
@@ -22,6 +22,7 @@
#include <sigc++/bind.h>
#include <cassert>
+#include <cmath> // For rounding
#include <iostream>
#include <gtkmm/linkbutton.h>
@@ -43,7 +44,7 @@ void PreferencesWindow::connect_monitor_colorbutton(Gtk::ColorButton
colorbutton));
}
-PreferencesWindow::PreferencesWindow(Plugin &plugin_, monitor_seq monitors)
+PreferencesWindow::PreferencesWindow(Plugin &plugin_, monitor_seq monitors) // NOLINT - considers lots of members not initialised due to get_widget calls
: plugin(plugin_)
{
// Now we are forced to use top-level widgets this is much more over the top...
@@ -330,7 +331,7 @@ namespace
/* Originally gconf callbacks
* This code is separated out from the radiobutton toggling code as the
* PreferencesWindow constructor needs to set up the UI via this too */
-void PreferencesWindow::viewer_type_listener(const Glib::ustring viewer_type,
+void PreferencesWindow::viewer_type_listener(const Glib::ustring &viewer_type,
bool enable)
{
if (viewer_type == "curve")
@@ -415,7 +416,7 @@ void PreferencesWindow::size_listener(int viewer_size)
// This works with more than one font button now
void PreferencesWindow::font_listener(Gtk::CheckButton *checkbutton,
Gtk::FontButton *font_button,
- const Glib::ustring viewer_font)
+ const Glib::ustring &viewer_font)
{
if (viewer_font.empty())
checkbutton->set_active(false);
@@ -487,8 +488,9 @@ namespace
}
}
-void PreferencesWindow::sync_conf_with_colorbutton(Glib::ustring settings_dir,
- Glib::ustring setting_name, Gtk::ColorButton *button)
+void PreferencesWindow::sync_conf_with_colorbutton(
+ const Glib::ustring &settings_dir, const Glib::ustring &setting_name,
+ Gtk::ColorButton *button)
{
// Search for a writeable settings file, create one if it doesnt exist
@@ -796,8 +798,8 @@ void PreferencesWindow::on_size_scale_changed()
// Preventing further callbacks firing
size_scale_cb.block();
- // Adding 0.5 to current scale value??
- int i = int(size_scale->get_value() + 0.5);
+ // Rounding up scale
+ int i = lround(size_scale->get_value());
size_scale->set_value(i);
/* Saving pixel value of scale
@@ -868,20 +870,20 @@ void PreferencesWindow::on_text_overlay_checkbutton_toggled()
save_text_overlay_enabled(active);
}
-bool PreferencesWindow::on_text_overlay_format_string_focus_out(GdkEventFocus *event)
+bool PreferencesWindow::on_text_overlay_format_string_focus_out(GdkEventFocus *event) // NOLINT - unused parameter
{
save_text_overlay_format_string(text_overlay_format_string_entry->get_text());
// Allow event to propagate
- return FALSE;
+ return FALSE; // NOLINT - interacting with C code so FALSE is fine?
}
-bool PreferencesWindow::on_text_overlay_separator_focus_out(GdkEventFocus *event)
+bool PreferencesWindow::on_text_overlay_separator_focus_out(GdkEventFocus *event) // NOLINT - unused parameter
{
save_text_overlay_separator(text_overlay_separator_entry->get_text());
// Allow event to propagate
- return FALSE;
+ return FALSE; // NOLINT - interacting with C code so FALSE is fine?
}
void PreferencesWindow::on_text_overlay_font_checkbutton_toggled()
@@ -1074,7 +1076,7 @@ void PreferencesWindow::on_close_button_clicked()
window->hide();
}
-bool PreferencesWindow::on_closed(GdkEventAny *)
+bool PreferencesWindow::on_closed(GdkEventAny *) // NOLINT - unused parameter
{
window->hide();
return false;
@@ -1087,13 +1089,13 @@ Monitor *PreferencesWindow::run_choose_monitor_window(const Glib::ustring &str)
return chooser.run(str);
}
-void PreferencesWindow::add_to_monitors_list(Monitor *mon)
+void PreferencesWindow::add_to_monitors_list(Monitor *monitor)
{
MonitorColumns mc;
store_iter i = monitor_store->append();
- (*i)[mc.name] = mon->get_name();
- (*i)[mc.monitor] = mon;
+ (*i)[mc.name] = monitor->get_name();
+ (*i)[mc.monitor] = monitor;
monitor_treeview->get_selection()->select(i);
}
@@ -1127,7 +1129,7 @@ int PreferencesWindow::pixels_to_size_scale(int pixels)
return min_i;
}
-void PreferencesWindow::save_font_details(Glib::ustring font_details)
+void PreferencesWindow::save_font_details(const Glib::ustring &font_details)
{
plugin.set_viewer_font(font_details);
@@ -1188,7 +1190,8 @@ void PreferencesWindow::save_monitor_type_sync_enabled(bool enabled)
}
}
-void PreferencesWindow::save_text_overlay_font_details(Glib::ustring font_details)
+void PreferencesWindow::save_text_overlay_font_details(
+ const Glib::ustring &font_details)
{
plugin.set_viewer_text_overlay_font(font_details);
@@ -1249,7 +1252,8 @@ void PreferencesWindow::save_text_overlay_enabled(bool enabled)
}
}
-void PreferencesWindow::save_text_overlay_format_string(const Glib::ustring format_string)
+void PreferencesWindow::save_text_overlay_format_string(
+ const Glib::ustring &format_string)
{
plugin.set_viewer_text_overlay_format_string(format_string);
@@ -1281,7 +1285,8 @@ void PreferencesWindow::save_text_overlay_format_string(const Glib::ustring form
}
}
-void PreferencesWindow::save_text_overlay_separator(const Glib::ustring separator)
+void PreferencesWindow::save_text_overlay_separator(
+ const Glib::ustring &separator)
{
plugin.set_viewer_text_overlay_separator(separator);
diff --git a/src/preferences-window.hpp b/src/preferences-window.hpp
index 4e69902..a6f8697 100644
--- a/src/preferences-window.hpp
+++ b/src/preferences-window.hpp
@@ -47,7 +47,7 @@ class Plugin;
class PreferencesWindow: public sigc::trackable
{
public:
- PreferencesWindow(Plugin &plugin, monitor_seq monitors);
+ PreferencesWindow(Plugin &plugin_, monitor_seq monitors);
~PreferencesWindow();
void show();
@@ -106,12 +106,12 @@ private:
Glib::RefPtr<Gtk::ListStore> text_overlay_position_store;
// Originally gconf callbacks
- void viewer_type_listener(const Glib::ustring viewer_type, bool enable);
+ void viewer_type_listener(const Glib::ustring &viewer_type, bool enable);
void background_color_listener(unsigned int background_color);
void use_background_color_listener(bool use_background_color);
void size_listener(int viewer_size);
void font_listener(Gtk::CheckButton *checkbutton, Gtk::FontButton *font_button,
- const Glib::ustring viewer_font);
+ const Glib::ustring &viewer_font);
void monitor_color_listener(unsigned int color);
void text_overlay_color_listener(unsigned int color);
@@ -160,16 +160,16 @@ private:
// for converting between size_scale units and pixels
int size_scale_to_pixels(int size);
int pixels_to_size_scale(int pixels);
- void sync_conf_with_colorbutton(Glib::ustring settings_dir,
- Glib::ustring setting_name, Gtk::ColorButton *button);
+ void sync_conf_with_colorbutton(const Glib::ustring &settings_dir,
+ const Glib::ustring &setting_name, Gtk::ColorButton *button);
void connect_monitor_colorbutton(Gtk::ColorButton *colorbutton);
- void save_font_details(Glib::ustring font_details);
+ void save_font_details(const 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);
- void save_text_overlay_separator(const Glib::ustring separator);
+ void save_text_overlay_font_details(const Glib::ustring &font_details);
+ void save_text_overlay_format_string(const Glib::ustring &format_string);
+ void save_text_overlay_separator(const Glib::ustring &separator);
Plugin &plugin;
};
diff --git a/src/text-view.cpp b/src/text-view.cpp
index 85eef96..623743a 100644
--- a/src/text-view.cpp
+++ b/src/text-view.cpp
@@ -35,9 +35,9 @@
class Text
{
public:
- Text(Monitor *monitor);
+ explicit Text(Monitor *monitor_);
- void add_to_table(Gtk::Table &table, int col, int row);
+ void add_to_table(Gtk::Table &table, int col, int row); // NOLINT - TODO: complaints about table, but making it const causes further warnings - need more understanding on this
void update(const Glib::ustring &font);
Monitor *monitor;
@@ -46,8 +46,8 @@ private:
std::auto_ptr<Gtk::Label> label;
};
-Text::Text(Monitor *mon)
- : monitor(mon)
+Text::Text(Monitor *monitor_)
+ : monitor(monitor_)
{
}
@@ -81,8 +81,8 @@ void Text::update(const Glib::ustring &font)
}
-TextView::TextView()
- : View(false)
+TextView::TextView(Plugin &plugin_)
+ : View(false, plugin_)
{
}
@@ -90,7 +90,7 @@ TextView::TextView()
void TextView::do_display()
{
background_box.add(table);
- plugin->get_container().add(background_box);
+ plugin.get_container().add(background_box);
table.show();
background_box.show();
@@ -100,7 +100,7 @@ void TextView::do_update()
{
// Update
for (text_iterator i = texts.begin(), end = texts.end(); i != end; ++i)
- (*i)->update(plugin->get_viewer_font());
+ (*i)->update(plugin.get_viewer_font());
}
void TextView::do_attach(Monitor *monitor)
@@ -127,7 +127,7 @@ void TextView::do_detach(Monitor *monitor)
return;
}
- g_assert_not_reached();
+ g_assert_not_reached(); // NOLINT
}
void TextView::do_set_background(unsigned int color)
diff --git a/src/text-view.hpp b/src/text-view.hpp
index 5476e83..049edaa 100644
--- a/src/text-view.hpp
+++ b/src/text-view.hpp
@@ -32,7 +32,7 @@ class Text;
class TextView: public View
{
public:
- TextView();
+ TextView(Plugin &plugin_);
private:
virtual void do_display();
diff --git a/src/value-history.cpp b/src/value-history.cpp
index 70960f4..08618ff 100644
--- a/src/value-history.cpp
+++ b/src/value-history.cpp
@@ -25,8 +25,8 @@
#include "plugin.hpp"
-ValueHistory::ValueHistory(Monitor *mon)
- : monitor(mon), max_value(0), waits_remaining(0)
+ValueHistory::ValueHistory(Monitor *monitor_)
+ : monitor(monitor_), max_value(0), max_count(0), waits_remaining(0)
{
wait_iterations = monitor->update_interval() / Plugin::update_interval;
}
diff --git a/src/value-history.hpp b/src/value-history.hpp
index 4300353..9c770de 100644
--- a/src/value-history.hpp
+++ b/src/value-history.hpp
@@ -27,7 +27,7 @@ class Monitor;
class ValueHistory
{
public:
- ValueHistory(Monitor *monitor);
+ ValueHistory(Monitor *monitor_);
// perform a measurement if needed, new_value is set to true if it was
void update(unsigned int max_samples, bool &new_value);
diff --git a/src/view.cpp b/src/view.cpp
index de4ad06..0db70b8 100644
--- a/src/view.cpp
+++ b/src/view.cpp
@@ -19,8 +19,8 @@
#include "view.hpp"
-View::View(bool kh)
- : keeps_history(kh)
+View::View(bool keeps_history_, Plugin &plugin_)
+ : keeps_history(keeps_history_), plugin(plugin_)
{
}
@@ -28,9 +28,8 @@ View::View::~View()
{
}
-void View::display(Plugin &a)
+void View::display()
{
- plugin = &a;
do_display();
}
diff --git a/src/view.hpp b/src/view.hpp
index 8cee1a3..88875e5 100644
--- a/src/view.hpp
+++ b/src/view.hpp
@@ -36,10 +36,10 @@ class Monitor;
class View: noncopyable
{
public:
- View(bool keeps_history);
+ View(bool keeps_history_, Plugin &plugin_);
virtual ~View();
- void display(Plugin &plugin);
+ void display();
void update();
void attach(Monitor *monitor);
void detach(Monitor *monitor);
@@ -50,7 +50,7 @@ public:
bool const keeps_history;
protected:
- Plugin *plugin; // store pointer for reference
+ Plugin &plugin;
private:
// for derived classes to override
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list