1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-03 12:16:44 +02:00

add setting to control history size

This commit is contained in:
Jfreegman
2014-05-25 19:54:34 -04:00
parent 083ca2f3b7
commit f0962bd060
5 changed files with 25 additions and 4 deletions

View File

@ -27,6 +27,7 @@
#include "configdir.h"
#include "audio_call.h"
#include "settings.h"
#include "line_info.h"
static void uset_autolog(struct user_settings *s, int val);
static void uset_time(struct user_settings *s, int val);
@ -34,6 +35,7 @@ static void uset_alerts(struct user_settings *s, int val);
static void uset_colours(struct user_settings *s, int val);
static void uset_ain_dev(struct user_settings *s, int val);
static void uset_aout_dev(struct user_settings *s, int val);
static void uset_hst_size(struct user_settings *s, int val);
struct {
const char *name;
@ -45,6 +47,7 @@ struct {
{ "colour_theme", uset_colours },
{ "audio_in_dev", uset_ain_dev },
{ "audio_out_dev", uset_aout_dev },
{ "history_size", uset_hst_size },
};
static void uset_autolog(struct user_settings *s, int val)
@ -87,6 +90,12 @@ static void uset_aout_dev(struct user_settings *s, int val)
s->audio_out_dev = (long int) val;
}
static void uset_hst_size(struct user_settings *s, int val)
{
/* if val is out of range use default history size */
s->history_size = (val > MAX_HISTORY || val < MIN_HISTORY) ? DFLT_HST_SIZE : val;
}
int settings_load(struct user_settings *s, char *path)
{
char *user_config_dir = get_user_config_dir();
@ -102,6 +111,8 @@ int settings_load(struct user_settings *s, char *path)
free(user_config_dir);
uset_hst_size(s, DFLT_HST_SIZE); /* must be forced in case no setting specified */
if (fp == NULL && !path) {
if ((fp = fopen(dflt_path, "w")) == NULL)
return -1;