[Xfce4-commits] [panel-plugins/xfce4-hardware-monitor-plugin] 05/18: Remove load method from monitors - all state should be set through constructor, load_monitors is the main place
noreply at xfce.org
noreply at xfce.org
Tue Jun 28 21:33:27 CEST 2016
This is an automated email from the git hooks/post-receive script.
omegaphil pushed a commit to branch omegaphil/graph-disk-io
in repository panel-plugins/xfce4-hardware-monitor-plugin.
commit 696cfb0012d26c5554f962aa7bfe8df9abf633ed
Author: OmegaPhil <OmegaPhil at startmail.com>
Date: Fri Jun 10 22:08:57 2016 +0100
Remove load method from monitors - all state should be set through constructor, load_monitors is the main place
---
src/applet.cpp | 55 +----------------------
src/monitor-impls.cpp | 122 --------------------------------------------------
src/monitor-impls.hpp | 5 ---
src/monitor.hpp | 5 ---
4 files changed, 1 insertion(+), 186 deletions(-)
diff --git a/src/applet.cpp b/src/applet.cpp
index dcc6509..6032c60 100644
--- a/src/applet.cpp
+++ b/src/applet.cpp
@@ -640,9 +640,6 @@ void Applet::add_monitor(Monitor *monitor)
add_sync_for(monitor);
monitors.push_back(monitor);
- /* Read and write config locations and the open call are different in XFCE4 -
- * hence the duplication here */
-
/* Checking if monitor has a defined settings directory and therefore
* settings to load */
if (monitor->get_settings_dir().empty())
@@ -672,32 +669,6 @@ void Applet::add_monitor(Monitor *monitor)
"order to save monitor in add_monitor call!\n");
}
}
- else
- {
- /* Monitor has a saved settings directory and therefore settings to
- * load
- * Search for settings file */
- gchar* file = xfce_panel_plugin_lookup_rc_file(panel_applet);
-
- if (file)
- {
- // One exists - loading readonly settings
- XfceRc* settings_ro = xfce_rc_simple_open(file, true);
- g_free(file);
-
- // Load settings for monitor
- monitor->load(settings_ro);
-
- // Close settings file
- xfce_rc_close(settings_ro);
- }
- else
- {
- // Unable to obtain read only config file - informing user
- std::cerr << _("Unable to obtain read-only config file path in "
- "order to load monitor settings in add_monitor call!\n");
- }
- }
// Attaching monitor to view
if (view.get())
@@ -753,32 +724,8 @@ void Applet::replace_monitor(Monitor *prev_mon, Monitor *new_mon)
*i = new_mon;
new_mon->set_settings_dir(prev_mon->get_settings_dir());
- /* Loading monitor with previous monitor's settings - XFCE4 needs
- * different code to read a config file as compared to writing to it
- * Search for settings file */
- gchar* file = xfce_panel_plugin_lookup_rc_file(panel_applet);
-
- if (file)
- {
- // One exists - loading readonly settings
- XfceRc* settings_ro = xfce_rc_simple_open(file, true);
- g_free(file);
-
- // Load settings
- new_mon->load(settings_ro);
-
- // Close settings file
- xfce_rc_close(settings_ro);
- }
- else
- {
- // Unable to obtain read-only config file - informing user
- std::cerr << _("Unable to obtain read-only config file path in "
- "order to load monitor settings in replace_monitor call!\n");
- }
-
// Search for a writeable settings file, create one if it doesnt exist
- file = xfce_panel_plugin_save_location(panel_applet, true);
+ gchar* file = xfce_panel_plugin_save_location(panel_applet, true);
if (file)
{
diff --git a/src/monitor-impls.cpp b/src/monitor-impls.cpp
index 0e9549f..510f4c2 100644
--- a/src/monitor-impls.cpp
+++ b/src/monitor-impls.cpp
@@ -544,18 +544,6 @@ void LoadAverageMonitor::save(XfceRc *settings_w)
xfce_rc_write_entry(settings_w, "max", setting.c_str());
}
-void LoadAverageMonitor::load(XfceRc *settings_ro)
-{
- // Fetching assigned settings group
- Glib::ustring dir = get_settings_dir();
-
- // Loading settings - no support for floats, unstringifying
- xfce_rc_set_group(settings_ro, dir.c_str());
- Glib::ustring type = xfce_rc_read_entry(settings_ro, "type", "");
- if (type == "load_average")
- max_value = atof(xfce_rc_read_entry(settings_ro, "max", "5"));
-}
-
//
// class MemoryUsageMonitor
@@ -847,47 +835,6 @@ void DiskStatsMonitor::save(XfceRc *settings_w)
xfce_rc_write_entry(settings_w, "tag", tag.c_str());
}
-void DiskStatsMonitor::load(XfceRc *settings_ro)
-{
- /*
- * // TODO: This seems to be completely unnecessary - loading/configuration is already done in load_monitors, looks like that should be moved into individual monitor ::load functions?
- // Fetching assigned settings group
- Glib::ustring dir = get_settings_dir();
-
- // Loading settings
- xfce_rc_set_group(settings_ro, dir.c_str());
- Glib::ustring type = xfce_rc_read_entry(settings_ro, "type", "");
- device_name = xfce_rc_read_entry(settings_ro, "disk_stats_device", "");
- int stat = xfce_rc_read_int_entry(settings_ro, "interface_type",
- int(num_reads_completed));
-
- // Validating input - an enum does not enforce a range!!
- if (stat < num_reads_completed || stat >= NUM_STATS)
- {
- std::cerr << "DiskStatsMonitor::load has read configuration specifying an "
- "invalid statistic: " << stat << "!\n";
- stat = num_reads_completed;
- }
- else
- inter_type = static_cast<InterfaceType>(inter_type_int);
-
- Direction inter_direction;
- if (inter_direction_int < all_data || inter_direction_int >= NUM_DIRECTIONS)
- {
- std::cerr << "NetworkLoadMonitor::load has read configuration specifying an "
- "invalid direction: " << inter_direction_int << "!\n";
- inter_direction = all_data;
- }
- else
- inter_direction = static_cast<Direction>(inter_direction_int);
-
- // Making sure the monitor type is correct to load further configuration??
- if (type == "network_load" && inter_type == interface_type
- && inter_direction == direction)
- max_value = xfce_rc_read_int_entry(settings_ro, "max", 0);
- */
-}
-
bool DiskStatsMonitor::stats_available()
{
// Make sure file exists
@@ -1282,47 +1229,6 @@ void NetworkLoadMonitor::save(XfceRc *settings_w)
xfce_rc_write_entry(settings_w, "tag", tag.c_str());
}
-void NetworkLoadMonitor::load(XfceRc *settings_ro)
-{
- // Fetching assigned settings group
- Glib::ustring dir = get_settings_dir();
-
- // Loading settings
- xfce_rc_set_group(settings_ro, dir.c_str());
- Glib::ustring type = xfce_rc_read_entry(settings_ro, "type", "");
- int inter_type_int = xfce_rc_read_int_entry(settings_ro, "interface_type",
- int(ethernet_first));
- int inter_direction_int = xfce_rc_read_int_entry(settings_ro,
- "interface_direction",
- int(all_data));
-
- // Validating input - an enum does not enforce a range!!
- InterfaceType inter_type;
- if (inter_type_int < ethernet_first || inter_type_int >= NUM_INTERFACE_TYPES)
- {
- std::cerr << "NetworkLoadMonitor::load has read configuration specifying an "
- "invalid interface type: " << inter_type_int << "!\n";
- inter_type = ethernet_first;
- }
- else
- inter_type = static_cast<InterfaceType>(inter_type_int);
-
- Direction inter_direction;
- if (inter_direction_int < all_data || inter_direction_int >= NUM_DIRECTIONS)
- {
- std::cerr << "NetworkLoadMonitor::load has read configuration specifying an "
- "invalid direction: " << inter_direction_int << "!\n";
- inter_direction = all_data;
- }
- else
- inter_direction = static_cast<Direction>(inter_direction_int);
-
- // Making sure the monitor type is correct to load further configuration??
- if (type == "network_load" && inter_type == interface_type
- && inter_direction == direction)
- max_value = xfce_rc_read_int_entry(settings_ro, "max", 0);
-}
-
void NetworkLoadMonitor::possibly_add_sync_with(Monitor *other)
{
if (NetworkLoadMonitor *o = dynamic_cast<NetworkLoadMonitor *>(other))
@@ -1964,21 +1870,6 @@ void TemperatureMonitor::save(XfceRc *settings_w)
xfce_rc_write_entry(settings_w, "max", setting.c_str());
}
-void TemperatureMonitor::load(XfceRc *settings_ro)
-{
- // Fetching assigned settings group
- Glib::ustring dir = get_settings_dir();
-
- /* Loading settings, making sure the right sensor is loaded. No support
- * for floats, unstringifying */
- xfce_rc_set_group(settings_ro, dir.c_str());
- Glib::ustring type = xfce_rc_read_entry(settings_ro, "type", "");
- if (type == "temperature" && xfce_rc_read_int_entry(settings_ro,
- "temperature_no", 0) == sensors_no)
- max_value = atof(xfce_rc_read_entry(settings_ro, "max", "40"));
-}
-
-
//
// class FanSpeedMonitor
@@ -2061,16 +1952,3 @@ void FanSpeedMonitor::save(XfceRc *settings_w)
xfce_rc_write_entry(settings_w, "max", setting.c_str());
}
-void FanSpeedMonitor::load(XfceRc *settings_ro)
-{
- // Fetching assigned settings group
- Glib::ustring dir = get_settings_dir();
-
- /* Loading settings, making sure the right fan is loaded. No support
- * for floats, unstringifying */
- xfce_rc_set_group(settings_ro, dir.c_str());
- Glib::ustring type = xfce_rc_read_entry(settings_ro, "type", "");
- int fan_no = xfce_rc_read_int_entry(settings_ro, "fan_no", 0);
- if (type == "fan_speed" && fan_no == sensors_no)
- max_value = atof(xfce_rc_read_entry(settings_ro, "max", "1"));
-}
diff --git a/src/monitor-impls.hpp b/src/monitor-impls.hpp
index 3365a7e..89ed4bd 100644
--- a/src/monitor-impls.hpp
+++ b/src/monitor-impls.hpp
@@ -107,7 +107,6 @@ public:
virtual Glib::ustring get_short_name();
virtual int update_interval();
virtual void save(XfceRc *settings_w);
- virtual void load(XfceRc *settings_ro);
private:
virtual double do_measure();
@@ -190,7 +189,6 @@ public:
virtual Glib::ustring get_short_name();
virtual int update_interval();
virtual void save(XfceRc *settings_w);
- virtual void load(XfceRc *settings_ro);
static bool stats_available();
static std::vector<Glib::ustring> current_device_names();
@@ -256,7 +254,6 @@ public:
virtual Glib::ustring get_short_name();
virtual int update_interval();
virtual void save(XfceRc *settings_w);
- virtual void load(XfceRc *settings_ro);
virtual void possibly_add_sync_with(Monitor *other);
virtual void remove_sync_with(Monitor *other);
@@ -326,7 +323,6 @@ public:
virtual Glib::ustring get_short_name();
virtual int update_interval();
virtual void save(XfceRc *settings_w);
- virtual void load(XfceRc *settings_ro);
private:
virtual double do_measure();
@@ -351,7 +347,6 @@ public:
virtual Glib::ustring get_short_name();
virtual int update_interval();
virtual void save(XfceRc *settings_w);
- virtual void load(XfceRc *settings_ro);
private:
virtual double do_measure();
diff --git a/src/monitor.hpp b/src/monitor.hpp
index 6791243..fe6e324 100644
--- a/src/monitor.hpp
+++ b/src/monitor.hpp
@@ -96,11 +96,6 @@ public:
// Save information about the monitor
virtual void save(XfceRc *settings_w) = 0;
- // Load any internal monitor state
- virtual void load(XfceRc *settings_ro)
- {
- }
-
/* If other is watching the same thing as this monitor, it might be
* a good idea to sync maxima with it */
virtual void possibly_add_sync_with(Monitor *other)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list