summaryrefslogtreecommitdiff
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2012-08-13 14:25:57 -0400
committerTarmac <>2012-08-13 14:25:57 -0400
commit5cc3573fd349cb9cba1c4648c53b77d95414d427 (patch)
tree87caf4a9431ed12f89c410e39dd2b45b611dfb46
parent5b656cd81f5fead3a10624622186cde0d25fdf0b (diff)
parent2a8ca4ef14dd3a43130fcb0a8f994f656ee75e90 (diff)
LauncherIcon: make an icon type to be set on construction, so that it can't be changed. Fixes: https://bugs.launchpad.net/bugs/763560. Approved by Marco Trevisan (Treviño).
(bzr r2553)
-rw-r--r--launcher/AbstractLauncherIcon.h2
-rw-r--r--launcher/BFBLauncherIcon.cpp3
-rw-r--r--launcher/BamfLauncherIcon.cpp3
-rw-r--r--launcher/DesktopLauncherIcon.cpp3
-rw-r--r--launcher/DeviceLauncherIcon.cpp3
-rw-r--r--launcher/HudLauncherIcon.cpp3
-rw-r--r--launcher/LauncherController.cpp3
-rw-r--r--launcher/LauncherIcon.cpp14
-rw-r--r--launcher/LauncherIcon.h10
-rw-r--r--launcher/MockLauncherIcon.h2
-rw-r--r--launcher/SimpleLauncherIcon.cpp5
-rw-r--r--launcher/SimpleLauncherIcon.h2
-rw-r--r--launcher/SingleMonitorLauncherIcon.cpp4
-rw-r--r--launcher/SingleMonitorLauncherIcon.h2
-rw-r--r--launcher/SoftwareCenterLauncherIcon.cpp1
-rw-r--r--launcher/SpacerLauncherIcon.cpp3
-rw-r--r--launcher/TrashLauncherIcon.cpp3
-rw-r--r--plugins/unityshell/src/unitya11ytests.cpp2
-rw-r--r--tests/test_single_monitor_launcher_icon.cpp4
19 files changed, 28 insertions, 44 deletions
diff --git a/launcher/AbstractLauncherIcon.h b/launcher/AbstractLauncherIcon.h
index 73f0395af..ca56aeda4 100644
--- a/launcher/AbstractLauncherIcon.h
+++ b/launcher/AbstractLauncherIcon.h
@@ -175,7 +175,7 @@ public:
virtual void ResetQuirkTime(Quirk quirk) = 0;
- virtual IconType GetIconType() = 0;
+ virtual IconType GetIconType() const = 0;
virtual std::string RemoteUri() = 0;
diff --git a/launcher/BFBLauncherIcon.cpp b/launcher/BFBLauncherIcon.cpp
index d66f2deaa..394106cf1 100644
--- a/launcher/BFBLauncherIcon.cpp
+++ b/launcher/BFBLauncherIcon.cpp
@@ -33,7 +33,7 @@ namespace launcher
UBusManager BFBLauncherIcon::ubus_manager_;
BFBLauncherIcon::BFBLauncherIcon(LauncherHideMode hide_mode)
- : SimpleLauncherIcon()
+ : SimpleLauncherIcon(IconType::HOME)
, reader_(dash::LensDirectoryReader::GetDefault())
, launcher_hide_mode_(hide_mode)
{
@@ -41,7 +41,6 @@ BFBLauncherIcon::BFBLauncherIcon(LauncherHideMode hide_mode)
icon_name = PKGDATADIR"/launcher_bfb.png";
SetQuirk(Quirk::VISIBLE, true);
SetQuirk(Quirk::RUNNING, false);
- SetIconType(IconType::HOME);
background_color_ = nux::color::White;
diff --git a/launcher/BamfLauncherIcon.cpp b/launcher/BamfLauncherIcon.cpp
index 62f70dbdb..c686ae122 100644
--- a/launcher/BamfLauncherIcon.cpp
+++ b/launcher/BamfLauncherIcon.cpp
@@ -57,7 +57,7 @@ nux::logging::Logger logger("unity.launcher");
NUX_IMPLEMENT_OBJECT_TYPE(BamfLauncherIcon);
BamfLauncherIcon::BamfLauncherIcon(BamfApplication* app)
- : SimpleLauncherIcon()
+ : SimpleLauncherIcon(IconType::APPLICATION)
, _bamf_app(app, glib::AddRef())
, _supported_types_filled(false)
, use_custom_bg_color_(false)
@@ -71,7 +71,6 @@ BamfLauncherIcon::BamfLauncherIcon(BamfApplication* app)
tooltip_text = BamfName();
icon_name = (icon ? icon.Str() : DEFAULT_ICON);
- SetIconType(IconType::APPLICATION);
if (IsSticky())
SetQuirk(Quirk::VISIBLE, true);
diff --git a/launcher/DesktopLauncherIcon.cpp b/launcher/DesktopLauncherIcon.cpp
index 715fd9ac8..712763060 100644
--- a/launcher/DesktopLauncherIcon.cpp
+++ b/launcher/DesktopLauncherIcon.cpp
@@ -28,14 +28,13 @@ namespace launcher
{
DesktopLauncherIcon::DesktopLauncherIcon()
- : SimpleLauncherIcon()
+ : SimpleLauncherIcon(IconType::DESKTOP)
, show_in_switcher_(true)
{
tooltip_text = _("Show Desktop");
icon_name = "desktop";
SetQuirk(Quirk::VISIBLE, true);
SetQuirk(Quirk::RUNNING, false);
- SetIconType(IconType::DESKTOP);
}
DesktopLauncherIcon::~DesktopLauncherIcon()
diff --git a/launcher/DeviceLauncherIcon.cpp b/launcher/DeviceLauncherIcon.cpp
index 017f5aacb..23926a1cb 100644
--- a/launcher/DeviceLauncherIcon.cpp
+++ b/launcher/DeviceLauncherIcon.cpp
@@ -45,7 +45,7 @@ const unsigned int volume_changed_timeout = 500;
}
DeviceLauncherIcon::DeviceLauncherIcon(glib::Object<GVolume> const& volume)
- : SimpleLauncherIcon()
+ : SimpleLauncherIcon(IconType::DEVICE)
, volume_(volume)
{
signal_volume_changed_.Connect(volume, "changed", sigc::mem_fun(this, &DeviceLauncherIcon::OnVolumeChanged));
@@ -109,7 +109,6 @@ void DeviceLauncherIcon::UpdateDeviceIcon()
tooltip_text = name_;
icon_name = icon_string.Str();
- SetIconType(IconType::DEVICE);
SetQuirk(Quirk::RUNNING, false);
}
diff --git a/launcher/HudLauncherIcon.cpp b/launcher/HudLauncherIcon.cpp
index 3a7c64ef6..abdb6a960 100644
--- a/launcher/HudLauncherIcon.cpp
+++ b/launcher/HudLauncherIcon.cpp
@@ -39,7 +39,7 @@ nux::logging::Logger logger("unity.launcher.hudlaunchericon");
UBusManager HudLauncherIcon::ubus_manager_;
HudLauncherIcon::HudLauncherIcon(LauncherHideMode hide_mode)
- : SingleMonitorLauncherIcon(0)
+ : SingleMonitorLauncherIcon(IconType::HUD, 0)
, launcher_hide_mode_(hide_mode)
{
tooltip_text = _("HUD");
@@ -47,7 +47,6 @@ HudLauncherIcon::HudLauncherIcon(LauncherHideMode hide_mode)
SetQuirk(Quirk::VISIBLE, false);
SetQuirk(Quirk::RUNNING, false);
SetQuirk(Quirk::ACTIVE, true);
- SetIconType(IconType::HUD);
background_color_ = nux::color::White;
diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp
index 2ee6150c3..afc981f6f 100644
--- a/launcher/LauncherController.cpp
+++ b/launcher/LauncherController.cpp
@@ -565,14 +565,13 @@ void Controller::Impl::UpdateNumWorkspaces(int workspaces)
void Controller::Impl::InsertExpoAction()
{
- expo_icon_ = AbstractLauncherIcon::Ptr(new SimpleLauncherIcon());
+ expo_icon_ = AbstractLauncherIcon::Ptr(new SimpleLauncherIcon(AbstractLauncherIcon::IconType::EXPO));
SimpleLauncherIcon* icon = static_cast<SimpleLauncherIcon*>(expo_icon_.GetPointer());
icon->tooltip_text = _("Workspace Switcher");
icon->icon_name = "workspace-switcher";
icon->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, true);
icon->SetQuirk(AbstractLauncherIcon::Quirk::RUNNING, false);
- icon->SetIconType(AbstractLauncherIcon::IconType::EXPO);
icon->SetShortcut('s');
on_expoicon_activate_connection_ = icon->activate.connect(sigc::mem_fun(this, &Impl::OnExpoActivated));
diff --git a/launcher/LauncherIcon.cpp b/launcher/LauncherIcon.cpp
index 236e3a38e..6dcbff56f 100644
--- a/launcher/LauncherIcon.cpp
+++ b/launcher/LauncherIcon.cpp
@@ -72,8 +72,9 @@ NUX_IMPLEMENT_OBJECT_TYPE(LauncherIcon);
int LauncherIcon::_current_theme_is_mono = -1;
glib::Object<GtkIconTheme> LauncherIcon::_unity_theme;
-LauncherIcon::LauncherIcon()
- : _remote_urgent(false)
+LauncherIcon::LauncherIcon(IconType type)
+ : _icon_type(type)
+ , _remote_urgent(false)
, _present_urgency(0)
, _progress(0)
, _sort_priority(0)
@@ -81,7 +82,6 @@ LauncherIcon::LauncherIcon()
, _background_color(nux::color::White)
, _glow_color(nux::color::White)
, _shortcut(0)
- , _icon_type(IconType::NONE)
, _center(max_num_monitors)
, _has_visible_window(max_num_monitors)
, _last_stable(max_num_monitors)
@@ -812,12 +812,6 @@ LauncherIcon::Remove()
}
void
-LauncherIcon::SetIconType(IconType type)
-{
- _icon_type = type;
-}
-
-void
LauncherIcon::SetSortPriority(int priority)
{
_sort_priority = priority;
@@ -830,7 +824,7 @@ LauncherIcon::SortPriority()
}
LauncherIcon::IconType
-LauncherIcon::GetIconType()
+LauncherIcon::GetIconType() const
{
return _icon_type;
}
diff --git a/launcher/LauncherIcon.h b/launcher/LauncherIcon.h
index 3544535ae..88fd229ef 100644
--- a/launcher/LauncherIcon.h
+++ b/launcher/LauncherIcon.h
@@ -54,7 +54,7 @@ class LauncherIcon : public AbstractLauncherIcon
public:
typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr;
- LauncherIcon();
+ LauncherIcon(IconType type);
virtual ~LauncherIcon();
@@ -139,7 +139,7 @@ public:
struct timespec GetQuirkTime(Quirk quirk);
- IconType GetIconType();
+ IconType GetIconType() const;
virtual nux::Color BackgroundColor() const;
@@ -186,8 +186,6 @@ public:
OnDndLeave();
}
- void SetIconType(IconType type);
-
virtual std::string DesktopFile() { return std::string(""); }
virtual bool IsSticky() const { return false; }
@@ -298,6 +296,8 @@ protected:
glib::Object<DbusmenuClient> _menuclient_dynamic_quicklist;
private:
+ IconType _icon_type;
+
nux::ObjectPtr<Tooltip> _tooltip;
nux::ObjectPtr<QuicklistView> _quicklist;
@@ -323,8 +323,6 @@ private:
gint64 _shortcut;
- IconType _icon_type;
-
std::vector<nux::Point3> _center;
std::vector<bool> _has_visible_window;
std::vector<bool> _is_visible_on_monitor;
diff --git a/launcher/MockLauncherIcon.h b/launcher/MockLauncherIcon.h
index df00452ac..5fa49873c 100644
--- a/launcher/MockLauncherIcon.h
+++ b/launcher/MockLauncherIcon.h
@@ -222,7 +222,7 @@ public:
return quirk_times_[unsigned(quirk)];
}
- IconType GetIconType()
+ IconType GetIconType() const
{
return type_;
}
diff --git a/launcher/SimpleLauncherIcon.cpp b/launcher/SimpleLauncherIcon.cpp
index e1d9648d2..a3c6ccac4 100644
--- a/launcher/SimpleLauncherIcon.cpp
+++ b/launcher/SimpleLauncherIcon.cpp
@@ -43,8 +43,9 @@ namespace
NUX_IMPLEMENT_OBJECT_TYPE(SimpleLauncherIcon);
-SimpleLauncherIcon::SimpleLauncherIcon()
- : icon_name("", sigc::mem_fun(this, &SimpleLauncherIcon::SetIconName))
+SimpleLauncherIcon::SimpleLauncherIcon(IconType type)
+ : LauncherIcon(type)
+ , icon_name("", sigc::mem_fun(this, &SimpleLauncherIcon::SetIconName))
, theme_changed_id_(0)
{
LauncherIcon::mouse_down.connect(sigc::mem_fun(this, &SimpleLauncherIcon::OnMouseDown));
diff --git a/launcher/SimpleLauncherIcon.h b/launcher/SimpleLauncherIcon.h
index d22ac1013..921f75559 100644
--- a/launcher/SimpleLauncherIcon.h
+++ b/launcher/SimpleLauncherIcon.h
@@ -33,7 +33,7 @@ class SimpleLauncherIcon : public LauncherIcon
{
NUX_DECLARE_OBJECT_TYPE(SimpleLauncherIcon, LauncherIcon);
public:
- SimpleLauncherIcon();
+ SimpleLauncherIcon(IconType type);
virtual ~SimpleLauncherIcon();
// override
diff --git a/launcher/SingleMonitorLauncherIcon.cpp b/launcher/SingleMonitorLauncherIcon.cpp
index f4b562daf..7cb6355b7 100644
--- a/launcher/SingleMonitorLauncherIcon.cpp
+++ b/launcher/SingleMonitorLauncherIcon.cpp
@@ -27,8 +27,8 @@ namespace unity
namespace launcher
{
-SingleMonitorLauncherIcon::SingleMonitorLauncherIcon(int monitor)
- : SimpleLauncherIcon()
+SingleMonitorLauncherIcon::SingleMonitorLauncherIcon(IconType type, int monitor)
+ : SimpleLauncherIcon(type)
, monitor_(monitor)
{
UpdateMonitor();
diff --git a/launcher/SingleMonitorLauncherIcon.h b/launcher/SingleMonitorLauncherIcon.h
index a27c1310d..fdca150be 100644
--- a/launcher/SingleMonitorLauncherIcon.h
+++ b/launcher/SingleMonitorLauncherIcon.h
@@ -31,7 +31,7 @@ class SingleMonitorLauncherIcon : public SimpleLauncherIcon
{
public:
- SingleMonitorLauncherIcon(int monitor);
+ SingleMonitorLauncherIcon(IconType type, int monitor);
void SetMonitor(int monitor);
int GetMonitor();
diff --git a/launcher/SoftwareCenterLauncherIcon.cpp b/launcher/SoftwareCenterLauncherIcon.cpp
index e88c6462f..93227a2a8 100644
--- a/launcher/SoftwareCenterLauncherIcon.cpp
+++ b/launcher/SoftwareCenterLauncherIcon.cpp
@@ -49,7 +49,6 @@ SoftwareCenterLauncherIcon::SoftwareCenterLauncherIcon(BamfApplication* app,
aptdaemon_trans_.Connect("PropertyChanged", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnPropertyChanged));
aptdaemon_trans_.Connect("Finished", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnFinished));
- SetIconType(IconType::APPLICATION);
icon_name = icon_path;
if (!aptdaemon_trans_id_.empty()) // Application is being installed, or hasn't been installed yet
tooltip_text = _("Waiting to install");
diff --git a/launcher/SpacerLauncherIcon.cpp b/launcher/SpacerLauncherIcon.cpp
index 6c46b6749..db4803b7a 100644
--- a/launcher/SpacerLauncherIcon.cpp
+++ b/launcher/SpacerLauncherIcon.cpp
@@ -28,11 +28,10 @@ namespace launcher
{
SpacerLauncherIcon::SpacerLauncherIcon(int monitor)
- : SingleMonitorLauncherIcon(monitor)
+ : SingleMonitorLauncherIcon(IconType::APPLICATION, monitor)
{
SetQuirk(Quirk::VISIBLE, true);
SetQuirk(Quirk::RUNNING, false);
- SetIconType(IconType::APPLICATION);
tooltip_text = _("Drop To Add Application");
}
diff --git a/launcher/TrashLauncherIcon.cpp b/launcher/TrashLauncherIcon.cpp
index b91efd13f..692bb34be 100644
--- a/launcher/TrashLauncherIcon.cpp
+++ b/launcher/TrashLauncherIcon.cpp
@@ -38,7 +38,7 @@ namespace
}
TrashLauncherIcon::TrashLauncherIcon()
- : SimpleLauncherIcon()
+ : SimpleLauncherIcon(IconType::TRASH)
, proxy_("org.gnome.Nautilus", "/org/gnome/Nautilus", "org.gnome.Nautilus.FileOperations")
, cancellable_(g_cancellable_new())
{
@@ -46,7 +46,6 @@ TrashLauncherIcon::TrashLauncherIcon()
icon_name = "user-trash";
SetQuirk(Quirk::VISIBLE, true);
SetQuirk(Quirk::RUNNING, false);
- SetIconType(IconType::TRASH);
SetShortcut('t');
glib::Object<GFile> location(g_file_new_for_uri("trash:///"));
diff --git a/plugins/unityshell/src/unitya11ytests.cpp b/plugins/unityshell/src/unitya11ytests.cpp
index 20328a674..7a84331ce 100644
--- a/plugins/unityshell/src/unitya11ytests.cpp
+++ b/plugins/unityshell/src/unitya11ytests.cpp
@@ -224,7 +224,7 @@ a11y_unit_test_launcher_connection(void)
g_debug("[a11y] Launcher accessible created correctly");
}
- launcher_icon = new SimpleLauncherIcon();
+ launcher_icon = new SimpleLauncherIcon(unity::launcher::AbstractLauncherIcon::IconType::NONE);
launcher_icon->SinkReference();
launcher_icon_accessible = unity_a11y_get_accessible(launcher_icon);
diff --git a/tests/test_single_monitor_launcher_icon.cpp b/tests/test_single_monitor_launcher_icon.cpp
index 22f512b65..eeaa9f373 100644
--- a/tests/test_single_monitor_launcher_icon.cpp
+++ b/tests/test_single_monitor_launcher_icon.cpp
@@ -30,7 +30,7 @@ namespace
TEST(TestSingleMonitorLauncherIcon, Construction)
{
- SingleMonitorLauncherIcon icon(1);
+ SingleMonitorLauncherIcon icon(AbstractLauncherIcon::IconType::NONE, 1);
EXPECT_EQ(icon.GetMonitor(), 1);
EXPECT_TRUE(icon.IsVisibleOnMonitor(1));
@@ -39,7 +39,7 @@ TEST(TestSingleMonitorLauncherIcon, Construction)
TEST(TestSingleMonitorLauncherIcon, MonitorVisibility)
{
- SingleMonitorLauncherIcon icon(2);
+ SingleMonitorLauncherIcon icon(AbstractLauncherIcon::IconType::NONE, 2);
for (int i = 0; i < max_num_monitors; ++i)
{