[Xfce4-commits] [panel-plugins/xfce4-hardware-monitor-plugin] 28/96: Reconnect viewer type changes in preferences dialog to actual changing code
noreply at xfce.org
noreply at xfce.org
Thu Nov 27 22:20:33 CET 2014
This is an automated email from the git hooks/post-receive script.
nick pushed a commit to branch master
in repository panel-plugins/xfce4-hardware-monitor-plugin.
commit fe2dd0a351b557453db0bc91d6a1bf6736978b1b
Author: Omega Weapon <OmegaPhil at gmail.com>
Date: Mon Nov 4 18:59:41 2013 +0000
Reconnect viewer type changes in preferences dialog to actual changing code
---
src/applet.cpp | 100 ++++++++++++++++++++++++--------------------
src/applet.hpp | 3 ++
src/preferences-window.cpp | 10 ++---
src/preferences-window.hpp | 1 +
4 files changed, 63 insertions(+), 51 deletions(-)
diff --git a/src/applet.cpp b/src/applet.cpp
index 4db8954..dab0b5e 100644
--- a/src/applet.cpp
+++ b/src/applet.cpp
@@ -193,51 +193,7 @@ Applet::Applet(XfcePanelPlugin *plugin)
}
// Configuring viewer type
- if (viewer_type == "curve")
- {
- // Setting view to CurveView if it isnt already
- if (!dynamic_cast<CurveView *>(view.get()))
- set_view(new CurveView);
- }
- else if (viewer_type == "bar")
- {
- // Setting view to horizontal BarView if it isnt already
- // It gets tricky here because them BarView can render 2 viewers.
- // Thus, we much also check the oriententation
- BarView *bar_view = dynamic_cast<BarView *>(view.get());
- if (!(bar_view && bar_view->is_horizontal()) )
- set_view(new BarView);
- }
- else if (viewer_type == "vbar")
- {
- // Setting view to vertical BarView if it isnt already
- // Same situation as with "bar"
- BarView *bar_view = dynamic_cast<BarView *>(view.get());
- if (!(bar_view && !bar_view->is_horizontal()) )
- set_view(new BarView(false));
- }
- else if (viewer_type == "text") {
-
- // Setting view to TextView if it isnt already
- if (!dynamic_cast<TextView *>(view.get()))
- set_view(new TextView);
- }
- else if (viewer_type == "flame") {
-
- // Setting view to FlameView if it isnt already
- if (!dynamic_cast<FlameView *>(view.get()))
- set_view(new FlameView);
- }
- else if (viewer_type == "column") {
-
- // Setting view to ColumnView if it isnt already
- if (!dynamic_cast<ColumnView *>(view.get()))
- set_view(new ColumnView);
- }
-
- // Setting the view background colour if desired
- if (use_background_color)
- view->set_background(background_color);
+ viewer_type_listener(viewer_type, use_background_color, background_color);
/* Actually setting the viewer size has no effect in this function -
* seems that it needs to be done in or after the mainloop kicks off */
@@ -334,6 +290,60 @@ void Applet::set_view(View *v)
view->attach(*i);
}
+// Note that the last two parameters have defaults in the declaration
+void Applet::viewer_type_listener(const Glib::ustring viewer_type,
+ bool use_background_color, int background_color)
+{
+ if (viewer_type == "curve")
+ {
+ // Setting view to CurveView if it isnt already
+ if (!dynamic_cast<CurveView *>(view.get()))
+ set_view(new CurveView);
+ }
+ else if (viewer_type == "bar")
+ {
+ // Setting view to horizontal BarView if it isnt already
+ // It gets tricky here because them BarView can render 2 viewers.
+ // Thus, we much also check the oriententation
+ BarView *bar_view = dynamic_cast<BarView *>(view.get());
+ if (!(bar_view && bar_view->is_horizontal()) )
+ set_view(new BarView);
+ }
+ else if (viewer_type == "vbar")
+ {
+ // Setting view to vertical BarView if it isnt already
+ // Same situation as with "bar"
+ BarView *bar_view = dynamic_cast<BarView *>(view.get());
+ if (!(bar_view && !bar_view->is_horizontal()) )
+ set_view(new BarView(false));
+ }
+ else if (viewer_type == "text") {
+
+ // Setting view to TextView if it isnt already
+ if (!dynamic_cast<TextView *>(view.get()))
+ set_view(new TextView);
+ }
+ else if (viewer_type == "flame") {
+
+ // Setting view to FlameView if it isnt already
+ if (!dynamic_cast<FlameView *>(view.get()))
+ set_view(new FlameView);
+ }
+ else if (viewer_type == "column") {
+
+ // Setting view to ColumnView if it isnt already
+ if (!dynamic_cast<ColumnView *>(view.get()))
+ set_view(new ColumnView);
+ }
+
+ // Setting the view background colour if desired
+ if (use_background_color)
+ view->set_background(background_color);
+
+ // Update recorded viewer type
+ this->viewer_type = viewer_type;
+}
+
bool Applet::main_loop()
{
// Update view
diff --git a/src/applet.hpp b/src/applet.hpp
index df04baf..431a99f 100644
--- a/src/applet.hpp
+++ b/src/applet.hpp
@@ -70,6 +70,9 @@ public:
void set_viewer_size(const int size);
const Glib::ustring get_viewer_font();
void set_viewer_font(const Glib::ustring font_name);
+ void viewer_type_listener(const Glib::ustring viewer_type,
+ bool use_background_color = false,
+ int background_color = 0);
Glib::RefPtr<Gdk::Pixbuf> get_icon(); // get the application icon
diff --git a/src/preferences-window.cpp b/src/preferences-window.cpp
index bab7777..9824a9a 100644
--- a/src/preferences-window.cpp
+++ b/src/preferences-window.cpp
@@ -164,12 +164,6 @@ PreferencesWindow::PreferencesWindow(Applet &applet_, monitor_seq monitors)
// connect GConf
// TODO: Do these even need to be set up? When a chnge is made, then the relevant function is to be called
/*
- Glib::RefPtr<Gnome::Conf::Client> &client = applet.get_gconf_client();
-
- client->notify_add(dir + "/viewer_type",
- sigc::mem_fun(*this, &PreferencesWindow::
- viewer_type_listener));
-
client->notify_add(dir + "/background_interval",
sigc::mem_fun(*this, &PreferencesWindow::
background_color_listener));
@@ -295,6 +289,10 @@ void PreferencesWindow::viewer_type_listener(unsigned int,
size_outer_vbox->property_visible() = true;
monitor_flame_options->property_visible() = true;
}
+
+ /* Actually changing the viewer type - background color use etc is set
+ * separately */
+ applet.viewer_type_listener(viewer_type);
}
void PreferencesWindow::background_color_listener(unsigned int,
diff --git a/src/preferences-window.hpp b/src/preferences-window.hpp
index c01cf93..bd01ab9 100644
--- a/src/preferences-window.hpp
+++ b/src/preferences-window.hpp
@@ -104,6 +104,7 @@ private:
typedef Gtk::ListStore::iterator store_iter;
// Originally gconf callbacks
+ // TODO: Kill off superfluous ints in these function calls
void viewer_type_listener(unsigned int, const Glib::ustring viewer_type);
void background_color_listener(unsigned int,
unsigned int background_color);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list