[evolution] I#893 - Include description in the tooltip of the events



commit 772d3fdf7ccd0ae1c8ceed9200349f1d6326170b
Author: Milan Crha <mcrha redhat com>
Date:   Mon Aug 31 19:02:51 2020 +0200

    I#893 - Include description in the tooltip of the events
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/893

 src/calendar/gui/e-calendar-view.c | 42 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
---
diff --git a/src/calendar/gui/e-calendar-view.c b/src/calendar/gui/e-calendar-view.c
index 5b186c29ff..472364d7a8 100644
--- a/src/calendar/gui/e-calendar-view.c
+++ b/src/calendar/gui/e-calendar-view.c
@@ -1797,6 +1797,7 @@ e_calendar_view_destroy_tooltip (ECalendarView *cal_view)
  *     Location: PlaceOfTheMeeting
  *     Time : DateAndTime (xx Minutes)
  *      Status: Accepted: X   Declined: Y   ...
+ *      \n<description>
  */
 
 gboolean
@@ -1817,6 +1818,7 @@ e_calendar_view_get_tooltips (const ECalendarViewEventData *data)
        ICalTimezone *zone, *default_zone;
        ECalModel *model;
        ECalClient *client = NULL;
+       const gchar *description;
 
        /* This function is a timeout callback. */
 
@@ -2020,6 +2022,46 @@ e_calendar_view_get_tooltips (const ECalendarViewEventData *data)
                g_free (tmp);
        }
 
+       description = i_cal_component_get_description (e_cal_component_get_icalcomponent (newcomp));
+       if (description && *description && g_utf8_validate (description, -1, NULL) &&
+           !g_str_equal (description, "\r") &&
+           !g_str_equal (description, "\n") &&
+           !g_str_equal (description, "\r\n")) {
+               #define MAX_TOOLTIP_DESCRIPTION_LEN 1024
+               glong len;
+
+               tmp = NULL;
+
+               len = g_utf8_strlen (description, -1);
+               if (len > MAX_TOOLTIP_DESCRIPTION_LEN) {
+                       GString *str;
+                       const gchar *end;
+
+                       end = g_utf8_offset_to_pointer (description, MAX_TOOLTIP_DESCRIPTION_LEN);
+                       str = g_string_new_len (description, end - description);
+                       g_string_append (str, "…");
+
+                       tmp = g_string_free (str, FALSE);
+               }
+
+               hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+               gtk_widget_set_margin_top (hbox, 12);
+               label = gtk_label_new (tmp ? tmp : description);
+               g_object_set (G_OBJECT (label),
+                       "wrap", TRUE,
+                       "width-chars", 80,
+                       "max-width-chars", 100,
+                       "xalign", 0.0,
+                       NULL);
+
+               gtk_box_pack_start ((GtkBox *) hbox, label, FALSE, FALSE, 0);
+               ebox = gtk_event_box_new ();
+               gtk_container_add ((GtkContainer *) ebox, hbox);
+               gtk_box_pack_start ((GtkBox *) box, ebox, FALSE, FALSE, 0);
+
+               g_free (tmp);
+       }
+
        pevent->tooltip = gtk_window_new (GTK_WINDOW_POPUP);
 
        toplevel = gtk_widget_get_toplevel (GTK_WIDGET (data->cal_view));


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