1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Organised config file

This commit is contained in:
James Booth 2012-12-02 02:21:59 +00:00
parent 6826a66f85
commit 9d700f3f1f
4 changed files with 59 additions and 66 deletions

View File

@ -104,7 +104,7 @@ static gboolean _cmd_set_priority(gchar **args, struct cmd_help_t help);
static gboolean _cmd_set_reconnect(gchar **args, struct cmd_help_t help);
static gboolean _cmd_set_intype(gchar **args, struct cmd_help_t help);
static gboolean _cmd_set_flash(gchar **args, struct cmd_help_t help);
static gboolean _cmd_set_showsplash(gchar **args, struct cmd_help_t help);
static gboolean _cmd_set_splash(gchar **args, struct cmd_help_t help);
static gboolean _cmd_set_chlog(gchar **args, struct cmd_help_t help);
static gboolean _cmd_set_history(gchar **args, struct cmd_help_t help);
static gboolean _cmd_set_states(gchar **args, struct cmd_help_t help);
@ -400,15 +400,15 @@ static struct cmd_t setting_commands[] =
"Config file value : intype=true|false",
NULL } } },
{ "/showsplash",
_cmd_set_showsplash, parse_args, 1, 1,
{ "/showsplash on|off", "Splash logo on startup.",
{ "/showsplash on|off",
"------------------",
{ "/splash",
_cmd_set_splash, parse_args, 1, 1,
{ "/splash on|off", "Splash logo on startup.",
{ "/splash on|off",
"--------------",
"Switch on or off the ascii logo on start up.",
"",
"Config file section : [ui]",
"Config file value : showsplash=true|false",
"Config file value : splash=true|false",
NULL } } },
{ "/vercheck",
@ -435,16 +435,8 @@ static struct cmd_t setting_commands[] =
{ "/chlog on|off",
"-------------",
"Switch chat logging on or off.",
"Chat logs are stored in the ~/.profanoty/log directory.",
"A folder is created for each login that you have used with Profanity.",
"Within in those folders, a log file is created for each user you chat to.",
"",
"For example if you are logged in as someuser@chatserv.com, and you chat",
"to myfriend@chatserv.com, the following chat log will be created:",
"",
" ~/.profanity/log/someuser_at_chatserv.com/myfriend_at_chatserv.com",
"",
"Config file section : [ui]",
"Config file section : [logging]",
"Config file value : chlog=true|false",
NULL } } },
@ -458,8 +450,8 @@ static struct cmd_t setting_commands[] =
"session with somebody, such as whether you have become inactive, or",
"have close the chat window.",
"",
"Config file section : [ui]",
"Config file value : states=true|false",
"Config file section : [chatstates]",
"Config file value : enabled=true|false",
NULL } } },
{ "/outtype",
@ -470,7 +462,7 @@ static struct cmd_t setting_commands[] =
"Send an indication that you are typing to the other person in chat.",
"Chat states must be enabled for this to work, see the /states command.",
"",
"Config file section : [ui]",
"Config file section : [chatstates]",
"Config file value : outtype=true|false",
NULL } } },
@ -497,7 +489,7 @@ static struct cmd_t setting_commands[] =
"maxsize : When log file size exceeds this value it will be automatically",
" rotated (file will be renamed). Default value is 1048580 (1MB)",
"",
"Config file section : [log]",
"Config file section : [logging]",
"Config file value : maxsize=bytes",
NULL } } },
@ -509,7 +501,7 @@ static struct cmd_t setting_commands[] =
"Set the reconnect attempt interval in seconds for when the connection is lost.",
"A value of 0 will switch of reconnect attempts.",
"",
"Config file section : [jabber]",
"Config file section : [connection]",
"Config file value : reconnect=seconds",
NULL } } },
@ -521,7 +513,7 @@ static struct cmd_t setting_commands[] =
"Set the number of seconds between server pings, so ensure connection kept alive.",
"A value of 0 will switch off autopinging the server.",
"",
"Config file section : [jabber]",
"Config file section : [connection]",
"Config file value : autoping=seconds",
NULL } } },
@ -545,11 +537,11 @@ static struct cmd_t setting_commands[] =
"Example: /autoaway message I'm not really doing much",
"Example: /autoaway check false",
"",
"Config file section : [autoaway]",
"Config file value : mode=idle|away|off",
"Config file value : time=value",
"Config file value : message=value",
"Config file value : check=on|off",
"Config file section : [presence]",
"Config file value : autoaway.mode=idle|away|off",
"Config file value : autoaway.time=value",
"Config file value : autoaway.message=value",
"Config file value : autoaway.check=on|off",
NULL } } },
{ "/priority",
@ -559,7 +551,8 @@ static struct cmd_t setting_commands[] =
"--------------------",
"value : Number between -128 and 127. Default value is 0.",
"",
"Config file section : [jabber]",
"Config file section : [presence]",
"Config file value : priority=value",
NULL } } }
};
@ -889,7 +882,7 @@ _cmd_complete_parameters(char *input, int *size)
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/flash",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/showsplash",
_parameter_autocomplete(input, size, "/splash",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/chlog",
prefs_autocomplete_boolean_choice);
@ -1755,10 +1748,10 @@ _cmd_set_intype(gchar **args, struct cmd_help_t help)
}
static gboolean
_cmd_set_showsplash(gchar **args, struct cmd_help_t help)
_cmd_set_splash(gchar **args, struct cmd_help_t help)
{
return _cmd_set_boolean_preference(args[0], help,
"Splash screen", prefs_set_showsplash);
"Splash screen", prefs_set_splash);
}
static gboolean

