mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 20:45:32 +00:00
nmtui: add NOT_EMPTY flag to NmtPasswordFields
Add a new flag to return a NULL string when the password is empty. This is needed when creating the binding to some properties that don't accept an empty value.
This commit is contained in:
parent
729d00249e
commit
7f5f2eefca
|
@ -47,6 +47,7 @@ enum {
|
|||
* NmtPasswordFieldsExtras:
|
||||
* @NMT_PASSWORD_FIELDS_ALWAYS_ASK: show an "Always ask" checkbox
|
||||
* @NMT_PASSWORD_FIELDS_SHOW_PASSWORD: show a "Show password" checkbox
|
||||
* @NMT_PASSWORD_FIELDS_NOT_EMPTY: return NULL instead of empty string
|
||||
*
|
||||
* Extra widgets to include in an #NmtPasswordFields
|
||||
*/
|
||||
|
@ -82,8 +83,13 @@ static const char *
|
|||
nmt_password_fields_get_password(NmtPasswordFields *fields)
|
||||
{
|
||||
NmtPasswordFieldsPrivate *priv = NMT_PASSWORD_FIELDS_GET_PRIVATE(fields);
|
||||
const char *text;
|
||||
|
||||
return nmt_newt_entry_get_text(priv->entry);
|
||||
text = nmt_newt_entry_get_text(priv->entry);
|
||||
if (priv->extras & NMT_PASSWORD_FIELDS_NOT_EMPTY)
|
||||
return nm_str_not_empty(text);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -34,6 +34,7 @@ GType nmt_password_fields_get_type(void);
|
|||
typedef enum {
|
||||
NMT_PASSWORD_FIELDS_ALWAYS_ASK = (1 << 0),
|
||||
NMT_PASSWORD_FIELDS_SHOW_PASSWORD = (1 << 1),
|
||||
NMT_PASSWORD_FIELDS_NOT_EMPTY = (1 << 2), /* Return NULL instead of empty string */
|
||||
} NmtPasswordFieldsExtras;
|
||||
|
||||
NmtNewtWidget *nmt_password_fields_new(int width, NmtPasswordFieldsExtras extras);
|
||||
|
|
Loading…
Reference in a new issue