summaryrefslogtreecommitdiff
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2021-06-01 21:13:12 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2021-06-01 21:16:56 +0200
commit653d80099af95b30d969b9b0e91fff120fde11d6 (patch)
treee2a172e247894c47e3bb3555405f3181b3798aad
parent4ee3e74f398a3d17552407a088a9fffead381954 (diff)
LauncherController: Move GetLastIconPriority into a private impl header
Being a template it must be defined for all its customers, so expose it to the test. Fixes linking issue on s390x.
-rw-r--r--launcher/LauncherController.cpp54
-rw-r--r--launcher/LauncherControllerPrivateImpl.h81
-rw-r--r--tests/test_launcher_controller.cpp1
3 files changed, 83 insertions, 53 deletions
diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp
index 5fb288299..3a38b5f5c 100644
--- a/launcher/LauncherController.cpp
+++ b/launcher/LauncherController.cpp
@@ -36,6 +36,7 @@
#include "FileManagerLauncherIcon.h"
#include "LauncherController.h"
#include "LauncherControllerPrivate.h"
+#include "LauncherControllerPrivateImpl.h"
#include "SoftwareCenterLauncherIcon.h"
#include "ExpoLauncherIcon.h"
#include "TrashLauncherIcon.h"
@@ -790,59 +791,6 @@ void Controller::Impl::RegisterIcon(AbstractLauncherIcon::Ptr const& icon, int p
}
}
-template<typename IconType>
-int Controller::Impl::GetLastIconPriority(std::string const& favorite_uri, bool sticky)
-{
- auto const& icons = model_->GetSublist<IconType>();
- int icon_prio = std::numeric_limits<int>::min();
-
- AbstractLauncherIcon::Ptr last_icon;
-
- // Get the last (non)-sticky icon position (if available)
- for (auto it = icons.rbegin(); it != icons.rend(); ++it)
- {
- auto const& icon = *it;
- bool update_last_icon = ((!last_icon && !sticky) || sticky);
-
- if (update_last_icon || icon->IsSticky() == sticky)
- {
- last_icon = icon;
-
- if (icon->IsSticky() == sticky)
- break;
- }
- }
-
- if (last_icon)
- {
- icon_prio = last_icon->SortPriority();
-
- if (sticky && last_icon->IsSticky() != sticky)
- icon_prio -= 1;
- }
- else if (!favorite_uri.empty())
- {
- // If we have no applications opened, we must guess it position by favorites
- for (auto const& fav : FavoriteStore::Instance().GetFavorites())
- {
- if (fav == favorite_uri)
- {
- if (icon_prio == std::numeric_limits<int>::min())
- icon_prio = (*model_->begin())->SortPriority() - 1;
-
- break;
- }
-
- auto const& icon = GetIconByUri(fav);
-
- if (icon)
- icon_prio = icon->SortPriority();
- }
- }
-
- return icon_prio;
-}
-
void Controller::Impl::OnApplicationStarted(ApplicationPtr const& app)
{
if (app->sticky() || app->seen())
diff --git a/launcher/LauncherControllerPrivateImpl.h b/launcher/LauncherControllerPrivateImpl.h
new file mode 100644
index 000000000..88b1db842
--- /dev/null
+++ b/launcher/LauncherControllerPrivateImpl.h
@@ -0,0 +1,81 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2010-2012 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Jason Smith <jason.smith@canonical.com>
+ * Tim Penhey <tim.penhey@canonical.com>
+ * Marco Trevisan <marco.trevisan@canonical.com>
+ */
+
+namespace unity
+{
+namespace launcher
+{
+
+template<typename IconType>
+int Controller::Impl::GetLastIconPriority(std::string const& favorite_uri, bool sticky)
+{
+ auto const& icons = model_->GetSublist<IconType>();
+ int icon_prio = std::numeric_limits<int>::min();
+
+ AbstractLauncherIcon::Ptr last_icon;
+
+ // Get the last (non)-sticky icon position (if available)
+ for (auto it = icons.rbegin(); it != icons.rend(); ++it)
+ {
+ auto const& icon = *it;
+ bool update_last_icon = ((!last_icon && !sticky) || sticky);
+
+ if (update_last_icon || icon->IsSticky() == sticky)
+ {
+ last_icon = icon;
+
+ if (icon->IsSticky() == sticky)
+ break;
+ }
+ }
+
+ if (last_icon)
+ {
+ icon_prio = last_icon->SortPriority();
+
+ if (sticky && last_icon->IsSticky() != sticky)
+ icon_prio -= 1;
+ }
+ else if (!favorite_uri.empty())
+ {
+ // If we have no applications opened, we must guess it position by favorites
+ for (auto const& fav : FavoriteStore::Instance().GetFavorites())
+ {
+ if (fav == favorite_uri)
+ {
+ if (icon_prio == std::numeric_limits<int>::min())
+ icon_prio = (*model_->begin())->SortPriority() - 1;
+
+ break;
+ }
+
+ auto const& icon = GetIconByUri(fav);
+
+ if (icon)
+ icon_prio = icon->SortPriority();
+ }
+ }
+
+ return icon_prio;
+}
+
+} // namespace launcher
+} // namespace unity
diff --git a/tests/test_launcher_controller.cpp b/tests/test_launcher_controller.cpp
index 6a6df5c48..9495dffff 100644
--- a/tests/test_launcher_controller.cpp
+++ b/tests/test_launcher_controller.cpp
@@ -22,6 +22,7 @@
#include "FavoriteStore.h"
#include "LauncherController.h"
#include "LauncherControllerPrivate.h"
+#include "LauncherControllerPrivateImpl.h"
#include "ExpoLauncherIcon.h"
#include "DesktopLauncherIcon.h"
#include "DesktopUtilities.h"