From 05b00102814137d744ac5d1304fbac7176a6a1a0 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 4 May 2018 00:59:46 +0200 Subject: [PATCH] menu_view: optional 'version' widget attribute The new 'version' attribute can be used to explicitly distinguish widgets that have the same name. E.g., if one widget is removed and another with the same name is created somewhere else at the same time, the menu view would normally interpret this change as a movement. By attaching a distinct 'version' the new instance, menu view won't attempt perform a smooth transition between the old and new widgets. --- repos/gems/src/app/menu_view/widget.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/repos/gems/src/app/menu_view/widget.h b/repos/gems/src/app/menu_view/widget.h index 247a7b80b..ceb86e3ca 100644 --- a/repos/gems/src/app/menu_view/widget.h +++ b/repos/gems/src/app/menu_view/widget.h @@ -52,7 +52,8 @@ class Menu_view::Widget : public List_model::Element enum { NAME_MAX_LEN = 32 }; typedef String Name; - typedef Name Type_name; + typedef Name Type_name; + typedef String<10> Version; struct Unique_id { @@ -92,6 +93,7 @@ class Menu_view::Widget : public List_model::Element Type_name const _type_name; Name const _name; + Version const _version; Unique_id const _unique_id; @@ -122,7 +124,8 @@ class Menu_view::Widget : public List_model::Element static bool element_matches_xml_node(Widget const &w, Xml_node node) { return node.has_type(w._type_name.string()) - && Widget::node_name(node) == w._name; + && Widget::node_name(node) == w._name + && node.attribute_value("version", Version()) == w._version; } } _model_update_policy { _factory };