From b3be26a21406b549426f6c94c91e8b2a6bf32701 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 10 Feb 2015 23:16:09 +0000 Subject: Updated copyright --- src/ui/statusbar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/statusbar.c') diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 2ef20913..58f3fc58 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -1,7 +1,7 @@ /* * statusbar.c * - * Copyright (C) 2012 - 2014 James Booth + * Copyright (C) 2012 - 2015 James Booth * * This file is part of Profanity. * -- cgit 1.4.1-2-gfad0 From a1d14c4526a8d47adeef254cf0ae9142ae2b13b3 Mon Sep 17 00:00:00 2001 From: Christian Storm Date: Tue, 17 Feb 2015 10:52:37 +0100 Subject: Fixed spelling. --- src/chat_session.c | 2 +- src/command/command.c | 32 ++++++++++++++++---------------- src/config/accounts.c | 2 +- src/muc.c | 2 +- src/roster_list.c | 10 +++++----- src/tools/parser.c | 10 +++++----- src/ui/console.c | 2 +- src/ui/core.c | 8 ++++---- src/ui/statusbar.c | 4 ++-- src/ui/window.c | 2 +- src/xmpp/presence.c | 2 +- 11 files changed, 38 insertions(+), 38 deletions(-) (limited to 'src/ui/statusbar.c') diff --git a/src/chat_session.c b/src/chat_session.c index 555452cb..8ce2e437 100644 --- a/src/chat_session.c +++ b/src/chat_session.c @@ -141,7 +141,7 @@ chat_session_recipient_active(const char * const barejid, const char * const res // session exists with resource, update chat_states if (g_strcmp0(session->resource, resource) == 0) { session->send_states = send_states; - // session exists with differet resource and no override, replace + // session exists with different resource and no override, replace } else if (!session->resource_override) { _chat_session_new(barejid, resource, FALSE, send_states); } diff --git a/src/command/command.c b/src/command/command.c index 4411487d..944a9b8d 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -290,7 +290,7 @@ static struct cmd_t command_defs[] = "nick value - Nickname to use in the room", "password value - Password if the room requires it.", "", - "If no nickname is specfied the account preference 'muc.nick' will be used which by default is the localpart of your JID.", + "If no nickname is specified the account preference 'muc.nick' will be used which by default is the localpart of your JID.", "If the room doesn't exist, and the server allows it, a new one will be created.", NULL } } }, @@ -318,7 +318,7 @@ static struct cmd_t command_defs[] = { "/invites", "Show outstanding chat room invites.", { "/invites", "--------", - "Show all rooms that you have been invited to, and not accepted or declind.", + "Show all rooms that you have been invited to, and not accepted or declined.", NULL } } }, { "/decline", @@ -326,7 +326,7 @@ static struct cmd_t command_defs[] = { "/decline room", "Decline a chat room invite.", { "/decline room", "-------------", - "Decline a chat room ivivation.", + "Decline a chat room invitation.", "", "room - The room for the invite you wish to decline.", NULL } } }, @@ -515,9 +515,9 @@ static struct cmd_t command_defs[] = "Manage subscriptions to contact presence.", "", "request [jid] - Send a subscription request to the user.", - "allow [jid] - Approve a contact's subscription reqeust.", + "allow [jid] - Approve a contact's subscription request.", "deny [jid] - Remove subscription for a contact, or deny a request", - "show [jid] - Show subscriprion status for a contact.", + "show [jid] - Show subscription status for a contact.", "sent - Show all sent subscription requests pending a response.", "received - Show all received subscription requests awaiting your response.", "", @@ -548,7 +548,7 @@ static struct cmd_t command_defs[] = " any - Contacts with any status (same as calling with no argument).", "role - moderator|participant|visitor", "affiliation - owner|admin|member", - "group - Filter the results by the specfied group.", + "group - Filter the results by the specified group.", NULL } } }, { "/close", @@ -633,24 +633,24 @@ static struct cmd_t command_defs[] = " : Valid values are 1-1000.", "dynamic : Start with a 0 timeout and increase the value dynamically up to the specified 'timeout'.", " : on|off", - "A higher timeout will result in less CPU usage, but a noticable delay for response to input.", + "A higher timeout will result in less CPU usage, but a noticeable delay for response to input.", "A lower timeout will result in higher CPU usage, but faster response to input.", "Using the dynamic setting, higher CPU usage will occur during activity, but over time the CPU usage will decrease whilst there is no activity.", NULL } } }, { "/notify", cmd_notify, parse_args, 2, 3, &cons_notify_setting, - { "/notify [type value]|[type setting value]", "Control various desktop noficiations.", + { "/notify [type value]|[type setting value]", "Control various desktop notifications.", { "/notify [type value]|[type setting value]", "-----------------------------------------", "Settings for various desktop notifications where type is one of:", - "message : Notificaitons for regular messages.", + "message : Notifications for regular messages.", " : on|off", "message current : Whether messages in the current window trigger notifications.", " : on|off", "message text : Show message text in message notifications.", " : on|off", - "room : Notificaitons for chat room messages.", + "room : Notifications for chat room messages.", " : on|off|mention", "room current : Whether chat room messages in the current window trigger notifications.", " : on|off", @@ -661,7 +661,7 @@ static struct cmd_t command_defs[] = " : use 0 to disable.", "typing : Notifications when contacts are typing.", " : on|off", - "typing current : Whether typing notifications are triggerd for the current window.", + "typing current : Whether typing notifications are triggered for the current window.", " : on|off", "invite : Notifications for chat room invites.", " : on|off", @@ -742,7 +742,7 @@ static struct cmd_t command_defs[] = { "/mouse on|off", "-------------", "If set to 'on', profanity will handle mouse actions, which enables scrolling the main window with the mouse wheel.", - "To select text, use the shift key while selcting an area.", + "To select text, use the shift key while selecting an area.", "If set to 'off', profanity leaves mouse handling to the terminal implementation.", "This feature is experimental, certain mouse click events may occasionally freeze", "Profanity until a key is pressed or another mouse event is received", @@ -804,13 +804,13 @@ static struct cmd_t command_defs[] = "start [contact] - Start an OTR session with the contact, or the current recipient if in a chat window and no argument supplied.", "end - End the current OTR session,", "trust - Indicate that you have verified the contact's fingerprint.", - "untrust - Indicate the the contact's fingerprint is not verified,", + "untrust - Indicate the contact's fingerprint is not verified,", "log - How to log OTR messages, options are 'on', 'off' and 'redact', with redaction being the default.", "warn - Show when unencrypted messaging is being used in the title bar, options are 'on' and 'off' with 'on' being the default.", "libver - Show which version of the libotr library is being used.", "policy - manual, opportunistic or always.", "secret [secret]- Verify a contacts identity using a shared secret.", - "question [question] [answer] - Verify a contacts identity using a question and expected anwser, if the question has spaces, surround with double quotes.", + "question [question] [answer] - Verify a contacts identity using a question and expected answer, if the question has spaces, surround with double quotes.", "answer [answer] - Respond to a question answer verification request with your answer.", NULL } } }, @@ -876,9 +876,9 @@ static struct cmd_t command_defs[] = { "/ping", cmd_ping, parse_args, 0, 1, NULL, { "/ping [target]", "Send ping IQ request.", - { "/ping [rarget]", + { "/ping [target]", "--------------", - "Sends an IQ ping stanza to the specificed target.", + "Sends an IQ ping stanza to the specified target.", "If no target is supplied, your chat server will be used.", NULL } } }, diff --git a/src/config/accounts.c b/src/config/accounts.c index dd0d6eb4..6c04549c 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -828,7 +828,7 @@ _fix_legacy_accounts(const char * const account_name) _save_accounts(); } - // acounts with no muc service or nick + // accounts with no muc service or nick if (!g_key_file_has_key(accounts, account_name, "muc.service", NULL)) { gchar *account_jid = g_key_file_get_string(accounts, account_name, "jid", NULL); Jid *jidp = jid_create(account_jid); diff --git a/src/muc.c b/src/muc.c index 0d606873..ea4ae915 100644 --- a/src/muc.c +++ b/src/muc.c @@ -315,7 +315,7 @@ muc_nick_change_pending(const char * const room) } /* - * Change the current nuck name for the room, call once + * Change the current nick name for the room, call once * the service has responded */ void diff --git a/src/roster_list.c b/src/roster_list.c index 4ec5ea4f..b9a142cb 100644 --- a/src/roster_list.c +++ b/src/roster_list.c @@ -286,7 +286,7 @@ roster_get_contacts_by_presence(const char * const presence) } } - // resturn all contact structs + // return all contact structs return result; } @@ -303,7 +303,7 @@ roster_get_contacts(void) result = g_slist_insert_sorted(result, value, (GCompareFunc)_compare_contacts); } - // resturn all contact structs + // return all contact structs return result; } @@ -321,7 +321,7 @@ roster_get_contacts_online(void) result = g_slist_insert_sorted(result, value, (GCompareFunc)_compare_contacts); } - // resturn all contact structs + // return all contact structs return result; } @@ -371,7 +371,7 @@ roster_get_nogroup(void) } } - // resturn all contact structs + // return all contact structs return result; } @@ -395,7 +395,7 @@ roster_get_group(const char * const group) } } - // resturn all contact structs + // return all contact structs return result; } diff --git a/src/tools/parser.c b/src/tools/parser.c index 98fc21d4..1f8a5220 100644 --- a/src/tools/parser.c +++ b/src/tools/parser.c @@ -47,9 +47,9 @@ * * inp - The line of input * min - The minimum allowed number of arguments - * max - The maxmimum allowed number of arguments + * max - The maximum allowed number of arguments * - * Returns - An NULL terminated array of strings representing the aguments + * Returns - An NULL terminated array of strings representing the arguments * of the command, or NULL if the validation fails. * * E.g. the following input line: @@ -69,7 +69,7 @@ parse_args(const char * const inp, int min, int max, gboolean *result) return NULL; } - // copy and strip input of leading/trailing whitepsace + // copy and strip input of leading/trailing whitespace char *copy = strdup(inp); g_strstrip(copy); @@ -181,9 +181,9 @@ parse_args(const char * const inp, int min, int max, gboolean *result) * * inp - The line of input * min - The minimum allowed number of arguments - * max - The maxmimum allowed number of arguments + * max - The maximum allowed number of arguments * - * Returns - An NULL terminated array of strings representing the aguments + * Returns - An NULL terminated array of strings representing the arguments * of the command, or NULL if the validation fails. * * E.g. the following input line: diff --git a/src/ui/console.c b/src/ui/console.c index 01d1c73a..ef7df667 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -723,7 +723,7 @@ cons_show_account(ProfAccount *account) if (curr != NULL) { win_save_println(console, "Resources:"); - // sort in order of availabiltiy + // sort in order of availability while (curr != NULL) { Resource *resource = curr->data; ordered_resources = g_list_insert_sorted(ordered_resources, diff --git a/src/ui/core.c b/src/ui/core.c index fc6c0ed4..b5d32c73 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1871,7 +1871,7 @@ ui_room_message(const char * const roomjid, const char * const nick, if (wins_is_current(window)) { status_bar_active(num); - // not currenlty on groupchat window + // not currently on groupchat window } else { status_bar_new(num); cons_show_incoming_message(nick, num); @@ -1955,7 +1955,7 @@ ui_room_requires_config(const char * const roomjid) if (wins_is_current(window)) { status_bar_active(num); - // not currenlty on groupchat window + // not currently on groupchat window } else { status_bar_new(num); } @@ -2096,7 +2096,7 @@ ui_room_subject(const char * const roomjid, const char * const nick, const char if (wins_is_current(window)) { status_bar_active(num); - // not currenlty on groupchat window + // not currently on groupchat window } else { status_bar_active(num); } @@ -2130,7 +2130,7 @@ ui_room_broadcast(const char * const roomjid, const char * const message) if (wins_is_current(window)) { status_bar_active(num); - // not currenlty on groupchat window + // not currently on groupchat window } else { status_bar_new(num); } diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 58f3fc58..b9244fcd 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -192,7 +192,7 @@ status_bar_inactive(const int win) is_new[11] = TRUE; _mark_new(11); - // still have active winsows + // still have active windows } else if (g_hash_table_size(remaining_active) != 0) { is_active[11] = TRUE; is_new[11] = FALSE; @@ -241,7 +241,7 @@ status_bar_active(const int win) _mark_active(11); } - // visible winsow indicators + // visible window indicators } else { is_active[true_win] = TRUE; is_new[true_win] = FALSE; diff --git a/src/ui/window.c b/src/ui/window.c index 85cc875c..d683312b 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -690,7 +690,7 @@ win_show_info(ProfWin *window, PContact contact) if (resources != NULL) { win_save_print(window, '-', NULL, 0, 0, "", "Resources:"); - // sort in order of availabiltiy + // sort in order of availability GList *curr = resources; while (curr != NULL) { Resource *resource = curr->data; diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index a0d9e0f1..f4c45318 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -517,7 +517,7 @@ _handle_caps(char *jid, XMPPCaps *caps) } } - // unsupported hash, xep-0115, assoiciate with JID, no cache + // unsupported hash, xep-0115, associate with JID, no cache } else if (caps->hash) { log_info("Hash %s not supported: %s, sending service discovery request", caps->hash, jid); char *id = create_unique_id("caps"); -- cgit 1.4.1-2-gfad0 From e5bb12a0d6223e6c6297c1700914332942a4ca00 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 10 Mar 2015 23:35:08 +0000 Subject: Added /time statusbar preference --- src/command/command.c | 50 ++++++++++++++++++++++++++++++++++++------ src/command/commands.c | 56 +++++++++++++++++++++++++++++++++--------------- src/config/preferences.c | 5 +++++ src/config/preferences.h | 1 + src/config/theme.c | 1 + src/ui/console.c | 10 +++++++++ src/ui/statusbar.c | 54 +++++++++++++++++++++++++++++++++++----------- themes/boothj5 | 1 + themes/complex | 1 + themes/simple | 1 + 10 files changed, 144 insertions(+), 36 deletions(-) (limited to 'src/ui/statusbar.c') diff --git a/src/command/command.c b/src/command/command.c index 6a5603ee..2186d224 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -102,6 +102,7 @@ static char * _role_autocomplete(const char * const input); static char * _resource_autocomplete(const char * const input); static char * _titlebar_autocomplete(const char * const input); static char * _inpblock_autocomplete(const char * const input); +static char * _time_autocomplete(const char * const input); GHashTable *commands = NULL; @@ -681,11 +682,18 @@ static struct cmd_t command_defs[] = 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.", + cmd_time, parse_args, 1, 2, &cons_time_setting, + { "/time setting|statusbar [setting]", "Time display.", + { "/time setting|statusbar [setting]", + "---------------------------------", + "Configure time display preferences.", + "", + "minutes : Use minutes precision in main window.", + "seconds : Use seconds precision in main window.", + "off : Do not show time in main window.", + "statusbar minutes : Show minutes precision in status bar.", + "statusbar seconds : Show seconds precision in status bar.", + "statusbar off : Do not show time in status bar.", NULL } } }, { "/inpblock", @@ -1180,6 +1188,7 @@ static Autocomplete form_field_multi_ac; static Autocomplete occupants_ac; static Autocomplete occupants_default_ac; static Autocomplete time_ac; +static Autocomplete time_statusbar_ac; static Autocomplete resource_ac; static Autocomplete inpblock_ac; @@ -1523,6 +1532,12 @@ cmd_init(void) autocomplete_add(time_ac, "minutes"); autocomplete_add(time_ac, "seconds"); autocomplete_add(time_ac, "off"); + autocomplete_add(time_ac, "statusbar"); + + time_statusbar_ac = autocomplete_new(); + autocomplete_add(time_statusbar_ac, "minutes"); + autocomplete_add(time_statusbar_ac, "seconds"); + autocomplete_add(time_statusbar_ac, "off"); resource_ac = autocomplete_new(); autocomplete_add(resource_ac, "set"); @@ -1587,6 +1602,7 @@ cmd_uninit(void) autocomplete_free(occupants_ac); autocomplete_free(occupants_default_ac); autocomplete_free(time_ac); + autocomplete_free(time_statusbar_ac); autocomplete_free(resource_ac); autocomplete_free(inpblock_ac); } @@ -1752,6 +1768,7 @@ cmd_reset_autocomplete() autocomplete_reset(occupants_ac); autocomplete_reset(occupants_default_ac); autocomplete_reset(time_ac); + autocomplete_reset(time_statusbar_ac); autocomplete_reset(resource_ac); autocomplete_reset(inpblock_ac); @@ -2067,8 +2084,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); @@ -2103,6 +2120,7 @@ _cmd_complete_parameters(const char * const input) g_hash_table_insert(ac_funcs, "/resource", _resource_autocomplete); g_hash_table_insert(ac_funcs, "/titlebar", _titlebar_autocomplete); g_hash_table_insert(ac_funcs, "/inpblock", _inpblock_autocomplete); + g_hash_table_insert(ac_funcs, "/time", _time_autocomplete); int len = strlen(input); char parsed[len+1]; @@ -2739,6 +2757,24 @@ _occupants_autocomplete(const char * const input) return NULL; } +static char * +_time_autocomplete(const char * const input) +{ + char *found = NULL; + + found = autocomplete_param_with_ac(input, "/time statusbar", time_statusbar_ac, TRUE); + if (found != NULL) { + return found; + } + + found = autocomplete_param_with_ac(input, "/time", time_ac, TRUE); + if (found != NULL) { + return found; + } + + return NULL; +} + static char * _kick_autocomplete(const char * const input) { diff --git a/src/command/commands.c b/src/command/commands.c index 2ca749fb..1851a3f4 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -3270,24 +3270,46 @@ 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; + if (g_strcmp0(args[0], "statusbar") == 0) { + if (g_strcmp0(args[1], "minutes") == 0) { + prefs_set_string(PREF_TIME_STATUSBAR, "minutes"); + cons_show("Status bar time precision set to minutes."); + ui_redraw(); + return TRUE; + } else if (g_strcmp0(args[1], "seconds") == 0) { + prefs_set_string(PREF_TIME_STATUSBAR, "seconds"); + cons_show("Status bar time precision set to seconds."); + ui_redraw(); + return TRUE; + } else if (g_strcmp0(args[1], "off") == 0) { + prefs_set_string(PREF_TIME_STATUSBAR, "off"); + cons_show("Status bar time display disabled."); + ui_redraw(); + return TRUE; + } else { + cons_show("Usage: %s", help.usage); + return TRUE; + } } else { - cons_show("Usage: %s", help.usage); - return TRUE; + 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; + } } } diff --git a/src/config/preferences.c b/src/config/preferences.c index eb610732..0dbfe3e3 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -507,6 +507,7 @@ _get_group(preference_t pref) case PREF_PRESENCE: case PREF_WRAP: case PREF_TIME: + case PREF_TIME_STATUSBAR: case PREF_ROSTER: case PREF_ROSTER_OFFLINE: case PREF_ROSTER_RESOURCE: @@ -646,6 +647,8 @@ _get_key(preference_t pref) return "wrap"; case PREF_TIME: return "time"; + case PREF_TIME_STATUSBAR: + return "time.statusbar"; case PREF_ROSTER: return "roster"; case PREF_ROSTER_OFFLINE: @@ -722,6 +725,8 @@ _get_default_string(preference_t pref) return "presence"; case PREF_TIME: return "seconds"; + case PREF_TIME_STATUSBAR: + return "minutes"; default: return NULL; } diff --git a/src/config/preferences.h b/src/config/preferences.h index 61a35c8a..7b29ae33 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -72,6 +72,7 @@ typedef enum { PREF_PRESENCE, PREF_WRAP, PREF_TIME, + PREF_TIME_STATUSBAR, PREF_STATUSES, PREF_STATUSES_CONSOLE, PREF_STATUSES_CHAT, diff --git a/src/config/theme.c b/src/config/theme.c index d2bf0a48..3aeadf40 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -426,6 +426,7 @@ _load_preferences(void) _set_boolean_preference("splash", PREF_SPLASH); _set_boolean_preference("wrap", PREF_WRAP); _set_string_preference("time", PREF_TIME); + _set_string_preference("time.statusbar", PREF_TIME_STATUSBAR); _set_boolean_preference("resource.title", PREF_RESOURCE_TITLE); _set_boolean_preference("resource.message", PREF_RESOURCE_MESSAGE); diff --git a/src/ui/console.c b/src/ui/console.c index 745a12ee..dc8a3c7b 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -934,6 +934,16 @@ cons_time_setting(void) cons_show("Time (/time) : seconds"); prefs_free_string(pref_time); + + char *pref_time_statusbar = prefs_get_string(PREF_TIME_STATUSBAR); + if (g_strcmp0(pref_time_statusbar, "minutes") == 0) + cons_show("Time statusbar (/time) : minutes"); + else if (g_strcmp0(pref_time_statusbar, "off") == 0) + cons_show("Time statusbar (/time) : OFF"); + else + cons_show("Time statusbar (/time) : seconds"); + + prefs_free_string(pref_time_statusbar); } void diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index b9244fcd..93eeaab0 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -48,6 +48,7 @@ #include "ui/ui.h" #include "ui/statusbar.h" #include "ui/inputwin.h" +#include "config/preferences.h" #define TIME_CHECK 60000000 @@ -127,7 +128,14 @@ status_bar_resize(void) wattroff(status_bar, bracket_attrs); if (message != NULL) { - mvwprintw(status_bar, 0, 10, message); + char *time_pref = prefs_get_string(PREF_TIME_STATUSBAR); + if (g_strcmp0(time_pref, "minutes") == 0) { + mvwprintw(status_bar, 0, 10, message); + } else if (g_strcmp0(time_pref, "seconds") == 0) { + mvwprintw(status_bar, 0, 13, message); + } else { + mvwprintw(status_bar, 0, 1, message); + } } if (last_time != NULL) { g_date_time_unref(last_time); @@ -293,7 +301,15 @@ status_bar_print_message(const char * const msg) free(message); } message = strdup(msg); - mvwprintw(status_bar, 0, 10, message); + + char *time_pref = prefs_get_string(PREF_TIME_STATUSBAR); + if (g_strcmp0(time_pref, "minutes") == 0) { + mvwprintw(status_bar, 0, 10, message); + } else if (g_strcmp0(time_pref, "seconds") == 0) { + mvwprintw(status_bar, 0, 13, message); + } else { + mvwprintw(status_bar, 0, 1, message); + } int cols = getmaxx(stdscr); int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET); @@ -416,19 +432,33 @@ _status_bar_draw(void) g_date_time_unref(last_time); } last_time = g_date_time_new_now_local(); - gchar *date_fmt = g_date_time_format(last_time, "%H:%M"); - assert(date_fmt != NULL); int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET); - wattron(status_bar, bracket_attrs); - mvwaddch(status_bar, 0, 1, '['); - wattroff(status_bar, bracket_attrs); - mvwprintw(status_bar, 0, 2, date_fmt); - wattron(status_bar, bracket_attrs); - mvwaddch(status_bar, 0, 7, ']'); - wattroff(status_bar, bracket_attrs); - g_free(date_fmt); + char *time_pref = prefs_get_string(PREF_TIME_STATUSBAR); + if (g_strcmp0(time_pref, "minutes") == 0) { + gchar *date_fmt = g_date_time_format(last_time, "%H:%M"); + assert(date_fmt != NULL); + wattron(status_bar, bracket_attrs); + mvwaddch(status_bar, 0, 1, '['); + wattroff(status_bar, bracket_attrs); + mvwprintw(status_bar, 0, 2, date_fmt); + wattron(status_bar, bracket_attrs); + mvwaddch(status_bar, 0, 7, ']'); + wattroff(status_bar, bracket_attrs); + g_free(date_fmt); + } else if (g_strcmp0(time_pref, "seconds") == 0) { + gchar *date_fmt = g_date_time_format(last_time, "%H:%M:%S"); + assert(date_fmt != NULL); + wattron(status_bar, bracket_attrs); + mvwaddch(status_bar, 0, 1, '['); + wattroff(status_bar, bracket_attrs); + mvwprintw(status_bar, 0, 2, date_fmt); + wattron(status_bar, bracket_attrs); + mvwaddch(status_bar, 0, 10, ']'); + wattroff(status_bar, bracket_attrs); + g_free(date_fmt); + } _update_win_statuses(); wnoutrefresh(status_bar); diff --git a/themes/boothj5 b/themes/boothj5 index cd6379cd..49231ab0 100644 --- a/themes/boothj5 +++ b/themes/boothj5 @@ -54,6 +54,7 @@ flash=false splash=true wrap=true time=seconds +time.statusbar=seconds privileges=true presence=true intype=true diff --git a/themes/complex b/themes/complex index a2695a1f..61f6a270 100644 --- a/themes/complex +++ b/themes/complex @@ -4,6 +4,7 @@ flash=false splash=true wrap=true time=seconds +time.statusbar=seconds resource.title=true resource.message=true statuses.console=all diff --git a/themes/simple b/themes/simple index 0b9baab5..2885db12 100644 --- a/themes/simple +++ b/themes/simple @@ -4,6 +4,7 @@ flash=false splash=true wrap=true time=minutes +time.statusbar=off resource.title=false resource.message=false statuses.console=none -- cgit 1.4.1-2-gfad0 From bf5646aee31864945c767eeb676c0de84756051a Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 4 May 2015 23:07:36 +0100 Subject: Use null check convention in statusbar.c --- src/ui/statusbar.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/ui/statusbar.c') diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 93eeaab0..581e63df 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -95,7 +95,7 @@ create_status_bar(void) mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); wattroff(status_bar, bracket_attrs); - if (last_time != NULL) { + if (last_time) { g_date_time_unref(last_time); } last_time = g_date_time_new_now_local(); @@ -127,7 +127,7 @@ status_bar_resize(void) mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); wattroff(status_bar, bracket_attrs); - if (message != NULL) { + if (message) { char *time_pref = prefs_get_string(PREF_TIME_STATUSBAR); if (g_strcmp0(time_pref, "minutes") == 0) { mvwprintw(status_bar, 0, 10, message); @@ -137,7 +137,7 @@ status_bar_resize(void) mvwprintw(status_bar, 0, 1, message); } } - if (last_time != NULL) { + if (last_time) { g_date_time_unref(last_time); } last_time = g_date_time_new_now_local(); @@ -297,7 +297,7 @@ status_bar_print_message(const char * const msg) { werase(status_bar); - if (message != NULL) { + if (message) { free(message); } message = strdup(msg); @@ -325,7 +325,7 @@ status_bar_print_message(const char * const msg) void status_bar_clear(void) { - if (message != NULL) { + if (message) { free(message); message = NULL; } @@ -346,7 +346,7 @@ status_bar_clear(void) void status_bar_clear_message(void) { - if (message != NULL) { + if (message) { free(message); message = NULL; } @@ -428,7 +428,7 @@ _mark_inactive(int num) static void _status_bar_draw(void) { - if (last_time != NULL) { + if (last_time) { g_date_time_unref(last_time); } last_time = g_date_time_new_now_local(); -- cgit 1.4.1-2-gfad0