From d845ee7361886599f6ffa4f403b44a3f45fd88db Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Mon, 19 Mar 2018 09:18:42 +0100 Subject: change the statusbar commands so that no accidenal status bars are created --- src/fe-text/statusbar-config.c | 431 ++++++++++++++++++++++++++--------------- 1 file changed, 275 insertions(+), 156 deletions(-) (limited to 'src') diff --git a/src/fe-text/statusbar-config.c b/src/fe-text/statusbar-config.c index 48f4aa61..391a5768 100644 --- a/src/fe-text/statusbar-config.c +++ b/src/fe-text/statusbar-config.c @@ -95,8 +95,10 @@ statusbar_config_find(STATUSBAR_GROUP_REC *group, const char *name) for (tmp = group->config_bars; tmp != NULL; tmp = tmp->next) { STATUSBAR_CONFIG_REC *config = tmp->data; - if (g_strcmp0(config->name, name) == 0) - return config; + if ((config->name == NULL || name == NULL) ? + config->name == name : + g_ascii_strcasecmp(config->name, name) == 0) + return config; } return NULL; @@ -273,6 +275,24 @@ static const char *sbar_get_visibility(STATUSBAR_CONFIG_REC *rec) rec->visible == STATUSBAR_VISIBLE_INACTIVE ? "inactive" : "??"; } +static CONFIG_NODE *sbar_node(const char *name, gboolean create) +{ + CONFIG_NODE *node; + STATUSBAR_CONFIG_REC *rec = statusbar_config_find(active_statusbar_group, name); + if (rec != NULL) { + name = rec->name; + } else if (!create) { + return NULL; + } + + /* lookup/create the statusbar node */ + node = iconfig_node_traverse("statusbar", TRUE); + node = iconfig_node_section(node, active_statusbar_group->name, NODE_TYPE_BLOCK); + node = iconfig_node_section(node, name, NODE_TYPE_BLOCK); + + return node; +} + static void statusbar_list_items(STATUSBAR_CONFIG_REC *bar) { GSList *tmp; @@ -334,98 +354,133 @@ static void cmd_statusbar_list(void) static void cmd_statusbar_print_info(const char *name) { - GSList *tmp; + STATUSBAR_CONFIG_REC *rec = statusbar_config_find(active_statusbar_group, name); - tmp = active_statusbar_group->config_bars; - for (; tmp != NULL; tmp = tmp->next) { - STATUSBAR_CONFIG_REC *rec = tmp->data; - - if (g_ascii_strcasecmp(rec->name, name) == 0) { - statusbar_print(rec); - return; - } + if (rec != NULL) { + statusbar_print(rec); + return; } printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_NOT_FOUND, name); } -/* SYNTAX: STATUSBAR ENABLE */ -static void cmd_statusbar_enable(const char *data, void *server, - void *item, CONFIG_NODE *node) +/* SYNTAX: STATUSBAR ADD|MODIFY [-disable | -nodisable] [-type window|root] + [-placement top|bottom] [-position #] [-visible always|active|inactive] */ +static void cmd_statusbar_add_modify(const char *data, void *server, void *witem) { - iconfig_node_set_str(node, "disabled", NULL); -} + GHashTable *optlist; + CONFIG_NODE *node; + char *name, *type, *placement, *visible; + void *free_arg; + int error; -/* SYNTAX: STATUSBAR DISABLE */ -static void cmd_statusbar_disable(const char *data, void *server, - void *item, CONFIG_NODE *node) -{ - iconfig_node_set_bool(node, "disabled", TRUE); -} + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | PARAM_FLAG_STRIP_TRAILING_WS, + "statusbar add", &optlist, &name)) + return; -/* SYNTAX: STATUSBAR RESET */ -static void cmd_statusbar_reset(const char *data, void *server, - void *item, CONFIG_NODE *node) -{ - CONFIG_NODE *parent; + if (*name == '\0') { + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + } - parent = iconfig_node_traverse("statusbar", TRUE); - parent = iconfig_node_section(parent, active_statusbar_group->name, - NODE_TYPE_BLOCK); + error = 0; + + type = NULL; + data = g_hash_table_lookup(optlist, "type"); + if (data != NULL) { + if (g_ascii_strcasecmp(data, "window") == 0) + type = "window"; + else if (g_ascii_strcasecmp(data, "root") == 0) + type = "root"; + else { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_UNKNOWN_TYPE, + data); + error++; + } + } - iconfig_node_set_str(parent, node->key, NULL); -} + placement = NULL; + data = g_hash_table_lookup(optlist, "placement"); + if (data != NULL) { + if (g_ascii_strcasecmp(data, "top") == 0) + placement = "top"; + else if (g_ascii_strcasecmp(data, "bottom") == 0) + placement = "bottom"; + else { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, + TXT_STATUSBAR_UNKNOWN_PLACEMENT, data); + error++; + } + } -/* SYNTAX: STATUSBAR TYPE window|root */ -static void cmd_statusbar_type(const char *data, void *server, - void *item, CONFIG_NODE *node) -{ - if (g_ascii_strcasecmp(data, "window") == 0) - iconfig_node_set_str(node, "type", "window"); - else if (g_ascii_strcasecmp(data, "root") == 0) - iconfig_node_set_str(node, "type", "root"); - else { - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, - TXT_STATUSBAR_UNKNOWN_TYPE, data); + visible = NULL; + data = g_hash_table_lookup(optlist, "visible"); + if (data != NULL) { + if (g_ascii_strcasecmp(data, "always") == 0) + visible = "always"; + else if (g_ascii_strcasecmp(data, "active") == 0) + visible = "active"; + else if (g_ascii_strcasecmp(data, "inactive") == 0) + visible = "inactive"; + else { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, + TXT_STATUSBAR_UNKNOWN_VISIBILITY, data); + error++; + } } -} -/* SYNTAX: STATUSBAR PLACEMENT top|bottom */ -static void cmd_statusbar_placement(const char *data, void *server, - void *item, CONFIG_NODE *node) -{ - if (g_ascii_strcasecmp(data, "top") == 0) - iconfig_node_set_str(node, "placement", "top"); - else if (g_ascii_strcasecmp(data, "bottom") == 0) - iconfig_node_set_str(node, "placement", "bottom"); - else { - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, - TXT_STATUSBAR_UNKNOWN_PLACEMENT, data); + if (error) { + cmd_params_free(free_arg); + return; } -} -/* SYNTAX: STATUSBAR POSITION */ -static void cmd_statusbar_position(const char *data, void *server, - void *item, CONFIG_NODE *node) -{ - iconfig_node_set_int(node, "position", atoi(data)); + node = sbar_node(name, TRUE); + if (g_hash_table_lookup(optlist, "nodisable")) + iconfig_node_set_str(node, "disabled", NULL); + if (g_hash_table_lookup(optlist, "disable")) + iconfig_node_set_bool(node, "disabled", TRUE); + if (type != NULL) + iconfig_node_set_str(node, "type", type); + if (placement != NULL) + iconfig_node_set_str(node, "placement", placement); + data = g_hash_table_lookup(optlist, "position"); + if (data != NULL) + iconfig_node_set_int(node, "position", atoi(data)); + if (visible != NULL) + iconfig_node_set_str(node, "visible", visible); + + read_statusbar_config(); + cmd_params_free(free_arg); } -/* SYNTAX: STATUSBAR VISIBLE always|active|inactive */ -static void cmd_statusbar_visible(const char *data, void *server, - void *item, CONFIG_NODE *node) +/* SYNTAX: STATUSBAR RESET */ +static void cmd_statusbar_reset(const char *data, void *server, void *witem) { - if (g_ascii_strcasecmp(data, "always") == 0) - iconfig_node_set_str(node, "visible", "always"); - else if (g_ascii_strcasecmp(data, "active") == 0) - iconfig_node_set_str(node, "visible", "active"); - else if (g_ascii_strcasecmp(data, "inactive") == 0) - iconfig_node_set_str(node, "visible", "inactive"); - else { - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, - TXT_STATUSBAR_UNKNOWN_VISIBILITY, data); + CONFIG_NODE *node, *parent; + char *name; + void *free_arg; + + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_STRIP_TRAILING_WS, &name)) + return; + + if (*name == '\0') { + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); } + + node = sbar_node(name, FALSE); + if (node == NULL) { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_NOT_FOUND, name); + cmd_params_free(free_arg); + return; + } + + parent = iconfig_node_traverse("statusbar", TRUE); + parent = iconfig_node_section(parent, active_statusbar_group->name, NODE_TYPE_BLOCK); + + iconfig_node_set_str(parent, node->key, NULL); + + read_statusbar_config(); + cmd_params_free(free_arg); } static CONFIG_NODE *statusbar_items_section(CONFIG_NODE *parent) @@ -455,45 +510,58 @@ static CONFIG_NODE *statusbar_items_section(CONFIG_NODE *parent) node = iconfig_node_section(parent, rec->name, NODE_TYPE_BLOCK); if (rec->priority != 0) - iconfig_node_set_int(node, "priority", rec->priority); + iconfig_node_set_int(node, "priority", rec->priority); if (rec->right_alignment) - iconfig_node_set_str(node, "alignment", "right"); + iconfig_node_set_str(node, "alignment", "right"); } - return parent; + return parent; } -/* SYNTAX: STATUSBAR ADD [-before | -after ] - [-priority #] [-alignment left|right] */ -static void cmd_statusbar_add(const char *data, void *server, - void *item, CONFIG_NODE *node) +/* SYNTAX: STATUSBAR ADDITEM|MODIFYITEM [-before | -after ] + [-priority #] [-alignment left|right] */ +static void cmd_statusbar_additem_modifyitem(const char *data, void *server, void *witem) { - GHashTable *optlist; - char *name, *value; + CONFIG_NODE *node; + GHashTable *optlist; + char *item, *statusbar, *value; void *free_arg; - int index; + int index; - node = statusbar_items_section(node); - if (node == NULL) - return; + if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS | PARAM_FLAG_STRIP_TRAILING_WS, + "statusbar additem", &optlist, &item, &statusbar)) + return; + + if (*statusbar == '\0') { + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + } - if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS, - "statusbar add", &optlist, &name)) + node = sbar_node(statusbar, FALSE); + if (node == NULL) { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_NOT_FOUND, statusbar); + cmd_params_free(free_arg); return; + } + + node = statusbar_items_section(node); + if (node == NULL) { + cmd_params_free(free_arg); + return; + } - /* get the index */ + /* get the index */ index = -1; value = g_hash_table_lookup(optlist, "before"); if (value != NULL) index = config_node_index(node, value); value = g_hash_table_lookup(optlist, "after"); if (value != NULL) index = config_node_index(node, value)+1; - /* create/move item */ - node = iconfig_node_section_index(node, name, index, NODE_TYPE_BLOCK); + /* create/move item */ + node = iconfig_node_section_index(node, item, index, NODE_TYPE_BLOCK); - /* set the options */ - value = g_hash_table_lookup(optlist, "priority"); - if (value != NULL) iconfig_node_set_int(node, "priority", atoi(value)); + /* set the options */ + value = g_hash_table_lookup(optlist, "priority"); + if (value != NULL) iconfig_node_set_int(node, "priority", atoi(value)); value = g_hash_table_lookup(optlist, "alignment"); if (value != NULL) { @@ -502,67 +570,115 @@ static void cmd_statusbar_add(const char *data, void *server, "right" : NULL); } + read_statusbar_config(); cmd_params_free(free_arg); } -/* SYNTAX: STATUSBAR REMOVE */ -static void cmd_statusbar_remove(const char *data, void *server, - void *item, CONFIG_NODE *node) +/* SYNTAX: STATUSBAR REMOVEITEM */ +static void cmd_statusbar_removeitem(const char *data, void *server, void *witem) { - node = statusbar_items_section(node); - if (node == NULL) - return; + CONFIG_NODE *node; + char *item, *statusbar; + void *free_arg; + if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_STRIP_TRAILING_WS, &item, &statusbar)) + return; + + if (*statusbar == '\0') { + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + } + + node = sbar_node(statusbar, FALSE); + if (node == NULL) { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_NOT_FOUND, statusbar); + cmd_params_free(free_arg); + return; + } - if (iconfig_node_section(node, data, -1) != NULL) - iconfig_node_set_str(node, data, NULL); + node = statusbar_items_section(node); + if (node == NULL) { + cmd_params_free(free_arg); + return; + } + + if (iconfig_node_section(node, item, -1) != NULL) + iconfig_node_set_str(node, item, NULL); else { - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, - TXT_STATUSBAR_ITEM_NOT_FOUND, data); + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_ITEM_NOT_FOUND, item); } + + read_statusbar_config(); + cmd_params_free(free_arg); } -static void cmd_statusbar(const char *data) +/* SYNTAX: STATUSBAR INFO */ +static void cmd_statusbar_info(const char *data) { - CONFIG_NODE *node; - char *name, *cmd, *params, *signal; void *free_arg; - - if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, - &name, &cmd, ¶ms)) + char *name; + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_STRIP_TRAILING_WS, &name)) return; if (*name == '\0') { - /* list all statusbars */ - cmd_statusbar_list(); - cmd_params_free(free_arg); - return; + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); } - if (*cmd == '\0') { - /* print statusbar info */ - cmd_statusbar_print_info(name); - cmd_params_free(free_arg); - return; - } + /* print statusbar info */ + cmd_statusbar_print_info(name); + cmd_params_free(free_arg); + return; +} - /* lookup/create the statusbar node */ - node = iconfig_node_traverse("statusbar", TRUE); - node = iconfig_node_section(node, active_statusbar_group->name, - NODE_TYPE_BLOCK); - node = iconfig_node_section(node, name, NODE_TYPE_BLOCK); +static void cmd_statusbar(const char *data) +{ + char *arg1, *arg2, *params, *oldcmd; + void *free_arg; - /* call the subcommand */ - signal = g_strconcat("command statusbar ", cmd, NULL); - ascii_strdown(signal); - if (!signal_emit(signal, 4, params, NULL, NULL, node)) { - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, - TXT_STATUSBAR_UNKNOWN_COMMAND, cmd); - } else { - read_statusbar_config(); + if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST | PARAM_FLAG_STRIP_TRAILING_WS, + &arg1, &arg2, ¶ms)) + return; + + /* backward compatibility layer */ + oldcmd = NULL; + if (*arg1 == '\0') { + oldcmd = g_strdup("list"); + } else if (g_ascii_strcasecmp(arg2, "enable") == 0) { + oldcmd = g_strdup_printf("add -nodisable %s %s", arg1, params); + } else if (g_ascii_strcasecmp(arg2, "disable") == 0) { + oldcmd = g_strdup_printf("add -disable %s %s", arg1, params); + } else if (g_ascii_strcasecmp(arg2, "reset") == 0) { + oldcmd = g_strdup_printf("reset %s", arg1); + } else if (g_ascii_strcasecmp(arg2, "type") == 0) { + oldcmd = g_strdup_printf("add -type %s %s", params, arg1); + } else if (g_ascii_strcasecmp(arg2, "placement") == 0) { + oldcmd = g_strdup_printf("add -placement %s %s", params, arg1); + } else if (g_ascii_strcasecmp(arg2, "position") == 0) { + oldcmd = g_strdup_printf("add -position %s %s", params, arg1); + } else if (g_ascii_strcasecmp(arg2, "visible") == 0) { + oldcmd = g_strdup_printf("add -visible %s %s", params, arg1); + } else if (g_ascii_strcasecmp(arg2, "add") == 0) { + oldcmd = g_strdup_printf("additem %s %s", params, arg1); + } else if (g_ascii_strcasecmp(arg2, "remove") == 0) { + oldcmd = g_strdup_printf("removeitem %s %s", params, arg1); + } else if (*arg2 == '\0') { + oldcmd = g_strdup_printf("statusbar %s", arg1); + if (command_find(oldcmd) == NULL) { + g_free(oldcmd); + oldcmd = g_strdup_printf("info %s", arg1); + } else { + g_free(oldcmd); + oldcmd = NULL; + } } - g_free(signal); cmd_params_free(free_arg); + if (oldcmd) { + command_runsub("statusbar", oldcmd, NULL, NULL); + g_free(oldcmd); + } else { + command_runsub("statusbar", data, NULL, NULL); + } + + return; } void statusbar_config_init(void) @@ -571,18 +687,22 @@ void statusbar_config_init(void) signal_add_last("setup reread", (SIGNAL_FUNC) read_statusbar_config); signal_add("theme changed", (SIGNAL_FUNC) read_statusbar_config); - command_bind("statusbar", NULL, (SIGNAL_FUNC) cmd_statusbar); - command_bind("statusbar enable", NULL, (SIGNAL_FUNC) cmd_statusbar_enable); - command_bind("statusbar disable", NULL, (SIGNAL_FUNC) cmd_statusbar_disable); - command_bind("statusbar reset", NULL, (SIGNAL_FUNC) cmd_statusbar_reset); - command_bind("statusbar add", NULL, (SIGNAL_FUNC) cmd_statusbar_add); - command_bind("statusbar remove", NULL, (SIGNAL_FUNC) cmd_statusbar_remove); - command_bind("statusbar type", NULL, (SIGNAL_FUNC) cmd_statusbar_type); - command_bind("statusbar placement", NULL, (SIGNAL_FUNC) cmd_statusbar_placement); - command_bind("statusbar position", NULL, (SIGNAL_FUNC) cmd_statusbar_position); - command_bind("statusbar visible", NULL, (SIGNAL_FUNC) cmd_statusbar_visible); - - command_set_options("statusbar add", "+before +after +priority +alignment"); + command_bind("statusbar", NULL, (SIGNAL_FUNC) cmd_statusbar); + command_bind("statusbar list", NULL, (SIGNAL_FUNC) cmd_statusbar_list); + command_bind("statusbar add", NULL, (SIGNAL_FUNC) cmd_statusbar_add_modify); + command_bind("statusbar modify", NULL, (SIGNAL_FUNC) cmd_statusbar_add_modify); + command_bind("statusbar reset", NULL, (SIGNAL_FUNC) cmd_statusbar_reset); + command_bind("statusbar info", NULL, (SIGNAL_FUNC) cmd_statusbar_info); + command_bind("statusbar additem", NULL, (SIGNAL_FUNC) cmd_statusbar_additem_modifyitem); + command_bind("statusbar modifyitem", NULL, (SIGNAL_FUNC) cmd_statusbar_additem_modifyitem); + command_bind("statusbar removeitem", NULL, (SIGNAL_FUNC) cmd_statusbar_removeitem); + + command_set_options("statusbar additem", "+before +after +priority +alignment"); + command_set_options("statusbar modifyitem", "+before +after +priority +alignment"); + command_set_options("statusbar add", + "disable nodisable +type +placement +position +visible"); + command_set_options("statusbar modify", + "disable nodisable +type +placement +position +visible"); } void statusbar_config_deinit(void) @@ -590,14 +710,13 @@ void statusbar_config_deinit(void) signal_remove("setup reread", (SIGNAL_FUNC) read_statusbar_config); signal_remove("theme changed", (SIGNAL_FUNC) read_statusbar_config); - command_unbind("statusbar", (SIGNAL_FUNC) cmd_statusbar); - command_unbind("statusbar enable", (SIGNAL_FUNC) cmd_statusbar_enable); - command_unbind("statusbar disable", (SIGNAL_FUNC) cmd_statusbar_disable); - command_unbind("statusbar reset", (SIGNAL_FUNC) cmd_statusbar_reset); - command_unbind("statusbar add", (SIGNAL_FUNC) cmd_statusbar_add); - command_unbind("statusbar remove", (SIGNAL_FUNC) cmd_statusbar_remove); - command_unbind("statusbar type", (SIGNAL_FUNC) cmd_statusbar_type); - command_unbind("statusbar placement", (SIGNAL_FUNC) cmd_statusbar_placement); - command_unbind("statusbar position", (SIGNAL_FUNC) cmd_statusbar_position); - command_unbind("statusbar visible", (SIGNAL_FUNC) cmd_statusbar_visible); + command_unbind("statusbar", (SIGNAL_FUNC) cmd_statusbar); + command_unbind("statusbar list", (SIGNAL_FUNC) cmd_statusbar_list); + command_unbind("statusbar add", (SIGNAL_FUNC) cmd_statusbar_add_modify); + command_unbind("statusbar modify", (SIGNAL_FUNC) cmd_statusbar_add_modify); + command_unbind("statusbar reset", (SIGNAL_FUNC) cmd_statusbar_reset); + command_unbind("statusbar info", (SIGNAL_FUNC) cmd_statusbar_info); + command_unbind("statusbar additem", (SIGNAL_FUNC) cmd_statusbar_additem_modifyitem); + command_unbind("statusbar modifyitem", (SIGNAL_FUNC) cmd_statusbar_additem_modifyitem); + command_unbind("statusbar removeitem", (SIGNAL_FUNC) cmd_statusbar_removeitem); } -- cgit v1.2.3 From 61c58b7690e9eec159ba32e5ea40809ed17ef424 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Mon, 19 Mar 2018 10:35:39 +0100 Subject: actually check which of add or modify was called --- src/fe-text/statusbar-config.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/fe-text/statusbar-config.c b/src/fe-text/statusbar-config.c index 391a5768..75d10612 100644 --- a/src/fe-text/statusbar-config.c +++ b/src/fe-text/statusbar-config.c @@ -374,6 +374,7 @@ static void cmd_statusbar_add_modify(const char *data, void *server, void *witem char *name, *type, *placement, *visible; void *free_arg; int error; + int add = GPOINTER_TO_INT(signal_get_user_data()); if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | PARAM_FLAG_STRIP_TRAILING_WS, "statusbar add", &optlist, &name)) @@ -429,12 +430,20 @@ static void cmd_statusbar_add_modify(const char *data, void *server, void *witem } } + if (!error) { + node = sbar_node(name, add); + + if (node == NULL) { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_NOT_FOUND, name); + error++; + } + } + if (error) { cmd_params_free(free_arg); return; } - node = sbar_node(name, TRUE); if (g_hash_table_lookup(optlist, "nodisable")) iconfig_node_set_str(node, "disabled", NULL); if (g_hash_table_lookup(optlist, "disable")) @@ -527,6 +536,7 @@ static void cmd_statusbar_additem_modifyitem(const char *data, void *server, voi char *item, *statusbar, *value; void *free_arg; int index; + int additem = GINT_TO_POINTER(signal_get_user_data()); if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS | PARAM_FLAG_STRIP_TRAILING_WS, "statusbar additem", &optlist, &item, &statusbar)) @@ -556,6 +566,12 @@ static void cmd_statusbar_additem_modifyitem(const char *data, void *server, voi value = g_hash_table_lookup(optlist, "after"); if (value != NULL) index = config_node_index(node, value)+1; + if (!additem && iconfig_node_section(node, item, -1) == NULL) { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_ITEM_NOT_FOUND, item); + cmd_params_free(free_arg); + return; + } + /* create/move item */ node = iconfig_node_section_index(node, item, index, NODE_TYPE_BLOCK); @@ -689,12 +705,12 @@ void statusbar_config_init(void) command_bind("statusbar", NULL, (SIGNAL_FUNC) cmd_statusbar); command_bind("statusbar list", NULL, (SIGNAL_FUNC) cmd_statusbar_list); - command_bind("statusbar add", NULL, (SIGNAL_FUNC) cmd_statusbar_add_modify); - command_bind("statusbar modify", NULL, (SIGNAL_FUNC) cmd_statusbar_add_modify); + command_bind_data("statusbar add", NULL, (SIGNAL_FUNC) cmd_statusbar_add_modify, GINT_TO_POINTER(TRUE)); + command_bind_data("statusbar modify", NULL, (SIGNAL_FUNC) cmd_statusbar_add_modify, GINT_TO_POINTER(FALSE)); command_bind("statusbar reset", NULL, (SIGNAL_FUNC) cmd_statusbar_reset); command_bind("statusbar info", NULL, (SIGNAL_FUNC) cmd_statusbar_info); - command_bind("statusbar additem", NULL, (SIGNAL_FUNC) cmd_statusbar_additem_modifyitem); - command_bind("statusbar modifyitem", NULL, (SIGNAL_FUNC) cmd_statusbar_additem_modifyitem); + command_bind_data("statusbar additem", NULL, (SIGNAL_FUNC) cmd_statusbar_additem_modifyitem, GINT_TO_POINTER(TRUE)); + command_bind_data("statusbar modifyitem", NULL, (SIGNAL_FUNC) cmd_statusbar_additem_modifyitem, GINT_TO_POINTER(FALSE)); command_bind("statusbar removeitem", NULL, (SIGNAL_FUNC) cmd_statusbar_removeitem); command_set_options("statusbar additem", "+before +after +priority +alignment"); @@ -712,11 +728,11 @@ void statusbar_config_deinit(void) command_unbind("statusbar", (SIGNAL_FUNC) cmd_statusbar); command_unbind("statusbar list", (SIGNAL_FUNC) cmd_statusbar_list); - command_unbind("statusbar add", (SIGNAL_FUNC) cmd_statusbar_add_modify); - command_unbind("statusbar modify", (SIGNAL_FUNC) cmd_statusbar_add_modify); + command_unbind_full("statusbar add", (SIGNAL_FUNC) cmd_statusbar_add_modify, GINT_TO_POINTER(TRUE)); + command_unbind_full("statusbar modify", (SIGNAL_FUNC) cmd_statusbar_add_modify, GINT_TO_POINTER(FALSE)); command_unbind("statusbar reset", (SIGNAL_FUNC) cmd_statusbar_reset); command_unbind("statusbar info", (SIGNAL_FUNC) cmd_statusbar_info); - command_unbind("statusbar additem", (SIGNAL_FUNC) cmd_statusbar_additem_modifyitem); - command_unbind("statusbar modifyitem", (SIGNAL_FUNC) cmd_statusbar_additem_modifyitem); + command_unbind_full("statusbar additem", (SIGNAL_FUNC) cmd_statusbar_additem_modifyitem, GINT_TO_POINTER(TRUE)); + command_unbind_full("statusbar modifyitem", (SIGNAL_FUNC) cmd_statusbar_additem_modifyitem, GINT_TO_POINTER(FALSE)); command_unbind("statusbar removeitem", (SIGNAL_FUNC) cmd_statusbar_removeitem); } -- cgit v1.2.3 From c8191b33155ae7ee1ebb07d87b8e001f75188eeb Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Mon, 12 Mar 2018 09:41:53 +0100 Subject: abi bump --- src/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/common.h b/src/common.h index 746aad4e..de29abd5 100644 --- a/src/common.h +++ b/src/common.h @@ -6,7 +6,7 @@ #define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */ #define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */ -#define IRSSI_ABI_VERSION 15 +#define IRSSI_ABI_VERSION 16 #define DEFAULT_SERVER_ADD_PORT 6667 #define DEFAULT_SERVER_ADD_TLS_PORT 6697 -- cgit v1.2.3 From 501c150ec21b1dceeecc0c201d22fc1bad161cf4 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Tue, 20 Mar 2018 17:39:08 +0100 Subject: make new status bar actually work --- src/fe-text/statusbar-config.c | 194 ++++++++++++++++++++++++++++++++--------- 1 file changed, 153 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/fe-text/statusbar-config.c b/src/fe-text/statusbar-config.c index 75d10612..a6ec81fe 100644 --- a/src/fe-text/statusbar-config.c +++ b/src/fe-text/statusbar-config.c @@ -275,22 +275,49 @@ static const char *sbar_get_visibility(STATUSBAR_CONFIG_REC *rec) rec->visible == STATUSBAR_VISIBLE_INACTIVE ? "inactive" : "??"; } -static CONFIG_NODE *sbar_node(const char *name, gboolean create) +#define iconfig_sbar_node(a, b) config_sbar_node(mainconfig, a, b) +static CONFIG_NODE *config_sbar_node(CONFIG_REC *config, const char *name, gboolean create) { CONFIG_NODE *node; + + node = config_node_traverse(config, "statusbar", create); + if (node != NULL) { + node = config_node_section(config, node, active_statusbar_group->name, + create ? NODE_TYPE_BLOCK : -1); + } + + if (node != NULL) { + node = config_node_section(config, node, name, create ? NODE_TYPE_BLOCK : -1); + } + + return node; +} + +static CONFIG_NODE *sbar_node(const char *name, gboolean create) +{ STATUSBAR_CONFIG_REC *rec = statusbar_config_find(active_statusbar_group, name); if (rec != NULL) { name = rec->name; - } else if (!create) { - return NULL; } /* lookup/create the statusbar node */ - node = iconfig_node_traverse("statusbar", TRUE); - node = iconfig_node_section(node, active_statusbar_group->name, NODE_TYPE_BLOCK); - node = iconfig_node_section(node, name, NODE_TYPE_BLOCK); + return iconfig_sbar_node(name, create); +} - return node; +static gboolean sbar_node_isdefault(const char *name) +{ + CONFIG_REC *config; + CONFIG_NODE *node; + + /* read the default statusbar settings from internal config */ + config = config_open(NULL, -1); + config_parse_data(config, default_config, "internal"); + + node = config_sbar_node(config, name, FALSE); + + config_close(config); + + return node != NULL ? TRUE : FALSE; } static void statusbar_list_items(STATUSBAR_CONFIG_REC *bar) @@ -432,6 +459,11 @@ static void cmd_statusbar_add_modify(const char *data, void *server, void *witem if (!error) { node = sbar_node(name, add); + if (node == NULL && !add && sbar_node_isdefault(name)) { + /* If this node is a default status bar, we need to create it in the config + * to configure it */ + node = sbar_node(name, TRUE); + } if (node == NULL) { printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_NOT_FOUND, name); @@ -477,50 +509,59 @@ static void cmd_statusbar_reset(const char *data, void *server, void *witem) } node = sbar_node(name, FALSE); - if (node == NULL) { + if (node == NULL && !sbar_node_isdefault(name)) { printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_NOT_FOUND, name); cmd_params_free(free_arg); return; } - parent = iconfig_node_traverse("statusbar", TRUE); - parent = iconfig_node_section(parent, active_statusbar_group->name, NODE_TYPE_BLOCK); + parent = iconfig_node_traverse("statusbar", FALSE); + if (parent != NULL) { + parent = iconfig_node_section(parent, active_statusbar_group->name, -1); + } - iconfig_node_set_str(parent, node->key, NULL); + if (parent != NULL && node != NULL) { + iconfig_node_set_str(parent, node->key, NULL); + } read_statusbar_config(); cmd_params_free(free_arg); } -static CONFIG_NODE *statusbar_items_section(CONFIG_NODE *parent) +#define iconfig_sbar_items_section(a, b) config_sbar_items_section(mainconfig, a, b) +static CONFIG_NODE *config_sbar_items_section(CONFIG_REC *config, CONFIG_NODE *parent, + gboolean create) +{ + return config_node_section(config, parent, "items", create ? NODE_TYPE_BLOCK : -1); +} + +static CONFIG_NODE *statusbar_copy_config(CONFIG_REC *config, CONFIG_NODE *source, + CONFIG_NODE *parent) { - STATUSBAR_CONFIG_REC *bar; - CONFIG_NODE *node; GSList *tmp; - node = iconfig_node_section(parent, "items", -1); - if (node != NULL) - return node; + g_return_val_if_fail(parent != NULL, NULL); - /* find the statusbar configuration from memory */ - bar = statusbar_config_find(active_statusbar_group, parent->key); - if (bar == NULL) { - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, - TXT_STATUSBAR_NOT_FOUND, parent->key); - return NULL; - } + parent = iconfig_sbar_items_section(parent, TRUE); /* since items list in config file overrides defaults, we'll need to copy the whole list. */ - parent = iconfig_node_section(parent, "items", NODE_TYPE_BLOCK); - for (tmp = bar->items; tmp != NULL; tmp = tmp->next) { - SBAR_ITEM_CONFIG_REC *rec = tmp->data; + for (tmp = config_node_first(source->value); tmp != NULL; tmp = config_node_next(tmp)) { + int priority, right_alignment; + CONFIG_NODE *node, *snode; + + snode = tmp->data; - node = iconfig_node_section(parent, rec->name, - NODE_TYPE_BLOCK); - if (rec->priority != 0) - iconfig_node_set_int(node, "priority", rec->priority); - if (rec->right_alignment) + priority = config_node_get_int(snode, "priority", 0); + right_alignment = + g_strcmp0(config_node_get_str(snode, "alignment", ""), "right") == 0; + + /* create new item */ + node = iconfig_node_section(parent, snode->key, NODE_TYPE_BLOCK); + + if (priority != 0) + iconfig_node_set_int(node, "priority", priority); + if (right_alignment) iconfig_node_set_str(node, "alignment", "right"); } @@ -531,12 +572,13 @@ static CONFIG_NODE *statusbar_items_section(CONFIG_NODE *parent) [-priority #] [-alignment left|right] */ static void cmd_statusbar_additem_modifyitem(const char *data, void *server, void *witem) { + CONFIG_REC *config, *close_config; CONFIG_NODE *node; GHashTable *optlist; char *item, *statusbar, *value; void *free_arg; int index; - int additem = GINT_TO_POINTER(signal_get_user_data()); + int additem = GPOINTER_TO_INT(signal_get_user_data()); if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS | PARAM_FLAG_STRIP_TRAILING_WS, "statusbar additem", &optlist, &item, &statusbar)) @@ -546,15 +588,33 @@ static void cmd_statusbar_additem_modifyitem(const char *data, void *server, voi cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); } + close_config = NULL; + config = mainconfig; + node = sbar_node(statusbar, FALSE); + if (node == NULL) { + /* we are looking up defaults from the internal config */ + close_config = config = config_open(NULL, -1); + config_parse_data(config, default_config, "internal"); + node = config_sbar_node(config, statusbar, FALSE); + } + if (node == NULL) { printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_NOT_FOUND, statusbar); + if (close_config != NULL) { + config_close(close_config); + } cmd_params_free(free_arg); return; } - node = statusbar_items_section(node); + node = config_sbar_items_section(config, node, additem); + if (node == NULL) { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_ITEM_NOT_FOUND, item); + if (close_config != NULL) { + config_close(close_config); + } cmd_params_free(free_arg); return; } @@ -566,8 +626,28 @@ static void cmd_statusbar_additem_modifyitem(const char *data, void *server, voi value = g_hash_table_lookup(optlist, "after"); if (value != NULL) index = config_node_index(node, value)+1; - if (!additem && iconfig_node_section(node, item, -1) == NULL) { + if (!additem && config_node_section(config, node, item, -1) == NULL) { printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_ITEM_NOT_FOUND, item); + if (close_config != NULL) { + config_close(close_config); + } + cmd_params_free(free_arg); + return; + } + + if (config != mainconfig) { + /* we need to copy default to user config */ + node = statusbar_copy_config(config, node, sbar_node(statusbar, TRUE)); + config = mainconfig; + } + + if (close_config != NULL) { + config_close(close_config); + close_config = NULL; + } + + if (node == NULL) { + g_warning("node not found"); cmd_params_free(free_arg); return; } @@ -593,6 +673,7 @@ static void cmd_statusbar_additem_modifyitem(const char *data, void *server, voi /* SYNTAX: STATUSBAR REMOVEITEM */ static void cmd_statusbar_removeitem(const char *data, void *server, void *witem) { + CONFIG_REC *config, *close_config; CONFIG_NODE *node; char *item, *statusbar; void *free_arg; @@ -603,25 +684,56 @@ static void cmd_statusbar_removeitem(const char *data, void *server, void *witem cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); } + close_config = NULL; + config = mainconfig; + node = sbar_node(statusbar, FALSE); + if (node == NULL) { + /* we are looking up defaults from the internal config */ + close_config = config = config_open(NULL, -1); + config_parse_data(config, default_config, "internal"); + node = config_sbar_node(config, statusbar, FALSE); + } + if (node == NULL) { printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_NOT_FOUND, statusbar); + if (close_config != NULL) { + config_close(close_config); + } cmd_params_free(free_arg); return; } - node = statusbar_items_section(node); - if (node == NULL) { + node = config_sbar_items_section(config, node, FALSE); + + if (node == NULL || config_node_section(config, node, item, -1) == NULL) { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_ITEM_NOT_FOUND, item); + if (close_config != NULL) { + config_close(close_config); + } cmd_params_free(free_arg); return; } - if (iconfig_node_section(node, item, -1) != NULL) - iconfig_node_set_str(node, item, NULL); - else { - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_ITEM_NOT_FOUND, item); + if (config != mainconfig) { + /* we need to copy default to user config */ + node = statusbar_copy_config(config, node, sbar_node(statusbar, TRUE)); + config = mainconfig; + } + + if (close_config != NULL) { + config_close(close_config); + close_config = NULL; } + if (node == NULL) { + g_warning("node not found"); + cmd_params_free(free_arg); + return; + } + + iconfig_node_set_str(node, item, NULL); + read_statusbar_config(); cmd_params_free(free_arg); } -- cgit v1.2.3 From 977c2c0a0d911e3b7b43387ed19c5bfee565c617 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Tue, 20 Mar 2018 17:53:03 +0100 Subject: refactor common parts --- src/fe-text/statusbar-config.c | 139 +++++++++++++---------------------------- 1 file changed, 44 insertions(+), 95 deletions(-) (limited to 'src') diff --git a/src/fe-text/statusbar-config.c b/src/fe-text/statusbar-config.c index a6ec81fe..0c6070fa 100644 --- a/src/fe-text/statusbar-config.c +++ b/src/fe-text/statusbar-config.c @@ -568,30 +568,16 @@ static CONFIG_NODE *statusbar_copy_config(CONFIG_REC *config, CONFIG_NODE *sourc return parent; } -/* SYNTAX: STATUSBAR ADDITEM|MODIFYITEM [-before | -after ] - [-priority #] [-alignment left|right] */ -static void cmd_statusbar_additem_modifyitem(const char *data, void *server, void *witem) +static CONFIG_NODE *sbar_find_item_with_defaults(const char *statusbar, const char *item, + gboolean create) { CONFIG_REC *config, *close_config; CONFIG_NODE *node; - GHashTable *optlist; - char *item, *statusbar, *value; - void *free_arg; - int index; - int additem = GPOINTER_TO_INT(signal_get_user_data()); - - if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS | PARAM_FLAG_STRIP_TRAILING_WS, - "statusbar additem", &optlist, &item, &statusbar)) - return; - - if (*statusbar == '\0') { - cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - } close_config = NULL; config = mainconfig; - node = sbar_node(statusbar, FALSE); + if (node == NULL) { /* we are looking up defaults from the internal config */ close_config = config = config_open(NULL, -1); @@ -601,57 +587,65 @@ static void cmd_statusbar_additem_modifyitem(const char *data, void *server, voi if (node == NULL) { printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_NOT_FOUND, statusbar); - if (close_config != NULL) { - config_close(close_config); - } - cmd_params_free(free_arg); - return; - } - - node = config_sbar_items_section(config, node, additem); - - if (node == NULL) { - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_ITEM_NOT_FOUND, item); - if (close_config != NULL) { + if (close_config != NULL) config_close(close_config); - } - cmd_params_free(free_arg); - return; + return NULL; } - /* get the index */ - index = -1; - value = g_hash_table_lookup(optlist, "before"); - if (value != NULL) index = config_node_index(node, value); - value = g_hash_table_lookup(optlist, "after"); - if (value != NULL) index = config_node_index(node, value)+1; + node = config_sbar_items_section(config, node, create); - if (!additem && config_node_section(config, node, item, -1) == NULL) { + if (node == NULL || (!create && config_node_section(config, node, item, -1) == NULL)) { printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_ITEM_NOT_FOUND, item); - if (close_config != NULL) { + if (close_config != NULL) config_close(close_config); - } - cmd_params_free(free_arg); - return; + return NULL; } if (config != mainconfig) { /* we need to copy default to user config */ node = statusbar_copy_config(config, node, sbar_node(statusbar, TRUE)); - config = mainconfig; } - if (close_config != NULL) { + if (close_config != NULL) config_close(close_config); - close_config = NULL; + + return node; +} + +/* SYNTAX: STATUSBAR ADDITEM|MODIFYITEM [-before | -after ] + [-priority #] [-alignment left|right] */ +static void cmd_statusbar_additem_modifyitem(const char *data, void *server, void *witem) +{ + CONFIG_NODE *node; + GHashTable *optlist; + char *item, *statusbar, *value; + void *free_arg; + int index; + int additem = GPOINTER_TO_INT(signal_get_user_data()); + + if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS | PARAM_FLAG_STRIP_TRAILING_WS, + "statusbar additem", &optlist, &item, &statusbar)) + return; + + if (*statusbar == '\0') { + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); } + node = sbar_find_item_with_defaults(statusbar, item, additem); if (node == NULL) { - g_warning("node not found"); cmd_params_free(free_arg); return; } + /* get the index */ + index = -1; + value = g_hash_table_lookup(optlist, "before"); + if (value != NULL) + index = config_node_index(node, value); + value = g_hash_table_lookup(optlist, "after"); + if (value != NULL) + index = config_node_index(node, value) + 1; + /* create/move item */ node = iconfig_node_section_index(node, item, index, NODE_TYPE_BLOCK); @@ -684,55 +678,10 @@ static void cmd_statusbar_removeitem(const char *data, void *server, void *witem cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); } - close_config = NULL; - config = mainconfig; - - node = sbar_node(statusbar, FALSE); - if (node == NULL) { - /* we are looking up defaults from the internal config */ - close_config = config = config_open(NULL, -1); - config_parse_data(config, default_config, "internal"); - node = config_sbar_node(config, statusbar, FALSE); - } + node = sbar_find_item_with_defaults(statusbar, item, FALSE); - if (node == NULL) { - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_NOT_FOUND, statusbar); - if (close_config != NULL) { - config_close(close_config); - } - cmd_params_free(free_arg); - return; - } - - node = config_sbar_items_section(config, node, FALSE); - - if (node == NULL || config_node_section(config, node, item, -1) == NULL) { - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_ITEM_NOT_FOUND, item); - if (close_config != NULL) { - config_close(close_config); - } - cmd_params_free(free_arg); - return; - } - - if (config != mainconfig) { - /* we need to copy default to user config */ - node = statusbar_copy_config(config, node, sbar_node(statusbar, TRUE)); - config = mainconfig; - } - - if (close_config != NULL) { - config_close(close_config); - close_config = NULL; - } - - if (node == NULL) { - g_warning("node not found"); - cmd_params_free(free_arg); - return; - } - - iconfig_node_set_str(node, item, NULL); + if (node != NULL) + iconfig_node_set_str(node, item, NULL); read_statusbar_config(); cmd_params_free(free_arg); -- cgit v1.2.3 From ee04cd503ff70a1aed79cdb2c9f787c98b075182 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Tue, 20 Mar 2018 17:59:11 +0100 Subject: add disabled txt --- src/fe-text/module-formats.c | 1 + src/fe-text/module-formats.h | 1 + src/fe-text/statusbar-config.c | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/fe-text/module-formats.c b/src/fe-text/module-formats.c index b234f46c..277872c6 100644 --- a/src/fe-text/module-formats.c +++ b/src/fe-text/module-formats.c @@ -67,6 +67,7 @@ FORMAT_REC gui_text_formats[] = { "statusbar_info_item_footer", "", 0 }, { "statusbar_info_item_name", "%# : $[35]0 $[9]1 $2", 3, { 0, 1, 0 } }, { "statusbar_not_found", "Statusbar doesn't exist: $0", 1, { 0 } }, + { "statusbar_not_found", "Statusbar is disabled: $0", 1, { 0 } }, { "statusbar_item_not_found", "Statusbar item doesn't exist: $0", 1, { 0 } }, { "statusbar_unknown_command", "Unknown statusbar command: $0", 1, { 0 } }, { "statusbar_unknown_type", "Statusbar type must be 'window' or 'root'", 1, { 0 } }, diff --git a/src/fe-text/module-formats.h b/src/fe-text/module-formats.h index b753238b..a9f4c6ae 100644 --- a/src/fe-text/module-formats.h +++ b/src/fe-text/module-formats.h @@ -42,6 +42,7 @@ enum { TXT_STATUSBAR_INFO_ITEM_FOOTER, TXT_STATUSBAR_INFO_ITEM_NAME, TXT_STATUSBAR_NOT_FOUND, + TXT_STATUSBAR_NOT_ENABLED, TXT_STATUSBAR_ITEM_NOT_FOUND, TXT_STATUSBAR_UNKNOWN_COMMAND, TXT_STATUSBAR_UNKNOWN_TYPE, diff --git a/src/fe-text/statusbar-config.c b/src/fe-text/statusbar-config.c index 0c6070fa..7b5b6884 100644 --- a/src/fe-text/statusbar-config.c +++ b/src/fe-text/statusbar-config.c @@ -388,8 +388,12 @@ static void cmd_statusbar_print_info(const char *name) return; } - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, - TXT_STATUSBAR_NOT_FOUND, name); + if (sbar_node(name, FALSE) != NULL || sbar_node_isdefault(name)) + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, + TXT_STATUSBAR_NOT_ENABLED, name); + else + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, + TXT_STATUSBAR_NOT_FOUND, name); } /* SYNTAX: STATUSBAR ADD|MODIFY [-disable | -nodisable] [-type window|root] -- cgit v1.2.3 From 138eca0749dd05a4a16df9e43d87af2143b224f2 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Tue, 20 Mar 2018 18:11:12 +0100 Subject: fix build --- src/fe-text/module-formats.h | 18 +++++++++--------- src/fe-text/statusbar-config.c | 5 ++--- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/fe-text/module-formats.h b/src/fe-text/module-formats.h index a9f4c6ae..ac60fdb7 100644 --- a/src/fe-text/module-formats.h +++ b/src/fe-text/module-formats.h @@ -30,24 +30,24 @@ enum { TXT_FILL_3, - TXT_STATUSBAR_LIST_HEADER, + TXT_STATUSBAR_LIST_HEADER, TXT_STATUSBAR_LIST_FOOTER, TXT_STATUSBAR_LIST, TXT_STATUSBAR_INFO_NAME, TXT_STATUSBAR_INFO_TYPE, - TXT_STATUSBAR_INFO_PLACEMENT, + TXT_STATUSBAR_INFO_PLACEMENT, TXT_STATUSBAR_INFO_POSITION, TXT_STATUSBAR_INFO_VISIBLE, - TXT_STATUSBAR_INFO_ITEM_HEADER, + TXT_STATUSBAR_INFO_ITEM_HEADER, TXT_STATUSBAR_INFO_ITEM_FOOTER, - TXT_STATUSBAR_INFO_ITEM_NAME, - TXT_STATUSBAR_NOT_FOUND, - TXT_STATUSBAR_NOT_ENABLED, - TXT_STATUSBAR_ITEM_NOT_FOUND, + TXT_STATUSBAR_INFO_ITEM_NAME, + TXT_STATUSBAR_NOT_FOUND, + TXT_STATUSBAR_NOT_ENABLED, + TXT_STATUSBAR_ITEM_NOT_FOUND, TXT_STATUSBAR_UNKNOWN_COMMAND, - TXT_STATUSBAR_UNKNOWN_TYPE, + TXT_STATUSBAR_UNKNOWN_TYPE, TXT_STATUSBAR_UNKNOWN_PLACEMENT, - TXT_STATUSBAR_UNKNOWN_VISIBILITY, + TXT_STATUSBAR_UNKNOWN_VISIBILITY, TXT_FILL_4, diff --git a/src/fe-text/statusbar-config.c b/src/fe-text/statusbar-config.c index 7b5b6884..314befaa 100644 --- a/src/fe-text/statusbar-config.c +++ b/src/fe-text/statusbar-config.c @@ -101,7 +101,7 @@ statusbar_config_find(STATUSBAR_GROUP_REC *group, const char *name) return config; } - return NULL; + return NULL; } static void statusbar_reset_defaults(void) @@ -542,7 +542,7 @@ static CONFIG_NODE *config_sbar_items_section(CONFIG_REC *config, CONFIG_NODE *p static CONFIG_NODE *statusbar_copy_config(CONFIG_REC *config, CONFIG_NODE *source, CONFIG_NODE *parent) { - GSList *tmp; + GSList *tmp; g_return_val_if_fail(parent != NULL, NULL); @@ -671,7 +671,6 @@ static void cmd_statusbar_additem_modifyitem(const char *data, void *server, voi /* SYNTAX: STATUSBAR REMOVEITEM */ static void cmd_statusbar_removeitem(const char *data, void *server, void *witem) { - CONFIG_REC *config, *close_config; CONFIG_NODE *node; char *item, *statusbar; void *free_arg; -- cgit v1.2.3