Added preferences for showing resource in titlebar and messages

This commit is contained in:
James Booth
2015-01-10 19:10:10 +00:00
parent c3ad3c0ba6
commit 31c0f2ba78
9 changed files with 72 additions and 17 deletions

View File

@@ -278,13 +278,15 @@ static struct cmd_t command_defs[] =
NULL } } },
{ "/resource",
cmd_resource, parse_args, 1, 2, NULL,
{ "/resource set|off [resource]", "Set the contact's resource.",
{ "/resource set|off [resource]",
"----------------------------",
"Set the resource to use when chatting to a contact.",
"set resource - Set the resource.",
"off - Let the server choose which resource to route messages to.",
cmd_resource, parse_args, 1, 2, &cons_resource_setting,
{ "/resource set|off|title|message [resource]", "Set the contact's resource.",
{ "/resource set|off|title|message [resource]",
"------------------------------------------",
"Set the resource to use when chatting to a contact and manage resource display settings.",
"set resource - Set the resource.",
"off - Let the server choose which resource to route messages to.",
"title on|off - Show or hide the current resource in the titlebar.",
"message on|off - Show or hide the resource from which a message was recieved.",
NULL } } },
{ "/join",
@@ -1455,6 +1457,8 @@ cmd_init(void)
resource_ac = autocomplete_new();
autocomplete_add(resource_ac, "set");
autocomplete_add(resource_ac, "off");
autocomplete_add(resource_ac, "title");
autocomplete_add(resource_ac, "message");
cmd_history_init();
}
@@ -2462,6 +2466,16 @@ _resource_autocomplete(char *input, int *size)
}
}
found = autocomplete_param_with_func(input, size, "/resource title", prefs_autocomplete_boolean_choice);
if (found != NULL) {
return found;
}
found = autocomplete_param_with_func(input, size, "/resource message", prefs_autocomplete_boolean_choice);
if (found != NULL) {
return found;
}
found = autocomplete_param_with_ac(input, size, "/resource", resource_ac, FALSE);
if (found != NULL) {
return found;

View File

@@ -1582,16 +1582,33 @@ cmd_roster(gchar **args, struct cmd_help_t help)
gboolean
cmd_resource(gchar **args, struct cmd_help_t help)
{
ProfWin *current = wins_get_current();
if (current->type != WIN_CHAT) {
cons_show("The /resource command is only valid in chat windows.");
return TRUE;
char *cmd = args[0];
char *setting = NULL;
if (g_strcmp0(cmd, "message") == 0) {
setting = args[1];
if (!setting) {
cons_show("Usage: %s", help.usage);
return TRUE;
} else {
return _cmd_set_boolean_preference(setting, help, "Message resource", PREF_RESOURCE_MESSAGE);
}
} else if (g_strcmp0(cmd, "title") == 0) {
setting = args[1];
if (!setting) {
cons_show("Usage: %s", help.usage);
return TRUE;
} else {
return _cmd_set_boolean_preference(setting, help, "Title resource", PREF_RESOURCE_TITLE);
}
}
ProfWin *current = wins_get_current();
if (current->type != WIN_CHAT) {
cons_show("Resource can only be changed in chat windows.");
return TRUE;
}
ProfChatWin *chatwin = (ProfChatWin*)current;
char *cmd = args[0];
if (g_strcmp0(cmd, "set") == 0) {
char *resource = args[1];
if (!resource) {