2011-04-01 05:04:46 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2011-08-05 20:09:07 +00:00
|
|
|
*
|
2011-04-01 05:04:46 +00:00
|
|
|
* 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.
|
2011-08-05 20:09:07 +00:00
|
|
|
*
|
2011-04-01 05:04:46 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-06-23 00:52:59 +00:00
|
|
|
#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
|
|
|
|
#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
|
2011-04-01 12:01:53 +00:00
|
|
|
#include "common/scummsys.h"
|
|
|
|
|
2014-01-21 18:01:28 +00:00
|
|
|
#if defined(POSIX) && defined(USE_TASKBAR) && defined(USE_UNITY)
|
2011-04-01 05:04:46 +00:00
|
|
|
|
2014-10-06 14:23:24 +00:00
|
|
|
#define GLIB_DISABLE_DEPRECATION_WARNINGS
|
|
|
|
|
2011-04-01 05:04:46 +00:00
|
|
|
#include "backends/taskbar/unity/unity-taskbar.h"
|
|
|
|
|
|
|
|
#include "common/textconsole.h"
|
|
|
|
|
2011-06-23 00:52:59 +00:00
|
|
|
#include <unity.h>
|
|
|
|
|
2011-04-01 05:04:46 +00:00
|
|
|
UnityTaskbarManager::UnityTaskbarManager() {
|
2014-10-05 15:05:08 +00:00
|
|
|
/*
|
2014-10-06 14:23:24 +00:00
|
|
|
* Deprecated in Glib >= 2.36.0
|
2014-10-05 15:05:08 +00:00
|
|
|
*/
|
2014-10-06 14:29:37 +00:00
|
|
|
if (!glib_check_version(2, 36, 0)) {
|
|
|
|
g_type_init();
|
|
|
|
}
|
2011-04-01 12:01:53 +00:00
|
|
|
|
2011-04-04 16:35:19 +00:00
|
|
|
_loop = g_main_loop_new(NULL, FALSE);
|
|
|
|
|
|
|
|
_launcher = unity_launcher_entry_get_for_desktop_id("scummvm.desktop");
|
2011-04-01 05:04:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UnityTaskbarManager::~UnityTaskbarManager() {
|
2011-04-04 16:35:19 +00:00
|
|
|
g_main_loop_unref(_loop);
|
|
|
|
_loop = NULL;
|
2011-04-01 05:04:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void UnityTaskbarManager::setProgressValue(int completed, int total) {
|
2011-04-04 16:35:19 +00:00
|
|
|
if (_launcher == NULL)
|
|
|
|
return;
|
2011-04-01 12:01:53 +00:00
|
|
|
|
2011-04-04 16:35:19 +00:00
|
|
|
double percentage = (double)completed / (double)total;
|
|
|
|
unity_launcher_entry_set_progress(_launcher, percentage);
|
2011-04-01 12:01:53 +00:00
|
|
|
unity_launcher_entry_set_progress_visible(_launcher, TRUE);
|
2011-04-01 05:04:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void UnityTaskbarManager::setProgressState(TaskbarProgressState state) {
|
2011-04-01 12:01:53 +00:00
|
|
|
if (_launcher == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
default:
|
|
|
|
warning("[UnityTaskbarManager::setProgressState] Unknown state / Not implemented (%d)", state);
|
2020-06-07 14:39:15 +00:00
|
|
|
// fall through
|
2011-04-01 12:01:53 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2011-04-01 05:04:46 +00:00
|
|
|
}
|
|
|
|
|
2011-04-01 12:01:53 +00:00
|
|
|
void UnityTaskbarManager::addRecent(const Common::String &name, const Common::String &description) {
|
2011-04-01 05:04:46 +00:00
|
|
|
warning("[UnityTaskbarManager::addRecent] Not implemented");
|
|
|
|
}
|
|
|
|
|
2011-04-04 16:49:49 +00:00
|
|
|
void UnityTaskbarManager::setCount(int count) {
|
|
|
|
if (_launcher == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
unity_launcher_entry_set_count(_launcher, count);
|
|
|
|
|
|
|
|
unity_launcher_entry_set_count_visible(_launcher, (count == 0) ? FALSE : TRUE);
|
|
|
|
}
|
|
|
|
|
2011-04-04 16:35:19 +00:00
|
|
|
// Unity requires the glib event loop to the run to function properly
|
|
|
|
// as events are sent asynchronously
|
|
|
|
bool UnityTaskbarManager::pollEvent(Common::Event &event) {
|
|
|
|
if (!_loop)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Get context
|
|
|
|
GMainContext *context = g_main_loop_get_context(_loop);
|
|
|
|
if (!context)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Dispatch events
|
|
|
|
g_main_context_iteration(context, FALSE);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-04-01 05:04:46 +00:00
|
|
|
#endif
|