appmenu-glib-translator 0.1.0

Rust bindings for the appmenu-glib-translator library.
docs.rs failed to build appmenu-glib-translator-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

Appmenu GLib translator

Rust bindings for the appmenu-glib-translator library.

This library makes it possible to create GLib app menus for StatusNotifierWatcher implementations.

Usage

This example shows how this library makes it possible to create tray menus.

use appmenu_glib_translator::{Importer, prelude::ImporterExtManual};

pub struct TrayItem {
    menu_path: String,
    bus_name: String,
    icon_name: String
}

fn append_tray_item(container: &gtk4::Box, item: TrayItem) {
    let importer = Importer::builder()
        .bus_name(item.bus_name.as_str())
        .object_path(item.menu_path.as_str())
        .build();

    let button = gtk4::MenuButton::builder()
        .icon_name(item.icon_name.as_str())
        .build();

    if let Some(ref menumodel) = importer.menu_model() {
        button.set_menu_model(Some(menumodel));
    }

    if let Some(ref action_group) = importer.action_group() {
        button.set_action_group(Some(action_group));
    }

    container.append(&button);
}

Dependencies

References