diff options
author | James Booth <boothj5@gmail.com> | 2014-11-16 00:40:54 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-11-16 00:40:54 +0000 |
commit | 40dc8e2c495deac830403872346dff9dd2b24499 (patch) | |
tree | b5d15c22eec80ce7c637721b61ac2ce92955e440 | |
parent | 1479a5e134004568245996a22418dadb6b6da6f6 (diff) | |
download | profani-tty-40dc8e2c495deac830403872346dff9dd2b24499.tar.gz |
Added /time setting
-rw-r--r-- | src/command/command.c | 19 | ||||
-rw-r--r-- | src/command/commands.c | 19 | ||||
-rw-r--r-- | src/command/commands.h | 1 | ||||
-rw-r--r-- | src/config/preferences.c | 5 | ||||
-rw-r--r-- | src/config/preferences.h | 1 | ||||
-rw-r--r-- | src/ui/console.c | 14 | ||||
-rw-r--r-- | src/ui/ui.h | 1 |
7 files changed, 58 insertions, 2 deletions
diff --git a/src/command/command.c b/src/command/command.c index f4add150..76f8d5e0 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -597,6 +597,14 @@ static struct cmd_t command_defs[] = "Enable or disable word wrapping.", NULL } } }, + { "/time", + cmd_time, parse_args, 1, 1, &cons_time_setting, + { "/time minutes|seconds", "Time display.", + { "/time minutes|seconds", + "---------------------", + "Configure time precision for the main window.", + NULL } } }, + { "/notify", cmd_notify, parse_args, 2, 3, &cons_notify_setting, { "/notify [type value]|[type setting value]", "Control various desktop noficiations.", @@ -1071,6 +1079,7 @@ static Autocomplete form_ac; static Autocomplete form_field_multi_ac; static Autocomplete occupants_ac; static Autocomplete occupants_default_ac; +static Autocomplete time_ac; /* * Initialise command autocompleter and history @@ -1397,6 +1406,10 @@ 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"); + cmd_history_init(); } @@ -1450,6 +1463,7 @@ cmd_uninit(void) autocomplete_free(form_field_multi_ac); autocomplete_free(occupants_ac); autocomplete_free(occupants_default_ac); + autocomplete_free(time_ac); } gboolean @@ -1620,6 +1634,7 @@ cmd_reset_autocomplete() autocomplete_reset(form_field_multi_ac); autocomplete_reset(occupants_ac); autocomplete_reset(occupants_default_ac); + autocomplete_reset(time_ac); if (ui_current_win_type() == WIN_MUC_CONFIG) { ProfWin *window = wins_get_current(); @@ -1885,8 +1900,8 @@ _cmd_complete_parameters(char *input, int *size) } } - 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 }; + 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 }; for (i = 0; i < ARRAY_SIZE(cmds); i++) { result = autocomplete_param_with_ac(input, size, cmds[i], completers[i], TRUE); diff --git a/src/command/commands.c b/src/command/commands.c index 3ae0015d..2393a72c 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -3031,6 +3031,25 @@ 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 { + cons_show("Usage: %s", help.usage); + return TRUE; + } +} + +gboolean cmd_states(gchar **args, struct cmd_help_t help) { gboolean result = _cmd_set_boolean_preference(args[0], help, "Sending chat states", diff --git a/src/command/commands.h b/src/command/commands.h index 87c05453..b5646caf 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -134,6 +134,7 @@ gboolean cmd_role(gchar **args, struct cmd_help_t help); gboolean cmd_privileges(gchar **args, struct cmd_help_t help); gboolean cmd_presence(gchar **args, struct cmd_help_t help); gboolean cmd_wrap(gchar **args, struct cmd_help_t help); +gboolean cmd_time(gchar **args, struct cmd_help_t help); gboolean cmd_form_field(char *tag, gchar **args); diff --git a/src/config/preferences.c b/src/config/preferences.c index 60d6d831..baf3e853 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -491,6 +491,7 @@ _get_group(preference_t pref) case PREF_MUC_PRIVILEGES: case PREF_PRESENCE: case PREF_WRAP: + case PREF_TIME: case PREF_ROSTER: case PREF_ROSTER_OFFLINE: case PREF_ROSTER_RESOURCE: @@ -615,6 +616,8 @@ _get_key(preference_t pref) return "presence"; case PREF_WRAP: return "wrap"; + case PREF_TIME: + return "time"; case PREF_ROSTER: return "roster"; case PREF_ROSTER_OFFLINE: @@ -670,6 +673,8 @@ _get_default_string(preference_t pref) return "all"; case PREF_ROSTER_BY: return "none"; + case PREF_TIME: + return "seconds"; default: return NULL; } diff --git a/src/config/preferences.h b/src/config/preferences.h index b1536507..d2a3fafd 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -67,6 +67,7 @@ typedef enum { PREF_MUC_PRIVILEGES, PREF_PRESENCE, PREF_WRAP, + PREF_TIME, PREF_STATUSES, PREF_STATUSES_CONSOLE, PREF_STATUSES_CHAT, diff --git a/src/ui/console.c b/src/ui/console.c index 9f9b9e2a..8d4e041e 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -901,6 +901,18 @@ _cons_autoconnect_setting(void) } static 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 + cons_show("Time (/time) : seconds"); + + prefs_free_string(pref_time); +} + +static void _cons_vercheck_setting(void) { if (prefs_get_boolean(PREF_VERCHECK)) @@ -976,6 +988,7 @@ _cons_show_ui_prefs(void) cons_flash_setting(); cons_splash_setting(); cons_wrap_setting(); + cons_time_setting(); cons_vercheck_setting(); cons_mouse_setting(); cons_statuses_setting(); @@ -1594,6 +1607,7 @@ console_init_module(void) cons_privileges_setting = _cons_privileges_setting; cons_beep_setting = _cons_beep_setting; cons_wrap_setting = _cons_wrap_setting; + cons_time_setting = _cons_time_setting; cons_presence_setting = _cons_presence_setting; cons_flash_setting = _cons_flash_setting; cons_splash_setting = _cons_splash_setting; diff --git a/src/ui/ui.h b/src/ui/ui.h index e1f48fbd..d453ce06 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -303,6 +303,7 @@ void (*cons_occupants_setting)(void); void (*cons_roster_setting)(void); void (*cons_presence_setting)(void); void (*cons_wrap_setting)(void); +void (*cons_time_setting)(void); void (*cons_mouse_setting)(void); void (*cons_statuses_setting)(void); void (*cons_titlebar_setting)(void); |