summarylogtreecommitdiffstats
path: root/update.diff
blob: ccdc5e058e120c2a9680cc0208d6fc231e17d70b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
diff -rudp xfce4-mpc-plugin-0.5.3.orig/panel-plugin/xfce4-mpc-plugin.c xfce4-mpc-plugin-0.5.3/panel-plugin/xfce4-mpc-plugin.c
--- xfce4-mpc-plugin-0.5.3.orig/panel-plugin/xfce4-mpc-plugin.c	2023-04-21 04:18:03.000000000 -0400
+++ xfce4-mpc-plugin-0.5.3/panel-plugin/xfce4-mpc-plugin.c	2023-12-23 23:07:02.000000000 -0500
@@ -36,6 +36,7 @@
 #define TOOLTIP_TEXT _("... not connected?")
 #define TOOLTIP_FORMAT "Volume: %vol%% - Mpd %status%%newline%%artist% - %album% -/- (#%track%) %title%"
 #define PLAYLIST_FORMAT "%artist% - %album% -/- (#%track%) %title%"
+#define TIMEOUT 1000
 
 static void resize_button(GtkWidget *, gint, gint);
 
@@ -705,6 +706,37 @@ show_playlist (t_mpc* mpc)
    g_string_free(str, TRUE);
 }
 
+static gint
+mpc_timer(t_mpc* mpc)
+{
+   GtkWidget *image;
+
+   switch (mpd_player_get_state(mpc->mo)) {
+      case MPD_PLAYER_PLAY:
+         if (!(mpc->button_says_playing)) {
+	    image = gtk_container_get_children(GTK_CONTAINER(mpc->toggle))->data;
+	    gtk_widget_destroy(image);
+	    image = xfce_panel_image_new_from_source("media-playback-pause");
+	    gtk_container_add(GTK_CONTAINER(mpc->toggle), image);
+	    gtk_widget_show(image);
+            mpc->button_says_playing = TRUE;
+	 }
+	 break;
+      default:
+	 if (mpc->button_says_playing) {
+	    image = gtk_container_get_children(GTK_CONTAINER(mpc->toggle))->data;
+	    gtk_widget_destroy(image);
+	    image = xfce_panel_image_new_from_source("media-playback-start");
+	    gtk_container_add(GTK_CONTAINER(mpc->toggle), image);
+	    gtk_widget_show(image);
+	    mpc->button_says_playing = FALSE;
+	 }
+	 break;
+   }
+
+   return TRUE;
+}
+
 static void
 toggle(GtkWidget *widget, GdkEventButton* event, t_mpc* mpc)
 {
@@ -884,6 +916,7 @@ mpc_create (XfcePanelPlugin * plugin)
    mpc->toggle = new_button_with_cbk(plugin, mpc->box, "media-playback-pause-symbolic", G_CALLBACK(toggle), mpc);
    mpc->next = new_button_with_cbk(plugin, mpc->box, "media-skip-forward-symbolic", G_CALLBACK(next), mpc);
 
+   mpc->button_says_playing = TRUE;
    mpc->random = gtk_check_menu_item_new_with_label (_("Random"));
    g_signal_connect (G_OBJECT(mpc->random), "toggled", G_CALLBACK (mpc_random_toggled), mpc);
    mpc->repeat = gtk_check_menu_item_new_with_label (_("Repeat"));
@@ -963,6 +996,7 @@ mpc_construct (XfcePanelPlugin * plugin)
           mpc_launch_streaming(mpc);
    }
 
+   g_timeout_add (TIMEOUT, (GSourceFunc) mpc_timer, mpc);
    gtk_container_add (GTK_CONTAINER (plugin), mpc->frame);
    gtk_frame_set_shadow_type (GTK_FRAME (mpc->frame), ((mpc->show_frame) ? GTK_SHADOW_IN : GTK_SHADOW_NONE));
 
diff -rudp xfce4-mpc-plugin-0.5.3.orig/panel-plugin/xfce4-mpc-plugin.h xfce4-mpc-plugin-0.5.3/panel-plugin/xfce4-mpc-plugin.h
--- xfce4-mpc-plugin-0.5.3.orig/panel-plugin/xfce4-mpc-plugin.h	2021-08-24 16:55:29.000000000 -0400
+++ xfce4-mpc-plugin-0.5.3/panel-plugin/xfce4-mpc-plugin.h	2023-12-23 23:05:31.000000000 -0500
@@ -54,6 +54,7 @@ typedef struct {
    gchar * playlist_format;
    gboolean mpd_repeat;
    gboolean mpd_random;
+   gboolean button_says_playing;
    gint nb_outputs;
    t_mpd_output ** mpd_outputs;
 } t_mpc;