Bug 228873 - [patch] audio/pavucontrol: fix unreadable label names due to ellipsize side-effect with GTK2 option
Summary: [patch] audio/pavucontrol: fix unreadable label names due to ellipsize side-e...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Romain Tartière
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-10 17:45 UTC by Samy Mahmoudi
Modified: 2019-03-06 18:40 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (romain)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Samy Mahmoudi 2018-06-10 17:45:43 UTC
Description:
When building audio/pavucontrol against GTK2 (default option), the label names of the streams/devices are improperly ellipsized. The GTK+2 Reference Manual mentions the side-effect that the label requests only enough space to display the ellipsis "...".
URL: https://developer.gnome.org/gtk2/stable/GtkLabel.html#GtkLabel--ellipsize

Reproducibility:
pkg install --yes pavucontrol && pavucontrol

Workaround for devices:
Conditionally patch src/pavucontrol.glade to expand corresponding labels (patches provided below)

Workarounds for streams (by increasing order of preference):
• Make GTK3 the default option (fixes not only streams but also devices)
• Conditionally patch src/pavucontrol.glade to set the "ellipsize" property of the affected labels to none. Runs the risk of stretching the window horizontally more than the screen size if the label name is too long (nevertheless, patch may be provided).
• Conditionally patch src/pavucontrol.glade to expand the affected labels. Works flawlessly with devices but slightly changes the pavucontrol expected appearance with streams because each stream is followed by an "on" label which gets shifted at right (nevertheless, patch may be provided).
• Conditionally patch src/mainwindow.cc to set the "width-chars" property dynamically if the label name is less than 64 characters and to ellipsize beyond 64 characters otherwise (patches provided below).

# Patch to apply to Makefile
--- Makefile.orig	2018-06-10 18:56:03.808240000 +0200
+++ Makefile	2018-06-10 18:55:59.757969000 +0200
@@ -30,6 +30,7 @@
 GTK2_USE=	GNOME=gtkmm24
 GTK2_LIB_DEPENDS=	libcanberra.so:audio/libcanberra
 GTK2_CONFIGURE_ON=	--disable-gtk3
+GTK2_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-gtk2-ellipsize-side-effect
 
 GTK3_USE=	GNOME=gtkmm30
 GTK3_LIB_DEPENDS=	libcanberra-gtk3.so:audio/libcanberra-gtk3
# End of file

# Patch file to add to files/extra-patch-gtk2-ellipsize-side-effect
--- src/mainwindow.cc.orig	2015-03-24 14:39:00 UTC
+++ src/mainwindow.cc
@@ -758,9 +758,11 @@ void MainWindow::updateSinkInput(const p
         g_free(txt);
         w->nameLabel->set_markup(txt = g_markup_printf_escaped(": %s", info.name));
         g_free(txt);
+        w->nameLabel->set_width_chars ((strlen(info.name) < 62) ? strlen(info.name) : 62);
     } else {
         w->boldNameLabel->set_text("");
         w->nameLabel->set_label(info.name);
+        w->nameLabel->set_width_chars ((strlen(info.name) < 64) ? strlen(info.name) : 64);
     }

     w->nameLabel->set_tooltip_text(info.name);
@@ -813,9 +815,11 @@ void MainWindow::updateSourceOutput(cons
         g_free(txt);
         w->nameLabel->set_markup(txt = g_markup_printf_escaped(": %s", info.name));
         g_free(txt);
+        w->nameLabel->set_width_chars ((strlen(info.name) < 62) ? strlen(info.name) : 62);
     } else {
         w->boldNameLabel->set_text("");
         w->nameLabel->set_label(info.name);
+        w->nameLabel->set_width_chars ((strlen(info.name) < 64) ? strlen(info.name) : 64);
     }

     w->nameLabel->set_tooltip_text(info.name);
@@ -897,6 +901,7 @@ bool MainWindow::createEventRoleWidget()

     eventRoleWidget->boldNameLabel->set_text("");
     eventRoleWidget->nameLabel->set_label(_("System Sounds"));
+    eventRoleWidget->nameLabel->set_width_chars (13);

     eventRoleWidget->iconImage->set_from_icon_name("multimedia-volume-control", Gtk::ICON_SIZE_SMALL_TOOLBAR);

--- src/pavucontrol.glade.orig	2015-03-24 14:39:00 UTC
+++ src/pavucontrol.glade
@@ -259,7 +259,7 @@
                             <property name="ellipsize">end</property>
                           </object>
                           <packing>
-                            <property name="expand">False</property>
+                            <property name="expand">True</property>
                             <property name="fill">True</property>
                             <property name="position">1</property>
                           </packing>
# End of file
Comment 1 Romain Tartière freebsd_committer freebsd_triage 2018-07-02 16:34:24 UTC
Thanks for this report.  Indeed, the Gtk 2.0 GUI is completely f**ked-up!

I'm giving a look right now.  If the Gtk 3.0 GUI has no problem, let's default to this and drop Gtk 2.0 support ;-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2018-07-02 19:47:12 UTC
A commit references this bug:

Author: romain
Date: Mon Jul  2 19:46:57 UTC 2018
New revision: 473769
URL: https://svnweb.freebsd.org/changeset/ports/473769

Log:
  Always use the GTK3 interface

  When built against GTK2, label names are improperly ellipsized, making the user
  interface somewhat useless.  Remove the OPTIONS to choose between GTK2 and GTK3
  and always build the GTK3 version which does not have this problem.

  Bump PORTREVISION.

  PR:		228873
  Reported by:	samy.mahmoudi@gmail.com

Changes:
  head/audio/pavucontrol/Makefile
  head/audio/pavucontrol/distinfo
