diff options
| author | Jussi Pakkanen <jussi.pakkanen@canonical.com> | 2012-12-13 09:47:24 +0200 |
|---|---|---|
| committer | Jussi Pakkanen <jussi.pakkanen@canonical.com> | 2012-12-13 09:47:24 +0200 |
| commit | 50f67d6e8def319d4418426ffca2ada7f01ca625 (patch) | |
| tree | bbca91c2befd63c967d32c53d27f961305d88f71 /launcher | |
| parent | a25c018cab7308ae09091ab62b9757806776ac4f (diff) | |
| parent | 3506d3b0ff658db6fafd092926d399752963fbba (diff) | |
Merged with trunk.
(bzr r2934.3.9)
Diffstat (limited to 'launcher')
| -rw-r--r-- | launcher/ApplicationLauncherIcon.cpp | 11 | ||||
| -rw-r--r-- | launcher/ApplicationLauncherIcon.h | 11 | ||||
| -rw-r--r-- | launcher/EdgeBarrierController.cpp | 24 | ||||
| -rw-r--r-- | launcher/LauncherController.cpp | 14 | ||||
| -rw-r--r-- | launcher/LauncherController.h | 2 | ||||
| -rw-r--r-- | launcher/LauncherControllerPrivate.h | 1 | ||||
| -rw-r--r-- | launcher/LauncherIcon.cpp | 14 | ||||
| -rw-r--r-- | launcher/SoftwareCenterLauncherIcon.cpp | 83 | ||||
| -rw-r--r-- | launcher/SoftwareCenterLauncherIcon.h | 4 | ||||
| -rw-r--r-- | launcher/Tooltip.cpp | 33 | ||||
| -rw-r--r-- | launcher/Tooltip.h | 13 |
11 files changed, 148 insertions, 62 deletions
diff --git a/launcher/ApplicationLauncherIcon.cpp b/launcher/ApplicationLauncherIcon.cpp index e9cc7bde8..cbae24243 100644 --- a/launcher/ApplicationLauncherIcon.cpp +++ b/launcher/ApplicationLauncherIcon.cpp @@ -973,16 +973,21 @@ std::string ApplicationLauncherIcon::GetDesktopID() return DesktopUtilities::GetDesktopID(desktop_file); } -std::string ApplicationLauncherIcon::GetRemoteUri() +void ApplicationLauncherIcon::UpdateRemoteUri() { - if (_remote_uri.empty()) - { std::string const& desktop_id = GetDesktopID(); if (!desktop_id.empty()) { _remote_uri = FavoriteStore::URI_PREFIX_APP + desktop_id; } +} + +std::string ApplicationLauncherIcon::GetRemoteUri() +{ + if (_remote_uri.empty()) + { + UpdateRemoteUri(); } return _remote_uri; diff --git a/launcher/ApplicationLauncherIcon.h b/launcher/ApplicationLauncherIcon.h index ceef2323f..6e756bfdd 100644 --- a/launcher/ApplicationLauncherIcon.h +++ b/launcher/ApplicationLauncherIcon.h @@ -89,6 +89,12 @@ protected: bool HandlesSpread() { return true; } std::string GetName() const; +protected: + void UpdateDesktopFile(); + void UpdateRemoteUri(); + std::string _desktop_file; + ApplicationPtr app_; + private: typedef unsigned long int WindowFilterMask; enum WindowFilter @@ -102,7 +108,6 @@ private: void EnsureWindowState(); void EnsureMenuItemsReady(); void UpdateBackgroundColor(); - void UpdateDesktopFile(); void UpdateMenus(); void UpdateDesktopQuickList(); @@ -117,10 +122,8 @@ private: const std::set<std::string> GetSupportedTypes(); std::string GetDesktopID(); - ApplicationPtr app_; - std::string _remote_uri; - std::string _desktop_file; + std::set<std::string> _supported_types; std::map<std::string, glib::Object<DbusmenuClient>> _menu_clients; std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items; std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items_extra; diff --git a/launcher/EdgeBarrierController.cpp b/launcher/EdgeBarrierController.cpp index 4f549cc3d..c3f52b3fa 100644 --- a/launcher/EdgeBarrierController.cpp +++ b/launcher/EdgeBarrierController.cpp @@ -36,21 +36,6 @@ struct EdgeBarrierController::Impl void OnPointerBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event); void BarrierRelease(PointerBarrierWrapper* owner, int event); - bool StickyEdgeSetter(bool const& new_val) - { - if (parent_->options() && new_val != parent_->options()->edge_resist()) - { - parent_->options()->edge_resist = new_val; - return true; - } - return false; - } - - bool StickyEdgeGetter() - { - return parent_->options() ? parent_->options()->edge_resist() : false; - } - std::vector<PointerBarrierWrapper::Ptr> barriers_; std::vector<EdgeBarrierSubscriber*> subscribers_; Decaymulator decaymulator_; @@ -73,15 +58,11 @@ EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent) SetupBarriers(layout); }); - parent_->sticky_edges.SetGetterFunction(sigc::mem_fun(this, &Impl::StickyEdgeGetter)); - parent_->sticky_edges.SetSetterFunction(sigc::mem_fun(this, &Impl::StickyEdgeSetter)); - -/* Set this back, once lp:~3v1n0/nux/use-std-function is merged - parent_->sticky_edges.SetGetterFunction([parent_] { + parent_->sticky_edges.SetGetterFunction([this] { return parent_->options() ? parent_->options()->edge_resist() : false; }); - parent_->sticky_edges.SetSetterFunction([parent_] (bool const& new_val) { + parent_->sticky_edges.SetSetterFunction([this] (bool const& new_val) { if (parent_->options() && new_val != parent_->options()->edge_resist()) { parent_->options()->edge_resist = new_val; @@ -89,7 +70,6 @@ EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent) } return false; }); - */ parent_->options.changed.connect([&](launcher::Options::Ptr options) { options->option_changed.connect([&]() { diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp index cf63cb04b..7f0419dbf 100644 --- a/launcher/LauncherController.cpp +++ b/launcher/LauncherController.cpp @@ -75,7 +75,6 @@ namespace local { namespace { - const int super_tap_duration = 250; const int launcher_minimum_show_duration = 1250; const int shortcuts_show_delay = 750; const int ignore_repeat_shortcut_duration = 250; @@ -109,6 +108,8 @@ Controller::Impl::Impl(Controller* parent, XdndManager::Ptr const& xdnd_manager) , reactivate_keynav(false) , keynav_restore_window_(true) , launcher_key_press_time_(0) + , last_dnd_monitor_(-1) + , super_tap_duration_(0) , dbus_owner_(g_bus_own_name(G_BUS_TYPE_SESSION, DBUS_NAME.c_str(), G_BUS_NAME_OWNER_FLAGS_NONE, OnBusAcquired, nullptr, nullptr, this, nullptr)) , gdbus_connection_(nullptr) @@ -1089,7 +1090,7 @@ void Controller::HandleLauncherKeyPress(int when) return false; }; - pimpl->sources_.AddTimeout(local::super_tap_duration, show_launcher, local::KEYPRESS_TIMEOUT); + pimpl->sources_.AddTimeout(pimpl->super_tap_duration_, show_launcher, local::KEYPRESS_TIMEOUT); auto show_shortcuts = [&]() { @@ -1109,7 +1110,7 @@ void Controller::HandleLauncherKeyPress(int when) bool Controller::AboutToShowDash(int was_tap, int when) const { - if ((when - pimpl->launcher_key_press_time_) < local::super_tap_duration && was_tap) + if ((when - pimpl->launcher_key_press_time_) < pimpl->super_tap_duration_ && was_tap) return true; return false; } @@ -1117,7 +1118,7 @@ bool Controller::AboutToShowDash(int was_tap, int when) const void Controller::HandleLauncherKeyRelease(bool was_tap, int when) { int tap_duration = when - pimpl->launcher_key_press_time_; - if (tap_duration < local::super_tap_duration && was_tap) + if (tap_duration < pimpl->super_tap_duration_ && was_tap) { LOG_DEBUG(logger) << "Quick tap, sending activation request."; pimpl->SendHomeActivationRequest(); @@ -1330,6 +1331,11 @@ bool Controller::IsOverlayOpen() const return false; } +void Controller::UpdateSuperTapDuration(int const super_tap_duration) +{ + pimpl->super_tap_duration_ = super_tap_duration; +} + std::string Controller::GetName() const { diff --git a/launcher/LauncherController.h b/launcher/LauncherController.h index 72995e5ce..04504ebc8 100644 --- a/launcher/LauncherController.h +++ b/launcher/LauncherController.h @@ -81,6 +81,8 @@ public: bool IsOverlayOpen() const; + void UpdateSuperTapDuration(int const super_tap_duration); + protected: // Introspectable methods std::string GetName() const; diff --git a/launcher/LauncherControllerPrivate.h b/launcher/LauncherControllerPrivate.h index 1fda57d2c..79368a77b 100644 --- a/launcher/LauncherControllerPrivate.h +++ b/launcher/LauncherControllerPrivate.h @@ -149,6 +149,7 @@ public: bool keynav_restore_window_; int launcher_key_press_time_; int last_dnd_monitor_; + int super_tap_duration_; unsigned dbus_owner_; GDBusConnection* gdbus_connection_; diff --git a/launcher/LauncherIcon.cpp b/launcher/LauncherIcon.cpp index b35906c22..a06f0da49 100644 --- a/launcher/LauncherIcon.cpp +++ b/launcher/LauncherIcon.cpp @@ -147,7 +147,7 @@ void LauncherIcon::LoadTooltip() _tooltip = new Tooltip(); AddChild(_tooltip.GetPointer()); - _tooltip->SetText(tooltip_text()); + _tooltip->text = tooltip_text(); } void LauncherIcon::LoadQuicklist() @@ -475,7 +475,7 @@ bool LauncherIcon::SetTooltipText(std::string& target, std::string const& value) { target = escaped; if (_tooltip) - _tooltip->SetText(target); + _tooltip->text = target; result = true; } @@ -520,7 +520,7 @@ LauncherIcon::ShowTooltip() if (!_tooltip) LoadTooltip(); - _tooltip->SetText(tooltip_text()); + _tooltip->text = tooltip_text(); _tooltip->ShowTooltipWithTipAt(tip_x, tip_y); _tooltip->ShowWindow(!tooltip_text().empty()); tooltip_visible.emit(_tooltip); @@ -1193,14 +1193,16 @@ void LauncherIcon::EmitRemove() void LauncherIcon::Stick(bool save) { + // allow save() even for already "_sticky" icons that may have been + // made _sticky without "save" (like SoftwareCenterApplications) + if (save) + position_saved.emit(); + if (_sticky) return; _sticky = true; - if (save) - position_saved.emit(); - SetQuirk(Quirk::VISIBLE, true); } diff --git a/launcher/SoftwareCenterLauncherIcon.cpp b/launcher/SoftwareCenterLauncherIcon.cpp index cd94f06ae..3d024cfe7 100644 --- a/launcher/SoftwareCenterLauncherIcon.cpp +++ b/launcher/SoftwareCenterLauncherIcon.cpp @@ -16,15 +16,19 @@ * * Authored by: Bilal Akhtar <bilalakhtar@ubuntu.com> * Marco Trevisan (TreviƱo) <3v1n0@ubuntu.com> + * Michael Vogt <mvo@ubuntu.com> */ -#include <NuxCore/Logger.h> #include "config.h" + +#include <NuxCore/Logger.h> +#include <glib.h> #include <glib/gi18n-lib.h> #include "SoftwareCenterLauncherIcon.h" #include "Launcher.h" #include "LauncherDragWindow.h" #include "LauncherModel.h" +#include "DesktopUtilities.h" namespace unity { @@ -69,6 +73,14 @@ void SoftwareCenterLauncherIcon::Animate(nux::ObjectPtr<Launcher> const& launche { launcher_ = launcher; + // FIXME: this needs testing, if there is no useful coordinates + // then do not animate + if(start_x <= 0 && start_y <= 0) + { + SetQuirk(Quirk::VISIBLE, true); + return; + } + icon_texture_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture( launcher->GetWidth(), launcher->GetWidth(), @@ -118,6 +130,63 @@ void SoftwareCenterLauncherIcon::ActivateLauncherIcon(ActionArg arg) } } +std::string SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall() +{ + // Fixup the _desktop_file because the one we get from software-center + // is not the final one, e.g. the s-c-agent does send a temp one and + // app-install-data points to the "wrong" one in /usr/share/app-install + // + // So: + // - if there is a desktop file already and it startswith + // /usr/share/app-install/desktop, then transform to + // /usr/share/application + // - if there is a desktop file with prefix /tmp/software-center-agent: + // transform to /usr/share/application + // (its using "/tmp/software-center-agent:$random:$pkgname.desktop") + // maybe: + // - and search in /var/lib/apt/lists/$pkgname.list + // for a desktop file that roughly matches what we want + std::string filename = _desktop_file; + + // take /usr/share/app-install/desktop/foo:subdir__bar.desktop + // and tranform it + if (_desktop_file.find("/share/app-install/desktop/") != std::string::npos) + { + filename = filename.substr(filename.rfind(":") + 1, + filename.length() - filename.rfind(":")); + // the app-install-data package encodes subdirs in a funny way, once + // that is fixed, this code can be dropped + if (filename.find("__") != std::string::npos) + { + int pos = filename.find("__"); + filename = filename.replace(pos, 2, "-"); + } + filename = DesktopUtilities::GetDesktopPathById(filename); + return filename; + } + else if (_desktop_file.find("/tmp/software-center-agent:") == 0) + { + // by convention the software-center-agent uses + // /usr/share/applications/$pkgname.desktop + // or + // /usr/share/applications/extras-$pkgname.desktop + std::string desktopf = filename.substr(filename.rfind(":") + 1, + filename.length() - filename.rfind(":")); + filename = DesktopUtilities::GetDesktopPathById(desktopf); + if (filename.size() > 0) + return filename; + // now try extras-$pkgname.desktop + filename = DesktopUtilities::GetDesktopPathById(std::string("extras-") + desktopf); + if (filename.size() > 0) + return filename; + + // FIXME: test if there is a file now and if not, search + // /var/lib/dpkg/info/$pkgname.list for a desktop file + } + + return _desktop_file; +} + void SoftwareCenterLauncherIcon::OnFinished(GVariant *params) { glib::String exit_state; @@ -132,6 +201,18 @@ void SoftwareCenterLauncherIcon::OnFinished(GVariant *params) finished_ = true; needs_urgent_ = true; + // find and update to the real desktop file + std::string new_desktop_path = GetActualDesktopFileAfterInstall(); + + // exchange the temp Application with the real one + app_ = ApplicationManager::Default().GetApplicationForDesktopFile(new_desktop_path); + + UpdateDesktopFile(); + UpdateRemoteUri(); + + // make it permanent + Stick(true); + _source_manager.AddIdle([this]() { ShowTooltip(); diff --git a/launcher/SoftwareCenterLauncherIcon.h b/launcher/SoftwareCenterLauncherIcon.h index 6f0306855..1b1b6970c 100644 --- a/launcher/SoftwareCenterLauncherIcon.h +++ b/launcher/SoftwareCenterLauncherIcon.h @@ -47,11 +47,12 @@ public: std::string GetName() const; protected: + std::string GetActualDesktopFileAfterInstall(); void ActivateLauncherIcon(ActionArg arg); + void OnFinished(GVariant *params); private: void OnPropertyChanged(GVariant* params); - void OnFinished(GVariant *params); void OnDragAnimationFinished(); glib::DBusProxy aptdaemon_trans_; @@ -61,7 +62,6 @@ private: nux::ObjectPtr<Launcher> launcher_; bool finished_; bool needs_urgent_; - std::string aptdaemon_trans_id_; std::string app_title_; }; diff --git a/launcher/Tooltip.cpp b/launcher/Tooltip.cpp index 0c4bb6ab1..1b499ade9 100644 --- a/launcher/Tooltip.cpp +++ b/launcher/Tooltip.cpp @@ -47,7 +47,6 @@ NUX_IMPLEMENT_OBJECT_TYPE(Tooltip); Tooltip::Tooltip() : _anchorX(0), _anchorY(0), - _labelText(TEXT("Unity")), _cairo_text_has_changed(true) { _hlayout = new nux::HLayout(TEXT(""), NUX_TRACKER_LOCATION); @@ -61,7 +60,7 @@ Tooltip::Tooltip() : _vlayout->AddLayout(_top_space, 0); - _tooltip_text = new nux::StaticCairoText(_labelText, NUX_TRACKER_LOCATION); + _tooltip_text = new nux::StaticCairoText(TEXT(""), NUX_TRACKER_LOCATION); _tooltip_text->SetTextAlignment(nux::StaticCairoText::AlignState::NUX_ALIGN_CENTRE); _tooltip_text->SetTextVerticalAlignment(nux::StaticCairoText::AlignState::NUX_ALIGN_CENTRE); _tooltip_text->SetMinimumWidth(MINIMUM_TEXT_WIDTH); @@ -69,6 +68,22 @@ Tooltip::Tooltip() : _tooltip_text->sigTextChanged.connect(sigc::mem_fun(this, &Tooltip::RecvCairoTextChanged)); _tooltip_text->sigFontChanged.connect(sigc::mem_fun(this, &Tooltip::RecvCairoTextChanged)); + // getter and setter for the property + text.SetSetterFunction([this](std::string newText) + { + if(_tooltip_text->GetText() == newText) + return false; + + _tooltip_text->SetText(newText); + return true; + } + ); + text.SetGetterFunction([this]() + { + return _tooltip_text->GetText(); + } + ); + _vlayout->AddView(_tooltip_text.GetPointer(), 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); _vlayout->AddLayout(_bottom_space, 0); @@ -129,6 +144,7 @@ void Tooltip::PreLayoutManagement() } _tooltip_text->SetMinimumWidth(text_min_width); + _tooltip_text->SetMinimumHeight(text_height); if (text_height < ANCHOR_HEIGHT) { @@ -539,17 +555,6 @@ void Tooltip::NotifyConfigurationChange(int width, { } -void Tooltip::SetText(std::string const& text) -{ - if (_labelText == text) - return; - - _labelText = text; - _tooltip_text->SetText(_labelText); - - QueueRelayout(); -} - // Introspection std::string Tooltip::GetName() const @@ -560,7 +565,7 @@ std::string Tooltip::GetName() const void Tooltip::AddProperties(GVariantBuilder* builder) { variant::BuilderWrapper(builder) - .add("text", _labelText) + .add("text", text) .add("x", GetBaseX()) .add("y", GetBaseY()) .add("width", GetBaseWidth()) diff --git a/launcher/Tooltip.h b/launcher/Tooltip.h index fb8992e18..0cb67c013 100644 --- a/launcher/Tooltip.h +++ b/launcher/Tooltip.h @@ -39,11 +39,11 @@ class Tooltip : public CairoBaseWindow, public debug::Introspectable public: Tooltip(); + nux::RWProperty<std::string> text; + void Draw(nux::GraphicsEngine& gfxContext, bool forceDraw); void DrawContent(nux::GraphicsEngine& gfxContext, bool forceDraw); - void SetText(std::string const& text); - void ShowTooltipWithTipAt(int anchor_tip_x, int anchor_tip_y); // Introspection @@ -52,11 +52,15 @@ public: virtual nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type); -private: +protected: + // protected to simplify testing + nux::ObjectPtr<nux::StaticCairoText> _tooltip_text; + void RecvCairoTextChanged(nux::StaticCairoText* cairo_text); void PreLayoutManagement(); +private: long PostLayoutManagement(long layoutResult); void PositionChildLayout(float offsetX, @@ -69,9 +73,6 @@ private: int _anchorX; int _anchorY; - std::string _labelText; - - nux::ObjectPtr<nux::StaticCairoText> _tooltip_text; nux::HLayout* _hlayout; nux::VLayout* _vlayout; |
