Esempio n. 1
0
static CONFIG_NODE *statusbar_items_section(CONFIG_NODE *parent)
{
	STATUSBAR_CONFIG_REC *bar;
        CONFIG_NODE *node;
        GSList *tmp;

	node = config_node_section(parent, "items", -1);
	if (node != NULL)
		return node;

        /* 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;
	}

	/* since items list in config file overrides defaults,
	   we'll need to copy the whole list. */
	parent = config_node_section(parent, "items", NODE_TYPE_BLOCK);
	for (tmp = bar->items; tmp != NULL; tmp = tmp->next) {
		SBAR_ITEM_CONFIG_REC *rec = tmp->data;

		node = config_node_section(parent, rec->name,
					   NODE_TYPE_BLOCK);
		if (rec->priority != 0)
                        iconfig_node_set_int(node, "priority", rec->priority);
		if (rec->right_alignment)
                        iconfig_node_set_str(node, "alignment", "right");
	}

        return parent;
}
Esempio n. 2
0
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;
	}

	/* lookup/create the statusbar node */
	return iconfig_sbar_node(name, create);
}
Esempio n. 3
0
static void statusbar_read(STATUSBAR_GROUP_REC *group, CONFIG_NODE *node)
{
	STATUSBAR_CONFIG_REC *bar;
        GSList *tmp;
        const char *visible_str;

	g_return_if_fail(is_node_list(node));
	g_return_if_fail(node->key != NULL);

	bar = statusbar_config_find(group, node->key);
	if (config_node_get_bool(node, "disabled", FALSE)) {
		/* disabled, destroy it if it already exists */
		if (bar != NULL)
			statusbar_config_destroy(group, bar);
                return;
	}

	if (bar == NULL) {
		bar = statusbar_config_create(group, node->key);
		bar->type = STATUSBAR_TYPE_ROOT;
		bar->placement = STATUSBAR_BOTTOM;
		bar->position = 0;
	}

        visible_str = config_node_get_str(node, "visible", "");
	if (g_ascii_strcasecmp(visible_str, "active") == 0)
                bar->visible = STATUSBAR_VISIBLE_ACTIVE;
	else if (g_ascii_strcasecmp(visible_str, "inactive") == 0)
		bar->visible = STATUSBAR_VISIBLE_INACTIVE;
	else
		bar->visible = STATUSBAR_VISIBLE_ALWAYS;

	if (g_ascii_strcasecmp(config_node_get_str(node, "type", ""), "window") == 0)
                bar->type = STATUSBAR_TYPE_WINDOW;
	if (g_ascii_strcasecmp(config_node_get_str(node, "placement", ""), "top") == 0)
                bar->placement = STATUSBAR_TOP;
	bar->position = config_node_get_int(node, "position", 0);

	node = iconfig_node_section(node, "items", -1);
	if (node != NULL) {
                /* we're overriding the items - destroy the old */
                while (bar->items != NULL)
			statusbar_config_item_destroy(bar, bar->items->data);

		tmp = config_node_first(node->value);
		for (; tmp != NULL; tmp = config_node_next(tmp))
			statusbar_read_item(bar, tmp->data);
	}
}
Esempio n. 4
0
static void cmd_statusbar_print_info(const char *name)
{
	STATUSBAR_CONFIG_REC *rec = statusbar_config_find(active_statusbar_group, name);

	if (rec != NULL) {
		statusbar_print(rec);
		return;
	}

	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);
}