using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Tmds.DBus; [assembly: InternalsVisibleTo(Tmds.DBus.Connection.DynamicAssemblyName)] namespace Avalonia.FreeDesktop.DBusMenu { [DBusInterface("org.freedesktop.DBus.Properties")] interface IFreeDesktopDBusProperties : IDBusObject { Task GetAsync(string prop); Task GetAllAsync(); Task SetAsync(string prop, object val); Task WatchPropertiesAsync(Action handler); } [DBusInterface("com.canonical.dbusmenu")] interface IDBusMenu : IFreeDesktopDBusProperties { Task<(uint revision, (int, KeyValuePair[], object[]) layout)> GetLayoutAsync(int ParentId, int RecursionDepth, string[] PropertyNames); Task<(int, KeyValuePair[])[]> GetGroupPropertiesAsync(int[] Ids, string[] PropertyNames); Task GetPropertyAsync(int Id, string Name); Task EventAsync(int Id, string EventId, object Data, uint Timestamp); Task EventGroupAsync((int id, string eventId, object data, uint timestamp)[] events); Task AboutToShowAsync(int Id); Task<(int[] updatesNeeded, int[] idErrors)> AboutToShowGroupAsync(int[] Ids); Task WatchItemsPropertiesUpdatedAsync(Action<((int, IDictionary)[] updatedProps, (int, string[])[] removedProps)> handler, Action onError = null); Task WatchLayoutUpdatedAsync(Action<(uint revision, int parent)> handler, Action onError = null); Task WatchItemActivationRequestedAsync(Action<(int id, uint timestamp)> handler, Action onError = null); } [Dictionary] class DBusMenuProperties { public uint Version { get; set; } = default (uint); public string TextDirection { get; set; } = default (string); public string Status { get; set; } = default (string); public string[] IconThemePath { get; set; } = default (string[]); } [DBusInterface("com.canonical.AppMenu.Registrar")] interface IRegistrar : IDBusObject { Task RegisterWindowAsync(uint WindowId, ObjectPath MenuObjectPath); Task UnregisterWindowAsync(uint WindowId); Task<(string service, ObjectPath menuObjectPath)> GetMenuForWindowAsync(uint WindowId); Task<(uint, string, ObjectPath)[]> GetMenusAsync(); Task WatchWindowRegisteredAsync(Action<(uint windowId, string service, ObjectPath menuObjectPath)> handler, Action onError = null); Task WatchWindowUnregisteredAsync(Action handler, Action onError = null); } }