Beispiel #1
0
static void
handle_player_method_call(GDBusConnection *connection,
			const char *sender,
			const char *object_path,
			const char *interface_name,
			const char *method_name,
			GVariant *parameters,
			GDBusMethodInvocation *invocation,
			XmrMprisPlugin *plugin)

{
	if(g_strcmp0(object_path, MPRIS_OBJECT_NAME) != 0 ||
	    g_strcmp0(interface_name, MPRIS_PLAYER_INTERFACE) != 0)
	{
		g_dbus_method_invocation_return_error(invocation,
						       G_DBUS_ERROR,
						       G_DBUS_ERROR_NOT_SUPPORTED,
						       "Method %s.%s not supported",
						       interface_name,
						       method_name);
		return;
	}

	if (g_strcmp0(method_name, "Next") == 0)
	{
		xmr_window_play_next(plugin->window);
		handle_result(invocation, TRUE, NULL);
	}
	else if (g_strcmp0(method_name, "Pause") == 0)
	{
		xmr_window_pause(plugin->window);
		handle_result(invocation, TRUE, NULL);
	}
	else if (g_strcmp0 (method_name, "Play") == 0)
	{
		xmr_window_play(plugin->window);
		handle_result(invocation, TRUE, NULL);
	}
	else
	{
		g_dbus_method_invocation_return_error(invocation,
					G_DBUS_ERROR,
					G_DBUS_ERROR_NOT_SUPPORTED,
					"Method %s.%s not supported",
					interface_name,
					method_name);
	}
}
Beispiel #2
0
static GdkFilterReturn
filter_mmkeys(GdkXEvent *xevent,
			  GdkEvent *event,
			  gpointer data)
{
	XEvent *xev;
	XKeyEvent *key;
	Display *display;
	XmrWindow *window;
	
	GdkFilterReturn retv = GDK_FILTER_CONTINUE;

	xev = (XEvent *)xevent;

	if (xev->type != KeyPress)
		return GDK_FILTER_CONTINUE;

	key = (XKeyEvent *)xevent;

	window = (XmrWindow *)data;
	display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());

	if (XKeysymToKeycode(display, XF86XK_AudioPlay) == key->keycode ||
		XKeysymToKeycode(display, XF86XK_AudioPause) == key->keycode)
	{
		if (xmr_window_playing(window))
			xmr_window_pause(window);
		else
			xmr_window_play(window);
		retv = GDK_FILTER_REMOVE;
	}
	else if (XKeysymToKeycode (display, XF86XK_AudioStop) == key->keycode)
	{
		xmr_window_pause(window);
		retv = GDK_FILTER_REMOVE;
	}
	else if (XKeysymToKeycode (display, XF86XK_AudioNext) == key->keycode)
	{
		xmr_window_play_next(window);
		retv = GDK_FILTER_REMOVE;
	}
	
	return retv;
}
Beispiel #3
0
static void
on_menu_item_activate(GtkMenuItem *item,
			XmrIndicatorPlugin *plugin)
{
	const gchar *menu = gtk_menu_item_get_label(item);
	
	if(g_strcmp0(menu, GTK_STOCK_QUIT) == 0)
	{
		xmr_window_quit(plugin->window);
	}
	else if(g_strcmp0(menu, GTK_STOCK_MEDIA_PLAY) == 0)
	{
		xmr_window_play(plugin->window);
		gtk_widget_hide(GTK_WIDGET(item));
		gtk_widget_show(plugin->menu_item_pause);
	}
	else if(g_strcmp0(menu, GTK_STOCK_MEDIA_PAUSE) == 0)
	{
		xmr_window_pause(plugin->window);
		gtk_widget_hide(GTK_WIDGET(item));
		gtk_widget_show(plugin->menu_item_play);
	}
	else if(g_strcmp0(menu, GTK_STOCK_MEDIA_NEXT) == 0)
	{
		xmr_window_play_next(plugin->window);
	}
	else if(g_strcmp0(menu, _("Show")) == 0)
	{
		gtk_widget_show(GTK_WIDGET(plugin->window));
        gtk_window_present(GTK_WINDOW(plugin->window));
	}
	else if(g_strcmp0(menu, _("Love")) == 0)
	{
		xmr_window_love(plugin->window);
	}
	else if(g_strcmp0(menu, _("Hate")) == 0)
	{
		xmr_window_hate(plugin->window);
	}
}
Beispiel #4
0
static void
media_player_key_pressed(GDBusProxy *proxy,
			  const gchar *sender,
			  const gchar *signal,
			  GVariant *parameters,
			  XmrMMKeysPlugin *plugin)
{
	gchar *key;
	gchar *application;

	g_variant_get(parameters, "(ss)", &application, &key);

	if (g_strcmp0(application, PACKAGE))
	{
		xmr_debug("got media player key signal for unexpected application '%s'", application);
		return;
	}

	if (g_strcmp0(key, "Play") == 0 ||
		g_strcmp0(key, "Pause") == 0)
	{
		if (xmr_window_playing(plugin->window))
			xmr_window_pause(plugin->window);
		else
			xmr_window_play(plugin->window);
	}
	else if (g_strcmp0(key, "Stop") == 0)
	{
		xmr_window_pause(plugin->window);
	}
	else if (g_strcmp0(key, "Next") == 0)
	{
		xmr_window_play_next(plugin->window);
	}

	g_free(key);
	g_free(application);
}