[notification-daemon] Fix positioning notifications with long text



commit 44130db13f3cde6683a03e129101b426bd244e26
Author: Balló György <ballogyor gmail com>
Date:   Thu Oct 30 02:34:52 2014 +0100

    Fix positioning notifications with long text
    
    https://bugzilla.gnome.org/show_bug.cgi?id=687724

 src/nd-bubble.c           |   13 +++++++++++++
 src/nd-notification-box.c |    2 ++
 src/nd-stack.c            |    4 ++--
 3 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/nd-bubble.c b/src/nd-bubble.c
index 6de7f8f..17e0897 100644
--- a/src/nd-bubble.c
+++ b/src/nd-bubble.c
@@ -413,6 +413,16 @@ nd_bubble_realize (GtkWidget *widget)
         GTK_WIDGET_CLASS (nd_bubble_parent_class)->realize (widget);
 }
 
+static void
+nd_bubble_get_preferred_width (GtkWidget *widget,
+                               gint *min_width,
+                               gint *nat_width)
+{
+        if (nat_width != NULL) {
+                 *nat_width = WIDTH;
+        }
+}
+
 static gboolean
 nd_bubble_enter_notify_event (GtkWidget        *widget,
                               GdkEventCrossing *event)
@@ -451,6 +461,7 @@ nd_bubble_class_init (NdBubbleClass *klass)
         widget_class->enter_notify_event = nd_bubble_enter_notify_event;
         widget_class->leave_notify_event = nd_bubble_leave_notify_event;
         widget_class->realize = nd_bubble_realize;
+        widget_class->get_preferred_width = nd_bubble_get_preferred_width;
 
         g_type_class_add_private (klass, sizeof (NdBubblePrivate));
 }
@@ -623,6 +634,7 @@ nd_bubble_init (NdBubble *bubble)
         gtk_box_pack_start (GTK_BOX (vbox), bubble->priv->summary_label, TRUE, TRUE, 0);
         gtk_misc_set_alignment (GTK_MISC (bubble->priv->summary_label), 0, 0);
         gtk_label_set_line_wrap (GTK_LABEL (bubble->priv->summary_label), TRUE);
+        gtk_label_set_line_wrap_mode (GTK_LABEL (bubble->priv->summary_label), PANGO_WRAP_WORD_CHAR);
 
         atkobj = gtk_widget_get_accessible (bubble->priv->summary_label);
         atk_object_set_description (atkobj, "Notification summary text.");
@@ -645,6 +657,7 @@ nd_bubble_init (NdBubble *bubble)
         gtk_box_pack_start (GTK_BOX (vbox), bubble->priv->body_label, TRUE, TRUE, 0);
         gtk_misc_set_alignment (GTK_MISC (bubble->priv->body_label), 0, 0);
         gtk_label_set_line_wrap (GTK_LABEL (bubble->priv->body_label), TRUE);
+        gtk_label_set_line_wrap_mode (GTK_LABEL (bubble->priv->body_label), PANGO_WRAP_WORD_CHAR);
         g_signal_connect (bubble->priv->body_label,
                           "activate-link",
                           G_CALLBACK (on_activate_link),
diff --git a/src/nd-notification-box.c b/src/nd-notification-box.c
index 352c515..12267a9 100644
--- a/src/nd-notification-box.c
+++ b/src/nd-notification-box.c
@@ -336,6 +336,7 @@ nd_notification_box_init (NdNotificationBox *notification_box)
         gtk_box_pack_start (GTK_BOX (vbox), notification_box->priv->summary_label, TRUE, TRUE, 0);
         gtk_misc_set_alignment (GTK_MISC (notification_box->priv->summary_label), 0, 0);
         gtk_label_set_line_wrap (GTK_LABEL (notification_box->priv->summary_label), TRUE);
+        gtk_label_set_line_wrap_mode (GTK_LABEL (notification_box->priv->summary_label), 
PANGO_WRAP_WORD_CHAR);
 
         atkobj = gtk_widget_get_accessible (notification_box->priv->summary_label);
         atk_object_set_description (atkobj, "Notification summary text.");
@@ -354,6 +355,7 @@ nd_notification_box_init (NdNotificationBox *notification_box)
         gtk_box_pack_start (GTK_BOX (vbox), notification_box->priv->body_label, TRUE, TRUE, 0);
         gtk_misc_set_alignment (GTK_MISC (notification_box->priv->body_label), 0, 0);
         gtk_label_set_line_wrap (GTK_LABEL (notification_box->priv->body_label), TRUE);
+        gtk_label_set_line_wrap_mode (GTK_LABEL (notification_box->priv->body_label), PANGO_WRAP_WORD_CHAR);
 
         atkobj = gtk_widget_get_accessible (notification_box->priv->body_label);
         atk_object_set_description (atkobj, "Notification body text.");
diff --git a/src/nd-stack.c b/src/nd-stack.c
index 6c03acc..43746c5 100644
--- a/src/nd-stack.c
+++ b/src/nd-stack.c
@@ -360,7 +360,7 @@ nd_stack_shift_notifications (NdStack     *stack,
                 GtkRequisition  req;
 
                 if (bubble == NULL || nw2 != bubble) {
-                        gtk_widget_size_request (GTK_WIDGET (nw2), &req);
+                        gtk_widget_get_preferred_size (GTK_WIDGET (nw2), NULL, &req);
 
                         translate_coordinates (stack->priv->location,
                                                &workarea,
@@ -431,7 +431,7 @@ nd_stack_add_bubble (NdStack  *stack,
         GtkRequisition  req;
         int             x, y;
 
-        gtk_widget_size_request (GTK_WIDGET (bubble), &req);
+        gtk_widget_get_preferred_size (GTK_WIDGET (bubble), NULL, &req);
         nd_stack_shift_notifications (stack,
                                       bubble,
                                       NULL,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]