comparison src/statusicon/si_ui.c @ 1054:2d6a00ed166f trunk

[svn] - statusicon: partial rewrite of si_ui_statusicon_cb_hook_tchange , nicer this way
author giacomo
date Tue, 22 May 2007 02:28:58 -0700
parents 149fc284aa86
children 95b8abed24c7
comparison
equal deleted inserted replaced
1053:149fc284aa86 1054:2d6a00ed166f
207 si_ui_statusicon_cb_hook_pbstart ( gpointer plentry_gp , gpointer evbox ) 207 si_ui_statusicon_cb_hook_pbstart ( gpointer plentry_gp , gpointer evbox )
208 { 208 {
209 if ( ( GPOINTER_TO_INT(g_object_get_data( G_OBJECT(evbox) , "popup_active" )) == 1 ) && 209 if ( ( GPOINTER_TO_INT(g_object_get_data( G_OBJECT(evbox) , "popup_active" )) == 1 ) &&
210 ( plentry_gp != NULL ) ) 210 ( plentry_gp != NULL ) )
211 { 211 {
212 g_print("hook change? 1\n");
213 si_ui_statusicon_popup_hide( evbox ); 212 si_ui_statusicon_popup_hide( evbox );
214 si_ui_statusicon_popup_timer_start( evbox ); 213 si_ui_statusicon_popup_timer_start( evbox );
215 } 214 }
216 } 215 }
217 216
218 217
219 static void 218 static void
220 si_ui_statusicon_cb_hook_tchange ( gpointer plentry_gp , gpointer prevs_gp ) 219 si_ui_statusicon_cb_hook_tchange ( gpointer plentry_gp , gpointer prevs_gp )
221 { 220 {
222 /* NOTE: this is quite intricated, but it works nicely and it's still
223 much better than polling; wonder if it can be simplified with some
224 help from the core player */
225 si_hook_tchange_prevs_t *prevs = prevs_gp; 221 si_hook_tchange_prevs_t *prevs = prevs_gp;
226 PlaylistEntry *pl_entry = plentry_gp; 222 PlaylistEntry *pl_entry = plentry_gp;
227 if ( ( GPOINTER_TO_INT(g_object_get_data( G_OBJECT(prevs->evbox) , "popup_active" )) == 1 ) && 223 gboolean upd_pop = FALSE;
228 ( plentry_gp != NULL ) ) 224
225 if ( pl_entry != NULL )
229 { 226 {
230 if ( ( prevs->title != NULL ) && ( prevs->filename != NULL ) ) 227 if ( ( prevs->title != NULL ) && ( prevs->filename != NULL ) )
231 { 228 {
232 if ( ( pl_entry->filename != NULL ) && 229 if ( ( pl_entry->filename != NULL ) &&
233 ( !strcmp(pl_entry->filename,prevs->filename) ) ) 230 ( !strcmp(pl_entry->filename,prevs->filename) ) )
234 { 231 {
235 if ( ( pl_entry->title != NULL ) && 232 if ( ( pl_entry->title != NULL ) &&
236 ( strcmp(pl_entry->title,prevs->title) ) ) 233 ( strcmp(pl_entry->title,prevs->title) ) )
237 { 234 {
238 si_ui_statusicon_popup_hide( prevs->evbox );
239 si_ui_statusicon_popup_timer_start( prevs->evbox );
240 g_free( prevs->title ); 235 g_free( prevs->title );
241 prevs->title = g_strdup(pl_entry->title); 236 prevs->title = g_strdup(pl_entry->title);
237 upd_pop = TRUE;
242 } 238 }
243 } 239 }
244 else 240 else
245 { 241 {
246 g_free(prevs->filename); 242 g_free(prevs->filename);
247 prevs->filename = g_strdup(pl_entry->filename); 243 prevs->filename = g_strdup(pl_entry->filename);
248 /* if filename changes, reset title as well */ 244 /* if filename changes, reset title as well */
249 if ( prevs->title != NULL ) 245 g_free(prevs->title);
250 g_free(prevs->title);
251 prevs->title = g_strdup(pl_entry->title); 246 prevs->title = g_strdup(pl_entry->title);
252 } 247 }
253 } 248 }
254 else 249 else
255 { 250 {
259 if ( prevs->filename != NULL ) 254 if ( prevs->filename != NULL )
260 g_free(prevs->filename); 255 g_free(prevs->filename);
261 prevs->filename = g_strdup(pl_entry->filename); 256 prevs->filename = g_strdup(pl_entry->filename);
262 } 257 }
263 } 258 }
264 else if ( ( prevs->title != NULL ) && 259
265 ( pl_entry->title != NULL ) && 260 if ( ( upd_pop == TRUE ) &&
266 ( strcmp(pl_entry->title,prevs->title) ) ) 261 ( GPOINTER_TO_INT(g_object_get_data( G_OBJECT(prevs->evbox) , "popup_active" )) == 1 ) )
267 { 262 {
268 g_free(prevs->title); 263 si_ui_statusicon_popup_hide( prevs->evbox );
269 prevs->title = g_strdup(pl_entry->title); 264 si_ui_statusicon_popup_timer_start( prevs->evbox );
270 } 265 }
271 } 266 }
272 267
273 268
274 static gboolean 269 static gboolean