[Xfce4-commits] [panel-plugins/xfce4-hardware-monitor-plugin] 04/13: Make CurveView text overlay configurable
noreply at xfce.org
noreply at xfce.org
Wed Aug 12 18:39:08 CEST 2015
This is an automated email from the git hooks/post-receive script.
omegaphil pushed a commit to branch master
in repository panel-plugins/xfce4-hardware-monitor-plugin.
commit 99cd0f12d653f5081fbfbf342a08616e76f66081
Author: OmegaPhil <OmegaPhil at startmail.com>
Date: Sun Aug 2 19:35:53 2015 +0100
Make CurveView text overlay configurable
---
src/applet.cpp | 42 +++++++-
src/applet.hpp | 10 ++
src/curve-view.cpp | 145 ++++++++++++++++++--------
src/curve-view.hpp | 10 +-
src/helpers.cpp | 12 +++
src/helpers.hpp | 2 +
src/preferences-window.cpp | 243 +++++++++++++++++++++++++++++++++-----------
src/preferences-window.hpp | 15 ++-
src/ui.glade | 148 +++++++++++++++++++++++++++
9 files changed, 515 insertions(+), 112 deletions(-)
diff --git a/src/applet.cpp b/src/applet.cpp
index 9c3a7ad..24c0c6d 100644
--- a/src/applet.cpp
+++ b/src/applet.cpp
@@ -164,7 +164,10 @@ Applet::Applet(XfcePanelPlugin *plugin)
viewer_size(96), // Arbitrary default, see later in this function for notes
background_color(0x00000000), // black as the night
use_background_color(false),
- next_color(0)
+ next_color(0),
+ viewer_text_overlay_enabled(false),
+ viewer_text_overlay_format_string("%a %m"),
+ viewer_text_overlay_separator(" ")
{
// Search for settings file
XfceRc* settings_ro = NULL;
@@ -192,6 +195,13 @@ Applet::Applet(XfcePanelPlugin *plugin)
"use_background_color", use_background_color);
next_color = xfce_rc_read_int_entry(settings_ro, "next_color",
next_color);
+ viewer_text_overlay_enabled = xfce_rc_read_bool_entry(settings_ro,
+ "viewer_text_overlay_enabled", viewer_text_overlay_enabled);
+ viewer_text_overlay_format_string = xfce_rc_read_entry(settings_ro,
+ "viewer_text_overlay_format_string",
+ viewer_text_overlay_format_string.c_str());
+ viewer_text_overlay_separator = xfce_rc_read_entry(settings_ro,
+ "viewer_text_overlay_separator", viewer_text_overlay_separator.c_str());
}
// Loading icon
@@ -534,6 +544,36 @@ void Applet::set_viewer_font(const Glib::ustring font_details)
viewer_font = font_details;
}
+bool Applet::get_viewer_text_overlay_enabled() const
+{
+ return viewer_text_overlay_enabled;
+}
+
+void Applet::set_viewer_text_overlay_enabled(bool enabled)
+{
+ viewer_text_overlay_enabled = enabled;
+}
+
+const Glib::ustring Applet::get_viewer_text_overlay_format_string()
+{
+ return viewer_text_overlay_format_string;
+}
+
+void Applet::set_viewer_text_overlay_format_string(const Glib::ustring format_string)
+{
+ viewer_text_overlay_format_string = format_string;
+}
+
+const Glib::ustring Applet::get_viewer_text_overlay_separator()
+{
+ return viewer_text_overlay_separator;
+}
+
+void Applet::set_viewer_text_overlay_separator(const Glib::ustring separator)
+{
+ viewer_text_overlay_separator = separator;
+}
+
void Applet::add_monitor(Monitor *monitor)
{
add_sync_for(monitor);
diff --git a/src/applet.hpp b/src/applet.hpp
index 9b2901b..77a2da9 100644
--- a/src/applet.hpp
+++ b/src/applet.hpp
@@ -69,6 +69,12 @@ public:
void set_viewer_size(const int size);
const Glib::ustring get_viewer_font();
void set_viewer_font(const Glib::ustring font_details);
+ bool get_viewer_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);
+ const Glib::ustring get_viewer_text_overlay_separator();
+ void set_viewer_text_overlay_separator(const Glib::ustring separator);
void viewer_type_listener(const Glib::ustring viewer_type);
void background_color_listener(unsigned int background_color);
void use_background_color_listener(gboolean use_background_color);
@@ -105,6 +111,10 @@ private:
Glib::ustring icon_path;
Glib::ustring viewer_type;
Glib::ustring viewer_font;
+ bool viewer_text_overlay_enabled;
+ Glib::ustring viewer_text_overlay_format_string;
+ Glib::ustring viewer_text_overlay_separator;
+
int viewer_size;
int background_color;
gboolean use_background_color;
diff --git a/src/curve-view.cpp b/src/curve-view.cpp
index 48af6d8..6c14b46 100644
--- a/src/curve-view.cpp
+++ b/src/curve-view.cpp
@@ -26,6 +26,7 @@
#include "curve-view.hpp"
#include "applet.hpp"
+#include "helpers.hpp"
#include "monitor.hpp"
#include "ucompose.hpp"
#include "value-history.hpp"
@@ -142,9 +143,15 @@ double Curve::get_max_value()
int const CurveView::pixels_per_sample = 2;
+// Text overlay format string substitution codes
+const Glib::ustring CurveView::monitor_full = "%M";
+const Glib::ustring CurveView::monitor_compact = "%m";
+const Glib::ustring CurveView::graph_max_full = "%A";
+const Glib::ustring CurveView::graph_max_compact = "%a";
+
+
CurveView::CurveView()
- : CanvasView(true), text_overlay_enabled(false), text_overlay(NULL),
- use_compact_format(false)
+ : CanvasView(true), text_overlay(NULL)
{
}
@@ -246,38 +253,75 @@ void CurveView::do_detach(Monitor *monitor)
void CurveView::do_draw_loop()
{
double max = 0;
- Glib::ustring max_formatted, monitor_data;
-
- // Debug code
- use_compact_format = true;
- separator_string = " ";
- text_overlay_enabled = true;
+ Glib::ustring max_formatted, max_formatted_compact, monitor_data,
+ monitor_data_compact, text_overlay_format_string,
+ separator_string = applet->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 = applet->get_viewer_text_overlay_enabled();
// Obtain maximum value of all curves in the view
for (curve_iterator i = curves.begin(), end = curves.end(); i != end; ++i)
if ((*i)->get_max_value() > max)
max = (*i)->get_max_value();
+ // If the text overlay is enabled, detecting all information required to output
+ if (text_overlay_enabled)
+ {
+ text_overlay_format_string = applet->get_viewer_text_overlay_format_string();
+
+ /* Glib::ustring::npos is the strange way C++ flags as a failure to find a
+ * string */
+ if (text_overlay_format_string.find(monitor_full) != Glib::ustring::npos)
+ monitor_data_needed = true;
+ if (text_overlay_format_string.find(monitor_compact) != Glib::ustring::npos)
+ monitor_data_compact_needed = true;
+ if (text_overlay_format_string.find(graph_max_full) != Glib::ustring::npos)
+ graph_max_needed = true;
+ if (text_overlay_format_string.find(graph_max_compact) != Glib::ustring::npos)
+ graph_max_compact_needed = true;
+ }
+
for (curve_iterator i = curves.begin(), end = curves.end(); i != end; ++i)
{
if (text_overlay_enabled)
{
/* Using first monitor to obtain the text formatted value (with units) -
* this mainly makes sense if all curves belong to the same monitor type */
- if (max_formatted.empty())
- max_formatted = (*i)->monitor->format_value(max, use_compact_format);
+ if (graph_max_needed && max_formatted.empty())
+ max_formatted += "Max:" + separator_string +
+ (*i)->monitor->format_value(max, false);
+ if (graph_max_compact_needed && max_formatted_compact.empty())
+ max_formatted_compact += "M:" + (*i)->monitor->format_value(max, true);
// Collecting a string of monitor data to overlay later
- if (monitor_data.empty())
+ if (monitor_data_needed)
{
- monitor_data = (*i)->monitor->format_value((*i)->monitor->value(),
- use_compact_format);
+ if (monitor_data.empty())
+ {
+ monitor_data = (*i)->monitor->format_value((*i)->monitor->value(),
+ false);
+ }
+ else
+ {
+ monitor_data.append(separator_string +
+ (*i)->monitor->format_value((*i)->monitor->value(),
+ false));
+ }
}
- else
+ if (monitor_data_compact_needed)
{
- monitor_data.append(separator_string +
- (*i)->monitor->format_value((*i)->monitor->value(),
- use_compact_format));
+ if (monitor_data_compact.empty())
+ {
+ monitor_data_compact = (*i)->monitor
+ ->format_value((*i)->monitor->value(), true);
+ }
+ else
+ {
+ monitor_data_compact.append(separator_string +
+ (*i)->monitor->format_value((*i)->monitor->value(),
+ true));
+ }
}
}
@@ -285,33 +329,46 @@ void CurveView::do_draw_loop()
(*i)->draw(*canvas, width(), height(), max);
}
- // Determination of text to overlay
- Glib::ustring overlay_text = use_compact_format ? _("M:") : _("Max: ");
- overlay_text.append(max_formatted + separator_string + monitor_data);
-
- /* Checking if overlay is already initialised
- * Possibility that text is not shown at start up - not failing consistently
- * now though, when it does, even resetting via switching views is not enough */
- if (!text_overlay)
+ // Overlaying text of monitor values if desired
+ if (text_overlay_enabled)
{
- /* Font and colour are required to output text, anchor is used to define
- * what point on the item (canvas thing) to take as the 'centre' to then
- * place on the canvas - e.g. ANCHOR_NW means the top-left corner is the
- * 'centre' and the item will be placed exactly as you would expect it to.
- * The default is GTK_ANCHOR_CENTER, hence text gets clipped in half top
- * and side */
- text_overlay = new Gnome::Canvas::Text(*canvas->root());
- text_overlay->property_anchor() = Gtk::ANCHOR_NW;
- text_overlay->property_text() = overlay_text;
- text_overlay->property_font() = "Sans 8";
- text_overlay->property_fill_color() = "black";
-
- // Positioning text at the bottom of the canvas
- text_overlay->property_y() = applet->get_height() -
- text_overlay->property_text_height();
- }
+ /* Generation of text to overlay - C++ does not have 'replace all'
+ * functionality??? Presumably using regex would be too slow for here? */
+ Glib::ustring overlay_text = text_overlay_format_string;
+ if (monitor_data_needed)
+ find_and_replace(overlay_text, monitor_full, monitor_data);
+ if (monitor_data_compact_needed)
+ find_and_replace(overlay_text, monitor_compact, monitor_data_compact);
+ if (graph_max_needed)
+ find_and_replace(overlay_text, graph_max_full, max_formatted);
+ if (graph_max_compact_needed)
+ find_and_replace(overlay_text, graph_max_compact, max_formatted_compact);
+
+ /* Checking if overlay is already initialised
+ * Possibility that text is not shown at start up - not failing consistently
+ * now though, when it does, even resetting via switching views is not enough */
+ // TODO: Still a bug here
+ if (!text_overlay)
+ {
+ /* Font and colour are required to output text, anchor is used to define
+ * what point on the item (canvas thing) to take as the 'centre' to then
+ * place on the canvas - e.g. ANCHOR_NW means the top-left corner is the
+ * 'centre' and the item will be placed exactly as you would expect it to.
+ * The default is GTK_ANCHOR_CENTER, hence text gets clipped in half top
+ * and side */
+ text_overlay = new Gnome::Canvas::Text(*canvas->root());
+ text_overlay->property_anchor() = Gtk::ANCHOR_NW;
+ text_overlay->property_text() = overlay_text;
+ text_overlay->property_font() = "Sans 8";
+ text_overlay->property_fill_color() = "black";
+
+ // Positioning text at the bottom of the canvas
+ text_overlay->property_y() = applet->get_height() -
+ text_overlay->property_text_height();
+ }
- // It is - updating if it has changed
- else if (text_overlay->property_text() != overlay_text)
- text_overlay->property_text() = overlay_text;
+ // It is - updating if it has changed
+ else if (text_overlay->property_text() != overlay_text)
+ text_overlay->property_text() = overlay_text;
+ }
}
diff --git a/src/curve-view.hpp b/src/curve-view.hpp
index fb5f910..54a91df 100644
--- a/src/curve-view.hpp
+++ b/src/curve-view.hpp
@@ -54,11 +54,13 @@ private:
typedef curve_sequence::iterator curve_iterator;
curve_sequence curves;
- // Text 'overlay' data and settings
- bool text_overlay_enabled;
Gnome::Canvas::Text *text_overlay;
- Glib::ustring separator_string;
- bool use_compact_format;
+
+ // Text overlay format string substitution codes
+ static const Glib::ustring monitor_full;
+ static const Glib::ustring monitor_compact;
+ static const Glib::ustring graph_max_full;
+ static const Glib::ustring graph_max_compact;
};
#endif
diff --git a/src/helpers.cpp b/src/helpers.cpp
index 4b9b7ac..960a094 100644
--- a/src/helpers.cpp
+++ b/src/helpers.cpp
@@ -56,6 +56,18 @@ int warning_dialog(const Glib::ustring &msg, const Glib::ustring &title,
}
*/
+// Why does std::string or Glib::ustring not have a replace all function??
+void find_and_replace(Glib::ustring &source, const Glib::ustring &to_replace,
+ const Glib::ustring &replace_with)
+{
+ Glib::ustring::size_type pos = 0;
+ while ((pos = source.find(to_replace, pos)) != Glib::ustring::npos)
+ {
+ source = source.replace(pos, to_replace.length(), replace_with);
+ pos += replace_with.length();
+ }
+}
+
Glib::ustring truncate_string(Glib::ustring s, unsigned int n)
{
// for when a string needs to be truncated
diff --git a/src/helpers.hpp b/src/helpers.hpp
index 329708c..90867c6 100644
--- a/src/helpers.hpp
+++ b/src/helpers.hpp
@@ -42,6 +42,8 @@ private:
};
void fatal_error(const Glib::ustring &msg);
+void find_and_replace(Glib::ustring &source, const Glib::ustring &to_replace,
+ const Glib::ustring &replace_with);
/* Attempting to host the warning_dialog code here has failed completely -
* constant bullshit include errors either not allowing namespace items to be
diff --git a/src/preferences-window.cpp b/src/preferences-window.cpp
index 3b50175..d26736c 100644
--- a/src/preferences-window.cpp
+++ b/src/preferences-window.cpp
@@ -23,8 +23,6 @@
#include <sigc++/bind.h>
-#include <gtkmm/button.h>
-
#include <cassert>
#include <iostream>
@@ -104,6 +102,23 @@ PreferencesWindow::PreferencesWindow(Applet &applet_, monitor_seq monitors)
.connect(sigc::mem_fun(*this,
&PreferencesWindow::on_fontbutton_set));
+ ui->get_widget("text_overlay_outer_vbox", text_overlay_outer_vbox);
+
+ ui->get_widget("text_overlay_checkbutton", text_overlay_checkbutton);
+ text_overlay_checkbutton->signal_toggled()
+ .connect(sigc::mem_fun(*this,
+ &PreferencesWindow::on_text_overlay_checkbutton_toggled));
+
+ ui->get_widget("format_string_entry", text_overlay_format_string_entry);
+ text_overlay_format_string_entry->signal_focus_out_event()
+ .connect(sigc::mem_fun(*this,
+ &PreferencesWindow::on_text_overlay_format_string_focus_out));
+
+ ui->get_widget("separator_string_entry", text_overlay_separator_entry);
+ text_overlay_separator_entry->signal_focus_out_event()
+ .connect(sigc::mem_fun(*this,
+ &PreferencesWindow::on_text_overlay_separator_focus_out));
+
ui->get_widget("background_colorbutton", background_colorbutton);
background_colorbutton->signal_color_set()
@@ -117,8 +132,8 @@ PreferencesWindow::PreferencesWindow(Applet &applet_, monitor_seq monitors)
background_color_radiobutton->signal_toggled()
.connect(sigc::mem_fun(*this,
&PreferencesWindow::on_background_color_radiobutton_toggled));
-
-
+
+
// Connect the Monitor tab widgets
Gtk::Button *add_button;
ui->get_widget("add_button", add_button);
@@ -171,11 +186,17 @@ PreferencesWindow::PreferencesWindow(Applet &applet_, monitor_seq monitors)
connect_monitor_colorbutton(flame_colorbutton);
// Fill in values
- viewer_type_listener(applet.get_viewer_type());
+ viewer_type_listener(applet.get_viewer_type(), true);
background_color_listener(applet.get_background_color());
use_background_color_listener(applet.get_use_background_color());
size_listener(applet.get_viewer_size());
font_listener(applet.get_viewer_font());
+ if (applet.get_viewer_text_overlay_enabled())
+ text_overlay_checkbutton->set_active();
+ text_overlay_format_string_entry->
+ set_text(applet.get_viewer_text_overlay_format_string());
+ text_overlay_separator_entry->
+ set_text(applet.get_viewer_text_overlay_separator());
for (monitor_iter i = monitors.begin(), end = monitors.end();
i != end; ++i)
@@ -241,49 +262,47 @@ namespace
}
-// Originally gconf callbacks
-void PreferencesWindow::viewer_type_listener(const Glib::ustring viewer_type)
+/* 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,
+ bool enable)
{
if (viewer_type == "curve")
{
- if (!curve_radiobutton->get_active())
- curve_radiobutton->property_active() = true;
- size_outer_vbox->property_visible() = true;
- monitor_curve_options->property_visible() = true;
+ curve_radiobutton->property_active() = enable;
+ size_outer_vbox->property_visible() = enable;
+ monitor_curve_options->property_visible() = enable;
+ text_overlay_outer_vbox->property_visible() = enable;
}
else if (viewer_type == "bar")
{
- if (!bar_radiobutton->get_active())
- bar_radiobutton->property_active() = true;
- size_outer_vbox->property_visible() = true;
- monitor_bar_options->property_visible() = true;
+ bar_radiobutton->property_active() = enable;
+ size_outer_vbox->property_visible() = enable;
+ monitor_bar_options->property_visible() = enable;
}
else if (viewer_type == "vbar")
{
- if (!vbar_radiobutton->get_active())
- vbar_radiobutton->property_active() = true;
- size_outer_vbox->property_visible() = true;
- monitor_vbar_options->property_visible() = true;
+ vbar_radiobutton->property_active() = enable;
+ size_outer_vbox->property_visible() = enable;
+ monitor_vbar_options->property_visible() = enable;
}
else if (viewer_type == "column")
{
- if (!column_radiobutton->get_active())
- column_radiobutton->property_active() = true;
- size_outer_vbox->property_visible() = true;
- monitor_column_options->property_visible() = true;
+ column_radiobutton->property_active() = enable;
+ size_outer_vbox->property_visible() = enable;
+ monitor_column_options->property_visible() = enable;
}
else if (viewer_type == "text")
{
- if (!text_radiobutton->get_active())
- text_radiobutton->property_active() = true;
- font_outer_vbox->property_visible() = true;
+ text_radiobutton->property_active() = enable;
+ font_outer_vbox->property_visible() = enable;
}
else if (viewer_type == "flame")
{
- if (!flame_radiobutton->get_active())
- flame_radiobutton->property_active() = true;
- size_outer_vbox->property_visible() = true;
- monitor_flame_options->property_visible() = true;
+ flame_radiobutton->property_active() = enable;
+ size_outer_vbox->property_visible() = enable;
+ monitor_flame_options->property_visible() = enable;
}
/* Actually changing the viewer type - background color use etc is set
@@ -496,13 +515,10 @@ void PreferencesWindow::on_curve_radiobutton_toggled()
" save viewer type in "
"PreferencesWindow::on_curve_radiobutton_toggled!\n");
}
-
- // Changing viewer type
- viewer_type_listener("curve");
}
- size_outer_vbox->property_visible() = active;
- monitor_curve_options->property_visible() = active;
+ // Enabling/disabling viewer as appropriate
+ viewer_type_listener("curve", active);
}
void PreferencesWindow::on_bar_radiobutton_toggled()
@@ -536,13 +552,10 @@ void PreferencesWindow::on_bar_radiobutton_toggled()
" save viewer type in "
"PreferencesWindow::on_bar_radiobutton_toggled!\n");
}
-
- // Changing viewer type
- viewer_type_listener("bar");
}
- size_outer_vbox->property_visible() = active;
- monitor_bar_options->property_visible() = active;
+ // Enabling/disabling viewer as appropriate
+ viewer_type_listener("bar", active);
}
void PreferencesWindow::on_vbar_radiobutton_toggled()
@@ -576,13 +589,10 @@ void PreferencesWindow::on_vbar_radiobutton_toggled()
" save viewer type in "
"PreferencesWindow::on_vbar_radiobutton_toggled!\n");
}
-
- // Changing viewer type
- viewer_type_listener("vbar");
}
- size_outer_vbox->property_visible() = active;
- monitor_vbar_options->property_visible() = active;
+ // Enabling/disabling viewer as appropriate
+ viewer_type_listener("vbar", active);
}
void PreferencesWindow::on_column_radiobutton_toggled()
@@ -616,13 +626,10 @@ void PreferencesWindow::on_column_radiobutton_toggled()
" save viewer type in "
"PreferencesWindow::on_column_radiobutton_toggled!\n");
}
-
- // Changing viewer type
- viewer_type_listener("column");
}
-
- size_outer_vbox->property_visible() = active;
- monitor_column_options->property_visible() = active;
+
+ // Enabling/disabling viewer as appropriate
+ viewer_type_listener("column", active);
}
void PreferencesWindow::on_text_radiobutton_toggled()
@@ -656,12 +663,10 @@ void PreferencesWindow::on_text_radiobutton_toggled()
" save viewer type in "
"PreferencesWindow::on_text_radiobutton_toggled!\n");
}
-
- // Changing viewer type
- viewer_type_listener("text");
}
-
- font_outer_vbox->property_visible() = active;
+
+ // Enabling/disabling viewer as appropriate
+ viewer_type_listener("text", active);
}
void PreferencesWindow::on_flame_radiobutton_toggled()
@@ -695,13 +700,10 @@ void PreferencesWindow::on_flame_radiobutton_toggled()
" save viewer type in "
"PreferencesWindow::on_flame_radiobutton_toggled!\n");
}
-
- // Changing viewer type
- viewer_type_listener("flame");
}
- size_outer_vbox->property_visible() = active;
- monitor_flame_options->property_visible() = active;
+ // Enabling/disabling viewer as appropriate
+ viewer_type_listener("flame", active);
}
void PreferencesWindow::on_size_scale_changed()
@@ -770,6 +772,31 @@ void PreferencesWindow::on_fontbutton_set()
save_font_details(fontbutton->get_font_name());
}
+void PreferencesWindow::on_text_overlay_checkbutton_toggled()
+{
+ bool active = text_overlay_checkbutton->get_active();
+ text_overlay_format_string_entry->set_sensitive(active);
+ text_overlay_separator_entry->set_sensitive(active);
+
+ save_text_overlay_enabled(active);
+}
+
+bool PreferencesWindow::on_text_overlay_format_string_focus_out(GdkEventFocus *event)
+{
+ save_text_overlay_format_string(text_overlay_format_string_entry->get_text());
+
+ // Allow event to propagate
+ return FALSE;
+}
+
+bool PreferencesWindow::on_text_overlay_separator_focus_out(GdkEventFocus *event)
+{
+ save_text_overlay_separator(text_overlay_separator_entry->get_text());
+
+ // Allow event to propagate
+ return FALSE;
+}
+
void PreferencesWindow::on_add_button_clicked()
{
Monitor *monitor = run_choose_monitor_window(Glib::ustring());
@@ -964,3 +991,97 @@ void PreferencesWindow::save_font_details(Glib::ustring font_details)
" save viewer font in save_font_details!\n");
}
}
+
+void PreferencesWindow::save_text_overlay_enabled(bool enabled)
+{
+ applet.set_viewer_text_overlay_enabled(enabled);
+
+ // Search for a writeable settings file, create one if it doesnt exist */
+ gchar* file = xfce_panel_plugin_save_location(applet.panel_applet, true);
+
+ if (file)
+ {
+ // Opening setting file
+ XfceRc* settings_w = xfce_rc_simple_open(file, false);
+ g_free(file);
+
+ // Ensuring default group is in focus
+ xfce_rc_set_group(settings_w, NULL);
+
+ // Updating configuration
+ xfce_rc_write_bool_entry(settings_w, "viewer_text_overlay_enabled", enabled);
+
+ // Close settings file
+ xfce_rc_close(settings_w);
+ }
+ else
+ {
+ // Unable to obtain writeable config file - informing user and exiting
+ std::cerr << _("Unable to obtain writeable config file path in order to"
+ " save viewer text overlay enabled setting in save_text_overlay_enabled!\n");
+ }
+}
+
+void PreferencesWindow::save_text_overlay_format_string(const Glib::ustring format_string)
+{
+ applet.set_viewer_text_overlay_format_string(format_string);
+
+ // Search for a writeable settings file, create one if it doesnt exist */
+ gchar* file = xfce_panel_plugin_save_location(applet.panel_applet, true);
+
+ if (file)
+ {
+ // Opening setting file
+ XfceRc* settings_w = xfce_rc_simple_open(file, false);
+ g_free(file);
+
+ // Ensuring default group is in focus
+ xfce_rc_set_group(settings_w, NULL);
+
+ // Updating configuration
+ xfce_rc_write_entry(settings_w, "viewer_text_overlay_format_string",
+ format_string.c_str());
+
+ // Close settings file
+ xfce_rc_close(settings_w);
+ }
+ else
+ {
+ // Unable to obtain writeable config file - informing user and exiting
+ std::cerr << _("Unable to obtain writeable config file path in order to"
+ " save viewer text overlay format string in "
+ "save_text_overlay_format_string!\n");
+ }
+}
+
+void PreferencesWindow::save_text_overlay_separator(const Glib::ustring separator)
+{
+ applet.set_viewer_text_overlay_separator(separator);
+
+ // Search for a writeable settings file, create one if it doesnt exist */
+ gchar* file = xfce_panel_plugin_save_location(applet.panel_applet, true);
+
+ if (file)
+ {
+ // Opening setting file
+ XfceRc* settings_w = xfce_rc_simple_open(file, false);
+ g_free(file);
+
+ // Ensuring default group is in focus
+ xfce_rc_set_group(settings_w, NULL);
+
+ // Updating configuration
+ xfce_rc_write_entry(settings_w, "viewer_text_overlay_separator",
+ separator.c_str());
+
+ // Close settings file
+ xfce_rc_close(settings_w);
+ }
+ else
+ {
+ // Unable to obtain writeable config file - informing user and exiting
+ std::cerr << _("Unable to obtain writeable config file path in order to"
+ " save viewer text overlay separator in "
+ "save_text_overlay_separator!\n");
+ }
+}
diff --git a/src/preferences-window.hpp b/src/preferences-window.hpp
index d45d968..a5866b2 100644
--- a/src/preferences-window.hpp
+++ b/src/preferences-window.hpp
@@ -75,6 +75,10 @@ private:
Gtk::Widget *font_outer_vbox;
Gtk::CheckButton *font_checkbutton;
Gtk::FontButton *fontbutton;
+ Gtk::Widget *text_overlay_outer_vbox;
+ Gtk::CheckButton *text_overlay_checkbutton;
+ Gtk::Entry *text_overlay_format_string_entry;
+ Gtk::Entry *text_overlay_separator_entry;
Gtk::Button *remove_button;
Gtk::Button *change_button;
@@ -105,7 +109,7 @@ private:
typedef Gtk::ListStore::iterator store_iter;
// Originally gconf callbacks
- void viewer_type_listener(const Glib::ustring viewer_type);
+ 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);
@@ -132,6 +136,10 @@ private:
void on_font_checkbutton_toggled();
void on_fontbutton_set();
+ void on_text_overlay_checkbutton_toggled();
+ bool on_text_overlay_format_string_focus_out(GdkEventFocus *event);
+ bool on_text_overlay_separator_focus_out(GdkEventFocus *event);
+
void on_add_button_clicked();
void on_remove_button_clicked();
void on_change_button_clicked();
@@ -152,7 +160,10 @@ private:
void connect_monitor_colorbutton(Gtk::ColorButton *colorbutton);
void save_font_details(Glib::ustring font_details);
-
+ void save_text_overlay_enabled(bool enabled);
+ void save_text_overlay_format_string(const Glib::ustring format_string);
+ void save_text_overlay_separator(const Glib::ustring separator);
+
Applet &applet;
};
diff --git a/src/ui.glade b/src/ui.glade
index 0eafc28..4b2c2b0 100644
--- a/src/ui.glade
+++ b/src/ui.glade
@@ -1727,6 +1727,154 @@
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <widget class="GtkVBox" id="text_overlay_outer_vbox">
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkLabel" id="Text Overlay">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><b>Text Overlay</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="text_overlay_checkbutton">
+ <property name="label" translatable="yes">Enable text overlay of monitor values</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip" translatable="yes">Output monitor values as
+text onto the curve view</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">False</property>
+ <property name="padding">10</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="format_string_hbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkLabel" id="format_string_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Text overlay format string:</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="format_string_entry">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip" translatable="yes">Description of text to overlay onto curve view:
+
+%M: Monitor values (full)
+%m: Monitor values (compact - no spaces, shorter units)
+%A: Graph max (full)
+%a: Graph max (compact - no spaces, shorter units)
+
+E.g.:
+
+%a %m
+
+So for 2 network bandwidth monitors this might produce (with
+space as a monitor value separator):
+
+M:1.42M D:1.21M U:1.16M</property>
+ <property name="invisible_char">●</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="separator_string_hbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkLabel" id="separator_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Separator between monitor values: </property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="separator_string_entry">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip" translatable="yes">Separator string between
+individual monitor values</property>
+ <property name="invisible_char">●</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="position">1</property>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list