mirror of
https://github.com/profanity-im/profanity.git
synced 2024-10-13 20:13:38 -04:00
titlebar: allow displaying MUC name and MUC jid
`/titlebar use name|jid` -> `/titlebar show|hide name|jid` Fix https://github.com/profanity-im/profanity/issues/1284
This commit is contained in:
parent
fd090d384d
commit
f131680055
@ -210,7 +210,6 @@ static Autocomplete pgp_sendfile_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;
|
||||
@ -825,10 +824,8 @@ cmd_ac_init(void)
|
||||
autocomplete_add(titlebar_show_ac, "encwarn");
|
||||
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");
|
||||
autocomplete_add(titlebar_show_ac, "jid");
|
||||
autocomplete_add(titlebar_show_ac, "name");
|
||||
|
||||
tls_certpath_ac = autocomplete_new();
|
||||
autocomplete_add(tls_certpath_ac, "set");
|
||||
@ -1256,7 +1253,6 @@ 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);
|
||||
@ -1405,7 +1401,6 @@ 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);
|
||||
@ -3085,11 +3080,6 @@ _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;
|
||||
|
@ -1292,8 +1292,7 @@ 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 },
|
||||
{ "use", cmd_titlebar_use }
|
||||
{ "hide", cmd_titlebar_show_hide }
|
||||
)
|
||||
CMD_MAINFUNC(cmd_titlebar)
|
||||
CMD_TAGS(
|
||||
@ -1301,8 +1300,7 @@ static struct cmd_t command_defs[] =
|
||||
CMD_SYN(
|
||||
"/titlebar up",
|
||||
"/titlebar down",
|
||||
"/titlebar show|hide [encwarn|resource|tls]",
|
||||
"/titlebar use name|jid"
|
||||
"/titlebar show|hide [encwarn|resource|tls]"
|
||||
)
|
||||
CMD_DESC(
|
||||
"Titlebar settings.")
|
||||
@ -1312,14 +1310,13 @@ static struct cmd_t command_defs[] =
|
||||
{ "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." },
|
||||
{ "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." }
|
||||
{ "show name", "In case of a MUC. Show the MUC name in the titlebar." },
|
||||
{ "show jid", "In case of a MUC. Show the JID in the titlebar." }
|
||||
)
|
||||
CMD_EXAMPLES(
|
||||
"/titlebar up",
|
||||
"/titlebar show tls",
|
||||
"/titlebar hide encwarn",
|
||||
"/titlebar use name")
|
||||
"/titlebar hide encwarn")
|
||||
},
|
||||
|
||||
{ "/mainwin",
|
||||
|
@ -5958,6 +5958,12 @@ cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args)
|
||||
} else if (g_strcmp0(args[1], "presence") == 0) {
|
||||
cons_show("Showing contact presence in titlebar enabled.");
|
||||
prefs_set_boolean(PREF_PRESENCE , TRUE);
|
||||
} else if (g_strcmp0(args[1], "jid") == 0) {
|
||||
cons_show("Showing MUC JID in titlebar as title enabled.");
|
||||
prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_JID, TRUE);
|
||||
} else if (g_strcmp0(args[1], "name") == 0) {
|
||||
cons_show("Showing MUC name in titlebar as title enabled.");
|
||||
prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_NAME, TRUE);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
@ -5975,6 +5981,12 @@ cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args)
|
||||
} else if (g_strcmp0(args[1], "presence") == 0) {
|
||||
cons_show("Showing contact presence in titlebar enabled.");
|
||||
prefs_set_boolean(PREF_PRESENCE , FALSE);
|
||||
} else if (g_strcmp0(args[1], "jid") == 0) {
|
||||
cons_show("Showing MUC JID in titlebar as title disabled.");
|
||||
prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_JID, FALSE);
|
||||
} else if (g_strcmp0(args[1], "name") == 0) {
|
||||
cons_show("Showing MUC name in titlebar as title disabled.");
|
||||
prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_NAME, FALSE);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
@ -5986,31 +5998,6 @@ 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,7 +146,6 @@ 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);
|
||||
|
@ -149,6 +149,16 @@ static void _prefs_load(void)
|
||||
g_key_file_remove_key(prefs, PREF_GROUP_UI, "titlebar.goodbye", NULL);
|
||||
}
|
||||
|
||||
// after 0.8.1: titlebar use jid|name -> titlebar show|hide jid|name
|
||||
if (g_key_file_has_key(prefs, PREF_GROUP_UI, "titlebar.muc.title", NULL)) {
|
||||
char *value = g_key_file_get_string(prefs, PREF_GROUP_UI, "titlebar.muc.title", NULL);
|
||||
if (g_strcmp0(value, "name") == 0) {
|
||||
g_key_file_set_boolean(prefs, PREF_GROUP_UI, "titlebar.muc.title.name", TRUE);
|
||||
} else if (g_strcmp0(value, "jid") == 0) {
|
||||
g_key_file_set_boolean(prefs, PREF_GROUP_UI, "titlebar.muc.title.jid", TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
_save_prefs();
|
||||
|
||||
boolean_choice_ac = autocomplete_new();
|
||||
@ -1742,7 +1752,8 @@ _get_group(preference_t pref)
|
||||
case PREF_STATUSBAR_SELF:
|
||||
case PREF_STATUSBAR_CHAT:
|
||||
case PREF_STATUSBAR_ROOM:
|
||||
case PREF_TITLEBAR_MUC_TITLE:
|
||||
case PREF_TITLEBAR_MUC_TITLE_JID:
|
||||
case PREF_TITLEBAR_MUC_TITLE_NAME:
|
||||
case PREF_HISTORY_COLOR_MUC:
|
||||
case PREF_SLASH_GUARD:
|
||||
return PREF_GROUP_UI;
|
||||
@ -2000,8 +2011,10 @@ _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_TITLEBAR_MUC_TITLE_JID:
|
||||
return "titlebar.muc.title.jid";
|
||||
case PREF_TITLEBAR_MUC_TITLE_NAME:
|
||||
return "titlebar.muc.title.name";
|
||||
case PREF_PGP_LOG:
|
||||
return "log";
|
||||
case PREF_PGP_SENDFILE:
|
||||
@ -2109,6 +2122,7 @@ _get_default_boolean(preference_t pref)
|
||||
case PREF_CARBONS:
|
||||
case PREF_STATES:
|
||||
case PREF_OUTTYPE:
|
||||
case PREF_TITLEBAR_MUC_TITLE_NAME:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
@ -2146,8 +2160,6 @@ _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:
|
||||
|
@ -140,7 +140,8 @@ typedef enum {
|
||||
PREF_RESOURCE_MESSAGE,
|
||||
PREF_INPBLOCK_DYNAMIC,
|
||||
PREF_ENC_WARN,
|
||||
PREF_TITLEBAR_MUC_TITLE,
|
||||
PREF_TITLEBAR_MUC_TITLE_JID,
|
||||
PREF_TITLEBAR_MUC_TITLE_NAME,
|
||||
PREF_PGP_LOG,
|
||||
PREF_PGP_SENDFILE,
|
||||
PREF_TLS_CERTPATH,
|
||||
|
@ -315,7 +315,8 @@ _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("titlebar.muc.title.name", PREF_TITLEBAR_MUC_TITLE_NAME);
|
||||
_set_boolean_preference("titlebar.muc.title.jid", PREF_TITLEBAR_MUC_TITLE_JID);
|
||||
_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);
|
||||
|
@ -1159,9 +1159,17 @@ cons_titlebar_setting(void)
|
||||
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);
|
||||
if (prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_NAME)) {
|
||||
cons_show("Titlebar show MUC name (/titlebar) : ON");
|
||||
} else {
|
||||
cons_show("Titlebar show MUC name (/titlebar) : OFF");
|
||||
}
|
||||
|
||||
if (prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_JID)) {
|
||||
cons_show("Titlebar show MUC JID (/titlebar) : ON");
|
||||
} else {
|
||||
cons_show("Titlebar show MUC JID (/titlebar) : OFF");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -300,14 +300,21 @@ win_get_title(ProfWin *window)
|
||||
ProfMucWin *mucwin = (ProfMucWin*) window;
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
|
||||
char *use_as_name = prefs_get_string(PREF_TITLEBAR_MUC_TITLE);
|
||||
if ((g_strcmp0(use_as_name, "name") == 0) && mucwin->room_name) {
|
||||
prefs_free_string(use_as_name);
|
||||
return strdup(mucwin->room_name);
|
||||
} else {
|
||||
prefs_free_string(use_as_name);
|
||||
return strdup(mucwin->roomjid);
|
||||
gboolean show_titlebar_jid = prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_JID);
|
||||
gboolean show_titlebar_name = prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_NAME);
|
||||
GString *title = g_string_new("");
|
||||
|
||||
if (show_titlebar_name) {
|
||||
g_string_append(title, mucwin->room_name);
|
||||
g_string_append(title, " ");
|
||||
}
|
||||
if (show_titlebar_jid) {
|
||||
g_string_append(title, mucwin->roomjid);
|
||||
}
|
||||
|
||||
char *title_str = title->str;
|
||||
g_string_free(title, FALSE);
|
||||
return title_str;
|
||||
}
|
||||
if (window->type == WIN_CONFIG) {
|
||||
ProfConfWin *confwin = (ProfConfWin*) window;
|
||||
|
Loading…
Reference in New Issue
Block a user