System: Arch linux, gtk 3.20.6-1, Xfce Notify Daemon 0.3.90, Xfce built from git. Since the migration of xfce4-notifyd to gtk3, there is no longer a limit on the width of the notification as there was with gtk2. In gtk2, the notifications occupied at most, a third of my screen real estate and if the message body was longer, it automatically wrapped. Now with GTK3, the notification can take up the width of the screen if the message body is long. Setting gtk_label_set_max_width_chars forces the notification to wrap. I set the value in this call to 55 chars for my screen (1366x768), but this value may need to be set based on the geometry of the screen. There may be a better way to do this..... diff --git a/xfce4-notifyd/xfce-notify-window.c b/xfce4-notifyd/xfce-notify-window.c index 4c5df56..9a5ecc0 100644 --- a/xfce4-notifyd/xfce-notify-window.c +++ b/xfce4-notifyd/xfce-notify-window.c @@ -228,12 +228,14 @@ xfce_notify_window_init(XfceNotifyWindow *window) window->summary = gtk_label_new(NULL); gtk_widget_set_name (window->summary, "summary"); + gtk_label_set_max_width_chars (GTK_LABEL(window->summary), 55); gtk_label_set_line_wrap(GTK_LABEL(window->summary), TRUE); gtk_label_set_xalign (GTK_LABEL(window->summary), 0); gtk_box_pack_start(GTK_BOX(vbox), window->summary, FALSE, FALSE, 0); window->body = gtk_label_new(NULL); gtk_widget_set_name (window->body, "body"); + gtk_label_set_max_width_chars (GTK_LABEL(window->body), 55); gtk_label_set_line_wrap(GTK_LABEL(window->body), TRUE); gtk_label_set_xalign (GTK_LABEL(window->body), 0); gtk_box_pack_start(GTK_BOX(vbox), window->body, TRUE, TRUE, 0);
Hm, good catch. I guess we should limit the size of the window instead of the label (although it's valid approach imo) because the label is already set to wrap.
I've pushed a workaround for this problem to master: http://git.xfce.org/apps/xfce4-notifyd/commit/?id=25f70e7d607ec745276f7504eafde164e3a28377 Basically I'm trying to limit the width of the window to 1/3 of the screen. Initially I tried with gtk_widget_set_size_request, but that didn't really work so I resorted to your approach, but basing the max characters on the 1/3 of the screen. The main problem I see with this though is that it assumes that a character including its padding is 10px in width (which it might not be, e.g. on a HiDPI screen). Hopefully we can find a better solution to this problem.
Simon Steinbeiss referenced this bugreport in commit f8d6aaf1c1498334749a1a45734f960cac59951a Ensure body and summary of notifications are correctly ellipsized (Bug #12674) https://git.xfce.org/apps/xfce4-notifyd/commit?id=f8d6aaf1c1498334749a1a45734f960cac59951a
Simon Steinbeiss referenced this bugreport in commit addbc3e8340af75607ea774d7163d110820cf91d Improve wrapping and ellipsizing of notification bubble (Bug #12674) https://git.xfce.org/apps/xfce4-notifyd/commit?id=addbc3e8340af75607ea774d7163d110820cf91d
Thanks Simon. The effect looks good. However, I am getting theme messages now: (xfce4-notifyd:10212): Gtk-CRITICAL **: gtk_label_set_line_wrap_mode: assertion 'GTK_IS_LABEL (label)' failed (xfce4-notifyd:10212): Gtk-CRITICAL **: gtk_label_set_lines: assertion 'GTK_IS_LABEL (label)' failed
Please disregard the above comment - it's working now. I believe it was an issue with my build environment and the state of the code I had checked out. It works fine and looks good. Thanks again.
@ToZ: Cool, happy you like the current state. There were already some discussions around the numbers of lines for body(6)/summary(1), but I think in general this is much better than 0.4.1. This can be further tweaked - alas I don't want to add more options.
I consider this fixed. It's also not easy to really improve this much further from what I know so far.