annotate src/aosd/aosd_trigger.c @ 2206:7c7e6f5c494e

added myself to authors
author Eugene Zagidullin <e.asphyx@gmail.com>
date Tue, 04 Dec 2007 02:11:02 +0300
parents c8d55b929442
children 5a925593d754
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
1 /*
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
2 *
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
3 * Author: Giacomo Lozito <james@develia.org>, (C) 2005-2007
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
4 *
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify it
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
6 * under the terms of the GNU General Public License as published by the
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
7 * Free Software Foundation; either version 2 of the License, or (at your
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
8 * option) any later version.
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
9 *
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful, but
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
13 * General Public License for more details.
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
14 *
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License along
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
16 * with this program; if not, write to the Free Software Foundation, Inc.,
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
18 *
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
19 */
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
20
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
21 #include "aosd_trigger.h"
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
22 #include "aosd_trigger_private.h"
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
23 #include "aosd_cfg.h"
2064
c8d55b929442 Just to hush down the warnings...
Eugene Paskevich <eugene@raptor.kiev.ua>
parents: 2060
diff changeset
24 #include "aosd_osd.h"
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
25 #include <glib.h>
746
40fb4189fa88 [svn] - aosd: replaced other occurrencies of glib18n with audacious i18n
giacomo
parents: 637
diff changeset
26 #include <audacious/i18n.h>
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
27 #include <audacious/playlist.h>
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
28 #include <audacious/strings.h>
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
29 #include <audacious/hook.h>
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
30 #include <audacious/auddrct.h>
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
31
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
32
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
33 extern aosd_cfg_t * global_config;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
34
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
35
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
36 /* trigger codes ( the code values do not need to be sequential ) */
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
37 enum
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
38 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
39 AOSD_TRIGGER_PB_START = 0,
623
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
40 AOSD_TRIGGER_PB_TITLECHANGE = 1,
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
41 AOSD_TRIGGER_VOL_CHANGE = 2,
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
42 AOSD_TRIGGER_PB_PAUSEON = 3,
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
43 AOSD_TRIGGER_PB_PAUSEOFF = 4
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
44 };
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
45
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
46 /* trigger codes array size */
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
47 #define AOSD_TRIGGER_CODES_ARRAY_SIZE 5
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
48
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
49 /* trigger codes array */
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
50 gint aosd_trigger_codes[] =
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
51 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
52 AOSD_TRIGGER_PB_START,
623
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
53 AOSD_TRIGGER_PB_TITLECHANGE,
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
54 AOSD_TRIGGER_VOL_CHANGE,
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
55 AOSD_TRIGGER_PB_PAUSEON,
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
56 AOSD_TRIGGER_PB_PAUSEOFF
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
57 };
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
58
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
59 /* prototypes of trigger functions */
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
60 static void aosd_trigger_func_pb_start_onoff ( gboolean );
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
61 static void aosd_trigger_func_pb_start_cb ( gpointer , gpointer );
623
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
62 static void aosd_trigger_func_pb_titlechange_onoff ( gboolean );
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
63 static void aosd_trigger_func_pb_titlechange_cb ( gpointer , gpointer );
623
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
64 static void aosd_trigger_func_vol_change_onoff ( gboolean );
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
65 static void aosd_trigger_func_vol_change_cb ( gpointer , gpointer );
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
66 static void aosd_trigger_func_pb_pauseon_onoff ( gboolean );
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
67 static void aosd_trigger_func_pb_pauseon_cb ( gpointer , gpointer );
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
68 static void aosd_trigger_func_pb_pauseoff_onoff ( gboolean );
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
69 static void aosd_trigger_func_pb_pauseoff_cb ( gpointer , gpointer );
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
70
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
71 /* map trigger codes to trigger objects */
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
72 aosd_trigger_t aosd_triggers[] =
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
73 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
74 [AOSD_TRIGGER_PB_START] = { N_("Playback Start") ,
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
75 N_("Triggers OSD when a playlist entry is played.") ,
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
76 aosd_trigger_func_pb_start_onoff ,
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
77 aosd_trigger_func_pb_start_cb },
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
78
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
79 [AOSD_TRIGGER_PB_TITLECHANGE] = { N_("Title Change") ,
637
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
80 N_("Triggers OSD when, during playback, the song title changes "
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
81 "but the filename is the same. This is mostly useful to display "
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
82 "title changes in internet streams.") ,
623
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
83 aosd_trigger_func_pb_titlechange_onoff ,
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
84 aosd_trigger_func_pb_titlechange_cb },
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
85
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
86 [AOSD_TRIGGER_VOL_CHANGE] = { N_("Volume Change") ,
637
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
87 N_("Triggers OSD when volume is changed.") ,
623
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
88 aosd_trigger_func_vol_change_onoff ,
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
89 aosd_trigger_func_vol_change_cb },
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
90
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
91 [AOSD_TRIGGER_PB_PAUSEON] = { N_("Pause On") ,
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
92 N_("Triggers OSD when playback is paused.") ,
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
93 aosd_trigger_func_pb_pauseon_onoff ,
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
94 aosd_trigger_func_pb_pauseon_cb },
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
95
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
96 [AOSD_TRIGGER_PB_PAUSEOFF] = { N_("Pause Off") ,
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
97 N_("Triggers OSD when playback is unpaused.") ,
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
98 aosd_trigger_func_pb_pauseoff_onoff ,
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
99 aosd_trigger_func_pb_pauseoff_cb }
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
100 };
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
101
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
102
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
103
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
104 /* TRIGGER API */
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
105
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
106 void
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
107 aosd_trigger_get_codes_array ( gint ** array , gint * array_size )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
108 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
109 *array = aosd_trigger_codes;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
110 *array_size = AOSD_TRIGGER_CODES_ARRAY_SIZE;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
111 return;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
112 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
113
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
114
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
115 const gchar *
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
116 aosd_trigger_get_name ( gint trig_code )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
117 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
118 return aosd_triggers[trig_code].name;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
119 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
120
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
121
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
122 const gchar *
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
123 aosd_trigger_get_desc ( gint trig_code )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
124 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
125 return aosd_triggers[trig_code].desc;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
126 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
127
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
128
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
129 void
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
130 aosd_trigger_start ( aosd_cfg_osd_trigger_t * cfg_trigger )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
131 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
132 gint i = 0;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
133 for ( i = 0 ; i < cfg_trigger->active->len ; i++ )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
134 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
135 gint trig_code = g_array_index( cfg_trigger->active , gint , i );
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
136 aosd_triggers[trig_code].onoff_func( TRUE );
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
137 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
138 return;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
139 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
140
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
141
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
142 void
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
143 aosd_trigger_stop ( aosd_cfg_osd_trigger_t * cfg_trigger )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
144 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
145 gint i = 0;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
146 for ( i = 0 ; i < cfg_trigger->active->len ; i++ )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
147 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
148 gint trig_code = g_array_index( cfg_trigger->active , gint , i );
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
149 aosd_triggers[trig_code].onoff_func( FALSE );
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
150 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
151 return;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
152 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
153
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
154
893
ca9907354db6 [svn] - aosd: added an option to enable/disable utf8 text conversion done by the plugin
giacomo
parents: 890
diff changeset
155 /* HELPER FUNCTIONS */
ca9907354db6 [svn] - aosd: added an option to enable/disable utf8 text conversion done by the plugin
giacomo
parents: 890
diff changeset
156
ca9907354db6 [svn] - aosd: added an option to enable/disable utf8 text conversion done by the plugin
giacomo
parents: 890
diff changeset
157 static gchar *
ca9907354db6 [svn] - aosd: added an option to enable/disable utf8 text conversion done by the plugin
giacomo
parents: 890
diff changeset
158 aosd_trigger_utf8convert ( gchar * str )
ca9907354db6 [svn] - aosd: added an option to enable/disable utf8 text conversion done by the plugin
giacomo
parents: 890
diff changeset
159 {
ca9907354db6 [svn] - aosd: added an option to enable/disable utf8 text conversion done by the plugin
giacomo
parents: 890
diff changeset
160 if ( global_config->osd->text.utf8conv_disable == FALSE )
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 1238
diff changeset
161 return aud_str_to_utf8( str );
893
ca9907354db6 [svn] - aosd: added an option to enable/disable utf8 text conversion done by the plugin
giacomo
parents: 890
diff changeset
162 else
ca9907354db6 [svn] - aosd: added an option to enable/disable utf8 text conversion done by the plugin
giacomo
parents: 890
diff changeset
163 return g_strdup( str );
ca9907354db6 [svn] - aosd: added an option to enable/disable utf8 text conversion done by the plugin
giacomo
parents: 890
diff changeset
164 }
ca9907354db6 [svn] - aosd: added an option to enable/disable utf8 text conversion done by the plugin
giacomo
parents: 890
diff changeset
165
ca9907354db6 [svn] - aosd: added an option to enable/disable utf8 text conversion done by the plugin
giacomo
parents: 890
diff changeset
166
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
167 /* TRIGGER FUNCTIONS */
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
168
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
169 static void
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
170 aosd_trigger_func_pb_start_onoff ( gboolean turn_on )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
171 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
172 if ( turn_on == TRUE )
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
173 aud_hook_associate( "playback begin" , aosd_trigger_func_pb_start_cb , NULL );
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
174 else
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
175 aud_hook_dissociate( "playback begin" , aosd_trigger_func_pb_start_cb );
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
176 return;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
177 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
178
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
179 static void
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
180 aosd_trigger_func_pb_start_cb ( gpointer plentry_gp , gpointer unused )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
181 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
182 PlaylistEntry *pl_entry = plentry_gp;
598
e83e6fb3ebfa [svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
giacomo
parents: 597
diff changeset
183 if ( plentry_gp != NULL )
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
184 {
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
185 gchar *title, *utf8_title;
598
e83e6fb3ebfa [svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
giacomo
parents: 597
diff changeset
186 if ( pl_entry->title != NULL )
e83e6fb3ebfa [svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
giacomo
parents: 597
diff changeset
187 {
e83e6fb3ebfa [svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
giacomo
parents: 597
diff changeset
188 /* if there is a proper title, use it */
e83e6fb3ebfa [svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
giacomo
parents: 597
diff changeset
189 title = g_strdup(pl_entry->title);
e83e6fb3ebfa [svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
giacomo
parents: 597
diff changeset
190 }
e83e6fb3ebfa [svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
giacomo
parents: 597
diff changeset
191 else
e83e6fb3ebfa [svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
giacomo
parents: 597
diff changeset
192 {
e83e6fb3ebfa [svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
giacomo
parents: 597
diff changeset
193 /* pick what we have as song title */
2057
cf4fa45ffd80 playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents: 2050
diff changeset
194 Playlist *active = aud_playlist_get_active();
cf4fa45ffd80 playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents: 2050
diff changeset
195 gint pos = aud_playlist_get_position(active);
cf4fa45ffd80 playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents: 2050
diff changeset
196 title = aud_playlist_get_songtitle(active, pos);
598
e83e6fb3ebfa [svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
giacomo
parents: 597
diff changeset
197 }
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
198 utf8_title = aosd_trigger_utf8convert( title );
766
53f63f43663f [svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
giacomo
parents: 746
diff changeset
199 if ( g_utf8_validate( utf8_title , -1 , NULL ) == TRUE )
53f63f43663f [svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
giacomo
parents: 746
diff changeset
200 {
53f63f43663f [svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
giacomo
parents: 746
diff changeset
201 gchar *utf8_title_markup = g_markup_printf_escaped(
53f63f43663f [svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
giacomo
parents: 746
diff changeset
202 "<span font_desc='%s'>%s</span>" , global_config->osd->text.fonts_name[0] , utf8_title );
883
e6d51d079a46 [svn] - aosd: use a single ghosd object for all of the osd showups; this will be a lot gentler to XLib and should definitely help with stability
giacomo
parents: 787
diff changeset
203 aosd_osd_display( utf8_title_markup , global_config->osd , FALSE );
766
53f63f43663f [svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
giacomo
parents: 746
diff changeset
204 g_free( utf8_title_markup );
53f63f43663f [svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
giacomo
parents: 746
diff changeset
205 }
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
206 g_free( utf8_title );
598
e83e6fb3ebfa [svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
giacomo
parents: 597
diff changeset
207 g_free( title );
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
208 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
209 return;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
210 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
211
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
212
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
213
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
214 typedef struct
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
215 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
216 gchar *title;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
217 gchar *filename;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
218 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
219 aosd_pb_titlechange_prevs_t;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
220
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
221
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
222 static void
623
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
223 aosd_trigger_func_pb_titlechange_onoff ( gboolean turn_on )
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
224 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
225 static aosd_pb_titlechange_prevs_t *prevs = NULL;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
226
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
227 if ( turn_on == TRUE )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
228 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
229 prevs = g_malloc0(sizeof(aosd_pb_titlechange_prevs_t));
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
230 prevs->title = NULL;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
231 prevs->filename = NULL;
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
232 aud_hook_associate( "playlist set info" , aosd_trigger_func_pb_titlechange_cb , prevs );
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
233 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
234 else
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
235 {
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
236 aud_hook_dissociate( "playlist set info" , aosd_trigger_func_pb_titlechange_cb );
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
237 if ( prevs != NULL )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
238 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
239 if ( prevs->title != NULL ) g_free( prevs->title );
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
240 if ( prevs->filename != NULL ) g_free( prevs->filename );
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
241 g_free( prevs );
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
242 prevs = NULL;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
243 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
244 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
245 return;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
246 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
247
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
248 static void
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
249 aosd_trigger_func_pb_titlechange_cb ( gpointer plentry_gp , gpointer prevs_gp )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
250 {
2058
fffa7e3d39e0 use aud_ip_state (replacement to ip_data).
William Pitcock <nenolod@atheme.org>
parents: 2057
diff changeset
251 if ( aud_ip_state->playing )
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
252 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
253 aosd_pb_titlechange_prevs_t *prevs = prevs_gp;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
254 PlaylistEntry *pl_entry = plentry_gp;
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
255
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
256 /* same filename but title changed, useful to detect http stream song changes */
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
257
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
258 if ( ( prevs->title != NULL ) && ( prevs->filename != NULL ) )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
259 {
598
e83e6fb3ebfa [svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
giacomo
parents: 597
diff changeset
260 if ( ( pl_entry->filename != NULL ) && ( !strcmp(pl_entry->filename,prevs->filename) ) )
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
261 {
598
e83e6fb3ebfa [svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
giacomo
parents: 597
diff changeset
262 if ( ( pl_entry->title != NULL ) && ( strcmp(pl_entry->title,prevs->title) ) )
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
263 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
264 /* string formatting is done here a.t.m. - TODO - improve this area */
893
ca9907354db6 [svn] - aosd: added an option to enable/disable utf8 text conversion done by the plugin
giacomo
parents: 890
diff changeset
265 gchar *utf8_title = aosd_trigger_utf8convert( pl_entry->title );
766
53f63f43663f [svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
giacomo
parents: 746
diff changeset
266 if ( g_utf8_validate( utf8_title , -1 , NULL ) == TRUE )
53f63f43663f [svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
giacomo
parents: 746
diff changeset
267 {
53f63f43663f [svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
giacomo
parents: 746
diff changeset
268 gchar *utf8_title_markup = g_markup_printf_escaped(
53f63f43663f [svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
giacomo
parents: 746
diff changeset
269 "<span font_desc='%s'>%s</span>" , global_config->osd->text.fonts_name[0] , utf8_title );
883
e6d51d079a46 [svn] - aosd: use a single ghosd object for all of the osd showups; this will be a lot gentler to XLib and should definitely help with stability
giacomo
parents: 787
diff changeset
270 aosd_osd_display( utf8_title_markup , global_config->osd , FALSE );
766
53f63f43663f [svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
giacomo
parents: 746
diff changeset
271 g_free( utf8_title_markup );
53f63f43663f [svn] - extra check with g_utf8_validate to avoid the osd crash when a non-utf8 string survives the str_to_utf8 conversion
giacomo
parents: 746
diff changeset
272 }
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
273 g_free( utf8_title );
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
274 g_free( prevs->title );
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
275 prevs->title = g_strdup(pl_entry->title);
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
276 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
277 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
278 else
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
279 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
280 g_free(prevs->filename);
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
281 prevs->filename = g_strdup(pl_entry->filename);
609
9b73eb35f4ff [svn] - aosd: avoid collision between playback start trigger and titlechange trigger, that occurred when the next file in playlist was played
giacomo
parents: 598
diff changeset
282 /* if filename changes, reset title as well */
9b73eb35f4ff [svn] - aosd: avoid collision between playback start trigger and titlechange trigger, that occurred when the next file in playlist was played
giacomo
parents: 598
diff changeset
283 if ( prevs->title != NULL )
9b73eb35f4ff [svn] - aosd: avoid collision between playback start trigger and titlechange trigger, that occurred when the next file in playlist was played
giacomo
parents: 598
diff changeset
284 g_free(prevs->title);
9b73eb35f4ff [svn] - aosd: avoid collision between playback start trigger and titlechange trigger, that occurred when the next file in playlist was played
giacomo
parents: 598
diff changeset
285 prevs->title = g_strdup(pl_entry->title);
597
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
286 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
287 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
288 else
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
289 {
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
290 if ( prevs->title != NULL )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
291 g_free(prevs->title);
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
292 prevs->title = g_strdup(pl_entry->title);
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
293 if ( prevs->filename != NULL )
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
294 g_free(prevs->filename);
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
295 prevs->filename = g_strdup(pl_entry->filename);
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
296 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
297 }
05bc0456fabb [svn] - aosd: add missing aosd_trigger* sources
giacomo
parents:
diff changeset
298 }
623
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
299
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
300
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
301 static void
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
302 aosd_trigger_func_vol_change_onoff ( gboolean turn_on )
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
303 {
637
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
304 if ( turn_on == TRUE )
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
305 aud_hook_associate( "volume set" , aosd_trigger_func_vol_change_cb , NULL );
637
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
306 else
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
307 aud_hook_dissociate( "volume set" , aosd_trigger_func_vol_change_cb );
623
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
308 return;
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
309 }
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
310
637
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
311 typedef struct
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
312 {
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
313 gint h_vol[2];
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
314 gint sid;
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
315 }
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
316 aosd_vol_change_bucket_t;
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
317
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
318 static gboolean
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
319 aosd_trigger_func_vol_change_timeout ( gpointer bucket_gp )
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
320 {
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
321 aosd_vol_change_bucket_t *bucket = bucket_gp;
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
322 gchar *utf8_title_markup = g_markup_printf_escaped(
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
323 "<span font_desc='%s'>Volume Change - L: %i , R: %i</span>" ,
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
324 global_config->osd->text.fonts_name[0] , bucket->h_vol[0] , bucket->h_vol[1] );
883
e6d51d079a46 [svn] - aosd: use a single ghosd object for all of the osd showups; this will be a lot gentler to XLib and should definitely help with stability
giacomo
parents: 787
diff changeset
325 aosd_osd_display( utf8_title_markup , global_config->osd , FALSE );
637
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
326 g_free( utf8_title_markup );
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
327 bucket->sid = 0; /* reset source id value */
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
328 return FALSE;
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
329 }
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
330
623
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
331 static void
637
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
332 aosd_trigger_func_vol_change_cb ( gpointer h_vol_gp , gpointer unused )
623
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
333 {
637
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
334 gint *h_vol = h_vol_gp;
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
335 static aosd_vol_change_bucket_t bucket = { { 0 , 0 } , 0 };
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
336
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
337 bucket.h_vol[0] = h_vol[0];
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
338 bucket.h_vol[1] = h_vol[1];
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
339
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
340 /* in order to avoid repeated display of osd for each volume variation, use a
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
341 timer to prevent it from appearing more than once when multiple volume
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
342 changes are performed in a short time interval (500 msec) */
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
343 if ( bucket.sid == 0 )
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
344 {
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
345 /* first call in the time interval */
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
346 bucket.sid = g_timeout_add( 500 , aosd_trigger_func_vol_change_timeout , &bucket );
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
347 }
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
348 else
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
349 {
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
350 /* another call in the same interval, reset the interval */
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
351 g_source_remove( bucket.sid );
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
352 bucket.sid = g_timeout_add( 500 , aosd_trigger_func_vol_change_timeout , &bucket );
a1687bd302ce [svn] - aosd: completed volume change trigger, works now
giacomo
parents: 623
diff changeset
353 }
623
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
354 return;
443de962d0a0 [svn] - aosd: revert window type setting
giacomo
parents: 609
diff changeset
355 }
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
356
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
357
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
358 static void
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
359 aosd_trigger_func_pb_pauseon_onoff ( gboolean turn_on )
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
360 {
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
361 if ( turn_on == TRUE )
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
362 aud_hook_associate( "playback pause" , aosd_trigger_func_pb_pauseon_cb , NULL );
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
363 else
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
364 aud_hook_dissociate( "playback pause" , aosd_trigger_func_pb_pauseon_cb );
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
365 return;
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
366 }
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
367
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
368 static void
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
369 aosd_trigger_func_pb_pauseon_cb ( gpointer unused1 , gpointer unused2 )
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
370 {
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
371 gchar *utf8_title_markup = g_markup_printf_escaped(
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
372 "<span font_desc='%s'>Paused</span>" , global_config->osd->text.fonts_name[0] );
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
373 aosd_osd_display( utf8_title_markup , global_config->osd , FALSE );
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
374 g_free( utf8_title_markup );
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
375 return;
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
376 }
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
377
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
378
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
379 static void
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
380 aosd_trigger_func_pb_pauseoff_onoff ( gboolean turn_on )
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
381 {
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
382 if ( turn_on == TRUE )
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
383 aud_hook_associate( "playback unpause" , aosd_trigger_func_pb_pauseoff_cb , NULL );
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
384 else
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
385 aud_hook_dissociate( "playback unpause" , aosd_trigger_func_pb_pauseoff_cb );
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
386 return;
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
387 }
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
388
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
389 static void
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
390 aosd_trigger_func_pb_pauseoff_cb ( gpointer unused1 , gpointer unused2 )
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
391 {
2057
cf4fa45ffd80 playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents: 2050
diff changeset
392 Playlist *active = aud_playlist_get_active();
cf4fa45ffd80 playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents: 2050
diff changeset
393 gint pos = aud_playlist_get_position(active);
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
394 gchar *title, *utf8_title, *utf8_title_markup;
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
395 gint time_cur, time_tot;
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
396 gint time_cur_m, time_cur_s, time_tot_m, time_tot_s;
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
397
2057
cf4fa45ffd80 playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents: 2050
diff changeset
398 time_tot = aud_playlist_get_songtime(active, pos) / 1000;
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
399 time_cur = audacious_drct_get_time() / 1000;
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
400 time_cur_s = time_cur % 60;
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
401 time_cur_m = (time_cur - time_cur_s) / 60;
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
402 time_tot_s = time_tot % 60;
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
403 time_tot_m = (time_tot - time_tot_s) / 60;
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
404
2057
cf4fa45ffd80 playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents: 2050
diff changeset
405 title = aud_playlist_get_songtitle(active, pos);
1238
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
406 utf8_title = aosd_trigger_utf8convert( title );
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
407 utf8_title_markup = g_markup_printf_escaped(
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
408 "<span font_desc='%s'>%s (%i:%02i/%i:%02i)</span>" ,
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
409 global_config->osd->text.fonts_name[0] , utf8_title , time_cur_m , time_cur_s , time_tot_m , time_tot_s );
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
410 aosd_osd_display( utf8_title_markup , global_config->osd , FALSE );
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
411 g_free( utf8_title_markup );
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
412 g_free( utf8_title );
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
413 g_free( title );
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
414 return;
5d9fb703a7cc aosd: added triggers for pause and unpause event
Giacomo Lozito <james@develia.org>
parents: 893
diff changeset
415 }