#ifdef HAVE_CONFIG_H # include "config.h" #endif #include #include "eggtrayicon.h" #include #include #include #include "tooltips.h" extern GeneralPlugin docklet_plugin; extern EggTrayIcon *docklet; static GtkTooltips *docklet_tooltips; static gboolean docklet_tooltips_cb (gpointer data) { static gchar *last_title = NULL; gint pos; gchar *title, *noutf8_title; if (docklet == NULL) return FALSE; if (last_title == NULL) last_title = g_utf8_normalize (g_strdup (""), -1, G_NORMALIZE_DEFAULT); pos = xmms_remote_get_playlist_pos (docklet_plugin.xmms_session); noutf8_title = xmms_remote_get_playlist_title (docklet_plugin.xmms_session, pos); if (noutf8_title == NULL) return TRUE; title = g_utf8_normalize (noutf8_title, -1, G_NORMALIZE_DEFAULT); g_free (noutf8_title); /* change tooltip only if title really changed */ if (g_utf8_collate (last_title, title) != 0) { gtk_tooltips_set_tip (GTK_TOOLTIPS (docklet_tooltips), GTK_WIDGET (docklet), title, NULL); g_free (last_title); last_title = title; } else g_free (title); return TRUE; } void docklet_tooltips_init (void) { docklet_tooltips = gtk_tooltips_new (); g_timeout_add (1000, docklet_tooltips_cb, NULL); } void docklet_tooltips_cleanup (void) { if (docklet_tooltips != NULL) { gtk_object_destroy (GTK_OBJECT (docklet_tooltips)); docklet_tooltips = NULL; } }