From 1780148f59c33365d1a547cd4b9ad788e80725a0 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 29 Nov 2012 20:34:52 +0000 Subject: [PATCH] Option to show version in title bar with /titlebarversion --- src/command.c | 18 ++++++++++++++++++ src/preferences.c | 13 +++++++++++++ src/preferences.h | 2 ++ src/windows.c | 18 +++++++++++++++--- 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/command.c b/src/command.c index 48aeceb5..c74d2045 100644 --- a/src/command.c +++ b/src/command.c @@ -118,6 +118,7 @@ static gboolean _cmd_set_history(gchar **args, struct cmd_help_t help); static gboolean _cmd_set_states(gchar **args, struct cmd_help_t help); static gboolean _cmd_set_outtype(gchar **args, struct cmd_help_t help); static gboolean _cmd_set_autoping(gchar **args, struct cmd_help_t help); +static gboolean _cmd_set_titlebarversion(gchar **args, struct cmd_help_t help); static gboolean _cmd_vercheck(gchar **args, struct cmd_help_t help); static gboolean _cmd_away(gchar **args, struct cmd_help_t help); static gboolean _cmd_online(gchar **args, struct cmd_help_t help); @@ -429,6 +430,14 @@ static struct cmd_t setting_commands[] = "and each time the /about command is run.", NULL } } }, + { "/titlebarversion", + _cmd_set_titlebarversion, parse_args, 1, 1, + { "/titlebarversion on|off", "Check for a new release.", + { "/titlebarversion on|off", + "------------------", + "Show the version in the title bar of the window.", + NULL } } }, + { "/chlog", _cmd_set_chlog, parse_args, 1, 1, { "/chlog on|off", "Chat logging to file", @@ -911,6 +920,8 @@ _cmd_complete_parameters(char *input, int *size) prefs_autocomplete_boolean_choice); _parameter_autocomplete(input, size, "/vercheck", prefs_autocomplete_boolean_choice); + _parameter_autocomplete(input, size, "/titlebarversion", + prefs_autocomplete_boolean_choice); _parameter_autocomplete(input, size, "/msg", contact_list_find_contact); @@ -1505,6 +1516,13 @@ _cmd_set_states(gchar **args, struct cmd_help_t help) "Sending chat states", prefs_set_states); } +static gboolean +_cmd_set_titlebarversion(gchar **args, struct cmd_help_t help) +{ + return _cmd_set_boolean_preference(args, help, "/titlebarversion", + "Show version in window title", prefs_set_titlebarversion); +} + static gboolean _cmd_set_outtype(gchar **args, struct cmd_help_t help) { diff --git a/src/preferences.c b/src/preferences.c index 91419846..fbae2f8a 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -278,6 +278,19 @@ prefs_set_vercheck(gboolean value) _save_prefs(); } +gboolean +prefs_get_titlebarversion(void) +{ + return g_key_file_get_boolean(prefs, "ui", "titlebarversion", NULL); +} + +void +prefs_set_titlebarversion(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "titlebarversion", value); + _save_prefs(); +} + gboolean prefs_get_flash(void) { diff --git a/src/preferences.h b/src/preferences.h index b871d053..d15608eb 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -57,6 +57,8 @@ gboolean prefs_get_showsplash(void); void prefs_set_showsplash(gboolean value); gboolean prefs_get_vercheck(void); void prefs_set_vercheck(gboolean value); +gboolean prefs_get_titlebarversion(void); +void prefs_set_titlebarversion(gboolean value); gboolean prefs_get_intype(void); void prefs_set_intype(gboolean value); gboolean prefs_get_states(void); diff --git a/src/windows.c b/src/windows.c index 269339c6..821a8ddb 100644 --- a/src/windows.c +++ b/src/windows.c @@ -123,6 +123,16 @@ ui_init(void) void ui_refresh(void) { + GString *version_str = g_string_new(""); + + if (prefs_get_titlebarversion()) { + g_string_append(version_str, " "); + g_string_append(version_str, PACKAGE_VERSION); + if (strcmp(PACKAGE_STATUS, "development") == 0) { + g_string_append(version_str, "dev"); + } + } + jabber_conn_status_t status = jabber_get_connection_status(); if (status == JABBER_CONNECTED) { @@ -130,14 +140,16 @@ ui_refresh(void) gint unread = _win_get_unread(); if (unread != 0) { - printf("%c]0;*%s - %s (%d unread)%c", '\033', "Profanity", jid, unread, '\007'); + printf("%c]0;*%s%s - %s (%d unread)%c", '\033', "Profanity", version_str->str, jid, unread, '\007'); } else { - printf("%c]0;%s - %s%c", '\033', "Profanity", jid, '\007'); + printf("%c]0;%s%s - %s%c", '\033', "Profanity", version_str->str, jid, '\007'); } } else { - printf("%c]0;%s%c", '\033', "Profanity", '\007'); + printf("%c]0;%s%s%c", '\033', "Profanity", version_str->str, '\007'); } + g_string_free(version_str, TRUE); + title_bar_refresh(); status_bar_refresh();