Blame clients/tui/newt/nmt-newt-entry.c

Packit Service 87a54e
/* SPDX-License-Identifier: GPL-2.0-or-later */
Packit 5756e2
/*
Packit 5756e2
 * Copyright (C) 2013 Red Hat, Inc.
Packit 5756e2
 */
Packit 5756e2
Packit 5756e2
/**
Packit 5756e2
 * SECTION:nmt-newt-entry
Packit 5756e2
 * @short_description: Text entries
Packit 5756e2
 *
Packit 5756e2
 * #NmtNewtEntry implements entry widgets, with optional filtering and
Packit 5756e2
 * validation.
Packit 5756e2
 *
Packit 5756e2
 * See also #NmtNewtEntryNumeric, for numeric-only entries.
Packit 5756e2
 */
Packit 5756e2
Packit Service 2bceb2
#include "libnm/nm-default-client.h"
Packit 5756e2
Packit 5756e2
#include "nmt-newt-entry.h"
Packit 5756e2
#include "nmt-newt-form.h"
Packit 5756e2
#include "nmt-newt-hacks.h"
Packit 5756e2
#include "nmt-newt-utils.h"
Packit 5756e2
Packit Service a1bd4f
G_DEFINE_TYPE(NmtNewtEntry, nmt_newt_entry, NMT_TYPE_NEWT_COMPONENT)
Packit 5756e2
Packit Service a1bd4f
#define NMT_NEWT_ENTRY_GET_PRIVATE(o) \
Packit Service a1bd4f
    (G_TYPE_INSTANCE_GET_PRIVATE((o), NMT_TYPE_NEWT_ENTRY, NmtNewtEntryPrivate))
Packit 5756e2
Packit 5756e2
typedef struct {
Packit Service a1bd4f
    int               width;
Packit Service a1bd4f
    NmtNewtEntryFlags flags;
Packit Service a1bd4f
    char *            text;
Packit Service a1bd4f
    int               last_cursor_pos;
Packit Service a1bd4f
    guint             idle_update;
Packit 5756e2
Packit Service a1bd4f
    NmtNewtEntryFilter filter;
Packit Service a1bd4f
    gpointer           filter_data;
Packit 5756e2
Packit Service a1bd4f
    NmtNewtEntryValidator validator;
Packit Service a1bd4f
    gpointer              validator_data;
Packit 5756e2
} NmtNewtEntryPrivate;
Packit 5756e2
Packit 5756e2
enum {
Packit Service a1bd4f
    PROP_0,
Packit Service a1bd4f
    PROP_TEXT,
Packit Service a1bd4f
    PROP_WIDTH,
Packit Service a1bd4f
    PROP_FLAGS,
Packit Service a1bd4f
    PROP_PASSWORD,
Packit 5756e2
Packit Service a1bd4f
    LAST_PROP
Packit 5756e2
};
Packit 5756e2
Packit 5756e2
/**
Packit 5756e2
 * NmtNewtEntryFlags:
Packit 5756e2
 * @NMT_NEWT_ENTRY_NOSCROLL: the entry content should not scroll left
Packit 5756e2
 *   and right
Packit 5756e2
 * @NMT_NEWT_ENTRY_PASSWORD: the entry should show '*'s instead of its
Packit 5756e2
 *   actual contents
Packit 5756e2
 * @NMT_NEWT_ENTRY_NONEMPTY: the entry should be considered not
Packit 5756e2
 *   #NmtNewtWidget:valid if it is empty.
Packit 5756e2
 *
Packit 5756e2
 * Flags describing an #NmtNewtEntry
Packit 5756e2
 */
Packit 5756e2
Packit 5756e2
/**
Packit 5756e2
 * nmt_newt_entry_new:
Packit 5756e2
 * @width: the width in characters for the entry
Packit 5756e2
 * @flags: flags describing the entry
Packit 5756e2
 *
Packit 5756e2
 * Creates a new #NmtNewtEntry.
Packit 5756e2
 *
Packit 5756e2
 * Returns: a new #NmtNewtEntry
Packit 5756e2
 */
