2
* Copyright (C) 2016 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
25
extern const CCSInterfaceTable ccsDefaultInterfaceTable;
27
void PluginSetActiveWithDeps(CCSContext* context, std::string const& plugin_name)
29
if (plugin_name.empty())
32
auto plugin = ccsFindPlugin(context, plugin_name.c_str());
37
auto reqs = ccsPluginGetRequiresPlugins(plugin);
38
for (auto req = reqs; req; req = req->next)
40
if (req->data && req->data->value)
42
std::string name = req->data->value;
43
PluginSetActiveWithDeps(context, name.c_str());
47
if (!ccsPluginIsActive(context, plugin_name.c_str())) {
48
std::cout << "Setting plugin '" << plugin_name << "' to active" << std::endl;
49
ccsPluginSetActive(plugin, true);
52
auto conflicts = ccsPluginGetConflictPlugins(plugin);
53
for (auto con = conflicts; con; con = con->next)
55
if (con->data && con->data->value)
57
std::string name = con->data->value;
58
auto plugin = ccsFindPlugin(context, name.c_str());
60
if (ccsPluginIsActive(context, name.c_str()))
62
std::cout << "Setting plugin '" << name << "' to non-active" << std::endl;
63
ccsPluginSetActive(plugin, false);
71
auto context = ccsContextNew (0, &ccsDefaultInterfaceTable);
76
PluginSetActiveWithDeps(context, "unityshell");
78
ccsWriteChangedSettings(context);
80
ccsFreeContext(context);