[Pkg-wmaker-commits] [wmauda] 09/17: Import Upstream version 0.7

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Jul 7 01:08:49 UTC 2017


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmauda.

commit 9c1cb1e8a03f26f6e7a03ca222f99c4cbce43616
Author: Doug Torrance <dtorrance at piedmont.edu>
Date:   Thu Jul 6 21:06:47 2017 -0400

    Import Upstream version 0.7
---
 Makefile |   4 +-
 README   |   3 ++
 config.h |   2 +-
 wmauda.c | 135 +++++++++++++++++++++++++++++++++++++--------------------------
 4 files changed, 85 insertions(+), 59 deletions(-)

diff --git a/Makefile b/Makefile
index 69c4fc1..840ad7c 100644
--- a/Makefile
+++ b/Makefile
@@ -7,8 +7,8 @@ INSTALL_DIR	:= $(PREFIX)/bin
 PIXMAP_DIR	:= $(PREFIX)/share/pixmaps
 MANPAGE_DIR	:= $(PREFIX)/share/man/man1
 
-CFLAGS 	+= $(shell pkg-config audacious --cflags)
-LIBS 	:= $(shell pkg-config audacious --libs)
+CFLAGS 	+= $(shell pkg-config audacious --cflags) $(shell pkg-config dbus-1 --cflags)
+LIBS 	:= $(shell pkg-config audacious --libs)   $(shell pkg-config dbus-1 --libs)
 
 OBJS 	= wmauda.o
 HEADERS = config.h dock-master.xpm
diff --git a/README b/README
index 3ff3094..b2e6a09 100644
--- a/README
+++ b/README
@@ -4,3 +4,6 @@ Just type 'make' to compile and 'make install' to install to /usr/local
 
 Michael Stewart <vericgar at gracefulsymmetry.com>
 Christian Birchinger <joker at netswarm.net>
+
+
+WARNING: wmauda 0.5 or later require the new dbus interface of Audacious
diff --git a/config.h b/config.h
index 1b83377..22ea9ba 100644
--- a/config.h
+++ b/config.h
@@ -1,2 +1,2 @@
 #define DATA_DIR "/usr/share/pixmaps"
-#define VERSION "0.3"
+#define VERSION "0.6"
diff --git a/wmauda.c b/wmauda.c
index e4e37a4..07dc4a8 100644
--- a/wmauda.c
+++ b/wmauda.c
@@ -26,9 +26,11 @@
 #include <string.h>
 #include <ctype.h>
 
+#include <audacious/dbus.h>
+#include <audacious/audctrl.h>
+
 #include "config.h"
 
-#include "audacious/beepctrl.h"
 #include "dock-master.xpm"
 
 #include <getopt.h>
@@ -126,7 +128,6 @@ GdkBitmap *mask, *launch_mask;
 GdkGC *dock_gc;
 GtkTooltips *tooltips = NULL;
 
-int xmms_session = 0;
 char *xmms_cmd = "audacious";
 gboolean xmms_running = FALSE;
 
@@ -134,6 +135,9 @@ gboolean has_geometry = FALSE, single_click = FALSE, song_title = FALSE;
 char *icon_name = NULL;
 int win_x, win_y;
 
