Author: rpmcruz
Date: Tue Oct 16 16:47:05 2007
New Revision: 41442
URL: http://svn.opensuse.org/viewcvs/yast?rev=41442&view=rev
Log:
* src/ygtkhtmlwrapper.h/c (added): to be used instead of YGtkRichText directly.
At the moment, it wraps YGtkRichText and GtkHTML, YGtkRichText being the
one used (for now, at least).
* src/YGUtils.cc: fixed a small memory leak when a html comment, and
disabled the removal of whitespaces (as needed by <pre>).
* src/ygtkrichtext.c: moved block and block&ident tags to common code.
For block tags, I am simply using two break lines, instead of spacing.
This could still use more polishing...
* src/YGRichText.cc: removed, moved to YGMultiLineEdit.cc, made the factory
constructing another object for plainText.
* configure.in.in: added GtkHtml check (uncommented as I dunno how to
make it optional; and either way, needs to be discussed what we want here).
Modified:
trunk/gtk/ChangeLog
trunk/gtk/configure.in.in
trunk/gtk/src/Makefile.am
trunk/gtk/src/YGMultiLineEdit.cc
trunk/gtk/src/YGPackageSelector.cc
trunk/gtk/src/YGRichText.cc
trunk/gtk/src/YGUtils.cc
trunk/gtk/src/YGUtils.h
trunk/gtk/src/ygtkrichtext.c
trunk/gtk/src/ygtkrichtext.h
trunk/gtk/src/ygtkwizard.c
trunk/gtk/tests/RichText2.ycp
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=41442&r1=41441&r2=41442&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Tue Oct 16 16:47:05 2007
@@ -1,9 +1,41 @@
+2007-10-16 Ricardo Cruz
+
+ * src/ygtkhtmlwrapper.h/c (added): to be used instead of YGtkRichText directly.
+ At the moment, it wraps YGtkRichText and GtkHTML, YGtkRichText being the
+ one used (for now, at least).
+
+ * src/YGUtils.cc: fixed a small memory leak when a html comment, and
+ disabled the removal of whitespaces (as needed by <pre>).
+ * src/ygtkrichtext.c: moved block and block&ident tags to common code.
+ For block tags, I am simply using two break lines, instead of spacing.
+ This could still use more polishing...
+
+ * src/YGRichText.cc: removed, moved to YGMultiLineEdit.cc, made the factory
+ constructing another object for plainText.
+
+ * configure.in.in: added GtkHtml check (uncommented as I dunno how to
+ make it optional; and either way, needs to be discussed what we want here).
+
2007-10-12 Ricardo Cruz
* src/ygdkmngloader.h/c / src/YGImage.cc: added support for inline MNG
images. Fixed ticks per second.
* tests/YGImage.ycp: added a bunch of MNGs I found...
+ * src/ygtkhtmltext.h/c: added wrapper around our YGtkRichText and GtkHtml.
+ -> Automake stuff needs works (it will just error if GtkHtml is not found...)
+ * src/YGRichText.cc & src/YGPackageSelector.cc: bug fix #326207: use
+ ygtkhtmltext code.
+
+ Doing our own renderer was fun, but it won't ever support tables, and still
+ has some corner cases where GMarkup complains, and inline/blocks tags are
+ problematic at times. And I already saw comments of people doing tables and
+ using HTML extensively on yast (like for a startup screen).
+ With a wrapper we can easily port the code to another HTML widget out there,
+ until gtk+ adopts one into the API. GtkHTML API is a bit sucky, but its
+ used by Evolution (including on the composer), so its robust, and it seems
+ fairly slim (certainely when compared to mozdev :P).
+
2007-10-11 Ricardo Cruz
* src/YGPackageSelector.cc: speed up Patterns view.
Modified: trunk/gtk/configure.in.in
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/configure.in.in?rev=41442&r1=41441&r2=41442&view=diff
==============================================================================
--- trunk/gtk/configure.in.in (original)
+++ trunk/gtk/configure.in.in Tue Oct 16 16:47:05 2007
@@ -47,6 +47,17 @@
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
+# TODO: we may want to check if GtkHtml is installed and set its flag
+#dnl Check if GtkHtml is installed
+#AC_MSG_CHECKING([for gtkhtml])
+#PKG_CHECK_MODULES( GTKHTML, libgtkhtml-3.14 )
+#AC_SUBST(GTKHTML_CFLAGS)
+#AC_SUBST(GTKHTML_LIBS)
+#AC_DEFINE(USE_GTKHTML, 1, [will use GtkHtml as the HTML renderer])
+
+PKG_CHECK_MODULES( ZYPP, libzypp )
+AC_SUBST(ZYPP_LIBS)
+
verstxt=`pkg-config --modversion yast2-core`
yast_vers=`echo "$verstxt" | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
AC_DEFINE_UNQUOTED(YAST2_VERSION, $yast_vers, [yast version for compile conditionals])
Modified: trunk/gtk/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/Makefile.am?rev=41442&r1=41441&r2=41442&view=diff
==============================================================================
--- trunk/gtk/src/Makefile.am (original)
+++ trunk/gtk/src/Makefile.am Tue Oct 16 16:47:05 2007
@@ -13,7 +13,8 @@
plugin_LTLIBRARIES = libpy2gtk.la
libpy2gtk_la_LDFLAGS = -version-info 2:0
-libpy2gtk_la_LIBADD = -L$(plugindir) $(PYUI_LIBS) -L$(libdir) -lycp -ly2 $(GTK_LIBS) $(ZYPP_LIBS)
+libpy2gtk_la_LIBADD = -L$(plugindir) $(PYUI_LIBS) -L$(libdir) -lycp -ly2 \
+ $(GTK_LIBS) $(ZYPP_LIBS) $(GTKHTML_LIBS)
libpy2gtk_la_SOURCES = \
Y2CCGtk.cc \
YGUtils.cc \
@@ -26,7 +27,6 @@
YGProgressBar.cc \
YGTextEntry.cc \
YGMultiLineEdit.cc \
- YGRichText.cc \
YGIntField.cc \
YGRadioButton.cc \
YGImage.cc \
@@ -42,14 +42,16 @@
YGPackageSelector.cc \
ygtkratiobox.c \
ygtkbargraph.c \
- ygtkrichtext.c \
ygtksteps.c \
ygtkfieldentry.c \
ygtkmenubutton.c \
ygtkwizard.c \
ygtkcellrendererarrow.c \
ygtkfindentry.c \
- ygdkmngloader.c
+ ygdkmngloader.c \
+ ygtkhtmlwrap.c \
+ ygtkrichtext.c
+# should only append ygtkrichtext.c if USE_GTKHTML is set
dummy_SOURCES = dummy.cc
dummy_LDADD = libpy2gtk.la
@@ -62,4 +64,5 @@
INCLUDES = -I$(srcdir)/include -I$(includedir) -I$(includedir)/yui $(ZYPP_CFLAGS)
-EXTRA_DIST = computer.xpm
+EXTRA_DIST =
+
Modified: trunk/gtk/src/YGMultiLineEdit.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGMultiLineEdit.cc?rev=41442&r1=41441&r2=41442&view=diff
==============================================================================
--- trunk/gtk/src/YGMultiLineEdit.cc (original)
+++ trunk/gtk/src/YGMultiLineEdit.cc Tue Oct 16 16:47:05 2007
@@ -15,7 +15,7 @@
public:
YGTextView (YWidget *y_widget, YGWidget *parent, const YWidgetOpt &opt,
- const YCPString &label, const YCPString &text)
+ const YCPString &label, const YCPString &text, bool editable)
: YGScrolledWidget (y_widget, parent, label, YD_VERT, true,
GTK_TYPE_TEXT_VIEW, "wrap-mode", GTK_WRAP_WORD, NULL)
{
@@ -27,12 +27,16 @@
maxChars = -1;
setText (text);
+ if (!editable)
+ {
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (getWidget()), FALSE);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (getWidget()), FALSE);
+ }
+
g_signal_connect (G_OBJECT (getBuffer()), "changed",
G_CALLBACK (text_changed_cb), this);
}
- virtual ~YGTextView() {}
-
GtkTextBuffer* getBuffer()
{ return gtk_text_view_get_buffer (GTK_TEXT_VIEW (getWidget())); }
@@ -80,6 +84,11 @@
return str;
}
+ void scrollToBottom()
+ {
+ YGUtils::scrollTextViewDown (GTK_TEXT_VIEW (getWidget()));
+ }
+
// Event callbacks
static void text_changed_cb (GtkTextBuffer *buffer, YGTextView *pThis)
{
@@ -99,11 +108,9 @@
YGMultiLineEdit (const YWidgetOpt &opt, YGWidget *parent,
const YCPString &label, const YCPString &text)
: YMultiLineEdit (opt, label)
- , YGTextView (this, parent, opt, label, text)
+ , YGTextView (this, parent, opt, label, text, true)
{ }
- virtual ~YGMultiLineEdit() {}
-
// YMultiLineEdit
virtual void setText (const YCPString &text)
{ YGTextView::setText (text); }
@@ -133,20 +140,16 @@
YGLogView (const YWidgetOpt &opt, YGWidget *parent,
const YCPString &label, int visibleLines, int maxLines)
: YLogView (opt, label, visibleLines, maxLines)
- , YGTextView (this, parent, opt, label, YCPString(""))
+ , YGTextView (this, parent, opt, label, YCPString(""), false)
{
setMinSizeInChars (0, visibleLines);
- gtk_text_view_set_editable (GTK_TEXT_VIEW (getWidget()), FALSE);
- gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (getWidget()), FALSE);
}
- virtual ~YGLogView() {}
-
// YLogView
virtual void setLogText (const YCPString &text)
{
setText (text);
- YGUtils::scrollTextViewDown (GTK_TEXT_VIEW (getWidget()));
+ scrollToBottom();
}
YGWIDGET_IMPL_COMMON
@@ -161,3 +164,84 @@
return new YGLogView (opt, YGWidget::get (parent),
label, visibleLines, maxLines);
}
+
+#include "YRichText.h"
+
+class YGPlainText : public YRichText, public YGTextView
+{
+bool m_autoScrollDown;
+
+public:
+ YGPlainText(const YWidgetOpt &opt, YGWidget *parent, const YCPString &text)
+ : YRichText (opt, text)
+ , YGTextView (this, parent, opt, YCPString(""), text, false)
+ {
+ IMPL
+ m_autoScrollDown = opt.autoScrollDown.value();
+ }
+
+ // YRichText
+ virtual void setText (const YCPString &text)
+ {
+ IMPL
+ YGTextView::setText (text);
+ if (m_autoScrollDown)
+ scrollToBottom();
+ YRichText::setText (text);
+ }
+
+ YGWIDGET_IMPL_COMMON
+};
+
+#include "ygtkhtmlwrap.h"
+
+class YGRichText : public YRichText, public YGScrolledWidget
+{
+bool m_autoScrollDown;
+
+public:
+ YGRichText(const YWidgetOpt &opt, YGWidget *parent, const YCPString &text)
+ : YRichText (opt, text)
+ , YGScrolledWidget (this, parent, true, ygtk_html_wrap_get_type(), NULL)
+ {
+ IMPL
+ if (!opt.isShrinkable.value())
+ setMinSizeInChars (20, 8);
+ m_autoScrollDown = opt.autoScrollDown.value();
+
+ ygtk_html_wrap_init (getWidget());
+ ygtk_html_wrap_connect_link_clicked (getWidget(), G_CALLBACK (link_clicked_cb), this);
+
+ setText (text);
+ }
+
+ // YRichText
+ virtual void setText (const YCPString &_text)
+ {
+ IMPL
+ string text (_text->value());
+ YGUtils::replace (text, "&product;", 9, YUI::ui()->productName().c_str());
+
+ ygtk_html_wrap_set_text (getWidget(), text.c_str());
+ if (m_autoScrollDown)
+ ygtk_html_wrap_scroll (getWidget(), FALSE);
+ YRichText::setText (_text);
+ }
+
+ static void link_clicked_cb (GtkWidget *widget, const char *url, YGRichText *pThis)
+ {
+ YGUI::ui()->sendEvent (new YMenuEvent (YCPString (url)));
+ }
+
+ YGWIDGET_IMPL_COMMON
+};
+
+YWidget *
+YGUI::createRichText (YWidget *parent, YWidgetOpt &opt, const YCPString &text)
+{
+ if (opt.plainTextMode.value())
+ return new YGPlainText (opt, YGWidget::get (parent), text);
+ else
+ return new YGRichText (opt, YGWidget::get (parent), text);
+}
+
Modified: trunk/gtk/src/YGPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=41442&r1=41441&r2=41442&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelector.cc (original)
+++ trunk/gtk/src/YGPackageSelector.cc Tue Oct 16 16:47:05 2007
@@ -13,7 +13,7 @@
#include "YGi18n.h"
#include "YGDialog.h"
#include "YPackageSelector.h"
-#include "ygtkrichtext.h"
+#include "ygtkhtmlwrap.h"
#include "ygtkwizard.h"
#include "ygtkcellrendererarrow.h"
#include "ygtkratiobox.h"
@@ -44,7 +44,7 @@
/* We should consider linking to libgnome and use gnome_url_show(url) here,
or at least do some path finding. */
-#define FILEMANAGER_EXEC "/opt/gnome/bin/nautilus"
+#define FILEMANAGER_EXEC "/usr/bin/nautilus"
inline bool FILEMANAGER_PRESENT()
{ return g_file_test (FILEMANAGER_EXEC, G_FILE_TEST_IS_EXECUTABLE); }
inline void FILEMANAGER_LAUNCH (const char *path)
@@ -103,15 +103,9 @@
_("_Reject"), GTK_RESPONSE_REJECT, _("_Accept"), GTK_RESPONSE_ACCEPT, NULL);
GtkWidget *license_view, *license_window;
-#ifdef PLAIN_TEXT
- GtkTextBuffer *buffer = gtk_text_buffer_new (NULL);
- gtk_text_buffer_set_text (buffer, license.c_str(), -1);
- license_view = gtk_text_view_new_with_buffer (buffer);
-#else
- /* FIXME: can we detect rich text vs. non - does it matter ? */
- license_view = ygtk_richtext_new();
- ygtk_richtext_set_text (YGTK_RICHTEXT (license_view), license.c_str(), true);
-#endif
+
+ license_view = ygtk_html_wrap_new();
+ ygtk_html_wrap_set_text (license_view, license.c_str());
license_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (license_window),
@@ -351,7 +345,7 @@
{
GtkWidget *m_widget, *m_notebook;
// Information text
- GtkWidget *m_about_text, *m_authors_text, *m_filelist_text, *m_history_text;
+ GtkWidget *m_about_text, *m_authors_text, *m_filelist_text, *m_changelog_text;
bool m_use_filemanager;
public:
@@ -364,10 +358,10 @@
GtkWidget *about_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (about_win),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
- m_about_text = gtk_text_view_new();
+ m_about_text = ygtk_html_wrap_new();
gtk_container_add (GTK_CONTAINER (about_win), m_about_text);
gtk_container_add (GTK_CONTAINER (m_widget), about_win);
- m_authors_text = m_filelist_text = m_history_text = NULL;
+ m_authors_text = m_filelist_text = m_changelog_text = NULL;
m_notebook = NULL;
}
else {
@@ -378,9 +372,9 @@
m_about_text = add_text_tab (m_notebook, _("Description"));
m_filelist_text = add_text_tab (m_notebook, _("File List"));
if ((m_use_filemanager = FILEMANAGER_PRESENT()))
- g_signal_connect (G_OBJECT (m_filelist_text), "link-pressed",
- G_CALLBACK (dir_pressed_cb), NULL);
- m_history_text = add_text_tab (m_notebook, _("History"));
+ ygtk_html_wrap_connect_link_clicked (m_filelist_text,
+ G_CALLBACK (dir_pressed_cb), NULL);
+ m_changelog_text = add_text_tab (m_notebook, _("Change Log"));
m_authors_text = add_text_tab (m_notebook, _("Authors"));
}
gtk_widget_set_size_request (gtk_bin_get_child (GTK_BIN (m_widget)),
@@ -397,8 +391,8 @@
set_text (m_about_text, "");
if (m_filelist_text)
set_text (m_filelist_text, "");
- if (m_history_text)
- set_text (m_history_text, "");
+ if (m_changelog_text)
+ set_text (m_changelog_text, "");
if (m_authors_text)
set_text (m_authors_text, "");
gtk_expander_set_expanded (GTK_EXPANDER (m_widget), FALSE);
@@ -414,15 +408,13 @@
ZyppPackage package = tryCastToZyppPkg (object);
if (m_about_text) {
- string description = YGUtils::escape_markup (object->description());
+ string description = YGUtils::escape_markup (object->description(), true);
// cut authors, since they have their own section
string::size_type pos = description.find ("Authors:");
if (pos != string::npos)
description.erase (pos, string::npos);
- description = YGUtils::escape_break_lines (description, true);
-
string str;
if (package) {
description += "<br>";
@@ -458,6 +450,9 @@
for (std::list <string>::const_iterator it = filenames.begin();
it != filenames.end(); it++) {
string file (*it);
+ // don't show created dirs
+ if (g_file_test (file.c_str(), G_FILE_TEST_IS_DIR))
+ continue;
// set the path as a link
if (m_use_filemanager) {
string::size_type pos = file.find_last_of ('/');
@@ -471,22 +466,21 @@
}
set_text (m_filelist_text, filelist);
}
- if (m_history_text) {
- string history;
+ if (m_changelog_text) {
+ string text;
const std::list zypp::ChangelogEntry &changelog = package->changelog();
for (std::list zypp::ChangelogEntry::const_iterator it = changelog.begin();
it != changelog.end(); it++) {
- string text = "<blockquote>" + YGUtils::escape_markup (it->text()) +
+ string t = "<blockquote>" + YGUtils::escape_markup (it->text(), true) +
"</blockquote>";
- text = YGUtils::escape_break_lines (text, false);
- history += "<p>" + YGUtils::escape_markup (it->date().asString()) +
- " " + YGUtils::escape_markup (it->author()) + ":<br>" +
- text + "</p>";
+ text += "<p>" + it->date().asString() + ""
+ + YGUtils::escape_markup (it->author()) + ":<br>"
+ + t + "</p>";
}
- set_text (m_history_text, history);
+ set_text (m_changelog_text, text);
}
if (m_authors_text) {
- string packager (package->packager()), authors;
+ string packager (YGUtils::escape_markup (package->packager())), authors;
const std::list <string> &authors_list = package->authors();
if (!authors_list.empty()) {
@@ -497,13 +491,13 @@
else {
/* authors() should be the proper way to get authors, but it seems to
be rarely used, instead packagers list them on the description. */
- string description = YGUtils::escape_markup (object->description());
+ string description (object->description());
string::size_type pos = description.find ("Authors:");
if (pos != string::npos) {
pos = description.find_first_not_of (
'-', pos + sizeof ("Authors:") + 1);
authors = string (description, pos, string::npos);
- authors = YGUtils::escape_break_lines (authors, false);
+ authors = YGUtils::escape_markup (authors, true);
}
}
@@ -523,8 +517,8 @@
else {
if (m_filelist_text)
set_text (m_filelist_text, "");
- if (m_history_text)
- set_text (m_history_text, "");
+ if (m_changelog_text)
+ set_text (m_changelog_text, "");
if (m_authors_text)
set_text (m_authors_text, "");
}
@@ -538,7 +532,7 @@
scroll_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_win),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
- widget = ygtk_richtext_new();
+ widget = ygtk_html_wrap_new();
gtk_container_add (GTK_CONTAINER (scroll_win), widget);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), scroll_win,
@@ -551,17 +545,12 @@
const char *str = _("<i>(not available)</i>");
if (!text.empty())
str = text.c_str();
- ygtk_richtext_set_text (YGTK_RICHTEXT (widget), str, TRUE);
-
- // scroll to the start
- GtkTextIter iter;
- gtk_text_buffer_get_start_iter (gtk_text_view_get_buffer (
- GTK_TEXT_VIEW (widget)), &iter);
- gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (widget), &iter, 0, TRUE, 0, 0);
+ ygtk_html_wrap_set_text (widget, str);
+ ygtk_html_wrap_scroll (widget, TRUE); // scroll to the start
}
/* When a directory is pressed on the file list. */
- static void dir_pressed_cb (YGtkRichText *rich_text, const gchar *link)
+ static void dir_pressed_cb (GtkWidget *text, const gchar *link)
{ FILEMANAGER_LAUNCH (link); }
};
Modified: trunk/gtk/src/YGRichText.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGRichText.cc?rev=41442&r1=41441&r2=41442&view=diff
==============================================================================
--- trunk/gtk/src/YGRichText.cc (original)
+++ trunk/gtk/src/YGRichText.cc Tue Oct 16 16:47:05 2007
@@ -8,27 +8,24 @@
#include "YGUtils.h"
#include "YGWidget.h"
#include "YRichText.h"
-#include "ygtkrichtext.h"
+#include "ygtkhtmlwrap.h"
class YGRichText : public YRichText, public YGScrolledWidget
{
- bool m_plainText;
+bool m_autoScrollDown;
public:
YGRichText(const YWidgetOpt &opt, YGWidget *parent, const YCPString &text)
: YRichText (opt, text),
- YGScrolledWidget (this, parent, true, YGTK_TYPE_RICHTEXT, NULL)
+ YGScrolledWidget (this, parent, true, ygtk_htmlwrap_get_type (opt.plainTextMode.value()), NULL)
{
IMPL
if (!opt.isShrinkable.value())
setMinSizeInChars (20, 8);
+ m_autoScrollDown = opt.autoScrollDown.value();
- m_plainText = opt.plainTextMode.value();
- ygtk_richttext_set_prodname (YGTK_RICHTEXT (getWidget()),
- YUI::ui()->productName().c_str());
-
- g_signal_connect (G_OBJECT (getWidget()), "link-pressed",
- G_CALLBACK (link_pressed_cb), this);
+ ygtk_htmlwrap_init (getWidget());
+ ygtk_htmlwrap_connect_link_clicked (getWidget(), G_CALLBACK (link_clicked_cb), this);
setText (text);
}
@@ -37,18 +34,19 @@
{ }
// YRichText
- virtual void setText (const YCPString &text)
+ virtual void setText (const YCPString &_text)
{
IMPL
- ygtk_richtext_set_text (YGTK_RICHTEXT (getWidget()), text->value_cstr(),
- !m_plainText);
+ string text (_text->value());
+ YGUtils::replace (text, "&product;", 9, YUI::ui()->productName().c_str());
- if (autoScrollDown)
- YGUtils::scrollTextViewDown (GTK_TEXT_VIEW (getWidget()));
- YRichText::setText (text);
+ ygtk_htmlwrap_set (getWidget(), text.c_str());
+ if (m_autoScrollDown)
+ ygtk_htmlwrap_scroll (getWidget(), FALSE);
+ YRichText::setText (_text);
}
- static void link_pressed_cb (YGtkRichText *rtext, const char *url, YGRichText *pThis)
+ static void link_clicked_cb (GtkWidget *widget, const char *url, YGRichText *pThis)
{
YGUI::ui()->sendEvent (new YMenuEvent (YCPString (url)));
}
@@ -62,3 +60,4 @@
{
return new YGRichText (opt, YGWidget::get (parent), text);
}
+
Modified: trunk/gtk/src/YGUtils.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUtils.cc?rev=41442&r1=41441&r2=41442&view=diff
==============================================================================
--- trunk/gtk/src/YGUtils.cc (original)
+++ trunk/gtk/src/YGUtils.cc Tue Oct 16 16:47:05 2007
@@ -64,6 +64,16 @@
g_free (text);
}
+void YGUtils::replace (string &str, const char *mouth, int mouth_len, const char *food)
+{
+ unsigned int i = 0;
+ while ((i = str.find (mouth, i)) != string::npos)
+ {
+ str.erase (i, mouth_len);
+ str.insert (i, food);
+ }
+}
+
void YGUtils::scrollTextViewDown(GtkTextView *text_view)
{
GtkTextBuffer *buffer = gtk_text_view_get_buffer (text_view);
@@ -77,7 +87,6 @@
gtk_text_buffer_delete_mark (buffer, end_mark);
}
-
/* Strings can ask for not being escape with the comment
<!-- DT:Rich --> */
static bool dont_escape (const string &str)
@@ -91,7 +100,7 @@
return true;
}
-string YGUtils::escape_markup (const string &str)
+string YGUtils::escape_markup (const string &str, bool break_lines)
{
if (dont_escape (str))
return string (str);
@@ -110,6 +119,9 @@
case '&':
ret += "&";
break;
+ case '\n':
+ ret += "<br/>";
+ break;
default:
ret += ch;
break;
@@ -119,6 +131,7 @@
return ret;
}
+#if 0
string YGUtils::escape_break_lines (const string &str, bool paragraph_mode)
{
if (dont_escape (str))
@@ -150,6 +163,7 @@
res += "</p>";
return res;
}
+#endif
#define PROD_ENTITY "&product;"
@@ -263,12 +277,6 @@
{
// Tag foo
if (instr[i] == '<') {
- gint j;
- gboolean is_close = FALSE;
- gboolean in_tag;
- int tag_len;
- GString *tag = g_string_sized_new (20);
-
// ignore comments
if (strncmp (&instr[i], "
Reply