changeset 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 0cc6b35fbeb4
files ChangeLog src/statusicon/si_ui.c
diffstat 2 files changed, 17 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue May 22 01:56:51 2007 -0700
+++ b/ChangeLog	Tue May 22 02:28:58 2007 -0700
@@ -1,3 +1,10 @@
+2007-05-22 08:56:51 +0000  Giacomo Lozito <james@develia.org>
+  revision [2272]
+  - statusicon: strenghten checks before last strcmp in si_ui_statusicon_cb_hook_tchange
+  trunk/src/statusicon/si_ui.c |    4 +++-
+  1 file changed, 3 insertions(+), 1 deletion(-)
+
+
 2007-05-21 23:34:55 +0000  Tony Vroon <chainsaw@gentoo.org>
   revision [2270]
   Isn't that cute. But it's WRONG
--- a/src/statusicon/si_ui.c	Tue May 22 01:56:51 2007 -0700
+++ b/src/statusicon/si_ui.c	Tue May 22 02:28:58 2007 -0700
@@ -209,7 +209,6 @@
   if ( ( GPOINTER_TO_INT(g_object_get_data( G_OBJECT(evbox) , "popup_active" )) == 1 ) &&
        ( plentry_gp != NULL ) )
   {
-g_print("hook change? 1\n");
     si_ui_statusicon_popup_hide( evbox );
     si_ui_statusicon_popup_timer_start( evbox );
   }
@@ -219,13 +218,11 @@
 static void
 si_ui_statusicon_cb_hook_tchange ( gpointer plentry_gp , gpointer prevs_gp )
 {
-  /* NOTE: this is quite intricated, but it works nicely and it's still
-     much better than polling; wonder if it can be simplified with some
-     help from the core player */
   si_hook_tchange_prevs_t *prevs = prevs_gp;
   PlaylistEntry *pl_entry = plentry_gp;
-  if ( ( GPOINTER_TO_INT(g_object_get_data( G_OBJECT(prevs->evbox) , "popup_active" )) == 1 ) &&
-       ( plentry_gp != NULL ) )
+  gboolean upd_pop = FALSE;
+
+  if ( pl_entry != NULL )
   {
     if ( ( prevs->title != NULL ) && ( prevs->filename != NULL ) )
     {
@@ -235,10 +232,9 @@
         if ( ( pl_entry->title != NULL ) &&
              ( strcmp(pl_entry->title,prevs->title) ) )
         {
-          si_ui_statusicon_popup_hide( prevs->evbox );
-          si_ui_statusicon_popup_timer_start( prevs->evbox );
           g_free( prevs->title );
           prevs->title = g_strdup(pl_entry->title);
+          upd_pop = TRUE;
         }
       }
       else
@@ -246,8 +242,7 @@
         g_free(prevs->filename);
         prevs->filename = g_strdup(pl_entry->filename);
         /* if filename changes, reset title as well */
-        if ( prevs->title != NULL )
-          g_free(prevs->title);
+        g_free(prevs->title);
         prevs->title = g_strdup(pl_entry->title);
       }
     }
@@ -261,12 +256,12 @@
       prevs->filename = g_strdup(pl_entry->filename);
     }
   }
-  else if ( ( prevs->title != NULL ) &&
-            ( pl_entry->title != NULL ) &&
-            ( strcmp(pl_entry->title,prevs->title) ) )
+
+  if ( ( upd_pop == TRUE ) &&
+       ( GPOINTER_TO_INT(g_object_get_data( G_OBJECT(prevs->evbox) , "popup_active" )) == 1 ) )
   {
-    g_free(prevs->title);
-    prevs->title = g_strdup(pl_entry->title);
+    si_ui_statusicon_popup_hide( prevs->evbox );
+    si_ui_statusicon_popup_timer_start( prevs->evbox );
   }
 }