#libappindicator #sni #api-bindings #ksni #appindicator #ayatana-appindicator

appindicator3

Rust bindings for the AppIndicator and AyatanaAppIndicator library

6 releases

0.3.0 Aug 29, 2023
0.2.3 Nov 30, 2022
0.2.2 Mar 19, 2022
0.1.0 Mar 18, 2022

#263 in GUI

24 downloads per month

MIT license

75KB
1K SLoC

appindicator3-rs

LGPL-2.1 licensed

Rust bindings for the AppIndicator and AyatanaAppIndicator library.

Ayatana Application Indicator Library

Allows applications to export a menu into the an Application Indicators aware menu bar. Based on KSNI it also works in KDE and will fallback to generic Systray support if none of those are available.

Usage

Add the following to your Cargo.toml:

[dependencies]
appindicator3 = "0.2.0"

By default appindicator3-rs links against the libayatana-appindicator3 library. To link against the original libappindicator3 library enable the original feature:

[dependencies]
appindicator3 = { version = "0.2.0", feature = ["original", "v0_5"] }

Dependencies

You will need the development packages for libayatana-appindicator3 to compile against this crate.

Debian/Ubuntu:

sudo apt install libayatana-appindicator3-dev

openSUSE:

sudo zypper install libayatana-appindicator3-devel
# or for feature = ["original"]
sudo zypper install libappindicator3-devel 

Example Program

use appindicator3::{prelude::*, IndicatorStatus};
use appindicator3::{Indicator, IndicatorCategory};
use gtk::prelude::*;

fn main() {
    gtk::init().unwrap();

    let m = gtk::Menu::new();
    let mi = gtk::MenuItem::with_label("Hello World");
    mi.connect_activate(|_| {
        gtk::main_quit();
    });
    m.add(&mi);
    mi.show_all();

    let _indicator = Indicator::builder("Example")
        .category(IndicatorCategory::ApplicationStatus)
        .menu(&m)
        .icon("face-smile", "icon")
        .status(IndicatorStatus::Active)
        .build();

    gtk::main();
}

Additonal examples can be found in examples.

Bindings

A large portion of the bindings is auto generated by GObject Introspection and gir using this configuration file.

More details on how to use gir can be found here.

License

appindicator3-rs is available under the MIT License. Please refer to the LICENSE file. This project provides bindings to the Application Indicator library but doesn't distribute any parts of it. Distributing compiled libraries and executable that link to this library may be subject to other licenses.

Dependencies

~17MB
~404K SLoC