示例#1
0
int avs_element_deserialize_many_new_params (AVSElement *element, AVSTree *avstree, ...)
{
        AVSSerializeContainer *scont;

        VisParamContainer *pcont;
        va_list ap;
        char *pname;

        pcont = visual_param_container_new ();
        scont = avs_serialize_container_new ();

        va_start (ap, avstree);

        while ((pname = va_arg (ap, char *)) != NULL) {
                VisParamEntry *param = visual_param_entry_new (pname);
                AVSSerializeEntry *sentry;

                sentry = avs_serialize_entry_new (param);
                sentry->type = va_arg (ap, AVSSerializeEntryType);

                avs_serialize_container_add (scont, sentry);
                visual_param_container_add (pcont, param);
        }

        va_end (ap);

        element->pcont = pcont;
        avs_element_connect_serialize_container (element, scont);

        return avs_element_deserialize (element, avstree);
}
示例#2
0
/**
 * Clones the source VisParamContainer into the destination VisParamContainer. When an entry with a certain name
 * already exists in the destination container, it will be overwritten with a new value.
 *
 * @param destcont A pointer to the VisParamContainer in which the VisParamEntry values are copied.
 * @param srccont A pointer to the VisParamContainer from which the VisParamEntry values are copied.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_CONTAINER_NULL, on failure.
 */
int visual_param_container_copy (VisParamContainer *destcont, VisParamContainer *srccont)
{
	VisListEntry *le = NULL;
	VisParamEntry *destparam;
	VisParamEntry *srcparam;
	VisParamEntry *tempparam;

	visual_log_return_val_if_fail (destcont != NULL, -VISUAL_ERROR_PARAM_CONTAINER_NULL);
	visual_log_return_val_if_fail (srccont != NULL, -VISUAL_ERROR_PARAM_CONTAINER_NULL);

	while ((srcparam = visual_list_next (&srccont->entries, &le)) != NULL) {
		tempparam = visual_param_container_get (destcont, visual_param_entry_get_name (srcparam));

		/* Already exists, overwrite */
		if (tempparam != NULL) {
			visual_param_entry_set_from_param (tempparam, srcparam);

			continue;
		}

		/* Does not yet exist, create a new entry */
		destparam = visual_param_entry_new (visual_param_entry_get_name (srcparam));
		visual_param_entry_set_from_param (destparam, srcparam);

		visual_param_container_add (destcont, destparam);
	}

	return VISUAL_OK;
}
示例#3
0
/* cur->name should be the element name */
static int parse_element (xmlNodePtr cur, LVAVSPresetElement *element)
{
  char *content;
  LVAVSPresetElement *child;
  VisParamEntry *param;

  for (cur = cur->xmlChildrenNode; cur; cur = cur->next)
  {
      if (xmlIsBlankNode (cur) || cur->type != XML_ELEMENT_NODE)
	continue;

	LVAVSPresetElementType type;
	xmlChar *prop = xmlGetProp(cur, (xmlChar *)"type");
	content = (char*)xmlNodeGetContent (cur);

	param = visual_param_entry_new((char *)cur->name);

	if(strcmp((char *)prop, "string") == 0) {
		visual_param_entry_set_string(param, content);
	} else if( strcmp((char *)prop, "float") == 0) {
		visual_param_entry_set_double(param, strtod(content, NULL));
	} else if( strcmp((char *)prop, "integer") == 0) {
		visual_param_entry_set_integer(param, (int)strtol(content, NULL, 0));
	} else if( strcmp((char *)prop, "color") == 0) {
		int r,g,b;
		char *s = content+1;
		r = strtoul (s, &s, 0);
		if (r > 255 || ! (s = strchr (s, ',')))
		  continue;
		g = strtoul (s+1, &s, 0);
		if (g > 255 || ! (s = strchr (s, ',')))
		  continue;
		b = strtoul (s+1, NULL, 0);
		if (b > 255)
		  continue;
		visual_param_entry_set_color(param, r, g, b);
	} else if( strcmp((char *)prop, "bool") == 0) {
		char *c, *d;
		int val;

#define isspace(c) (c == ' ' || c == '\t' || c == '\n')

		for (c=content; isspace (*c); c++);
		for (d=c; !isspace(*d); d++);
		*d = '\0';
		if (g_strcasecmp (c, "true") == 0)
		  val = TRUE;
		else if (g_strcasecmp (c, "false") == 0)
		  val = FALSE;
		else
			continue;
		visual_param_entry_set_integer(param, val);
	}

	visual_param_container_add(element->pcont, param);	

	xmlFree ((xmlChar*)content);
    }
    return TRUE;
}
示例#4
0
static int init_params (VisParamContainer *paramcontainer)
{
	VisParamEntry *param;

	visual_log_return_val_if_fail (paramcontainer != NULL, -1);

	/* Initialize all the global parameters here */

	/* Song information parameters */
	/* Show songinfo */
	param = visual_param_entry_new ("songinfo show");
	visual_param_entry_set_integer (param, 1);
	visual_param_container_add (paramcontainer, param);

	/* Songinfo timeout, in seconds */
	param = visual_param_entry_new ("songinfo timeout");
	visual_param_entry_set_integer (param, 5);
	visual_param_container_add (paramcontainer, param);

	/*
	 * Show songinfo in plugins, plugins that optionally show song
	 * info should query this parameter
	 */
	param = visual_param_entry_new ("songinfo in plugin");
	visual_param_entry_set_integer (param, 1);
	visual_param_container_add (paramcontainer, param);

	/* Cover art dimension */
	param = visual_param_entry_new ("songinfo cover size x");
	visual_param_entry_set_integer (param, 128);
	visual_param_container_add (paramcontainer, param);

	param = visual_param_entry_new ("songinfo cover size y");
	visual_param_entry_set_integer (param, 128);
	visual_param_container_add (paramcontainer, param);

	return 0;
}
示例#5
0
/**
 * Adds a list of VisParamEntry elements, the list is terminated by an entry of type VISUAL_PARAM_ENTRY_TYPE_END.
 * All the elements are reallocated, so this function can be used for static param lists.
 *
 * @param paramcontainer A pointer to the VisParamContainer in which the VisParamEntry elements are added.
 * @param params A pointer to the VisParamEntry elements that are added to the VisParamContainer.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_CONTAINER_NULL or -VISUAL_ERROR_PARAM_NULL on failure.
 */
