Author: rpmcruz
Date: Wed Nov 5 00:51:22 2008
New Revision: 52902
URL: http://svn.opensuse.org/viewcvs/yast?rev=52902&view=rev
Log:
* src/ygtkrichtext.c: moved to a generic entity lookup function.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/ygtkrichtext.c
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=52902&r1=52901&r2=52902&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Wed Nov 5 00:51:22 2008
@@ -3,6 +3,8 @@
* src/yzyppwrapper.cc: bug fix 441143: use candidate object as the
newest version -- just looking at the numbers ignores the arch.
+ * src/ygtkrichtext.c: moved to a generic entity lookup function.
+
2008-11-02 Ricardo Cruz
* src/YGProgressBar.cc: got rid of ygtkprogressbar.
Modified: trunk/gtk/src/ygtkrichtext.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkrichtext.c?rev=52902&r1=52901&r2=52902&view=diff
==============================================================================
--- trunk/gtk/src/ygtkrichtext.c (original)
+++ trunk/gtk/src/ygtkrichtext.c Wed Nov 5 00:51:22 2008
@@ -101,6 +101,24 @@
return TRUE;
}
+/* Some entities are translated by the xhtml parser, but not all... */
+typedef struct EntityMap {
+ const gchar *html, *text;
+} EntityMap;
+
+static const EntityMap entities[] = {
+ { "nbsp", " " },
+};
+
+static const EntityMap *lookup_entity (const char *html)
+{
+ int i;
+ for (i = 0; i < sizeof (entities) / sizeof (EntityMap); i++)
+ if (!g_ascii_strncasecmp (html+1, entities[i].html, strlen (entities[i].html)))
+ return entities+i;
+ return NULL;
+}
+
// We have to:
// + rewrite <br> and <hr> tags
// + deal with <a attrib=noquotes>
@@ -225,13 +243,15 @@
g_string_free (tag, TRUE);
}
- // non-break space entity
- else if (instr[i] == '&' &&
- !g_ascii_strncasecmp (instr + i, " ",
- sizeof (" ") - 1)) {
- // Replace this by a white-space
- g_string_append (outp, " ");
- i += sizeof (" ") - 2;
+ else if (instr[i] == '&') { // Entity
+ const EntityMap *entity = lookup_entity (instr+i);
+ if (entity) {
+ g_string_append (outp, entity->text);
+ i += strlen (entity->html);
+ if (instr[i+1] == ';') i++;
+ }
+ else
+ g_string_append_c (outp, instr[i]);
was_space = FALSE;
}
@@ -501,7 +521,7 @@
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_SELECT_ALL, NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
g_signal_connect (item, "activate", G_CALLBACK (select_all_activate_cb), buffer);
- gtk_widget_show_all (menu);
+ gtk_widget_show_all (GTK_WIDGET (menu));
}
/* Rich Text parsing methods. */
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org