Commit 98603c5f authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

Begin implementing change tracking

parent a3774f10
......@@ -60,7 +60,7 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, GMenuSection &ite
QDBusArgument &operator<<(QDBusArgument &argument, const GMenuChange &item)
{
argument.beginStructure();
argument << item.id << item.count << item.changePosition << item.itemsToRemoveCount << item.itemsToInsert;
argument << item.subscription << item.menu << item.changePosition << item.itemsToRemoveCount << item.itemsToInsert;
argument.endStructure();
return argument;
}
......@@ -68,7 +68,7 @@ QDBusArgument &operator<<(QDBusArgument &argument, const GMenuChange &item)
const QDBusArgument &operator>>(const QDBusArgument &argument, GMenuChange &item)
{
argument.beginStructure();
argument >> item.id >> item.count >> item.changePosition >> item.itemsToRemoveCount >> item.itemsToInsert;
argument >> item.subscription >> item.menu >> item.changePosition >> item.itemsToRemoveCount >> item.itemsToInsert;
argument.endStructure();
return argument;
}
......
......@@ -59,8 +59,9 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, GMenuSection &ite
// Changes of a menu item (Changed signal)
struct GMenuChange
{
uint id;
uint count;
uint subscription;
uint menu;
uint changePosition;
uint itemsToRemoveCount;
VariantMapList itemsToInsert;
......@@ -92,8 +93,8 @@ struct GMenuActionsChange
{
QStringList removed;
QMap<QString, bool> enabledChanged;
QMap<QString, QVariant> stateChanged;
QList<GMenuAction> added;
QVariantMap stateChanged;
GMenuActionMap added;
};
Q_DECLARE_METATYPE(GMenuActionsChange);
......
......@@ -51,7 +51,6 @@ Menu::Menu(WId winId,
{
qDebug() << "Created menu on" << m_serviceName << "at" << m_applicationObjectPath << m_windowObjectPath << m_menuObjectPath;
GDBusMenuTypes_register();
DBusMenuTypes_register();
......@@ -66,15 +65,22 @@ Menu::Menu(WId winId,
}
if (!QDBusConnection::sessionBus().connect(m_serviceName,
m_windowObjectPath,
m_applicationObjectPath,
s_orgGtkActions,
QStringLiteral("Changed"),
this,
SLOT(onWindowActionsChanged(GMenuActionsChange)))) {
qWarning() << "Failed to subsribe to window action changes in" << m_serviceName << "at" << m_windowObjectPath;
SLOT(onApplicationActionsChanged(GMenuActionsChange)))) {
qWarning() << "Failed to subscribe to application action changes in" << m_serviceName << "at" << m_applicationObjectPath;
}
// TODO connect to application action changes
if (!QDBusConnection::sessionBus().connect(m_serviceName,
m_windowObjectPath,
s_orgGtkActions,
QStringLiteral("Changed"),
this,
SLOT(onWindowActionsChanged(GMenuActionsChange))) ){
qWarning() << "Failed to subscribe to window action changes in" << m_serviceName << "at" << m_windowObjectPath;
}
// TODO share application actions between menus of the same app?
getActions(m_applicationObjectPath, [this](const GMenuActionMap &actions, bool ok) {
......@@ -266,8 +272,16 @@ void Menu::stop(const QList<uint> &ids)
void Menu::onMenuChanged(const GMenuChangeList &changes)
{
// TODO
Q_UNUSED(changes);
qDebug() << "menu changed";
for (const auto &change : changes) {
qDebug() << change.subscription << change.menu << change.changePosition << change.itemsToRemoveCount << change.itemsToInsert;
}
}
void Menu::onApplicationActionsChanged(const GMenuActionsChange &changes)
{
qDebug() << "app actions changed";
qDebug() << changes.removed << changes.enabledChanged << changes.stateChanged << changes.added.count();
}
void Menu::onWindowActionsChanged(const GMenuActionsChange &changes)
......
......@@ -79,6 +79,7 @@ signals:
private slots:
void onMenuChanged(const GMenuChangeList &changes);
void onApplicationActionsChanged(const GMenuActionsChange &changes);
void onWindowActionsChanged(const GMenuActionsChange &changes);
private:
......
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