tui: extend numeric range of NmtNewtEntryNumeric to gint64

It is used for example for the route's metric, which is
guint32 and may not fit into int type.
This commit is contained in:
Thomas Haller 2017-09-05 19:24:55 +02:00
parent 08d7bf5988
commit 08a186558c
2 changed files with 25 additions and 25 deletions

View file

@ -37,7 +37,7 @@ G_DEFINE_TYPE (NmtNewtEntryNumeric, nmt_newt_entry_numeric, NMT_TYPE_NEWT_ENTRY)
#define NMT_NEWT_ENTRY_NUMERIC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMT_TYPE_NEWT_ENTRY_NUMERIC, NmtNewtEntryNumericPrivate))
typedef struct {
int min, max;
gint64 min, max;
bool optional;
} NmtNewtEntryNumericPrivate;
@ -63,8 +63,8 @@ enum {
*/
NmtNewtWidget *
nmt_newt_entry_numeric_new (int width,
int min,
int max)
gint64 min,
gint64 max)
{
return nmt_newt_entry_numeric_new_full (width,
min,
@ -86,8 +86,8 @@ nmt_newt_entry_numeric_new (int width,
*/
NmtNewtWidget *
nmt_newt_entry_numeric_new_full (int width,
int min,
int max,
gint64 min,
gint64 max,
gboolean optional)
{
return g_object_new (NMT_TYPE_NEWT_ENTRY_NUMERIC,
@ -122,7 +122,7 @@ newt_entry_numeric_validate (NmtNewtEntry *entry,
gpointer user_data)
{
NmtNewtEntryNumericPrivate *priv = NMT_NEWT_ENTRY_NUMERIC_GET_PRIVATE (entry);
int val;
gint64 val;
if (!*text)
return priv->optional ? TRUE : FALSE;
@ -146,7 +146,7 @@ nmt_newt_entry_numeric_constructed (GObject *object)
if (!*nmt_newt_entry_get_text (NMT_NEWT_ENTRY (object))) {
char buf[32];
g_snprintf (buf, sizeof (buf), "%d", priv->min);
g_snprintf (buf, sizeof (buf), "%lld", (long long) priv->min);
nmt_newt_entry_set_text (NMT_NEWT_ENTRY (object), buf);
}
@ -163,10 +163,10 @@ nmt_newt_entry_numeric_set_property (GObject *object,
switch (prop_id) {
case PROP_MINIMUM:
priv->min = g_value_get_int (value);
priv->min = g_value_get_int64 (value);
break;
case PROP_MAXIMUM:
priv->max = g_value_get_int (value);
priv->max = g_value_get_int64 (value);
break;
case PROP_OPTIONAL:
priv->optional = g_value_get_boolean (value);
@ -187,10 +187,10 @@ nmt_newt_entry_numeric_get_property (GObject *object,
switch (prop_id) {
case PROP_MINIMUM:
g_value_set_int (value, priv->min);
g_value_set_int64 (value, priv->min);
break;
case PROP_MAXIMUM:
g_value_set_int (value, priv->max);
g_value_set_int64 (value, priv->max);
break;
case PROP_OPTIONAL:
g_value_set_boolean (value, priv->optional);
@ -222,11 +222,11 @@ nmt_newt_entry_numeric_class_init (NmtNewtEntryNumericClass *entry_class)
*/
g_object_class_install_property
(object_class, PROP_MINIMUM,
g_param_spec_int ("minimum", "", "",
G_MININT, G_MAXINT, 0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
g_param_spec_int64 ("minimum", "", "",
G_MININT64, G_MAXINT64, 0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
/**
* NmtNewtEntryNumeric:maximum:
*
@ -234,11 +234,11 @@ nmt_newt_entry_numeric_class_init (NmtNewtEntryNumericClass *entry_class)
*/
g_object_class_install_property
(object_class, PROP_MAXIMUM,
g_param_spec_int ("maximum", "", "",
G_MININT, G_MAXINT, G_MAXINT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
g_param_spec_int64 ("maximum", "", "",
G_MININT64, G_MAXINT64, G_MAXINT64,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
/**
* NmtNewtEntryNumeric:optional:
*

View file

@ -41,12 +41,12 @@ typedef struct {
GType nmt_newt_entry_numeric_get_type (void);
NmtNewtWidget *nmt_newt_entry_numeric_new (int width,
int min,
int max);
gint64 min,
gint64 max);
NmtNewtWidget *nmt_newt_entry_numeric_new_full (int width,
int min,
int max,
gint64 min,
gint64 max,
gboolean optional);
#endif /* NMT_NEWT_ENTRY_NUMERIC_H */