! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
GTK3 Notification Width Issue
Status:
RESOLVED: FIXED
Product:
Xfce4-notifyd
Component:
general

Comments

Description ToZ editbugs 2016-07-01 22:14:57 CEST
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);
Comment 1 Simon Steinbeiss editbugs 2016-07-02 09:09:52 CEST
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.
Comment 2 Simon Steinbeiss editbugs 2016-07-04 00:12:50 CEST
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.
Comment 3 Git Bot editbugs 2017-10-29 23:49:22 CET
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
Comment 4 Git Bot editbugs 2018-03-01 00:45:44 CET
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
Comment 5 ToZ editbugs 2018-03-01 01:02:54 CET
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
Comment 6 ToZ editbugs 2018-03-01 01:17:26 CET
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.
Comment 7 Simon Steinbeiss editbugs 2018-03-02 19:39:51 CET
@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.
Comment 8 Simon Steinbeiss editbugs 2020-05-05 01:25:33 CEST
I consider this fixed. It's also not easy to really improve this much further from what I know so far.

Bug #12674

Reported by:
ToZ
Reported on: 2016-07-01
Last modified on: 2020-05-05

People

Assignee:
Simon Steinbeiss
CC List:
1 user

Version

Attachments

Additional information