[dates] Truncate task summary when confirming deletion
- From: Ross Burton <rburton src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [dates] Truncate task summary when confirming deletion
- Date: Wed, 29 Jul 2009 14:16:03 +0000 (UTC)
commit 569dc650a64d32338c6db6c5c1b071ff8cf8552a
Author: Ross Burton <ross linux intel com>
Date: Wed Jul 29 15:15:14 2009 +0100
Truncate task summary when confirming deletion
src/dates_callbacks.c | 51 +++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 45 insertions(+), 6 deletions(-)
---
diff --git a/src/dates_callbacks.c b/src/dates_callbacks.c
index 6a8fce3..4979371 100644
--- a/src/dates_callbacks.c
+++ b/src/dates_callbacks.c
@@ -1052,12 +1052,48 @@ dates_details_ok_cb (GtkWidget *source, DatesData *d)
}
}
+static char *
+str_truncate (const char *long_str, guint max_length)
+{
+ char *p;
+ char *p_end;
+ const char *ellipsis_text;
+
+ if (max_length == 0)
+ return NULL;
+
+ if (!g_utf8_validate (long_str, -1, NULL))
+ return NULL;
+
+ p = g_strdup (long_str);
+
+ if (g_utf8_strlen (p, -1) < max_length)
+ return p;
+
+ /* 3 characters so that we definitely have space for ellipsis */
+ p_end = g_utf8_offset_to_pointer (p, max_length - 3);
+
+ /* Write an ellipsis */
+ if (g_unichar_iswide (g_utf8_get_char (p)))
+ ellipsis_text = "\342\213\257"; /* U+22EF: MIDLINE HORIZONTAL ELLIPSIS, used for CJK */
+ else
+ ellipsis_text = "\342\200\246"; /* U+2026: HORIZONTAL ELLIPSIS */
+ g_utf8_strncpy (p_end, ellipsis_text, 1);
+
+ /* Terminate the string */
+ p_end = g_utf8_next_char (p_end);
+ *p_end = '\0';
+
+ return p;
+}
+
void
dates_delete_cb (GtkWidget *source, DatesData *d)
{
ECalComponentText summary;
GtkWidget *widget;
- const char *value;
+ const char *orig_value;
+ char *value;
#ifdef WITH_HILDON
gchar *tmp;
#endif
@@ -1065,16 +1101,18 @@ dates_delete_cb (GtkWidget *source, DatesData *d)
e_cal_component_get_summary (d->comp, &summary);
widget = d->details_dialog;
if (GTK_WIDGET_VISIBLE (widget))
- value = gtk_entry_get_text (GTK_ENTRY (d->details_summary_entry));
+ orig_value = gtk_entry_get_text (GTK_ENTRY (d->details_summary_entry));
else if (summary.value)
- value = summary.value;
+ orig_value = summary.value;
else if (summary.altrep)
- value = summary.altrep;
+ orig_value = summary.altrep;
else {
g_warning ("Deleting event with no summary");
- value = _("Unknown event");
+ orig_value = _("Unknown event");
}
-
+
+ value = str_truncate (orig_value, 50);
+
#ifdef WITH_HILDON
tmp = g_strdup_printf(_("Are you sure you want to delete event '%s'?"), value);
widget = hildon_note_new_confirmation_add_buttons(
@@ -1118,6 +1156,7 @@ dates_delete_cb (GtkWidget *source, DatesData *d)
}
gtk_widget_destroy (widget);
+ g_free (value);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]