Exemple #1
0
int main(int argc, char **argv)
{
	XmrApp *app;
	GOptionContext *context;
	GError *error = NULL;
	PlayerAction player_action = ActionNone;
	gchar *tmp_dir = NULL;

#if !GLIB_CHECK_VERSION(2, 32, 0)
	g_thread_init(NULL);
#endif

	// !!! glib manual says since version 2.36
	// but ubuntu 13.04 !!!
#if !GLIB_CHECK_VERSION(2, 35, 7)
	g_type_init();
#endif

	setlocale(LC_ALL, NULL);

#ifdef ENABLE_NLS
	/* initialize i18n */
	bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");

	textdomain(GETTEXT_PACKAGE);
#endif
	
	context = g_option_context_new(NULL);

	g_option_context_add_main_entries(context, options, GETTEXT_PACKAGE);

	g_option_context_add_group(context, gtk_get_option_group(TRUE));
	g_option_context_add_group(context, gst_init_get_option_group());

	if (g_option_context_parse(context, &argc, &argv, &error) == FALSE)
	{
		g_print(_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
			 error->message, argv[0]);
		g_error_free(error);
		g_option_context_free(context);
		exit(1);
	}

	g_option_context_free(context);

	if (action_play){
		player_action = ActionPlay;
	}else if (action_pause){
		player_action = ActionPause;
	}else if(action_next){
		player_action = ActionNext;
	}else if(action_love){
		player_action = ActionLove;
	}else if(action_hate){
		player_action = ActionHate;
	}

	if (player_action != ActionNone)
	{
		DBusConnection *bus;
		DBusError dbus_error;
		dbus_error_init(&dbus_error);
		bus = dbus_bus_get(DBUS_BUS_SESSION, &dbus_error);
		if (!bus)
		{
			g_warning ("Failed to connect to the D-BUS daemon: %s", dbus_error.message);
			dbus_error_free(&dbus_error);
			exit(1);
		}
		
		dbus_connection_setup_with_g_main(bus, NULL);

		send_action(bus, player_action);

		// exit directly
		return 0;
	}

	xmr_debug_enable(debug);

	gst_init(&argc, &argv);

	curl_global_init(CURL_GLOBAL_ALL);

	// this make our XmrRadio always works
	g_object_set(gtk_settings_get_default(),
				"gtk-button-images", TRUE,
				NULL);

	// ensure folder exists
	tmp_dir = g_strdup_printf("%s/%s", g_get_tmp_dir(), PACKAGE);
	g_mkdir_with_parents(tmp_dir, 0755);

	app = xmr_app_instance();

	g_application_run(G_APPLICATION(app), argc, argv);

	// remove ...
	list_file(tmp_dir, FALSE, remove_file, NULL);

	g_free(tmp_dir);
	g_object_unref(app);

	curl_global_cleanup();

	return 0;
}
Exemple #2
0
int main(int argc, char **argv)
{
	XmrSkin *skin;
	SkinInfo *info;
	GdkPixbuf *pixbuf;
	gint x, y;

	g_type_init();
	xmr_debug_enable(TRUE);

	skin = xmr_skin_new();

	if (!xmr_skin_load(skin, "../data/skin/pure.skn"))
	{
		g_print("xmr_skin_load failed\n");
		g_object_unref(skin);
		return 1;
	}

	info = xmr_skin_info_new();

	xmr_skin_get_info(skin, info);
	print_skin_info(info);
	xmr_skin_info_free(info);

	if (!xmr_skin_get_position(skin, UI_MAIN, "next", &x, &y))
		g_print("get next position failed\n");
	else
		g_print("next (%d, %d)\n", x, y);

	pixbuf = xmr_skin_get_image(skin, UI_MAIN, NULL);
	if (pixbuf == NULL)
	{
		g_print("xmr_skin_get_image failed\n");
	}
	else
	{
		gint w, h;
		w = gdk_pixbuf_get_width(pixbuf);
		h = gdk_pixbuf_get_height(pixbuf);

		g_print("image size(%d, %d)\n", w, h);

		g_object_unref(pixbuf);
	}

	pixbuf = xmr_skin_get_image(skin, UI_MAIN, "play");
	if (pixbuf == NULL)
	{
		g_print("xmr_skin_get_image failed\n");
	}
	else
	{
		gint w, h;
		w = gdk_pixbuf_get_width(pixbuf);
		h = gdk_pixbuf_get_height(pixbuf);

		g_print("image size(%d, %d)\n", w, h);

		g_object_unref(pixbuf);
	}

	g_object_unref(skin);

	return 0;
}