[Goodies-commits] r7736 - in xfce4-dict/trunk: . lib

Enrico Troeger enrico at xfce.org
Thu Jul 16 17:03:07 CEST 2009


Author: enrico
Date: 2009-07-16 15:03:07 +0000 (Thu, 16 Jul 2009)
New Revision: 7736

Modified:
   xfce4-dict/trunk/ChangeLog
   xfce4-dict/trunk/lib/speedreader.c
Log:
Display paragraph signs at the end of the current word group.

Modified: xfce4-dict/trunk/ChangeLog
===================================================================
--- xfce4-dict/trunk/ChangeLog	2009-07-16 15:03:06 UTC (rev 7735)
+++ xfce4-dict/trunk/ChangeLog	2009-07-16 15:03:07 UTC (rev 7736)
@@ -3,6 +3,8 @@
  * lib/spell.c:
    Don't print the spell check header if in quiet mode and the word
    is spelled correctly.
+ * lib/speedreader.c:
+   Display paragraph signs at the end of the current word group.
 
 
 2009-07-09  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: xfce4-dict/trunk/lib/speedreader.c
===================================================================
--- xfce4-dict/trunk/lib/speedreader.c	2009-07-16 15:03:06 UTC (rev 7735)
+++ xfce4-dict/trunk/lib/speedreader.c	2009-07-16 15:03:07 UTC (rev 7736)
@@ -50,8 +50,8 @@
 	GtkTextBuffer *buffer;
 
 	guint timer_id;
-	gint word_idx;
-	gint words_len;
+	guint word_idx;
+	gsize words_len;
 	gchar **words;
 
 	GString *group;
@@ -265,6 +265,16 @@
 }
 
 
+static void sr_set_label_text(XfdSpeedReader *dialog)
+{
+	XfdSpeedReaderPrivate *priv = XFD_SPEED_READER_GET_PRIVATE(dialog);
+	
+	if (NZV(priv->group->str))
+		gtk_label_set_text(GTK_LABEL(priv->display_label), priv->group->str);
+	g_string_erase(priv->group, 0, -1);
+}
+
+
 static gboolean sr_timer(gpointer data)
 {
 	XfdSpeedReaderPrivate *priv = XFD_SPEED_READER_GET_PRIVATE(data);
@@ -285,16 +295,33 @@
 
 		if (priv->word_idx < priv->words_len)
 		{
-			g_string_append(priv->group, priv->words[priv->word_idx]);
-			if (i < (priv->group_size - 1))
-				g_string_append_c(priv->group, ' ');
+			if (g_utf8_get_char(priv->words[priv->word_idx]) == 182)
+			{	/* paragraph sign inside the group */
+				g_string_append_unichar(priv->group, 182);
+				sr_set_label_text(data);
+				priv->word_idx++;
+				return TRUE;				
+			}
+			if ((priv->word_idx + 1) < priv->words_len &&
+				g_utf8_get_char(priv->words[priv->word_idx + 1]) == 182)
+			{	/* paragraph sign in the next group, so move it to this group */
+				g_string_append(priv->group, priv->words[priv->word_idx]);
+				g_string_append_unichar(priv->group, 182);
+				sr_set_label_text(data);
+				priv->word_idx += 2;
+				return TRUE;				
+			}
+			else
+			{
+				g_string_append(priv->group, priv->words[priv->word_idx]);
+				if (i < (priv->group_size - 1))
+					g_string_append_c(priv->group, ' ');
+			}
 		}
 		priv->word_idx++;
 	}
-	if (NZV(priv->group->str))
-		gtk_label_set_text(GTK_LABEL(priv->display_label), priv->group->str);
-	g_string_erase(priv->group, 0, -1);
-
+	sr_set_label_text(data);
+	
 	return TRUE;
 }
 




More information about the Goodies-commits mailing list