comparison src/aosd/aosd_cfg.c @ 596:1708b03e116c trunk

[svn] - aosd: replaced polling with hooks; added trigger options as well, working triggers are playback start and title changes
author giacomo
date Thu, 01 Feb 2007 16:45:47 -0800
parents 26519231a4f4
children ca9907354db6
comparison
equal deleted inserted replaced
595:99e8b9881cb9 596:1708b03e116c
68 { 68 {
69 aosd_cfg_t *cfg = g_malloc0(sizeof(aosd_cfg_t)); 69 aosd_cfg_t *cfg = g_malloc0(sizeof(aosd_cfg_t));
70 aosd_cfg_osd_t *cfg_osd = aosd_cfg_osd_new(); 70 aosd_cfg_osd_t *cfg_osd = aosd_cfg_osd_new();
71 cfg->set = FALSE; 71 cfg->set = FALSE;
72 cfg->osd = cfg_osd; 72 cfg->osd = cfg_osd;
73 cfg->osd->trigger.active = g_array_new( FALSE , TRUE , sizeof(gint) );
73 return cfg; 74 return cfg;
74 } 75 }
75 76
76 77
77 void 78 void
79 { 80 {
80 if ( cfg != NULL ) 81 if ( cfg != NULL )
81 { 82 {
82 if ( cfg->osd != NULL ) 83 if ( cfg->osd != NULL )
83 aosd_cfg_osd_delete( cfg->osd ); 84 aosd_cfg_osd_delete( cfg->osd );
85 g_array_free( cfg->osd->trigger.active , TRUE );
84 g_free( cfg ); 86 g_free( cfg );
85 } 87 }
86 return; 88 return;
87 } 89 }
88 90
158 #ifdef DEBUG 160 #ifdef DEBUG
159 void 161 void
160 aosd_cfg_debug ( aosd_cfg_t * cfg ) 162 aosd_cfg_debug ( aosd_cfg_t * cfg )
161 { 163 {
162 gint i = 0; 164 gint i = 0;
165 GString *string = g_string_new( "" );
163 g_print("\n***** debug configuration *****\n\n"); 166 g_print("\n***** debug configuration *****\n\n");
164 g_print("POSITION\n"); 167 g_print("POSITION\n");
165 g_print(" placement: %i\n", cfg->osd->position.placement); 168 g_print(" placement: %i\n", cfg->osd->position.placement);
166 g_print(" offset x: %i\n", cfg->osd->position.offset_x); 169 g_print(" offset x: %i\n", cfg->osd->position.offset_x);
167 g_print(" offset y: %i\n", cfg->osd->position.offset_y); 170 g_print(" offset y: %i\n", cfg->osd->position.offset_y);
189 for ( i = 0 ; i < cfg->osd->decoration.colors->len ; i++ ) 192 for ( i = 0 ; i < cfg->osd->decoration.colors->len ; i++ )
190 { 193 {
191 aosd_color_t color = g_array_index( cfg->osd->decoration.colors , aosd_color_t , i ); 194 aosd_color_t color = g_array_index( cfg->osd->decoration.colors , aosd_color_t , i );
192 g_print(" color %i: %i,%i,%i (alpha %i)\n", i, color.red, color.green, color.blue, color.alpha); 195 g_print(" color %i: %i,%i,%i (alpha %i)\n", i, color.red, color.green, color.blue, color.alpha);
193 } 196 }
197 g_print("\TRIGGER\n");
198 for ( i = 0 ; i < cfg->osd->trigger.active->len ; i++ )
199 g_string_append_printf( string , "%i," , g_array_index( cfg->osd->trigger.active , gint , i ) );
200 if ( string->len > 1 )
201 g_string_truncate( string , string->len - 1 );
202 g_print(" active: %s\n", string->str);
203 g_string_free( string , TRUE );
194 g_print("\nEXTRA\n"); 204 g_print("\nEXTRA\n");
195 g_print(" set: %i\n", cfg->set); 205 g_print(" set: %i\n", cfg->set);
196 g_print("\n*******************************\n\n"); 206 g_print("\n*******************************\n\n");
197 return; 207 return;
198 } 208 }
203 aosd_cfg_load ( aosd_cfg_t * cfg ) 213 aosd_cfg_load ( aosd_cfg_t * cfg )
204 { 214 {
205 ConfigDb *cfgfile = bmp_cfg_db_open(); 215 ConfigDb *cfgfile = bmp_cfg_db_open();
206 gint i = 0; 216 gint i = 0;
207 gint max_numcol; 217 gint max_numcol;
218 gchar *trig_active_str;
208 219
209 /* position */ 220 /* position */
210 if ( !bmp_cfg_db_get_int( cfgfile , "aosd" , 221 if ( !bmp_cfg_db_get_int( cfgfile , "aosd" ,
211 "position_placement" , &(cfg->osd->position.placement) ) ) 222 "position_placement" , &(cfg->osd->position.placement) ) )
212 cfg->osd->position.placement = AOSD_POSITION_PLACEMENT_TOPLEFT; 223 cfg->osd->position.placement = AOSD_POSITION_PLACEMENT_TOPLEFT;
307 } 318 }
308 aosd_cfg_util_str_to_color( color_str , &color ); 319 aosd_cfg_util_str_to_color( color_str , &color );
309 g_array_insert_val( cfg->osd->decoration.colors , i , color ); 320 g_array_insert_val( cfg->osd->decoration.colors , i , color );
310 } 321 }
311 322
323 /* trigger */
324 if ( !bmp_cfg_db_get_string( cfgfile , "aosd" , "trigger_active" , &trig_active_str ) )
325 {
326 gint trig_active_defval = 0;
327 g_array_append_val( cfg->osd->trigger.active , trig_active_defval );
328 }
329 else if ( strcmp("x",trig_active_str) )
330 {
331 gchar **trig_active_strv = g_strsplit( trig_active_str , "," , 0 );
332 gint j = 0;
333 while ( trig_active_strv[j] != NULL )
334 {
335 gint trig_active_val = strtol( trig_active_strv[j] , NULL , 10 );
336 g_array_append_val( cfg->osd->trigger.active , trig_active_val );
337 j++;
338 }
339 g_strfreev( trig_active_strv );
340 }
341
312 bmp_cfg_db_close( cfgfile ); 342 bmp_cfg_db_close( cfgfile );
313 343
314 /* the config object has been filled with information */ 344 /* the config object has been filled with information */
315 cfg->set = TRUE; 345 cfg->set = TRUE;
316 346
322 aosd_cfg_save ( aosd_cfg_t * cfg ) 352 aosd_cfg_save ( aosd_cfg_t * cfg )
323 { 353 {
324 ConfigDb *cfgfile = bmp_cfg_db_open(); 354 ConfigDb *cfgfile = bmp_cfg_db_open();
325 gint i = 0; 355 gint i = 0;
326 gint max_numcol; 356 gint max_numcol;
357 GString *string = g_string_new( "" );
327 358
328 if ( cfg->set == FALSE ) 359 if ( cfg->set == FALSE )
329 return -1; 360 return -1;
330 361
331 /* position */ 362 /* position */
402 key_str , color_str ); 433 key_str , color_str );
403 g_free( key_str ); 434 g_free( key_str );
404 g_free( color_str ); 435 g_free( color_str );
405 } 436 }
406 437
438 /* trigger */
439 for ( i = 0 ; i < cfg->osd->trigger.active->len ; i++ )
440 g_string_append_printf( string , "%i," , g_array_index( cfg->osd->trigger.active , gint , i ) );
441 if ( string->len > 1 )
442 g_string_truncate( string , string->len - 1 );
443 else
444 g_string_assign( string , "x" );
445 bmp_cfg_db_set_string( cfgfile , "aosd" , "trigger_active" , string->str );
446 g_string_free( string , TRUE );
447
407 bmp_cfg_db_close( cfgfile ); 448 bmp_cfg_db_close( cfgfile );
408 449
409 return 0; 450 return 0;
410 } 451 }