| 31 |
31 |
#include "event.h"
|
| 32 |
32 |
#include "osd.h"
|
| 33 |
33 |
|
| 34 |
|
static gchar * last_title = NULL, * last_message = NULL;
|
| 35 |
|
|
| 36 |
|
static void clear (void)
|
| 37 |
|
{
|
| 38 |
|
g_free (last_title);
|
| 39 |
|
last_title = NULL;
|
| 40 |
|
g_free (last_message);
|
| 41 |
|
last_message = NULL;
|
| 42 |
|
}
|
| 43 |
|
|
| 44 |
|
static void update (void * unused, void * explicit)
|
|
34 |
static void update (void * unused, void * notif)
|
| 45 |
35 |
{
|
| 46 |
36 |
if (! aud_drct_get_playing () || ! aud_drct_get_ready ())
|
| 47 |
37 |
{
|
| 48 |
|
if (GPOINTER_TO_INT (explicit))
|
|
38 |
if (aud_get_bool ("notify", "actions"))
|
| 49 |
39 |
osd_show (_("Stopped"), _("Audacious is not playing."), NULL, NULL);
|
| 50 |
40 |
|
| 51 |
41 |
return;
|
| ... | ... | |
| 70 |
60 |
else
|
| 71 |
61 |
message = g_strdup ("");
|
| 72 |
62 |
|
| 73 |
|
if (! GPOINTER_TO_INT (explicit) && last_title && last_message && ! strcmp
|
| 74 |
|
(title, last_title) && ! strcmp (message, last_message))
|
| 75 |
|
{
|
| 76 |
|
g_free (message);
|
| 77 |
|
goto FREE;
|
| 78 |
|
}
|
| 79 |
|
|
| 80 |
63 |
GdkPixbuf * pb = audgui_pixbuf_for_current ();
|
| 81 |
64 |
if (pb)
|
| 82 |
65 |
audgui_pixbuf_scale_within (& pb, 96);
|
| 83 |
66 |
|
| 84 |
|
osd_show (title, message, "audio-x-generic", pb);
|
|
67 |
osd_show (title, message, "audio-x-generic", pb, notif);
|
| 85 |
68 |
|
| 86 |
69 |
if (pb)
|
| 87 |
70 |
g_object_unref (pb);
|
| 88 |
71 |
|
| 89 |
|
clear ();
|
| 90 |
|
last_title = g_strdup (title);
|
| 91 |
|
last_message = message;
|
| 92 |
|
|
| 93 |
|
FREE:
|
|
72 |
if(message)
|
|
73 |
g_free(message);
|
| 94 |
74 |
str_unref (title);
|
| 95 |
75 |
str_unref (artist);
|
| 96 |
76 |
str_unref (album);
|
| 97 |
77 |
}
|
| 98 |
78 |
|
| 99 |
|
void event_init (void)
|
|
79 |
static void update_explicit (void * unused, void * notif)
|
|
80 |
{
|
|
81 |
if (! aud_drct_get_playing () || ! aud_drct_get_ready ())
|
|
82 |
osd_show (_("Stopped"), _("Audacious is not playing."), "audio-x-generic", NULL, notif);
|
|
83 |
else
|
|
84 |
update(unused, notif);
|
|
85 |
return;
|
|
86 |
}
|
|
87 |
|
|
88 |
void event_init (void* notif)
|
| 100 |
89 |
{
|
| 101 |
|
update (NULL, GINT_TO_POINTER (FALSE));
|
| 102 |
|
hook_associate ("aosd toggle", (HookFunction) update, GINT_TO_POINTER (TRUE));
|
| 103 |
|
hook_associate ("playback ready", (HookFunction) update, GINT_TO_POINTER (FALSE));
|
| 104 |
|
hook_associate ("playlist update", (HookFunction) update, GINT_TO_POINTER (FALSE));
|
| 105 |
|
hook_associate ("playback stop", (HookFunction) clear, NULL);
|
|
90 |
hook_associate ("aosd toggle", (HookFunction) update_explicit, notif);
|
|
91 |
hook_associate ("playback ready", (HookFunction) update, notif);
|
|
92 |
hook_associate ("playlist update", (HookFunction) update, notif);
|
|
93 |
hook_associate ("playback pause", (HookFunction) update, notif);
|
|
94 |
hook_associate ("playback unpause", (HookFunction) update, notif);
|
| 106 |
95 |
}
|
| 107 |
96 |
|
| 108 |
97 |
void event_uninit (void)
|
| 109 |
98 |
{
|
| 110 |
|
hook_dissociate ("aosd toggle", (HookFunction) update);
|
|
99 |
hook_dissociate ("aosd toggle", (HookFunction) update_explicit);
|
| 111 |
100 |
hook_dissociate ("playback ready", (HookFunction) update);
|
| 112 |
101 |
hook_dissociate ("playlist update", (HookFunction) update);
|
| 113 |
|
hook_dissociate ("playback stop", (HookFunction) clear);
|
| 114 |
|
clear ();
|
|
102 |
hook_dissociate ("playback pause", (HookFunction) update);
|
|
103 |
hook_dissociate ("playback unpause", (HookFunction) update);
|
| 115 |
104 |
}
|