dbusmenu-gtk3 0.1.0

Rust bindings to dbusmenu-gtk3
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from /nix/store/39vgdpiqy94qwa8rraha7q4wcd8hdwcj-dbusmenu-gtk3-gir
// from /nix/store/ahri9v0b3c1jyls6691sjfzf2s461fzz-source
// DO NOT EDIT

use crate::{Client};
use glib::{prelude::*,translate::*};
use std::{fmt};

glib::wrapper! {
    #[doc(alias = "DbusmenuGtkMenu")]
    pub struct Menu(Object<ffi::DbusmenuGtkMenu, ffi::DbusmenuGtkMenuClass>) @extends gtk::Menu, gtk::MenuShell, gtk::Container, gtk::Widget, glib::object::InitiallyUnowned, @implements gtk::Buildable;

    match fn {
        type_ => || ffi::dbusmenu_gtkmenu_get_type(),
    }
}

impl Menu {
        pub const NONE: Option<&'static Menu> = None;
    

    /// Creates a new [`Menu`][crate::Menu] object and creates a [`dbusmenu_glib::Client`][crate::dbusmenu_glib::Client]
    /// that connects across DBus to a `DbusmenuServer`.
    /// ## `dbus_name`
    /// Name of the `DbusmenuServer` on DBus
    /// ## `dbus_object`
    /// Name of the object on the `DbusmenuServer`
    ///
    /// # Returns
    ///
    /// A new [`Menu`][crate::Menu] sync'd with a server
    #[doc(alias = "dbusmenu_gtkmenu_new")]
    pub fn new(dbus_name: &str, dbus_object: &str) -> Menu {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_none(ffi::dbusmenu_gtkmenu_new(dbus_name.to_glib_none().0, dbus_object.to_glib_none().0))
        }
    }
}

/// Trait containing all [`struct@Menu`] methods.
///
/// # Implementors
///
/// [`Menu`][struct@crate::Menu]
pub trait MenuExt: 'static {
    /// An accessor for the client that this menu is using to
    /// communicate with the server.
    ///
    /// # Returns
    ///
    /// A valid [`Client`][crate::Client] or NULL on error.
    #[doc(alias = "dbusmenu_gtkmenu_get_client")]
    #[doc(alias = "get_client")]
    fn client(&self) -> Option<Client>;

    #[doc(alias = "dbus-name")]
    fn dbus_name(&self) -> Option<glib::GString>;

    #[doc(alias = "dbus-object")]
    fn dbus_object(&self) -> Option<glib::GString>;
}

impl<O: IsA<Menu>> MenuExt for O {
    fn client(&self) -> Option<Client> {
        unsafe {
            from_glib_none(ffi::dbusmenu_gtkmenu_get_client(self.as_ref().to_glib_none().0))
        }
    }

    fn dbus_name(&self) -> Option<glib::GString> {
        glib::ObjectExt::property(self.as_ref(), "dbus-name")
    }

    fn dbus_object(&self) -> Option<glib::GString> {
        glib::ObjectExt::property(self.as_ref(), "dbus-object")
    }
}

impl fmt::Display for Menu {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("Menu")
    }
}