From: Luca Padovani Date: Tue, 5 Feb 2002 02:44:56 +0000 (+0000) Subject: porting to gdome2 started X-Git-Tag: just_before_moving_to_gdome~3 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=0ce4d0222fad1263912eed150ffa2f3a2581ee1b;p=helm.git porting to gdome2 started --- diff --git a/helm/helmpot/Makefile.am b/helm/helmpot/Makefile.am index 7d2fefe67..d730de386 100644 --- a/helm/helmpot/Makefile.am +++ b/helm/helmpot/Makefile.am @@ -21,3 +21,6 @@ lc: HFILES=`find . -name "*.h"`; \ wc -l $$CFILES $$HFILES | tail -n 1 \ ) + +INCLUDES = $(GTK_CFLAGS) + diff --git a/helm/helmpot/configure.in b/helm/helmpot/configure.in index b36ac29da..640472467 100644 --- a/helm/helmpot/configure.in +++ b/helm/helmpot/configure.in @@ -2,8 +2,8 @@ dnl Process this file with autoconf to produce a configure script. 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 @@ -42,41 +42,31 @@ dnl Check for iconv with const pointer as second argument 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 diff --git a/helm/helmpot/guiGTK.c b/helm/helmpot/guiGTK.c index ed2718a80..906daf2b6 100644 --- a/helm/helmpot/guiGTK.c +++ b/helm/helmpot/guiGTK.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000, Luca Padovani . + * Copyright (C) 2000-2002, Luca Padovani . * * This file is part of HelmPot, a minimal browser for HELM. * @@ -305,7 +305,7 @@ help_about(GtkWidget* widget, gpointer data) 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", @@ -460,7 +460,7 @@ save_as(GtkWidget* widget) } 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); @@ -468,10 +468,30 @@ element_changed(GtkMathView* math_view, mDOMNodeRef node) /* 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); @@ -479,19 +499,38 @@ element_changed(GtkMathView* math_view, mDOMNodeRef node) } 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); @@ -501,7 +540,7 @@ jump(mDOMConstStringRef href) 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); @@ -521,18 +560,40 @@ jump(mDOMConstStringRef href) 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 @@ -620,3 +681,4 @@ get_main_menu() return gtk_item_factory_get_widget(item_factory, "
"); } + diff --git a/helm/helmpot/main.c b/helm/helmpot/main.c index f99e2fa3b..c2abc2d7e 100644 --- a/helm/helmpot/main.c +++ b/helm/helmpot/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000, Luca Padovani . + * Copyright (C) 2000-2002, Luca Padovani . * * This file is part of HelmPot, a minimal browser for HELM. * @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * For details, see the HelmPot World-Wide-Web page, - * http://cs.unibo.it/helm/helmview, or send a mail to + * http://cs.unibo.it/helm/helmpot, or send a mail to * */