Mercurial > audlegacy-plugins
comparison src/aosd/aosd_trigger.c @ 2288:5a925593d754
Audacious OSD Plugin: Added trigger "aosd toggle" to trigger display of OSD from other plugins
author | Sascha Hlusiak <contact@saschahlusiak.de> |
---|---|
date | Thu, 10 Jan 2008 14:42:03 +0100 |
parents | c8d55b929442 |
children | bd3a24b39058 |
comparison
equal
deleted
inserted
replaced
2287:2421c87fb855 | 2288:5a925593d754 |
---|---|
65 static void aosd_trigger_func_vol_change_cb ( gpointer , gpointer ); | 65 static void aosd_trigger_func_vol_change_cb ( gpointer , gpointer ); |
66 static void aosd_trigger_func_pb_pauseon_onoff ( gboolean ); | 66 static void aosd_trigger_func_pb_pauseon_onoff ( gboolean ); |
67 static void aosd_trigger_func_pb_pauseon_cb ( gpointer , gpointer ); | 67 static void aosd_trigger_func_pb_pauseon_cb ( gpointer , gpointer ); |
68 static void aosd_trigger_func_pb_pauseoff_onoff ( gboolean ); | 68 static void aosd_trigger_func_pb_pauseoff_onoff ( gboolean ); |
69 static void aosd_trigger_func_pb_pauseoff_cb ( gpointer , gpointer ); | 69 static void aosd_trigger_func_pb_pauseoff_cb ( gpointer , gpointer ); |
70 static void aosd_trigger_func_hook_cb ( gpointer markup_text , gpointer unused ); | |
70 | 71 |
71 /* map trigger codes to trigger objects */ | 72 /* map trigger codes to trigger objects */ |
72 aosd_trigger_t aosd_triggers[] = | 73 aosd_trigger_t aosd_triggers[] = |
73 { | 74 { |
74 [AOSD_TRIGGER_PB_START] = { N_("Playback Start") , | 75 [AOSD_TRIGGER_PB_START] = { N_("Playback Start") , |
133 for ( i = 0 ; i < cfg_trigger->active->len ; i++ ) | 134 for ( i = 0 ; i < cfg_trigger->active->len ; i++ ) |
134 { | 135 { |
135 gint trig_code = g_array_index( cfg_trigger->active , gint , i ); | 136 gint trig_code = g_array_index( cfg_trigger->active , gint , i ); |
136 aosd_triggers[trig_code].onoff_func( TRUE ); | 137 aosd_triggers[trig_code].onoff_func( TRUE ); |
137 } | 138 } |
139 /* When called, this hook will display the text of the user pointer | |
140 or the current playing song, if NULL */ | |
141 aud_hook_register("aosd toggle"); | |
142 aud_hook_associate( "aosd toggle" , aosd_trigger_func_hook_cb , NULL ); | |
138 return; | 143 return; |
139 } | 144 } |
140 | 145 |
141 | 146 |
142 void | 147 void |
143 aosd_trigger_stop ( aosd_cfg_osd_trigger_t * cfg_trigger ) | 148 aosd_trigger_stop ( aosd_cfg_osd_trigger_t * cfg_trigger ) |
144 { | 149 { |
145 gint i = 0; | 150 gint i = 0; |
151 aud_hook_dissociate( "aosd toggle" , aosd_trigger_func_hook_cb ); | |
146 for ( i = 0 ; i < cfg_trigger->active->len ; i++ ) | 152 for ( i = 0 ; i < cfg_trigger->active->len ; i++ ) |
147 { | 153 { |
148 gint trig_code = g_array_index( cfg_trigger->active , gint , i ); | 154 gint trig_code = g_array_index( cfg_trigger->active , gint , i ); |
149 aosd_triggers[trig_code].onoff_func( FALSE ); | 155 aosd_triggers[trig_code].onoff_func( FALSE ); |
150 } | 156 } |
411 g_free( utf8_title_markup ); | 417 g_free( utf8_title_markup ); |
412 g_free( utf8_title ); | 418 g_free( utf8_title ); |
413 g_free( title ); | 419 g_free( title ); |
414 return; | 420 return; |
415 } | 421 } |
422 | |
423 | |
424 /* Call with aud_hook_call("aosd toggle", param); | |
425 If param != NULL, display the supplied text in the OSD | |
426 If param == NULL, display the current playing song */ | |
427 static void | |
428 aosd_trigger_func_hook_cb ( gpointer markup_text , gpointer unused ) | |
429 { | |
430 if ( markup_text != NULL ) | |
431 { | |
432 /* Display text from caller */ | |
433 aosd_osd_display( markup_text , global_config->osd , FALSE ); | |
434 } else { | |
435 /* Display currently playing song */ | |
436 Playlist* pl; | |
437 PlaylistEntry *pl_entry; | |
438 | |
439 pl = aud_playlist_get_active(); | |
440 if (pl == NULL) return; | |
441 pl_entry = aud_playlist_get_entry_to_play(pl); | |
442 aosd_trigger_func_pb_start_cb ( (void*)pl_entry, NULL ); | |
443 } | |
444 return; | |
445 } |