Skip to content

Commit

Permalink
Add startup notification support.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlindgren90 committed Apr 2, 2016
1 parent 6ed0f32 commit a32cca0
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 12 deletions.
1 change: 1 addition & 0 deletions audacious.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Icon=audacious
Categories=AudioVideo;Audio;Player;GTK;
Exec=audacious %U
TryExec=audacious
StartupNotify=true
Terminal=false
MimeType=application/ogg;application/x-cue;application/x-ogg;application/xspf+xml;audio/midi;audio/mp3;audio/mp4;audio/mpeg;audio/mpegurl;audio/ogg;audio/prs.sid;audio/x-flac;audio/x-it;audio/x-mod;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-asx;audio/x-ms-wma;audio/x-musepack;audio/x-s3m;audio/x-scpls;audio/x-stm;audio/x-vorbis+ogg;audio/x-wav;audio/x-xm;inode/directory;x-content/audio-cdda;

Expand Down
8 changes: 8 additions & 0 deletions src/audacious/dbus-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,13 @@ static gboolean do_song_tuple (Obj * obj, Invoc * invoc, unsigned pos, const cha
return true;
}

static gboolean do_startup_notify (Obj * obj, Invoc * invoc, const char * id)
{
aud_ui_startup_notify (id);
FINISH (startup_notify);
return true;
}

static gboolean do_status (Obj * obj, Invoc * invoc)
{
const char * status = "stopped";
Expand Down Expand Up @@ -745,6 +752,7 @@ handlers[] =
{"handle-song-length", (GCallback) do_song_length},
{"handle-song-title", (GCallback) do_song_title},
{"handle-song-tuple", (GCallback) do_song_tuple},
{"handle-startup-notify", (GCallback) do_startup_notify},
{"handle-status", (GCallback) do_status},
{"handle-stop", (GCallback) do_stop},
{"handle-stop-after", (GCallback) do_stop_after},
Expand Down
23 changes: 11 additions & 12 deletions src/audacious/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,14 @@ static void do_remote ()
if (dbus_server_init () != StartupType::Client)
return;

if (! (bus = g_bus_get_sync (G_BUS_TYPE_SESSION, nullptr, & error)))
goto ERR;

if (! (obj = obj_audacious_proxy_new_sync (bus, (GDBusProxyFlags) 0,
if (! (bus = g_bus_get_sync (G_BUS_TYPE_SESSION, nullptr, & error)) ||
! (obj = obj_audacious_proxy_new_sync (bus, (GDBusProxyFlags) 0,
"org.atheme.audacious", "/org/atheme/audacious", nullptr, & error)))
goto ERR;
{
AUDERR ("D-Bus error: %s\n", error->message);
g_error_free (error);
return;
}

AUDINFO ("Connected to remote session.\n");

Expand Down Expand Up @@ -253,16 +255,13 @@ static void do_remote ()
if (options.mainwin)
obj_audacious_call_show_main_win_sync (obj, true, nullptr, nullptr);

const char * startup_id = getenv ("DESKTOP_STARTUP_ID");
if (startup_id)
obj_audacious_call_startup_notify_sync (obj, startup_id, nullptr, nullptr);

g_object_unref (obj);

exit (EXIT_SUCCESS);

ERR:
if (error)
{
AUDERR ("D-Bus error: %s\n", error->message);
g_error_free (error);
}
}
#endif

Expand Down
5 changes: 5 additions & 0 deletions src/dbus/aud-dbus.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
<arg type="b" direction="in" name="show"/>
</method>

<!-- Send startup notification -->
<method name="StartupNotify">
<arg type="s" direction="in" name="id"/>
</method>

<!-- Get names of available 'standard' tuple fields -->
<method name="GetTupleFields">
<!-- Return array of tuple field names -->
Expand Down
7 changes: 7 additions & 0 deletions src/libaudcore/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ EXPORT bool aud_ui_is_shown ()
return aud_get_bool (0, "show_interface");
}

EXPORT void aud_ui_startup_notify (const char * id)
{
/* startup_notify was added in Audacious 3.8 */
if (current_interface && (current_interface->version & 0xffff) >= 48)
current_interface->startup_notify (id);
}

EXPORT void aud_ui_show_error (const char * message)
{
if (aud_get_headless_mode ())
Expand Down
1 change: 1 addition & 0 deletions src/libaudcore/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum class AudMenuID {
void aud_ui_show (bool show);
bool aud_ui_is_shown ();

void aud_ui_startup_notify (const char * id);
void aud_ui_show_error (const char * message); /* thread-safe */

void aud_ui_show_about_window ();
Expand Down
2 changes: 2 additions & 0 deletions src/libaudcore/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ class IfacePlugin : public Plugin
virtual void hide_prefs_window () = 0;
virtual void plugin_menu_add (AudMenuID id, void func (), const char * name, const char * icon) = 0;
virtual void plugin_menu_remove (AudMenuID id, void func ()) = 0;

virtual void startup_notify (const char * id) {}
};

#endif

0 comments on commit a32cca0

Please sign in to comment.