Changeset 2bca4f1c7e98f40ff31e9b0474ec2a2b60d59379
- Timestamp:
- 12/17/07 20:01:13
(9 months ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1197918073 +0000
- git-parent:
[194072ae20ccef4d08ee5c88c987d0097b0fd2e6]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1197918073 +0000
- Message:
Add action through vlc_config_set
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rff8c208 |
r2bca4f1 |
|
| 276 | 276 | /* possible values list |
|---|
| 277 | 277 | * (args=size_t, const <type> *, const char *const *) */ |
|---|
| | 278 | |
|---|
| | 279 | VLC_CONFIG_ADD_ACTION, |
|---|
| | 280 | /* add value change callback (args=vlc_callback_t, const char *) */ |
|---|
| 278 | 281 | }; |
|---|
| 279 | 282 | |
|---|
| … | … | |
| 466 | 469 | (double)(minv), (double)(maxv)) |
|---|
| 467 | 470 | |
|---|
| 468 | | #define change_action_add( pf_action, action_text ) \ |
|---|
| 469 | | if( !p_config[i_config].i_action ) \ |
|---|
| 470 | | { p_config[i_config].ppsz_action_text = 0; \ |
|---|
| 471 | | p_config[i_config].ppf_action = 0; } \ |
|---|
| 472 | | p_config[i_config].ppf_action = (vlc_callback_t *) \ |
|---|
| 473 | | realloc( p_config[i_config].ppf_action, \ |
|---|
| 474 | | (p_config[i_config].i_action + 1) * sizeof(void *) ); \ |
|---|
| 475 | | p_config[i_config].ppsz_action_text = (char **)\ |
|---|
| 476 | | realloc( p_config[i_config].ppsz_action_text, \ |
|---|
| 477 | | (p_config[i_config].i_action + 1) * sizeof(void *) ); \ |
|---|
| 478 | | p_config[i_config].ppf_action[p_config[i_config].i_action] = pf_action; \ |
|---|
| 479 | | p_config[i_config].ppsz_action_text[p_config[i_config].i_action] = \ |
|---|
| 480 | | action_text; \ |
|---|
| 481 | | p_config[i_config].i_action++; |
|---|
| | 471 | #define change_action_add( pf_action, text ) \ |
|---|
| | 472 | vlc_config_set (p_config + i_config, VLC_CONFIG_ADD_ACTION, \ |
|---|
| | 473 | (vlc_callback_t)(pf_action), (const char *)(text)) |
|---|
| 482 | 474 | |
|---|
| 483 | 475 | #define change_internal() \ |
|---|
| re4c890c |
r2bca4f1 |
|
| 111 | 111 | __VLC_SYMBOL(vlc_entry) ( module_t *p_module ) \ |
|---|
| 112 | 112 | { \ |
|---|
| 113 | | int i_shortcut = 1, res; \ |
|---|
| | 113 | int res; \ |
|---|
| 114 | 114 | size_t i_config = (size_t)(-1); \ |
|---|
| 115 | 115 | module_config_t *p_config = NULL; \ |
|---|
| … | … | |
| 123 | 123 | } \ |
|---|
| 124 | 124 | res = config_Duplicate( p_module, p_config, ++i_config ); \ |
|---|
| 125 | | for( size_t i = 0; i < i_config; i++ ) \ |
|---|
| 126 | | { \ |
|---|
| 127 | | if( p_config[ i ].i_action ) \ |
|---|
| 128 | | { \ |
|---|
| 129 | | free( p_config[ i ].ppf_action ); \ |
|---|
| 130 | | free( p_config[ i ].ppsz_action_text ); \ |
|---|
| 131 | | } \ |
|---|
| 132 | | } \ |
|---|
| 133 | 125 | free( p_config ); \ |
|---|
| 134 | 126 | if (res) \ |
|---|
| 135 | 127 | return res; \ |
|---|
| 136 | | (void)i_shortcut; \ |
|---|
| 137 | 128 | return VLC_SUCCESS; \ |
|---|
| 138 | 129 | \ |
|---|
| r72aec0c |
r2bca4f1 |
|
| 521 | 521 | p_module->p_config[i] = p_orig[i]; |
|---|
| 522 | 522 | p_module->p_config[i].p_lock = &p_module->object_lock; |
|---|
| 523 | | |
|---|
| 524 | | /* duplicate the actions list */ |
|---|
| 525 | | if( p_orig[i].i_action ) |
|---|
| 526 | | { |
|---|
| 527 | | int j; |
|---|
| 528 | | |
|---|
| 529 | | p_module->p_config[i].ppf_action = |
|---|
| 530 | | malloc( p_orig[i].i_action * sizeof(void *) ); |
|---|
| 531 | | p_module->p_config[i].ppsz_action_text = |
|---|
| 532 | | malloc( p_orig[i].i_action * sizeof(char *) ); |
|---|
| 533 | | |
|---|
| 534 | | for( j = 0; j < p_orig[i].i_action; j++ ) |
|---|
| 535 | | { |
|---|
| 536 | | p_module->p_config[i].ppf_action[j] = |
|---|
| 537 | | p_orig[i].ppf_action[j]; |
|---|
| 538 | | p_module->p_config[i].ppsz_action_text[j] = |
|---|
| 539 | | strdupnull (p_orig[i].ppsz_action_text[j]); |
|---|
| 540 | | } |
|---|
| 541 | | } |
|---|
| 542 | | |
|---|
| 543 | | p_module->p_config[i].pf_callback = p_orig[i].pf_callback; |
|---|
| 544 | 523 | } |
|---|
| 545 | 524 | return VLC_SUCCESS; |
|---|
| r64ea683 |
r2bca4f1 |
|
| 356 | 356 | break; |
|---|
| 357 | 357 | } |
|---|
| | 358 | |
|---|
| | 359 | case VLC_CONFIG_ADD_ACTION: |
|---|
| | 360 | { |
|---|
| | 361 | vlc_callback_t cb = va_arg (ap, vlc_callback_t), *tabcb; |
|---|
| | 362 | const char *name = va_arg (ap, const char *); |
|---|
| | 363 | char **tabtext; |
|---|
| | 364 | |
|---|
| | 365 | tabcb = realloc (item->ppf_action, |
|---|
| | 366 | (item->i_action + 2) * sizeof (cb)); |
|---|
| | 367 | if (tabcb == NULL) |
|---|
| | 368 | break; |
|---|
| | 369 | item->ppf_action = tabcb; |
|---|
| | 370 | tabcb[item->i_action] = cb; |
|---|
| | 371 | tabcb[item->i_action + 1] = NULL; |
|---|
| | 372 | |
|---|
| | 373 | tabtext = realloc (item->ppsz_action_text, |
|---|
| | 374 | (item->i_action + 2) * sizeof (name)); |
|---|
| | 375 | if (tabtext == NULL) |
|---|
| | 376 | break; |
|---|
| | 377 | item->ppsz_action_text = tabtext; |
|---|
| | 378 | |
|---|
| | 379 | if (name) |
|---|
| | 380 | tabtext[item->i_action] = strdup (gettext (name)); |
|---|
| | 381 | else |
|---|
| | 382 | tabtext[item->i_action] = NULL; |
|---|
| | 383 | tabtext[item->i_action + 1] = NULL; |
|---|
| | 384 | |
|---|
| | 385 | item->i_action++; |
|---|
| | 386 | ret = 0; |
|---|
| | 387 | } |
|---|
| 358 | 388 | } |
|---|
| 359 | 389 | |
|---|