[gthumb] ellipsize the metadata in the file list if too long



commit 741ee4b799184b186f7250c8516469d2b1f2230c
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Jan 5 20:07:31 2011 +0100

    ellipsize the metadata in the file list if too long

 gthumb/gth-file-list.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/gthumb/gth-file-list.c b/gthumb/gth-file-list.c
index 293d238..0f5cf77 100644
--- a/gthumb/gth-file-list.c
+++ b/gthumb/gth-file-list.c
@@ -944,6 +944,9 @@ _gth_file_list_update_pane (GthFileList *file_list)
 }
 
 
+#define MAX_TEXT_LENGTH 70
+
+
 static GString *
 _gth_file_list_get_metadata (GthFileList *file_list,
 			     GthFileData *file_data)
@@ -951,16 +954,26 @@ _gth_file_list_get_metadata (GthFileList *file_list,
 	GString *metadata;
 	int      i;
 
-	metadata = g_string_new ("");
+	metadata = g_string_new (NULL);
 	for (i = 0; file_list->priv->caption_attributes_v[i] != NULL; i++) {
 		char *value;
 
 		value = gth_file_data_get_attribute_as_string (file_data, file_list->priv->caption_attributes_v[i]);
-		if (value == NULL)
-			value = g_strdup ("-");
-		if (metadata->len > 0)
-			g_string_append (metadata, "\n");
-		g_string_append (metadata, value);
+		if (value != NULL) {
+			if (metadata->len > 0)
+				g_string_append (metadata, "\n");
+			if (g_utf8_strlen (value, -1) > MAX_TEXT_LENGTH) {
+				char *tmp;
+
+				tmp = g_strdup (value);
+				g_utf8_strncpy (tmp, value, MAX_TEXT_LENGTH);
+				g_free (value);
+				value = g_strdup_printf ("%s [â?¦]", tmp);
+
+				g_free (tmp);
+			}
+			g_string_append (metadata, value);
+		}
 
 		g_free (value);
 	}



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