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 glib::{prelude::*,translate::*};
use std::{fmt};

glib::wrapper! {
    #[doc(alias = "DbusmenuGtkClient")]
    pub struct Client(Object<ffi::DbusmenuGtkClient, ffi::DbusmenuGtkClientClass>) @extends dbusmenu_glib::Client;

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

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

    /// Creates a new [`Client`][crate::Client] 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 [`Client`][crate::Client] sync'd with a server
    #[doc(alias = "dbusmenu_gtkclient_new")]
    pub fn new(dbus_name: &str, dbus_object: &str) -> Client {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::dbusmenu_gtkclient_new(dbus_name.to_glib_none().0, dbus_object.to_glib_none().0))
        }
    }
}

/// Trait containing all [`struct@Client`] methods.
///
/// # Implementors
///
/// [`Client`][struct@crate::Client]
pub trait ClientExt: 'static {
    /// Gets the accel group for this client.
    ///
    /// # Returns
    ///
    /// Either a valid group or [`None`] on error or
    ///     none set.
    #[doc(alias = "dbusmenu_gtkclient_get_accel_group")]
    #[doc(alias = "get_accel_group")]
    fn accel_group(&self) -> Option<gtk::AccelGroup>;

    /// This grabs the [`gtk::MenuItem`][crate::gtk::MenuItem] that is associated with the
    /// [`dbusmenu_glib::Menuitem`][crate::dbusmenu_glib::Menuitem].
    /// ## `item`
    /// [`dbusmenu_glib::Menuitem`][crate::dbusmenu_glib::Menuitem] to get associated [`gtk::MenuItem`][crate::gtk::MenuItem] on.
    ///
    /// # Returns
    ///
    /// The [`gtk::MenuItem`][crate::gtk::MenuItem] that can be played with.
    #[doc(alias = "dbusmenu_gtkclient_menuitem_get")]
    fn menuitem_get(&self, item: &impl IsA<dbusmenu_glib::Menuitem>) -> Option<gtk::MenuItem>;

    /// This grabs the submenu associated with the menuitem.
    /// ## `item`
    /// [`dbusmenu_glib::Menuitem`][crate::dbusmenu_glib::Menuitem] to get associated [`gtk::Menu`][crate::gtk::Menu] on.
    ///
    /// # Returns
    ///
    /// The [`gtk::Menu`][crate::gtk::Menu] if there is one.
    #[doc(alias = "dbusmenu_gtkclient_menuitem_get_submenu")]
    fn menuitem_get_submenu(&self, item: &impl IsA<dbusmenu_glib::Menuitem>) -> Option<gtk::Menu>;

    /// This function provides some of the basic connectivity for being in
    /// the GTK world. Things like visibility and sensitivity of the item are
    /// handled here so that the subclasses don't have to. If you're building
    /// your on GTK menu item you can use this function to apply those basic
    /// attributes so that you don't have to deal with them either.
    ///
    /// This also handles passing the "activate" signal back to the
    /// [`dbusmenu_glib::Menuitem`][crate::dbusmenu_glib::Menuitem] side of thing.
    /// ## `item`
    /// The [`dbusmenu_glib::Menuitem`][crate::dbusmenu_glib::Menuitem] to attach the GTK-isms to
    /// ## `gmi`
    /// A [`gtk::MenuItem`][crate::gtk::MenuItem] representing the GTK world's view of this menuitem
    /// ## `parent`
    /// The parent [`dbusmenu_glib::Menuitem`][crate::dbusmenu_glib::Menuitem]
    #[doc(alias = "dbusmenu_gtkclient_newitem_base")]
    fn newitem_base(&self, item: &impl IsA<dbusmenu_glib::Menuitem>, gmi: &impl IsA<gtk::MenuItem>, parent: Option<&impl IsA<dbusmenu_glib::Menuitem>>);

    /// Sets the acceleration group for the menu items with accelerators
    /// on this client.
    /// ## `agroup`
    /// The new acceleration group
    #[doc(alias = "dbusmenu_gtkclient_set_accel_group")]
    fn set_accel_group(&self, agroup: &impl IsA<gtk::AccelGroup>);
}

impl<O: IsA<Client>> ClientExt for O {
    fn accel_group(&self) -> Option<gtk::AccelGroup> {
        unsafe {
            from_glib_none(ffi::dbusmenu_gtkclient_get_accel_group(self.as_ref().to_glib_none().0))
        }
    }

    fn menuitem_get(&self, item: &impl IsA<dbusmenu_glib::Menuitem>) -> Option<gtk::MenuItem> {
        unsafe {
            from_glib_none(ffi::dbusmenu_gtkclient_menuitem_get(self.as_ref().to_glib_none().0, item.as_ref().to_glib_none().0))
        }
    }

    fn menuitem_get_submenu(&self, item: &impl IsA<dbusmenu_glib::Menuitem>) -> Option<gtk::Menu> {
        unsafe {
            from_glib_none(ffi::dbusmenu_gtkclient_menuitem_get_submenu(self.as_ref().to_glib_none().0, item.as_ref().to_glib_none().0))
        }
    }

    fn newitem_base(&self, item: &impl IsA<dbusmenu_glib::Menuitem>, gmi: &impl IsA<gtk::MenuItem>, parent: Option<&impl IsA<dbusmenu_glib::Menuitem>>) {
        unsafe {
            ffi::dbusmenu_gtkclient_newitem_base(self.as_ref().to_glib_none().0, item.as_ref().to_glib_none().0, gmi.as_ref().to_glib_none().0, parent.map(|p| p.as_ref()).to_glib_none().0);
        }
    }

    fn set_accel_group(&self, agroup: &impl IsA<gtk::AccelGroup>) {
        unsafe {
            ffi::dbusmenu_gtkclient_set_accel_group(self.as_ref().to_glib_none().0, agroup.as_ref().to_glib_none().0);
        }
    }
}

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