medit/moo/mooedit/mooedithistoryitem.c

51 lines
1.1 KiB
C
Raw Normal View History

2010-11-23 21:54:39 -08:00
#include "mooedithistoryitem.h"
#include <stdlib.h>
#define KEY_ENCODING "encoding"
#define KEY_LINE "line"
void
2010-12-08 01:17:17 -08:00
_moo_edit_history_item_set_encoding (MooHistoryItem *item,
const char *encoding)
2010-11-23 21:54:39 -08:00
{
g_return_if_fail (item != NULL);
2010-12-08 01:17:17 -08:00
moo_history_item_set (item, KEY_ENCODING, encoding);
2010-11-23 21:54:39 -08:00
}
void
2010-12-08 01:17:17 -08:00
_moo_edit_history_item_set_line (MooHistoryItem *item,
int line)
2010-11-23 21:54:39 -08:00
{
char *value = NULL;
g_return_if_fail (item != NULL);
if (line >= 0)
value = g_strdup_printf ("%d", line + 1);
2010-12-08 01:17:17 -08:00
moo_history_item_set (item, KEY_LINE, value);
2010-11-23 21:54:39 -08:00
g_free (value);
}
const char *
2010-12-08 01:17:17 -08:00
_moo_edit_history_item_get_encoding (MooHistoryItem *item)
2010-11-23 21:54:39 -08:00
{
g_return_val_if_fail (item != NULL, NULL);
2010-12-08 01:17:17 -08:00
return moo_history_item_get (item, KEY_ENCODING);
2010-11-23 21:54:39 -08:00
}
int
2010-12-08 01:17:17 -08:00
_moo_edit_history_item_get_line (MooHistoryItem *item)
2010-11-23 21:54:39 -08:00
{
const char *strval;
g_return_val_if_fail (item != NULL, -1);
2010-12-08 01:17:17 -08:00
strval = moo_history_item_get (item, KEY_LINE);
2010-11-23 21:54:39 -08:00
if (strval && strval[0])
return strtol (strval, NULL, 10) - 1;
else
return -1;
}