[evolution] I#214 - Bold meeting summary text cut in Calendar view
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#214 - Bold meeting summary text cut in Calendar view
- Date: Tue, 6 Nov 2018 15:07:38 +0000 (UTC)
commit 714dac3c2320d222c00dd70f3a77c87182403d84
Author: Milan Crha <mcrha redhat com>
Date: Tue Nov 6 16:06:53 2018 +0100
I#214 - Bold meeting summary text cut in Calendar view
Closes https://gitlab.gnome.org/GNOME/evolution/issues/214
src/calendar/gui/e-day-view.c | 52 +++++++++++++++++++++++++++--------
src/calendar/gui/e-week-view.c | 62 ++++++++++++++++++++++++++++++------------
src/e-util/e-text.c | 5 ++++
3 files changed, 90 insertions(+), 29 deletions(-)
---
diff --git a/src/calendar/gui/e-day-view.c b/src/calendar/gui/e-day-view.c
index 088132b071..aaedadd79c 100644
--- a/src/calendar/gui/e-day-view.c
+++ b/src/calendar/gui/e-day-view.c
@@ -5931,6 +5931,25 @@ e_day_view_check_layout (EDayView *day_view)
}
}
+static void
+e_day_view_on_text_item_notify_text_width (GObject *etext,
+ GParamSpec *param,
+ gpointer user_data)
+{
+ EDayView *day_view = user_data;
+ gint event_num, day;
+
+ g_return_if_fail (E_IS_DAY_VIEW (day_view));
+
+ event_num = GPOINTER_TO_INT (g_object_get_data (etext, "event-num"));
+ day = GPOINTER_TO_INT (g_object_get_data (etext, "event-day"));
+
+ if (day == E_DAY_VIEW_LONG_EVENT)
+ e_day_view_reshape_long_event (day_view, event_num);
+ else
+ e_day_view_reshape_day_event (day_view, day, event_num);
+}
+
static void
e_day_view_reshape_long_events (EDayView *day_view)
{
@@ -6050,6 +6069,9 @@ e_day_view_reshape_long_event (EDayView *day_view,
g_signal_connect (
event->canvas_item, "event",
G_CALLBACK (e_day_view_on_text_item_event), day_view);
+ g_signal_connect (
+ event->canvas_item, "notify::text-width",
+ G_CALLBACK (e_day_view_on_text_item_notify_text_width), day_view);
g_signal_emit_by_name (day_view, "event_added", event);
e_day_view_update_long_event_label (day_view, event_num);
@@ -6069,18 +6091,26 @@ e_day_view_reshape_long_event (EDayView *day_view,
text_x = item_x;
text_w = item_w;
} else {
+ gdouble item_text_width = 0;
+
/* Get the requested size of the label. */
- g_object_get (event->canvas_item, "text", &text, NULL);
- text_width = 0;
- if (text) {
- end_of_line = strchr (text, '\n');
- if (end_of_line)
- line_len = end_of_line - text;
- else
- line_len = strlen (text);
- pango_layout_set_text (layout, text, line_len);
- pango_layout_get_pixel_size (layout, &text_width, NULL);
- g_free (text);
+ g_object_get (event->canvas_item, "text-width", &item_text_width, NULL);
+
+ text_width = (gint) item_text_width;
+
+ if (text_width <= 0) {
+ g_object_get (event->canvas_item, "text", &text, NULL);
+ text_width = 0;
+ if (text) {
+ end_of_line = strchr (text, '\n');
+ if (end_of_line)
+ line_len = end_of_line - text;
+ else
+ line_len = strlen (text);
+ pango_layout_set_text (layout, text, line_len);
+ pango_layout_get_pixel_size (layout, &text_width, NULL);
+ g_free (text);
+ }
}
width = text_width + icons_width;
diff --git a/src/calendar/gui/e-week-view.c b/src/calendar/gui/e-week-view.c
index 66d85b8e9b..cb1e96e464 100644
--- a/src/calendar/gui/e-week-view.c
+++ b/src/calendar/gui/e-week-view.c
@@ -3712,6 +3712,22 @@ get_comp_summary (ECalClient *client,
return summary;
}
+static void
+e_week_view_on_text_item_notify_text_width (GObject *etext,
+ GParamSpec *param,
+ gpointer user_data)
+{
+ EWeekView *week_view = user_data;
+ gint event_num = 0, span_num;
+
+ g_return_if_fail (E_IS_WEEK_VIEW (week_view));
+
+ if (!e_week_view_find_event_from_item (week_view, GNOME_CANVAS_ITEM (etext), &event_num, &span_num))
+ return;
+
+ e_week_view_reshape_event_span (week_view, event_num, span_num);
+}
+
static void
e_week_view_reshape_event_span (EWeekView *week_view,
gint event_num,
@@ -3858,6 +3874,9 @@ e_week_view_reshape_event_span (EWeekView *week_view,
g_signal_connect (
span->text_item, "event",
G_CALLBACK (e_week_view_on_text_item_event), week_view);
+ g_signal_connect (
+ span->text_item, "notify::text-width",
+ G_CALLBACK (e_week_view_on_text_item_notify_text_width), week_view);
g_signal_emit_by_name (
G_OBJECT (week_view),
"event_added", event);
@@ -3941,24 +3960,31 @@ e_week_view_reshape_event_span (EWeekView *week_view,
- E_WEEK_VIEW_EVENT_BORDER_WIDTH
- E_WEEK_VIEW_EVENT_EDGE_X_PAD - text_x;
} else {
- text = NULL;
- /* Get the width of the text of the event. This is a
- * bit of a hack. It would be better if EText could
- * tell us this. */
- g_object_get (span->text_item, "text", &text, NULL);
- text_width = 0;
- if (text) {
- /* It should only have one line of text in it.
- * I'm not sure we need this any more. */
- end_of_line = strchr (text, '\n');
- if (end_of_line)
- line_len = end_of_line - text;
- else
- line_len = strlen (text);
-
- pango_layout_set_text (layout, text, line_len);
- pango_layout_get_pixel_size (layout, &text_width, NULL);
- g_free (text);
+ gdouble item_text_width = 0.0;
+
+ g_object_get (span->text_item, "text-width", &item_text_width, NULL);
+ text_width = (gint) item_text_width;
+
+ if (text_width <= 0) {
+ text = NULL;
+ /* Get the width of the text of the event. This is a
+ * bit of a hack. It would be better if EText could
+ * tell us this. */
+ g_object_get (span->text_item, "text", &text, NULL);
+ text_width = 0;
+ if (text) {
+ /* It should only have one line of text in it.
+ * I'm not sure we need this any more. */
+ end_of_line = strchr (text, '\n');
+ if (end_of_line)
+ line_len = end_of_line - text;
+ else
+ line_len = strlen (text);
+
+ pango_layout_set_text (layout, text, line_len);
+ pango_layout_get_pixel_size (layout, &text_width, NULL);
+ g_free (text);
+ }
}
/* Add on the width of the icons and find the default
diff --git a/src/e-util/e-text.c b/src/e-util/e-text.c
index 2a5cf4ba9a..6a916327db 100644
--- a/src/e-util/e-text.c
+++ b/src/e-util/e-text.c
@@ -558,6 +558,11 @@ calc_height (EText *text)
text->height = height;
text->width = width;
+ if (old_width != text->width)
+ g_object_notify (G_OBJECT (text), "text-width");
+ if (old_height != text->height)
+ g_object_notify (G_OBJECT (text), "text-height");
+
if (old_height != text->height || old_width != text->width)
e_canvas_item_request_parent_reflow (item);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]