[gnome-font-viewer] font-view: strip empty lines when they're the last line
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-font-viewer] font-view: strip empty lines when they're the last line
- Date: Tue, 1 May 2012 15:13:11 +0000 (UTC)
commit f51507cd1c5bdd325d3ac60a4fdfaeb27b44960c
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue May 1 10:48:13 2012 -0400
font-view: strip empty lines when they're the last line
src/font-view.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/font-view.c b/src/font-view.c
index d7d23b1..13f8fa8 100644
--- a/src/font-view.c
+++ b/src/font-view.c
@@ -96,7 +96,7 @@ static const gchar *app_menu =
#define WHITESPACE_CHARS "\f \t"
static void
-strip_whitespace (gchar **copyright)
+strip_whitespace (gchar **original)
{
GString *reassembled;
gchar **split;
@@ -104,7 +104,7 @@ strip_whitespace (gchar **copyright)
gint idx, n_stripped;
size_t len;
- split = g_strsplit (*copyright, "\n", -1);
+ split = g_strsplit (*original, "\n", -1);
reassembled = g_string_new (NULL);
n_stripped = 0;
@@ -115,15 +115,19 @@ strip_whitespace (gchar **copyright)
if (len)
str += len;
+ if (strlen (str) == 0 &&
+ ((split[idx + 1] == NULL) || strlen (split[idx + 1]) == 0))
+ continue;
+
if (n_stripped++ > 0)
g_string_append (reassembled, "\n");
g_string_append (reassembled, str);
}
g_strfreev (split);
- g_free (*copyright);
+ g_free (*original);
- *copyright = g_string_free (reassembled, FALSE);
+ *original = g_string_free (reassembled, FALSE);
}
static void
@@ -228,11 +232,12 @@ populate_grid (FontViewApplication *self,
}
if (copyright) {
strip_whitespace (©right);
- add_row (grid, _("Copyright"), copyright, TRUE);
+ add_row (grid, _("Copyright"), copyright, TRUE);
g_free (copyright);
}
if (description) {
- add_row (grid, _("Description"), description, TRUE);
+ strip_whitespace (&description);
+ add_row (grid, _("Description"), description, TRUE);
g_free (description);
}
} else if (FT_Get_PS_Font_Info (face, &ps_info) == 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]