mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Added preferences for showing resource in titlebar and messages
This commit is contained in:
parent
c3ad3c0ba6
commit
31c0f2ba78
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -514,6 +514,8 @@ _get_group(preference_t pref)
|
||||
case PREF_ROSTER_OFFLINE:
|
||||
case PREF_ROSTER_RESOURCE:
|
||||
case PREF_ROSTER_BY:
|
||||
case PREF_RESOURCE_TITLE:
|
||||
case PREF_RESOURCE_MESSAGE:
|
||||
return PREF_GROUP_UI;
|
||||
case PREF_STATES:
|
||||
case PREF_OUTTYPE:
|
||||
@ -647,6 +649,10 @@ _get_key(preference_t pref)
|
||||
return "roster.resource";
|
||||
case PREF_ROSTER_BY:
|
||||
return "roster.by";
|
||||
case PREF_RESOURCE_TITLE:
|
||||
return "resource.title";
|
||||
case PREF_RESOURCE_MESSAGE:
|
||||
return "resource.message";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
@ -95,7 +95,9 @@ typedef enum {
|
||||
PREF_LOG_SHARED,
|
||||
PREF_OTR_LOG,
|
||||
PREF_OTR_WARN,
|
||||
PREF_OTR_POLICY
|
||||
PREF_OTR_POLICY,
|
||||
PREF_RESOURCE_TITLE,
|
||||
PREF_RESOURCE_MESSAGE
|
||||
} preference_t;
|
||||
|
||||
typedef struct prof_alias_t {
|
||||
|
@ -840,6 +840,19 @@ cons_beep_setting(void)
|
||||
cons_show("Terminal beep (/beep) : OFF");
|
||||
}
|
||||
|
||||
void
|
||||
cons_resource_setting(void)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_RESOURCE_TITLE))
|
||||
cons_show("Resource title (/resource) : ON");
|
||||
else
|
||||
cons_show("Resource title (/resource) : OFF");
|
||||
if (prefs_get_boolean(PREF_RESOURCE_MESSAGE))
|
||||
cons_show("Message title (/resource) : ON");
|
||||
else
|
||||
cons_show("Message title (/resource) : OFF");
|
||||
}
|
||||
|
||||
void
|
||||
cons_wrap_setting(void)
|
||||
{
|
||||
@ -991,6 +1004,7 @@ cons_show_ui_prefs(void)
|
||||
cons_splash_setting();
|
||||
cons_wrap_setting();
|
||||
cons_time_setting();
|
||||
cons_resource_setting();
|
||||
cons_vercheck_setting();
|
||||
cons_mouse_setting();
|
||||
cons_statuses_setting();
|
||||
|
@ -341,10 +341,10 @@ ui_incoming_msg(const char * const barejid, const char * const resource, const c
|
||||
g_string_append(user, barejid);
|
||||
}
|
||||
} else {
|
||||
g_string_append(user,barejid);
|
||||
g_string_append(user, barejid);
|
||||
}
|
||||
|
||||
if (resource) {
|
||||
if (resource && prefs_get_boolean(PREF_RESOURCE_MESSAGE)) {
|
||||
g_string_append(user, "/");
|
||||
g_string_append(user, resource);
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ _show_contact_presence(ProfChatWin *chatwin)
|
||||
} else if (session && session->resource) {
|
||||
resource = session->resource;
|
||||
}
|
||||
if (resource) {
|
||||
if (resource && prefs_get_boolean(PREF_RESOURCE_TITLE)) {
|
||||
wprintw(win, "/");
|
||||
wprintw(win, resource);
|
||||
}
|
||||
|
@ -286,6 +286,7 @@ void cons_show_received_subs(void);
|
||||
void cons_show_sent_subs(void);
|
||||
void cons_alert(void);
|
||||
void cons_theme_setting(void);
|
||||
void cons_resource_setting(void);
|
||||
void cons_privileges_setting(void);
|
||||
void cons_beep_setting(void);
|
||||
void cons_flash_setting(void);
|
||||
|
@ -436,6 +436,7 @@ void cons_beep_setting(void) {}
|
||||
void cons_flash_setting(void) {}
|
||||
void cons_splash_setting(void) {}
|
||||
void cons_vercheck_setting(void) {}
|
||||
void cons_resource_setting(void) {}
|
||||
void cons_occupants_setting(void) {}
|
||||
void cons_roster_setting(void) {}
|
||||
void cons_presence_setting(void) {}
|
||||
|
Loading…
Reference in New Issue
Block a user