]> matita.cs.unibo.it Git - helm.git/commitdiff
Initial revision
authorLuca Padovani <luca.padovani@unito.it>
Thu, 12 Apr 2001 11:19:14 +0000 (11:19 +0000)
committerLuca Padovani <luca.padovani@unito.it>
Thu, 12 Apr 2001 11:19:14 +0000 (11:19 +0000)
14 files changed:
helm/helmpot/.cvsignore [new file with mode: 0644]
helm/helmpot/AUTHORS [new file with mode: 0644]
helm/helmpot/ChangeLog [new file with mode: 0644]
helm/helmpot/LICENSE [new file with mode: 0644]
helm/helmpot/Makefile.am [new file with mode: 0644]
helm/helmpot/NEWS [new file with mode: 0644]
helm/helmpot/README [new file with mode: 0644]
helm/helmpot/acconfig.h [new file with mode: 0644]
helm/helmpot/configure.in [new file with mode: 0644]
helm/helmpot/guiGTK.c [new file with mode: 0644]
helm/helmpot/guiGTK.h [new file with mode: 0644]
helm/helmpot/helmpot.spec.in [new file with mode: 0644]
helm/helmpot/main.c [new file with mode: 0644]
helm/helmpot/pot_mask [new file with mode: 0644]

diff --git a/helm/helmpot/.cvsignore b/helm/helmpot/.cvsignore
new file mode 100644 (file)
index 0000000..3568925
--- /dev/null
@@ -0,0 +1,16 @@
+.emacs.desktop
+config.h
+config.h.in
+config.cache
+config.log
+config.status
+configure
+configure.scan
+t1lib.log
+stamp-h
+stamp-h.in
+Makefile
+Makefile.in
+*.gz
+aclocal.m4
+*.spec
diff --git a/helm/helmpot/AUTHORS b/helm/helmpot/AUTHORS
new file mode 100644 (file)
index 0000000..fe59f14
--- /dev/null
@@ -0,0 +1 @@
+Luca Padovani <luca.padovani@cs.unibo.it>
diff --git a/helm/helmpot/ChangeLog b/helm/helmpot/ChangeLog
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/helm/helmpot/LICENSE b/helm/helmpot/LICENSE
new file mode 100644 (file)
index 0000000..eef8774
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+ * 
+ * This file is part of HelmPot, a minimal browser for HELM.
+ * 
+ * HelmPot is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HelmPot is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with HelmPot; if not, write to the Free Software
+ * 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
+ * <luca.padovani@cs.unibo.it>
+ */
diff --git a/helm/helmpot/Makefile.am b/helm/helmpot/Makefile.am
new file mode 100644 (file)
index 0000000..7d2fefe
--- /dev/null
@@ -0,0 +1,23 @@
+
+CLEANFILES = core t1lib.log helmpot.spec
+
+bin_PROGRAMS = helmpot
+
+noinst_HEADERS = guiGTK.h
+
+helmpot_SOURCES = \
+  main.c \
+  guiGTK.c
+
+backup:
+       tar cvfz ../@PACKAGE@-@VERSION@-`date|tr ' ' '_'|tr ':' '_'`.tar.gz .
+
+cleanbak:
+       -rm -f `find . -name "*~"`
+
+lc:
+       @( \
+       CFILES=`find . -name "*.c"`; \
+       HFILES=`find . -name "*.h"`; \
+       wc -l $$CFILES $$HFILES | tail -n 1 \
+       )
diff --git a/helm/helmpot/NEWS b/helm/helmpot/NEWS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/helm/helmpot/README b/helm/helmpot/README
new file mode 100644 (file)
index 0000000..2e7cb0d
--- /dev/null
@@ -0,0 +1,18 @@
+
+HELMPoT
+-------
+
+HELMPoT is a small plug-out for Netscape Navigator in order to
+browse the HELM library. After installing the binary somewhere
+in your hard disk, just configure a new helper application in
+Netscape associated to the text/xml MIME type. The command
+to be executed should something of the kind:
+
+       helmpot '%s'
+
+assuming that helmpot is visible in your path.
+
+Enjoy,
+
+       luca.padovani@cs.unibo.it
+
diff --git a/helm/helmpot/acconfig.h b/helm/helmpot/acconfig.h
new file mode 100644 (file)
index 0000000..887d868
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+ * 
+ * This file is part of HelmView, a minimal browser for HELM.
+ * 
+ * HelmView is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HelmView is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with HelmView; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * 
+ * For details, see the HelmView World-Wide-Web page,
+ * http://cs.unibo.it/helm/helmview, or send a mail to
+ * <luca.padovani@cs.unibo.it>
+ */
+
+#ifndef __config_h__
+#define __config_h__
+
+#define PRIVATE static
+
+@TOP@
+
+/* If defined the widget will perform a huge amount
+ * of validity checks while running
+ */
+#undef ENABLE_CHECKS
+
+#ifdef ENABLE_CHECKS
+#define DEBUG
+#else
+#define NDEBUG
+#define G_DISABLE_ASSERT
+#define G_DISABLE_CHECKS
+#endif
+
+@BOTTOM@
+
+#endif /* __config_h__ */
diff --git a/helm/helmpot/configure.in b/helm/helmpot/configure.in
new file mode 100644 (file)
index 0000000..a568285
--- /dev/null
@@ -0,0 +1,86 @@
+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=1
+HELMPOT_VERSION=$HELMPOT_MAJOR_VERSION.$HELMPOT_MINOR_VERSION.$HELMPOT_MICRO_VERSION
+VERSION=$HELMPOT_VERSION
+
+AC_SUBST(HELMPOT_VERSION)
+
+AC_ARG_ENABLE(
+       checks,
+       [  --enable-checks[=ARG]   include debugging checks [default=yes]],
+       [
+               if test $enableval = yes; then
+                       AC_DEFINE(ENABLE_CHECKS)
+               fi
+       ],
+       AC_DEFINE(ENABLE_CHECKS)
+)
+
+dnl Automake configuration
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE(helmpot, $HELMPOT_VERSION)
+
+dnl Checks for programs.
+AC_LANG_C
+AC_PROG_CC
+AC_ISC_POSIX
+AC_CHECK_PROG(HAVE_COLORGCC, colorgcc, yes, no)
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(unistd.h)
+AC_FUNC_VFORK
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+
+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`
+)
+
+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`
+)
+
+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`
+)
+
+if test $HAVE_COLORGCC = "yes"; then
+       CC=colorgcc
+       CXX=colorgcc
+fi
+
+CFLAGS="$CFLAGS -W -Wall"
+CXXFLAGS="$CXXFLAGS -W -Wall"
+
+AC_OUTPUT([
+Makefile
+helmpot.spec
+])
diff --git a/helm/helmpot/guiGTK.c b/helm/helmpot/guiGTK.c
new file mode 100644 (file)
index 0000000..ede4aa0
--- /dev/null
@@ -0,0 +1,577 @@
+/*
+ * Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+ * 
+ * This file is part of HelmPot, a minimal browser for HELM.
+ * 
+ * HelmPot is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HelmPot is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with HelmPot; if not, write to the Free Software
+ * 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
+ * <luca.padovani@cs.unibo.it>
+ */
+
+#include <config.h>
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#if HAVE_UNISTD_H
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <fcntl.h>
+# include <unistd.h>
+#endif
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "gtkmathview.h"
+#include "guiGTK.h"
+
+#define XLINK_NS_URI "http://www.w3.org/1999/xlink"
+
+#define pot_width 16
+#define pot_height 16
+PRIVATE unsigned char pot_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x07,
+   0x00, 0x00, 0xe6, 0x2f, 0x34, 0x5f, 0xdc, 0x5f, 0xf8, 0x3f, 0xf8, 0x3f,
+   0xf0, 0x1f, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00};
+
+#define pot_mask_width 16
+#define pot_mask_height 16
+static unsigned char pot_mask_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0xe0, 0x0f, 0xe0, 0x0f,
+   0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f,
+   0xfc, 0x7f, 0xf8, 0x3f, 0xf0, 0x1f, 0x00, 0x00};
+
+PRIVATE GtkWidget* window;
+PRIVATE GtkWidget* main_area;
+PRIVATE GtkWidget* scrolled_area;
+PRIVATE GtkWidget* status_bar;
+PRIVATE GtkMenuItem* kerning_item;
+PRIVATE GtkMenuItem* anti_aliasing_item;
+PRIVATE GtkMenuItem* font_size_item;
+PRIVATE gchar* file_name = NULL;
+
+PRIVATE GdkCursor* pot;
+
+PRIVATE guint statusbar_context;
+
+PRIVATE void create_widget_set(void);
+PRIVATE GtkWidget* get_main_menu(void);
+PRIVATE void options_font_size(GtkWidget*, guint);
+PRIVATE void options_font_manager(GtkWidget*, guint);
+PRIVATE void options_verbosity(GtkWidget*, guint);
+PRIVATE void options_kerning(GtkWidget*, gpointer);
+PRIVATE void options_anti_aliasing(GtkWidget*, gpointer);
+PRIVATE void help_about(GtkWidget*, gpointer);
+PRIVATE void save_as(GtkWidget*);
+PRIVATE void export_to_ps(GtkWidget*);
+
+PRIVATE GtkItemFactoryEntry menu_items[] = {
+  { "/_File",                          NULL,         NULL,          0, "<Branch>" },
+  { "/File/Save _As...",               NULL,         save_as,       0, NULL },
+  { "/File/_Export to PostScript...",  NULL,         export_to_ps,  0, NULL },
+  { "/File/sep1",                      NULL,         NULL,          0, "<Separator>" },
+  { "/File/_Quit",                     "<control>Q", gtk_main_quit, 0, NULL },
+
+  { "/_Options",                       NULL, NULL,                  0,  "<Branch>" },
+  { "/Options/Default _Font Size",     NULL, NULL,                  0,  "<Branch>" },
+  { "/Options/Default Font Size/8pt",  NULL, options_font_size,     8,  "<RadioItem>" },
+  { "/Options/Default Font Size/10pt", NULL, options_font_size,     10, "/Options/Default Font Size/8pt" },
+  { "/Options/Default Font Size/12pt", NULL, options_font_size,     12, "/Options/Default Font Size/8pt" },
+  { "/Options/Default Font Size/14pt", NULL, options_font_size,     14, "/Options/Default Font Size/8pt" },
+  { "/Options/Default Font Size/18pt", NULL, options_font_size,     18, "/Options/Default Font Size/8pt" },
+  { "/Options/Default Font Size/24pt", NULL, options_font_size,     24, "/Options/Default Font Size/8pt" },
+  { "/Options/Font Manager",           NULL, NULL,                  0,  "<Branch>" },
+  { "/Options/Font Manager/_GTK",      NULL, options_font_manager,  0,  "<RadioItem>" },
+  { "/Options/Font Manager/_Type 1",   NULL, options_font_manager,  1,  "/Options/Font Manager/GTK" },
+  { "/Options/Verbosity",              NULL, NULL,                  0,  "<Branch>" },
+  { "/Options/Verbosity/_Errors",      NULL, options_verbosity,     0,  "<RadioItem>" },
+  { "/Options/Verbosity/_Warnings",    NULL, options_verbosity,     1,  "/Options/Verbosity/Errors" },
+  { "/Options/Verbosity/_Info",        NULL, options_verbosity,     2,  "/Options/Verbosity/Errors" },
+  { "/Options/Verbosity/_Debug",       NULL, options_verbosity,     3,  "/Options/Verbosity/Errors" },
+  { "/Options/sep1",                   NULL, NULL,                  0,  "<Separator>" },
+  { "/Options/_Kerning",               NULL, options_kerning,       0,  "<ToggleItem>" },
+  { "/Options/_Anti Aliasing",         NULL, options_anti_aliasing, 0,  "<ToggleItem>" },
+
+  { "/_Help" ,        NULL,         NULL,          0, "<LastBranch>" },
+  { "/Help/About...", NULL,         help_about,    0, NULL }
+};
+
+PRIVATE void
+quick_message(const gchar* msg)
+{
+  GtkWidget* dialog;
+  GtkWidget* label;
+  GtkWidget* okay_button;
+     
+  /* Create the widgets */
+     
+  dialog = gtk_dialog_new();
+  label = gtk_label_new (msg);
+  okay_button = gtk_button_new_with_label("OK");
+
+  gtk_widget_set_usize(dialog, 300, 100);
+
+  /* Ensure that the dialog box is destroyed when the user clicks ok. */
+     
+  gtk_signal_connect_object (GTK_OBJECT (okay_button), "clicked",
+                            GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT(dialog));
+  gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area),
+                    okay_button);
+  
+  /* Add the label, and show everything we've added to the dialog. */
+  
+  gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), label);
+  gtk_widget_show_all (dialog);
+}
+
+PRIVATE void
+load_error_msg(const gchar* name)
+{
+  gchar* msg = g_strdup_printf("Could not load\n`%s'", name);
+  quick_message(msg);
+  g_free(msg);
+}
+
+PRIVATE void
+save_error_msg(const gchar* name)
+{
+  gchar* msg = g_strdup_printf("Could not save\n`%s'", name);
+  quick_message(msg);
+  g_free(msg);
+}
+
+void
+GUI_init(gint* argc, gchar*** argv, gchar* title, guint width, guint height, GtkFunction f, guint32 timeout)
+{
+  GdkPixmap* source;
+  GdkPixmap* mask;
+
+  GdkColor fg = { 0, 65535, 65535, 65535 };
+  GdkColor bg = { 0, 0, 0, 0 };
+
+  gtk_init(argc, argv);
+
+  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_title(GTK_WINDOW(window), title);
+  gtk_window_set_default_size(GTK_WINDOW(window), width, height);
+  gtk_signal_connect(GTK_OBJECT(window), "delete_event", (GtkSignalFunc) gtk_main_quit, NULL);
+  create_widget_set();
+
+  gtk_widget_show(window);
+
+  gtk_timeout_add(timeout, f, NULL);
+
+  source = gdk_bitmap_create_from_data (NULL, pot_bits,
+                                       pot_width, pot_height);
+  mask = gdk_bitmap_create_from_data (NULL, pot_mask_bits,
+                                     pot_mask_width, pot_mask_height);
+  pot = gdk_cursor_new_from_pixmap (source, mask, &fg, &bg, 8, 8);
+  gdk_pixmap_unref (source);
+  gdk_pixmap_unref (mask);  
+}
+
+void
+GUI_uninit()
+{
+}
+
+int
+GUI_load_document(const gchar* name)
+{
+  GtkMathView* math_view;
+  GtkMathViewClass* klass;
+
+  g_return_val_if_fail(name != NULL, -1);
+  g_return_val_if_fail(main_area != NULL, -1);
+  g_return_val_if_fail(GTK_IS_MATH_VIEW(main_area), -1);
+
+  math_view = GTK_MATH_VIEW(main_area);
+  g_return_val_if_fail(math_view != NULL, -1);
+
+  klass = (GtkMathViewClass*) gtk_type_class(gtk_math_view_get_type());
+  g_return_val_if_fail(klass != NULL, -1);
+
+  gdk_window_set_cursor (main_area->window, pot);  
+
+  if (!gtk_math_view_load(math_view, name)) {
+    load_error_msg(name);
+    return -1;
+  }
+
+  gtk_statusbar_pop(GTK_STATUSBAR(status_bar), statusbar_context);
+  if (strlen(name) > 40) name += strlen(name) - 40;
+  gtk_statusbar_push(GTK_STATUSBAR(status_bar), statusbar_context, name);
+
+  gdk_window_set_cursor(main_area->window, klass->normal_cursor);
+
+  if (file_name != NULL) g_free(file_name);
+  file_name = g_strdup(name);
+
+  return 0;
+}
+
+void
+GUI_unload_document()
+{
+  GtkMathView* math_view;
+
+  g_return_if_fail(main_area != NULL);
+  g_return_if_fail(GTK_IS_MATH_VIEW(main_area));
+
+  math_view = GTK_MATH_VIEW(main_area);
+
+  gtk_math_view_unload(math_view);
+}
+
+void
+GUI_run()
+{
+  gtk_main();
+}
+
+PRIVATE void
+options_font_size(GtkWidget* widget, guint size)
+{
+  GtkMathView* math_view;
+
+  g_return_if_fail(main_area != NULL);
+  g_return_if_fail(GTK_IS_MATH_VIEW(main_area));
+
+  math_view = GTK_MATH_VIEW(main_area);
+
+  gtk_math_view_set_font_size(math_view, size);
+}
+
+PRIVATE void
+options_font_manager(GtkWidget* widget, guint id)
+{
+  GtkMathView* math_view;
+
+  g_return_if_fail(main_area != NULL);
+  g_return_if_fail(GTK_IS_MATH_VIEW(main_area));
+  
+  math_view = GTK_MATH_VIEW(main_area);
+
+  gtk_math_view_set_font_manager_type(math_view, id);
+}
+
+PRIVATE void
+options_anti_aliasing(GtkWidget* widget, gpointer data)
+{
+  gboolean aa = gtk_math_view_get_anti_aliasing(GTK_MATH_VIEW(main_area));
+  gtk_math_view_set_anti_aliasing(GTK_MATH_VIEW(main_area), !aa);
+}
+
+PRIVATE void
+options_kerning(GtkWidget* widget, gpointer data)
+{
+  gboolean k = gtk_math_view_get_kerning(GTK_MATH_VIEW(main_area));
+  gtk_math_view_set_kerning(GTK_MATH_VIEW(main_area), !k);
+}
+
+PRIVATE void
+options_verbosity(GtkWidget* widget, guint level)
+{
+  gtk_math_view_set_log_verbosity(GTK_MATH_VIEW(main_area), level);
+}
+
+PRIVATE void
+help_about(GtkWidget* widget, gpointer data)
+{
+  GtkWidget* dialog;
+  GtkWidget* label;
+  GtkWidget* ok;
+
+  dialog = gtk_dialog_new();
+  label = gtk_label_new("\n    HELM PoT    \n    Copyright (C) 2001 Luca Padovani    \n");
+  ok = gtk_button_new_with_label("Close");
+
+  gtk_signal_connect_object (GTK_OBJECT (ok), "clicked",
+                            GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) dialog);
+  gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area),
+                    ok);
+
+  gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), label);
+
+  gtk_widget_show_all (dialog);
+}
+
+PRIVATE void
+export_filename(GtkFileSelection* selector, gpointer user_data)
+{
+  FILE* f;
+  GtkMathView* math_view;
+  gchar* selected_filename;
+  
+  selected_filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION(user_data));
+
+  math_view = GTK_MATH_VIEW(main_area);
+
+  f = fopen(selected_filename, "wt");
+  if (f == NULL) {
+    save_error_msg(selected_filename);
+    /*g_free(selected_filename);*/
+    return;
+  }
+
+  gtk_math_view_export_to_postscript(math_view,
+                                    (21 * SCALED_POINTS_PER_CM) / SCALED_POINTS_PER_PX,
+                                    (29 * SCALED_POINTS_PER_CM) / SCALED_POINTS_PER_PX,
+                                    SCALED_POINTS_PER_IN / SCALED_POINTS_PER_PX,
+                                    SCALED_POINTS_PER_IN / SCALED_POINTS_PER_PX,
+                                    FALSE,
+                                    f);
+
+  fclose(f);
+  /*g_free(selected_filename);*/
+}
+
+PRIVATE void
+save_filename(GtkFileSelection* selector, gpointer user_data)
+{
+  FILE* source;
+  FILE* dest;
+  gchar* buffer;
+  gchar* selected_filename;
+
+  if (file_name == NULL) return;
+
+  source = fopen(file_name, "rt");
+  if (source == NULL) {
+    load_error_msg(file_name);
+    return;
+  }
+
+  selected_filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION(user_data));
+  if (selected_filename == NULL) return;
+
+  dest = fopen(selected_filename, "wt");
+  if (dest == NULL) {
+    save_error_msg(selected_filename);
+    /*g_free(selected_filename);*/
+    return;
+  }
+
+  /*g_free(selected_filename);*/
+
+  buffer = g_new(gchar, 2048);
+  while (!feof(source)) {
+    size_t n = fread(buffer, sizeof(gchar), 2048, source);
+    fwrite(buffer, sizeof(gchar), n, dest);
+  }
+
+  g_free(buffer);
+  fclose(source);
+  fclose(dest);
+}
+
+PRIVATE void
+file_dialog(const gchar* title, GtkSignalFunc f)
+{
+  GtkWidget* fs;
+
+  g_return_if_fail(title != NULL);
+  g_return_if_fail(f != NULL);
+
+  fs = gtk_file_selection_new(title);
+
+  gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION(fs)->ok_button),
+                     "clicked", f, fs);
+                             
+  /* Ensure that the dialog box is destroyed when the user clicks a button. */
+     
+  gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(fs)->ok_button),
+                            "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
+                            (gpointer) fs);
+
+  gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(fs)->cancel_button),
+                            "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
+                            (gpointer) fs);
+     
+  /* Display that dialog */
+     
+  gtk_widget_show (fs);
+}
+
+PRIVATE void
+export_to_ps(GtkWidget* widget)
+{
+  file_dialog("Export to PostScript", export_filename);
+#if 0
+  static GList* items = NULL;
+
+  GtkWidget* dialog;
+  GtkWidget* tmp;
+
+  if (items == NULL) {
+    items = g_list_append(items, "A4");
+    items = g_list_append(items, "A5");
+  }
+
+  dialog = gtk_dialog_new();
+  tmp = gtk_label_new("Paper size");
+  gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), tmp);
+  tmp = gtk_combo_new();
+  gtk_combo_set_popdown_strings(GTK_COMBO(tmp), items);
+  gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), tmp);
+#if 0
+  tmp = gtk_check_button_new_with_label("Disable Colors");
+  gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), tmp);
+#endif
+
+  tmp = gtk_button_new_with_label("OK");
+  gtk_signal_connect_object(GTK_OBJECT(tmp), "clicked", GTK_SIGNAL_FUNC(export_to_ps_get_file_name), dialog);
+  gtk_signal_connect_object(GTK_OBJECT(tmp), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), dialog);
+  gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), tmp);
+  tmp = gtk_button_new_with_label("Cancel");
+  gtk_signal_connect_object(GTK_OBJECT(tmp), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), dialog);
+  gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), tmp);
+
+  gtk_widget_show_all(dialog);
+#endif
+}
+
+PRIVATE void
+save_as(GtkWidget* widget)
+{
+  file_dialog("Save As...", save_filename);
+}
+
+PRIVATE void
+selection_changed(GtkMathView* math_view, mDOMNodeRef node)
+{
+  g_return_if_fail(math_view != NULL);
+  g_return_if_fail(GTK_IS_MATH_VIEW(math_view));
+  gtk_math_view_set_selection(math_view, node);
+}
+
+PRIVATE void
+jump(GtkMathView* math_view, mDOMNodeRef node)
+{
+  mDOMStringRef href;
+
+  g_return_if_fail(node != NULL);
+  href = mdom_node_get_attribute_ns(node, DOM_CONST_STRING("href"), XLINK_NS_URI);
+
+  if (href != NULL) {
+    pid_t pid;
+
+    g_assert(main_area != NULL);
+    gdk_window_set_cursor (main_area->window, pot);  
+
+    pid = fork();
+    if (pid == -1) exit(-1);
+    if (pid == 0) {
+      gchar* open_url = g_strdup_printf("openURL(%s,cic)", href);
+      gint fd;
+
+      close(0);
+      close(1);
+      close(2);
+
+      fd = open("/dev/null", O_RDWR);
+      dup(fd);
+      dup(fd);
+
+      execlp("netscape", "netscape", "-noraise", "-remote", open_url, NULL);
+      perror("exec failed:");
+      exit(-1);
+    }
+    mdom_string_free(href);
+  }
+}
+
+PRIVATE void
+create_widget_set()
+{
+  GtkWidget* main_vbox;
+  GtkWidget* menu_bar;
+
+  main_vbox = gtk_vbox_new(FALSE, 1);
+  gtk_container_border_width(GTK_CONTAINER(main_vbox), 1);
+  gtk_container_add(GTK_CONTAINER(window), main_vbox);
+  gtk_widget_show(main_vbox);
+
+  menu_bar = get_main_menu();
+  gtk_box_pack_start(GTK_BOX(main_vbox), menu_bar, FALSE, TRUE, 0);
+  gtk_widget_show(menu_bar);
+
+  main_area = gtk_math_view_new(NULL, NULL);
+  gtk_widget_show(main_area);
+
+  gtk_signal_connect_object (GTK_OBJECT (main_area),
+                            "selection_changed", GTK_SIGNAL_FUNC (selection_changed),
+                            (gpointer) main_area);
+
+  gtk_signal_connect_object (GTK_OBJECT (main_area), "jump", GTK_SIGNAL_FUNC(jump), NULL);
+                            
+  scrolled_area = gtk_scrolled_window_new(NULL, NULL);
+  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_area),
+                                GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
+  gtk_widget_show(scrolled_area);
+  gtk_container_add(GTK_CONTAINER(scrolled_area), main_area);
+  gtk_box_pack_start(GTK_BOX(main_vbox), scrolled_area, TRUE, TRUE, 0);
+
+  status_bar = gtk_statusbar_new();
+  gtk_widget_show(status_bar);
+  gtk_box_pack_start(GTK_BOX(main_vbox), status_bar, FALSE, TRUE, 0);
+  statusbar_context = gtk_statusbar_get_context_id(GTK_STATUSBAR(status_bar), "filename");
+
+  gtk_widget_show(main_vbox);
+
+  if (gtk_math_view_get_anti_aliasing(GTK_MATH_VIEW(main_area)))
+    gtk_menu_item_activate(anti_aliasing_item);
+
+  if (gtk_math_view_get_kerning(GTK_MATH_VIEW(main_area)))
+    gtk_menu_item_activate(kerning_item);
+
+  gtk_math_view_set_font_size(GTK_MATH_VIEW(main_area), DEFAULT_FONT_SIZE);
+  gtk_menu_item_activate(font_size_item);
+}
+
+GtkWidget*
+get_main_menu()
+{
+  GtkItemFactory* item_factory;
+  GtkAccelGroup* accel_group;
+  GtkWidget* menu_item;
+
+  gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
+
+  accel_group = gtk_accel_group_new();
+
+  item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group);
+
+  gtk_item_factory_create_items(item_factory, nmenu_items, menu_items, NULL);
+
+  gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
+
+  menu_item = gtk_item_factory_get_widget(item_factory, "/Options/Kerning");
+  kerning_item = GTK_MENU_ITEM(menu_item);
+
+  menu_item = gtk_item_factory_get_widget(item_factory, "/Options/Anti Aliasing");
+  anti_aliasing_item = GTK_MENU_ITEM(menu_item);
+
+  /* !!!BEWARE!!! the default font size must be kept aligned with the definition
+   * in defs.h
+   */
+  menu_item = gtk_item_factory_get_widget(item_factory, "/Options/Default Font Size/14pt");
+  font_size_item = GTK_MENU_ITEM(menu_item);
+
+  return gtk_item_factory_get_widget(item_factory, "<main>");
+}
diff --git a/helm/helmpot/guiGTK.h b/helm/helmpot/guiGTK.h
new file mode 100644 (file)
index 0000000..83f5f86
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+ * 
+ * This file is part of HelmPot, a minimal browser for HELM.
+ * 
+ * HelmPot is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HelmPot is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with HelmPot; if not, write to the Free Software
+ * 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
+ * <luca.padovani@cs.unibo.it>
+ */
+
+#ifndef __guiGTK_h__
+#define __guiGTK_h__
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+  /* initGUI: some initialization stuff, creates the main window, sets it with a title */
+  void GUI_init(gint *, gchar ***, gchar *, guint, guint, GtkFunction, guint32);
+  void GUI_uninit(void);
+
+  int  GUI_load_document(const gchar*);
+  void GUI_unload_document(void);
+  void GUI_dump_entities(void);
+
+  /* main: this is the main event loop, to be called when the program is ready to run */
+  void GUI_run(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __guiGTK_h__ */
diff --git a/helm/helmpot/helmpot.spec.in b/helm/helmpot/helmpot.spec.in
new file mode 100644 (file)
index 0000000..641f184
--- /dev/null
@@ -0,0 +1,24 @@
+Summary: A minimal browser for the HELM library
+Name: @PACKAGE@
+Version: @VERSION@
+Release: 1
+Copyright: GPL
+Group: Development/Libraries
+Source: www.cs.unibo.it:/helm/helmpot/@PACKAGE@-@VERSION@.tar.gz
+%description
+HelmView is a minimal browser for the HELM library.
+
+%prep
+%setup
+
+%build
+./configure
+make
+
+%install
+make install
+
+%files
+%doc AUTHORS COPYING ChangeLog INSTALL LICENSE NEWS README TODO 
+
+/usr/local/bin/@PACKAGE@
diff --git a/helm/helmpot/main.c b/helm/helmpot/main.c
new file mode 100644 (file)
index 0000000..f99e2fa
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+ * 
+ * This file is part of HelmPot, a minimal browser for HELM.
+ * 
+ * HelmPot is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HelmPot is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with HelmPot; if not, write to the Free Software
+ * 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
+ * <luca.padovani@cs.unibo.it>
+ */
+
+#include <config.h>
+
+#include <glib.h>
+#include <assert.h>
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "defs.h"
+#include "guiGTK.h"
+
+#define BUFFER_SIZE 2048
+
+PRIVATE gchar app_name[64];
+PRIVATE gint sockfd;
+PRIVATE struct sockaddr_in address;
+
+PRIVATE void
+error(const gchar* msg)
+{
+  g_assert(msg != NULL);
+  fprintf(stderr, "%s: fatal error: %s\n", app_name, msg);
+}
+
+#if 0
+PRIVATE void
+print_version()
+{
+  printf("%s - written by Luca Padovani (C) 2000.\n", app_name);
+#ifdef DEBUG
+  printf("Compiled %s %s\n", __DATE__, __TIME__);
+#endif
+  exit(0);
+}
+#endif
+
+PRIVATE gboolean
+timeout(gpointer user_data)
+{
+  static gchar file_name[BUFFER_SIZE];
+
+  if (recv(sockfd, file_name, BUFFER_SIZE, 0) < 0) {
+    if (errno != EAGAIN && errno != EWOULDBLOCK)
+      error("error receving message");
+  } else
+    GUI_load_document(file_name);
+
+  return TRUE;
+}
+
+int
+main(int argc, char *argv[])
+{
+  sprintf(app_name, "HELM Pot (Plug-OuT) v%s", VERSION);
+
+  if (argc != 2) {
+    fprintf(stderr, "%s\n\n", app_name);
+    fprintf(stderr, "Usage: helmpot URL\n");
+    exit(-1);
+  }
+
+  sockfd = socket(PF_INET, SOCK_DGRAM, 0);
+  if (sockfd < 0) error("could not create socket");
+
+  if (inet_aton("127.0.0.1", &address.sin_addr) < 0)
+    error("could not create address");
+  address.sin_port = 8778;
+  address.sin_family = PF_INET;
+
+  if (bind(sockfd, &address, sizeof(address)) < 0) {
+    if (sendto(sockfd, argv[1], strlen(argv[1]), 0, &address, sizeof(address)) < 0) 
+      error("could not send message");
+    sleep(1);
+    exit(0);
+  }
+
+  if (fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0)
+    error("could not set the socket to non-block mode");
+
+  GUI_init(&argc, &argv, app_name, 500, 600, timeout, 500);
+
+  GUI_load_document(argv[1]);
+
+  GUI_run();
+  GUI_uninit();
+  GUI_unload_document();
+
+  return 0;
+}
diff --git a/helm/helmpot/pot_mask b/helm/helmpot/pot_mask
new file mode 100644 (file)
index 0000000..09f71a6
--- /dev/null
@@ -0,0 +1,6 @@
+#define pot_mask_width 16
+#define pot_mask_height 16
+static unsigned char pot_mask_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0xe0, 0x0f, 0xe0, 0x0f,
+   0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f,
+   0xfc, 0x7f, 0xf8, 0x3f, 0xf0, 0x1f, 0x00, 0x00};