summaryrefslogtreecommitdiffstats
path: root/client/menu.cpp
diff options
context:
space:
mode:
authorArnon Gilboa <agilboa@redhat.com>2010-10-17 11:44:13 +0200
committerArnon Gilboa <agilboa@redhat.com>2010-10-17 11:44:13 +0200
commit793dd31cad280ed331e174b52829aa82c5281fad (patch)
tree670fcb024bcfc1c68638bca6ad76bde336ca6794 /client/menu.cpp
parent21f586762f96f9b0c3237b2b7ea21fbc9022435c (diff)
downloadspice-793dd31cad280ed331e174b52829aa82c5281fad.tar.gz
spice-793dd31cad280ed331e174b52829aa82c5281fad.tar.xz
spice-793dd31cad280ed331e174b52829aa82c5281fad.zip
spicec: add menu id & find_sub()
Diffstat (limited to 'client/menu.cpp')
-rw-r--r--client/menu.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/client/menu.cpp b/client/menu.cpp
index 0f7a7e86..17438218 100644
--- a/client/menu.cpp
+++ b/client/menu.cpp
@@ -20,10 +20,11 @@
#include "utils.h"
#include "debug.h"
-Menu::Menu(CommandTarget& target, const std::string& name)
+Menu::Menu(CommandTarget& target, const std::string& name, int id)
: _refs (1)
, _target (target)
, _name (name)
+ , _id (id)
{
}
@@ -115,6 +116,21 @@ Menu* Menu::sub_at(int pos)
return ((Menu*)_items[pos].obj)->ref();
}
+Menu* Menu::find_sub(int id)
+{
+ Menu* sub;
+
+ if (_id == id) {
+ return ref();
+ }
+ for (unsigned int i = 0; i < _items.size(); i++) {
+ if (_items[i].type == MENU_ITEM_TYPE_MENU && (sub = ((Menu*)_items[i].obj)->find_sub(id))) {
+ return sub;
+ }
+ }
+ return NULL;
+}
+
void Menu::clear()
{
for (unsigned int i = 0; i < _items.size(); i++) {