nma4 0.1.2

Rust bindings for the libnma library.
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from girs
// from gtk-girs (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{ffi};
use glib::{prelude::*,translate::*};


/// Splits the input MCCMNC string into separate MCC and MNC strings.
/// ## `mccmnc`
/// input MCCMNC string.
///
/// # Returns
///
/// [`true`] if correctly split and @mcc and @mnc are set; [`false`] otherwise.
///
/// ## `mcc`
/// the MCC.
///
/// ## `mnc`
/// the MNC.
#[doc(alias = "nma_mobile_providers_split_3gpp_mcc_mnc")]
pub fn mobile_providers_split_3gpp_mcc_mnc(mccmnc: &str) -> Option<(glib::GString, glib::GString)> {
    assert_initialized_main_thread!();
    unsafe {
        let mut mcc = std::ptr::null_mut();
        let mut mnc = std::ptr::null_mut();
        let ret = from_glib(ffi::nma_mobile_providers_split_3gpp_mcc_mnc(mccmnc.to_glib_none().0, &mut mcc, &mut mnc));
        if ret { Some((from_glib_full(mcc), from_glib_full(mnc))) } else { None }
    }
}

/// Returns secret flags corresponding to the selected password storage menu
/// in the attached icon
/// ## `passwd_entry`
/// password #GtkEntry which the password icon/menu is attached to
///
/// # Returns
///
/// secret flags corresponding to the active item in password menu
#[doc(alias = "nma_utils_menu_to_secret_flags")]
pub fn utils_menu_to_secret_flags(passwd_entry: &impl IsA<gtk::Widget>) -> nm::SettingSecretFlags {
    assert_initialized_main_thread!();
    unsafe {
        from_glib(ffi::nma_utils_menu_to_secret_flags(passwd_entry.as_ref().to_glib_none().0))
    }
}

/// Adds a secondary icon and creates a popup menu for password entry.
/// The active menu item is set up according to initial_flags, or
/// from @setting/@password_flags_name (if they are not NULL).
/// If the @setting/@password_flags_name are not NULL, secret flags will
/// be automatically updated in the setting when menu is changed.
/// ## `passwd_entry`
/// password #GtkEntry which the icon is attached to
/// ## `initial_flags`
/// initial secret flags to setup password menu from
/// ## `setting`
/// #NMSetting containing the password, or NULL
/// ## `password_flags_name`
/// name of the secret flags (like psk-flags), or NULL
/// ## `with_not_required`
/// whether to include "Not required" menu item
/// ## `ask_mode`
/// [`true`] if the entry is shown in ASK mode. That means,
///   while prompting for a password, contrary to being inside the
///   editor mode.
///   If [`true`], the entry should be sensivive on selected "always-ask"
///   icon (this is e.f. for nm-applet asking for password), otherwise
///   not.
///   If [`false`], it shall not be possible to select a different storage,
///   because we only prompt for a password, we cannot change the password
///   location.
#[doc(alias = "nma_utils_setup_password_storage")]
pub fn utils_setup_password_storage(passwd_entry: &impl IsA<gtk::Widget>, initial_flags: nm::SettingSecretFlags, setting: &impl IsA<nm::Setting>, password_flags_name: &str, with_not_required: bool, ask_mode: bool) {
    assert_initialized_main_thread!();
    unsafe {
        ffi::nma_utils_setup_password_storage(passwd_entry.as_ref().to_glib_none().0, initial_flags.into_glib(), setting.as_ref().to_glib_none().0, password_flags_name.to_glib_none().0, with_not_required.into_glib(), ask_mode.into_glib());
    }
}

/// Updates secret flags in the password storage popup menu and also
/// in the @setting (if @setting and @password_flags_name are not NULL).
/// ## `passwd_entry`
/// #GtkEntry with the password
/// ## `secret_flags`
/// secret flags to set
/// ## `setting`
/// #NMSetting containing the password, or NULL
/// ## `password_flags_name`
/// name of the secret flags (like psk-flags), or NULL
#[doc(alias = "nma_utils_update_password_storage")]
pub fn utils_update_password_storage(passwd_entry: &impl IsA<gtk::Widget>, secret_flags: nm::SettingSecretFlags, setting: &impl IsA<nm::Setting>, password_flags_name: &str) {
    assert_initialized_main_thread!();
    unsafe {
        ffi::nma_utils_update_password_storage(passwd_entry.as_ref().to_glib_none().0, secret_flags.into_glib(), setting.as_ref().to_glib_none().0, password_flags_name.to_glib_none().0);
    }
}