int visual_param_container_add_many (VisParamContainer *paramcontainer, VisParamEntry *params)
{
	VisParamEntry *pnew;
	int i = 0;

	visual_log_return_val_if_fail (paramcontainer != NULL, -VISUAL_ERROR_PARAM_CONTAINER_NULL);
	visual_log_return_val_if_fail (params != NULL, -VISUAL_ERROR_PARAM_NULL);

	while (params[i].type != VISUAL_PARAM_ENTRY_TYPE_END) {
		pnew = visual_param_entry_new (visual_param_entry_get_name (&params[i]));
		visual_param_entry_set_from_param (pnew, &params[i]);

		visual_param_container_add (paramcontainer, pnew);

		i++;
	}

	return VISUAL_OK;
}
示例#6
0
AVSElement *avs_parse_element_non_complex (AVSTree *avstree, AVSElementType type, ...)
{
        AVSElement *element;
        AVSSerializeContainer *scont;
        VisParamContainer *pcont;
        va_list ap;
        char *pname;

        element = visual_mem_new0 (AVSElement, 1);

        /* Do the VisObject initialization */
        visual_object_initialize (VISUAL_OBJECT (element), TRUE, avs_element_dtor);

        element->type = type;

        pcont = visual_param_container_new ();
        scont = avs_serialize_container_new ();

        va_start (ap, type);

        while ((pname = va_arg (ap, char *)) != NULL) {
                VisParamEntry *param = visual_param_entry_new (pname);
                AVSSerializeEntry *sentry;

                sentry = avs_serialize_entry_new (param);
                sentry->type = va_arg (ap, AVSSerializeEntryType);

                avs_serialize_container_add (scont, sentry);
                visual_param_container_add (pcont, param);
        }

        va_end (ap);

        element->pcont = pcont;
        avs_element_connect_serialize_container (element, scont);

        avs_element_deserialize (element, avstree);

        return element;
}