summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLogan Rathbone <poprocks@gmail.com>2023-02-04 10:38:36 -0500
committerLogan Rathbone <poprocks@gmail.com>2023-02-04 10:38:36 -0500
commit47b1a40e88e8b4b5ad4ae4b10dd42606145eb110 (patch)
treecb63487b9f077ce943027bb7aa6b96ad91d77e94 /src
parentPrevent ZENITY_TIMEOUT from clashing with custom response IDs (diff)
downloadzenity-47b1a40e88e8b4b5ad4ae4b10dd42606145eb110.tar.gz
zenity-47b1a40e88e8b4b5ad4ae4b10dd42606145eb110.tar.bz2
zenity-47b1a40e88e8b4b5ad4ae4b10dd42606145eb110.zip
msg: Set max-width-chars to relatively small value if --width specified
This should fix a small regression caused by 25a92fff, in which dialog texts can be stretched out too long if --width *is* specified. See also #42
Diffstat (limited to 'src')
-rw-r--r--src/msg.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/msg.c b/src/msg.c
index 92651525..641dad6c 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -199,8 +199,24 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) {
gtk_window_set_default_size (
GTK_WINDOW (dialog), data->width, data->height);
- if (data->width > -1)
+ if (data->width > -1) {
gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1);
+
+ if (!msg_data->no_wrap) {
+ /* Minimum width */
+ gtk_label_set_width_chars (GTK_LABEL(text), 10);
+
+ /* If we don't set max-width-chars, gtk may set the natural width
+ * of the label to be wider than what we want for the window. So we
+ * want to set it to something relatively small, because,
+ * according to TFM, even if max_width_chars is set to anything
+ * other than -1, for wrapping labels the label will still be
+ * rewrapped to use all of the available width. So we'll just set
+ * it to the same value as width-chars for posterity.
+ */
+ gtk_label_set_max_width_chars (GTK_LABEL(text), 10);
+ }
+ }
else if (!msg_data->ellipsize && !msg_data->no_wrap) {
/* The magic number 60 is taken from gtk+/gtk/ui/gtkmessagedialog.ui
with 10 as a minimum width. */
bgstack15