Commit 71d77a76 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

The variant list in an action describes its state, this isn't arguments to pass for activation

Fixes toggle actions like full screen not working in gedit
parent b6b29242
......@@ -77,7 +77,7 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, GMenuChange &item
QDBusArgument &operator<<(QDBusArgument &argument, const GMenuAction &item)
{
argument.beginStructure();
argument << item.enabled << item.signature << item.arguments;
argument << item.enabled << item.signature << item.state;
argument.endStructure();
return argument;
}
......@@ -85,7 +85,7 @@ QDBusArgument &operator<<(QDBusArgument &argument, const GMenuAction &item)
const QDBusArgument &operator>>(const QDBusArgument &argument, GMenuAction &item)
{
argument.beginStructure();
argument >> item.enabled >> item.signature >> item.arguments;
argument >> item.enabled >> item.signature >> item.state;
argument.endStructure();
return argument;
}
......
......@@ -75,7 +75,7 @@ struct GMenuAction
{
bool enabled;
QDBusSignature signature;
QVariantList arguments;
QVariantList state;
};
Q_DECLARE_METATYPE(GMenuAction);
......
......@@ -350,17 +350,8 @@ void Menu::triggerAction(const QString &name)
s_orgGtkActions,
QStringLiteral("Activate"));
msg << lookupName;
// It seems to be our responsibility to invoke the correct argument.
// If the action has a "true" argument it means it's checked and we need to toggle it ourselves.
// FIXME doesn't work, though
// Docs also mention a "target" property on the menu item that contains stuff we should send along
// when invoking the action but that stuff works even without o.O
if (action.arguments.count() == 1 && action.arguments.constFirst().canConvert<bool>()) {
msg << QVariantList{!action.arguments.constFirst().toBool()};
} else {
msg << QVariant::fromValue(action.arguments);
}
// TODO use the arguments provided by "target" in the menu item
msg << QVariant::fromValue(QVariantList());
QVariantMap platformData;
msg << platformData;
......@@ -706,15 +697,13 @@ QVariantMap Menu::gMenuToDBusMenuProperties(const QVariantMap &source) const
result.insert(QStringLiteral("icon-name"), icon);
}
bool isCheckBox = false;
if (actionOk) {
const auto args = action.arguments;
const auto args = action.state;
if (args.count() == 1) {
const auto &firstArg = args.first();
// assume this is a checkbox
if (firstArg.canConvert<bool>() && !isMenu) {
result.insert(QStringLiteral("toggle-type"), QStringLiteral("checkbox"));
isCheckBox = true;
if (firstArg.toBool()) {
result.insert(QStringLiteral("toggle-state"), 1);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment