2
* arch-tag: Simple program to test bonobo notification from rhythmbox
9
#define RB_IID "OAFIID:GNOME_Rhythmbox"
13
on_bonobo_event (BonoboListener *listener, const char *event_name,
14
const CORBA_any *any, CORBA_Environment *ev,
17
g_print ("event received: %s\n", event_name);
21
on_song_change (BonoboListener *listener, const char *event_name,
22
const CORBA_any *any, CORBA_Environment *ev,
25
GNOME_Rhythmbox_SongInfo *song_info;
27
if (!CORBA_TypeCode_equivalent (any->_type,
28
TC_GNOME_Rhythmbox_SongInfo,
30
g_warning ("Unexpected type\n");
32
song_info = (GNOME_Rhythmbox_SongInfo *)any->_value;
33
if (song_info == NULL) {
34
g_warning ("Unexpected error\n");
36
g_print ("Now Playing:\n");
37
g_print ("Title: %s\n", song_info->title);
38
g_print ("Artist: %s\n", song_info->artist);
39
g_print ("Album: %s\n", song_info->album);
40
g_print ("Bitrate: %u bps\n", song_info->bitrate);
41
g_print ("Length: %u\n", song_info->duration);
45
main (int argc, char *argv [])
49
Bonobo_PropertyBag pb;
54
if (!bonobo_init (&argc, argv))
55
g_error ("Could not initialize Bonobo");
57
CORBA_exception_init (&ev);
58
rb = bonobo_activation_activate_from_id (RB_IID, 0, NULL, &ev);
61
if (rb == CORBA_OBJECT_NIL) {
62
g_warning ("Could not create an instance of Rhythmbox");
63
return bonobo_debug_shutdown ();
65
CORBA_exception_init (&ev);
67
pb = GNOME_Rhythmbox_getPlayerProperties (rb, &ev);
68
if (BONOBO_EX (&ev)) {
69
char *err = bonobo_exception_get_text (&ev);
70
g_warning ("An exception occured '%s'", err);
75
bonobo_event_source_client_add_listener (pb, on_bonobo_event,
76
"Bonobo/Property:change:repeat",
78
bonobo_event_source_client_add_listener (pb, on_bonobo_event,
79
"Bonobo/Property:change:shuffle",
81
bonobo_event_source_client_add_listener (pb, on_bonobo_event,
82
"Bonobo/Property:change:playing",
84
bonobo_event_source_client_add_listener (pb, on_bonobo_event,
85
"Bonobo/Property:change:visibility",
87
bonobo_event_source_client_add_listener (pb, on_bonobo_event,
88
"Bonobo/Property:change:play-order",
90
bonobo_event_source_client_add_listener (pb, on_bonobo_event,
91
"Bonobo/Property:change:volume",
93
bonobo_event_source_client_add_listener (pb, on_song_change,
94
"Bonobo/Property:change:song",
97
if (BONOBO_EX (&ev)) {
98
char *err = bonobo_exception_get_text (&ev);
99
g_warning ("An exception occured '%s'", err);
107
CORBA_exception_free (&ev);
109
bonobo_object_release_unref (rb, NULL);
111
return bonobo_debug_shutdown ();