From 16eb1983859385095d935f08955fa092f7f22f22 Mon Sep 17 00:00:00 2001
From: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
Date: Mon, 12 Oct 2026 20:31:39 -0300
Subject: Update Kaffeine mute volume icon
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Read Xine's explicit mute parameter to keep the mute action icon in sync with the audio state. Refresh it after playback initialization as well as after toggling mute.

Fixes: TDE/kaffeine#7
Signed-off-by: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
---
 kaffeine/src/player-parts/xine-part/kxinewidget.cpp |  9 +++++++++
 kaffeine/src/player-parts/xine-part/kxinewidget.h   |  1 +
 kaffeine/src/player-parts/xine-part/xine_part.cpp   | 17 ++++++++++++++---
 kaffeine/src/player-parts/xine-part/xine_part.h     |  2 ++
 4 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/kaffeine/src/player-parts/xine-part/kxinewidget.cpp b/kaffeine/src/player-parts/xine-part/kxinewidget.cpp
index 7361e19..21348fc 100644
--- a/kaffeine/src/player-parts/xine-part/kxinewidget.cpp
+++ b/kaffeine/src/player-parts/xine-part/kxinewidget.cpp
@@ -2749,6 +2749,15 @@ void KXineWidget::slotToggleMute()
 	}
 }
 
+bool KXineWidget::isMuted() const
+{
+	if (!m_xineReady)
+		return false;
+
+	int muteParam = m_softwareMixer ? XINE_PARAM_AUDIO_AMP_MUTE : XINE_PARAM_AUDIO_MUTE;
+	return xine_get_param(m_xineStream, muteParam) != 0;
+}
+
 bool KXineWidget::SoftwareMixing() const
 {
 	if (m_softwareMixer)
diff --git a/kaffeine/src/player-parts/xine-part/kxinewidget.h b/kaffeine/src/player-parts/xine-part/kxinewidget.h
index c9e1155..79e3530 100644
--- a/kaffeine/src/player-parts/xine-part/kxinewidget.h
+++ b/kaffeine/src/player-parts/xine-part/kxinewidget.h
@@ -221,6 +221,7 @@ public slots:
 
 	void slotSetVolume(int);
 	void slotToggleMute();
+	bool isMuted() const;
 	void slotSpeedPause();
 	void slotSpeedNormal();
 	void slotSpeedFaster();
diff --git a/kaffeine/src/player-parts/xine-part/xine_part.cpp b/kaffeine/src/player-parts/xine-part/xine_part.cpp
index f68122f..6edd41a 100644
--- a/kaffeine/src/player-parts/xine-part/xine_part.cpp
+++ b/kaffeine/src/player-parts/xine-part/xine_part.cpp
@@ -69,8 +69,8 @@ K_EXPORT_COMPONENT_FACTORY (libxinepart, XinePartFactory)
 XinePart::XinePart(TQWidget* parentWidget, const char* widgetName, TQObject* parent, const char* name, const TQStringList& args)
 		: DCOPObject("XinePartIface"),
 		KaffeinePart(parent, name ? name : "XinePart"),
-		m_current(0), m_xine(NULL), m_pictureSettings(NULL), m_deinterlacerConfigWidget(NULL),
-		m_filterDialog(NULL), m_embeddedContext(NULL)
+		m_current(0), m_muteAction(NULL), m_xine(NULL), m_pictureSettings(NULL),
+		m_deinterlacerConfigWidget(NULL), m_filterDialog(NULL), m_embeddedContext(NULL)
 {
 	kdDebug() << "XinePart: Creating new XinePart..." << endl;
 
@@ -486,6 +486,15 @@ void XinePart::slotMute()
 		return;
 
 	m_xine->slotToggleMute();
+	updateMuteIcon();
+}
+
+void XinePart::updateMuteIcon()
+{
+	if (!m_muteAction || !m_xine->isXineReady())
+		return;
+
+	m_muteAction->setIcon(m_xine->isMuted() ? "player_mute" : "player_volume");
 }
 
 void XinePart::slotVolumeUp()
@@ -1247,6 +1256,8 @@ void XinePart::slotInfo()
 
 void XinePart::slotFinalize()
 {
+	updateMuteIcon();
+
 	if (factory())
 	{
 		TDEToolBar *pos = (TDEToolBar*)factory()->container("positionToolBar", this);
@@ -1359,7 +1370,7 @@ void XinePart::initActions()
 	new TDEAction(i18n("&Next Audio Channel"), 0, 0, this, TQ_SLOT(slotNextAudioChannel()), actionCollection(), "next_audio_channels");
 	m_audioVisual = new TDESelectAction(i18n("Audio &Visualization"), 0, actionCollection(), "audio_visualization");
 	connect(m_audioVisual, TQ_SIGNAL(activated(const TQString&)), m_xine, TQ_SLOT(slotSetVisualPlugin(const TQString&)));
-	new TDEAction(i18n("&Mute"), "player_mute", Key_U, this, TQ_SLOT(slotMute()), actionCollection(), "audio_mute");
+	m_muteAction = new TDEAction(i18n("&Mute"), "player_volume", Key_U, this, TQ_SLOT(slotMute()), actionCollection(), "audio_mute");
 	new TDEAction(i18n("Volume Up"), NULL, Key_Plus, this, TQ_SLOT(slotVolumeUp()), actionCollection(), "volume_increase");
 	new TDEAction(i18n("Volume Down"), NULL, Key_Minus, this, TQ_SLOT(slotVolumeDown()), actionCollection(), "volume_decrease");
 
diff --git a/kaffeine/src/player-parts/xine-part/xine_part.h b/kaffeine/src/player-parts/xine-part/xine_part.h
index 2afcab5..6fc1d44 100644
--- a/kaffeine/src/player-parts/xine-part/xine_part.h
+++ b/kaffeine/src/player-parts/xine-part/xine_part.h
@@ -175,6 +175,7 @@ private slots:
 	void slotNewFrameSize();
 	void slotPlaybackFinished();
 	void slotContextMenu(const TQPoint&);
+	void updateMuteIcon();
 	void slotDisableAllActions();
 	void slotEnableAllActions();
 	void slotEnablePlayActions();
@@ -219,6 +220,7 @@ private:
 	TQString m_broadcastAddress;
 
 	TQSlider* m_volume;
+	TDEAction* m_muteAction;
 	PositionSlider* m_position;
 	TQPushButton* m_playTime;
 	uint currentPosition;
-- 
cgit v1.2.3