View File

@ -58,7 +58,7 @@ prefs_load(void)
NULL);
err = NULL;
log_maxsize = g_key_file_get_integer(prefs, "log", "maxsize", &err);
log_maxsize = g_key_file_get_integer(prefs, "logging", "maxsize", &err);
if (err != NULL) {
log_maxsize = 0;
g_error_free(err);
@ -117,26 +117,26 @@ prefs_set_theme(gchar *value)
gboolean
prefs_get_states(void)
{
return g_key_file_get_boolean(prefs, "ui", "states", NULL);
return g_key_file_get_boolean(prefs, "chatstates", "enabled", NULL);
}
void
prefs_set_states(gboolean value)
{
g_key_file_set_boolean(prefs, "ui", "states", value);
g_key_file_set_boolean(prefs, "chatstates", "enabled", value);
_save_prefs();
}
gboolean
prefs_get_outtype(void)
{
return g_key_file_get_boolean(prefs, "ui", "outtype", NULL);
return g_key_file_get_boolean(prefs, "chatstates", "outtype", NULL);
}
void
prefs_set_outtype(gboolean value)
{
g_key_file_set_boolean(prefs, "ui", "outtype", value);
g_key_file_set_boolean(prefs, "chatstates", "outtype", value);
_save_prefs();
}
@ -192,46 +192,46 @@ void
prefs_set_max_log_size(gint value)
{
log_maxsize = value;
g_key_file_set_integer(prefs, "log", "maxsize", value);
g_key_file_set_integer(prefs, "logging", "maxsize", value);
_save_prefs();
}
gint
prefs_get_priority(void)
{
return g_key_file_get_integer(prefs, "jabber", "priority", NULL);
return g_key_file_get_integer(prefs, "presence", "priority", NULL);
}
void
prefs_set_priority(gint value)
{
g_key_file_set_integer(prefs, "jabber", "priority", value);
g_key_file_set_integer(prefs, "presence", "priority", value);
_save_prefs();
}
gint
prefs_get_reconnect(void)
{
return g_key_file_get_integer(prefs, "jabber", "reconnect", NULL);
return g_key_file_get_integer(prefs, "connection", "reconnect", NULL);
}
void
prefs_set_reconnect(gint value)
{
g_key_file_set_integer(prefs, "jabber", "reconnect", value);
g_key_file_set_integer(prefs, "connection", "reconnect", value);
_save_prefs();
}
gint
prefs_get_autoping(void)
{
return g_key_file_get_integer(prefs, "jabber", "autoping", NULL);
return g_key_file_get_integer(prefs, "connection", "autoping", NULL);
}
void
prefs_set_autoping(gint value)
{
g_key_file_set_integer(prefs, "jabber", "autoping", value);
g_key_file_set_integer(prefs, "connection", "autoping", value);
_save_prefs();
}
@ -290,13 +290,13 @@ prefs_set_intype(gboolean value)
gboolean
prefs_get_chlog(void)
{
return g_key_file_get_boolean(prefs, "ui", "chlog", NULL);
return g_key_file_get_boolean(prefs, "logging", "chlog", NULL);
}
void
prefs_set_chlog(gboolean value)
{
g_key_file_set_boolean(prefs, "ui", "chlog", value);
g_key_file_set_boolean(prefs, "logging", "chlog", value);
_save_prefs();
}
@ -316,7 +316,7 @@ prefs_set_history(gboolean value)
gchar *
prefs_get_autoaway_mode(void)
{
gchar *result = g_key_file_get_string(prefs, "autoaway", "mode", NULL);
gchar *result = g_key_file_get_string(prefs, "presence", "autoaway.mode", NULL);
if (result == NULL) {
return strdup("off");
} else {
@ -327,14 +327,14 @@ prefs_get_autoaway_mode(void)
void
prefs_set_autoaway_mode(gchar *value)
{
g_key_file_set_string(prefs, "autoaway", "mode", value);
g_key_file_set_string(prefs, "presence", "autoaway.mode", value);
_save_prefs();
}
gint
prefs_get_autoaway_time(void)
{
gint result = g_key_file_get_integer(prefs, "autoaway", "time", NULL);
gint result = g_key_file_get_integer(prefs, "presence", "autoaway.time", NULL);
if (result == 0) {
return 15;
@ -346,23 +346,23 @@ prefs_get_autoaway_time(void)
void
prefs_set_autoaway_time(gint value)
{
g_key_file_set_integer(prefs, "autoaway", "time", value);
g_key_file_set_integer(prefs, "presence", "autoaway.time", value);
_save_prefs();
}
gchar *
prefs_get_autoaway_message(void)
{
return g_key_file_get_string(prefs, "autoaway", "message", NULL);
return g_key_file_get_string(prefs, "presence", "autoaway.message", NULL);
}
void
prefs_set_autoaway_message(gchar *value)
{
if (value == NULL) {
g_key_file_remove_key(prefs, "autoaway", "message", NULL);
g_key_file_remove_key(prefs, "presence", "autoaway.message", NULL);
} else {
g_key_file_set_string(prefs, "autoaway", "message", value);
g_key_file_set_string(prefs, "presence", "autoaway.message", value);
}
_save_prefs();
}
@ -370,8 +370,8 @@ prefs_set_autoaway_message(gchar *value)
gboolean
prefs_get_autoaway_check(void)
{
if (g_key_file_has_key(prefs, "autoaway", "check", NULL)) {
return g_key_file_get_boolean(prefs, "autoaway", "check", NULL);
if (g_key_file_has_key(prefs, "presence", "autoaway.check", NULL)) {
return g_key_file_get_boolean(prefs, "presence", "autoaway.check", NULL);
} else {
return TRUE;
}
@ -380,20 +380,20 @@ prefs_get_autoaway_check(void)
void
prefs_set_autoaway_check(gboolean value)
{
g_key_file_set_boolean(prefs, "autoaway", "check", value);
g_key_file_set_boolean(prefs, "presence", "autoaway.check", value);
_save_prefs();
}
gboolean
prefs_get_showsplash(void)
prefs_get_splash(void)
{
return g_key_file_get_boolean(prefs, "ui", "showsplash", NULL);
return g_key_file_get_boolean(prefs, "ui", "splash", NULL);
}
void
prefs_set_showsplash(gboolean value)
prefs_set_splash(gboolean value)
{
g_key_file_set_boolean(prefs, "ui", "showsplash", value);
g_key_file_set_boolean(prefs, "ui", "splash", value);
_save_prefs();
}

View File

@ -53,8 +53,8 @@ gboolean prefs_get_chlog(void);
void prefs_set_chlog(gboolean value);
gboolean prefs_get_history(void);
void prefs_set_history(gboolean value);
gboolean prefs_get_showsplash(void);
void prefs_set_showsplash(gboolean value);
gboolean prefs_get_splash(void);
void prefs_set_splash(gboolean value);
gboolean prefs_get_vercheck(void);
void prefs_set_vercheck(gboolean value);
gboolean prefs_get_titlebarversion(void);

View File

@ -1127,10 +1127,10 @@ cons_show_ui_prefs(void)
else
cons_show("Show typing (/intype) : OFF");
if (prefs_get_showsplash())
cons_show("Splash screen (/showsplash) : ON");
if (prefs_get_splash())
cons_show("Splash screen (/splash) : ON");
else
cons_show("Splash screen (/showsplash) : OFF");
cons_show("Splash screen (/splash) : OFF");
if (prefs_get_history())
cons_show("Chat history (/history) : ON");
@ -1214,7 +1214,7 @@ cons_show_presence_prefs(void)
cons_show("Autoaway (/autoaway mode) : %s", prefs_get_autoaway_mode());
}
cons_show("Autoaway time (/autoaway time) : %d minutes", prefs_get_autoaway_time());
cons_show("Autoaway minutes (/autoaway time) : %d minutes", prefs_get_autoaway_time());
if ((prefs_get_autoaway_message() == NULL) ||
(strcmp(prefs_get_autoaway_message(), "") == 0)) {
@ -1491,7 +1491,7 @@ cons_about(void)
int rows, cols;
getmaxyx(stdscr, rows, cols);
if (prefs_get_showsplash()) {
if (prefs_get_splash()) {
_cons_splash_logo();
} else {
_win_show_time(console->win);