1 #include "WidgetToggle.h"
2 
WidgetToggle()3 WidgetToggle::WidgetToggle() :
4 	Toggle(MemberCaller<WidgetToggle, &WidgetToggle::doNothing>(*this))
5 {}
6 
7 	// Dummy callback for the Toggle base class, we don't need any callbacks...
doNothing()8 void WidgetToggle::doNothing() {}
9 
10 /* This method only adds the widget to the show/hide list if the widget
11  * is NOT of type GtkCheckMenuItem/GtkToggleToolButtons. Any other
12  * widgets are added to the show/hide list */
connectWidget(GtkWidget * widget)13 void WidgetToggle::connectWidget(GtkWidget* widget) {
14 	// Call the base class method
15 	Toggle::connectWidget(widget);
16 
17 	// Any other widgets are added to the list
18 	if (!GTK_IS_CHECK_MENU_ITEM(widget) && !GTK_IS_TOGGLE_TOOL_BUTTON(widget) && widget != NULL) {
19 		// No special widget, add it to the list
20 		_widgets.push_back(widget);
21 	}
22 
23 	updateWidgets();
24 }
25 
updateWidgets()26 void WidgetToggle::updateWidgets() {
27 	// Show/hide the widgets according to the _toggled state
28 	if (_toggled) {
29 		showWidgets();
30 	}
31 	else {
32 		hideWidgets();
33 	}
34 
35 	// Pass the call to the base class to do the rest
36 	Toggle::updateWidgets();
37 }
38 
39 // Show all the connected widgets
showWidgets()40 void WidgetToggle::showWidgets() {
41 	for (unsigned int i = 0; i < _widgets.size(); i++) {
42 		gtk_widget_show(_widgets[i]);
43 	}
44 }
45 
46 // Hide all the connected widgets
hideWidgets()47 void WidgetToggle::hideWidgets() {
48 	for (unsigned int i = 0; i < _widgets.size(); i++) {
49 		gtk_widget_hide(_widgets[i]);
50 	}
51 }
52