Hi folks,
I just implemented a small feature for lxmusic. You can now toggle
play/pause by clicking on the tray icon which is well known from other media
players (eg. amarok). Secondly you can increase/decrease the volume with the
mouse wheel on the tray icon now. If you appreciate this feature, please
commit my patch.
Greets,
Manuel Luitz
diff --git a/src/lxmusic.c b/src/lxmusic.c
index 993b06e..6d301d1 100644
--- a/src/lxmusic.c
+++ b/src/lxmusic.c
@@ -45,6 +45,7 @@
#include "lxmusic-plugin-config.h"
#include "utils.h"
+
enum {
COL_ID = 0,
COL_ARTIST,
@@ -141,6 +142,8 @@ static int win_ypos = 0;
void on_locate_cur_track (GtkAction* act, gpointer user_data);
void on_play_btn_clicked (GtkButton* btn, gpointer user_data);
+static void on_volume_btn_scrolled ( GtkWidget *widget, GdkEventScroll *event, gpointer user_data );
+static int on_playback_started ( xmmsv_t* value, void* user_data );
static GtkTreeIter get_current_track_iter ();
static gboolean get_track_properties (xmmsv_t *value, TrackProperties *properties);
@@ -439,13 +442,38 @@ static void on_tray_icon_popup_menu(GtkStatusIcon* icon, guint btn, guint time,
return;
}
-static void create_tray_icon()
-{
- tray_icon = (GtkWidget*)gtk_status_icon_new_from_icon_name("lxmusic");
- gtk_status_icon_set_tooltip(GTK_STATUS_ICON(tray_icon), _("LXMusic"));
- g_signal_connect(tray_icon, "activate", G_CALLBACK(on_tray_icon_activate), NULL );
- g_signal_connect(tray_icon, "popup-menu", G_CALLBACK(on_tray_icon_popup_menu), NULL );
-}
+static gboolean on_tray_icon_middle_clicked(GtkWidget *widget, GdkEventButton *event, gpointer data) {
+ /* Only handle the keypress event on middle click
+ Toggle play/pause */
+ if ( event->button == 2 ) {
+ xmmsc_result_t *res;
+
+ if( playback_status == XMMS_PLAYBACK_STATUS_PLAY )
+ {
+ res = xmmsc_playback_pause(con);
+ xmmsc_result_notifier_set_and_unref(res, on_playback_started, NULL);
+ }
+ else
+ {
+ res = xmmsc_playback_start(con);
+ xmmsc_result_unref(res);
+ }
+ return TRUE;
+
+ } else {
+ return FALSE;
+ }
+}
+
+ static void create_tray_icon()
+ {
+ tray_icon = (GtkWidget*)gtk_status_icon_new_from_icon_name("lxmusic");
+ gtk_status_icon_set_tooltip(GTK_STATUS_ICON(tray_icon), _("LXMusic"));
+ g_signal_connect(tray_icon, "activate", G_CALLBACK(on_tray_icon_activate), NULL );
+ g_signal_connect(tray_icon, "popup-menu", G_CALLBACK(on_tray_icon_popup_menu), NULL );
+ g_signal_connect(tray_icon, "scroll-event", G_CALLBACK(on_volume_btn_scrolled), volume_btn);
+ g_signal_connect(tray_icon, "button_press_event", G_CALLBACK(on_tray_icon_middle_clicked), NULL );
+ }
void on_preference(GtkAction* act, gpointer data)
{
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Lxde-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lxde-list