about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-01-10 19:10:10 +0000
committerJames Booth <boothj5@gmail.com>2015-01-10 19:10:10 +0000
commit31c0f2ba788b19d776da5e7368280091c8d3bbdf (patch)
tree853f4556b2fd37c299c7dc3b0f1a3f9459f021ea /src/command
parentc3ad3c0ba692613c6b26203d1328e42899775b0f (diff)
downloadprofani-tty-31c0f2ba788b19d776da5e7368280091c8d3bbdf.tar.gz
Added preferences for showing resource in titlebar and messages
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c28
-rw-r--r--src/command/commands.c25
2 files changed, 42 insertions, 11 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 7fd1616e..b225f45d 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -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;
diff --git a/src/command/commands.c b/src/command/commands.c
index 7f902836..12c6ba48 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1582,16 +1582,33 @@ cmd_roster(gchar **args, struct cmd_help_t help)
 gboolean
 cmd_resource(gchar **args, struct cmd_help_t help)
 {
+    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("The /resource command is only valid in chat windows.");
+        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) {