[gnote] remove libxml++, at last



commit d8d85fe5e7559a2cb44dae0c9258ce2c3dfade9f
Author: Hubert Figuiere <hub figuiere net>
Date:   Wed May 27 14:33:42 2009 -0400

    remove libxml++, at last
---
 NEWS                  |    6 ++++-
 configure.ac          |    1 -
 src/Makefile.am       |    4 +-
 src/actionmanager.cpp |   55 ++++++++++++++++++++++++++++--------------------
 src/actionmanager.hpp |    3 --
 5 files changed, 39 insertions(+), 30 deletions(-)

diff --git a/NEWS b/NEWS
index ba243b9..36f9f8f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+  * Remove libxml++. (Closes #579292) Possibly closes bug #579316.
+
 0.4.0 - 2009/05/27
 
 New features:
@@ -8,7 +10,9 @@ New features:
 
 Fixes:
 
-  * Remove libxml++ TextReader. (Closes #579292) Possibly closes bug #579316.
+  * Hard require on libxml++ 2.26. Should prevent some bugs (Bug #583807, 
+    Bug #583808, Bug #579292, Bug #579316)
+    See: http://git.gnome.org/cgit/libxml++/commit/?id=24b3ec06f5c5ebd0529100a5506a8038f14bac5b
   * Note is now trackable. Should avoid a crash related to signals.
     (Closes #581618)
   * Remove obsolete UTF-8 keyword in .desktop (Closes #581623) 
diff --git a/configure.ac b/configure.ac
index 2086a58..615ccd9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,7 +70,6 @@ PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= $GTK_VERSION])
 PKG_CHECK_MODULES(LIBGTKMM, [gtkmm-2.4 >= $LIBGTKMM_VERSION])
 PKG_CHECK_MODULES(LIBXML, [libxml-2.0])
 PKG_CHECK_MODULES(LIBXSLT, [libxslt])
-PKG_CHECK_MODULES(LIBXMLPP, [libxml++-2.6])
 PKG_CHECK_MODULES(GCONF, [gconf-2.0])
 dnl PKG_CHECK_MODULES(LIBGLADEMM, [libglademm-2.4 >= $LIBGLADEMM_VERSION])
 dnl PKG_CHECK_MODULES(LIBGNOMEUI, [libgnomeui-2.0 >= $LIBGNOMEUI_VERSION])
diff --git a/src/Makefile.am b/src/Makefile.am
index 4c1d931..fbcad23 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,14 +6,14 @@ EXTRA_DIST = gnote-applet.in
 
 INCLUDES = -I$(top_srcdir)
 AM_CPPFLAGS= LIBGTKMM_CFLAGS@ @LIBGLIBMM_CFLAGS@ \
-	@LIBXMLPP_CFLAGS@ @GCONF_CFLAGS@ @GTK_CFLAGS@ \
+	@GCONF_CFLAGS@ @GTK_CFLAGS@ \
 	@GTKSPELL_CFLAGS@ @LIBXML_CFLAGS@ \
 	-DGNOTE_LOCALEDIR=\"@GNOTE_LOCALEDIR \" \
 	-DDATADIR=\"$(datadir)\" -DLIBDIR=\"$(libdir)\"
 
 AM_LDFLAGS=-Wl,--export-dynamic
 
-GNOTE_LIBS = libgnote.a @LIBGLIBMM_LIBS@ @LIBGTKMM_LIBS@ @LIBXMLPP_LIBS@ \
+GNOTE_LIBS = libgnote.a @LIBGLIBMM_LIBS@ @LIBGTKMM_LIBS@ \
 	@GCONF_LIBS@ @BOOST_FILESYSTEM_LIBS@ @BOOST_REGEX_LIBS@ \
 	@GTKSPELL_LIBS@ @GTK_LIBS@ \
 	-luuid -L$(top_builddir)/libtomboy -ltomboy
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index 3160ed6..7058150 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -54,10 +54,11 @@
 #include <gtkmm/imagemenuitem.h>
 #include <gtkmm/image.h>
 #include <gtkmm/stock.h>
-#include <libxml++/parsers/domparser.h>
 
+#include <libxml/tree.h>
 
 #include "sharp/string.hpp"
+#include "sharp/xml.hpp"
 #include "debug.hpp"
 #include "actionmanager.hpp"
 #include "utils.hpp"
@@ -116,38 +117,46 @@ namespace gnote {
     // so that it's real parseable XML.
     std::string xml = "<root>" + m_ui->get_ui() + "</root>";
 
-    xmlpp::DomParser reader;
-    reader.parse_memory(xml);
-
-    xmlpp::Document *doc = reader.get_document();
+    xmlDocPtr doc = xmlParseDoc((const xmlChar*)xml.c_str());
+    if(doc == NULL) {
+      return;
+    }
         
     // Get the element name
     std::string placeholderName = sharp::string_substring(path, sharp::string_last_index_of(
                                                             path, "/") + 1);
     DBG_OUT("path = %s placeholdername = %s", path.c_str(), placeholderName.c_str());
 
-    xmlpp::Element *root_node = doc->get_root_node();
-    xmlpp::NodeSet nodes(root_node->find("//placeholder"));
+    sharp::XmlNodeSet nodes = sharp::xml_node_xpath_find(doc->children, "//placeholder");
     // Find the placeholder specified in the path
-    for(xmlpp::NodeSet::const_iterator iter = nodes.begin();
+    for(sharp::XmlNodeSet::const_iterator iter = nodes.begin();
         iter != nodes.end(); ++iter) {
-      xmlpp::Node * placeholderNode = *iter;
-      
-      xmlpp::Element * element = dynamic_cast<xmlpp::Element*>(placeholderNode);
-      if (element && (element->get_attribute_value("name") == placeholderName)) {
-        // Return each child element's widget
-        xmlpp::Node::NodeList children2(placeholderNode->get_children());
-        for(xmlpp::Node::NodeList::const_iterator iter2 = children2.begin();
-            iter2 != children2.end(); ++iter2) {
-
-          xmlpp::Node * widgetNode = *iter2;
-
-          xmlpp::Element *element2 = dynamic_cast<xmlpp::Element*>(widgetNode);
-          if(element2) {
-            std::string widgetName = element2->get_attribute_value("name");
-            children.push_back(get_widget(path + "/" + widgetName));
+      xmlNodePtr placeholderNode = *iter;
+
+      if (placeholderNode->type == XML_ELEMENT_NODE) {
+
+        xmlChar * prop = xmlGetProp(placeholderNode, (const xmlChar*)"name");
+        if(!prop) {
+          continue;
+        }
+        if(xmlStrEqual(prop, (xmlChar*)placeholderName.c_str())) {
+
+          // Return each child element's widget
+          for(xmlNodePtr widgetNode = placeholderNode->children;
+              widgetNode; widgetNode = widgetNode->next) {
+
+            if(widgetNode->type == XML_ELEMENT_NODE) {
+
+              xmlChar * widgetName = xmlGetProp(widgetNode, (const xmlChar*)"name");
+              if(widgetName) {
+                children.push_back(get_widget(path + "/"
+                                              + (const char*)widgetName));
+                xmlFree(widgetName);
+              }
+            }
           }
         }
+        xmlFree(prop);
       }
     }
   }
diff --git a/src/actionmanager.hpp b/src/actionmanager.hpp
index bd545c8..d4794c3 100644
--- a/src/actionmanager.hpp
+++ b/src/actionmanager.hpp
@@ -17,9 +17,6 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-
-
-
 #ifndef __ACTIONMANAGER_HPP_
 #define __ACTIONMANAGER_HPP_
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]