diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:13:13 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:13:13 +0200 |
commit | 7f23ee90fd545995a29e2175f15e8b97e59ca67a (patch) | |
tree | f8d0afac51995032e58b9a475ccbbc73ba207baf /shared/taskbar.cpp | |
parent | 3.19 (diff) | |
download | FreeFileSync-7f23ee90fd545995a29e2175f15e8b97e59ca67a.tar.gz FreeFileSync-7f23ee90fd545995a29e2175f15e8b97e59ca67a.tar.bz2 FreeFileSync-7f23ee90fd545995a29e2175f15e8b97e59ca67a.zip |
3.20
Diffstat (limited to 'shared/taskbar.cpp')
-rw-r--r-- | shared/taskbar.cpp | 106 |
1 files changed, 84 insertions, 22 deletions
diff --git a/shared/taskbar.cpp b/shared/taskbar.cpp index 969f4bb0..005df705 100644 --- a/shared/taskbar.cpp +++ b/shared/taskbar.cpp @@ -5,16 +5,24 @@ // ************************************************************************** // #include "taskbar.h" + +#ifdef FFS_WIN #include "Taskbar_Seven/taskbar.h" #include "dll_loader.h" #include "build_info.h" #include "assert_static.h" #include <wx/msw/wrapwin.h> //includes "windows.h" +#elif defined HAVE_UBUNTU_UNITY +#include <unity/unity/unity.h> +#endif + using namespace util; -using namespace tbseven; +#ifdef FFS_WIN +using namespace tbseven; + namespace { bool windows7TaskbarAvailable() @@ -45,7 +53,7 @@ std::wstring getTaskBarDllName() //######################################################################################################## -class TaskbarProgress::Pimpl //throw (TaskbarNotAvailable) +class Taskbar::Pimpl //throw (TaskbarNotAvailable) { public: Pimpl(const wxTopLevelWindow& window) : @@ -60,29 +68,26 @@ public: throw TaskbarNotAvailable(); } - ~Pimpl() - { - setStatus(STATUS_NOPROGRESS); - } + ~Pimpl() { setStatus(STATUS_NOPROGRESS); } void setStatus(Status status) { TaskBarStatus tbSevenStatus = tbseven::STATUS_NORMAL; switch (status) { - case TaskbarProgress::STATUS_NOPROGRESS: + case Taskbar::STATUS_NOPROGRESS: tbSevenStatus = tbseven::STATUS_NOPROGRESS; break; - case TaskbarProgress::STATUS_INDETERMINATE: + case Taskbar::STATUS_INDETERMINATE: tbSevenStatus = tbseven::STATUS_INDETERMINATE; break; - case TaskbarProgress::STATUS_NORMAL: + case Taskbar::STATUS_NORMAL: tbSevenStatus = tbseven::STATUS_NORMAL; break; - case TaskbarProgress::STATUS_ERROR: + case Taskbar::STATUS_ERROR: tbSevenStatus = tbseven::STATUS_ERROR; break; - case TaskbarProgress::STATUS_PAUSED: + case Taskbar::STATUS_PAUSED: tbSevenStatus = tbseven::STATUS_PAUSED; break; } @@ -96,23 +101,80 @@ public: } private: - void* assocWindow; + void* assocWindow; //HWND const SetStatusFct setStatus_; const SetProgressFct setProgress_; }; -//######################################################################################################## +#elif defined HAVE_UBUNTU_UNITY //Ubuntu unity +namespace +{ +const char FFS_DESKTOP_FILE[] = "freefilesync.desktop"; +} -TaskbarProgress::TaskbarProgress(const wxTopLevelWindow& window) : pimpl_(new Pimpl(window)) {} +class Taskbar::Pimpl //throw (TaskbarNotAvailable) +{ +public: + Pimpl(const wxTopLevelWindow& window) : + tbEntry(unity_launcher_entry_get_for_desktop_id(FFS_DESKTOP_FILE)) + //tbEntry(unity_launcher_entry_get_for_app_uri("application://freefilesync.desktop")) + { + if (!tbEntry) + throw TaskbarNotAvailable(); + } -TaskbarProgress::~TaskbarProgress() {} //std::unique_ptr ... + ~Pimpl() { setStatus(STATUS_NOPROGRESS); } //it seems UnityLauncherEntry* does not need destruction -void TaskbarProgress::setStatus(Status status) -{ - pimpl_->setStatus(status); -} + void setStatus(Status status) + { + switch (status) + { + case Taskbar::STATUS_ERROR: + unity_launcher_entry_set_urgent(tbEntry, true); + break; -void TaskbarProgress::setProgress(size_t current, size_t total) + case Taskbar::STATUS_NOPROGRESS: + case Taskbar::STATUS_INDETERMINATE: + unity_launcher_entry_set_urgent(tbEntry, false); + unity_launcher_entry_set_progress_visible(tbEntry, false); + break; + + case Taskbar::STATUS_NORMAL: + unity_launcher_entry_set_urgent(tbEntry, false); + unity_launcher_entry_set_progress_visible(tbEntry, true); + break; + + case Taskbar::STATUS_PAUSED: + unity_launcher_entry_set_urgent (tbEntry, false); + break; + } + } + + void setProgress(size_t current, size_t total) + { + unity_launcher_entry_set_progress(tbEntry, total == 0 ? 0 : double(current) / total); + } + +private: + UnityLauncherEntry* tbEntry; +}; + + +#else //no taskbar support yet +class Taskbar::Pimpl { - pimpl_->setProgress(current, total); -} +public: + Pimpl(const wxTopLevelWindow& window) { throw TaskbarNotAvailable(); } + void setStatus(Status status) {} + void setProgress(size_t current, size_t total) {} + +}; +#endif + + +//######################################################################################################## +Taskbar::Taskbar(const wxTopLevelWindow& window) : pimpl_(new Pimpl(window)) {} //throw TaskbarNotAvailable +Taskbar::~Taskbar() {} //std::unique_ptr ... + +void Taskbar::setStatus(Status status) { pimpl_->setStatus(status); } +void Taskbar::setProgress(size_t current, size_t total) { pimpl_->setProgress(current, total); } |