Packit 5756e2
NmtNewtWidget *
Packit Service a1bd4f
nmt_newt_entry_new(int width, NmtNewtEntryFlags flags)
Packit 5756e2
{
Packit Service a1bd4f
    return g_object_new(NMT_TYPE_NEWT_ENTRY, "width", width, "flags", flags, NULL);
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
/**
Packit 5756e2
 * NmtNewtEntryFilter:
Packit 5756e2
 * @entry: the #NmtNewtEntry
Packit 5756e2
 * @text: the current contents of @entry
Packit 5756e2
 * @ch: the character just typed
Packit 5756e2
 * @position: the position of the cursor in @entry
Packit 5756e2
 * @user_data: the data passed to nmt_newt_entry_set_filter()
Packit 5756e2
 *
Packit 5756e2
 * Callback function used to filter the contents of an entry.
Packit 5756e2
 *
Packit 5756e2
 * Returns: %TRUE if @ch should be accepted, %FALSE if not
Packit 5756e2
 */
Packit 5756e2
Packit 5756e2
/**
Packit 5756e2
 * nmt_newt_entry_set_filter:
Packit 5756e2
 * @entry: an #NmtNewtEntry
Packit 5756e2
 * @filter: the function to use to filter the entry
Packit 5756e2
 * @user_data: data for @filter
Packit 5756e2
 *
Packit 5756e2
 * Sets a #NmtNewtEntryFilter on @entry, to allow filtering out
Packit 5756e2
 * certain characters from the entry.
Packit 5756e2
 *
Packit 5756e2
 * Note that @filter will only be called for printable characters (eg,
Packit 5756e2
 * not for cursor-control characters or the like), and that it will
Packit 5756e2
 * only be called for user input, not, eg, for
Packit 5756e2
 * nmt_newt_entry_set_text().
Packit 5756e2
 */
Packit 5756e2
void
Packit Service a1bd4f
nmt_newt_entry_set_filter(NmtNewtEntry *entry, NmtNewtEntryFilter filter, gpointer user_data)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(entry);
Packit 5756e2
Packit Service a1bd4f
    priv->filter      = filter;
Packit Service a1bd4f
    priv->filter_data = user_data;
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
nmt_newt_entry_check_valid(NmtNewtEntry *entry)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(entry);
Packit Service a1bd4f
    gboolean             valid;
Packit Service a1bd4f
Packit Service a1bd4f
    if ((priv->flags & NMT_NEWT_ENTRY_NONEMPTY) && *priv->text == '\0')
Packit Service a1bd4f
        valid = FALSE;
Packit Service a1bd4f
    else if (priv->validator)
Packit Service a1bd4f
        valid = !!priv->validator(entry, priv->text, priv->validator_data);
Packit Service a1bd4f
    else
Packit Service a1bd4f
        valid = TRUE;
Packit Service a1bd4f
Packit Service a1bd4f
    nmt_newt_widget_set_valid(NMT_NEWT_WIDGET(entry), valid);
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
/**
Packit 5756e2
 * NmtNewtEntryValidator:
Packit 5756e2
 * @entry: the #NmtNewtEntry
Packit 5756e2
 * @text: the current contents of @entry
Packit 5756e2
 * @user_data: the data passed to nmt_newt_entry_set_validator()
Packit 5756e2
 *
Packit 5756e2
 * Callback function used to validate the contents of an entry.
Packit 5756e2
 *
Packit 5756e2
 * Returns: whether the entry is #NmtNewtWidget:valid
Packit 5756e2
 */
Packit 5756e2
Packit 5756e2
/**
Packit 5756e2
 * nmt_newt_entry_set_validator:
Packit 5756e2
 * @entry: an #NmtNewtEntry
Packit 5756e2
 * @validator: the function to use to validate the entry
Packit 5756e2
 * @user_data: data for @validator
Packit 5756e2
 *
Packit 5756e2
 * Sets a #NmtNewtEntryValidator on @entry, to allow validation of
Packit 5756e2
 * the entry contents. If @validator returns %FALSE, then the entry
Packit 5756e2
 * will not be considered #NmtNewtWidget:valid.
Packit 5756e2
 */
Packit 5756e2
void
Packit Service a1bd4f
nmt_newt_entry_set_validator(NmtNewtEntry *        entry,
Packit Service a1bd4f
                             NmtNewtEntryValidator validator,
Packit Service a1bd4f
                             gpointer              user_data)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(entry);
Packit 5756e2
Packit Service a1bd4f
    priv->validator      = validator;
Packit Service a1bd4f
    priv->validator_data = user_data;
Packit 5756e2
Packit Service a1bd4f
    nmt_newt_entry_check_valid(entry);
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
nmt_newt_entry_set_text_internal(NmtNewtEntry *entry, const char *text, newtComponent co)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(entry);
Packit 5756e2
Packit Service a1bd4f
    if (!text)
Packit Service a1bd4f
        text = "";
Packit 5756e2
Packit Service a1bd4f
    if (!strcmp(priv->text, text))
Packit Service a1bd4f
        return;
Packit 5756e2
Packit Service a1bd4f
    g_free(priv->text);
Packit Service a1bd4f
    priv->text = g_strdup(text);
Packit 5756e2
Packit Service a1bd4f
    if (co) {
Packit Service a1bd4f
        char *text_lc;
Packit 5756e2
Packit Service a1bd4f
        text_lc = priv->text ? nmt_newt_locale_from_utf8(priv->text) : NULL;
Packit Service a1bd4f
        newtEntrySet(co, text_lc, TRUE);
Packit Service a1bd4f
        g_free(text_lc);
Packit Service a1bd4f
        priv->last_cursor_pos = -1;
Packit Service a1bd4f
    }
Packit 5756e2
Packit Service a1bd4f
    g_object_freeze_notify(G_OBJECT(entry));
Packit Service a1bd4f
    nmt_newt_entry_check_valid(entry);
Packit Service a1bd4f
    g_object_notify(G_OBJECT(entry), "text");
Packit Service a1bd4f
    g_object_thaw_notify(G_OBJECT(entry));
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
/**
Packit 5756e2
 * nmt_newt_entry_set_text:
Packit 5756e2
 * @entry: an #NmtNewtEntry
Packit 5756e2
 * @text: the new text
Packit 5756e2
 *
Packit 5756e2
 * Updates @entry's text. Note that this skips the entry's
Packit 5756e2
 * #NmtNewtEntryFilter, but will cause its #NmtNewtEntryValidator to
Packit 5756e2
 * be re-run.
Packit 5756e2
 */
Packit 5756e2
void
Packit Service a1bd4f
nmt_newt_entry_set_text(NmtNewtEntry *entry, const char *text)
Packit 5756e2
{
Packit Service a1bd4f
    newtComponent co;
Packit 5756e2
Packit Service a1bd4f
    co = nmt_newt_component_get_component(NMT_NEWT_COMPONENT(entry));
Packit Service a1bd4f
    nmt_newt_entry_set_text_internal(entry, text, co);
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
/**
Packit 5756e2
 * nmt_newt_entry_get_text:
Packit 5756e2
 * @entry: an #NmtNewtEntry
Packit 5756e2
 *
Packit 5756e2
 * Gets @entry's text
Packit 5756e2
 *
Packit 5756e2
 * Returns: @entry's text
Packit 5756e2
 */
Packit 5756e2
const char *
Packit Service a1bd4f
nmt_newt_entry_get_text(NmtNewtEntry *entry)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(entry);
Packit 5756e2
Packit Service a1bd4f
    return priv->text;
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
/**
Packit 5756e2
 * nmt_newt_entry_set_width:
Packit 5756e2
 * @entry: an #NmtNewtEntpry
Packit 5756e2
 * @widget: the new width
Packit 5756e2
 *
Packit 5756e2
 * Updates @entry's width
Packit 5756e2
 */
Packit 5756e2
void
Packit Service a1bd4f
nmt_newt_entry_set_width(NmtNewtEntry *entry, int width)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(entry);
Packit 5756e2
Packit Service a1bd4f
    if (priv->width == width)
Packit Service a1bd4f
        return;
Packit 5756e2
Packit Service a1bd4f
    priv->width = width;
Packit Service a1bd4f
    nmt_newt_widget_needs_rebuild(NMT_NEWT_WIDGET(entry));
Packit 5756e2
Packit Service a1bd4f
    g_object_notify(G_OBJECT(entry), "width");
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
/**
Packit 5756e2
 * nmt_newt_entry_get_width:
Packit 5756e2
 * @entry: an #NmtNewtEntry
Packit 5756e2
 *
Packit 5756e2
 * Gets @entry's width
Packit 5756e2
 *
Packit 5756e2
 * Returns: @entry's width
Packit 5756e2
 */
Packit 5756e2
int
Packit Service a1bd4f
nmt_newt_entry_get_width(NmtNewtEntry *entry)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(entry);
Packit 5756e2
Packit Service a1bd4f
    return priv->width;
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
nmt_newt_entry_init(NmtNewtEntry *entry)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(entry);
Packit 5756e2
Packit Service a1bd4f
    priv->text            = g_strdup("");
Packit Service a1bd4f
    priv->last_cursor_pos = -1;
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
nmt_newt_entry_constructed(GObject *object)
Packit 5756e2
{
Packit Service a1bd4f
    nmt_newt_entry_check_valid(NMT_NEWT_ENTRY(object));
Packit 5756e2
Packit Service a1bd4f
    G_OBJECT_CLASS(nmt_newt_entry_parent_class)->constructed(object);
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
nmt_newt_entry_finalize(GObject *object)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(object);
Packit 5756e2
Packit Service a1bd4f
    g_free(priv->text);
Packit Service a1bd4f
    if (priv->idle_update)
Packit Service a1bd4f
        g_source_remove(priv->idle_update);
Packit 5756e2
Packit Service a1bd4f
    G_OBJECT_CLASS(nmt_newt_entry_parent_class)->finalize(object);
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static gboolean
Packit Service a1bd4f
idle_update_entry(gpointer entry)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(entry);
Packit Service a1bd4f
    newtComponent        co   = nmt_newt_component_get_component(entry);
Packit Service a1bd4f
    char *               text;
Packit 5756e2
Packit Service a1bd4f
    priv->idle_update = 0;
Packit Service a1bd4f
    if (!co)
Packit Service a1bd4f
        return FALSE;
Packit 5756e2
Packit Service a1bd4f
    priv->last_cursor_pos = newtEntryGetCursorPosition(co);
Packit 5756e2
Packit Service a1bd4f
    text = nmt_newt_locale_to_utf8(newtEntryGetValue(co));
Packit Service a1bd4f
    nmt_newt_entry_set_text_internal(entry, text, NULL);
Packit Service a1bd4f
    g_free(text);
Packit 5756e2
Packit Service a1bd4f
    return FALSE;
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static int
Packit Service a1bd4f
entry_filter(newtComponent entry, void *self, int ch, int cursor)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(self);
Packit Service a1bd4f
Packit Service a1bd4f
    if (g_ascii_isprint(ch)) {
Packit Service a1bd4f
        if (priv->filter) {
Packit Service a1bd4f
            char *text = nmt_newt_locale_to_utf8(newtEntryGetValue(entry));
Packit Service a1bd4f
Packit Service a1bd4f
            if (!priv->filter(self, text, ch, cursor, priv->filter_data)) {
Packit Service a1bd4f
                g_free(text);
Packit Service a1bd4f
                return 0;
Packit Service a1bd4f
            }
Packit Service a1bd4f
            g_free(text);
Packit Service a1bd4f
        }
Packit Service a1bd4f
    }
Packit Service a1bd4f
Packit Service a1bd4f
    if (!priv->idle_update)
Packit Service a1bd4f
        priv->idle_update = g_idle_add(idle_update_entry, self);
Packit Service a1bd4f
    return ch;
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static guint
Packit Service a1bd4f
convert_flags(NmtNewtEntryFlags flags)
Packit 5756e2
{
Packit Service a1bd4f
    guint newt_flags = NEWT_FLAG_RETURNEXIT;
Packit 5756e2
Packit Service a1bd4f
    if (!(flags & NMT_NEWT_ENTRY_NOSCROLL))
Packit Service a1bd4f
        newt_flags |= NEWT_FLAG_SCROLL;
Packit Service a1bd4f
    if (flags & NMT_NEWT_ENTRY_PASSWORD)
Packit Service a1bd4f
        newt_flags |= NEWT_FLAG_PASSWORD;
Packit 5756e2
Packit Service a1bd4f
    return newt_flags;
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static newtComponent
Packit Service a1bd4f
nmt_newt_entry_build_component(NmtNewtComponent *component, gboolean sensitive)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(component);
Packit Service a1bd4f
    newtComponent        co;
Packit Service a1bd4f
    char *               text_lc;
Packit Service a1bd4f
    int                  flags;
Packit 5756e2
Packit Service a1bd4f
    flags = convert_flags(priv->flags);
Packit Service a1bd4f
    if (!sensitive)
Packit Service a1bd4f
        flags |= NEWT_FLAG_DISABLED;
Packit 5756e2
Packit Service a1bd4f
    text_lc = priv->text ? nmt_newt_locale_from_utf8(priv->text) : NULL;
Packit Service a1bd4f
    co      = newtEntry(-1, -1, text_lc, priv->width, NULL, flags);
Packit Service a1bd4f
    g_free(text_lc);
Packit 5756e2
Packit Service a1bd4f
    if (priv->last_cursor_pos != -1)
Packit Service a1bd4f
        newtEntrySetCursorPosition(co, priv->last_cursor_pos);
Packit 5756e2
Packit Service a1bd4f
    newtEntrySetFilter(co, entry_filter, component);
Packit Service a1bd4f
    return co;
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
nmt_newt_entry_activated(NmtNewtWidget *widget)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv = NMT_NEWT_ENTRY_GET_PRIVATE(widget);
Packit 5756e2
Packit Service a1bd4f
    if (priv->idle_update) {
Packit Service a1bd4f
        g_source_remove(priv->idle_update);
Packit Service a1bd4f
        idle_update_entry(widget);
Packit Service a1bd4f
    }
Packit 5756e2
Packit Service a1bd4f
    NMT_NEWT_WIDGET_CLASS(nmt_newt_entry_parent_class)->activated(widget);
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
nmt_newt_entry_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntry *       entry = NMT_NEWT_ENTRY(object);
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv  = NMT_NEWT_ENTRY_GET_PRIVATE(entry);
Packit Service a1bd4f
Packit Service a1bd4f
    switch (prop_id) {
Packit Service a1bd4f
    case PROP_TEXT:
Packit Service a1bd4f
        nmt_newt_entry_set_text(entry, g_value_get_string(value));
Packit Service a1bd4f
        break;
Packit Service a1bd4f
    case PROP_WIDTH:
Packit Service a1bd4f
        nmt_newt_entry_set_width(entry, g_value_get_int(value));
Packit Service a1bd4f
        break;
Packit Service a1bd4f
    case PROP_FLAGS:
Packit Service a1bd4f
        priv->flags = g_value_get_uint(value);
Packit Service a1bd4f
        nmt_newt_widget_needs_rebuild(NMT_NEWT_WIDGET(entry));
Packit Service a1bd4f
        break;
Packit Service a1bd4f
    case PROP_PASSWORD:
Packit Service a1bd4f
        if (g_value_get_boolean(value))
Packit Service a1bd4f
            priv->flags |= NMT_NEWT_ENTRY_PASSWORD;
Packit Service a1bd4f
        else
Packit Service a1bd4f
            priv->flags &= ~NMT_NEWT_ENTRY_PASSWORD;
Packit Service a1bd4f
        nmt_newt_widget_needs_rebuild(NMT_NEWT_WIDGET(entry));
Packit Service a1bd4f
        break;
Packit Service a1bd4f
    default:
Packit Service a1bd4f
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
Packit Service a1bd4f
        break;
Packit Service a1bd4f
    }
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
nmt_newt_entry_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
Packit 5756e2
{
Packit Service a1bd4f
    NmtNewtEntry *       entry = NMT_NEWT_ENTRY(object);
Packit Service a1bd4f
    NmtNewtEntryPrivate *priv  = NMT_NEWT_ENTRY_GET_PRIVATE(entry);
Packit Service a1bd4f
Packit Service a1bd4f
    switch (prop_id) {
Packit Service a1bd4f
    case PROP_TEXT:
Packit Service a1bd4f
        g_value_set_string(value, nmt_newt_entry_get_text(entry));
Packit Service a1bd4f
        break;
Packit Service a1bd4f
    case PROP_WIDTH:
Packit Service a1bd4f
        g_value_set_int(value, priv->width);
Packit Service a1bd4f
        break;
Packit Service a1bd4f
    case PROP_FLAGS:
Packit Service a1bd4f
        g_value_set_uint(value, priv->flags);
Packit Service a1bd4f
        break;
Packit Service a1bd4f
    case PROP_PASSWORD:
Packit Service a1bd4f
        g_value_set_boolean(value, (priv->flags & NMT_NEWT_ENTRY_PASSWORD) != 0);
Packit Service a1bd4f
        break;
Packit Service a1bd4f
    default:
Packit Service a1bd4f
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
Packit Service a1bd4f
        break;
Packit Service a1bd4f
    }
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
nmt_newt_entry_class_init(NmtNewtEntryClass *entry_class)
Packit 5756e2
{
Packit Service a1bd4f
    GObjectClass *         object_class    = G_OBJECT_CLASS(entry_class);
Packit Service a1bd4f
    NmtNewtWidgetClass *   widget_class    = NMT_NEWT_WIDGET_CLASS(entry_class);
Packit Service a1bd4f
    NmtNewtComponentClass *component_class = NMT_NEWT_COMPONENT_CLASS(entry_class);
Packit Service a1bd4f
Packit Service a1bd4f
    g_type_class_add_private(entry_class, sizeof(NmtNewtEntryPrivate));
Packit Service a1bd4f
Packit Service a1bd4f
    /* virtual methods */
Packit Service a1bd4f
    object_class->constructed  = nmt_newt_entry_constructed;
Packit Service a1bd4f
    object_class->set_property = nmt_newt_entry_set_property;
Packit Service a1bd4f
    object_class->get_property = nmt_newt_entry_get_property;
Packit Service a1bd4f
    object_class->finalize     = nmt_newt_entry_finalize;
Packit Service a1bd4f
Packit Service a1bd4f
    widget_class->activated = nmt_newt_entry_activated;
Packit Service a1bd4f
Packit Service a1bd4f
    component_class->build_component = nmt_newt_entry_build_component;
Packit Service a1bd4f
Packit Service a1bd4f
    /**
Packit Service a1bd4f
     * NmtNewtEntry:text
Packit Service a1bd4f
     *
Packit Service a1bd4f
     * The entry's text
Packit Service a1bd4f
     */
Packit Service a1bd4f
    g_object_class_install_property(
Packit Service a1bd4f
        object_class,
Packit Service a1bd4f
        PROP_TEXT,
Packit Service a1bd4f
        g_param_spec_string("text", "", "", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit Service a1bd4f
    /**
Packit Service a1bd4f
     * NmtNewtEntry:width
Packit Service a1bd4f
     *
Packit Service a1bd4f
     * The entry's width in characters
Packit Service a1bd4f
     */
Packit Service a1bd4f
    g_object_class_install_property(
Packit Service a1bd4f
        object_class,
Packit Service a1bd4f
        PROP_WIDTH,
Packit Service a1bd4f
        g_param_spec_int("width", "", "", -1, 80, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit Service a1bd4f
    /**
Packit Service a1bd4f
     * NmtNewtEntry:flags
Packit Service a1bd4f
     *
Packit Service a1bd4f
     * The entry's #NmtNewtEntryFlags
Packit Service a1bd4f
     */
Packit Service a1bd4f
    g_object_class_install_property(
Packit Service a1bd4f
        object_class,
Packit Service a1bd4f
        PROP_FLAGS,
Packit Service a1bd4f
        g_param_spec_uint("flags",
Packit Service a1bd4f
                          "",
Packit Service a1bd4f
                          "",
Packit Service a1bd4f
                          0,
Packit Service a1bd4f
                          0xFFFF,
Packit Service a1bd4f
                          0,
Packit Service a1bd4f
                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
Packit Service a1bd4f
    /**
Packit Service a1bd4f
     * NmtNewtEntry:password
Packit Service a1bd4f
     *
Packit Service a1bd4f
     * %TRUE if #NmtNewtEntry:flags contains %NMT_NEWT_ENTRY_PASSWORD,
Packit Service a1bd4f
     * %FALSE if not.
Packit Service a1bd4f
     */
Packit Service a1bd4f
    g_object_class_install_property(
Packit Service a1bd4f
        object_class,
Packit Service a1bd4f
        PROP_PASSWORD,
Packit Service a1bd4f
        g_param_spec_boolean("password",
Packit Service a1bd4f
                             "",
Packit Service a1bd4f
                             "",
Packit Service a1bd4f
                             FALSE,
Packit Service a1bd4f
                             G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 5756e2
}