summaryrefslogtreecommitdiff
diff options
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2014-02-14 23:05:34 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-02-14 23:05:34 +0000
commitb2f250aa130b86e7c684b70c81223cf02ab3b2d3 (patch)
treee3258b7e2c708eda3b40a6bf0417533430f82ae7
parent066adaef6ab6595779ed36e526a553b136d965eb (diff)
parenteaa687fd778e3196d68f82bd18b4d2af4b4e9055 (diff)
PanelMenuView: we don't need to escape the panel title anymore
New decorations just use pango text. Fixes: 1280077 (bzr r3660)
-rw-r--r--launcher/LauncherIcon.cpp18
-rw-r--r--launcher/LauncherIcon.h2
-rw-r--r--launcher/SwitcherView.cpp6
-rw-r--r--launcher/Tooltip.cpp4
-rw-r--r--panel/PanelMenuView.cpp6
-rw-r--r--tests/test_launcher_tooltip.cpp6
-rw-r--r--tests/test_panel_menu_view.cpp12
7 files changed, 17 insertions, 37 deletions
diff --git a/launcher/LauncherIcon.cpp b/launcher/LauncherIcon.cpp
index 237b0510a..d5d702226 100644
--- a/launcher/LauncherIcon.cpp
+++ b/launcher/LauncherIcon.cpp
@@ -86,7 +86,6 @@ LauncherIcon::LauncherIcon(IconType type)
{
tooltip_enabled = true;
tooltip_enabled.changed.connect(sigc::mem_fun(this, &LauncherIcon::OnTooltipEnabledChanged));
- tooltip_text.SetSetterFunction(sigc::mem_fun(this, &LauncherIcon::SetTooltipText));
position = Position::FLOATING;
removed = false;
@@ -447,23 +446,6 @@ BaseTexturePtr LauncherIcon::TextureFromPath(std::string const& icon_name, int s
return BaseTexturePtr();
}
-bool LauncherIcon::SetTooltipText(std::string& target, std::string const& value)
-{
- auto const& escaped = glib::String(g_markup_escape_text(value.c_str(), -1)).Str();
-
- if (escaped != target)
- {
- target = escaped;
-
- if (_tooltip)
- _tooltip->text = target;
-
- return true;
- }
-
- return false;
-}
-
void LauncherIcon::OnTooltipEnabledChanged(bool value)
{
if (!value)
diff --git a/launcher/LauncherIcon.h b/launcher/LauncherIcon.h
index 38536b7e3..934cc15c2 100644
--- a/launcher/LauncherIcon.h
+++ b/launcher/LauncherIcon.h
@@ -53,8 +53,6 @@ public:
LauncherIcon(IconType type);
- bool SetTooltipText(std::string& target, std::string const& value);
-
void SetShortcut(guint64 shortcut);
guint64 GetShortcut();
diff --git a/launcher/SwitcherView.cpp b/launcher/SwitcherView.cpp
index 08376ac74..7245bbf82 100644
--- a/launcher/SwitcherView.cpp
+++ b/launcher/SwitcherView.cpp
@@ -161,7 +161,7 @@ void SwitcherView::SetModel(SwitcherModel::Ptr model)
text_view_->SetVisible(!model->detail_selection);
if (!model->detail_selection)
- text_view_->SetText(model->Selection()->tooltip_text());
+ text_view_->SetText(model->Selection()->tooltip_text(), true);
}
void SwitcherView::OnIconSizeChanged (int size)
@@ -207,7 +207,7 @@ void SwitcherView::OnDetailSelectionChanged(bool detail)
if (!detail)
{
- text_view_->SetText(model_->Selection()->tooltip_text());
+ text_view_->SetText(model_->Selection()->tooltip_text(), true);
render_targets_.clear();
}
@@ -217,7 +217,7 @@ void SwitcherView::OnDetailSelectionChanged(bool detail)
void SwitcherView::OnSelectionChanged(AbstractLauncherIcon::Ptr const& selection)
{
if (selection)
- text_view_->SetText(selection->tooltip_text());
+ text_view_->SetText(selection->tooltip_text(), true);
delta_tracker_.ResetState();
diff --git a/launcher/Tooltip.cpp b/launcher/Tooltip.cpp
index 78d5c290e..89f544c4b 100644
--- a/launcher/Tooltip.cpp
+++ b/launcher/Tooltip.cpp
@@ -66,12 +66,12 @@ Tooltip::Tooltip() :
_tooltip_text->sigFontChanged.connect(sigc::mem_fun(this, &Tooltip::RecvCairoTextChanged));
// getter and setter for the property
- text.SetSetterFunction([this](std::string newText)
+ text.SetSetterFunction([this](std::string const& newText)
{
if(_tooltip_text->GetText() == newText)
return false;
- _tooltip_text->SetText(newText);
+ _tooltip_text->SetText(newText, true);
return true;
}
);
diff --git a/panel/PanelMenuView.cpp b/panel/PanelMenuView.cpp
index a5cab6d9e..1281e0815 100644
--- a/panel/PanelMenuView.cpp
+++ b/panel/PanelMenuView.cpp
@@ -727,11 +727,7 @@ std::string PanelMenuView::GetCurrentTitle() const
window_buttons_->controlled_window = active_xid_;
}
- // panel_title_ needs to be only escaped when computed
- // in this function, if it comes from OnLauncherSelectionChanged
- // it is already escaped
- glib::String escaped(g_markup_escape_text(new_title.c_str(), -1));
- return escaped.Str();
+ return new_title;
}
else
{
diff --git a/tests/test_launcher_tooltip.cpp b/tests/test_launcher_tooltip.cpp
index 3b123b046..ebf9862d3 100644
--- a/tests/test_launcher_tooltip.cpp
+++ b/tests/test_launcher_tooltip.cpp
@@ -106,4 +106,10 @@ TEST_F(TestTooltip, TestSetTooltipText)
EXPECT_EQ(new_tip, tooltip->_tooltip_text->GetText());
}
+TEST_F(TestTooltip, EscapedText)
+{
+ tooltip->text = "Unity's Tooltip!";
+ EXPECT_EQ("Unity&apos;s Tooltip!", tooltip->_tooltip_text->GetText());
+}
+
} // unity
diff --git a/tests/test_panel_menu_view.cpp b/tests/test_panel_menu_view.cpp
index 6cd051e71..ee9ec589e 100644
--- a/tests/test_panel_menu_view.cpp
+++ b/tests/test_panel_menu_view.cpp
@@ -82,20 +82,18 @@ protected:
TEST_F(TestPanelMenuView, Escaping)
{
ON_CALL(menu_view, GetActiveViewName(testing::_)).WillByDefault(Return("<>'"));
- static const char *escapedText = "Panel d&amp;Inici";
- EXPECT_TRUE(menu_view.GetCurrentTitle().empty());
+ auto escapedText = "Panel d'Inici";
+ ASSERT_TRUE(menu_view.GetCurrentTitle().empty());
UBusManager ubus;
ubus.SendMessage(UBUS_LAUNCHER_START_KEY_NAV);
- ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED,
- glib::Variant(escapedText));
- Utils::WaitUntilMSec([this] {return menu_view.GetCurrentTitle() == escapedText;});
-
+ ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED, glib::Variant(escapedText));
+ Utils::WaitUntilMSec([this, &escapedText] {return menu_view.GetCurrentTitle() == escapedText;});
WM->SetScaleActive(true);
WM->SetScaleActiveForGroup(true);
ubus.SendMessage(UBUS_LAUNCHER_END_KEY_NAV);
- Utils::WaitUntilMSec([this] {return menu_view.GetCurrentTitle() == "&lt;&gt;&apos;";});
+ Utils::WaitUntilMSec([this] {return menu_view.GetCurrentTitle() == "<>'";});
}
TEST_F(TestPanelMenuView, QueuesDrawOnButtonsOpacityChange)