mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
use custom format string for time preference
This commit is contained in:
parent
6529220351
commit
7f436d614b
@ -620,10 +620,10 @@ static struct cmd_t command_defs[] =
|
||||
|
||||
{ "/time",
|
||||
cmd_time, parse_args, 1, 1, &cons_time_setting,
|
||||
{ "/time minutes|seconds", "Time display.",
|
||||
{ "/time minutes|seconds",
|
||||
{ "/time <format>", "Time display.",
|
||||
{ "/time <format>",
|
||||
"---------------------",
|
||||
"Configure time precision for the main window.",
|
||||
"Configure the time format for the main window.",
|
||||
NULL } } },
|
||||
|
||||
{ "/inpblock",
|
||||
@ -1121,7 +1121,6 @@ static Autocomplete form_ac;
|
||||
static Autocomplete form_field_multi_ac;
|
||||
static Autocomplete occupants_ac;
|
||||
static Autocomplete occupants_default_ac;
|
||||
static Autocomplete time_ac;
|
||||
static Autocomplete resource_ac;
|
||||
static Autocomplete inpblock_ac;
|
||||
|
||||
@ -1461,15 +1460,6 @@ cmd_init(void)
|
||||
autocomplete_add(occupants_default_ac, "show");
|
||||
autocomplete_add(occupants_default_ac, "hide");
|
||||
|
||||
time_ac = autocomplete_new();
|
||||
autocomplete_add(time_ac, "minutes");
|
||||
autocomplete_add(time_ac, "seconds");
|
||||
autocomplete_add(time_ac, "off");
|
||||
|
||||
time_ac = autocomplete_new();
|
||||
autocomplete_add(time_ac, "minutes");
|
||||
autocomplete_add(time_ac, "seconds");
|
||||
|
||||
resource_ac = autocomplete_new();
|
||||
autocomplete_add(resource_ac, "set");
|
||||
autocomplete_add(resource_ac, "off");
|
||||
@ -1532,7 +1522,6 @@ cmd_uninit(void)
|
||||
autocomplete_free(form_field_multi_ac);
|
||||
autocomplete_free(occupants_ac);
|
||||
autocomplete_free(occupants_default_ac);
|
||||
autocomplete_free(time_ac);
|
||||
autocomplete_free(resource_ac);
|
||||
autocomplete_free(inpblock_ac);
|
||||
}
|
||||
@ -1697,7 +1686,6 @@ cmd_reset_autocomplete()
|
||||
autocomplete_reset(form_field_multi_ac);
|
||||
autocomplete_reset(occupants_ac);
|
||||
autocomplete_reset(occupants_default_ac);
|
||||
autocomplete_reset(time_ac);
|
||||
autocomplete_reset(resource_ac);
|
||||
autocomplete_reset(inpblock_ac);
|
||||
|
||||
@ -2010,8 +1998,8 @@ _cmd_complete_parameters(const char * const input)
|
||||
}
|
||||
}
|
||||
|
||||
gchar *cmds[] = { "/help", "/prefs", "/disco", "/close", "/wins", "/subject", "/room", "/time" };
|
||||
Autocomplete completers[] = { help_ac, prefs_ac, disco_ac, close_ac, wins_ac, subject_ac, room_ac, time_ac };
|
||||
gchar *cmds[] = { "/help", "/prefs", "/disco", "/close", "/wins", "/subject", "/room", };
|
||||
Autocomplete completers[] = { help_ac, prefs_ac, disco_ac, close_ac, wins_ac, subject_ac, room_ac, };
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(cmds); i++) {
|
||||
result = autocomplete_param_with_ac(input, cmds[i], completers[i], TRUE);
|
||||
|
@ -3257,25 +3257,10 @@ cmd_wrap(gchar **args, struct cmd_help_t help)
|
||||
gboolean
|
||||
cmd_time(gchar **args, struct cmd_help_t help)
|
||||
{
|
||||
if (g_strcmp0(args[0], "minutes") == 0) {
|
||||
prefs_set_string(PREF_TIME, "minutes");
|
||||
cons_show("Time precision set to minutes.");
|
||||
wins_resize_all();
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(args[0], "seconds") == 0) {
|
||||
prefs_set_string(PREF_TIME, "seconds");
|
||||
cons_show("Time precision set to seconds.");
|
||||
wins_resize_all();
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(args[0], "off") == 0) {
|
||||
prefs_set_string(PREF_TIME, "off");
|
||||
cons_show("Time display disabled.");
|
||||
wins_resize_all();
|
||||
return TRUE;
|
||||
} else {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
return TRUE;
|
||||
}
|
||||
prefs_set_string(PREF_TIME, args[0]);
|
||||
cons_show("Time format set to '%s'", args[0]);
|
||||
wins_resize_all();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -727,7 +727,7 @@ _get_default_string(preference_t pref)
|
||||
case PREF_ROSTER_BY:
|
||||
return "none";
|
||||
case PREF_TIME:
|
||||
return "seconds";
|
||||
return "%H:%M:%S";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
@ -919,12 +919,10 @@ void
|
||||
cons_time_setting(void)
|
||||
{
|
||||
char *pref_time = prefs_get_string(PREF_TIME);
|
||||
if (g_strcmp0(pref_time, "minutes") == 0)
|
||||
cons_show("Time (/time) : minutes");
|
||||
else if (g_strcmp0(pref_time, "off") == 0)
|
||||
if (g_strcmp0(pref_time, "off") == 0)
|
||||
cons_show("Time (/time) : OFF");
|
||||
else
|
||||
cons_show("Time (/time) : seconds");
|
||||
cons_show("Time (/time) : %s", pref_time);
|
||||
|
||||
prefs_free_string(pref_time);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <glib.h>
|
||||
@ -882,14 +883,10 @@ _win_print(ProfWin *window, const char show_char, GDateTime *time,
|
||||
if ((flags & NO_DATE) == 0) {
|
||||
gchar *date_fmt = NULL;
|
||||
char *time_pref = prefs_get_string(PREF_TIME);
|
||||
if (g_strcmp0(time_pref, "minutes") == 0) {
|
||||
date_fmt = g_date_time_format(time, "%H:%M");
|
||||
} else if (g_strcmp0(time_pref, "seconds") == 0) {
|
||||
date_fmt = g_date_time_format(time, "%H:%M:%S");
|
||||
}
|
||||
date_fmt = g_date_time_format(time, time_pref);
|
||||
free(time_pref);
|
||||
|
||||
if (date_fmt) {
|
||||
if (date_fmt && strlen(date_fmt)) {
|
||||
if ((flags & NO_COLOUR_DATE) == 0) {
|
||||
wattron(window->layout->win, theme_attrs(THEME_TIME));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user