comparison src/audacious/tuple_formatter.c @ 3490:602ec8c40d0d trunk

Fixed to comply with the Tuple API changes.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 01 Sep 2007 07:09:38 +0300
parents 86dafe2300f7
children 3a2ee00bc962
comparison
equal deleted inserted replaced
3489:9580bb3e58fa 3490:602ec8c40d0d
269 } 269 }
270 270
271 /* ${artist} */ 271 /* ${artist} */
272 if (expr == NULL && argument == NULL) 272 if (expr == NULL && argument == NULL)
273 { 273 {
274 TupleValueType type = tuple_get_value_type(tuple, expression); 274 TupleValueType type = tuple_get_value_type(tuple, -1, expression);
275 275
276 switch(type) 276 switch(type)
277 { 277 {
278 case TUPLE_STRING: 278 case TUPLE_STRING:
279 return g_strdup(tuple_get_string(tuple, expression)); 279 return g_strdup(tuple_get_string(tuple, -1, expression));
280 break; 280 break;
281 case TUPLE_INT: 281 case TUPLE_INT:
282 return g_strdup_printf("%d", tuple_get_int(tuple, expression)); 282 return g_strdup_printf("%d", tuple_get_int(tuple, -1, expression));
283 break; 283 break;
284 case TUPLE_UNKNOWN: 284 case TUPLE_UNKNOWN:
285 default: 285 default:
286 return NULL; 286 return NULL;
287 } 287 }
381 381
382 /* builtin-keyword: ${?arg}, returns TRUE if <arg> exists. */ 382 /* builtin-keyword: ${?arg}, returns TRUE if <arg> exists. */
383 static gboolean 383 static gboolean
384 tuple_formatter_expression_exists(Tuple *tuple, const gchar *expression) 384 tuple_formatter_expression_exists(Tuple *tuple, const gchar *expression)
385 { 385 {
386 return (tuple_get_value_type(tuple, expression) != TUPLE_UNKNOWN) ? TRUE : FALSE; 386 return (tuple_get_value_type(tuple, -1, expression) != TUPLE_UNKNOWN) ? TRUE : FALSE;
387 } 387 }
388 388
389 /* builtin-keyword: ${==arg1,arg2}, returns TRUE if <arg1> and <arg2> match. 389 /* builtin-keyword: ${==arg1,arg2}, returns TRUE if <arg1> and <arg2> match.
390 <arg1> and <arg2> can also be raw text, which should be enclosed in "double quotes". */ 390 <arg1> and <arg2> can also be raw text, which should be enclosed in "double quotes". */
391 static gboolean 391 static gboolean
404 args[0][strlen(args[0]) - 1] = '\"'; 404 args[0][strlen(args[0]) - 1] = '\"';
405 } 405 }
406 else /* bad formatted arg */ 406 else /* bad formatted arg */
407 return FALSE; 407 return FALSE;
408 } 408 }
409 else if (tuple_get_value_type(tuple, args[0]) == TUPLE_UNKNOWN) 409 else if (tuple_get_value_type(tuple, -1, args[0]) == TUPLE_UNKNOWN)
410 { 410 {
411 g_strfreev(args); 411 g_strfreev(args);
412 return FALSE; 412 return FALSE;
413 } 413 }
414 414
421 args[1][strlen(args[1]) - 1] = '\"'; 421 args[1][strlen(args[1]) - 1] = '\"';
422 } 422 }
423 else /* bad formatted arg */ 423 else /* bad formatted arg */
424 return FALSE; 424 return FALSE;
425 } 425 }
426 else if (tuple_get_value_type(tuple, args[1]) == TUPLE_UNKNOWN) 426 else if (tuple_get_value_type(tuple, -1, args[1]) == TUPLE_UNKNOWN)
427 { 427 {
428 g_strfreev(args); 428 g_strfreev(args);
429 return FALSE; 429 return FALSE;
430 } 430 }
431 431
432 if (!arg1) /* if arg1 is not "raw text", get the tuple value */ 432 if (!arg1) /* if arg1 is not "raw text", get the tuple value */
433 { 433 {
434 if (tuple_get_value_type(tuple, args[0]) == TUPLE_STRING) 434 if (tuple_get_value_type(tuple, -1, args[0]) == TUPLE_STRING)
435 arg1 = g_strdup(tuple_get_string(tuple, args[0])); 435 arg1 = g_strdup(tuple_get_string(tuple, -1, args[0]));
436 else 436 else
437 arg1 = g_strdup_printf("%d", tuple_get_int(tuple, args[0])); 437 arg1 = g_strdup_printf("%d", tuple_get_int(tuple, -1, args[0]));
438 } 438 }
439 439
440 if (!arg2) /* if arg2 is not "raw text", get the tuple value */ 440 if (!arg2) /* if arg2 is not "raw text", get the tuple value */
441 { 441 {
442 if (tuple_get_value_type(tuple, args[1]) == TUPLE_STRING) 442 if (tuple_get_value_type(tuple, -1, args[1]) == TUPLE_STRING)
443 arg2 = g_strdup(tuple_get_string(tuple, args[1])); 443 arg2 = g_strdup(tuple_get_string(tuple, -1, args[1]));
444 else 444 else
445 arg2 = g_strdup_printf("%d", tuple_get_int(tuple, args[1])); 445 arg2 = g_strdup_printf("%d", tuple_get_int(tuple, -1, args[1]));
446 } 446 }
447 447
448 ret = g_ascii_strcasecmp(arg1, arg2); 448 ret = g_ascii_strcasecmp(arg1, arg2);
449 g_free(arg1); 449 g_free(arg1);
450 g_free(arg2); 450 g_free(arg2);
465 static gboolean 465 static gboolean
466 tuple_formatter_expression_empty(Tuple *tuple, const gchar *expression) 466 tuple_formatter_expression_empty(Tuple *tuple, const gchar *expression)
467 { 467 {
468 gboolean ret = TRUE; 468 gboolean ret = TRUE;
469 const gchar *iter; 469 const gchar *iter;
470 TupleValueType type = tuple_get_value_type(tuple, expression); 470 TupleValueType type = tuple_get_value_type(tuple, -1, expression);
471 471
472 if (type == TUPLE_UNKNOWN) 472 if (type == TUPLE_UNKNOWN)
473 return TRUE; 473 return TRUE;
474 474
475 if (type == TUPLE_INT && tuple_get_int(tuple, expression) != 0) 475 if (type == TUPLE_INT && tuple_get_int(tuple, -1, expression) != 0)
476 return FALSE; 476 return FALSE;
477 477
478 iter = tuple_get_string(tuple, expression); 478 iter = tuple_get_string(tuple, -1, expression);
479 479
480 while (ret && *iter != '\0') 480 while (ret && *iter != '\0')
481 { 481 {
482 if (*iter == ' ') 482 if (*iter == ' ')
483 iter++; 483 iter++;
527 527
528 rv = tuple_formatter_process_string(tuple, string); 528 rv = tuple_formatter_process_string(tuple, string);
529 529
530 if(!rv || !strcmp(rv, "")) { 530 if(!rv || !strcmp(rv, "")) {
531 g_free(rv); 531 g_free(rv);
532 rv = g_strdup(tuple_get_string(tuple, "file-name")); 532 rv = g_strdup(tuple_get_string(tuple, FIELD_FILE_NAME, NULL));
533 } 533 }
534 534
535 return rv; 535 return rv;
536 } 536 }