[Goodies-commits] r1997 - in xfce4-mpc-plugin/branches/xfce4-mpd-playlist-plugin: . panel-plugin
Mike Massonnet
mmassonnet at xfce.org
Sun Sep 10 03:39:28 CEST 2006
Author: mmassonnet
Date: 2006-09-10 01:39:16 +0000 (Sun, 10 Sep 2006)
New Revision: 1997
Modified:
xfce4-mpc-plugin/branches/xfce4-mpd-playlist-plugin/ChangeLog
xfce4-mpc-plugin/branches/xfce4-mpd-playlist-plugin/panel-plugin/mpd-playlist.c
xfce4-mpc-plugin/branches/xfce4-mpd-playlist-plugin/panel-plugin/mpd-playlist.h
Log:
* panel-plugin/mpd-playlist.{c,h}: Add a volume slider.
Modified: xfce4-mpc-plugin/branches/xfce4-mpd-playlist-plugin/ChangeLog
===================================================================
--- xfce4-mpc-plugin/branches/xfce4-mpd-playlist-plugin/ChangeLog 2006-09-08 20:57:28 UTC (rev 1996)
+++ xfce4-mpc-plugin/branches/xfce4-mpd-playlist-plugin/ChangeLog 2006-09-10 01:39:16 UTC (rev 1997)
@@ -1,8 +1,6 @@
-2006-09-05 Mike Massonnet <mmassonnet at gmail.com>
+2006-09-10 Mike Massonnet <mmassonnet at gmail.com>
- * panel-plugin/*.{c,h}: Some fixes with automatic hidden panel, the
- GtkMenu leak, and the "pressed button" state when no server is available
- or the playlist is empty.
+ * panel-plugin/mpd-playlist.{c,h}: Add a volume slider.
2006-09-03 Mike Massonnet <mmassonnet at gmail.com>
Modified: xfce4-mpc-plugin/branches/xfce4-mpd-playlist-plugin/panel-plugin/mpd-playlist.c
===================================================================
--- xfce4-mpc-plugin/branches/xfce4-mpd-playlist-plugin/panel-plugin/mpd-playlist.c 2006-09-08 20:57:28 UTC (rev 1996)
+++ xfce4-mpc-plugin/branches/xfce4-mpd-playlist-plugin/panel-plugin/mpd-playlist.c 2006-09-10 01:39:16 UTC (rev 1997)
@@ -33,6 +33,7 @@
#include "mpd-playlist.h"
#define PLUGIN_NAME "MPD Playlist plugin"
+#define BORDER 8
@@ -55,8 +56,11 @@
static void mpd_playlist_change_track (gpointer data);
+static void mpd_playlist_change_volume (gpointer data,
+ GdkEventScroll *);
+
static gchar *mpd_host;
static gint mpd_port;
static gchar *mpd_passwd;
@@ -92,6 +96,7 @@
mpd_pl = data;
gtk_widget_set_size_request (mpd_pl->button, size, size);
+ gtk_widget_set_size_request (mpd_pl->volume, BORDER, size - BORDER);
size = size - 2 - (2 * MAX (mpd_pl->button->style->xthickness,
mpd_pl->button->style->ythickness));
@@ -121,7 +126,7 @@
xfce_panel_plugin_get_screen_position (plugin));
mpd_pl = mpd_playlist_new (plugin);
- gtk_container_add (GTK_CONTAINER (plugin), mpd_pl->button);
+ gtk_container_add (GTK_CONTAINER (plugin), mpd_pl->box);
xfce_panel_plugin_add_action_widget (plugin, mpd_pl->button);
@@ -167,11 +172,15 @@
mpd_playlist_new (XfcePanelPlugin *plugin)
{
MpdPlaylistPlugin *mpd_pl;
+ static GtkWidget *ebox;
mpd_pl = g_new0 (MpdPlaylistPlugin, 1);
mpd_pl->panel_plugin = plugin;
+ mpd_pl->box = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (mpd_pl->box);
+
mpd_pl->button = xfce_create_panel_toggle_button ();
gtk_widget_show (mpd_pl->button);
@@ -179,9 +188,29 @@
gtk_container_add (GTK_CONTAINER (mpd_pl->button), mpd_pl->icon);
gtk_widget_show (mpd_pl->icon);
+ gtk_box_pack_start (GTK_BOX(mpd_pl->box), mpd_pl->button, FALSE, FALSE, 0);
+
+ if (GTK_IS_WIDGET (ebox))
+ gtk_widget_destroy (ebox);
+ ebox = gtk_event_box_new ();
+ gtk_container_set_border_width (GTK_CONTAINER (ebox), BORDER / 2);
+ gtk_widget_show (ebox);
+
+ mpd_pl->volume = gtk_progress_bar_new ();
+ gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (mpd_pl->volume), GTK_PROGRESS_BOTTOM_TO_TOP);
+ gtk_widget_show (mpd_pl->volume);
+
+ g_signal_connect_swapped (ebox, "scroll-event",
+ G_CALLBACK (mpd_playlist_change_volume), mpd_pl->volume);
+
+ gtk_container_add (GTK_CONTAINER (ebox), mpd_pl->volume);
+ gtk_box_pack_start (GTK_BOX(mpd_pl->box), ebox, FALSE, FALSE, 0);
+
return mpd_pl;
}
+
+
static gboolean
mpd_playlist_button_pressed (XfcePanelPlugin *plugin,
GdkEventButton *event,
@@ -285,3 +314,33 @@
mpd_free (mpd_obj);
}
+static void
+mpd_playlist_change_volume (gpointer data, GdkEventScroll *event)
+{
+ MpdObj *mpd_obj;
+ gint mpd_volume = 0;
+ GtkWidget *volume;
+ volume = data;
+
+ if (event->type != GDK_SCROLL)
+ return;
+
+ DBG ("Connect to MPD");
+ mpd_obj = mpd_new (mpd_host, mpd_port, mpd_passwd);
+
+ if (mpd_connect (mpd_obj) == MPD_OK)
+ {
+ if (event->direction == GDK_SCROLL_UP)
+ mpd_volume = mpd_status_get_volume (mpd_obj) + 2;
+ else if (event->direction == GDK_SCROLL_DOWN)
+ mpd_volume = mpd_status_get_volume (mpd_obj) - 2;
+
+ mpd_volume = mpd_status_set_volume (mpd_obj, mpd_volume);
+
+ DBG ("Volume: %f", (gdouble)(mpd_volume/100.));
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (volume), (gdouble)(mpd_volume/100.));
+ }
+
+ DBG ("Free the MPD object");
+ mpd_free (mpd_obj);
+}
Modified: xfce4-mpc-plugin/branches/xfce4-mpd-playlist-plugin/panel-plugin/mpd-playlist.h
===================================================================
--- xfce4-mpc-plugin/branches/xfce4-mpd-playlist-plugin/panel-plugin/mpd-playlist.h 2006-09-08 20:57:28 UTC (rev 1996)
+++ xfce4-mpc-plugin/branches/xfce4-mpd-playlist-plugin/panel-plugin/mpd-playlist.h 2006-09-10 01:39:16 UTC (rev 1997)
@@ -26,9 +26,11 @@
{
XfcePanelPlugin *panel_plugin;
+ GtkWidget *box;
GtkWidget *button;
GtkWidget *icon;
GtkWidget *menu;
+ GtkWidget *volume;
};
#endif
More information about the Goodies-commits
mailing list