aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2015-03-06 14:26:38 -0600
committerCharles Kerr <charles.kerr@canonical.com>2015-03-06 14:26:38 -0600
commit31d3dc42ef25b1ba43a50ace638498b60dedf475 (patch)
tree1750dee6f9c1d167418a4ef5cf652b15688349d9 /src/main.c
parentdbdad5a86fd619564857adad66a23414edec2619 (diff)
downloadayatana-indicator-sound-31d3dc42ef25b1ba43a50ace638498b60dedf475.tar.gz
ayatana-indicator-sound-31d3dc42ef25b1ba43a50ace638498b60dedf475.tar.bz2
ayatana-indicator-sound-31d3dc42ef25b1ba43a50ace638498b60dedf475.zip
move from g_bus_own_name_on_connection() to g_bus_own_name() to simplify the code
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/main.c b/src/main.c
index ad8b3d4..4633b4b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,7 +32,7 @@ sigterm_handler (gpointer data)
static void
name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data)
{
- g_debug("Name lost");
+ g_warning("Name lost or unable to acquire bus: %s", name);
g_main_loop_quit((GMainLoop *)user_data);
}
@@ -40,21 +40,11 @@ int
main (int argc, char ** argv) {
GMainLoop * loop = NULL;
IndicatorSoundService* service = NULL;
- GDBusConnection * bus = NULL;
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
- /* Grab DBus */
- GError * error = NULL;
- bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
- if (error != NULL) {
- g_error("Unable to get session bus: %s", error->message);
- g_error_free(error);
- return -1;
- }
-
/* Build Mainloop */
loop = g_main_loop_new(NULL, FALSE);
@@ -63,6 +53,15 @@ main (int argc, char ** argv) {
/* Initialize libnotify */
notify_init ("indicator-sound");
+ g_bus_own_name(G_BUS_TYPE_SESSION,
+ "com.canonical.indicator.sound",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ NULL, /* bus acquired */
+ NULL, /* name acquired */
+ name_lost,
+ loop,
+ NULL);
+
MediaPlayerList * playerlist = NULL;
AccountsServiceUser * accounts = NULL;
@@ -77,20 +76,11 @@ main (int argc, char ** argv) {
service = indicator_sound_service_new (playerlist, volume, accounts);
- g_bus_own_name_on_connection(bus,
- "com.canonical.indicator.sound",
- G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL, /* acquired */
- name_lost,
- loop,
- NULL);
-
g_main_loop_run(loop);
g_clear_object(&playerlist);
g_clear_object(&accounts);
g_clear_object(&service);
- g_clear_object(&bus);
return 0;
}