aboutsummaryrefslogtreecommitdiff
path: root/src/SendToMenu.cc
diff options
context:
space:
mode:
authorHenrik Kinnunen <fluxgen@fluxbox.org>2008-04-27 19:22:18 (GMT)
committerHenrik Kinnunen <fluxgen@fluxbox.org>2008-04-27 19:22:18 (GMT)
commit80b10f7772b91f1f4a61eace4e5235a79060e1f0 (patch)
tree27057e59c41188e7c2f724614233265fed03c9b3 /src/SendToMenu.cc
parent40e17b4d0ef1b9503f21509e697dd4dcb24d2bbf (diff)
downloadfluxbox_pavel-80b10f7772b91f1f4a61eace4e5235a79060e1f0.zip
fluxbox_pavel-80b10f7772b91f1f4a61eace4e5235a79060e1f0.tar.bz2
Added SimpleObserver class.
This class works in the same way as the SimpleCommand class. Use it with the makeObserver function. It calls the receiver's member function when the subject sends a signal.
Diffstat (limited to 'src/SendToMenu.cc')
-rw-r--r--src/SendToMenu.cc31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/SendToMenu.cc b/src/SendToMenu.cc
index ae261b9..8ec2094 100644
--- a/src/SendToMenu.cc
+++ b/src/SendToMenu.cc
@@ -1,5 +1,5 @@
1// SendToMenu.cc for Fluxbox 1// SendToMenu.cc for Fluxbox
2// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) 2// Copyright (c) 2003 - 2008 Henrik Kinnunen (fluxgen at fluxbox dot org)
3// and Simon Bowden (rathnor at users.sourceforge.net) 3// and Simon Bowden (rathnor at users.sourceforge.net)
4// 4//
5// Permission is hereby granted, free of charge, to any person obtaining a 5// Permission is hereby granted, free of charge, to any person obtaining a
@@ -31,6 +31,7 @@
31 31
32#include "FbTk/MultiButtonMenuItem.hh" 32#include "FbTk/MultiButtonMenuItem.hh"
33#include "FbTk/Command.hh" 33#include "FbTk/Command.hh"
34#include "FbTk/SimpleObserver.hh"
34 35
35class SendToCmd: public FbTk::Command<void> { 36class SendToCmd: public FbTk::Command<void> {
36public: 37public:
@@ -54,24 +55,21 @@ SendToMenu::SendToMenu(BScreen &screen):
54 // workspace count signal 55 // workspace count signal
55 // workspace names signal 56 // workspace names signal
56 // current workspace signal 57 // current workspace signal
57 screen.workspaceCountSig().attach(this); 58 m_rebuildObs = makeObserver(*this, &SendToMenu::rebuildMenu);
58 screen.workspaceNamesSig().attach(this); 59 screen.workspaceCountSig().attach(m_rebuildObs);
59 screen.currentWorkspaceSig().attach(this); 60 screen.workspaceNamesSig().attach(m_rebuildObs);
60 61 screen.currentWorkspaceSig().attach(m_rebuildObs);
62 // no title for this menu, it should be a submenu in the window menu.
61 disableTitle(); 63 disableTitle();
62 // build menu 64 // setup menu items
63 update(0); 65 rebuildMenu();
64} 66}
65 67
66void SendToMenu::update(FbTk::Subject *subj) { 68SendToMenu::~SendToMenu() {
67 if (subj != 0) { 69 delete m_rebuildObs;
68 if (subj == &(theme().reconfigSig())) { 70}
69 // we got reconfig Theme signal, let base menu handle it 71
70 FbTk::Menu::update(subj); 72void SendToMenu::rebuildMenu() {
71 return;
72 }
73
74 }
75 // rebuild menu 73 // rebuild menu
76 74
77 removeAll(); 75 removeAll();
@@ -95,6 +93,7 @@ void SendToMenu::show() {
95 if (WindowCmd<void>::window() != 0) { 93 if (WindowCmd<void>::window() != 0) {
96 for (unsigned int i=0; i < numberOfItems(); ++i) 94 for (unsigned int i=0; i < numberOfItems(); ++i)
97 setItemEnabled(i, true); 95 setItemEnabled(i, true);
96 // update the workspace for the current window
98 setItemEnabled(WindowCmd<void>::window()->workspaceNumber(), false); 97 setItemEnabled(WindowCmd<void>::window()->workspaceNumber(), false);
99 updateMenu(); 98 updateMenu();
100 } 99 }