aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
blob: 01bc95100ee56521513ee894551938defeb192ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* main.c generated by valac 0.22.1, the Vala compiler
 * generated from main.vala, do not modify */


#include <glib.h>
#include <locale.h>
#include <libnotify/notify.h>

#include "indicator-sound-service.h"
#include "config.h"

gboolean
sigterm_handler (gpointer data)
{
	g_debug("Got SIGTERM");
	g_main_loop_quit((GMainLoop *)data);
	return G_SOURCE_REMOVE;
}

int
main (int argc, char ** argv) {
	GMainLoop * loop = NULL;
	IndicatorSoundService* service = NULL;

	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);

	/* Build Mainloop */
	loop = g_main_loop_new(NULL, FALSE);

	g_unix_signal_add(SIGTERM, sigterm_handler, loop); 

	/* Initialize libnotify */
	notify_init ("indicator-sound");

	MediaPlayerList * playerlist = NULL;
	AccountsServiceUser * accounts = NULL;

	if (g_strcmp0("lightdm", g_get_user_name()) == 0) {
		playerlist = MEDIA_PLAYER_LIST(media_player_list_greeter_new());
	} else {
		playerlist = MEDIA_PLAYER_LIST(media_player_list_mpris_new());
		accounts = accounts_service_user_new();
	}

	VolumeControlPulse * volume = volume_control_pulse_new();

	service = indicator_sound_service_new (loop, playerlist, volume, accounts);

	g_main_loop_run(loop);

	g_object_unref(playerlist);
	g_clear_object(&accounts);
	g_object_unref(service);

	return 0;
}