Author: rpmcruz
Date: Tue Jun 10 00:45:56 2008
New Revision: 48183
URL: http://svn.opensuse.org/viewcvs/yast?rev=48183&view=rev
Log:
* src/ygtkrichtext.c: bug fix 396692: glitches with breaklines
and spaces around inline tags.
* src/ygtktimezonepicker.c: found g_strstrip: use instead of
internal.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGUtils.cc
trunk/gtk/src/ygtkrichtext.c
trunk/gtk/src/ygtktimezonepicker.c
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=48183&r1=48182&r2=48183&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Tue Jun 10 00:45:56 2008
@@ -1,3 +1,11 @@
+2008-06-09 Ricardo Cruz
+
+ * src/ygtkrichtext.c: bug fix 396692: glitches with breaklines
+ and spaces around inline tags.
+
+ * src/ygtktimezonepicker.c: found g_strstrip: use instead of
+ internal.
+
2008-06-08 Ricardo Cruz
* src/ygtkrichtext.h/c: bug fix 393143: cursor ownership was
Modified: trunk/gtk/src/YGUtils.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUtils.cc?rev=48183&r1=48182&r2=48183&view=diff
==============================================================================
--- trunk/gtk/src/YGUtils.cc (original)
+++ trunk/gtk/src/YGUtils.cc Tue Jun 10 00:45:56 2008
@@ -264,11 +264,8 @@
skipSpace (instr, i);
- // We must add an outer tag to make GMarkup happy
- gboolean addOuterTag = TRUE;
-// gboolean addOuterTag = FALSE;
-// if ((addOuterTag = (instr[i] != '<')))
- g_string_append (outp, "<body>");
+ // we must add an outer tag to make GMarkup happy
+ g_string_append (outp, "<body>");
for (; instr[i] != '\0'; i++)
{
@@ -374,26 +371,13 @@
i += sizeof (" ") - 2;
}
-#if 0
- // removing new-lines chars sure isn't a xhtml conversion
- // but it's still valid xhtml and GtkTextView appreciates it
- else if (/*cut_breaklines &&*/ instr[i] == '\n') {
- // In HTML a breakline should be treated as a white space when
- // not in the start of a paragraph.
- if (i > 0 && instr[i-1] != '>' && !g_ascii_isspace (instr[i-1]))
- g_string_append_c (outp, ' ');
- }
-#endif
-
else // Normal text
g_string_append_c (outp, instr[i]);
}
emit_unclosed_tags_for (outp, tag_queue, "", 0);
g_queue_free (tag_queue);
-
- if (addOuterTag)
- g_string_append (outp, "</body>");
+ g_string_append (outp, "</body>");
gchar *ret = g_string_free (outp, FALSE);
return ret;
Modified: trunk/gtk/src/ygtkrichtext.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkrichtext.c?rev=48183&r1=48182&r2=48183&view=diff
==============================================================================
--- trunk/gtk/src/ygtkrichtext.c (original)
+++ trunk/gtk/src/ygtkrichtext.c Tue Jun 10 00:45:56 2008
@@ -234,6 +234,7 @@
gboolean default_color;
int left_margin;
GList *html_list; // of HTMLList
+ gboolean closed_block_tag;
} GRTParseState;
static void GRTParseState_init (GRTParseState *state, GtkTextBuffer *buffer)
@@ -245,6 +246,7 @@
state->tags = gtk_text_buffer_get_tag_table (buffer);
state->html_list = NULL;
state->htags = NULL;
+ state->closed_block_tag = FALSE;
}
static void free_list (GList *list)
@@ -262,7 +264,7 @@
free_list (state->htags);
}
-static char *elide_whitespace (const char *instr, int len);
+static gchar *elide_whitespace (const gchar *instr, gint len);
// Tags to support: <p> and not </p>:
// either 'elide' \ns (turn off with <pre> I guess
@@ -289,12 +291,12 @@
// Check if this is a block tag
if (isBlockTag (element_name)) {
// make sure this opens a new paragraph
- if (!gtk_text_iter_starts_line (&iter))
- {
+ if (!gtk_text_iter_starts_line (&iter)) {
gtk_text_buffer_insert (state->buffer, &iter, "\n", -1);
gtk_text_buffer_get_end_iter (state->buffer, &iter);
}
}
+ state->closed_block_tag = FALSE;
char *lower = g_ascii_strdown (element_name, -1);
tag->tag = gtk_text_tag_table_lookup (state->tags, lower);
@@ -430,27 +432,15 @@
else if (!g_ascii_strcasecmp (element_name, "font"))
state->default_color = TRUE;
- else if (!g_ascii_strcasecmp (element_name, "pre")) {
+ else if (!g_ascii_strcasecmp (element_name, "pre"))
state->pre_mode = FALSE;
-/*
- // \n must be inserted as <br>
- char *txt = gtk_text_buffer_get_text (state->buffer,
- &start, &end, TRUE);
- char endc = txt ? txt[strlen(txt) - 1] : '\0';
- appendLines = (endc != '\r' && endc != '\n') ? 1 : 0;
- g_free (txt);*/
- }
- else if (!g_ascii_strcasecmp (element_name, "br"))
+ if (isBlockTag (element_name) || !g_ascii_strcasecmp (element_name, "br")) {
appendLines = 1;
-
- if (isBlockTag (element_name))
- {
-// appendLines = 2;
-// if (!g_ascii_strcasecmp (element_name, "li"))
- appendLines = 1;
+ state->closed_block_tag = TRUE;
}
-
+ else
+ state->closed_block_tag = FALSE;
if (appendLines) {
gtk_text_buffer_insert (state->buffer, &end,
@@ -480,9 +470,14 @@
gtk_text_buffer_insert_with_tags (state->buffer, &start,
text, text_len, NULL, NULL);
else {
- char *real = elide_whitespace (text, text_len);
- gtk_text_buffer_insert_with_tags (state->buffer, &start,
- real, -1, NULL, NULL);
+ if (!state->closed_block_tag) {
+ if (g_ascii_isspace (text[0]))
+ gtk_text_buffer_insert (state->buffer, &start, " ", 1);
+ }
+ state->closed_block_tag = FALSE;
+
+ gchar *real = elide_whitespace (text, text_len);
+ gtk_text_buffer_insert (state->buffer, &start, real, -1);
g_free (real);
}
gtk_text_buffer_get_end_iter (state->buffer, &end);
@@ -519,39 +514,27 @@
}
/* String preparation methods. */
-static char *elide_whitespace (const char *instr, int len)
+static gchar *elide_whitespace (const gchar *instr, gint len)
{
GString *dest = g_string_new ("");
if (len < 0)
len = strlen (instr);
- gboolean last_white = FALSE;
- // transform breaklines in whitespace if in the middle of the text
- gboolean special_white = FALSE, start_text = TRUE;
- int i;
- for (i = 0; i < len; i++)
- {
- char ch = instr[i];
- if (ch == '\n') {
- if (!start_text)
- special_white = TRUE;
- continue;
- }
- if (ch == '\t')
- ch = ' ';
- gboolean cur_white = ch == ' ';
- if (!cur_white) {
- start_text = FALSE;
- if (special_white) {
+ // collapse more than one space in one
+ gboolean start_text = TRUE, is_white = FALSE;
+ gint i;
+ for (i = 0; i < len; i++) {
+ gchar ch = instr[i];
+ if (g_ascii_isspace (ch)) {
+ if (!is_white && !start_text)
g_string_append_c (dest, ' ');
- special_white = FALSE;
- }
+ is_white = TRUE;
}
- if (!cur_white || !last_white)
+ else {
g_string_append_c (dest, ch);
-
- last_white = cur_white;
+ is_white = FALSE;
+ start_text = FALSE;
+ }
}
-
return g_string_free (dest, FALSE);
}
Modified: trunk/gtk/src/ygtktimezonepicker.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtktimezonepicker.c?rev=48183&r1=48182&r2=48183&view=diff
==============================================================================
--- trunk/gtk/src/ygtktimezonepicker.c (original)
+++ trunk/gtk/src/ygtktimezonepicker.c Tue Jun 10 00:45:56 2008
@@ -15,16 +15,6 @@
// General utilities
-static char *trim_string (const char *str)
-{
- char *ret;
- int i, j;
- for (i = 0; str[i] && g_ascii_isspace (str[i]); i++) ;
- for (j = strlen (str)-1; j > 0 && g_ascii_isspace (str[j]); j--) ;
- ret = g_strndup (str+i, j-i+1);
- return ret;
-}
-
static char *substring (const char *str, int start, int end)
{
if (end == -1)
@@ -189,7 +179,7 @@
while (fgets (buf, sizeof (buf), tzfile)) {
if (*buf == '#') continue;
- char *trim = trim_string (buf);
+ gchar *trim = g_strstrip (buf);
gchar **arr = g_strsplit (trim, "\t", -1);
g_free (trim);
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org