aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-08-05 13:17:02 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-11-01 10:04:01 (GMT)
commit36c4e55717eed81779fdc057d70e19fb80db2b92 (patch)
tree9ba49165193c9bb3dff193350201ef895b95bfd3 /src
parent5d355d755d3204eb3c9b9c1846e3aca78020b6d4 (diff)
downloadfluxbox_paul-36c4e55717eed81779fdc057d70e19fb80db2b92.zip
fluxbox_paul-36c4e55717eed81779fdc057d70e19fb80db2b92.tar.bz2
Attach modifiedSig handlers to the session.screenX.iconbar.mode resource
Diffstat (limited to 'src')
-rw-r--r--src/IconbarTool.cc70
-rw-r--r--src/IconbarTool.hh10
2 files changed, 31 insertions, 49 deletions
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
index a912030..621a8a1 100644
--- a/src/IconbarTool.cc
+++ b/src/IconbarTool.cc
@@ -77,19 +77,16 @@ const EnumTraits<Container::Alignment>::Pair EnumTraits<Container::Alignment>::s
77 77
78} // end namespace FbTk 78} // end namespace FbTk
79 79
80namespace { 80class IconbarTool::ToolbarModeMenuItem : public FbTk::RadioMenuItem {
81
82class ToolbarModeMenuItem : public FbTk::RadioMenuItem {
83public: 81public:
84 ToolbarModeMenuItem(const FbTk::FbString &label, IconbarTool &handler, 82 ToolbarModeMenuItem(const FbTk::FbString &label, IconbarTool &handler,
85 string mode, 83 string mode):
86 FbTk::RefCount<FbTk::Command<void> > &cmd): 84 FbTk::RadioMenuItem(label), m_handler(handler), m_mode(mode) {
87 FbTk::RadioMenuItem(label, cmd), m_handler(handler), m_mode(mode) {
88 setCloseOnClick(false); 85 setCloseOnClick(false);
89 } 86 }
90 bool isSelected() const { return m_handler.mode() == m_mode; } 87 bool isSelected() const { return m_handler.m_rc_mode.get() == m_mode; }
91 void click(int button, int time, unsigned int mods) { 88 void click(int button, int time, unsigned int mods) {
92 m_handler.setMode(m_mode); 89 *m_handler.m_rc_mode = m_mode;
93 FbTk::RadioMenuItem::click(button, time, mods); 90 FbTk::RadioMenuItem::click(button, time, mods);
94 } 91 }
95 92
@@ -98,12 +95,11 @@ private:
98 string m_mode; 95 string m_mode;
99}; 96};
100 97
101class ToolbarAlignMenuItem: public FbTk::RadioMenuItem { 98class IconbarTool::ToolbarAlignMenuItem: public FbTk::RadioMenuItem {
102public: 99public:
103 ToolbarAlignMenuItem(const FbTk::FbString &label, IconbarTool &handler, 100 ToolbarAlignMenuItem(const FbTk::FbString &label, IconbarTool &handler,
104 FbTk::Container::Alignment mode, 101 FbTk::Container::Alignment mode):
105 FbTk::RefCount<FbTk::Command<void> > &cmd): 102 FbTk::RadioMenuItem(label), m_handler(handler), m_mode(mode) {
106 FbTk::RadioMenuItem(label, cmd), m_handler(handler), m_mode(mode) {
107 setCloseOnClick(false); 103 setCloseOnClick(false);
108 } 104 }
109 bool isSelected() const { return m_handler.alignment() == m_mode; } 105 bool isSelected() const { return m_handler.alignment() == m_mode; }
@@ -117,77 +113,66 @@ private:
117 FbTk::Container::Alignment m_mode; 113 FbTk::Container::Alignment m_mode;
118}; 114};
119 115
120void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { 116void IconbarTool::setupModeMenu(FbTk::Menu &menu) {
121 using namespace FbTk; 117 using namespace FbTk;
122 _FB_USES_NLS; 118 _FB_USES_NLS;
123 119
124 menu.setLabel(_FB_XTEXT(Toolbar, IconbarMode, "Iconbar Mode", "Menu title - chooses which set of icons are shown in the iconbar")); 120 menu.setLabel(_FB_XTEXT(Toolbar, IconbarMode, "Iconbar Mode", "Menu title - chooses which set of icons are shown in the iconbar"));
125 121
126 RefCount<Command<void> > saverc_cmd(new FbCommands::SaveResources());
127
128
129 menu.insert(new ToolbarModeMenuItem(_FB_XTEXT(Toolbar, IconbarModeNone, 122 menu.insert(new ToolbarModeMenuItem(_FB_XTEXT(Toolbar, IconbarModeNone,
130 "None", "No icons are shown in the iconbar"), 123 "None", "No icons are shown in the iconbar"),
131 handler, 124 *this, "none"));
132 "none", saverc_cmd));
133 125
134 menu.insert(new ToolbarModeMenuItem( 126 menu.insert(new ToolbarModeMenuItem(
135 _FB_XTEXT(Toolbar, IconbarModeIcons, 127 _FB_XTEXT(Toolbar, IconbarModeIcons,
136 "Icons", "Iconified windows from all workspaces are shown"), 128 "Icons", "Iconified windows from all workspaces are shown"),
137 handler, 129 *this, "{static groups} (minimized=yes)"));
138 "{static groups} (minimized=yes)", saverc_cmd));
139 130
140 menu.insert(new ToolbarModeMenuItem( 131 menu.insert(new ToolbarModeMenuItem(
141 _FB_XTEXT(Toolbar, IconbarModeNoIcons, 132 _FB_XTEXT(Toolbar, IconbarModeNoIcons,
142 "NoIcons", "No iconified windows from all workspaces are shown"), 133 "NoIcons", "No iconified windows from all workspaces are shown"),
143 handler, 134 *this, "{static groups} (minimized=no)"));
144 "{static groups} (minimized=no)", saverc_cmd));
145 135
146 menu.insert(new ToolbarModeMenuItem( 136 menu.insert(new ToolbarModeMenuItem(
147 _FB_XTEXT(Toolbar, IconbarModeWorkspaceIcons, 137 _FB_XTEXT(Toolbar, IconbarModeWorkspaceIcons,
148 "WorkspaceIcons", "Iconified windows from this workspace are shown"), 138 "WorkspaceIcons", "Iconified windows from this workspace are shown"),
149 handler, 139 *this, "{static groups} (minimized=yes) (workspace)"));
150 "{static groups} (minimized=yes) (workspace)", saverc_cmd));
151 140
152 menu.insert(new ToolbarModeMenuItem( 141 menu.insert(new ToolbarModeMenuItem(
153 _FB_XTEXT(Toolbar, IconbarModeWorkspaceNoIcons, 142 _FB_XTEXT(Toolbar, IconbarModeWorkspaceNoIcons,
154 "WorkspaceNoIcons", "No iconified windows from this workspace are shown"), 143 "WorkspaceNoIcons", "No iconified windows from this workspace are shown"),
155 handler, 144 *this, "{static groups} (minimized=no) (workspace)"));
156 "{static groups} (minimized=no) (workspace)", saverc_cmd));
157 145
158 menu.insert(new ToolbarModeMenuItem( 146 menu.insert(new ToolbarModeMenuItem(
159 _FB_XTEXT(Toolbar, IconbarModeWorkspace, 147 _FB_XTEXT(Toolbar, IconbarModeWorkspace,
160 "Workspace", "Normal and iconified windows from this workspace are shown"), 148 "Workspace", "Normal and iconified windows from this workspace are shown"),
161 handler, 149 *this, "{static groups} (workspace)"));
162 "{static groups} (workspace)", saverc_cmd));
163 150
164 menu.insert(new ToolbarModeMenuItem( 151 menu.insert(new ToolbarModeMenuItem(
165 _FB_XTEXT(Toolbar, IconbarModeAllWindows, "All Windows", "All windows are shown"), 152 _FB_XTEXT(Toolbar, IconbarModeAllWindows, "All Windows", "All windows are shown"),
166 handler, 153 *this, "{static groups}"));
167 "{static groups}", saverc_cmd));
168 154
169 menu.insert(new FbTk::MenuSeparator()); 155 menu.insert(new FbTk::MenuSeparator());
170 156
171 menu.insert(new ToolbarAlignMenuItem( 157 menu.insert(new ToolbarAlignMenuItem(
172 _FB_XTEXT(Align, Left, "Left", "Align to the left"), 158 _FB_XTEXT(Align, Left, "Left", "Align to the left"),
173 handler, 159 *this, FbTk::Container::LEFT));
174 FbTk::Container::LEFT, saverc_cmd));
175 160
176 menu.insert(new ToolbarAlignMenuItem( 161 menu.insert(new ToolbarAlignMenuItem(
177 _FB_XTEXT(Align, Relative, "Relative", "Align relative to the width"), 162 _FB_XTEXT(Align, Relative, "Relative", "Align relative to the width"),
178 handler, 163 *this, FbTk::Container::RELATIVE));
179 FbTk::Container::RELATIVE, saverc_cmd));
180 164
181 menu.insert(new ToolbarAlignMenuItem( 165 menu.insert(new ToolbarAlignMenuItem(
182 _FB_XTEXT(Align, Right, "Right", "Align to the right"), 166 _FB_XTEXT(Align, Right, "Right", "Align to the right"),
183 handler, 167 *this, FbTk::Container::RIGHT));
184 FbTk::Container::RIGHT, saverc_cmd));
185 168
186 menu.insert(new FbTk::MenuSeparator()); 169 menu.insert(new FbTk::MenuSeparator());
187 170
188 menu.updateMenu(); 171 menu.updateMenu();
189} 172}
190 173
174namespace {
175
191typedef FbTk::RefCount<FbTk::Command<void> > RefCmd; 176typedef FbTk::RefCount<FbTk::Command<void> > RefCmd;
192 177
193class ShowMenu: public FbTk::Command<void> { 178class ShowMenu: public FbTk::Command<void> {
@@ -237,7 +222,6 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme,
237 m_unfocused_theme(unfocused_theme), 222 m_unfocused_theme(unfocused_theme),
238 m_empty_pm( screen.imageControl() ), 223 m_empty_pm( screen.imageControl() ),
239 m_winlist(new FocusableList(screen)), 224 m_winlist(new FocusableList(screen)),
240 m_mode("none"),
241 m_rc_mode(screen.resourceManager(), "{static groups} (workspace)", 225 m_rc_mode(screen.resourceManager(), "{static groups} (workspace)",
242 screen.name() + ".iconbar.mode"), 226 screen.name() + ".iconbar.mode"),
243 m_rc_alignment(screen.resourceManager(), FbTk::Container::RELATIVE, 227 m_rc_alignment(screen.resourceManager(), FbTk::Container::RELATIVE,
@@ -251,7 +235,7 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme,
251 m_alpha(255) { 235 m_alpha(255) {
252 236
253 // setup mode menu 237 // setup mode menu
254 setupModeMenu(*m_menu, *this); 238 setupModeMenu(*m_menu);
255 _FB_USES_NLS; 239 _FB_USES_NLS;
256 using namespace FbTk; 240 using namespace FbTk;
257 // setup use pixmap item to reconfig iconbar and save resource on click 241 // setup use pixmap item to reconfig iconbar and save resource on click
@@ -270,7 +254,8 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme,
270 menu.insert(m_menu->label().logical(), FbTk::RefCount<FbTk::Menu>(m_menu)); 254 menu.insert(m_menu->label().logical(), FbTk::RefCount<FbTk::Menu>(m_menu));
271 255
272 // setup signals 256 // setup signals
273 setMode(*m_rc_mode); 257 m_tracker.join(m_rc_mode.modifiedSig(), FbTk::MemFun(*this, &IconbarTool::modeChanged));
258 modeChanged(*m_rc_mode);
274} 259}
275 260
276IconbarTool::~IconbarTool() { 261IconbarTool::~IconbarTool() {
@@ -309,12 +294,7 @@ void IconbarTool::setAlignment(FbTk::Container::Alignment align) {
309 m_menu->reconfigure(); 294 m_menu->reconfigure();
310} 295}
311 296
312void IconbarTool::setMode(string mode) { 297void IconbarTool::modeChanged(const std::string &mode) {
313 if (mode == m_mode)
314 return;
315
316 *m_rc_mode = m_mode = mode;
317
318 // lock graphics update 298 // lock graphics update
319 m_icon_container.setUpdateLock(true); 299 m_icon_container.setUpdateLock(true);
320 300
diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh
index 6ce3c35..074a317 100644
--- a/src/IconbarTool.hh
+++ b/src/IconbarTool.hh
@@ -56,15 +56,12 @@ public:
56 void show(); 56 void show();
57 void hide(); 57 void hide();
58 void setAlignment(FbTk::Container::Alignment a); 58 void setAlignment(FbTk::Container::Alignment a);
59 void setMode(std::string mode);
60 void parentMoved() { m_icon_container.parentMoved(); } 59 void parentMoved() { m_icon_container.parentMoved(); }
61 60
62 unsigned int width() const; 61 unsigned int width() const;
63 unsigned int height() const; 62 unsigned int height() const;
64 unsigned int borderWidth() const; 63 unsigned int borderWidth() const;
65 64
66 std::string mode() const { return *m_rc_mode; }
67
68 void setOrientation(FbTk::Orientation orient); 65 void setOrientation(FbTk::Orientation orient);
69 FbTk::Container::Alignment alignment() const { return m_icon_container.alignment(); } 66 FbTk::Container::Alignment alignment() const { return m_icon_container.alignment(); }
70 67
@@ -73,6 +70,7 @@ private:
73 enum UpdateReason { LIST_ORDER, LIST_ADD, LIST_REMOVE, LIST_RESET, ALIGN }; 70 enum UpdateReason { LIST_ORDER, LIST_ADD, LIST_REMOVE, LIST_RESET, ALIGN };
74 71
75 void updateSizing(); 72 void updateSizing();
73 void setupModeMenu(FbTk::Menu &menu);
76 74
77 /// render single button, and probably apply changes (clear) 75 /// render single button, and probably apply changes (clear)
78 /// @param button the button to render 76 /// @param button the button to render
@@ -96,6 +94,11 @@ private:
96 94
97 /// called when the list emits a signal 95 /// called when the list emits a signal
98 void update(UpdateReason reason, Focusable *win); 96 void update(UpdateReason reason, Focusable *win);
97 /// called when the mode changes
98 void modeChanged(const std::string &mode);
99
100 class ToolbarModeMenuItem;
101 class ToolbarAlignMenuItem;
99 102
100 BScreen &m_screen; 103 BScreen &m_screen;
101 FbTk::Container m_icon_container; 104 FbTk::Container m_icon_container;
@@ -107,7 +110,6 @@ private:
107 110
108 std::auto_ptr<FocusableList> m_winlist; 111 std::auto_ptr<FocusableList> m_winlist;
109 IconMap m_icons; 112 IconMap m_icons;
110 std::string m_mode;
111 FbTk::StringResource m_rc_mode; 113 FbTk::StringResource m_rc_mode;
112 /// alignment of buttons 114 /// alignment of buttons
113 FbTk::Resource<FbTk::Container::Alignment, FbTk::EnumTraits<FbTk::Container::Alignment> > m_rc_alignment; 115 FbTk::Resource<FbTk::Container::Alignment, FbTk::EnumTraits<FbTk::Container::Alignment> > m_rc_alignment;