+DBusGProxy *dbus_proxy = NULL;   
+static DBusGConnection *connection = NULL;
+
 GtkTargetEntry drop_types[] =
 {
 	{"text/plain", 0, 1}
@@ -141,32 +145,33 @@ GtkTargetEntry drop_types[] =
 
 void action_play(void)
 {
-	xmms_remote_play(xmms_session);
+	audacious_remote_play(dbus_proxy);
 }
 
 void action_pause(void)
 {
-	xmms_remote_pause(xmms_session);
+	audacious_remote_pause(dbus_proxy);
 }
 
 void action_eject(void)
 {
-	xmms_remote_eject(xmms_session);
+	audacious_remote_playlist_clear(dbus_proxy);
+	audacious_remote_stop(dbus_proxy);
 }
 
 void action_prev(void)
 {
-	xmms_remote_playlist_prev(xmms_session);
+	audacious_remote_playlist_prev(dbus_proxy);
 }
 
 void action_next(void)
 {
-	xmms_remote_playlist_next(xmms_session);
+	audacious_remote_playlist_next(dbus_proxy);
 }
 
 void action_stop(void)
 {
-	xmms_remote_stop(xmms_session);
+	audacious_remote_stop(dbus_proxy);
 }
 
 gboolean inside_region(int mx, int my, int x, int y, int w, int h)
@@ -249,11 +254,11 @@ void draw_seekslider(void)
 void real_draw_scrolltext(GdkWindow * w)
 {
         /* get titlestring */
-	gint pl_pos = xmms_remote_get_playlist_pos(xmms_session);
+	gint pl_pos = audacious_remote_get_playlist_pos(dbus_proxy);
 
 	if (pl_pos != -1)
 	{
-	        char *title = xmms_remote_get_playlist_title(xmms_session, pl_pos);
+	        char *title = audacious_remote_get_playlist_title(dbus_proxy, pl_pos);
 		if (title)
 		{
 		        /* render text */	
@@ -327,6 +332,25 @@ void expose_cb(GtkWidget *w, GdkEventExpose *event, gpointer data)
 	redraw_window();
 }
 
+void wheel_scroll_cb(GtkWidget *w, GdkEventScroll *event)
+{
+	if (xmms_running)
+	{
+		if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_DOWN)
+		{
+			if (event->direction == GDK_SCROLL_UP)
+				volslider_pos += 3;
+			else
+				volslider_pos -= 3;
+			if (volslider_pos < 0)
+				volslider_pos = 0;
+			if (volslider_pos > VOLSLIDER_HEIGHT)
+				volslider_pos = VOLSLIDER_HEIGHT;
+			audacious_remote_set_main_volume(dbus_proxy, (volslider_pos * 100) / VOLSLIDER_HEIGHT);
+			draw_volslider();
+		}
+	}
+}
 void button_press_cb(GtkWidget *w, GdkEventButton *event, gpointer data)
 {
 	GList *node;
@@ -338,30 +362,17 @@ void button_press_cb(GtkWidget *w, GdkEventButton *event, gpointer data)
 	{
 		if (event->button == 2)
 		{
-			if(xmms_remote_is_pl_win(xmms_session))
-				xmms_remote_pl_win_toggle(xmms_session, 0);
+			if(audacious_remote_is_pl_win(dbus_proxy))
+				audacious_remote_pl_win_toggle(dbus_proxy, FALSE);
 			else
-				xmms_remote_pl_win_toggle(xmms_session, 1);
+				audacious_remote_pl_win_toggle(dbus_proxy, TRUE);
 		}
 		else if (event->button == 3)
 		{
-			if(xmms_remote_is_main_win(xmms_session))
-				xmms_remote_main_win_toggle(xmms_session, 0);
+			if(audacious_remote_is_main_win(dbus_proxy))
+				audacious_remote_main_win_toggle(dbus_proxy, FALSE);
 			else
-				xmms_remote_main_win_toggle(xmms_session, 1);
-		}
-		else if (event->button == 4 || event->button == 5)
-		{
-			if (event->button == 4)
-				volslider_pos += 3;
-			else
-				volslider_pos -= 3;
-			if (volslider_pos < 0)
-				volslider_pos = 0;
-			if (volslider_pos > VOLSLIDER_HEIGHT)
-				volslider_pos = VOLSLIDER_HEIGHT;
-			xmms_remote_set_main_volume(xmms_session, (volslider_pos * 100) / VOLSLIDER_HEIGHT);
-			draw_volslider();
+				audacious_remote_main_win_toggle(dbus_proxy, TRUE);
 		}
 	}
 
@@ -382,7 +393,7 @@ void button_press_cb(GtkWidget *w, GdkEventButton *event, gpointer data)
 		if (inside_region(event->x, event->y, VOLSLIDER_X, VOLSLIDER_Y, VOLSLIDER_WIDTH, VOLSLIDER_HEIGHT))
 		{
 			volslider_pos = VOLSLIDER_HEIGHT - (event->y - VOLSLIDER_Y);
-			xmms_remote_set_main_volume(xmms_session, (volslider_pos * 100) / VOLSLIDER_HEIGHT);
+			audacious_remote_set_main_volume(dbus_proxy, (volslider_pos * 100) / VOLSLIDER_HEIGHT);
 			draw_volslider();
 			volslider_dragging = TRUE;
 		}
@@ -439,8 +450,8 @@ void button_release_cb(GtkWidget *w, GdkEventButton *event, gpointer data)
 	volslider_dragging = FALSE;
 	if (seekslider_dragging)
 	{
-		len = xmms_remote_get_playlist_time(xmms_session, xmms_remote_get_playlist_pos(xmms_session));
-		xmms_remote_jump_to_time(xmms_session, (seekslider_pos * len) / SEEKSLIDER_MAX);
+		len = audacious_remote_get_playlist_time(dbus_proxy, audacious_remote_get_playlist_pos(dbus_proxy));
+		audacious_remote_jump_to_time(dbus_proxy, (seekslider_pos * len) / SEEKSLIDER_MAX);
 		seekslider_dragging = FALSE;
 	}
 
@@ -475,7 +486,7 @@ void motion_notify_cb(GtkWidget *w, GdkEventMotion *event, gpointer data)
 			volslider_pos = 0;
 		if (volslider_pos > VOLSLIDER_HEIGHT)
 			volslider_pos = VOLSLIDER_HEIGHT;
-		xmms_remote_set_main_volume(xmms_session, (volslider_pos * 100) / VOLSLIDER_HEIGHT);
+		audacious_remote_set_main_volume(dbus_proxy, (volslider_pos * 100) / VOLSLIDER_HEIGHT);
 		draw_volslider();
 	}
 	if (seekslider_dragging)
@@ -505,7 +516,7 @@ static void update_tooltip(void)
 	if (!tooltips)
 		return;
 	
-	new_pos = xmms_remote_get_playlist_pos(xmms_session);
+	new_pos = audacious_remote_get_playlist_pos(dbus_proxy);
 
 	if (new_pos == 0)
 	{
@@ -513,7 +524,7 @@ static void update_tooltip(void)
 		 * Need to do some extra checking, as we get 0 also on
 		 * a empty playlist
 		 */
-		char *current = xmms_remote_get_playlist_file(xmms_session, 0);
+		char *current = audacious_remote_get_playlist_file(dbus_proxy, 0);
 		if (!filename && current)
 		{
 			filename = current;
@@ -537,7 +548,7 @@ static void update_tooltip(void)
 	{
 		char *tip = NULL;
 		char *title =
-			xmms_remote_get_playlist_title(xmms_session, new_pos);
+			audacious_remote_get_playlist_title(dbus_proxy, new_pos);
 		if (title)
 		{
 			tip = g_strdup_printf("%d. %s", new_pos+1, title);
@@ -554,7 +565,7 @@ int timeout_func(gpointer data)
 	int new_pos, pos;
 	gboolean playing, running;
 
-	running = xmms_remote_is_running(xmms_session);
+	running = audacious_remote_is_running(dbus_proxy);
 
 	if (running)
 	{
@@ -566,10 +577,7 @@ int timeout_func(gpointer data)
 		}
 		if (!volslider_dragging)
 		{
-			int vl, vr;
-			xmms_remote_get_volume(xmms_session, &vl, &vr);
-
-			new_pos = ((vl > vr ? vl : vr) * 40) / 100;
+			new_pos = (audacious_remote_get_main_volume(dbus_proxy) * 40) / 100;
 
 			if (new_pos < 0)
 				new_pos = 0;
@@ -586,7 +594,7 @@ int timeout_func(gpointer data)
 		update_tooltip();
 		draw_scrolltext();
 
-		playing = xmms_remote_is_playing(xmms_session);
+		playing = audacious_remote_is_playing(dbus_proxy);
 		if (!playing && seekslider_visible)
 		{
 			seekslider_visible = FALSE;
@@ -596,8 +604,8 @@ int timeout_func(gpointer data)
 		}
 		else if (playing)
 		{
-			int len, p = xmms_remote_get_playlist_pos(xmms_session);
-			len = xmms_remote_get_playlist_time(xmms_session, p);
+			int len, p = audacious_remote_get_playlist_pos(dbus_proxy);
+			len = audacious_remote_get_playlist_time(dbus_proxy, p);
 			if (len == -1)
 			{
 				seekslider_visible = FALSE;
@@ -608,7 +616,7 @@ int timeout_func(gpointer data)
 			else if (!seekslider_dragging)
 			{
 				seekslider_visible = TRUE;
-				pos = xmms_remote_get_output_time(xmms_session);
+				pos = audacious_remote_get_output_time(dbus_proxy);
 				if (len != 0)
 					new_pos = (pos * SEEKSLIDER_MAX) / len;
 				else
@@ -647,15 +655,31 @@ void drag_data_received(GtkWidget *widget, GdkDragContext *context,
 	if (selection_data->data)
 	{
 		char *url = selection_data->data;
-		xmms_remote_playlist_clear(xmms_session);
-		xmms_remote_playlist_add_url_string(xmms_session, url);
-		xmms_remote_play(xmms_session);
+		audacious_remote_playlist_clear(dbus_proxy);
+		audacious_remote_playlist_add_url_string(dbus_proxy, url);
+		audacious_remote_play(dbus_proxy);
 	}
 }
 
-void init(void)
+static gboolean dbus_init(void)
 {
+	GError *error = NULL;
 	
+	connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+	if (connection == NULL)
+		return FALSE;
+		
+	dbus_proxy = dbus_g_proxy_new_for_name(connection, AUDACIOUS_DBUS_SERVICE,
+                                                           AUDACIOUS_DBUS_PATH,
+                                                           AUDACIOUS_DBUS_INTERFACE);
+	if (dbus_proxy == NULL)
+		return FALSE;
+		
+	return TRUE;
+}
+
+void init(void)
+{
 	GdkWindowAttr attr;
 	GdkColor bg_color;
 	GdkWindow *leader;
@@ -683,6 +707,8 @@ void init(void)
 			   GTK_SIGNAL_FUNC(expose_cb), NULL);
 	gtk_signal_connect(GTK_OBJECT(icon_win), "button_press_event",
 			   GTK_SIGNAL_FUNC(button_press_cb), NULL);
+	gtk_signal_connect(GTK_OBJECT(icon_win), "scroll_event",
+			   GTK_SIGNAL_FUNC(wheel_scroll_cb), NULL);
 	gtk_signal_connect(GTK_OBJECT(icon_win), "button_release_event",
 			   GTK_SIGNAL_FUNC(button_release_cb), NULL);
 	gtk_signal_connect(GTK_OBJECT(icon_win), "motion_notify_event",
@@ -703,8 +729,7 @@ void init(void)
 	gdk_window_clear(icon_win->window);
 	dock_gc = gdk_gc_new(icon_win->window);
 
-	launch_pixmap = gdk_pixmap_new(icon_win->window, 64, 64,
-				       gdk_visual_get_best_depth());
+	launch_pixmap = gdk_pixmap_new(icon_win->window, 64, 64, -1);
 
 	launch_mask = gdk_pixmap_new(icon_win->window, 64, 64, 1);
 	mask_gc = gdk_gc_new(launch_mask);
@@ -779,7 +804,6 @@ void display_usage(char *cmd)
 		"--------\n\n"
 		"-h, --help		Display this text and exit.\n"
 		"-g, --geometry		Set the geometry (for example +20+20)\n"
-		"-s, --session		Set the Audacious session to use (Default: 0)\n"
 		"-c, --command		Command to launch Audacious (Default: audacious)\n"
 		"-i, --icon		Set the icon to use when Audacious is not running\n"
 		"-n, --single		Only a single click is needed to start Audacious\n"
@@ -822,9 +846,6 @@ int main(int argc, char **argv)
 					       &dummy, &dummy);
 				has_geometry = TRUE;
 				break;
-			case 's':
-				xmms_session = atoi(optarg);
-				break;
 			case 'c':
 				xmms_cmd = g_strdup(optarg);
 				break;
@@ -843,7 +864,9 @@ int main(int argc, char **argv)
 				break;
 		}
 	}
-
+	if (!dbus_init())
+		return 1;
+	
 	init();
 	gtk_main();
 	return 0;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmauda.git



More information about the Pkg-wmaker-commits mailing list