aboutsummaryrefslogtreecommitdiff
path: root/src/LayerMenu.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/LayerMenu.hh')
-rw-r--r--src/LayerMenu.hh29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/LayerMenu.hh b/src/LayerMenu.hh
index 1a48878..3eafa3f 100644
--- a/src/LayerMenu.hh
+++ b/src/LayerMenu.hh
@@ -20,13 +20,16 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: LayerMenu.hh,v 1.1 2003/02/18 22:09:02 rathnor Exp $ 23// $Id: LayerMenu.hh,v 1.2 2003/04/16 13:43:41 rathnor Exp $
24 24
25#ifndef LAYERMENU_HH 25#ifndef LAYERMENU_HH
26#define LAYERMENU_HH 26#define LAYERMENU_HH
27 27
28#include "MenuItem.hh" 28#include "MenuItem.hh"
29#include "FbMenu.hh" 29#include "FbMenu.hh"
30#include "FbCommands.hh"
31#include "RefCount.hh"
32#include "SimpleCommand.hh"
30 33
31class Fluxbox; 34class Fluxbox;
32 35
@@ -36,12 +39,16 @@ class Fluxbox;
36template <typename ItemType> 39template <typename ItemType>
37class LayerMenuItem : public FbTk::MenuItem { 40class LayerMenuItem : public FbTk::MenuItem {
38public: 41public:
42 LayerMenuItem(const char *label, ItemType *object, int layernum,
43 FbTk::RefCount<FbTk::Command> &cmd):
44 FbTk::MenuItem(label,cmd), m_object(object), m_layernum(layernum) {}
39 LayerMenuItem(const char *label, ItemType *object, int layernum): 45 LayerMenuItem(const char *label, ItemType *object, int layernum):
40 FbTk::MenuItem(label), m_object(object), m_layernum(layernum) {} 46 FbTk::MenuItem(label), m_object(object), m_layernum(layernum) {}
41 47
42 bool isEnabled() const { return m_object->getLayerItem().getLayerNum() != m_layernum; } ; 48 bool isEnabled() const { return m_object->getLayerItem().getLayerNum() != m_layernum; } ;
43 void click(int button, int time) { 49 void click(int button, int time) {
44 m_object->moveToLayer(m_layernum); 50 m_object->moveToLayer(m_layernum);
51 FbTk::MenuItem::click(button, time);
45 } 52 }
46 53
47private: 54private:
@@ -55,7 +62,7 @@ template <typename ItemType>
55class LayerMenu : public FbMenu { 62class LayerMenu : public FbMenu {
56public: 63public:
57 LayerMenu(FbTk::MenuTheme &tm, int screen_num, FbTk::ImageControl &imgctrl, 64 LayerMenu(FbTk::MenuTheme &tm, int screen_num, FbTk::ImageControl &imgctrl,
58 FbTk::XLayer &layer, ItemType *item); 65 FbTk::XLayer &layer, ItemType *item, bool save_rc);
59 66
60private: 67private:
61 ItemType *m_object; 68 ItemType *m_object;
@@ -64,7 +71,7 @@ private:
64 71
65template <typename ItemType> 72template <typename ItemType>
66LayerMenu<ItemType>::LayerMenu(FbTk::MenuTheme &tm, int screen_num, FbTk::ImageControl &imgctrl, 73LayerMenu<ItemType>::LayerMenu(FbTk::MenuTheme &tm, int screen_num, FbTk::ImageControl &imgctrl,
67 FbTk::XLayer &layer, ItemType *item): 74 FbTk::XLayer &layer, ItemType *item, bool save_rc):
68 FbMenu(tm, screen_num, imgctrl, layer), 75 FbMenu(tm, screen_num, imgctrl, layer),
69 m_object(item) 76 m_object(item)
70{ 77{
@@ -86,11 +93,21 @@ LayerMenu<ItemType>::LayerMenu(FbTk::MenuTheme &tm, int screen_num, FbTk::ImageC
86 {0, 0, "Desktop", fluxbox->getDesktopLayer()}, 93 {0, 0, "Desktop", fluxbox->getDesktopLayer()},
87 }; 94 };
88 95
96 FbTk::RefCount<FbTk::Command> saverc_cmd(new FbTk::SimpleCommand<Fluxbox>(
97 *Fluxbox::instance(),
98 &Fluxbox::save_rc));
99
89 for (size_t i=0; i < 6; ++i) { 100 for (size_t i=0; i < 6; ++i) {
90 // TODO: fetch nls string 101 // TODO: fetch nls string
91 insert(new LayerMenuItem<ItemType>( 102 if (save_rc) {
92 layer_menuitems[i].default_str, 103 insert(new LayerMenuItem<ItemType>(
93 m_object, layer_menuitems[i].layernum)); 104 layer_menuitems[i].default_str,
105 m_object, layer_menuitems[i].layernum, saverc_cmd));
106 } else {
107 insert(new LayerMenuItem<ItemType>(
108 layer_menuitems[i].default_str,
109 m_object, layer_menuitems[i].layernum));
110 }
94 } 111 }
95 update(); 112 update();
96} 113}