mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Add option to display MUC name or JID in titlebar
Add `/titlebar use [name|jid]`.
This commit is contained in:
parent
0401412c64
commit
56b7482b08
@ -205,6 +205,7 @@ static Autocomplete pgp_log_ac;
|
||||
static Autocomplete tls_ac;
|
||||
static Autocomplete titlebar_ac;
|
||||
static Autocomplete titlebar_show_ac;
|
||||
static Autocomplete titlebar_use_ac;
|
||||
static Autocomplete tls_certpath_ac;
|
||||
static Autocomplete script_ac;
|
||||
static Autocomplete script_show_ac;
|
||||
@ -791,6 +792,7 @@ cmd_ac_init(void)
|
||||
autocomplete_add(titlebar_ac, "down");
|
||||
autocomplete_add(titlebar_ac, "show");
|
||||
autocomplete_add(titlebar_ac, "hide");
|
||||
autocomplete_add(titlebar_ac, "use");
|
||||
|
||||
titlebar_show_ac = autocomplete_new();
|
||||
autocomplete_add(titlebar_show_ac, "tls");
|
||||
@ -798,6 +800,10 @@ cmd_ac_init(void)
|
||||
autocomplete_add(titlebar_show_ac, "resource");
|
||||
autocomplete_add(titlebar_show_ac, "presence");
|
||||
|
||||
titlebar_use_ac = autocomplete_new();
|
||||
autocomplete_add(titlebar_use_ac, "name");
|
||||
autocomplete_add(titlebar_use_ac, "jid");
|
||||
|
||||
tls_certpath_ac = autocomplete_new();
|
||||
autocomplete_add(tls_certpath_ac, "set");
|
||||
autocomplete_add(tls_certpath_ac, "clear");
|
||||
@ -1202,6 +1208,7 @@ cmd_ac_reset(ProfWin *window)
|
||||
autocomplete_reset(tls_ac);
|
||||
autocomplete_reset(titlebar_ac);
|
||||
autocomplete_reset(titlebar_show_ac);
|
||||
autocomplete_reset(titlebar_use_ac);
|
||||
autocomplete_reset(tls_certpath_ac);
|
||||
autocomplete_reset(console_ac);
|
||||
autocomplete_reset(console_msg_ac);
|
||||
@ -1343,6 +1350,7 @@ cmd_ac_uninit(void)
|
||||
autocomplete_free(tls_ac);
|
||||
autocomplete_free(titlebar_ac);
|
||||
autocomplete_free(titlebar_show_ac);
|
||||
autocomplete_free(titlebar_use_ac);
|
||||
autocomplete_free(tls_certpath_ac);
|
||||
autocomplete_free(script_ac);
|
||||
autocomplete_free(script_show_ac);
|
||||
@ -2964,6 +2972,11 @@ _titlebar_autocomplete(ProfWin *window, const char *const input, gboolean previo
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/titlebar use", titlebar_use_ac, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/titlebar", titlebar_ac, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
|
@ -1293,7 +1293,8 @@ static struct cmd_t command_defs[] =
|
||||
parse_args, 1, 2, &cons_titlebar_setting,
|
||||
CMD_SUBFUNCS(
|
||||
{ "show", cmd_titlebar_show_hide },
|
||||
{ "hide", cmd_titlebar_show_hide }
|
||||
{ "hide", cmd_titlebar_show_hide },
|
||||
{ "use", cmd_titlebar_use }
|
||||
)
|
||||
CMD_MAINFUNC(cmd_titlebar)
|
||||
CMD_TAGS(
|
||||
@ -1301,7 +1302,9 @@ static struct cmd_t command_defs[] =
|
||||
CMD_SYN(
|
||||
"/titlebar up",
|
||||
"/titlebar down",
|
||||
"/titlebar show|hide [encwarn|resource|tls]")
|
||||
"/titlebar show|hide [encwarn|resource|tls]",
|
||||
"/titlebar use [name|jid]"
|
||||
)
|
||||
CMD_DESC(
|
||||
"Titlebar settings.")
|
||||
CMD_ARGS(
|
||||
@ -1309,12 +1312,15 @@ static struct cmd_t command_defs[] =
|
||||
{ "down", "Move the title bar down the screen." },
|
||||
{ "show tls", "Show or hide TLS indicator in the titlebar." },
|
||||
{ "show encwarn", "Enable or disable the unencrypted warning message in the titlebar." },
|
||||
{ "show resource", "Show or hide the current resource in the titlebar." }
|
||||
{ "show resource", "Show or hide the current resource in the titlebar." },
|
||||
{ "use name", "In case of a MUC. Use the MUC name as title." },
|
||||
{ "use jid", "In case of a MUC. Use the JID as title." }
|
||||
)
|
||||
CMD_EXAMPLES(
|
||||
"/titlebar up",
|
||||
"/titlebar show tls",
|
||||
"/titlebar hide encwarn")
|
||||
"/titlebar hide encwarn",
|
||||
"/titlebar use name")
|
||||
},
|
||||
|
||||
{ "/mainwin",
|
||||
|
@ -5942,6 +5942,31 @@ cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_titlebar_use(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
if (args[1] == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "use") == 0) {
|
||||
if (g_strcmp0(args[1], "jid") == 0) {
|
||||
cons_show("Using MUC JID in titlebar as title.");
|
||||
prefs_set_string(PREF_TITLEBAR_MUC_TITLE, "jid");
|
||||
} else if (g_strcmp0(args[1], "name") == 0) {
|
||||
cons_show("Using MUC name in titlebar as title.");
|
||||
prefs_set_string(PREF_TITLEBAR_MUC_TITLE, "name");
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_mainwin(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
|
@ -146,6 +146,7 @@ gboolean cmd_resource(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_inpblock(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_titlebar(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_titlebar_use(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_mainwin(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_statusbar(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_inputwin(ProfWin *window, const char *const command, gchar **args);
|
||||
|
@ -1719,6 +1719,7 @@ _get_group(preference_t pref)
|
||||
case PREF_STATUSBAR_SELF:
|
||||
case PREF_STATUSBAR_CHAT:
|
||||
case PREF_STATUSBAR_ROOM:
|
||||
case PREF_TITLEBAR_MUC_TITLE:
|
||||
return PREF_GROUP_UI;
|
||||
case PREF_STATES:
|
||||
case PREF_OUTTYPE:
|
||||
@ -1961,6 +1962,8 @@ _get_key(preference_t pref)
|
||||
return "inpblock.dynamic";
|
||||
case PREF_ENC_WARN:
|
||||
return "enc.warn";
|
||||
case PREF_TITLEBAR_MUC_TITLE:
|
||||
return "titlebar.muc.title";
|
||||
case PREF_PGP_LOG:
|
||||
return "log";
|
||||
case PREF_TLS_CERTPATH:
|
||||
@ -2087,6 +2090,8 @@ _get_default_string(preference_t pref)
|
||||
return "none";
|
||||
case PREF_ROSTER_ROOMS_USE_AS_NAME:
|
||||
return "name";
|
||||
case PREF_TITLEBAR_MUC_TITLE:
|
||||
return "name";
|
||||
case PREF_ROSTER_ROOMS_ORDER:
|
||||
return "name";
|
||||
case PREF_ROSTER_ROOMS_UNREAD:
|
||||
|
@ -137,6 +137,7 @@ typedef enum {
|
||||
PREF_RESOURCE_MESSAGE,
|
||||
PREF_INPBLOCK_DYNAMIC,
|
||||
PREF_ENC_WARN,
|
||||
PREF_TITLEBAR_MUC_TITLE,
|
||||
PREF_PGP_LOG,
|
||||
PREF_TLS_CERTPATH,
|
||||
PREF_TLS_SHOW,
|
||||
|
@ -309,6 +309,7 @@ _load_preferences(void)
|
||||
_set_boolean_preference("presence", PREF_PRESENCE);
|
||||
_set_boolean_preference("intype", PREF_INTYPE);
|
||||
_set_boolean_preference("enc.warn", PREF_ENC_WARN);
|
||||
_set_boolean_preference("titlebar.muc.title", PREF_TITLEBAR_MUC_TITLE);
|
||||
_set_boolean_preference("tls.show", PREF_TLS_SHOW);
|
||||
_set_boolean_preference("statusbar.show.name", PREF_STATUSBAR_SHOW_NAME);
|
||||
_set_boolean_preference("statusbar.show.number", PREF_STATUSBAR_SHOW_NUMBER);
|
||||
|
@ -1158,6 +1158,10 @@ cons_titlebar_setting(void)
|
||||
} else {
|
||||
cons_show("Titlebar presence (/titlebar) : OFF");
|
||||
}
|
||||
|
||||
char *muctitle = prefs_get_string(PREF_TITLEBAR_MUC_TITLE);
|
||||
cons_show("MUC window title (/titlebar) : %s", muctitle);
|
||||
prefs_free_string(muctitle);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -190,14 +190,26 @@ _title_bar_draw(void)
|
||||
waddch(win, ' ');
|
||||
}
|
||||
|
||||
char *title;
|
||||
char *title = NULL;
|
||||
if (current && current->type == WIN_MUC) {
|
||||
ProfMucWin *mucwin = (ProfMucWin*) current;
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
title = strdup(mucwin->room_name);
|
||||
} else {
|
||||
char *use_as_name = prefs_get_string(PREF_TITLEBAR_MUC_TITLE);
|
||||
|
||||
if ((g_strcmp0(use_as_name, "name") == 0)) {
|
||||
ProfMucWin *mucwin = (ProfMucWin*) current;
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
|
||||
if (mucwin->room_name) {
|
||||
title = strdup(mucwin->room_name);
|
||||
}
|
||||
}
|
||||
|
||||
prefs_free_string(use_as_name);
|
||||
}
|
||||
|
||||
if (title == NULL) {
|
||||
title = win_get_title(current);
|
||||
}
|
||||
|
||||
mvwprintw(win, 0, 0, " %s", title);
|
||||
free(title);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user