diff options
| author | Andrea Azzarone <azzaronea@gmail.com> | 2012-04-24 17:57:01 -0400 |
|---|---|---|
| committer | Tarmac <> | 2012-04-24 17:57:01 -0400 |
| commit | 2c5982c81982a905102e7ef60c947c96b6e3e2c4 (patch) | |
| tree | bb20189b07537cb2bcbcdb7d3175d451838763e4 | |
| parent | f98845b16299b47521a4413607a7df769072c60a (diff) | |
| parent | 9f5e7897d7ab0e8058a117e81998c089d0824192 (diff) | |
Set a shortcut for the new apps on the launcher too.. Fixes: https://bugs.launchpad.net/bugs/778499. Approved by Marco Trevisan (TreviƱo).
(bzr r2335)
| -rw-r--r-- | plugins/unityshell/src/AbstractLauncherIcon.h | 1 | ||||
| -rw-r--r-- | plugins/unityshell/src/LauncherController.cpp | 9 | ||||
| -rw-r--r-- | plugins/unityshell/src/LauncherIcon.cpp | 6 | ||||
| -rw-r--r-- | tests/autopilot/autopilot/emulators/unity/launcher.py | 11 | ||||
| -rw-r--r-- | tests/autopilot/autopilot/tests/test_launcher.py | 13 |
5 files changed, 37 insertions, 3 deletions
diff --git a/plugins/unityshell/src/AbstractLauncherIcon.h b/plugins/unityshell/src/AbstractLauncherIcon.h index 874ce310c..d34e07a97 100644 --- a/plugins/unityshell/src/AbstractLauncherIcon.h +++ b/plugins/unityshell/src/AbstractLauncherIcon.h @@ -215,6 +215,7 @@ public: sigc::signal<void, AbstractLauncherIcon::Ptr> needs_redraw; sigc::signal<void, AbstractLauncherIcon::Ptr> remove; + sigc::signal<void> visibility_changed; sigc::connection needs_redraw_connection; sigc::connection on_icon_added_connection; diff --git a/plugins/unityshell/src/LauncherController.cpp b/plugins/unityshell/src/LauncherController.cpp index f4a9a4718..a2e0868a2 100644 --- a/plugins/unityshell/src/LauncherController.cpp +++ b/plugins/unityshell/src/LauncherController.cpp @@ -497,7 +497,7 @@ void Controller::Impl::SortAndUpdate() std::stringstream shortcut_string; shortcut_string << (shortcut % 10); icon->SetShortcut(shortcut_string.str()[0]); - shortcut++; + ++shortcut; } // reset shortcut else @@ -607,6 +607,8 @@ void Controller::Impl::OnFavoriteStoreFavoriteAdded(std::string const& entry, st else model_->ReorderBefore(result, other, false); } + + SortAndUpdate(); } void Controller::Impl::OnFavoriteStoreFavoriteRemoved(std::string const& entry) @@ -738,10 +740,11 @@ void Controller::Impl::OnViewOpened(BamfMatcher* matcher, BamfView* view, gpoint return; } - AbstractLauncherIcon::Ptr icon (new BamfLauncherIcon(app)); + AbstractLauncherIcon::Ptr icon(new BamfLauncherIcon(app)); + icon->visibility_changed.connect(sigc::mem_fun(self, &Impl::SortAndUpdate)); icon->SetSortPriority(self->sort_priority_++); - self->RegisterIcon(icon); + self->SortAndUpdate(); } AbstractLauncherIcon::Ptr Controller::Impl::CreateFavorite(const char* file_path) diff --git a/plugins/unityshell/src/LauncherIcon.cpp b/plugins/unityshell/src/LauncherIcon.cpp index 5ea08d50b..448bd72f5 100644 --- a/plugins/unityshell/src/LauncherIcon.cpp +++ b/plugins/unityshell/src/LauncherIcon.cpp @@ -202,6 +202,7 @@ LauncherIcon::AddProperties(GVariantBuilder* builder) .add("icon_type", _icon_type) .add("tooltip_text", tooltip_text()) .add("sort_priority", _sort_priority) + .add("shortcut", _shortcut) .add("monitors_visibility", g_variant_builder_end(&monitors_builder)) .add("active", GetQuirk(QUIRK_ACTIVE)) .add("visible", GetQuirk(QUIRK_VISIBLE)) @@ -853,6 +854,11 @@ LauncherIcon::SetQuirk(LauncherIcon::Quirk quirk, bool value) UBusServer* ubus = ubus_server_get_default(); ubus_server_send_message(ubus, UBUS_LAUNCHER_ICON_URGENT_CHANGED, g_variant_new_boolean(value)); } + + if (quirk == QUIRK_VISIBLE) + { + visibility_changed.emit(); + } } gboolean diff --git a/tests/autopilot/autopilot/emulators/unity/launcher.py b/tests/autopilot/autopilot/emulators/unity/launcher.py index f8a978414..2a11ceda6 100644 --- a/tests/autopilot/autopilot/emulators/unity/launcher.py +++ b/tests/autopilot/autopilot/emulators/unity/launcher.py @@ -301,6 +301,13 @@ class LauncherModel(UnityIntrospectionObject): else: return self.get_children_by_type(SimpleLauncherIcon) + def get_bamf_launcher_icons(self, visible_only=True): + """Get a list of bamf launcher icons in this launcher.""" + if visible_only: + return self.get_children_by_type(BamfLauncherIcon, visible=True) + else: + return self.get_children_by_type(BamfLauncherIcon) + def get_launcher_icons_for_monitor(self, monitor, visible_only=True): """Get a list of launcher icons for provided monitor.""" icons = [] @@ -345,3 +352,7 @@ class LauncherModel(UnityIntrospectionObject): def num_launcher_icons(self): """Get the number of icons in the launcher model.""" return len(self.get_launcher_icons()) + + def num_bamf_launcher_icons(self, visible_only=True): + """Get the number of bamf icons in the launcher model.""" + return len(self.get_bamf_launcher_icons(visible_only)) diff --git a/tests/autopilot/autopilot/tests/test_launcher.py b/tests/autopilot/autopilot/tests/test_launcher.py index 10cf3480e..ed0518f5c 100644 --- a/tests/autopilot/autopilot/tests/test_launcher.py +++ b/tests/autopilot/autopilot/tests/test_launcher.py @@ -499,6 +499,19 @@ class LauncherRevealTests(LauncherTestCase): sleep(5) self.assertThat(self.launcher_instance.is_showing, Equals(False)) + def test_new_icon_has_the_shortcut(self): + """New icons should have an associated shortcut""" + if self.launcher.model.num_bamf_launcher_icons() >= 10: + self.skip("There are already more than 9 icons in the launcher") + + desktop_file = self.KNOWN_APPS['Calculator']['desktop-file'] + if self.launcher.model.get_icon_by_desktop_id(desktop_file) != None: + self.skip("Calculator icon is already on the launcher.") + + self.start_app('Calculator') + icon = self.launcher.model.get_icon_by_desktop_id(desktop_file) + self.assertThat(icon.shortcut, GreaterThan(0)) + class LauncherVisualTests(LauncherTestCase): """Tests for visual aspects of the launcher (icon saturation etc.).""" |
