AC_INIT(main.c)
HELMPOT_MAJOR_VERSION=0
-HELMPOT_MINOR_VERSION=0
-HELMPOT_MICRO_VERSION=4
+HELMPOT_MINOR_VERSION=1
+HELMPOT_MICRO_VERSION=0
HELMPOT_VERSION=$HELMPOT_MAJOR_VERSION.$HELMPOT_MINOR_VERSION.$HELMPOT_MICRO_VERSION
VERSION=$HELMPOT_VERSION
AC_LANG_C
dnl Checks for libraries
-AC_CHECK_LIB(gtk, gtk_window_new,
- [
- CFLAGS="$CFLAGS `gtk-config --cflags`"
- CXXFLAGS="$CXXFLAGS `gtk-config --cflags`"
- LIBS="$LIBS `gtk-config --libs`"
- ],
- AC_MSG_ERROR(could not find GTK),
- `gtk-config --libs`
-)
+AM_PATH_GTK(1.2.0, gtklib="yes", gtklib="no")
-AC_CHECK_LIB(minidom, mdom_node_get_type,
- [
- CFLAGS="$CFLAGS `minidom-config --cflags`"
- CXXFLAGS="$CXXFLAGS `minidom-config --cflags`"
- LIBS="$LIBS `minidom-config --libs`"
- ],
- AC_MSG_ERROR(could not find minidom),
- `minidom-config --libs` `glib-config --libs`
-)
+if test $gtklib = "no"; then
+ AC_MSG_ERROR(GTK is needed in order to use helmpot)
+fi
+
+AC_CHECK_PROG(HAVE_GTKMATHVIEW_CONFIG, gtkmathview-config, yes, no)
+if test $HAVE_GTKMATHVIEW_CONFIG = "no"; then
+ AC_MSG_ERROR(gtkmathview is required)
+fi
-vers=`minidom-config --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
-minvers=`echo 0.1.3 | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
+GTKMATHVIEW_MIN_VERSION=0.3.0
+AC_MSG_CHECKING(for gtkmathview >= $GTKMATHVIEW_MIN_VERSION)
+vers=`gtkmathview-config --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
+minvers=`echo $GTKMATHVIEW_MIN_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
if test "$vers" -lt "$minvers"; then
- AC_MSG_ERROR(you need at least minidom 0.1.3)
+ AC_MSG_RESULT(not found)
+ AC_MSG_ERROR(gtkmathview >= $GTKMATHVIEW_MIN_VERSION is required)
+else
+ AC_MSG_RESULT(found)
fi
-AC_CHECK_LIB(gtkmathview, gtk_math_view_new,
- [
- CFLAGS="$CFLAGS `gtkmathview-config --cflags`"
- CXXFLAGS="$CXXFLAGS `gtkmathview-config --cflags`"
- LIBS="$LIBS `gtkmathview-config --libs`"
- ],
- AC_MSG_ERROR(cound not find gtkmathview),
- `gtkmathview-config --libs`
-)
+CFLAGS="$CFLAGS `gtkmathview-config --cflags`"
+CXXFLAGS="$CXXFLAGS `gtkmathview-config --cflags`"
+LIBS="$LIBS `gtkmathview-config --libs`"
if test $HAVE_COLORGCC = "yes"; then
CC=colorgcc
/*
- * Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+ * Copyright (C) 2000-2002, Luca Padovani <luca.padovani@cs.unibo.it>.
*
* This file is part of HelmPot, a minimal browser for HELM.
*
GtkWidget* ok;
dialog = gtk_dialog_new();
- label = gtk_label_new("\n HELM PoT \n Copyright (C) 2001 Luca Padovani \n");
+ label = gtk_label_new("\n HELM PoT \n Copyright (C) 2001-2002 Luca Padovani \n");
ok = gtk_button_new_with_label("Close");
gtk_signal_connect_object (GTK_OBJECT (ok), "clicked",
}
PRIVATE void
-element_changed(GtkMathView* math_view, mDOMNodeRef node)
+element_changed(GtkMathView* math_view, GdomeElement* elem)
{
g_return_if_fail(math_view != NULL);
g_return_if_fail(main_area != NULL);
/* fprintf(stderr, "node changed: %p %s\n", node, (node != NULL) ? mdom_node_get_name(node) : "-"); */
if (!loading) {
- while (node != NULL && !mdom_node_has_attribute_ns(node, DOM_CONST_STRING("href"), XLINK_NS_URI))
- node = mdom_node_get_parent(node);
-
- if (node != NULL) {
+ GdomeException exc = 0;
+ GdomeDOMString* namespaceURI = gdome_str_mkref(XLINK_NS_URI);
+ GdomeDOMString* localName = gdome_str_mkref("href");
+
+ if (elem != NULL) {
+ gdome_el_ref(elem, &exc);
+ g_assert(exc == 0);
+ }
+
+ while (elem != NULL && !gdome_el_hasAttributeNS(elem, namespaceURI, localName, &exc)) {
+ GdomeElement* parent = gdome_cast_el(gdome_el_parentNode(elem, &exc));
+ g_assert(exc == 0);
+ gdome_el_unref(elem, &exc);
+ g_assert(exc == 0);
+ elem = parent;
+ }
+ g_assert(exc == 0);
+
+ gdome_str_unref(namespaceURI);
+ gdome_str_unref(localName);
+
+ if (elem != NULL) {
+ gdome_el_unref(elem, &exc);
+ g_assert(exc == 0);
gdk_window_set_cursor(main_area->window, link_cursor);
} else
gdk_window_set_cursor(main_area->window, normal_cursor);
}
PRIVATE void
-selection_changed(GtkMathView* math_view, mDOMNodeRef node)
+selection_changed(GtkMathView* math_view, GdomeElement* elem)
{
+ GdomeException exc = 0;
+ GdomeDOMString* localName = gdome_str_mkref("xref");
+
g_return_if_fail(math_view != NULL);
g_return_if_fail(GTK_IS_MATH_VIEW(math_view));
- while (node != NULL && !mdom_node_has_attribute(node, DOM_CONST_STRING("xref")))
- node = mdom_node_get_parent(node);
+ if (elem != NULL) {
+ gdome_el_ref(elem, &exc);
+ g_assert(exc == 0);
+ }
+
+ while (elem != NULL && !gdome_el_hasAttribute(elem, localName, &exc)) {
+ GdomeElement* parent = gdome_cast_el(gdome_el_parentNode(elem, &exc));
+ g_assert(exc == 0);
+ gdome_el_unref(elem, &exc);
+ g_assert(exc == 0);
+ elem = parent;
+ }
+
+ gdome_str_unref(localName);
- gtk_math_view_set_selection(math_view, node);
+ gtk_math_view_set_selection(math_view, elem);
+ if (elem != NULL) {
+ gdome_el_unref(elem, &exc);
+ g_assert(exc == 0);
+ }
}
PRIVATE void
-jump(mDOMConstStringRef href)
+jump(GdomeDOMString* href)
{
pid_t pid;
g_return_if_fail(href != NULL);
pid = fork();
if (pid == -1) exit(-1);
if (pid == 0) {
- gchar* open_url = g_strdup_printf("openURL(%s,cic)", href);
+ gchar* open_url = g_strdup_printf("openURL(%s,cic)", href->str);
gint fd;
close(0);
PRIVATE void
clicked(GtkMathView* math_view, gpointer user_data)
{
- mDOMNodeRef p = gtk_math_view_get_element(math_view);
- while (p != NULL && !mdom_node_has_attribute_ns(p, DOM_CONST_STRING("href"), XLINK_NS_URI))
- p = mdom_node_get_parent(p);
+ GdomeException exc = 0;
+ GdomeDOMString* namespaceURI = gdome_str_mkref(XLINK_NS_URI);
+ GdomeDOMString* localName = gdome_str_mkref("href");
+
+ GdomeElement* p = gtk_math_view_get_element(math_view);
+ while (p != NULL && !gdome_el_hasAttributeNS(p, namespaceURI, localName, &exc)) {
+ GdomeElement* parent = gdome_cast_el(gdome_el_parentNode(p, &exc));
+ g_assert(exc == 0);
+ gdome_el_unref(p, &exc);
+ g_assert(exc == 0);
+ p = parent;
+ }
+ g_assert(exc == 0);
if (p != NULL) {
- mDOMStringRef href = mdom_node_get_attribute_ns(p, DOM_CONST_STRING("href"), XLINK_NS_URI);
+ GdomeDOMString* href = gdome_el_getAttributeNS(p, namespaceURI, localName, &exc);
+ g_assert(exc == 0);
g_assert(href != NULL);
- jump(C_CONST_STRING(href));
- mdom_string_free(href);
- } else if (gtk_math_view_get_action(math_view) != NULL)
- gtk_math_view_action_toggle(math_view);
+ jump(href);
+ gdome_str_unref(href);
+ gdome_el_unref(p, &exc);
+ g_assert(exc == 0);
+ } else {
+ p = gtk_math_view_get_action(math_view);
+ if (p != NULL) {
+ gtk_math_view_action_toggle(math_view);
+ gdome_el_unref(p, &exc);
+ g_assert(exc == 0);
+ }
+ }
+
+ gdome_str_unref(namespaceURI);
+ gdome_str_unref(localName);
}
PRIVATE void
return gtk_item_factory_get_widget(item_factory, "<main>");
}
+