From b72c417165e828d7fb6afc6c647f9fc123fd7847 Mon Sep 17 00:00:00 2001
From: John Darrington <john@darrington.wattle.id.au>
Date: Thu, 29 May 2008 00:43:01 +0000
Subject: [PATCH] Added a --enable-anachronistic-dependencies flag to
 configure, which allows psppire to be built against older versions of GTK and
 other libraries.

---
 INSTALL                              |  8 +++++++
 configure.ac                         | 14 ++++++++++--
 src/ui/gui/dict-display.c            |  5 +++++
 src/ui/gui/text-data-import-dialog.c | 32 +++++++++++++++++++++++++++-
 4 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/INSTALL b/INSTALL
index 5d79c55e44..c1a48ef8f5 100644
--- a/INSTALL
+++ b/INSTALL
@@ -209,6 +209,14 @@ Optional Features
     In these cases you can use --without-lib{xx} to force configure
     to disregard it.
 
+`--enable-anachronistic-dependencies'
+   If you use this option, some of the checks for dependent libraries
+   will be relaxed, permitting configure to succeed when older versions
+   of libraries are detected.   Use of this option is not recommended.
+   If you use it, some features may be missing and the build may fail
+   with obscure error messages.
+   
+
 Defining Variables
 ==================
 
diff --git a/configure.ac b/configure.ac
index 8f3c96c4dd..fdfc16627c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,6 +16,11 @@ AC_LIBTOOL_DLOPEN
 AC_PROG_LIBTOOL
 PKG_PROG_PKG_CONFIG
 
+AC_ARG_ENABLE(
+  anachronistic-dependencies, 
+  [AS_HELP_STRING([--enable-anachronistic-dependencies], 
+                  [Attempt to allow building against older versions of dependent libraries])])
+
 PSPP_ENABLE_OPTION(-Wdeclaration-after-statement)
 
 AM_CONDITIONAL(cc_is_gcc, test x"$GCC" = x"yes" )
@@ -39,9 +44,14 @@ AC_ARG_WITH(
   gui, 
   [AS_HELP_STRING([--without-gui], [don't build the PSPPIRE gui])])
 
+required_gtk_version=2.12
+if test x"$enable_anachronistic_dependencies" = x"yes"  ; then
+  required_gtk_version=2.8.20
+fi
+
 if test x"$with_gui" != x"no" ; then 
-  PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.12.0,,
-    [PSPP_REQUIRED_PREREQ([gtk+ 2.0 v2.12.0 or later (or use --without-gui)])])
+  PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $required_gtk_version,,
+    [PSPP_REQUIRED_PREREQ([gtk+ 2.0 v$required_gtk_version or later (or use --without-gui)])])
   PKG_CHECK_MODULES(GLADE, libglade-2.0 >= 2.6.0,,
     [PSPP_REQUIRED_PREREQ([libglade 2.0 v2.6.0 or later (or use --without-gui)])])
 fi
diff --git a/src/ui/gui/dict-display.c b/src/ui/gui/dict-display.c
index 8424413721..356758beee 100644
--- a/src/ui/gui/dict-display.c
+++ b/src/ui/gui/dict-display.c
@@ -154,6 +154,7 @@ var_description_cell_data_func (GtkTreeViewColumn *col,
 }
 
 
+#if GTK_CHECK_VERSION (2, 12, 0)
 /* Sets the tooltip to be the name of the variable under the cursor */
 static gboolean
 set_tooltip_for_variable (GtkTreeView  *treeview,
@@ -171,6 +172,7 @@ set_tooltip_for_variable (GtkTreeView  *treeview,
   struct variable *var = NULL;
   gboolean ok;
 
+
   gtk_tree_view_convert_widget_to_bin_window_coords (treeview,
                                                      x, y, &bx, &by);
 
@@ -199,6 +201,7 @@ set_tooltip_for_variable (GtkTreeView  *treeview,
 
   return TRUE;
 }
+#endif
 
    /* Sets up TREEVIEW to display the variables of DICT.
    MODE is the selection mode for TREEVIEW.
@@ -269,7 +272,9 @@ attach_dictionary_to_treeview (GtkTreeView *treeview, PsppireDict *dict,
 
   g_object_set (treeview, "has-tooltip", TRUE, NULL);
 
+#if GTK_CHECK_VERSION (2, 12, 0)
   g_signal_connect (treeview, "query-tooltip", G_CALLBACK (set_tooltip_for_variable), NULL);
+#endif
 }
 
 
diff --git a/src/ui/gui/text-data-import-dialog.c b/src/ui/gui/text-data-import-dialog.c
index 1f17630852..11ca7b044e 100644
--- a/src/ui/gui/text-data-import-dialog.c
+++ b/src/ui/gui/text-data-import-dialog.c
@@ -16,11 +16,15 @@
 
 #include <config.h>
 
+#include <gtk/gtk.h>
+
+
+
 #include "checkbox-treeview.h"
 #include "descriptives-dialog.h"
 
 #include <errno.h>
-#include <gtk/gtk.h>
+
 #include <gtksheet/gtksheet.h>
 #include <limits.h>
 #include <stdlib.h>
@@ -50,6 +54,30 @@
 #define _(msgid) gettext (msgid)
 #define N_(msgid) msgid
 
+
+#if !GTK_CHECK_VERSION (2, 10, 0)
+
+void
+text_data_import_assistant (GObject *o, gpointer de_)
+{
+  struct data_editor *de = de_;
+
+  GtkWidget *dialog =
+    gtk_message_dialog_new  (de->parent.window,
+			     GTK_DIALOG_MODAL,
+			     GTK_MESSAGE_WARNING,
+			     GTK_BUTTONS_CLOSE,
+			     _("The text import assistant has not been "
+			       "compiled into this build of PSPPIRE, because "
+			       "GTK+ version 2.10.0 or later was not available."));
+
+  gtk_dialog_run (GTK_DIALOG (dialog));
+
+  gtk_widget_destroy (dialog);
+}
+
+#else
+
 /* TextImportModel, a GtkTreeModel used by the text data import
    dialog. */
 enum
@@ -2282,3 +2310,5 @@ pop_watch_cursor (struct import_assistant *ia)
       gdk_window_set_cursor (widget->window, NULL);
     }
 }
+
+#endif
-- 
2.30.2