From 984e1968bce3b4a23833719653a5d5751e5c8a04 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Fri, 1 Apr 2011 08:01:53 -0400 Subject: BACKENDS: Add WIP Unity support --- backends/taskbar/unity/unity-taskbar.cpp | 43 +++++++++++++++++++++++++++----- backends/taskbar/unity/unity-taskbar.h | 7 ++++-- 2 files changed, 42 insertions(+), 8 deletions(-) (limited to 'backends/taskbar/unity') diff --git a/backends/taskbar/unity/unity-taskbar.cpp b/backends/taskbar/unity/unity-taskbar.cpp index 4a074abca2..6c18f0940c 100644 --- a/backends/taskbar/unity/unity-taskbar.cpp +++ b/backends/taskbar/unity/unity-taskbar.cpp @@ -23,33 +23,64 @@ * */ +#include "common/scummsys.h" + #if defined(UNIX) && defined(USE_TASKBAR) #include "backends/taskbar/unity/unity-taskbar.h" -#include "common/config-manager.h" #include "common/textconsole.h" -#include "common/file.h" UnityTaskbarManager::UnityTaskbarManager() { + g_type_init(); + + _launcher = unity_launcher_entry_get_for_desktop_id("scummvm.desktop"); } UnityTaskbarManager::~UnityTaskbarManager() { } -void UnityTaskbarManager::setOverlayIcon(Common::String name, Common::String description) { +void UnityTaskbarManager::setOverlayIcon(const Common::String &name, const Common::String &description) { + if (_launcher == NULL) + return; + warning("[UnityTaskbarManager::setOverlayIcon] Not implemented"); } void UnityTaskbarManager::setProgressValue(int completed, int total) { - warning("[UnityTaskbarManager::setProgressValue] Not implemented"); + if (_launcher == NULL) + return; + + double percentage = (double)completed / (double)total; + unity_launcher_entry_set_progress(_launcher, percentage); + unity_launcher_entry_set_progress_visible(_launcher, TRUE); } void UnityTaskbarManager::setProgressState(TaskbarProgressState state) { - warning("[UnityTaskbarManager::setProgressState] Not implemented"); + if (_launcher == NULL) + return; + + switch (state) { + default: + warning("[UnityTaskbarManager::setProgressState] Unknown state / Not implemented (%d)", state); + // fallback to noprogress state + + case kTaskbarNoProgress: + unity_launcher_entry_set_progress_visible(_launcher, FALSE); + break; + + // Unity only support two progress states as of 3.0: visible or not visible + // We show progress in all of those states + case kTaskbarIndeterminate: + case kTaskbarNormal: + case kTaskbarError: + case kTaskbarPaused: + unity_launcher_entry_set_progress_visible(_launcher, TRUE); + break; + } } -void UnityTaskbarManager::addRecent(Common::String name, Common::String description) { +void UnityTaskbarManager::addRecent(const Common::String &name, const Common::String &description) { warning("[UnityTaskbarManager::addRecent] Not implemented"); } diff --git a/backends/taskbar/unity/unity-taskbar.h b/backends/taskbar/unity/unity-taskbar.h index cd8efdaf2a..0d0484c02e 100644 --- a/backends/taskbar/unity/unity-taskbar.h +++ b/backends/taskbar/unity/unity-taskbar.h @@ -31,17 +31,20 @@ #include "common/str.h" #include "common/taskbar.h" +#include + class UnityTaskbarManager : public Common::TaskbarManager { public: UnityTaskbarManager(); virtual ~UnityTaskbarManager(); - virtual void setOverlayIcon(Common::String name, Common::String description); + virtual void setOverlayIcon(const Common::String &name, const Common::String &description); virtual void setProgressValue(int completed, int total); virtual void setProgressState(TaskbarProgressState state); - virtual void addRecent(Common::String name, Common::String description); + virtual void addRecent(const Common::String &name, const Common::String &description); private: + UnityLauncherEntry *_launcher; }; #endif -- cgit v1.2.3