Comment 3 Romain Tartière freebsd_committer freebsd_triage 2018-07-02 19:48:02 UTC
Committed, thanks!
Comment 4 Samy Mahmoudi 2018-07-03 17:03:05 UTC
Thank you Romain for your review and your commit.

After further consideration, making GTK3 the default option also seems fair enough to me. Modern third-party software tends to use GTK+ 3 and there is an ongoing effort to migrate older software from GTK+ 2.x to GTK+ 3, e.g. Xfce.

However, we could also continue to offer the GTK2 option during the transition to allow current Xfce users to have a consistent interface without struggling with theme porting/backporting. Other users may permanently need the GTK2 option to consistently integrate pavucontrol into their environment (LXDE, ROX-Filer with various window managers, etc.). Besides, new port requests audio/pavucontrol-qt and audio/pavucontrolqt-l10n have been added less than two weeks ago, so that pavucontrol would be usable by a wide range of FreeBSD users.

The following modifications (to apply to your recent port revision 2) allow to patch the sources only if the user chooses the GTK2 option. Still, GTK+ 3 is the future ;-) At least for the moment...

# Patch to apply to Makefile
--- Makefile.orig	2018-07-03 17:49:01.888507000 +0200
+++ Makefile	2018-07-03 18:36:54.812833000 +0200
@@ -3,7 +3,7 @@
 
 PORTNAME=	pavucontrol
 PORTVERSION=	3.0
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	audio
 MASTER_SITES=	http://freedesktop.org/software/pulseaudio/${PORTNAME}/
 
@@ -13,15 +13,27 @@
 LICENSE=	GPLv2
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
-LIB_DEPENDS=	libpulse.so:audio/pulseaudio \
-		libcanberra-gtk3.so:audio/libcanberra-gtk3
+LIB_DEPENDS=	libpulse.so:audio/pulseaudio
 
 GNU_CONFIGURE=	yes
 USES=		gmake pkgconfig gettext tar:xz compiler:c++11-lang
-USE_GNOME=	glibmm gtkmm30 intltool libsigc++20
+USE_GNOME=	glibmm intltool libsigc++20
 USE_CXXSTD=	c++11
 
+OPTIONS_SUB=	yes
+OPTIONS_SINGLE=	GTK
+OPTIONS_SINGLE_GTK=	GTK2 GTK3
+OPTIONS_DEFAULT=	GTK3
+
 CONFIGURE_ARGS=	--disable-lynx
+
+GTK2_USE=	GNOME=gtkmm24
+GTK2_LIB_DEPENDS=	libcanberra.so:audio/libcanberra
+GTK2_CONFIGURE_ON=	--disable-gtk3
+GTK2_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-gtk2-ellipsize-side-effect
+
+GTK3_USE=	GNOME=gtkmm30
+GTK3_LIB_DEPENDS=	libcanberra-gtk3.so:audio/libcanberra-gtk3
 
 post-patch:
 # Install locales files in right place
# End of file

# Patch file to add to files/extra-patch-gtk2-ellipsize-side-effect
--- src/mainwindow.cc.orig	2015-03-24 14:39:00 UTC
+++ src/mainwindow.cc
@@ -758,9 +758,11 @@ void MainWindow::updateSinkInput(const p
         g_free(txt);
         w->nameLabel->set_markup(txt = g_markup_printf_escaped(": %s", info.name));
         g_free(txt);
+        w->nameLabel->set_width_chars ((strlen(info.name) < 62) ? strlen(info.name) : 62);
     } else {
         w->boldNameLabel->set_text("");
         w->nameLabel->set_label(info.name);
+        w->nameLabel->set_width_chars ((strlen(info.name) < 64) ? strlen(info.name) : 64);
     }

     w->nameLabel->set_tooltip_text(info.name);
@@ -813,9 +815,11 @@ void MainWindow::updateSourceOutput(cons
         g_free(txt);
         w->nameLabel->set_markup(txt = g_markup_printf_escaped(": %s", info.name));
         g_free(txt);
+        w->nameLabel->set_width_chars ((strlen(info.name) < 62) ? strlen(info.name) : 62);
     } else {
         w->boldNameLabel->set_text("");
         w->nameLabel->set_label(info.name);
+        w->nameLabel->set_width_chars ((strlen(info.name) < 64) ? strlen(info.name) : 64);
     }

     w->nameLabel->set_tooltip_text(info.name);
@@ -897,6 +901,7 @@ bool MainWindow::createEventRoleWidget()

     eventRoleWidget->boldNameLabel->set_text("");
     eventRoleWidget->nameLabel->set_label(_("System Sounds"));
+    eventRoleWidget->nameLabel->set_width_chars (13);

     eventRoleWidget->iconImage->set_from_icon_name("multimedia-volume-control", Gtk::ICON_SIZE_SMALL_TOOLBAR);

--- src/pavucontrol.glade.orig	2015-03-24 14:39:00 UTC
+++ src/pavucontrol.glade
@@ -259,7 +259,7 @@
                             <property name="ellipsize">end</property>
                           </object>
                           <packing>
-                            <property name="expand">False</property>
+                            <property name="expand">True</property>
                             <property name="fill">True</property>
                             <property name="position">1</property>
                           </packing>
# End of file
Comment 5 Samy Mahmoudi 2018-07-03 17:07:46 UTC
I forgot to change the status...
Comment 6 Romain Tartière freebsd_committer freebsd_triage 2019-03-06 18:40:57 UTC
I have just been recalled about this when updating to 4.0 (I had non committed patches in my local repo).

Support for GTK2 was removed upstream, so closing the issue.

Thanks!