diff --git a/ChangeLog b/ChangeLog index 899a8e5a48..92b2bfc545 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,69 @@ +2000-08-14 Juergen Vigna + + * sigc++/.cvsignore: added acinclude.m4 + + * lib/.cvsignore: added listerros + + * src/frontends/Makefile.am: modified for now to ALWAYS compile the + xforms tree as objects are needed for other frontends. + + * src/frontends/gnome/Makefile.am (libgnome_la_OBJADD): added for + linking with not yet implemented xforms objects. + + * src/frontends/gnome/Dialogs.C (Dialogs): added FormDocument. + +2000-08-14 Baruch Even + + * src/frontends/xforms/FormGraphics.h: + * src/frontends/xforms/FormGraphics.C: + * src/frontends/xforms/RadioButtonGroup.h: + * src/frontends/xforms/RadioButtonGroup.C: + * src/insets/insetgraphics.h: + * src/insets/insetgraphics.C: + * src/insets/insetgraphicsParams.h: + * src/insets/insetgraphicsParams.C: Changed indentation to use tabs + instead of spaces, and various other indentation issues to make the + sources more consistent. + +2000-08-14 Marko Vendelin + + * src/frontends/gnome/dialogs/diaprint.glade + * src/frontends/gnome/FormPrint.C + * src/frontends/gnome/FormPrint.h + * src/frontends/gnome/diaprint_callbacks.c + * src/frontends/gnome/diaprint_callbacks.h + * src/frontends/gnome/diaprint_interface.c + * src/frontends/gnome/diaprint_interface.h: Print dialog Gnome + implementation + + * src/frontends/gnome/dialogs/diainserturl.glade + * src/frontends/gnome/FormUrl.C + * src/frontends/gnome/FormUrl.h + * src/frontends/gnome/diainserturl_callbacks.c + * src/frontends/gnome/diainserturl_callbacks.h + * src/frontends/gnome/diainserturl_interface.c + * src/frontends/gnome/diainserturl_interface.h: Insert Url dialog + Gnome implementation + + * src/frontends/gnome/Dialogs.C + * src/frontends/gnome/Makefile.am: added Print, Insert Url and all other + dialogs. Copy all unimplemented dialogs from Xforms frontend + + * src/frontends/gnome/support.c + * src/frontends/gnome/support.h: support files generated by Glade + + * autogen.sh + * configure.in + * config/gnome.m4: Gnome configuration scripts + + * config/lyxinclude.m4: cleanup: frontend renamed from gtk to gnome in + configure --help message + + * src/lyx_gui.C: Gnome/Gtk releases control in LyXGUI::runTime() only if + there are no events pendling in Gnome/Gtk. This enhances the performance of + menus. + + 2000-08-14 Allan Rae * lib/Makefile.am: listerrors cleaning diff --git a/autogen.sh b/autogen.sh index 41df2374e4..f915b16813 100755 --- a/autogen.sh +++ b/autogen.sh @@ -24,7 +24,7 @@ fi echo -n "Generate acinclude.m4... " rm -f acinclude.m4 sigc++/acinclude.m4 touch acinclude.m4 -for fil in config/lyxinclude.m4 config/libtool.m4 config/gettext.m4 config/lcmessage.m4 config/progtest.m4 config/sigc++.m4 config/kde.m4 config/gtk--.m4 config/gnome--.m4 ; do +for fil in config/lyxinclude.m4 config/libtool.m4 config/gettext.m4 config/lcmessage.m4 config/progtest.m4 config/sigc++.m4 config/kde.m4 config/gtk--.m4 config/gnome--.m4 config/gnome.m4 ; do cat $fil >> acinclude.m4 done touch sigc++/acinclude.m4 diff --git a/config/gnome.m4 b/config/gnome.m4 new file mode 100644 index 0000000000..fc7c91211c --- /dev/null +++ b/config/gnome.m4 @@ -0,0 +1,2498 @@ +# aclocal-include.m4 +# +# This macro adds the name macrodir to the set of directories +# that `aclocal' searches for macros. + +# serial 1 + +dnl AM_ACLOCAL_INCLUDE(macrodir) +AC_DEFUN([AM_ACLOCAL_INCLUDE], +[ + AM_CONDITIONAL(INSIDE_GNOME_COMMON, test x = y) + + test -n "$ACLOCAL_FLAGS" && ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS" + + for k in $1 ; do ACLOCAL="$ACLOCAL -I $k" ; done +]) +dnl GNOME_COMPILE_WARNINGS +dnl Turn on many useful compiler warnings +dnl For now, only works on GCC +AC_DEFUN([GNOME_COMPILE_WARNINGS],[ + AC_ARG_ENABLE(compile-warnings, + [ --enable-compile-warnings=[no/minimum/yes] Turn on compiler warnings.],,enable_compile_warnings=minimum) + + AC_MSG_CHECKING(what warning flags to pass to the C compiler) + warnCFLAGS= + if test "x$GCC" != xyes; then + enable_compile_warnings=no + fi + + if test "x$enable_compile_warnings" != "xno"; then + if test "x$GCC" = "xyes"; then + case " $CFLAGS " in + *[\ \ ]-Wall[\ \ ]*) ;; + *) warnCFLAGS="-Wall -Wunused" ;; + esac + + ## -W is not all that useful. And it cannot be controlled + ## with individual -Wno-xxx flags, unlike -Wall + if test "x$enable_compile_warnings" = "xyes"; then + warnCFLAGS="$warnCFLAGS -Wmissing-prototypes -Wmissing-declarations" + fi + fi + fi + AC_MSG_RESULT($warnCFLAGS) + + AC_ARG_ENABLE(iso-c, + [ --enable-iso-c Try to warn if code is not ISO C ],, + enable_iso_c=no) + + AC_MSG_CHECKING(what language compliance flags to pass to the C compiler) + complCFLAGS= + if test "x$enable_iso_c" != "xno"; then + if test "x$GCC" = "xyes"; then + case " $CFLAGS " in + *[\ \ ]-ansi[\ \ ]*) ;; + *) complCFLAGS="$complCFLAGS -ansi" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-pedantic[\ \ ]*) ;; + *) complCFLAGS="$complCFLAGS -pedantic" ;; + esac + fi + fi + AC_MSG_RESULT($complCFLAGS) + if test "x$cflags_set" != "xyes"; then + CFLAGS="$CFLAGS $warnCFLAGS $complCFLAGS" + cflags_set=yes + AC_SUBST(cflags_set) + fi +]) + +dnl For C++, do basically the same thing. + +AC_DEFUN([GNOME_CXX_WARNINGS],[ + AC_ARG_ENABLE(cxx-warnings, + [ --enable-cxx-warnings=[no/minimum/yes] Turn on compiler warnings.],,enable_cxx_warnings=minimum) + + AC_MSG_CHECKING(what warning flags to pass to the C++ compiler) + warnCXXFLAGS= + if test "x$GCC" != xyes; then + enable_compile_warnings=no + fi + if test "x$enable_cxx_warnings" != "xno"; then + if test "x$GCC" = "xyes"; then + case " $CXXFLAGS " in + *[\ \ ]-Wall[\ \ ]*) ;; + *) warnCXXFLAGS="-Wall -Wno-unused" ;; + esac + + ## -W is not all that useful. And it cannot be controlled + ## with individual -Wno-xxx flags, unlike -Wall + if test "x$enable_cxx_warnings" = "xyes"; then + warnCXXFLAGS="$warnCXXFLAGS -Wmissing-prototypes -Wmissing-declarations -Wshadow -Woverloaded-virtual" + fi + fi + fi + AC_MSG_RESULT($warnCXXFLAGS) + + AC_ARG_ENABLE(iso-cxx, + [ --enable-iso-cxx Try to warn if code is not ISO C++ ],, + enable_iso_cxx=no) + + AC_MSG_CHECKING(what language compliance flags to pass to the C++ compiler) + complCXXFLAGS= + if test "x$enable_iso_cxx" != "xno"; then + if test "x$GCC" = "xyes"; then + case " $CXXFLAGS " in + *[\ \ ]-ansi[\ \ ]*) ;; + *) complCXXFLAGS="$complCXXFLAGS -ansi" ;; + esac + + case " $CXXFLAGS " in + *[\ \ ]-pedantic[\ \ ]*) ;; + *) complCXXFLAGS="$complCXXFLAGS -pedantic" ;; + esac + fi + fi + AC_MSG_RESULT($complCXXFLAGS) + if test "x$cxxflags_set" != "xyes"; then + CXXFLAGS="$CXXFLAGS $warnCXXFLAGS $complCXXFLAGS" + cxxflags_set=yes + AC_SUBST(cxxflags_set) + fi +]) +dnl Curses detection: Munged from Midnight Commander's configure.in +dnl +dnl What it does: +dnl ============= +dnl +dnl - Determine which version of curses is installed on your system +dnl and set the -I/-L/-l compiler entries and add a few preprocessor +dnl symbols +dnl - Do an AC_SUBST on the CURSES_INCLUDEDIR and CURSES_LIBS so that +dnl @CURSES_INCLUDEDIR@ and @CURSES_LIBS@ will be available in +dnl Makefile.in's +dnl - Modify the following configure variables (these are the only +dnl curses.m4 variables you can access from within configure.in) +dnl CURSES_INCLUDEDIR - contains -I's and possibly -DRENAMED_CURSES if +dnl an ncurses.h that's been renamed to curses.h +dnl is found. +dnl CURSES_LIBS - sets -L and -l's appropriately +dnl CFLAGS - if --with-sco, add -D_SVID3 +dnl has_curses - exports result of tests to rest of configure +dnl +dnl Usage: +dnl ====== +dnl 1) Add lines indicated below to acconfig.h +dnl 2) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in +dnl 3) Instead of #include you should use the following to +dnl properly locate ncurses or curses header file +dnl +dnl #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES) +dnl #include +dnl #else +dnl #include +dnl #endif +dnl +dnl 4) Make sure to add @CURSES_INCLUDEDIR@ to your preprocessor flags +dnl 5) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS +dnl +dnl Notes with automake: +dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from +dnl configure.in +dnl - your Makefile.am can look something like this +dnl ----------------------------------------------- +dnl INCLUDES= blah blah blah $(CURSES_INCLUDEDIR) +dnl if HAS_CURSES +dnl CURSES_TARGETS=name_of_curses_prog +dnl endif +dnl bin_PROGRAMS = other_programs $(CURSES_TARGETS) +dnl other_programs_SOURCES = blah blah blah +dnl name_of_curses_prog_SOURCES = blah blah blah +dnl other_programs_LDADD = blah +dnl name_of_curses_prog_LDADD = blah $(CURSES_LIBS) +dnl ----------------------------------------------- +dnl +dnl +dnl The following lines should be added to acconfig.h: +dnl ================================================== +dnl +dnl /*=== Curses version detection defines ===*/ +dnl /* Found some version of curses that we're going to use */ +dnl #undef HAS_CURSES +dnl +dnl /* Use SunOS SysV curses? */ +dnl #undef USE_SUNOS_CURSES +dnl +dnl /* Use old BSD curses - not used right now */ +dnl #undef USE_BSD_CURSES +dnl +dnl /* Use SystemV curses? */ +dnl #undef USE_SYSV_CURSES +dnl +dnl /* Use Ncurses? */ +dnl #undef USE_NCURSES +dnl +dnl /* If you Curses does not have color define this one */ +dnl #undef NO_COLOR_CURSES +dnl +dnl /* Define if you want to turn on SCO-specific code */ +dnl #undef SCO_FLAVOR +dnl +dnl /* Set to reflect version of ncurses * +dnl * 0 = version 1.* +dnl * 1 = version 1.9.9g +dnl * 2 = version 4.0/4.1 */ +dnl #undef NCURSES_970530 +dnl +dnl /*=== End new stuff for acconfig.h ===*/ +dnl + + +AC_DEFUN(AC_CHECK_CURSES,[ + search_ncurses=true + screen_manager="" + has_curses=false + + CFLAGS=${CFLAGS--O} + + AC_SUBST(CURSES_LIBS) + AC_SUBST(CURSES_INCLUDEDIR) + + AC_ARG_WITH(sco, + [ --with-sco Use this to turn on SCO-specific code],[ + if test x$withval = xyes; then + AC_DEFINE(SCO_FLAVOR) + CFLAGS="$CFLAGS -D_SVID3" + fi + ]) + + AC_ARG_WITH(sunos-curses, + [ --with-sunos-curses Used to force SunOS 4.x curses],[ + if test x$withval = xyes; then + AC_USE_SUNOS_CURSES + fi + ]) + + AC_ARG_WITH(osf1-curses, + [ --with-osf1-curses Used to force OSF/1 curses],[ + if test x$withval = xyes; then + AC_USE_OSF1_CURSES + fi + ]) + + AC_ARG_WITH(vcurses, + [ --with-vcurses[=incdir] Used to force SysV curses], + if test x$withval != xyes; then + CURSES_INCLUDEDIR="-I$withval" + fi + AC_USE_SYSV_CURSES + ) + + AC_ARG_WITH(ncurses, + [ --with-ncurses[=dir] Compile with ncurses/locate base dir], + if test x$withval = xno ; then + search_ncurses=false + elif test x$withval != xyes ; then + CURSES_LIBS="$LIBS -L$withval/lib -lncurses" + CURSES_INCLUDEDIR="-I$withval/include" + search_ncurses=false + screen_manager="ncurses" + AC_DEFINE(USE_NCURSES) + AC_DEFINE(HAS_CURSES) + has_curses=true + fi + ) + + if $search_ncurses + then + AC_SEARCH_NCURSES() + fi + + +]) + + +AC_DEFUN(AC_USE_SUNOS_CURSES, [ + search_ncurses=false + screen_manager="SunOS 4.x /usr/5include curses" + AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses) + AC_DEFINE(USE_SUNOS_CURSES) + AC_DEFINE(HAS_CURSES) + has_curses=true + AC_DEFINE(NO_COLOR_CURSES) + AC_DEFINE(USE_SYSV_CURSES) + CURSES_INCLUDEDIR="-I/usr/5include" + CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a" + AC_MSG_RESULT(Please note that some screen refreshs may fail) +]) + +AC_DEFUN(AC_USE_OSF1_CURSES, [ + AC_MSG_RESULT(Using OSF1 curses) + search_ncurses=false + screen_manager="OSF1 curses" + AC_DEFINE(HAS_CURSES) + has_curses=true + AC_DEFINE(NO_COLOR_CURSES) + AC_DEFINE(USE_SYSV_CURSES) + CURSES_LIBS="-lcurses" +]) + +AC_DEFUN(AC_USE_SYSV_CURSES, [ + AC_MSG_RESULT(Using SysV curses) + AC_DEFINE(HAS_CURSES) + has_curses=true + AC_DEFINE(USE_SYSV_CURSES) + search_ncurses=false + screen_manager="SysV/curses" + CURSES_LIBS="-lcurses" +]) + +dnl AC_ARG_WITH(bsd-curses, +dnl [--with-bsd-curses Used to compile with bsd curses, not very fancy], +dnl search_ncurses=false +dnl screen_manager="Ultrix/cursesX" +dnl if test $system = ULTRIX +dnl then +dnl THIS_CURSES=cursesX +dnl else +dnl THIS_CURSES=curses +dnl fi +dnl +dnl CURSES_LIBS="-l$THIS_CURSES -ltermcap" +dnl AC_DEFINE(HAS_CURSES) +dnl has_curses=true +dnl AC_DEFINE(USE_BSD_CURSES) +dnl AC_MSG_RESULT(Please note that some screen refreshs may fail) +dnl AC_WARN(Use of the bsdcurses extension has some) +dnl AC_WARN(display/input problems.) +dnl AC_WARN(Reconsider using xcurses) +dnl) + + +dnl +dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename +dnl +AC_DEFUN(AC_NCURSES, [ + if $search_ncurses + then + if test -f $1/$2 + then + AC_MSG_RESULT(Found ncurses on $1/$2) + CURSES_LIBS="$3" + CURSES_INCLUDEDIR="$4" + search_ncurses=false + screen_manager=$5 + AC_DEFINE(HAS_CURSES) + has_curses=true + AC_DEFINE(USE_NCURSES) + fi + fi +]) + +AC_DEFUN(AC_SEARCH_NCURSES, [ + AC_CHECKING("location of ncurses.h file") + + AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include") + AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses") + AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local") + AC_NCURSES(/usr/local/include/ncurses, ncurses.h, -L/usr/local/lib -L/usr/local/lib/ncurses -lncurses, -I/usr/local/include/ncurses, "ncurses on /usr/local/include/ncurses") + + AC_NCURSES(/usr/local/include/ncurses, curses.h, -L/usr/local/lib -lncurses, -I/usr/local/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/local/.../ncurses") + + AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses") + + dnl + dnl We couldn't find ncurses, try SysV curses + dnl + if $search_ncurses + then + AC_EGREP_HEADER(init_color, /usr/include/curses.h, + AC_USE_SYSV_CURSES) + AC_EGREP_CPP(USE_NCURSES,[ +#include +#ifdef __NCURSES_H +#undef USE_NCURSES +USE_NCURSES +#endif +],[ + CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES" + AC_DEFINE(HAS_CURSES) + has_curses=true + AC_DEFINE(USE_NCURSES) + search_ncurses=false + screen_manager="ncurses installed as curses" +]) + fi + + dnl + dnl Try SunOS 4.x /usr/5{lib,include} ncurses + dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES + dnl should be replaced by a more fine grained selection routine + dnl + if $search_ncurses + then + if test -f /usr/5include/curses.h + then + AC_USE_SUNOS_CURSES + fi + else + # check for ncurses version, to properly ifdef mouse-fix + AC_MSG_CHECKING(for ncurses version) + ncurses_version=unknown +cat > conftest.$ac_ext < +#else +#include +#endif +#undef VERSION +VERSION:NCURSES_VERSION +EOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC | + egrep "VERSION:" >conftest.out 2>&1; then +changequote(,)dnl + ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'` +changequote([,])dnl + fi + rm -rf conftest* + AC_MSG_RESULT($ncurses_version) + case "$ncurses_version" in +changequote(,)dnl + 4.[01]) +changequote([,])dnl + AC_DEFINE(NCURSES_970530,2) + ;; + 1.9.9g) + AC_DEFINE(NCURSES_970530,1) + ;; + 1*) + AC_DEFINE(NCURSES_970530,0) + ;; + esac + fi +]) + + + + + +# Configure paths for Bonobo +# Miguel de Icaza, 99-04-12 +# Stolen from Chris Lahey 99-2-5 +# stolen from Manish Singh again +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_BONOBO ([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for Bonobo, and define BONOBO_CFLAGS and BONOBO_LIBS +dnl +AC_DEFUN([AM_PATH_BONOBO], +[ +dnl +dnl Get the cflags and libraries from the gnome-config script +dnl +AC_ARG_WITH(bonobo-prefix,[ --with-bonobo-prefix=PFX Prefix where Bonobo is installed (optional)], + bonobo_prefix="$withval", bonobo_prefix="") +AC_ARG_WITH(bonobo-exec-prefix,[ --with-bonobo-exec-prefix=PFX Exec prefix where Bonobo is installed (optional)], + bonobo_exec_prefix="$withval", bonobo_exec_prefix="") +AC_ARG_ENABLE(bonobotest, [ --disable-bonobotest Do not try to compile and run a test Bonobo program], + , enable_bonobotest=yes) + + if test x$bonobo_exec_prefix != x ; then + bonobo_args="$bonobo_args --exec-prefix=$bonobo_exec_prefix" + if test x${GNOME_CONFIG+set} != xset ; then + GNOME_CONFIG=$bonobo_exec_prefix/bin/gnome-config + fi + fi + if test x$bonobo_prefix != x ; then + bonobo_args="$bonobo_args --prefix=$bonobo_prefix" + if test x${GNOME_CONFIG+set} != xset ; then + GNOME_CONFIG=$bonobo_prefix/bin/gnome-config + fi + fi + + AC_PATH_PROG(GNOME_CONFIG, gnome-config, no) + min_bonobo_version=ifelse([$1], ,0.1.0,$1) + AC_MSG_CHECKING(for BONOBO - version >= $min_bonobo_version) + no_bonobo="" + if test "$GNOME_CONFIG" = "no" ; then + no_bonobo=yes + else + BONOBO_CFLAGS=`$GNOME_CONFIG $bonoboconf_args --cflags bonobo` + BONOBO_LIBS=`$GNOME_CONFIG $bonoboconf_args --libs bonobo` + + bonobo_major_version=`$GNOME_CONFIG $bonobo_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + bonobo_minor_version=`$GNOME_CONFIG $bonobo_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + bonobo_micro_version=`$GNOME_CONFIG $bonobo_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_bonobotest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $BONOBO_CFLAGS" + LIBS="$LIBS $BONOBO_LIBS" +dnl +dnl Now check if the installed BONOBO is sufficiently new. (Also sanity +dnl checks the results of gnome-config to some extent +dnl + rm -f conf.bonobotest + AC_TRY_RUN([ +#include +#include +#include +#include + +static char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.bonobotest"); + bonobo_object_get_type (); + return 0; +} + +],, no_bonobo=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_bonobo" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$GNOME_CONFIG" = "no" ; then + echo "*** The gnome-config script installed by GNOME-LIBS could not be found" + echo "*** If BONOBO was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the GNOME_CONFIG environment variable to the" + echo "*** full path to gnome-config." + else + if test -f conf.bonobotest ; then + : + else + echo "*** Could not run BONOBO test program, checking why..." + CFLAGS="$CFLAGS $BONOBO_CFLAGS" + LIBS="$LIBS $BONOBO_LIBS" + AC_TRY_LINK([ +#include +#include +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding BONOBO or finding the wrong" + echo "*** version of BONOBO. If it is not finding BONOBO, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means BONOBO was incorrectly installed" + echo "*** or that you have moved BONOBO since it was installed. In the latter case, you" + echo "*** may want to edit the gnome-config script: $GNOME_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + BONOBO_CFLAGS="" + BONOBO_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(BONOBO_CFLAGS) + AC_SUBST(BONOBO_LIBS) + rm -f conf.bonobotest +]) + +AC_DEFUN([BONOBO_CHECK], [ + AM_PATH_BONOBO(0.1.0,,[AC_MSG_ERROR(BONOBO not found)]) +]) + +# gnome-common.m4 +# +# This only for packages that are not in the GNOME CVS tree. + +dnl GNOME_COMMON_INIT + +AC_DEFUN([GNOME_COMMON_INIT], +[ + GNOME_ACLOCAL_DIR=`$ACLOCAL --print-ac-dir`/gnome + AC_SUBST(GNOME_ACLOCAL_DIR) + + ACLOCAL="$ACLOCAL -I $GNOME_ACLOCAL_DIR" +]) + +dnl +dnl GNOME_FILEUTILS_CHECKS +dnl +dnl checks that are needed for the diskusage applet. +dnl + +AC_DEFUN([GNOME_FILEUTILS_CHECKS], +[ +AC_CHECK_HEADERS(fcntl.h sys/param.h sys/statfs.h sys/fstyp.h \ +mnttab.h mntent.h sys/statvfs.h sys/vfs.h sys/mount.h \ +sys/filsys.h sys/fs_types.h sys/fs/s5param.h) + +AC_CHECK_FUNCS(bcopy endgrent endpwent fchdir ftime ftruncate \ +getcwd getmntinfo gettimeofday isascii lchown \ +listmntent memcpy mkfifo strchr strerror strrchr vprintf) + +dnl Set some defaults when cross-compiling + +if test x$cross_compiling = xyes ; then + case "$host_os" in + linux*) + fu_cv_sys_mounted_getmntent1=yes + fu_cv_sys_stat_statfs2_bsize=yes + ;; + sunos*) + fu_cv_sys_stat_statfs4=yes + ;; + freebsd*) + fu_cv_sys_stat_statfs2_bsize=yes + ;; + osf*) + fu_cv_sys_stat_statfs3_osf1=yes + ;; + esac +fi + +# Determine how to get the list of mounted filesystems. +list_mounted_fs= + +# If the getmntent function is available but not in the standard library, +# make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX). +AC_FUNC_GETMNTENT + +# This test must precede the ones for getmntent because Unicos-9 is +# reported to have the getmntent function, but its support is incompatible +# with other getmntent implementations. + +# NOTE: Normally, I wouldn't use a check for system type as I've done for +# `CRAY' below since that goes against the whole autoconf philosophy. But +# I think there is too great a chance that some non-Cray system has a +# function named listmntent to risk the false positive. + +if test -z "$list_mounted_fs"; then +# Cray UNICOS 9 +AC_MSG_CHECKING([for listmntent of Cray/Unicos-9]) +AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent, +[fu_cv_sys_mounted_cray_listmntent=no +AC_EGREP_CPP(yes, +[#ifdef _CRAY +yes +#endif +], [test $ac_cv_func_listmntent = yes \ +&& fu_cv_sys_mounted_cray_listmntent=yes] +) +] +) +AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent) +if test $fu_cv_sys_mounted_cray_listmntent = yes; then +list_mounted_fs=found +AC_DEFINE(MOUNTED_LISTMNTENT) +fi +fi + +if test $ac_cv_func_getmntent = yes; then + +# This system has the getmntent function. +# Determine whether it's the one-argument variant or the two-argument one. + +if test -z "$list_mounted_fs"; then +# 4.3BSD, SunOS, HP-UX, Dynix, Irix +AC_MSG_CHECKING([for one-argument getmntent function]) +AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1, +[test $ac_cv_header_mntent_h = yes \ +&& fu_cv_sys_mounted_getmntent1=yes \ +|| fu_cv_sys_mounted_getmntent1=no]) +AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1) +if test $fu_cv_sys_mounted_getmntent1 = yes; then +list_mounted_fs=found +AC_DEFINE(MOUNTED_GETMNTENT1) +fi +fi + +if test -z "$list_mounted_fs"; then +# SVR4 +AC_MSG_CHECKING([for two-argument getmntent function]) +AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2, +[AC_EGREP_HEADER(getmntent, sys/mnttab.h, +fu_cv_sys_mounted_getmntent2=yes, +fu_cv_sys_mounted_getmntent2=no)]) +AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2) +if test $fu_cv_sys_mounted_getmntent2 = yes; then +list_mounted_fs=found +AC_DEFINE(MOUNTED_GETMNTENT2) +fi +fi + +if test -z "$list_mounted_fs"; then +AC_MSG_ERROR([could not determine how to read list of mounted filesystems]) +fi + +fi + +if test -z "$list_mounted_fs"; then +# DEC Alpha running OSF/1. +AC_MSG_CHECKING([for getfsstat function]) +AC_CACHE_VAL(fu_cv_sys_mounted_getsstat, +[AC_TRY_LINK([ +#include +#include +#include ], +[struct statfs *stats; +int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ], +fu_cv_sys_mounted_getsstat=yes, +fu_cv_sys_mounted_getsstat=no)]) +AC_MSG_RESULT($fu_cv_sys_mounted_getsstat) +if test $fu_cv_sys_mounted_getsstat = yes; then +list_mounted_fs=found +AC_DEFINE(MOUNTED_GETFSSTAT) +fi +fi + +if test -z "$list_mounted_fs"; then +# AIX. +AC_MSG_CHECKING([for mntctl function and struct vmount]) +AC_CACHE_VAL(fu_cv_sys_mounted_vmount, +[AC_TRY_CPP([#include ], +fu_cv_sys_mounted_vmount=yes, +fu_cv_sys_mounted_vmount=no)]) +AC_MSG_RESULT($fu_cv_sys_mounted_vmount) +if test $fu_cv_sys_mounted_vmount = yes; then +list_mounted_fs=found +AC_DEFINE(MOUNTED_VMOUNT) +fi +fi + +if test -z "$list_mounted_fs"; then +# SVR3 +AC_MSG_CHECKING([for FIXME existence of three headers]) +AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp, +[AC_TRY_CPP([ +#include +#include +#include ], +fu_cv_sys_mounted_fread_fstyp=yes, +fu_cv_sys_mounted_fread_fstyp=no)]) +AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp) +if test $fu_cv_sys_mounted_fread_fstyp = yes; then +list_mounted_fs=found +AC_DEFINE(MOUNTED_FREAD_FSTYP) +fi +fi + +if test -z "$list_mounted_fs"; then +# 4.4BSD and DEC OSF/1. +AC_MSG_CHECKING([for getmntinfo function]) +AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo, +[ +ok= +if test $ac_cv_func_getmntinfo = yes; then +AC_EGREP_HEADER(f_type;, sys/mount.h, +ok=yes) +fi +test -n "$ok" \ +&& fu_cv_sys_mounted_getmntinfo=yes \ +|| fu_cv_sys_mounted_getmntinfo=no +]) +AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo) +if test $fu_cv_sys_mounted_getmntinfo = yes; then +list_mounted_fs=found +AC_DEFINE(MOUNTED_GETMNTINFO) +fi +fi + +# FIXME: add a test for netbsd-1.1 here + +if test -z "$list_mounted_fs"; then +# Ultrix +AC_MSG_CHECKING([for getmnt function]) +AC_CACHE_VAL(fu_cv_sys_mounted_getmnt, +[AC_TRY_CPP([ +#include +#include ], +fu_cv_sys_mounted_getmnt=yes, +fu_cv_sys_mounted_getmnt=no)]) +AC_MSG_RESULT($fu_cv_sys_mounted_getmnt) +if test $fu_cv_sys_mounted_getmnt = yes; then +list_mounted_fs=found +AC_DEFINE(MOUNTED_GETMNT) +fi +fi + +if test -z "$list_mounted_fs"; then +# SVR2 +AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab]) +AC_CACHE_VAL(fu_cv_sys_mounted_fread, +[AC_TRY_CPP([#include ], +fu_cv_sys_mounted_fread=yes, +fu_cv_sys_mounted_fread=no)]) +AC_MSG_RESULT($fu_cv_sys_mounted_fread) +if test $fu_cv_sys_mounted_fread = yes; then +list_mounted_fs=found +AC_DEFINE(MOUNTED_FREAD) +fi +fi + +if test -z "$list_mounted_fs"; then +AC_MSG_ERROR([could not determine how to read list of mounted filesystems]) +# FIXME -- no need to abort building the whole package +# Can't build mountlist.c or anything that needs its functions +fi + +AC_CHECKING(how to get filesystem space usage) +space=no + +# Perform only the link test since it seems there are no variants of the +# statvfs function. This check is more than just AC_CHECK_FUNCS(statvfs) +# because that got a false positive on SCO OSR5. Adding the declaration +# of a `struct statvfs' causes this test to fail (as it should) on such +# systems. That system is reported to work fine with STAT_STATFS4 which +# is what it gets when this test fails. +if test $space = no; then +# SVR4 +AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs, +[AC_TRY_LINK([#include +#include ], +[struct statvfs fsd; statvfs (0, &fsd);], +fu_cv_sys_stat_statvfs=yes, +fu_cv_sys_stat_statvfs=no)]) +if test $fu_cv_sys_stat_statvfs = yes; then +space=yes +AC_DEFINE(STAT_STATVFS) +fi +fi + +if test $space = no; then +# DEC Alpha running OSF/1 +AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) +AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1, +[AC_TRY_RUN([ +#include +#include +#include +main () +{ +struct statfs fsd; +fsd.f_fsize = 0; +exit (statfs (".", &fsd, sizeof (struct statfs))); +}], +fu_cv_sys_stat_statfs3_osf1=yes, +fu_cv_sys_stat_statfs3_osf1=no, +fu_cv_sys_stat_statfs3_osf1=no)]) +AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1) +if test $fu_cv_sys_stat_statfs3_osf1 = yes; then +space=yes +AC_DEFINE(STAT_STATFS3_OSF1) +fi +fi + +if test $space = no; then +# AIX +AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl +member (AIX, 4.3BSD)]) +AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize, +[AC_TRY_RUN([ +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_MOUNT_H +#include +#endif +#ifdef HAVE_SYS_VFS_H +#include +#endif +main () +{ +struct statfs fsd; +fsd.f_bsize = 0; +exit (statfs (".", &fsd)); +}], +fu_cv_sys_stat_statfs2_bsize=yes, +fu_cv_sys_stat_statfs2_bsize=no, +fu_cv_sys_stat_statfs2_bsize=no)]) +AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize) +if test $fu_cv_sys_stat_statfs2_bsize = yes; then +space=yes +AC_DEFINE(STAT_STATFS2_BSIZE) +fi +fi + +if test $space = no; then +# SVR3 +AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) +AC_CACHE_VAL(fu_cv_sys_stat_statfs4, +[AC_TRY_RUN([#include +#include +main () +{ +struct statfs fsd; +exit (statfs (".", &fsd, sizeof fsd, 0)); +}], +fu_cv_sys_stat_statfs4=yes, +fu_cv_sys_stat_statfs4=no, +fu_cv_sys_stat_statfs4=no)]) +AC_MSG_RESULT($fu_cv_sys_stat_statfs4) +if test $fu_cv_sys_stat_statfs4 = yes; then +space=yes +AC_DEFINE(STAT_STATFS4) +fi +fi + +if test $space = no; then +# 4.4BSD and NetBSD +AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl +member (4.4BSD and NetBSD)]) +AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize, +[AC_TRY_RUN([#include +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_MOUNT_H +#include +#endif +main () +{ +struct statfs fsd; +fsd.f_fsize = 0; +exit (statfs (".", &fsd)); +}], +fu_cv_sys_stat_statfs2_fsize=yes, +fu_cv_sys_stat_statfs2_fsize=no, +fu_cv_sys_stat_statfs2_fsize=no)]) +AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize) +if test $fu_cv_sys_stat_statfs2_fsize = yes; then +space=yes +AC_DEFINE(STAT_STATFS2_FSIZE) +fi +fi + +if test $space = no; then +# Ultrix +AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)]) +AC_CACHE_VAL(fu_cv_sys_stat_fs_data, +[AC_TRY_RUN([#include +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_MOUNT_H +#include +#endif +#ifdef HAVE_SYS_FS_TYPES_H +#include +#endif +main () +{ +struct fs_data fsd; +/* Ultrix's statfs returns 1 for success, +0 for not mounted, -1 for failure. */ +exit (statfs (".", &fsd) != 1); +}], +fu_cv_sys_stat_fs_data=yes, +fu_cv_sys_stat_fs_data=no, +fu_cv_sys_stat_fs_data=no)]) +AC_MSG_RESULT($fu_cv_sys_stat_fs_data) +if test $fu_cv_sys_stat_fs_data = yes; then +space=yes +AC_DEFINE(STAT_STATFS2_FS_DATA) +fi +fi + +if test $space = no; then +# SVR2 +AC_TRY_CPP([#include ], +AC_DEFINE(STAT_READ_FILSYS) space=yes) +fi + +if test -n "$list_mounted_fs" && test $space != no; then +DF_PROG="df" +# LIBOBJS="$LIBOBJS fsusage.o" +# LIBOBJS="$LIBOBJS mountlist.o" +fi + +# Check for SunOS statfs brokenness wrt partitions 2GB and larger. +# If exists and struct statfs has a member named f_spare, +# enable the work-around code in fsusage.c. +AC_MSG_CHECKING([for statfs that truncates block counts]) +AC_CACHE_VAL(fu_cv_sys_truncating_statfs, +[AC_TRY_COMPILE([ +#if !defined(sun) && !defined(__sun) +choke -- this is a workaround for a Sun-specific problem +#endif +#include +#include ], +[struct statfs t; long c = *(t.f_spare);], +fu_cv_sys_truncating_statfs=yes, +fu_cv_sys_truncating_statfs=no, +)]) +if test $fu_cv_sys_truncating_statfs = yes; then +AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS) +fi +AC_MSG_RESULT($fu_cv_sys_truncating_statfs) + +AC_CHECKING(for AFS) +test -d /afs && AC_DEFINE(AFS) +]) +AC_DEFUN([GNOME_GHTTP_CHECK],[ + AC_REQUIRE([GNOME_INIT_HOOK]) + GHTTP_LIB= + AC_CHECK_FUNC(connect,,[ + AC_CHECK_LIB(socket,connect, + GHTTP_LIB="-lsocket $GHTTP_LIB",,$GHTTP_LIB)]) + AC_CHECK_FUNC(gethostbyname,,[ + AC_CHECK_LIB(nsl,gethostbyname, + GHTTP_LIB="-lnsl $GHTTP_LIB",,$GHTTP_LIB)]) + AC_CHECK_LIB(ghttp, ghttp_request_new, + GHTTP_LIB="-lghttp $GHTTP_LIB",GHTTP_LIB="",-L$gnome_prefix $GHTTP_LIB) + AC_SUBST(GHTTP_LIB) + AC_PROVIDE([GNOME_GHTTP_CHECK]) +]) +dnl +dnl GNOME_GNORBA_HOOK (script-if-gnorba-found, failflag) +dnl +dnl if failflag is "failure" it aborts if gnorba is not found. +dnl + +AC_DEFUN([GNOME_GNORBA_HOOK],[ + GNOME_ORBIT_HOOK([],$2) + AC_CACHE_CHECK([for gnorba libraries],gnome_cv_gnorba_found,[ + gnome_cv_gnorba_found=no + if test x$gnome_cv_orbit_found = xyes; then + GNORBA_CFLAGS="`gnome-config --cflags gnorba gnomeui`" + GNORBA_LIBS="`gnome-config --libs gnorba gnomeui`" + if test -n "$GNORBA_LIBS"; then + gnome_cv_gnorba_found=yes + fi + fi + ]) + AM_CONDITIONAL(HAVE_GNORBA, test x$gnome_cv_gnorba_found = xyes) + if test x$gnome_cv_orbit_found = xyes; then + $1 + GNORBA_CFLAGS="`gnome-config --cflags gnorba gnomeui`" + GNORBA_LIBS="`gnome-config --libs gnorba gnomeui`" + AC_SUBST(GNORBA_CFLAGS) + AC_SUBST(GNORBA_LIBS) + else + if test x$2 = xfailure; then + AC_MSG_ERROR(gnorba library not installed or installation problem) + fi + fi +]) + +AC_DEFUN([GNOME_GNORBA_CHECK], [ + GNOME_GNORBA_HOOK([],failure) +]) +dnl +dnl GNOME_CHECK_GUILE (failflag) +dnl +dnl if failflag is "fail" then GNOME_CHECK_GUILE will abort if guile is not found. +dnl + +AC_DEFUN([GNOME_CHECK_GUILE], +[ + saved_ldflags="$LDFLAGS" + saved_cppflags="$CPPFLAGS" + LDFLAGS="$LDFLAGS $GNOME_LIBDIR" + + AC_CHECK_LIB(qthreads,qt_null,[ + QTTHREADS_LIB="-lqthreads" + ],[ + AC_CHECK_LIB(qt, qt_null, QTTHREADS_LIB="-lqt") + ],$LIBS) + AC_SUBST(QTTHREADS_LIB) + + AC_CHECK_LIB(termcap,main,TERMCAP_LIB="-ltermcap") + AC_CHECK_LIB(readline,main,READLINE_LIB="-lreadline",,$TERMCAP_LIB) + + AC_SUBST(TERMCAP_LIB) + AC_SUBST(READLINE_LIB) + + if test "x$cross_compiling" = "xyes" ; then + name_build_guile="$target_alias-guile-config" + else + name_build_guile="guile-config" + fi + + AC_CHECK_PROG(BUILD_GUILE, $name_build_guile, yes, no) + + if test "x$BUILD_GUILE" = "xyes"; then + AC_MSG_CHECKING(whether $name_build_guile works) + if test x`$name_build_guile --version >/dev/null 2>&1 || \ + echo no` = xno; then + BUILD_GUILE=no + fi + AC_MSG_RESULT($BUILD_GUILE) + else + + if test "x$cross_compiling" = "xyes" ; then + name_build_guile="$target_alias-build-guile" + else + name_build_guile="build-guile" + fi + + AC_CHECK_PROG(BUILD_GUILE, $name_build_guile, yes, no) + + if test "x$BUILD_GUILE" = "xyes"; then + AC_MSG_CHECKING(whether $name_build_guile works) + if test x`$name_build_guile --version >/dev/null 2>&1 || \ + echo no` = xno; then + BUILD_GUILE=no + fi + AC_MSG_RESULT($BUILD_GUILE) + fi + fi + + AC_CHECK_LIB(m, sin) + + if test "x$BUILD_GUILE" = "xyes"; then + AC_MSG_CHECKING(for guile libraries) + GUILE_LIBS="`$name_build_guile link`" + AC_MSG_RESULT($GUILE_LIBS) + AC_MSG_CHECKING(for guile headers) + GUILE_INCS="`$name_build_guile compile`" + AC_MSG_RESULT($GUILE_INCS) + else + GUILE_LIBS="$GNOME_LIBDIR" + GUILE_INCS="$GNOME_INCLUDEDIR" + AC_CHECK_LIB(rx, main, GUILE_LIBS="-lrx $GUILE_LIBS") + AC_CHECK_LIB(qt, qt_null, GUILE_LIBS="-lqt $GUILE_LIBS") + AC_CHECK_LIB(dl, dlopen, GUILE_LIBS="-ldl $GUILE_LIBS") + AC_CHECK_LIB(nsl, t_accept, GUILE_LIBS="$GUILE_LIBS -lnsl") + AC_CHECK_LIB(socket, socket, GUILE_LIBS="$GUILE_LIBS -lsocket") + GUILE_LIBS="-lguile $GUILE_LIBS $QTTHREADS_LIB $READLINE_LIB $TERMCAP_LIB" + fi + + AC_SUBST(GUILE_LIBS) + AC_SUBST(GUILE_INCS) + + saved_LIBS="$LIBS" + LIBS="$LIBS $GUILE_LIBS" + CPPFLAGS="$saved_cppflags $GUILE_INCS" + + AC_MSG_CHECKING(whether guile works) + AC_TRY_LINK([ + #include + #include + ],[ + gh_eval_str("(newline)"); + scm_boot_guile(0,NULL,NULL,NULL); + ],[ + ac_cv_guile_found=yes + AC_DEFINE(HAVE_GUILE) + ],[ + ac_cv_guile_found=no + ]) + AC_MSG_RESULT($ac_cv_guile_found) + + if test x$ac_cv_guile_found = xno ; then + if test x$1 = xfail ; then + AC_MSG_ERROR(Can not find Guile on this system) + else + AC_MSG_WARN(Can not find Guile on this system) + fi + ac_cv_guile_found=no + GUILE_LIBS= GUILE_INCS= + fi + + LIBS="$saved_LIBS" + LDFLAGS="$saved_ldflags" + CPPFLAGS="$saved_cppflags" + + AC_SUBST(GUILE_LIBS) + AM_CONDITIONAL(GUILE, test x$ac_cv_guile_found = xyes) +]) +dnl +dnl LIBGTOP_CHECK_TYPE +dnl +dnl Improved version of AC_CHECK_TYPE which takes into account +dnl that we need to #include some other header files on some +dnl systems to get some types. + +dnl AC_LIBGTOP_CHECK_TYPE(TYPE, DEFAULT) +AC_DEFUN(AC_LIBGTOP_CHECK_TYPE, +[AC_REQUIRE([AC_HEADER_STDC])dnl +AC_MSG_CHECKING(for $1) +AC_CACHE_VAL(ac_cv_type_$1, +[AC_EGREP_CPP(dnl +changequote(<<,>>)dnl +<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl +changequote([,]), [#include +#if STDC_HEADERS +#include +#include +#endif + +/* For Tru64 */ +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl +AC_MSG_RESULT($ac_cv_type_$1) +if test $ac_cv_type_$1 = no; then + AC_DEFINE($1, $2) +fi +]) + +dnl +dnl GNOME_LIBGTOP_TYPES +dnl +dnl some typechecks for libgtop. +dnl + +AC_DEFUN([GNOME_LIBGTOP_TYPES], +[ + AC_CHECK_HEADERS(sys/bitypes.h) + AC_LIBGTOP_CHECK_TYPE(u_int64_t, unsigned long long int) + AC_LIBGTOP_CHECK_TYPE(int64_t, signed long long int) +]) + +dnl +dnl GNOME_LIBGTOP_HOOK (minversion, script-if-libgtop-enabled, failflag) +dnl +dnl if failflag is "fail" then GNOME_LIBGTOP_HOOK will abort if LibGTop +dnl is not found. +dnl + +AC_DEFUN([GNOME_LIBGTOP_HOOK], +[ + AC_REQUIRE([GNOME_LIBGTOP_TYPES]) + + AC_SUBST(LIBGTOP_LIBDIR) + AC_SUBST(LIBGTOP_INCLUDEDIR) + AC_SUBST(LIBGTOP_EXTRA_LIBS) + AC_SUBST(LIBGTOP_LIBS) + AC_SUBST(LIBGTOP_INCS) + AC_SUBST(LIBGTOP_NAMES_LIBS) + AC_SUBST(LIBGTOP_NAMES_INCS) + AC_SUBST(LIBGTOP_MAJOR_VERSION) + AC_SUBST(LIBGTOP_MINOR_VERSION) + AC_SUBST(LIBGTOP_MICRO_VERSION) + AC_SUBST(LIBGTOP_VERSION) + AC_SUBST(LIBGTOP_VERSION_CODE) + AC_SUBST(LIBGTOP_SERVER_VERSION) + AC_SUBST(LIBGTOP_INTERFACE_AGE) + AC_SUBST(LIBGTOP_BINARY_AGE) + AC_SUBST(LIBGTOP_BINDIR) + AC_SUBST(LIBGTOP_SERVER) + + dnl Get the cflags and libraries from the libgtop-config script + dnl + AC_ARG_WITH(libgtop, + [ --with-libgtop=PFX Prefix where LIBGTOP is installed (optional)], + libgtop_config_prefix="$withval", libgtop_config_prefix="") + AC_ARG_WITH(libgtop-exec, + [ --with-libgtop-exec=PFX Exec prefix where LIBGTOP is installed (optional)], + libgtop_config_exec_prefix="$withval", libgtop_config_exec_prefix="") + + if test x$libgtop_config_exec_prefix != x ; then + libgtop_config_args="$libgtop_config_args --exec-prefix=$libgtop_config_exec_prefix" + if test x${LIBGTOP_CONFIG+set} != xset ; then + LIBGTOP_CONFIG=$libgtop_config_exec_prefix/bin/libgtop-config + fi + fi + if test x$libgtop_config_prefix != x ; then + libgtop_config_args="$libgtop_config_args --prefix=$libgtop_config_prefix" + if test x${LIBGTOP_CONFIG+set} != xset ; then + LIBGTOP_CONFIG=$libgtop_config_prefix/bin/libgtop-config + fi + fi + + AC_PATH_PROG(LIBGTOP_CONFIG, libgtop-config, no) + dnl IMPORTANT NOTICE: + dnl If you increase this number here, this means that *ALL* + dnl modules will require the new version, even if they explicitly + dnl give a lower number in their `configure.in' !!! + real_min_libgtop_version=1.0.0 + min_libgtop_version=ifelse([$1], ,$real_min_libgtop_version,$1) + dnl I know, the following code looks really ugly, but if you want + dnl to make changes, please test it with a brain-dead /bin/sh and + dnl with a brain-dead /bin/test (not all shells/tests support the + dnl `<' operator to compare strings, that's why I convert everything + dnl into numbers and test them). + min_libgtop_major=`echo $min_libgtop_version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + min_libgtop_minor=`echo $min_libgtop_version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + min_libgtop_micro=`echo $min_libgtop_version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + test x$min_libgtop_micro = x && min_libgtop_micro=0 + real_min_libgtop_major=`echo $real_min_libgtop_version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + real_min_libgtop_minor=`echo $real_min_libgtop_version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + real_min_libgtop_micro=`echo $real_min_libgtop_version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + test x$real_min_libgtop_micro = x && real_min_libgtop_micro=0 + dnl You cannot require a version less then $real_min_libgtop_version, + dnl so you don't need to update each `configure.in' when it's increased. + if test $real_min_libgtop_major -gt $min_libgtop_major ; then + min_libgtop_major=$real_min_libgtop_major + min_libgtop_minor=$real_min_libgtop_minor + min_libgtop_micro=$real_min_libgtop_micro + elif test $real_min_libgtop_major = $min_libgtop_major ; then + if test $real_min_libgtop_minor -gt $min_libgtop_minor ; then + min_libgtop_minor=$real_min_libgtop_minor + min_libgtop_micro=$real_min_libgtop_micro + elif test $real_min_libgtop_minor = $min_libgtop_minor ; then + if test $real_min_libgtop_micro -gt $min_libgtop_micro ; then + min_libgtop_micro=$real_min_libgtop_micro + fi + fi + fi + min_libgtop_version="$min_libgtop_major.$min_libgtop_minor.$min_libgtop_micro" + AC_MSG_CHECKING(for libgtop - version >= $min_libgtop_version) + no_libgtop="" + if test "$LIBGTOP_CONFIG" = "no" ; then + no_libgtop=yes + else + configfile=`$LIBGTOP_CONFIG --config` + libgtop_major_version=`$LIBGTOP_CONFIG --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + libgtop_minor_version=`$LIBGTOP_CONFIG --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + libgtop_micro_version=`$LIBGTOP_CONFIG --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test $libgtop_major_version != $min_libgtop_major ; then + no_libgtop=mismatch + else + test $libgtop_minor_version -lt $min_libgtop_minor && no_libgtop=yes + if test $libgtop_minor_version = $min_libgtop_minor ; then + test $libgtop_micro_version -lt $min_libgtop_micro && no_libgtop=yes + fi + fi + . $configfile + fi + if test x$no_libgtop = x ; then + AC_DEFINE(HAVE_LIBGTOP) + AC_DEFINE_UNQUOTED(LIBGTOP_VERSION, "$LIBGTOP_VERSION") + AC_DEFINE_UNQUOTED(LIBGTOP_VERSION_CODE, $LIBGTOP_VERSION_CODE) + AC_DEFINE_UNQUOTED(LIBGTOP_MAJOR_VERSION, $LIBGTOP_MAJOR_VERSION) + AC_DEFINE_UNQUOTED(LIBGTOP_MINOR_VERSION, $LIBGTOP_MINOR_VERSION) + AC_DEFINE_UNQUOTED(LIBGTOP_MICRO_VERSION, $LIBGTOP_MICRO_VERSION) + AC_DEFINE_UNQUOTED(LIBGTOP_SERVER_VERSION, $LIBGTOP_SERVER_VERSION) + AC_MSG_RESULT(yes) + dnl Note that an empty true branch is not valid sh syntax. + ifelse([$2], [], :, [$2]) + else + AC_MSG_RESULT(no) + if test "$no_libgtop"x = mismatchx; then + AC_MSG_ERROR(LibGTop major version mismatch $libgtop_major_version != $min_libgtop_major) + fi + if test "x$3" = "xfail"; then + AC_MSG_ERROR(LibGTop >= $min_libgtop_version not found) + else + AC_MSG_WARN(LibGTop >= $min_libgtop_version not found) + fi + fi + + AM_CONDITIONAL(HAVE_LIBGTOP, test x$no_libgtop != xyes) +]) + +AC_DEFUN([GNOME_INIT_LIBGTOP],[ + GNOME_LIBGTOP_HOOK($1,[ifelse([$3], [], :, [$3])],$2) +]) + +dnl +dnl GNOME_LIBGTOP_DOCU +dnl +dnl checks whether the documentation of LibGTop is installed +dnl + +AC_DEFUN([GNOME_LIBGTOP_DOCU], +[ + AC_REQUIRE([GNOME_LIBGTOP_HOOK]) + + helpdir="$LIBGTOP_DATADIR/gnome/help/libgtop" + + AC_MSG_CHECKING(whether you have the LibGTop Documentation) + + if test -f "$helpdir/C/topic.dat" ; then + have_libgtop_docu=yes + AC_DEFINE(HAVE_LIBGTOP_DOCU) + else + have_libgtop_docu=no + fi + + AC_MSG_RESULT($have_libgtop_docu) + + AM_CONDITIONAL(HAVE_LIBGTOP_DOCU, test x$have_libgtop_docu = xyes) +]) + +AC_DEFUN([GNOME_CHECK_OBJC], +[ +dnl Look for an ObjC compiler. +dnl FIXME: extend list of possible names of ObjC compilers. + AC_CHECK_PROGS(OBJC, $OBJC egcs, "") + if test "x$OBJC" = "x" ; then + AC_CHECK_PROGS(OBJC, $OBJC egcc, "") + if test "x$OBJC" = "x" ; then + AC_CHECK_PROGS(OBJC, $OBJC gcc, "") + fi + fi + + AC_REQUIRE([GNOME_PTHREAD_CHECK]) + + OBJC_LIBS="-lobjc $PTHREAD_LIB" + AC_CHECK_FUNC(sched_yield,,[ + AC_CHECK_LIB(rt,sched_yield, + OBJC_LIBS="$OBJC_LIBS -lrt",[ + AC_CHECK_LIB(posix4,sched_yield, + OBJC_LIBS="$OBJC_LIBS -lposix4",, + $OBJC_LIBS)], + $OBJC_LIBS)]) + AC_SUBST(OBJC_LIBS) + + AC_CACHE_CHECK([if Objective C compiler ($OBJC) works], + ac_cv_prog_objc_works, [ + if test -n "$OBJC"; then + cat > conftest.m < +@interface myRandomObj : Object +{ +} +@end +@implementation myRandomObj +@end +int main () { + /* No, you are not seeing double. Remember that square brackets + are the autoconf m4 quotes. */ + id myid = [[myRandomObj alloc]]; + [[myid free]]; + return 0; +} +EOF + + $OBJC $CFLAGS -o conftest $LDFLAGS conftest.m $OBJC_LIBS 1>&AC_FD_CC 2>&1 + result=$? + rm -f conftest* + + if test $result -eq 0; then + ac_cv_prog_objc_works=yes + fi + else + ac_cv_prog_objc_works=no + fi + ]) + + AM_CONDITIONAL(OBJECTIVE_C, test x$ac_cv_prog_objc_works = xyes) + dnl Also set the shell variable OBJECTIVE_C to "yes" or "no". + OBJECTIVE_C=$ac_cv_prog_objc_works +]) + +AC_DEFUN([GNOME_INIT_OBJC], +[ + AC_MSG_CHECKING(for an obGnomeConf.sh) + my_gnome_libdir=`$GNOME_CONFIG --libdir` + if test -f $my_gnome_libdir/obGnomeConf.sh; then + . $my_gnome_libdir/obGnomeConf.sh + AC_MSG_RESULT(found $my_gnome_libdir) + ac_cv_have_gnome_objc=yes + else + AC_MSG_RESULT(not found) + AC_MSG_WARN(Could not find the obGnomeConf.sh file that is generated by gnome-objc install) + ac_cv_have_gnome_objc=no + fi + + dnl Add a conditional on whether or not we have gnome-objc + AM_CONDITIONAL(HAVE_GNOME_OBJC, test x$ac_cv_have_gnome_objc = xyes) + HAVE_GNOME_OBJC=$ac_cv_have_gnome_objc + + AC_SUBST(OBGNOME_INCLUDEDIR) + AC_SUBST(OBGNOME_LIBS) + AC_SUBST(OBGTK_LIBS) +]) +dnl +dnl GNOME_ORBIT_HOOK (script-if-orbit-found, failflag) +dnl +dnl if failflag is "failure" it aborts if orbit is not found. +dnl + +AC_DEFUN([GNOME_ORBIT_HOOK],[ + AC_PATH_PROG(ORBIT_CONFIG,orbit-config,no) + AC_PATH_PROG(ORBIT_IDL,orbit-idl,no) + AC_CACHE_CHECK([for working ORBit environment],gnome_cv_orbit_found,[ + if test x$ORBIT_CONFIG = xno -o x$ORBIT_IDL = xno; then + gnome_cv_orbit_found=no + else + gnome_cv_orbit_found=yes + fi + ]) + AM_CONDITIONAL(HAVE_ORBIT, test x$gnome_cv_orbit_found = xyes) + if test x$gnome_cv_orbit_found = xyes; then + $1 + ORBIT_CFLAGS=`orbit-config --cflags client server` + ORBIT_LIBS=`orbit-config --use-service=name --libs client server` + AC_SUBST(ORBIT_CFLAGS) + AC_SUBST(ORBIT_LIBS) + else + if test x$2 = xfailure; then + AC_MSG_ERROR(ORBit not installed or installation problem) + fi + fi +]) + +AC_DEFUN([GNOME_ORBIT_CHECK], [ + GNOME_ORBIT_HOOK([],failure) +]) +# Configure paths for GNOME-PRINT +# Chris Lahey 99-2-5 +# stolen from Manish Singh again +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_GNOME_PRINT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for GNOME-PRINT, and define GNOME_PRINT_CFLAGS and GNOME_PRINT_LIBS +dnl +AC_DEFUN(AM_PATH_GNOME_PRINT, +[dnl +dnl Get the cflags and libraries from the gnome-config script +dnl +AC_ARG_WITH(gnome-print-prefix,[ --with-gnome-print-prefix=PFX Prefix where GNOME-PRINT is installed (optional)], + gnome_print_prefix="$withval", gnome_print_prefix="") +AC_ARG_WITH(gnome-print-exec-prefix,[ --with-gnome-print-exec-prefix=PFX Exec prefix where GNOME-PRINT is installed (optional)], + gnome_print_exec_prefix="$withval", gnome_print_exec_prefix="") +AC_ARG_ENABLE(gnome-printtest, [ --disable-gnome-printtest Do not try to compile and run a test GNOME-PRINT program], + , enable_gnome_printtest=yes) + + if test x$gnome_print_exec_prefix != x ; then + gnome_print_args="$gnome_print_args --exec-prefix=$gnome_print_exec_prefix" + if test x${GNOME_CONFIG+set} != xset ; then + GNOME_CONFIG=$gnome_print_exec_prefix/bin/gnome-config + fi + fi + if test x$gnome_print_prefix != x ; then + gnome_print_args="$gnome_print_args --prefix=$gnome_print_prefix" + if test x${GNOME_CONFIG+set} != xset ; then + GNOME_CONFIG=$gnome_print_prefix/bin/gnome-config + fi + fi + + AC_PATH_PROG(GNOME_CONFIG, gnome-config, no) + min_gnome_print_version=ifelse([$1], ,0.1.0,$1) + AC_MSG_CHECKING(for GNOME-PRINT - version >= $min_gnome_print_version) + no_gnome_print="" + if test "$GNOME_CONFIG" = "no" ; then + no_gnome_print=yes + else + GNOME_PRINT_CFLAGS=`$GNOME_CONFIG $gnome_printconf_args --cflags print` + GNOME_PRINT_LIBS=`$GNOME_CONFIG $gnome_printconf_args --libs print` + + gnome_print_major_version=`$GNOME_CONFIG $gnome_print_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + gnome_print_minor_version=`$GNOME_CONFIG $gnome_print_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + gnome_print_micro_version=`$GNOME_CONFIG $gnome_print_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_gnome_printtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GNOME_PRINT_CFLAGS" + LIBS="$LIBS $GNOME_PRINT_LIBS" +dnl +dnl Now check if the installed GNOME-PRINT is sufficiently new. (Also sanity +dnl checks the results of gnome-config to some extent +dnl + rm -f conf.gnome_printtest + AC_TRY_RUN([ +#include +#include +#include +#include + +static char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.gnome_printtest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_gnome_print_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_gnome_print_version"); + exit(1); + } + return 0; +#if 0 + if (($gnome_print_major_version > major) || + (($gnome_print_major_version == major) && ($gnome_print_minor_version > minor)) || + (($gnome_print_major_version == major) && ($gnome_print_minor_version == minor) && ($gnome_print_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'gnome-config print --version' returned %d.%d.%d, but the minimum version\n", $gnome_print_major_version, $gnome_print_minor_version, $gnome_print_micro_version); + printf("*** of GNOME-PRINT required is %d.%d.%d. If gnome-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If gnome-config was wrong, set the environment variable GNOME_CONFIG\n"); + printf("*** to point to the correct copy of gnome-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +#endif +} + +],, no_gnome_print=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_gnome_print" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$GNOME_CONFIG" = "no" ; then + echo "*** The gnome-config script installed by GNOME-LIBS could not be found" + echo "*** If GNOME-PRINT was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the GNOME_CONFIG environment variable to the" + echo "*** full path to gnome-config." + else + if test -f conf.gnome_printtest ; then + : + else + echo "*** Could not run GNOME-PRINT test program, checking why..." + CFLAGS="$CFLAGS $GNOME_PRINT_CFLAGS" + LIBS="$LIBS $GNOME_PRINT_LIBS" + AC_TRY_LINK([ +#include +#include +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GNOME-PRINT or finding the wrong" + echo "*** version of GNOME-PRINT. If it is not finding GNOME-PRINT, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GNOME-PRINT was incorrectly installed" + echo "*** or that you have moved GNOME-PRINT since it was installed. In the latter case, you" + echo "*** may want to edit the gnome-config script: $GNOME_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GNOME_PRINT_CFLAGS="" + GNOME_PRINT_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GNOME_PRINT_CFLAGS) + AC_SUBST(GNOME_PRINT_LIBS) + rm -f conf.gnome_printtest +]) + +AC_DEFUN([GNOME_PRINT_CHECK], [ + AM_PATH_GNOME_PRINT(0.1.0,,[AC_MSG_ERROR(GNOME-PRINT not found)]) +]) +dnl +dnl And better, use gthreads instead... +dnl + +AC_DEFUN([GNOME_PTHREAD_CHECK],[ + PTHREAD_LIB="" + AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIB="-lpthread", + [AC_CHECK_LIB(pthreads, pthread_create, PTHREAD_LIB="-lpthreads", + [AC_CHECK_LIB(c_r, pthread_create, PTHREAD_LIB="-lc_r", + [AC_CHECK_FUNC(pthread_create)] + )] + )] + ) + AC_SUBST(PTHREAD_LIB) + AC_PROVIDE([GNOME_PTHREAD_CHECK]) +]) +dnl GNOME_SUPPORT_CHECKS +dnl Check for various support functions needed by the standard +dnl Gnome libraries. Sets LIBOBJS, might define some macros. +dnl This should only be used when building the Gnome libs; +dnl Gnome clients should not need this macro. +AC_DEFUN([GNOME_SUPPORT_CHECKS],[ + # we need an `awk' to build `gnomesupport.h' + AC_REQUIRE([AC_PROG_AWK]) + + # this should go away soon + need_gnome_support=yes + + save_LIBOBJS="$LIBOBJS" + LIBOBJS= + + AC_CHECK_FUNCS(getopt_long,,LIBOBJS="$LIBOBJS getopt.o getopt1.o") + + # for `scandir' + AC_HEADER_DIRENT + + # copied from `configure.in' of `libiberty' + vars="program_invocation_short_name program_invocation_name sys_errlist" + for v in $vars; do + AC_MSG_CHECKING([for $v]) + AC_CACHE_VAL(gnome_cv_var_$v, + [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;], + [eval "gnome_cv_var_$v=yes"], + [eval "gnome_cv_var_$v=no"])]) + if eval "test \"`echo '$gnome_cv_var_'$v`\" = yes"; then + AC_MSG_RESULT(yes) + n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + AC_DEFINE_UNQUOTED($n) + else + AC_MSG_RESULT(no) + fi + done + + AC_REPLACE_FUNCS(memmove mkstemp scandir strcasecmp strerror strndup strnlen) + AC_REPLACE_FUNCS(strtok_r strtod strtol strtoul vasprintf vsnprintf) + + AC_CHECK_FUNCS(realpath,,LIBOBJS="$LIBOBJS canonicalize.o") + + # to include `error.c' error.c has some HAVE_* checks + AC_CHECK_FUNCS(vprintf doprnt strerror_r) + AM_FUNC_ERROR_AT_LINE + + # This is required if we declare setreuid () and setregid (). + AC_TYPE_UID_T + + # see if we need to declare some functions. Solaris is notorious for + # putting functions into the `libc' but not listing them in the headers + AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h dirent.h) + GCC_NEED_DECLARATIONS(gethostname setreuid setregid getpagesize) + GCC_NEED_DECLARATION(scandir,[ +#ifdef HAVE_DIRENT_H +#include +#endif +]) + + # Turn our LIBOBJS into libtool objects. This is gross, but it + # requires changes to autoconf before it goes away. + LTLIBOBJS=`echo "$LIBOBJS" | sed 's/\.o/.lo/g'` + AC_SUBST(need_gnome_support) + AC_SUBST(LTLIBOBJS) + + LIBOBJS="$save_LIBOBJS" + AM_CONDITIONAL(BUILD_GNOME_SUPPORT, test "$need_gnome_support" = yes) +]) +dnl GNOME_UNDELFS_CHECKS +dnl Check for ext2fs undel support. +dnl Set shell variable ext2fs_undel to "yes" if we have it, +dnl "no" otherwise. May define USE_EXT2FSLIB for cpp. +dnl Will set EXT2FS_UNDEL_LIBS to required libraries. + +AC_DEFUN([GNOME_UNDELFS_CHECKS], [ + AC_CHECK_HEADERS(ext2fs/ext2fs.h linux/ext2_fs.h) + ext2fs_undel=no + EXT2FS_UNDEL_LIBS= + if test x$ac_cv_header_ext2fs_ext2fs_h = xyes + then + if test x$ac_cv_header_linux_ext2_fs_h = xyes + then + AC_DEFINE(USE_EXT2FSLIB) + ext2fs_undel=yes + EXT2FS_UNDEL_LIBS="-lext2fs -lcom_err" + fi + fi +]) +dnl GNOME_VFS_CHECKS +dnl Check for various functions needed by libvfs. +dnl This has various effects: +dnl Sets GNOME_VFS_LIBS to libraries required +dnl Sets termnet to true or false depending on whether it is required. +dnl If yes, defines USE_TERMNET. +dnl Sets vfs_flags to "pretty" list of vfs implementations we include. +dnl Sets shell variable use_vfs to yes (default, --with-vfs) or +dnl "no" (--without-vfs). +dnl Calls AC_SUBST(mcserv), which is either empty or "mcserv". + +dnl Private define +AC_DEFUN([GNOME_WITH_VFS],[ + dnl FIXME: network checks should probably be in their own macro. + AC_CHECK_LIB(nsl, t_accept) + AC_CHECK_LIB(socket, socket) + + have_socket=no + AC_CHECK_FUNCS(socket, have_socket=yes) + if test $have_socket = no; then + # socket is not in the default libraries. See if it's in some other. + for lib in bsd socket inet; do + AC_CHECK_LIB($lib, socket, [ + LIBS="$LIBS -l$lib" + have_socket=yes + AC_DEFINE(HAVE_SOCKET) + break]) + done + fi + + have_gethostbyname=no + AC_CHECK_FUNC(gethostbyname, have_gethostbyname=yes) + if test $have_gethostbyname = no; then + # gethostbyname is not in the default libraries. See if it's in some other. + for lib in bsd socket inet; do + AC_CHECK_LIB($lib, gethostbyname, [LIBS="$LIBS -l$lib"; have_gethostbyname=yes; break]) + done + fi + + vfs_flags="tarfs" + use_net_code=false + if test $have_socket = yes; then + AC_STRUCT_LINGER + AC_CHECK_FUNCS(pmap_set, , [ + AC_CHECK_LIB(rpc, pmap_set, [ + LIBS="-lrpc $LIBS" + AC_DEFINE(HAVE_PMAP_SET) + ])]) + AC_CHECK_FUNCS(pmap_getport pmap_getmaps rresvport) + dnl add for source routing support setsockopt + AC_CHECK_HEADERS(rpc/pmap_clnt.h) + vfs_flags="$vfs_flags, mcfs, ftpfs, fish" + use_net_code=true + fi + + dnl + dnl Samba support + dnl + smbfs="" + SAMBAFILES="" + AC_ARG_WITH(samba, + [--with-samba Support smb virtual file system],[ + if test "x$withval != xno"; then + AC_DEFINE(WITH_SMBFS) + vfs_flags="$vfs_flags, smbfs" + smbfs="smbfs.o" + SAMBAFILES="\$(SAMBAFILES)" + fi + ]) + AC_SUBST(smbfs) + AC_SUBST(SAMBAFILES) + + dnl + dnl The termnet support + dnl + termnet=false + AC_ARG_WITH(termnet, + [--with-termnet If you want a termified net support],[ + if test x$withval = xyes; then + AC_DEFINE(USE_TERMNET) + termnet=true + fi + ]) + + TERMNET="" + AC_DEFINE(USE_VFS) + if $use_net_code; then + AC_DEFINE(USE_NETCODE) + fi + mcserv= + if test $have_socket = yes; then + mcserv="mcserv" + if $termnet; then + TERMNET="-ltermnet" + fi + fi + + AC_SUBST(TERMNET) + AC_SUBST(mcserv) + +dnl FIXME: +dnl GNOME_VFS_LIBS= + +]) + +AC_DEFUN([GNOME_VFS_CHECKS],[ + use_vfs=yes + AC_ARG_WITH(vfs, + [--with-vfs Compile with the VFS code], + use_vfs=$withval + ) + case $use_vfs in + yes) GNOME_WITH_VFS;; + no) use_vfs=no;; + *) use_vfs=no;; + dnl Should we issue a warning? + esac +]) + + +dnl GNOME_X_CHECKS +dnl +dnl Basic X11 related checks for X11. At the end, the following will be +dnl defined/changed: +dnl GTK_{CFLAGS,LIBS} From AM_PATH_GTK +dnl CPPFLAGS Will include $X_CFLAGS +dnl GNOME_HAVE_SM `true' or `false' depending on whether session +dnl management is available. It is available if +dnl both -lSM and X11/SM/SMlib.h exist. (Some +dnl Solaris boxes have the library but not the header) +dnl XPM_LIBS -lXpm if Xpm library is present, otherwise "" +dnl +dnl The following configure cache variables are defined (but not used): +dnl gnome_cv_passdown_{x_libs,X_LIBS,X_CFLAGS} +dnl +AC_DEFUN([GNOME_X_CHECKS], +[ + AM_PATH_GTK(1.2.0,,AC_MSG_ERROR(GTK not installed, or gtk-config not in path)) + dnl Hope that GTK_CFLAGS have only -I and -D. Otherwise, we could + dnl test -z "$x_includes" || CPPFLAGS="$CPPFLAGS -I$x_includes" + dnl + dnl Use CPPFLAGS instead of CFLAGS because AC_CHECK_HEADERS uses + dnl CPPFLAGS, not CFLAGS + CPPFLAGS="$CPPFLAGS $GTK_CFLAGS" + + saved_ldflags="$LDFLAGS" + LDFLAGS="$LDFLAGS $GTK_LIBS" + + gnome_cv_passdown_x_libs="$GTK_LIBS" + gnome_cv_passdown_X_LIBS="$GTK_LIBS" + gnome_cv_passdown_X_CFLAGS="$GTK_CFLAGS" + gnome_cv_passdown_GTK_LIBS="$GTK_LIBS" + + LDFLAGS="$saved_ldflags $GTK_LIBS" + +dnl We are requiring GTK >= 1.1.1, which means this will be fine anyhow. + USE_DEVGTK=true + +dnl AC_MSG_CHECKING([whether to use features from (unstable) GTK+ 1.1.x]) +dnl AC_EGREP_CPP(answer_affirmatively, +dnl [#include +dnl #ifdef GTK_HAVE_FEATURES_1_1_0 +dnl answer_affirmatively +dnl #endif +dnl ], dev_gtk=yes, dev_gtk=no) +dnl if test "$dev_gtk" = "yes"; then +dnl USE_DEVGTK=true +dnl fi +dnl AC_MSG_RESULT("$dev_gtk") + + GNOME_HAVE_SM=true + case "$GTK_LIBS" in + *-lSM*) + dnl Already found it. + ;; + *) + dnl Assume that if we have -lSM then we also have -lICE. + AC_CHECK_LIB(SM, SmcSaveYourselfDone, + [GTK_LIBS="-lSM -lICE $GTK_LIBS"],GNOME_HAVE_SM=false, + $x_libs -lICE) + ;; + esac + + if test "$GNOME_HAVE_SM" = true; then + AC_CHECK_HEADERS(X11/SM/SMlib.h,,GNOME_HAVE_SM=false) + fi + + if test "$GNOME_HAVE_SM" = true; then + AC_DEFINE(HAVE_LIBSM) + fi + + XPM_LIBS="" + AC_CHECK_LIB(Xpm, XpmFreeXpmImage, [XPM_LIBS="-lXpm"], , $x_libs) + AC_SUBST(XPM_LIBS) + + AC_REQUIRE([GNOME_PTHREAD_CHECK]) + LDFLAGS="$saved_ldflags" + + AC_PROVIDE([GNOME_X_CHECKS]) +]) +dnl +dnl GNOME_XML_HOOK (script-if-xml-found, failflag) +dnl +dnl If failflag is "failure", script aborts due to lack of XML +dnl +dnl Check for availability of the libxml library +dnl the XML parser uses libz if available too +dnl + +AC_DEFUN([GNOME_XML_HOOK],[ + AC_PATH_PROG(GNOME_CONFIG,gnome-config,no) + if test "$GNOME_CONFIG" = no; then + if test x$2 = xfailure; then + AC_MSG_ERROR(Could not find gnome-config) + fi + fi + AC_CHECK_LIB(xml, xmlNewDoc, [ + $1 + GNOME_XML_LIB=`$GNOME_CONFIG --libs xml` + ], [ + if test x$2 = xfailure; then + AC_MSG_ERROR(Could not link sample xml program) + fi + ], `$GNOME_CONFIG --libs xml`) + AC_SUBST(GNOME_XML_LIB) +]) + +AC_DEFUN([GNOME_XML_CHECK], [ + GNOME_XML_HOOK([],failure) +]) +dnl +dnl GNOME_INIT_HOOK (script-if-gnome-enabled, [failflag], [additional-inits]) +dnl +dnl if failflag is "fail" then GNOME_INIT_HOOK will abort if gnomeConf.sh +dnl is not found. +dnl + +AC_DEFUN([GNOME_INIT_HOOK],[ + AC_SUBST(GNOME_LIBS) + AC_SUBST(GNOMEUI_LIBS) + AC_SUBST(GNOMEGNORBA_LIBS) + AC_SUBST(GTKXMHTML_LIBS) + AC_SUBST(ZVT_LIBS) + AC_SUBST(GNOME_LIBDIR) + AC_SUBST(GNOME_INCLUDEDIR) + + AC_ARG_WITH(gnome-includes, + [ --with-gnome-includes Specify location of GNOME headers],[ + CFLAGS="$CFLAGS -I$withval" + ]) + + AC_ARG_WITH(gnome-libs, + [ --with-gnome-libs Specify location of GNOME libs],[ + LDFLAGS="$LDFLAGS -L$withval" + gnome_prefix=$withval + ]) + + AC_ARG_WITH(gnome, + [ --with-gnome Specify prefix for GNOME files], + if test x$withval = xyes; then + want_gnome=yes + dnl Note that an empty true branch is not + dnl valid sh syntax. + ifelse([$1], [], :, [$1]) + else + if test "x$withval" = xno; then + want_gnome=no + else + want_gnome=yes + LDFLAGS="$LDFLAGS -L$withval/lib" + CFLAGS="$CFLAGS -I$withval/include" + gnome_prefix=$withval/lib + fi + fi, + want_gnome=yes) + + if test "x$want_gnome" = xyes; then + + AC_PATH_PROG(GNOME_CONFIG,gnome-config,no) + if test "$GNOME_CONFIG" = "no"; then + no_gnome_config="yes" + else + AC_MSG_CHECKING(if $GNOME_CONFIG works) + if $GNOME_CONFIG --libs-only-l gnome >/dev/null 2>&1; then + AC_MSG_RESULT(yes) + GNOME_GNORBA_HOOK([],$2) + GNOME_LIBS="`$GNOME_CONFIG --libs-only-l gnome`" + GNOMEUI_LIBS="`$GNOME_CONFIG --libs-only-l gnomeui`" + GNOMEGNORBA_LIBS="`$GNOME_CONFIG --libs-only-l gnorba gnomeui`" + GTKXMHTML_LIBS="`$GNOME_CONFIG --libs-only-l gtkxmhtml`" + ZVT_LIBS="`$GNOME_CONFIG --libs-only-l zvt`" + GNOME_LIBDIR="`$GNOME_CONFIG --libs-only-L gnorba gnomeui`" + GNOME_INCLUDEDIR="`$GNOME_CONFIG --cflags gnorba gnomeui`" + $1 + else + AC_MSG_RESULT(no) + no_gnome_config="yes" + fi + fi + + if test x$exec_prefix = xNONE; then + if test x$prefix = xNONE; then + gnome_prefix=$ac_default_prefix/lib + else + gnome_prefix=$prefix/lib + fi + else + gnome_prefix=`eval echo \`echo $libdir\`` + fi + + if test "$no_gnome_config" = "yes"; then + AC_MSG_CHECKING(for gnomeConf.sh file in $gnome_prefix) + if test -f $gnome_prefix/gnomeConf.sh; then + AC_MSG_RESULT(found) + echo "loading gnome configuration from" \ + "$gnome_prefix/gnomeConf.sh" + . $gnome_prefix/gnomeConf.sh + $1 + else + AC_MSG_RESULT(not found) + if test x$2 = xfail; then + AC_MSG_ERROR(Could not find the gnomeConf.sh file that is generated by gnome-libs install) + fi + fi + fi + fi + + if test -n "$3"; then + n="$3" + for i in $n; do + AC_MSG_CHECKING(extra library \"$i\") + case $i in + applets) + AC_SUBST(GNOME_APPLETS_LIBS) + GNOME_APPLETS_LIBS=`$GNOME_CONFIG --libs-only-l applets` + AC_MSG_RESULT($GNOME_APPLETS_LIBS);; + docklets) + AC_SUBST(GNOME_DOCKLETS_LIBS) + GNOME_DOCKLETS_LIBS=`$GNOME_CONFIG --libs-only-l docklets` + AC_MSG_RESULT($GNOME_DOCKLETS_LIBS);; + capplet) + AC_SUBST(GNOME_CAPPLET_LIBS) + GNOME_CAPPLET_LIBS=`$GNOME_CONFIG --libs-only-l capplet` + AC_MSG_RESULT($GNOME_CAPPLET_LIBS);; + *) + AC_MSG_RESULT(unknown library) + esac + done + fi +]) + +dnl +dnl GNOME_INIT ([additional-inits]) +dnl + +AC_DEFUN([GNOME_INIT],[ + GNOME_INIT_HOOK([],fail,$1) +]) +dnl +dnl AC_PROG_GPERF (MINIMUM-VERSION) +dnl +dnl Check for availability of gperf. +dnl Abort if not found or if current version is not up to par. +dnl + +AC_DEFUN([AC_PROG_GPERF],[ + AC_PATH_PROG(GPERF, gperf, no) + if test "$GPERF" = no; then + AC_MSG_ERROR(Could not find gperf) + fi + min_gperf_version=ifelse([$1], ,2.7,$1) + AC_MSG_CHECKING(for gperf - version >= $min_gperf_version) + gperf_major_version=`$GPERF --version | \ + sed 's/GNU gperf \([[0-9]]*\).\([[0-9]]*\)/\1/'` + gperf_minor_version=`$GPERF --version | \ + sed 's/GNU gperf \([[0-9]]*\).\([[0-9]]*\)/\2/'` + no_gperf="" +dnl +dnl Now check if the installed gperf is sufficiently new. +dnl + AC_TRY_RUN([ +#include +#include +#include + +static char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int +main () +{ + char *tmp_version; + + int major; + int minor; + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_gperf_version"); + if (sscanf(tmp_version, "%d.%d", &major, &minor) != 2) { + printf ("%s, bad version string\n", "$min_gperf_version"); + exit (1); + } + + if (($gperf_major_version > major) || + (($gperf_major_version == major) && ($gperf_minor_version >= minor))) { + return 0; + } else { + printf ("\n"); + printf ("*** An old version of gperf ($gperf_major_version.$gperf_minor_version) was found.\n"); + printf ("*** You need a version of gperf newer than %d.%d.%d. The latest version of\n", + major, minor); + printf ("*** gperf is always available from ftp://ftp.gnu.org.\n"); + printf ("***\n"); + return 1; + } +} +],,no_gperf=yes,[/bin/true]) + if test "x$no_gperf" = x ; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + +]) +dnl +dnl Check for struct linger +dnl +AC_DEFUN(AC_STRUCT_LINGER, [ +av_struct_linger=no +AC_MSG_CHECKING(struct linger is available) +AC_TRY_RUN([ +#include +#include + +struct linger li; + +main () +{ + li.l_onoff = 1; + li.l_linger = 120; + exit (0); +} +],[ +AC_DEFINE(HAVE_STRUCT_LINGER) +av_struct_linger=yes +],[ +av_struct_linger=no +],[ +av_struct_linger=no +]) +AC_MSG_RESULT($av_struct_linger) +]) +dnl See whether we need a declaration for a function. +dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES]) +AC_DEFUN(GCC_NEED_DECLARATION, +[AC_MSG_CHECKING([whether $1 must be declared]) +AC_CACHE_VAL(gcc_cv_decl_needed_$1, +[AC_TRY_COMPILE([ +#include +#ifdef HAVE_STRING_H +#include +#else +#ifdef HAVE_STRINGS_H +#include +#endif +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +$2], +[char *(*pfn) = (char *(*)) $1], +eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")]) +if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then + AC_MSG_RESULT(yes) + gcc_need_declarations="$gcc_need_declarations $1" + gcc_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + AC_DEFINE_UNQUOTED($gcc_tr_decl) +else + AC_MSG_RESULT(no) +fi +])dnl + +dnl Check multiple functions to see whether each needs a declaration. +dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES]) +AC_DEFUN(GCC_NEED_DECLARATIONS, +[for ac_func in $1 +do +GCC_NEED_DECLARATION($ac_func, $2) +done +] +) +# Configure paths for GTK+ +# Owen Taylor 97-11-3 + +dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) +dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS +dnl +AC_DEFUN(AM_PATH_GTK, +[dnl +dnl Get the cflags and libraries from the gtk-config script +dnl +AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)], + gtk_config_prefix="$withval", gtk_config_prefix="") +AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)], + gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="") +AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program], + , enable_gtktest=yes) + + for module in . $4 + do + case "$module" in + gthread) + gtk_config_args="$gtk_config_args gthread" + ;; + esac + done + + if test x$gtk_config_exec_prefix != x ; then + gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix" + if test x${GTK_CONFIG+set} != xset ; then + GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config + fi + fi + if test x$gtk_config_prefix != x ; then + gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix" + if test x${GTK_CONFIG+set} != xset ; then + GTK_CONFIG=$gtk_config_prefix/bin/gtk-config + fi + fi + + AC_PATH_PROG(GTK_CONFIG, gtk-config, no) + min_gtk_version=ifelse([$1], ,0.99.7,$1) + AC_MSG_CHECKING(for GTK - version >= $min_gtk_version) + no_gtk="" + if test "$GTK_CONFIG" = "no" ; then + no_gtk=yes + else + GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags` + GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs` + gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_gtktest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GTK_CFLAGS" + LIBS="$GTK_LIBS $LIBS" +dnl +dnl Now check if the installed GTK is sufficiently new. (Also sanity +dnl checks the results of gtk-config to some extent +dnl + rm -f conf.gtktest + AC_TRY_RUN([ +#include +#include +#include + +int +main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.gtktest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_gtk_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_gtk_version"); + exit(1); + } + + if ((gtk_major_version != $gtk_config_major_version) || + (gtk_minor_version != $gtk_config_minor_version) || + (gtk_micro_version != $gtk_config_micro_version)) + { + printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", + $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version, + gtk_major_version, gtk_minor_version, gtk_micro_version); + printf ("*** was found! If gtk-config was correct, then it is best\n"); + printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n"); + printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); + printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); + printf("*** required on your system.\n"); + printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n"); + printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n"); + printf("*** before re-running configure\n"); + } +#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION) + else if ((gtk_major_version != GTK_MAJOR_VERSION) || + (gtk_minor_version != GTK_MINOR_VERSION) || + (gtk_micro_version != GTK_MICRO_VERSION)) + { + printf("*** GTK+ header files (version %d.%d.%d) do not match\n", + GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + gtk_major_version, gtk_minor_version, gtk_micro_version); + } +#endif /* defined (GTK_MAJOR_VERSION) ... */ + else + { + if ((gtk_major_version > major) || + ((gtk_major_version == major) && (gtk_minor_version > minor)) || + ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n", + gtk_major_version, gtk_minor_version, gtk_micro_version); + printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n", + major, minor, micro); + printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n"); + printf("***\n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the gtk-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n"); + printf("*** correct copy of gtk-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} +],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_gtk" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$GTK_CONFIG" = "no" ; then + echo "*** The gtk-config script installed by GTK could not be found" + echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the GTK_CONFIG environment variable to the" + echo "*** full path to gtk-config." + else + if test -f conf.gtktest ; then + : + else + echo "*** Could not run GTK test program, checking why..." + CFLAGS="$CFLAGS $GTK_CFLAGS" + LIBS="$LIBS $GTK_LIBS" + AC_TRY_LINK([ +#include +#include +], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GTK or finding the wrong" + echo "*** version of GTK. If it is not finding GTK, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" + echo "***" + echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that" + echo "*** came with the system with the command" + echo "***" + echo "*** rpm --erase --nodeps gtk gtk-devel" ], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GTK was incorrectly installed" + echo "*** or that you have moved GTK since it was installed. In the latter case, you" + echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GTK_CFLAGS="" + GTK_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GTK_CFLAGS) + AC_SUBST(GTK_LIBS) + rm -f conf.gtktest +]) diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4 index 85c492c61d..6c89433892 100644 --- a/config/lyxinclude.m4 +++ b/config/lyxinclude.m4 @@ -906,7 +906,7 @@ AC_DEFUN(LYX_USE_FRONTEND, [AC_MSG_CHECKING(what frontend should be used as main GUI) AC_ARG_WITH(frontend, [ --with-frontend[=value] Use THIS frontend as main GUI: - Possible values: xforms,kde,gtk], + Possible values: xforms,kde,gnome], [lyx_use_frontend="$withval"], [lyx_use_frontend="xforms"]) AC_MSG_RESULT($lyx_use_frontend) lyx_flags="$lyx_flags frontend-$lyx_use_frontend" diff --git a/configure.in b/configure.in index bb5ac70cda..3de792e90b 100644 --- a/configure.in +++ b/configure.in @@ -61,6 +61,17 @@ LYX_SCO ### Check for program extensions (.exe or nothing) AC_EXEEXT +### check which frontend we want to use +LYX_USE_FRONTEND +dnl The code below is not in a macro, because this would cause big +dnl problems with the AC_REQUIRE contained in KDE_DO_IT_ALL. +case "$lyx_use_frontend" in + gnome) + GNOME_INIT + GNOME_COMPILE_WARNINGS + GNOME_X_CHECKS +esac + ### Check for a C++ compiler AC_LANG_CPLUSPLUS LYX_PROG_CXX @@ -144,7 +155,7 @@ CPPFLAGS="$CPPFLAGS $X_CFLAGS" AC_CHECK_FUNCS(XOpenIM) ### check which frontend we want to use -LYX_USE_FRONTEND +#LYX_USE_FRONTEND dnl The code below is not in a macro, because this would cause big dnl problems with the AC_REQUIRE contained in KDE_DO_IT_ALL. case "$lyx_use_frontend" in diff --git a/lib/.cvsignore b/lib/.cvsignore index 3f4602745f..c0ca31f9d6 100644 --- a/lib/.cvsignore +++ b/lib/.cvsignore @@ -3,3 +3,4 @@ Makefile.in textclass.lst packages.lst lyxrc.defaults +listerrors diff --git a/po/POTFILES.in b/po/POTFILES.in index e7eec6829f..b59f6b666e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -26,6 +26,7 @@ src/ext_l10n.h src/filedlg.C src/FontLoader.C src/form1.C +src/frontends/gnome/FormPrint.C src/frontends/xforms/FormCitation.C src/frontends/xforms/form_citation.C src/frontends/xforms/FormCopyright.C @@ -42,6 +43,17 @@ src/frontends/xforms/FormPrint.C src/frontends/xforms/form_print.C src/frontends/xforms/FormRef.C src/frontends/xforms/form_ref.C +src/frontends/xforms/forms/form_citation.C +src/frontends/xforms/forms/form_copyright.C +src/frontends/xforms/forms/form_document.C +src/frontends/xforms/forms/form_graphics.C +src/frontends/xforms/forms/form_index.C +src/frontends/xforms/forms/form_preferences.C +src/frontends/xforms/forms/form_print.C +src/frontends/xforms/forms/form_ref.C +src/frontends/xforms/forms/form_tabular.C +src/frontends/xforms/forms/form_toc.C +src/frontends/xforms/forms/form_url.C src/frontends/xforms/FormTabular.C src/frontends/xforms/form_tabular.C src/frontends/xforms/FormToc.C diff --git a/sigc++/.cvsignore b/sigc++/.cvsignore index 5b1f91095f..51bd63597b 100644 --- a/sigc++/.cvsignore +++ b/sigc++/.cvsignore @@ -26,3 +26,4 @@ sigc-config stamp* sigc++config.h sigc++config.h.in +acinclude.m4 diff --git a/src/ext_l10n.h b/src/ext_l10n.h index cc8a06ef60..d4c5eae411 100644 --- a/src/ext_l10n.h +++ b/src/ext_l10n.h @@ -165,17 +165,18 @@ _("Credits...|e"); _("Version...|V"); _(""); _("A&A"); +_("ACT"); +_("AT_RISE:"); _("Abstract"); _("Accepted"); _("Acknowledgement"); +_("Acknowledgement(s)"); _("Acknowledgement*"); _("Acknowledgement-numbered"); -_("Acknowledgement(s)"); -_("Acknowledgements"); _("Acknowledgement-unnumbered"); +_("Acknowledgements"); _("Acknowledgments"); _("Acnowledgement"); -_("ACT"); _("Addchap"); _("Addchap*"); _("Addition"); @@ -193,15 +194,15 @@ _("Anlagen"); _("Anrede"); _("Appendices"); _("Appendix"); -_("AT_RISE:"); _("Author"); +_("AuthorRunning"); _("Author_Email"); _("Author_Running"); -_("AuthorRunning"); _("Author_URL"); _("Axiom"); _("Axiom-numbered"); _("Axiom-plain"); +_("BLZ"); _("Backaddress"); _("Bank"); _("BankAccount"); @@ -209,13 +210,12 @@ _("BankCode"); _("Betreff"); _("Bibliography"); _("Biography"); -_("BLZ"); _("Brieftext"); +_("CC"); +_("CURTAIN"); _("Caption"); _("Case"); _("Case-numbered"); -_("CC"); -_("cc"); _("CenteredCaption"); _("Chapter"); _("Chapter*"); @@ -255,7 +255,6 @@ _("Criterion-plain"); _("CrossList"); _("Current"); _("Current_Address"); -_("CURTAIN"); _("Customer"); _("Data"); _("Date"); @@ -270,10 +269,10 @@ _("Definition-unnumbered"); _("Description"); _("Dialogue"); _("EMail"); +_("EXT."); _("Email"); _("Encl"); _("Encl."); -_("encl"); _("End_All_Slides"); _("Enumerate"); _("Example"); @@ -284,48 +283,43 @@ _("Example-unnumbered"); _("Exercise"); _("Exercise-numbered"); _("Exercise-plain"); -_("EXT."); _("Extratitle"); +_("FADE_IN:"); +_("FADE_OUT:"); _("Fact"); _("Fact*"); _("Fact-numbered"); _("Fact-plain"); _("Fact-unnumbered"); -_("FADE_IN:"); -_("FADE_OUT:"); _("FigCaption"); -_("first"); _("FirstAuthor"); _("FirstName"); _("FitBitmap"); _("FitFigure"); _("Foilhead"); -_("foilhead"); _("Footernote"); _("FourAffiliations"); _("FourAuthors"); _("Gruss"); -_("Headnote"); _("HTTP"); +_("Headnote"); +_("INT."); _("Idea"); _("IhrSchreiben"); _("IhrZeichen"); _("Institute"); _("Institution"); -_("INT."); _("InvisibleText"); _("Invoice"); _("Itemize"); _("Journal"); -_("journal"); _("Keywords"); _("Konto"); -_("Labeling"); -_("Land"); -_("landscape"); -_("LandscapeSlide"); _("LaTeX"); _("LaTeX_Title"); +_("Labeling"); +_("Land"); +_("LandscapeSlide"); _("Lemma"); _("Lemma*"); _("Lemma-numbered"); @@ -344,10 +338,8 @@ _("MarkBoth"); _("MathLetters"); _("MeinZeichen"); _("Minisec"); -_("modying"); -_("msnumber"); -_("My_Address"); _("MyRef"); +_("My_Address"); _("Myref"); _("Name"); _("Narrative"); @@ -357,18 +349,18 @@ _("Note"); _("Note*"); _("Note-numbered"); _("Note-plain"); +_("Note-unnumbered"); _("NoteToEditor"); _("Notetoeditor"); -_("Note-unnumbered"); _("Offprint"); _("Offprints"); _("Offsets"); -_("offsets"); _("Oggetto"); _("Opening"); _("Ort"); _("Overlay"); _("PACS"); +_("PS"); _("Paragraph"); _("Paragraph*"); _("Paragraph-numbered"); @@ -379,8 +371,8 @@ _("Petit"); _("Phone"); _("Place"); _("PlaceFigure"); -_("Placefigure"); _("PlaceTable"); +_("Placefigure"); _("Placetable"); _("PortraitSlide"); _("PostalCommend"); @@ -397,12 +389,11 @@ _("Proposition*"); _("Proposition-numbered"); _("Proposition-plain"); _("Proposition-unnumbered"); -_("PS"); -_("ps"); _("Publishers"); _("Question"); _("Quotation"); _("Quote"); +_("REVTEX_Title"); _("Received"); _("Recieved"); _("Recieved/Accepted"); @@ -412,17 +403,17 @@ _("Remark"); _("Remark*"); _("Remark-numbered"); _("Remark-plain"); -_("Remarks"); _("Remark-unnumbered"); +_("Remarks"); _("RetourAdresse"); _("ReturnAddress"); -_("REVTEX_Title"); -_("Right_Address"); _("RightHeader"); +_("Right_Address"); _("Rotatefoilhead"); _("Running_LaTeX_Title"); _("SCENE"); _("SCENE*"); +_("SGML"); _("Scrap"); _("Section"); _("Section*"); @@ -430,11 +421,10 @@ _("Section-numbered"); _("Send"); _("Send_To_Address"); _("Seriate"); -_("SGML"); _("ShortFoilhead"); -_("Shortfoilhead"); _("ShortRotatefoilhead"); _("ShortTitle"); +_("Shortfoilhead"); _("Signature"); _("Slide"); _("Slide*"); @@ -450,26 +440,26 @@ _("State"); _("Strasse"); _("Street"); _("Style"); -_("style"); +_("SubSection"); +_("SubTitle"); _("Subitle"); _("Subject"); _("Subjectclass"); _("Subparagraph"); _("Subparagraph*"); -_("SubSection"); _("Subsection"); _("Subsection*"); _("Subsection-numbered"); _("Subsubsection"); _("Subsubsection*"); _("Subsubsection-numbered"); -_("SubTitle"); _("Subtitle"); _("Suggested"); _("Summary"); _("Summary-numbered"); _("Surname"); -_("surname"); +_("TOC_Author"); +_("TOC_Title"); _("TableComments"); _("TableRefs"); _("Telefax"); @@ -481,8 +471,8 @@ _("Theorem"); _("Theorem*"); _("Theorem-numbered"); _("Theorem-plain"); -_("TheoremTemplate"); _("Theorem-unnumbered"); +_("TheoremTemplate"); _("Thesaurus"); _("ThickLine"); _("This"); @@ -490,29 +480,39 @@ _("ThreeAffiliations"); _("ThreeAuthors"); _("TickList"); _("Title"); -_("Titlehead"); _("Title_Running"); -_("TOC_Author"); -_("TOC_Title"); +_("Titlehead"); _("Town"); -_("Transition"); _("Trans_Keywords"); +_("Transition"); _("Translated"); _("TranslatedAbstract"); _("Translated_Title"); _("Translator"); _("TwoAffiliations"); _("TwoAuthors"); +_("URL"); _("Unterschrift"); _("Uppertitleback"); -_("URL"); _("Use"); _("Verbatim"); _("Verse"); _("Verteiler"); _("VisibleText"); _("YourMail"); -_("Yourmail"); _("YourRef"); +_("Yourmail"); _("Yourref"); _("Zusatz"); +_("cc"); +_("encl"); +_("first"); +_("foilhead"); +_("journal"); +_("landscape"); +_("modying"); +_("msnumber"); +_("offsets"); +_("ps"); +_("style"); +_("surname"); diff --git a/src/frontends/Makefile.am b/src/frontends/Makefile.am index fc2bf32051..eae524cab1 100644 --- a/src/frontends/Makefile.am +++ b/src/frontends/Makefile.am @@ -1,9 +1,12 @@ AUTOMAKE_OPTIONS = foreign 1.4 DISTCLEANFILES= *.orig *.rej *~ *.bak core MAINTAINERCLEANFILES = $(srcdir)/Makefile.in -SUBDIRS = @FRONTEND@ +# xforms has to be fixed here as we still need object files in this directory +# for the compilation of other frontends, so until that we have to let this +# here. +SUBDIRS = xforms @FRONTEND@ ETAGS_ARGS = --lang=c++ -INCLUDES = ${FRONTEND_INCLUDES} -I${srcdir}/.. -I${srcdir}/@FRONTEND@ ${SIGC_CFLAGS} +INCLUDES = ${FRONTEND_INCLUDES} -I${srcdir}/.. -I${srcdir}/@FRONTEND@ -I${srcdir}/xfroms ${SIGC_CFLAGS} LIBS = noinst_LTLIBRARIES = libfrontends.la libfrontends_la_SOURCES=\ diff --git a/src/frontends/gnome/Dialogs.C b/src/frontends/gnome/Dialogs.C index 077143cdf0..309dd2bca3 100644 --- a/src/frontends/gnome/Dialogs.C +++ b/src/frontends/gnome/Dialogs.C @@ -1,13 +1,33 @@ #include +#include FORMS_H_LOCATION + #include "Dialogs.h" #include "FormCopyright.h" +#include "FormCitation.h" +#include "FormDocument.h" +#include "FormGraphics.h" +#include "FormIndex.h" +#include "FormPreferences.h" +#include "FormPrint.h" +#include "FormRef.h" +#include "FormTabular.h" +#include "FormToc.h" +#include "FormUrl.h" Dialogs::Dialogs(LyXView * lv) { + dialogs_.push_back(new FormCitation(lv, this)); dialogs_.push_back(new FormCopyright(lv, this)); - //dialogs_.push_back(new FormPrint(lv, this)); - //dialogs_.push_back(new FormPreferences(lv, this)); + dialogs_.push_back(new FormDocument(lv, this)); + dialogs_.push_back(new FormGraphics(lv, this)); + dialogs_.push_back(new FormIndex(lv, this)); + dialogs_.push_back(new FormPreferences(lv, this)); + dialogs_.push_back(new FormPrint(lv, this)); + dialogs_.push_back(new FormRef(lv, this)); + dialogs_.push_back(new FormTabular(lv, this)); + dialogs_.push_back(new FormToc(lv, this)); + dialogs_.push_back(new FormUrl(lv, this)); // reduce the number of connections needed in // dialogs by a simple connection here. diff --git a/src/frontends/gnome/FormPrint.C b/src/frontends/gnome/FormPrint.C new file mode 100644 index 0000000000..0a2551083c --- /dev/null +++ b/src/frontends/gnome/FormPrint.C @@ -0,0 +1,213 @@ +// -*- C++ -*- +/* FormPrint.C + * FormPrint Interface Class Implementation + * This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== + */ + + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "FormPrint.h" +#include "LyXView.h" +#include "Dialogs.h" +#include "lyxrc.h" +#include "PrinterParams.h" +#include "Liason.h" +#include "debug.h" +#include "BufferView.h" +#include "lyx_gui_misc.h" +#include "gettext.h" + +extern "C" { +#include "diaprint_interface.h" +#include "support.h" +} + +#include +#include + +#ifdef SIGC_CXX_NAMESPACES +using SigC::slot; +using SigC::bind; +#endif + +#ifdef CXX_WORKING_NAMESPACES +using Liason::printBuffer; +using Liason::getPrinterParams; +#endif + +FormPrint::FormPrint(LyXView * lv, Dialogs * d) + : dialog_(NULL), lv_(lv), d_(d), u_(0), h_(0) +{ + // let the dialog be shown + // This is a permanent connection so we won't bother + // storing a copy because we won't be disconnecting. + d->showPrint.connect(slot(this,&FormPrint::show)); +} + + +FormPrint::~FormPrint() +{ + hide(); +} + + +void FormPrint::show() +{ + Gtk::Button * b_ok; + Gtk::Button * b_cancel; + if (!dialog_) + { + GtkWidget * pd = create_DiaPrint(); + + dialog_ = Gtk::wrap(pd); + print_all_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "print_all") ) ); + print_odd_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "print_odd") ) ); + print_even_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "print_even") ) ); + + print_pages_ = Gtk::wrap( GTK_CHECK_BUTTON( lookup_widget(pd, "print_pages") ) ); + + print_from_ = Gtk::wrap( GTK_SPIN_BUTTON( lookup_widget(pd, "print_from") ) ); + print_to_ = Gtk::wrap( GTK_SPIN_BUTTON( lookup_widget(pd, "print_to") ) ); + + order_normal_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "order_normal") ) ); + order_reverse_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "order_reverse") ) ); + + copies_unsorted_ = Gtk::wrap( GTK_CHECK_BUTTON( lookup_widget(pd, "copies_unsorted") ) ); + copies_count_ = Gtk::wrap( GTK_SPIN_BUTTON( lookup_widget(pd, "copies_count") ) ); + + printto_printer_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "printto_printer") ) ); + printto_file_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "printto_file") ) ); + + printto_printcommand_ = Gtk::wrap( GNOME_ENTRY( lookup_widget(pd, "printto_printcommand") ) ); + printto_fileentry_ = Gtk::wrap( GNOME_FILE_ENTRY( lookup_widget(pd, "printto_fileentry") ) ); + + b_ok = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_print") ) ); + b_cancel = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_cancel") ) ); + + // setting up connections + b_ok->clicked.connect(slot(this, &FormPrint::apply)); + b_ok->clicked.connect(dialog_->destroy.slot()); + b_cancel->clicked.connect(dialog_->destroy.slot()); + dialog_->destroy.connect(slot(this, &FormPrint::free)); + + u_ = d_->updateBufferDependent.connect(slot(this, + &FormPrint::update)); + h_ = d_->hideBufferDependent.connect(dialog_->destroy.slot()); + + if (!dialog_->is_visible()) dialog_->show_all(); + + update(); // make sure its up-to-date + } + else + { + Gdk_Window dialog_win(dialog_->get_window()); + dialog_win.raise(); + } +} + +void FormPrint::hide() +{ + if (dialog_!=NULL) dialog_->destroy(); +} + +void FormPrint::free() +{ + if (dialog_!=NULL) + { + dialog_ = NULL; + u_.disconnect(); + h_.disconnect(); + } +} + + +void FormPrint::apply() +{ + if (!lv_->view()->available()) return; + + PrinterParams::WhichPages wp(PrinterParams::ALL); + if (print_odd_->get_active()) wp = PrinterParams::ODD; + else if (print_even_->get_active()) wp = PrinterParams::EVEN; + + string from; + int to(0); + if (print_pages_->get_active()) + { + from = print_from_->get_text(); + to = print_to_->get_value_as_int(); + } + + PrinterParams::Target t(PrinterParams::PRINTER); + if (printto_file_->get_active()) t = PrinterParams::FILE; + + // we really should use the return value here I think. + if (!printBuffer(lv_->buffer(), + PrinterParams(t, + printto_printcommand_->get_entry()->get_text(), + printto_fileentry_->get_full_path(false), + wp, from, to, + order_reverse_->get_active(), + copies_unsorted_->get_active(), + copies_count_->get_value_as_int()))) + { + WriteAlert(_("Error:"), + _("Unable to print"), + _("Check that your parameters are correct")); + } +} + + +void FormPrint::update() +{ + if (dialog_ != NULL && + lv_->view()->available()) + { + PrinterParams pp(getPrinterParams(lv_->buffer())); + + printto_printcommand_->get_entry()->set_text( pp.printer_name.c_str() ); + ((Gtk::Entry *)printto_fileentry_->gtk_entry())->set_text(pp.file_name.c_str()); + + if (pp.target == PrinterParams::PRINTER) printto_printer_->set_active(true); + else printto_file_->set_active(true); + + if (pp.reverse_order) order_reverse_->set_active(true); + else order_normal_->set_active(true); + + switch (pp.which_pages) + { + case PrinterParams::ODD: + print_odd_->set_active(true); + break; + + case PrinterParams::EVEN: + print_even_->set_active(true); + break; + + case PrinterParams::ALL: + default: + print_all_->set_active(true); + break; + } + + // hmmm... maybe a bit weird but maybe not + // we might just be remembering the last + // time this was printed. + if (!pp.from_page.empty()) + { + print_to_->set_value(pp.to_page); + print_from_->set_value(strToInt(pp.from_page)); + } + } +} diff --git a/src/frontends/gnome/FormPrint.h b/src/frontends/gnome/FormPrint.h new file mode 100644 index 0000000000..fcf95ec54e --- /dev/null +++ b/src/frontends/gnome/FormPrint.h @@ -0,0 +1,108 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== */ +/* FormPrint.h + * FormPrint Interface Class + */ + +#ifndef FORMPRINT_H +#define FORMPRINT_H + +#include "DialogBase.h" +#include "support/utility.hpp" + +#include +#include +#include +#include +#include +#include + + +#ifdef __GNUG__ +#pragma interface +#endif + +class LyXView; +class Dialogs; + +#ifdef SIGC_CXX_NAMESPACES +using SigC::Connection; +#endif + +/** This class provides an Gnome implementation of the FormPrint Dialog. + The print dialog allows users to print their documents. + */ +class FormPrint : public DialogBase, public noncopyable { +public: + /**@name Constructors and Destructors */ + //@{ + /// #FormPrint x(LyXFunc ..., Dialogs ...);# + FormPrint(LyXView *, Dialogs *); + /// + ~FormPrint(); + //@} + + +private: + /**@name Slot Methods */ + //@{ + /// Create the dialog if necessary, update it and display it. + void show(); + /// Hide the dialog. + void hide(); + /// Update the dialog. + void update(); + /// Free memory + void free(); + //@} + + /**@name Dialog internal methods */ + //@{ + /// Apply from dialog + void apply(); + //@} + + /**@name Private Data */ + //@{ + /// Real GUI implementation. + Gtk::Widget * dialog_; + + Gtk::RadioButton * print_all_; + Gtk::RadioButton * print_odd_; + Gtk::RadioButton * print_even_; + + Gtk::CheckButton * print_pages_; + + Gtk::SpinButton * print_from_; + Gtk::SpinButton * print_to_; + + Gtk::RadioButton * order_normal_; + Gtk::RadioButton * order_reverse_; + + Gtk::CheckButton * copies_unsorted_; + Gtk::SpinButton * copies_count_; + + Gtk::RadioButton * printto_printer_; + Gtk::RadioButton * printto_file_; + + Gnome::Entry * printto_printcommand_; + Gnome::FileEntry * printto_fileentry_; + + /// Which LyXView do we belong to? + LyXView * lv_; + Dialogs * d_; + /// Update connection. + Connection u_; + /// Hide connection. + Connection h_; + //@} +}; + +#endif diff --git a/src/frontends/gnome/FormUrl.C b/src/frontends/gnome/FormUrl.C new file mode 100644 index 0000000000..afd39f614c --- /dev/null +++ b/src/frontends/gnome/FormUrl.C @@ -0,0 +1,163 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + + +#include "gettext.h" +#include "Dialogs.h" +#include "FormUrl.h" +#include "LyXView.h" +#include "buffer.h" +#include "lyxfunc.h" + +extern "C" { +#include "diainserturl_interface.h" +#include "support.h" +} + +#include + +FormUrl::FormUrl(LyXView * lv, Dialogs * d) + : lv_(lv), d_(d), u_(0), h_(0), ih_(0), inset_(0), dialog_(NULL) +{ + // let the dialog be shown + // These are permanent connections so we won't bother + // storing a copy because we won't be disconnecting. + d->showUrl.connect(slot(this, &FormUrl::showInset)); + d->createUrl.connect(slot(this, &FormUrl::createInset)); +} + + +FormUrl::~FormUrl() +{ + hide(); +} + +void FormUrl::showInset( InsetCommand * const inset ) +{ + if( dialog_!=NULL || inset == 0 ) return; + + inset_ = inset; + ih_ = inset_->hide.connect(slot(this, &FormUrl::hide)); + + params = inset->params(); + show(); +} + + +void FormUrl::createInset( string const & arg ) +{ + if( dialog_!=NULL ) return; + + params.setFromString( arg ); + show(); +} + +void FormUrl::show() +{ + if (!dialog_) + { + GtkWidget * pd = create_DiaInsertUrl(); + + dialog_ = Gtk::wrap(pd); + url_ = Gtk::wrap( GNOME_ENTRY( lookup_widget(pd, "url") ) ); + name_ = Gtk::wrap( GNOME_ENTRY( lookup_widget(pd, "name") ) ); + html_type_ = Gtk::wrap( GTK_CHECK_BUTTON( lookup_widget(pd, "html_type") ) ); + + b_ok = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_ok") ) ); + b_cancel = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_cancel") ) ); + + b_ok->clicked.connect(slot(this, &FormUrl::apply)); + b_ok->clicked.connect(dialog_->destroy.slot()); + b_cancel->clicked.connect(dialog_->destroy.slot()); + dialog_->destroy.connect(slot(this, &FormUrl::free)); + + u_ = d_->updateBufferDependent.connect(slot(this, &FormUrl::update)); + h_ = d_->hideBufferDependent.connect(slot(this, &FormUrl::hide)); + + if (!dialog_->is_visible()) dialog_->show_all(); + + update(); // make sure its up-to-date + } + else + { + Gdk_Window dialog_win(dialog_->get_window()); + dialog_win.raise(); + } +} + +void FormUrl::update() +{ + if (dialog_ != NULL && + lv_->view()->available()) + { + url_->get_entry()->set_text(params.getContents().c_str()); + name_->get_entry()->set_text(params.getOptions().c_str()); + + html_type_->set_active( (params.getCmdName() == "htmlurl") ); + + bool sens = (!(lv_->buffer()->isReadonly())); + + html_type_->set_sensitive(sens); + url_->set_sensitive(sens); + name_->set_sensitive(sens); + b_ok->set_sensitive(sens); + } +} + +void FormUrl::hide() +{ + if (dialog_!=NULL) dialog_->destroy(); +} + +void FormUrl::free() +{ + if (dialog_!=NULL) + { + dialog_ = NULL; + u_.disconnect(); + h_.disconnect(); + inset_ = 0; + ih_.disconnect(); + } +} + +void FormUrl::apply() +{ + if( lv_->buffer()->isReadonly() ) return; + + params.setContents( url_->get_entry()->get_text() ); + params.setOptions( name_->get_entry()->get_text() ); + + if (html_type_->get_active()) + params.setCmdName("htmlurl"); + else + params.setCmdName("url"); + + if( inset_ != 0 ) + { + // Only update if contents have changed + if( params != inset_->params() ) { + inset_->setParams( params ); + lv_->view()->updateInset( inset_, true ); + } + } + else + { + lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL, + params.getAsString().c_str() ); + } +} diff --git a/src/frontends/gnome/FormUrl.h b/src/frontends/gnome/FormUrl.h new file mode 100644 index 0000000000..4f0729d0c4 --- /dev/null +++ b/src/frontends/gnome/FormUrl.h @@ -0,0 +1,90 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== + */ + +#ifndef FORMURL_H +#define FORMURL_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "DialogBase.h" +#include "LString.h" +#include "support/utility.hpp" +#include "insets/insetcommand.h" + +#include +#include +#include +#include + +/** This class provides an Gnome implementation of the FormUrl Dialog. + */ +class FormUrl : public DialogBase, public noncopyable { +public: + /**@name Constructors and Destructors */ + //@{ + /// + FormUrl(LyXView *, Dialogs *); + /// + ~FormUrl(); + //@} + +private: + /// Slot launching dialog to (possibly) create a new inset + void createInset( string const & ); + /// Slot launching dialog to an existing inset + void showInset( InsetCommand * const ); + + /// Update dialog before showing it + virtual void update(); + /// Apply from dialog (modify or create inset) + virtual void apply(); + /// Explicitly free the dialog. + void free(); + /// Create the dialog if necessary, update it and display it. + void show(); + /// Hide the dialog. + void hide(); + + /** Which LyXFunc do we use? + We could modify Dialogs to have a visible LyXFunc* instead and + save a couple of bytes per dialog. + */ + LyXView * lv_; + /** Which Dialogs do we belong to? + Used so we can get at the signals we have to connect to. + */ + Dialogs * d_; + /// pointer to the inset passed through showInset (if any) + InsetCommand * inset_; + /// the nitty-griity. What is modified and passed back + InsetCommandParams params; + /// Update connection. + Connection u_; + /// Hide connection. + Connection h_; + /// inset::hide connection. + Connection ih_; + + /// Real GUI implementation. + Gtk::Widget * dialog_; + + Gtk::CheckButton * html_type_; + + Gnome::Entry * url_; + Gnome::Entry * name_; + + Gtk::Button * b_ok; + Gtk::Button * b_cancel; +}; + +#endif diff --git a/src/frontends/gnome/Makefile.am b/src/frontends/gnome/Makefile.am index 7fddb09299..1b312a966e 100644 --- a/src/frontends/gnome/Makefile.am +++ b/src/frontends/gnome/Makefile.am @@ -3,22 +3,55 @@ DISTCLEANFILES= *.orig *.rej *~ *.bak core MAINTAINERCLEANFILES = $(srcdir)/Makefile.in noinst_LTLIBRARIES = libgnome.la INCLUDES = ${FRONTEND_INCLUDES} -I${top_srcdir}/src/ \ - -I${top_srcdir}/src/frontends/ \ + -I${top_srcdir}/src/frontends/ -I${top_srcdir}/src/frontends/xforms \ ${SIGC_CFLAGS} -LIBS= -LDFLAGS= +libgnome_la_OBJADD = \ + ../xforms/FormCitation.lo \ + ../xforms/form_citation.lo \ + ../xforms/FormCommand.lo \ + ../xforms/FormDocument.lo \ + ../xforms/form_document.lo \ + ../xforms/FormGraphics.lo \ + ../xforms/form_graphics.lo \ + ../xforms/FormIndex.lo \ + ../xforms/form_index.lo \ + ../xforms/FormPreferences.lo \ + ../xforms/form_preferences.lo \ + ../xforms/FormRef.lo \ + ../xforms/form_ref.lo \ + ../xforms/FormTabular.lo \ + ../xforms/form_tabular.lo \ + ../xforms/FormToc.lo \ + ../xforms/form_toc.lo \ + ../xforms/input_validators.lo \ + ../xforms/RadioButtonGroup.lo \ + ../xforms/Toolbar_pimpl.lo +LIBS= +LDFLAGS= $(libgnome_la_OBJADD) LYXDATADIRS = -ETAGS_ARGS = --lang=c++ +#ETAGS_ARGS = --lang=c++ libgnome_la_SOURCES = \ Dialogs.C \ FormCopyright.C \ FormCopyright.h \ + FormPrint.C \ + FormPrint.h \ + FormUrl.C \ + FormUrl.h \ Menubar_pimpl.C \ Menubar_pimpl.h \ - Toolbar_pimpl.C \ - Toolbar_pimpl.h \ mainapp.C \ - mainapp.h + mainapp.h \ + support.c \ + support.h \ + diaprint_callbacks.c \ + diaprint_callbacks.h \ + diaprint_interface.c \ + diaprint_interface.h \ + diainserturl_callbacks.c \ + diainserturl_interface.c \ + diainserturl_callbacks.h \ + diainserturl_interface.h # These still have to be added. Sooner or later. ARRae-20000411 # GUI_defaults.C \ diff --git a/src/frontends/gnome/diainserturl_callbacks.c b/src/frontends/gnome/diainserturl_callbacks.c new file mode 100644 index 0000000000..7bd03ce855 --- /dev/null +++ b/src/frontends/gnome/diainserturl_callbacks.c @@ -0,0 +1,19 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#include "diainserturl_callbacks.h" +#include "diainserturl_interface.h" +#include "support.h" + diff --git a/src/frontends/gnome/diainserturl_callbacks.h b/src/frontends/gnome/diainserturl_callbacks.h new file mode 100644 index 0000000000..096523c330 --- /dev/null +++ b/src/frontends/gnome/diainserturl_callbacks.h @@ -0,0 +1,11 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== */ + +#include + diff --git a/src/frontends/gnome/diainserturl_interface.c b/src/frontends/gnome/diainserturl_interface.c new file mode 100644 index 0000000000..1d51a8368f --- /dev/null +++ b/src/frontends/gnome/diainserturl_interface.c @@ -0,0 +1,159 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include + +#include + +#include "diainserturl_callbacks.h" +#include "diainserturl_interface.h" +#include "support.h" + +GtkWidget* +create_DiaInsertUrl (void) +{ + GtkWidget *DiaInsertUrl; + GtkWidget *dialog_vbox1; + GtkWidget *vbox1; + GtkWidget *table1; + GtkWidget *label2; + GtkWidget *label1; + GtkWidget *url; + GtkWidget *combo_entry1; + GtkWidget *name; + GtkWidget *combo_entry2; + guint html_type_key; + GtkWidget *html_type; + GtkWidget *dialog_action_area1; + GtkWidget *button_ok; + GtkWidget *button_cancel; + GtkAccelGroup *accel_group; + + accel_group = gtk_accel_group_new (); + + DiaInsertUrl = gnome_dialog_new (_("Insert URL"), NULL); + gtk_object_set_data (GTK_OBJECT (DiaInsertUrl), "DiaInsertUrl", DiaInsertUrl); + gtk_container_set_border_width (GTK_CONTAINER (DiaInsertUrl), 2); + GTK_WINDOW (DiaInsertUrl)->type = GTK_WINDOW_DIALOG; + gtk_window_set_policy (GTK_WINDOW (DiaInsertUrl), FALSE, FALSE, FALSE); + + dialog_vbox1 = GNOME_DIALOG (DiaInsertUrl)->vbox; + gtk_object_set_data (GTK_OBJECT (DiaInsertUrl), "dialog_vbox1", dialog_vbox1); + gtk_widget_show (dialog_vbox1); + + vbox1 = gtk_vbox_new (FALSE, 2); + gtk_widget_ref (vbox1); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertUrl), "vbox1", vbox1, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox1); + gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0); + + table1 = gtk_table_new (2, 2, FALSE); + gtk_widget_ref (table1); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertUrl), "table1", table1, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (table1); + gtk_box_pack_start (GTK_BOX (vbox1), table1, TRUE, TRUE, 0); + gtk_table_set_row_spacings (GTK_TABLE (table1), 2); + gtk_table_set_col_spacings (GTK_TABLE (table1), 2); + + label2 = gtk_label_new (_("Name")); + gtk_widget_ref (label2); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertUrl), "label2", label2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label2); + gtk_table_attach (GTK_TABLE (table1), label2, 0, 1, 1, 2, + (GtkAttachOptions) (0), + (GtkAttachOptions) (0), 0, 0); + gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_LEFT); + + label1 = gtk_label_new (_("URL")); + gtk_widget_ref (label1); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertUrl), "label1", label1, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label1); + gtk_table_attach (GTK_TABLE (table1), label1, 0, 1, 0, 1, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT); + + url = gnome_entry_new ("diainserturl_url"); + gtk_widget_ref (url); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertUrl), "url", url, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (url); + gtk_table_attach (GTK_TABLE (table1), url, 1, 2, 0, 1, + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_container_set_border_width (GTK_CONTAINER (url), 1); + + combo_entry1 = gnome_entry_gtk_entry (GNOME_ENTRY (url)); + gtk_widget_ref (combo_entry1); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertUrl), "combo_entry1", combo_entry1, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (combo_entry1); + + name = gnome_entry_new ("diainserturl_name"); + gtk_widget_ref (name); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertUrl), "name", name, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (name); + gtk_table_attach (GTK_TABLE (table1), name, 1, 2, 1, 2, + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_container_set_border_width (GTK_CONTAINER (name), 1); + + combo_entry2 = gnome_entry_gtk_entry (GNOME_ENTRY (name)); + gtk_widget_ref (combo_entry2); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertUrl), "combo_entry2", combo_entry2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (combo_entry2); + + html_type = gtk_check_button_new_with_label (""); + html_type_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (html_type)->child), + _("_HTML type")); + gtk_widget_add_accelerator (html_type, "clicked", accel_group, + html_type_key, GDK_MOD1_MASK, 0); + gtk_widget_ref (html_type); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertUrl), "html_type", html_type, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (html_type); + gtk_box_pack_start (GTK_BOX (vbox1), html_type, FALSE, FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (html_type), 2); + + dialog_action_area1 = GNOME_DIALOG (DiaInsertUrl)->action_area; + gtk_object_set_data (GTK_OBJECT (DiaInsertUrl), "dialog_action_area1", dialog_action_area1); + gtk_widget_show (dialog_action_area1); + gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); + gtk_button_box_set_spacing (GTK_BUTTON_BOX (dialog_action_area1), 8); + + gnome_dialog_append_button (GNOME_DIALOG (DiaInsertUrl), GNOME_STOCK_BUTTON_OK); + button_ok = g_list_last (GNOME_DIALOG (DiaInsertUrl)->buttons)->data; + gtk_widget_ref (button_ok); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertUrl), "button_ok", button_ok, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (button_ok); + GTK_WIDGET_SET_FLAGS (button_ok, GTK_CAN_DEFAULT); + + gnome_dialog_append_button (GNOME_DIALOG (DiaInsertUrl), GNOME_STOCK_BUTTON_CANCEL); + button_cancel = g_list_last (GNOME_DIALOG (DiaInsertUrl)->buttons)->data; + gtk_widget_ref (button_cancel); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertUrl), "button_cancel", button_cancel, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (button_cancel); + GTK_WIDGET_SET_FLAGS (button_cancel, GTK_CAN_DEFAULT); + + gtk_widget_grab_default (button_ok); + gtk_window_add_accel_group (GTK_WINDOW (DiaInsertUrl), accel_group); + + return DiaInsertUrl; +} + diff --git a/src/frontends/gnome/diainserturl_interface.h b/src/frontends/gnome/diainserturl_interface.h new file mode 100644 index 0000000000..f0681c774b --- /dev/null +++ b/src/frontends/gnome/diainserturl_interface.h @@ -0,0 +1,5 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +GtkWidget* create_DiaInsertUrl (void); diff --git a/src/frontends/gnome/dialogs/diainserturl.glade b/src/frontends/gnome/dialogs/diainserturl.glade new file mode 100644 index 0000000000..89df1b48da --- /dev/null +++ b/src/frontends/gnome/dialogs/diainserturl.glade @@ -0,0 +1,245 @@ + + + + + diainserturl + diainserturl + + src + pixmaps + C + True + True + False + False + False + diainserturl_interface.c + diainserturl_interface.h + diainserturl_callbacks.c + diainserturl_callbacks.h + + + + GnomeDialog + DiaInsertUrl + 2 + Insert URL + GTK_WINDOW_DIALOG + GTK_WIN_POS_NONE + False + False + False + False + False + False + + + GtkVBox + GnomeDialog:vbox + dialog-vbox1 + False + 8 + + 4 + True + True + + + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area1 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + button_ok + True + True + True + GNOME_STOCK_BUTTON_OK + + + + GtkButton + button_cancel + True + True + GNOME_STOCK_BUTTON_CANCEL + + + + + GtkVBox + vbox1 + False + 2 + + 0 + True + True + + + + GtkTable + table1 + 2 + 2 + False + 2 + 2 + + 0 + True + True + + + + GtkLabel + label2 + + GTK_JUSTIFY_LEFT + False + 0.5 + 0.5 + 0 + 0 + + 0 + 1 + 1 + 2 + 0 + 0 + False + False + False + False + False + False + + + + + GtkLabel + label1 + + GTK_JUSTIFY_LEFT + False + 0.5 + 0.5 + 0 + 0 + + 0 + 1 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + + + + + GnomeEntry + url + 1 + diainserturl_url + 10 + + 1 + 2 + 0 + 1 + 0 + 0 + True + False + False + False + True + False + + + + GtkEntry + GnomeEntry:entry + combo-entry1 + True + True + True + 0 + + + + + + GnomeEntry + name + 1 + diainserturl_name + 10 + + 1 + 2 + 1 + 2 + 0 + 0 + True + False + False + False + True + False + + + + GtkEntry + GnomeEntry:entry + combo-entry2 + True + True + True + 0 + + + + + + + GtkCheckButton + html_type + 2 + True + + False + True + + 0 + False + False + + + + + + + diff --git a/src/frontends/gnome/dialogs/diaprint.glade b/src/frontends/gnome/dialogs/diaprint.glade new file mode 100644 index 0000000000..b0d5300601 --- /dev/null +++ b/src/frontends/gnome/dialogs/diaprint.glade @@ -0,0 +1,598 @@ + + + + + Project2 + project2 + + src + pixmaps + C + True + True + False + False + diaprint_interface.c + diaprint_interface.h + diaprint_callbacks.c + diaprint_callbacks.h + + + + GnomeDialog + DiaPrint + 2 + + show + diaprint_on_diaprint_show + Sat, 12 Aug 2000 07:05:03 GMT + + Print + GTK_WINDOW_DIALOG + GTK_WIN_POS_NONE + False + False + False + False + False + False + + + GtkVBox + GnomeDialog:vbox + dialog-vbox1 + False + 8 + + 4 + True + True + + + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area1 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + button_print + True + True + True + True + + GNOME_STOCK_PIXMAP_PRINT + + + + GtkButton + button_cancel + True + True + GNOME_STOCK_BUTTON_CANCEL + + + + + GtkVBox + vbox1 + False + 0 + + 0 + True + True + + + + GtkHBox + hbox1 + False + 0 + + 0 + True + True + + + + GtkFrame + frame2 + 2 + + 0 + GTK_SHADOW_ETCHED_IN + + 0 + True + True + + + + GtkVBox + vbox2 + False + 0 + + + GtkRadioButton + print_all + True + + False + True + print + + 0 + False + False + + + + + GtkRadioButton + print_odd + True + + False + True + print + + 0 + False + False + + + + + GtkRadioButton + print_even + True + + False + True + print + + 0 + False + False + + + + + GtkHBox + hbox2 + False + 0 + + 0 + True + True + + + + GtkCheckButton + print_pages + True + + toggled + diaprint_on_print_pages_toggled + Sun, 13 Aug 2000 07:14:15 GMT + + + False + True + + 0 + False + False + + + + + GtkLabel + label1 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 1 + 0 + + 0 + False + False + + + + + GtkSpinButton + print_from + True + + changed + diaprint_on_print_from_changed + Sun, 13 Aug 2000 10:34:42 GMT + + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 + 1 + 100000 + 1 + 10 + 10 + + 0 + False + False + + + + + GtkLabel + label2 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 1 + 0 + + 0 + False + False + + + + + GtkSpinButton + print_to + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 + 1 + 100000 + 1 + 10 + 10 + + 0 + False + False + + + + + + + + GtkVBox + vbox3 + False + 0 + + 0 + True + True + + + + GtkFrame + frame3 + 2 + + 0 + GTK_SHADOW_ETCHED_IN + + 0 + True + True + + + + GtkVBox + vbox4 + False + 0 + + + GtkRadioButton + order_normal + True + + False + True + order + + 0 + False + False + + + + + GtkRadioButton + order_reverse + True + + False + True + order + + 0 + False + False + + + + + + + GtkFrame + frame4 + 2 + + 0 + GTK_SHADOW_ETCHED_IN + + 0 + True + True + + + + GtkVBox + vbox5 + False + 0 + + + GtkCheckButton + copies_unsorted + True + + False + True + + 0 + False + False + + + + + GtkHBox + hbox3 + 2 + False + 0 + + 0 + True + True + + + + GtkLabel + label3 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 3 + 0 + + 0 + False + False + + + + + GtkSpinButton + copies_count + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 + 1 + 100000 + 1 + 10 + 10 + + 2 + True + True + + + + + + + + + + GtkFrame + frame1 + 2 + + 0 + GTK_SHADOW_ETCHED_IN + + 0 + True + True + + + + GtkTable + table1 + 2 + 2 + False + 0 + 0 + + + GtkRadioButton + printto_file + True + + toggled + diaprint_on_printto_file_toggled + Sat, 12 Aug 2000 07:04:41 GMT + + + False + True + printto + + 0 + 1 + 1 + 2 + 0 + 0 + False + False + False + False + True + False + + + + + GtkRadioButton + printto_printer + True + + toggled + diaprint_on_printto_printer_toggled + Sat, 12 Aug 2000 07:04:32 GMT + + + True + True + printto + + 0 + 1 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + + + + + GnomeFileEntry + printto_fileentry + 3 + diaprint_printto_fileentry + 10 + False + False + + 1 + 2 + 1 + 2 + 0 + 0 + True + False + False + False + True + False + + + + GtkEntry + GnomeEntry:entry + combo-entry1 + True + True + True + 0 + + + + + + GnomeEntry + printto_printcommand + 3 + diaprint_printto_printcommand + 10 + + 1 + 2 + 0 + 1 + 0 + 0 + True + False + False + False + True + False + + + + GtkEntry + GnomeEntry:entry + combo-entry2 + True + True + True + 0 + + + + + + + + + + diff --git a/src/frontends/gnome/diaprint_callbacks.c b/src/frontends/gnome/diaprint_callbacks.c new file mode 100644 index 0000000000..c70338034e --- /dev/null +++ b/src/frontends/gnome/diaprint_callbacks.c @@ -0,0 +1,104 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== */ + +/* Print dialog callbacks + * Controls the state of the widgets + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#include "diaprint_callbacks.h" +#include "diaprint_interface.h" +#include "support.h" + + +void +diaprint_set_printdest_state( GtkWidget *wid, gboolean active_is_printer ) +{ + if (active_is_printer) + { + gtk_widget_set_sensitive(lookup_widget(wid, "printto_printcommand"), TRUE); + gtk_widget_set_sensitive(lookup_widget(wid, "printto_fileentry"), FALSE); + } + else + { + gtk_widget_set_sensitive(lookup_widget(wid, "printto_printcommand"), FALSE); + gtk_widget_set_sensitive(lookup_widget(wid, "printto_fileentry"), TRUE); + } +} + +void +diaprint_set_pages_state( GtkWidget *wid, gboolean active_pages ) +{ + gtk_widget_set_sensitive(lookup_widget(wid, "print_from"), active_pages); + gtk_widget_set_sensitive(lookup_widget(wid, "print_to"), active_pages); +} + +void +diaprint_on_diaprint_show (GtkWidget *widget, + gpointer user_data) +{ + diaprint_set_printdest_state(widget, + gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON(lookup_widget(widget, "printto_printer"))) + ); + diaprint_set_pages_state(widget, + gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON(lookup_widget(widget, "print_pages"))) + ); +} + +void +diaprint_on_printto_file_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + diaprint_set_printdest_state(GTK_WIDGET(togglebutton), FALSE); +} + + +void +diaprint_on_printto_printer_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + diaprint_set_printdest_state(GTK_WIDGET(togglebutton), TRUE); +} + +void +diaprint_on_print_pages_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + diaprint_set_pages_state(GTK_WIDGET(togglebutton), + gtk_toggle_button_get_active(togglebutton)); +} + +void +diaprint_on_print_from_changed (GtkEditable *editable, + gpointer user_data) +{ + GtkSpinButton * to; + GtkAdjustment * a; + int nmin, v; + + nmin = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(editable) ); + to = GTK_SPIN_BUTTON(lookup_widget(GTK_WIDGET(editable), "print_to")); + a = gtk_spin_button_get_adjustment(to); + v = gtk_spin_button_get_value_as_int(to); + + a->lower = nmin; + if (v < nmin) + gtk_spin_button_set_value(to, nmin); + else + gtk_spin_button_set_value(to, v); +} + + diff --git a/src/frontends/gnome/diaprint_callbacks.h b/src/frontends/gnome/diaprint_callbacks.h new file mode 100644 index 0000000000..7c6cec9af0 --- /dev/null +++ b/src/frontends/gnome/diaprint_callbacks.h @@ -0,0 +1,36 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== */ + +#include + + +void +diaprint_on_diaprint_show (GtkWidget *widget, + gpointer user_data); + +void +diaprint_on_print_all_toggled (GtkToggleButton *togglebutton, + gpointer user_data); + +void +diaprint_on_print_pages_toggled (GtkToggleButton *togglebutton, + gpointer user_data); + +void +diaprint_on_printto_file_toggled (GtkToggleButton *togglebutton, + gpointer user_data); + +void +diaprint_on_printto_printer_toggled (GtkToggleButton *togglebutton, + gpointer user_data); + +void +diaprint_on_print_from_changed (GtkEditable *editable, + gpointer user_data); + diff --git a/src/frontends/gnome/diaprint_interface.c b/src/frontends/gnome/diaprint_interface.c new file mode 100644 index 0000000000..693beb09c9 --- /dev/null +++ b/src/frontends/gnome/diaprint_interface.c @@ -0,0 +1,424 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include + +#include + +#include "diaprint_callbacks.h" +#include "diaprint_interface.h" +#include "support.h" + +GtkWidget* +create_DiaPrint (void) +{ + GtkWidget *DiaPrint; + GtkWidget *dialog_vbox1; + GtkWidget *vbox1; + GtkWidget *hbox1; + GtkWidget *frame2; + GtkWidget *vbox2; + GSList *print_group = NULL; + guint print_all_key; + GtkWidget *print_all; + guint print_odd_key; + GtkWidget *print_odd; + guint print_even_key; + GtkWidget *print_even; + GtkWidget *hbox2; + guint print_pages_key; + GtkWidget *print_pages; + GtkWidget *label1; + GtkObject *print_from_adj; + GtkWidget *print_from; + GtkWidget *label2; + GtkObject *print_to_adj; + GtkWidget *print_to; + GtkWidget *vbox3; + GtkWidget *frame3; + GtkWidget *vbox4; + GSList *order_group = NULL; + guint order_normal_key; + GtkWidget *order_normal; + guint order_reverse_key; + GtkWidget *order_reverse; + GtkWidget *frame4; + GtkWidget *vbox5; + guint copies_unsorted_key; + GtkWidget *copies_unsorted; + GtkWidget *hbox3; + GtkWidget *label3; + GtkObject *copies_count_adj; + GtkWidget *copies_count; + GtkWidget *frame1; + GtkWidget *table1; + GSList *printto_group = NULL; + guint printto_file_key; + GtkWidget *printto_file; + guint printto_printer_key; + GtkWidget *printto_printer; + GtkWidget *printto_fileentry; + GtkWidget *combo_entry1; + GtkWidget *printto_printcommand; + GtkWidget *combo_entry2; + GtkWidget *dialog_action_area1; + GtkWidget *button_print; + GtkWidget *button_cancel; + GtkAccelGroup *accel_group; + + accel_group = gtk_accel_group_new (); + + DiaPrint = gnome_dialog_new (_("Print"), NULL); + gtk_object_set_data (GTK_OBJECT (DiaPrint), "DiaPrint", DiaPrint); + gtk_container_set_border_width (GTK_CONTAINER (DiaPrint), 2); + GTK_WINDOW (DiaPrint)->type = GTK_WINDOW_DIALOG; + gtk_window_set_policy (GTK_WINDOW (DiaPrint), FALSE, FALSE, FALSE); + + dialog_vbox1 = GNOME_DIALOG (DiaPrint)->vbox; + gtk_object_set_data (GTK_OBJECT (DiaPrint), "dialog_vbox1", dialog_vbox1); + gtk_widget_show (dialog_vbox1); + + vbox1 = gtk_vbox_new (FALSE, 0); + gtk_widget_ref (vbox1); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "vbox1", vbox1, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox1); + gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0); + + hbox1 = gtk_hbox_new (FALSE, 0); + gtk_widget_ref (hbox1); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "hbox1", hbox1, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbox1); + gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0); + + frame2 = gtk_frame_new (_("Print")); + gtk_widget_ref (frame2); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "frame2", frame2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (frame2); + gtk_box_pack_start (GTK_BOX (hbox1), frame2, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (frame2), 2); + + vbox2 = gtk_vbox_new (FALSE, 0); + gtk_widget_ref (vbox2); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "vbox2", vbox2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox2); + gtk_container_add (GTK_CONTAINER (frame2), vbox2); + + print_all = gtk_radio_button_new_with_label (print_group, ""); + print_all_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (print_all)->child), + _("All Pa_ges")); + gtk_widget_add_accelerator (print_all, "clicked", accel_group, + print_all_key, GDK_MOD1_MASK, 0); + print_group = gtk_radio_button_group (GTK_RADIO_BUTTON (print_all)); + gtk_widget_ref (print_all); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "print_all", print_all, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (print_all); + gtk_box_pack_start (GTK_BOX (vbox2), print_all, FALSE, FALSE, 0); + + print_odd = gtk_radio_button_new_with_label (print_group, ""); + print_odd_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (print_odd)->child), + _("_Only Odd Pages")); + gtk_widget_add_accelerator (print_odd, "clicked", accel_group, + print_odd_key, GDK_MOD1_MASK, 0); + print_group = gtk_radio_button_group (GTK_RADIO_BUTTON (print_odd)); + gtk_widget_ref (print_odd); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "print_odd", print_odd, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (print_odd); + gtk_box_pack_start (GTK_BOX (vbox2), print_odd, FALSE, FALSE, 0); + + print_even = gtk_radio_button_new_with_label (print_group, ""); + print_even_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (print_even)->child), + _("Only _Even Pages")); + gtk_widget_add_accelerator (print_even, "clicked", accel_group, + print_even_key, GDK_MOD1_MASK, 0); + print_group = gtk_radio_button_group (GTK_RADIO_BUTTON (print_even)); + gtk_widget_ref (print_even); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "print_even", print_even, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (print_even); + gtk_box_pack_start (GTK_BOX (vbox2), print_even, FALSE, FALSE, 0); + + hbox2 = gtk_hbox_new (FALSE, 0); + gtk_widget_ref (hbox2); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "hbox2", hbox2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbox2); + gtk_box_pack_start (GTK_BOX (vbox2), hbox2, TRUE, TRUE, 0); + + print_pages = gtk_check_button_new_with_label (""); + print_pages_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (print_pages)->child), + _("Page_s")); + gtk_widget_add_accelerator (print_pages, "clicked", accel_group, + print_pages_key, GDK_MOD1_MASK, 0); + gtk_widget_ref (print_pages); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "print_pages", print_pages, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (print_pages); + gtk_box_pack_start (GTK_BOX (hbox2), print_pages, FALSE, FALSE, 0); + + label1 = gtk_label_new (_("from")); + gtk_widget_ref (label1); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "label1", label1, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label1); + gtk_box_pack_start (GTK_BOX (hbox2), label1, FALSE, FALSE, 0); + gtk_misc_set_padding (GTK_MISC (label1), 1, 0); + + print_from_adj = gtk_adjustment_new (1, 1, 100000, 1, 10, 10); + print_from = gtk_spin_button_new (GTK_ADJUSTMENT (print_from_adj), 1, 0); + gtk_widget_ref (print_from); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "print_from", print_from, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (print_from); + gtk_box_pack_start (GTK_BOX (hbox2), print_from, FALSE, FALSE, 0); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (print_from), TRUE); + + label2 = gtk_label_new (_("to")); + gtk_widget_ref (label2); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "label2", label2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label2); + gtk_box_pack_start (GTK_BOX (hbox2), label2, FALSE, FALSE, 0); + gtk_misc_set_padding (GTK_MISC (label2), 1, 0); + + print_to_adj = gtk_adjustment_new (1, 1, 100000, 1, 10, 10); + print_to = gtk_spin_button_new (GTK_ADJUSTMENT (print_to_adj), 1, 0); + gtk_widget_ref (print_to); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "print_to", print_to, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (print_to); + gtk_box_pack_start (GTK_BOX (hbox2), print_to, FALSE, FALSE, 0); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (print_to), TRUE); + + vbox3 = gtk_vbox_new (FALSE, 0); + gtk_widget_ref (vbox3); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "vbox3", vbox3, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox3); + gtk_box_pack_start (GTK_BOX (hbox1), vbox3, TRUE, TRUE, 0); + + frame3 = gtk_frame_new (_("Order")); + gtk_widget_ref (frame3); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "frame3", frame3, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (frame3); + gtk_box_pack_start (GTK_BOX (vbox3), frame3, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (frame3), 2); + + vbox4 = gtk_vbox_new (FALSE, 0); + gtk_widget_ref (vbox4); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "vbox4", vbox4, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox4); + gtk_container_add (GTK_CONTAINER (frame3), vbox4); + + order_normal = gtk_radio_button_new_with_label (order_group, ""); + order_normal_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (order_normal)->child), + _("_Normal Order")); + gtk_widget_add_accelerator (order_normal, "clicked", accel_group, + order_normal_key, GDK_MOD1_MASK, 0); + order_group = gtk_radio_button_group (GTK_RADIO_BUTTON (order_normal)); + gtk_widget_ref (order_normal); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "order_normal", order_normal, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (order_normal); + gtk_box_pack_start (GTK_BOX (vbox4), order_normal, FALSE, FALSE, 0); + + order_reverse = gtk_radio_button_new_with_label (order_group, ""); + order_reverse_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (order_reverse)->child), + _("_Reverse Order")); + gtk_widget_add_accelerator (order_reverse, "clicked", accel_group, + order_reverse_key, GDK_MOD1_MASK, 0); + order_group = gtk_radio_button_group (GTK_RADIO_BUTTON (order_reverse)); + gtk_widget_ref (order_reverse); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "order_reverse", order_reverse, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (order_reverse); + gtk_box_pack_start (GTK_BOX (vbox4), order_reverse, FALSE, FALSE, 0); + + frame4 = gtk_frame_new (_("Copies")); + gtk_widget_ref (frame4); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "frame4", frame4, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (frame4); + gtk_box_pack_start (GTK_BOX (vbox3), frame4, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (frame4), 2); + + vbox5 = gtk_vbox_new (FALSE, 0); + gtk_widget_ref (vbox5); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "vbox5", vbox5, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox5); + gtk_container_add (GTK_CONTAINER (frame4), vbox5); + + copies_unsorted = gtk_check_button_new_with_label (""); + copies_unsorted_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (copies_unsorted)->child), + _("_Unsorted")); + gtk_widget_add_accelerator (copies_unsorted, "clicked", accel_group, + copies_unsorted_key, GDK_MOD1_MASK, 0); + gtk_widget_ref (copies_unsorted); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "copies_unsorted", copies_unsorted, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (copies_unsorted); + gtk_box_pack_start (GTK_BOX (vbox5), copies_unsorted, FALSE, FALSE, 0); + + hbox3 = gtk_hbox_new (FALSE, 0); + gtk_widget_ref (hbox3); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "hbox3", hbox3, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbox3); + gtk_box_pack_start (GTK_BOX (vbox5), hbox3, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (hbox3), 2); + + label3 = gtk_label_new (_("Count")); + gtk_widget_ref (label3); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "label3", label3, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label3); + gtk_box_pack_start (GTK_BOX (hbox3), label3, FALSE, FALSE, 0); + gtk_misc_set_padding (GTK_MISC (label3), 3, 0); + + copies_count_adj = gtk_adjustment_new (1, 1, 100000, 1, 10, 10); + copies_count = gtk_spin_button_new (GTK_ADJUSTMENT (copies_count_adj), 1, 0); + gtk_widget_ref (copies_count); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "copies_count", copies_count, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (copies_count); + gtk_box_pack_start (GTK_BOX (hbox3), copies_count, TRUE, TRUE, 2); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (copies_count), TRUE); + + frame1 = gtk_frame_new (_("Print to")); + gtk_widget_ref (frame1); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "frame1", frame1, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (frame1); + gtk_box_pack_start (GTK_BOX (vbox1), frame1, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (frame1), 2); + + table1 = gtk_table_new (2, 2, FALSE); + gtk_widget_ref (table1); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "table1", table1, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (table1); + gtk_container_add (GTK_CONTAINER (frame1), table1); + + printto_file = gtk_radio_button_new_with_label (printto_group, ""); + printto_file_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (printto_file)->child), + _("_File")); + gtk_widget_add_accelerator (printto_file, "clicked", accel_group, + printto_file_key, GDK_MOD1_MASK, 0); + printto_group = gtk_radio_button_group (GTK_RADIO_BUTTON (printto_file)); + gtk_widget_ref (printto_file); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "printto_file", printto_file, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (printto_file); + gtk_table_attach (GTK_TABLE (table1), printto_file, 0, 1, 1, 2, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + + printto_printer = gtk_radio_button_new_with_label (printto_group, ""); + printto_printer_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (printto_printer)->child), + _("_Printer")); + gtk_widget_add_accelerator (printto_printer, "clicked", accel_group, + printto_printer_key, GDK_MOD1_MASK, 0); + printto_group = gtk_radio_button_group (GTK_RADIO_BUTTON (printto_printer)); + gtk_widget_ref (printto_printer); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "printto_printer", printto_printer, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (printto_printer); + gtk_table_attach (GTK_TABLE (table1), printto_printer, 0, 1, 0, 1, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (printto_printer), TRUE); + + printto_fileentry = gnome_file_entry_new ("diaprint_printto_fileentry", NULL); + gtk_widget_ref (printto_fileentry); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "printto_fileentry", printto_fileentry, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (printto_fileentry); + gtk_table_attach (GTK_TABLE (table1), printto_fileentry, 1, 2, 1, 2, + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_container_set_border_width (GTK_CONTAINER (printto_fileentry), 3); + + combo_entry1 = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (printto_fileentry)); + gtk_widget_ref (combo_entry1); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "combo_entry1", combo_entry1, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (combo_entry1); + + printto_printcommand = gnome_entry_new ("diaprint_printto_printcommand"); + gtk_widget_ref (printto_printcommand); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "printto_printcommand", printto_printcommand, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (printto_printcommand); + gtk_table_attach (GTK_TABLE (table1), printto_printcommand, 1, 2, 0, 1, + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_container_set_border_width (GTK_CONTAINER (printto_printcommand), 3); + + combo_entry2 = gnome_entry_gtk_entry (GNOME_ENTRY (printto_printcommand)); + gtk_widget_ref (combo_entry2); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "combo_entry2", combo_entry2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (combo_entry2); + + dialog_action_area1 = GNOME_DIALOG (DiaPrint)->action_area; + gtk_object_set_data (GTK_OBJECT (DiaPrint), "dialog_action_area1", dialog_action_area1); + gtk_widget_show (dialog_action_area1); + gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); + gtk_button_box_set_spacing (GTK_BUTTON_BOX (dialog_action_area1), 8); + + gnome_dialog_append_button_with_pixmap (GNOME_DIALOG (DiaPrint), + _("Print"), GNOME_STOCK_PIXMAP_PRINT); + button_print = g_list_last (GNOME_DIALOG (DiaPrint)->buttons)->data; + gtk_widget_ref (button_print); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "button_print", button_print, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (button_print); + GTK_WIDGET_SET_FLAGS (button_print, GTK_CAN_DEFAULT); + + gnome_dialog_append_button (GNOME_DIALOG (DiaPrint), GNOME_STOCK_BUTTON_CANCEL); + button_cancel = g_list_last (GNOME_DIALOG (DiaPrint)->buttons)->data; + gtk_widget_ref (button_cancel); + gtk_object_set_data_full (GTK_OBJECT (DiaPrint), "button_cancel", button_cancel, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (button_cancel); + GTK_WIDGET_SET_FLAGS (button_cancel, GTK_CAN_DEFAULT); + + gtk_signal_connect (GTK_OBJECT (DiaPrint), "show", + GTK_SIGNAL_FUNC (diaprint_on_diaprint_show), + NULL); + gtk_signal_connect (GTK_OBJECT (print_pages), "toggled", + GTK_SIGNAL_FUNC (diaprint_on_print_pages_toggled), + NULL); + gtk_signal_connect (GTK_OBJECT (print_from), "changed", + GTK_SIGNAL_FUNC (diaprint_on_print_from_changed), + NULL); + gtk_signal_connect (GTK_OBJECT (printto_file), "toggled", + GTK_SIGNAL_FUNC (diaprint_on_printto_file_toggled), + NULL); + gtk_signal_connect (GTK_OBJECT (printto_printer), "toggled", + GTK_SIGNAL_FUNC (diaprint_on_printto_printer_toggled), + NULL); + + gtk_widget_grab_focus (button_print); + gtk_widget_grab_default (button_print); + gtk_window_add_accel_group (GTK_WINDOW (DiaPrint), accel_group); + + return DiaPrint; +} + diff --git a/src/frontends/gnome/diaprint_interface.h b/src/frontends/gnome/diaprint_interface.h new file mode 100644 index 0000000000..bf9e354101 --- /dev/null +++ b/src/frontends/gnome/diaprint_interface.h @@ -0,0 +1,5 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +GtkWidget* create_DiaPrint (void); diff --git a/src/frontends/gnome/support.c b/src/frontends/gnome/support.c new file mode 100644 index 0000000000..c76f33308d --- /dev/null +++ b/src/frontends/gnome/support.c @@ -0,0 +1,146 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include + +#include + +#include "support.h" + +/* This is an internally used function to create pixmaps. */ +static GtkWidget* create_dummy_pixmap (GtkWidget *widget, + gboolean gnome_pixmap); + +GtkWidget* +lookup_widget (GtkWidget *widget, + const gchar *widget_name) +{ + GtkWidget *parent, *found_widget; + + for (;;) + { + if (GTK_IS_MENU (widget)) + parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); + else + parent = widget->parent; + if (parent == NULL) + break; + widget = parent; + } + + found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget), + widget_name); + if (!found_widget) + g_warning ("Widget not found: %s", widget_name); + return found_widget; +} + +/* This is a dummy pixmap we use when a pixmap can't be found. */ +static char *dummy_pixmap_xpm[] = { +/* columns rows colors chars-per-pixel */ +"1 1 1 1", +" c None", +/* pixels */ +" ", +" " +}; + +/* This is an internally used function to create pixmaps. */ +static GtkWidget* +create_dummy_pixmap (GtkWidget *widget, + gboolean gnome_pixmap) +{ + GdkColormap *colormap; + GdkPixmap *gdkpixmap; + GdkBitmap *mask; + GtkWidget *pixmap; + + if (gnome_pixmap) + { + return gnome_pixmap_new_from_xpm_d (dummy_pixmap_xpm); + } + + colormap = gtk_widget_get_colormap (widget); + gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, + NULL, dummy_pixmap_xpm); + if (gdkpixmap == NULL) + g_error ("Couldn't create replacement pixmap."); + pixmap = gtk_pixmap_new (gdkpixmap, mask); + gdk_pixmap_unref (gdkpixmap); + gdk_bitmap_unref (mask); + return pixmap; +} + +/* This is an internally used function to create pixmaps. */ +GtkWidget* +create_pixmap (GtkWidget *widget, + const gchar *filename, + gboolean gnome_pixmap) +{ + GtkWidget *pixmap; + GdkColormap *colormap; + GdkPixmap *gdkpixmap; + GdkBitmap *mask; + gchar *pathname; + + if (!filename || !filename[0]) + return create_dummy_pixmap (widget, gnome_pixmap); + + pathname = gnome_pixmap_file (filename); + if (!pathname) + { + g_warning (_("Couldn't find pixmap file: %s"), filename); + return create_dummy_pixmap (widget, gnome_pixmap); + } + + if (gnome_pixmap) + { + pixmap = gnome_pixmap_new_from_file (pathname); + g_free (pathname); + return pixmap; + } + + colormap = gtk_widget_get_colormap (widget); + gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask, + NULL, pathname); + if (gdkpixmap == NULL) + { + g_warning (_("Couldn't create pixmap from file: %s"), pathname); + g_free (pathname); + return create_dummy_pixmap (widget, gnome_pixmap); + } + g_free (pathname); + + pixmap = gtk_pixmap_new (gdkpixmap, mask); + gdk_pixmap_unref (gdkpixmap); + gdk_bitmap_unref (mask); + return pixmap; +} + +/* This is an internally used function to create imlib images. */ +GdkImlibImage* +create_image (const gchar *filename) +{ + GdkImlibImage *image; + gchar *pathname; + + pathname = gnome_pixmap_file (filename); + if (!pathname) + { + g_warning (_("Couldn't find pixmap file: %s"), filename); + return NULL; + } + + image = gdk_imlib_load_image (pathname); + g_free (pathname); + return image; +} + diff --git a/src/frontends/gnome/support.h b/src/frontends/gnome/support.h new file mode 100644 index 0000000000..d9bb0728a7 --- /dev/null +++ b/src/frontends/gnome/support.h @@ -0,0 +1,34 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +#include + +/* + * Public Functions. + */ + +/* + * This function returns a widget in a component created by Glade. + * Call it with the toplevel widget in the component (i.e. a window/dialog), + * or alternatively any widget in the component, and the name of the widget + * you want returned. + */ +GtkWidget* lookup_widget (GtkWidget *widget, + const gchar *widget_name); + +/* get_widget() is deprecated. Use lookup_widget instead. */ +#define get_widget lookup_widget + + +/* + * Private Functions. + */ + +/* This is used to create the pixmaps in the interface. */ +GtkWidget* create_pixmap (GtkWidget *widget, + const gchar *filename, + gboolean gnome_pixmap); + +GdkImlibImage* create_image (const gchar *filename); + diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index 53c8f0dc68..4c34b0ea53 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -9,11 +9,11 @@ * */ +#include + #ifdef __GNUG__ #pragma implementation -#endif - -#include +#endif #include "lyx_gui_misc.h" #include "gettext.h" @@ -38,9 +38,7 @@ #include "RadioButtonGroup.h" -#ifdef ENABLE_ASSERTIONS #include "support/LAssert.h" -#endif using std::endl; @@ -48,18 +46,18 @@ C_RETURNCB(FormGraphics, WMHideCB) C_GENERICCB(FormGraphics, OKCB) C_GENERICCB(FormGraphics, ApplyCB) C_GENERICCB(FormGraphics, CancelCB) -C_GENERICCB(FormGraphics, BrowseCB) +C_GENERICCB(FormGraphics, BrowseCB) C_GENERICCB(FormGraphics, AdvancedOptionsCB) C_GENERICCB(FormGraphics, InputCB) - + FormGraphics::FormGraphics(LyXView * lv, Dialogs * d) - : dialog_(0), lv_(lv), d_(d), inset_(0), - // The buttons c-tor values are the number of buttons we use - // This is only to reduce memory waste. - widthButtons(5), heightButtons(4), displayButtons(4), - ih_(0), h_(0), u_(0), - last_image_path(".") + : dialog_(0), lv_(lv), d_(d), inset_(0), + // The buttons c-tor values are the number of buttons we use + // This is only to reduce memory waste. + widthButtons(5), heightButtons(4), displayButtons(4), + ih_(0), h_(0), u_(0), + last_image_path(".") { // let the dialog be shown // This is a permanent connection so we won't bother @@ -76,150 +74,146 @@ FormGraphics::~FormGraphics() void FormGraphics::build() { - dialog_ = build_graphics(); -#ifdef ENABLE_ASSERTIONS - Assert(dialog_ != 0); -#endif - if (!dialog_) - return; + dialog_ = build_graphics(); + Assert(dialog_ != 0); + if (!dialog_) + return ; - // This is the place to add settings of the dialog that did not go - // to the .fd file. + // This is the place to add settings of the dialog that did not go + // to the .fd file. - // Set the input widgets to issue a callback to input() whenever - // they change, so we can verify their content. - fl_set_input_return(dialog_->input_width, - FL_RETURN_CHANGED); - fl_set_input_return(dialog_->input_height, - FL_RETURN_CHANGED); - fl_set_input_return(dialog_->input_filename, - FL_RETURN_CHANGED); -// fl_set_input_return(dialog_->input_rotate_angle, -// FL_RETURN_CHANGED); - - // Set the maximum characters that can be written in the input texts. - fl_set_input_maxchars(dialog_->input_width, WIDTH_MAXDIGITS); - fl_set_input_maxchars(dialog_->input_height, HEIGHT_MAXDIGITS); - fl_set_input_maxchars(dialog_->input_filename, FILENAME_MAXCHARS); - fl_set_input_maxchars(dialog_->input_rotate_angle, ROTATE_MAXCHARS); - - // Set input filter on width and height to make them accept only - // unsigned numbers. - fl_set_input_filter(dialog_->input_width, - fl_unsigned_int_filter); - fl_set_input_filter(dialog_->input_height, - fl_unsigned_int_filter); + // Set the input widgets to issue a callback to input() whenever + // they change, so we can verify their content. + fl_set_input_return (dialog_->input_width, + FL_RETURN_CHANGED); + fl_set_input_return (dialog_->input_height, + FL_RETURN_CHANGED); + fl_set_input_return (dialog_->input_filename, + FL_RETURN_CHANGED); + // fl_set_input_return(dialog_->input_rotate_angle, + // FL_RETURN_CHANGED); - - // Add the widgets of the width radio buttons to their group - widthButtons.reset(); - widthButtons.registerRadioButton(dialog_->radio_width_default, - InsetGraphicsParams::DEFAULT_SIZE); - widthButtons.registerRadioButton(dialog_->radio_width_cm, - InsetGraphicsParams::CM); - widthButtons.registerRadioButton(dialog_->radio_width_inch, - InsetGraphicsParams::INCH); - widthButtons.registerRadioButton(dialog_->radio_width_percent_page, - InsetGraphicsParams::PERCENT_PAGE); - widthButtons.registerRadioButton(dialog_->radio_width_percent_column, - InsetGraphicsParams::PERCENT_COLUMN); - - // Add the widgets of the height radio buttons to their group - heightButtons.reset(); - heightButtons.registerRadioButton(dialog_->radio_height_default, - InsetGraphicsParams::DEFAULT_SIZE); - heightButtons.registerRadioButton(dialog_->radio_height_cm, - InsetGraphicsParams::CM); - heightButtons.registerRadioButton(dialog_->radio_height_inch, - InsetGraphicsParams::INCH); - heightButtons.registerRadioButton(dialog_->radio_height_percent_page, - InsetGraphicsParams::PERCENT_PAGE); - - // Add the widgets of the display radio buttons to their group - displayButtons.reset(); - displayButtons.registerRadioButton(dialog_->radio_display_color, - InsetGraphicsParams::COLOR); - displayButtons.registerRadioButton(dialog_->radio_display_grayscale, - InsetGraphicsParams::GRAYSCALE); - displayButtons.registerRadioButton(dialog_->radio_display_monochrome, - InsetGraphicsParams::MONOCHROME); - displayButtons.registerRadioButton(dialog_->radio_no_display, - InsetGraphicsParams::NONE); - - // Connect a signal to hide the window when the window manager orders it. - fl_set_form_atclose(dialog_->form, - C_FormGraphicsWMHideCB, 0); + // Set the maximum characters that can be written in the input texts. + fl_set_input_maxchars(dialog_->input_width, WIDTH_MAXDIGITS); + fl_set_input_maxchars(dialog_->input_height, HEIGHT_MAXDIGITS); + fl_set_input_maxchars(dialog_->input_filename, FILENAME_MAXCHARS); + fl_set_input_maxchars(dialog_->input_rotate_angle, ROTATE_MAXCHARS); + + // Set input filter on width and height to make them accept only + // unsigned numbers. + fl_set_input_filter(dialog_->input_width, + fl_unsigned_int_filter); + fl_set_input_filter(dialog_->input_height, + fl_unsigned_int_filter); + + + // Add the widgets of the width radio buttons to their group + widthButtons.reset(); + widthButtons.registerRadioButton(dialog_->radio_width_default, + InsetGraphicsParams::DEFAULT_SIZE); + widthButtons.registerRadioButton(dialog_->radio_width_cm, + InsetGraphicsParams::CM); + widthButtons.registerRadioButton(dialog_->radio_width_inch, + InsetGraphicsParams::INCH); + widthButtons.registerRadioButton(dialog_->radio_width_percent_page, + InsetGraphicsParams::PERCENT_PAGE); + widthButtons.registerRadioButton(dialog_->radio_width_percent_column, + InsetGraphicsParams::PERCENT_COLUMN); + + // Add the widgets of the height radio buttons to their group + heightButtons.reset(); + heightButtons.registerRadioButton(dialog_->radio_height_default, + InsetGraphicsParams::DEFAULT_SIZE); + heightButtons.registerRadioButton(dialog_->radio_height_cm, + InsetGraphicsParams::CM); + heightButtons.registerRadioButton(dialog_->radio_height_inch, + InsetGraphicsParams::INCH); + heightButtons.registerRadioButton(dialog_->radio_height_percent_page, + InsetGraphicsParams::PERCENT_PAGE); + + // Add the widgets of the display radio buttons to their group + displayButtons.reset(); + displayButtons.registerRadioButton(dialog_->radio_display_color, + InsetGraphicsParams::COLOR); + displayButtons.registerRadioButton(dialog_->radio_display_grayscale, + InsetGraphicsParams::GRAYSCALE); + displayButtons.registerRadioButton(dialog_->radio_display_monochrome, + InsetGraphicsParams::MONOCHROME); + displayButtons.registerRadioButton(dialog_->radio_no_display, + InsetGraphicsParams::NONE); + + // Connect a signal to hide the window when the window manager orders it. + fl_set_form_atclose(dialog_->form, + C_FormGraphicsWMHideCB, 0); } void FormGraphics::show() { - // If the dialog doesn't exist yet, build it. + // If the dialog doesn't exist yet, build it. if (!dialog_) { build(); } - // Update the form with the data from the inset. - update(); - - // If the form is visible + // Update the form with the data from the inset. + update(); + + // If the form is visible if (dialog_->form->visible) { - // Raise it. + // Raise it. fl_raise_form(dialog_->form); } else { - // Otherwise (invisible), show it. + // Otherwise (invisible), show it. fl_show_form(dialog_->form, - FL_PLACE_MOUSE, - FL_FULLBORDER, - _("Graphics")); + FL_PLACE_MOUSE, + FL_FULLBORDER, + _("Graphics")); - // And connect the signals 'updateBufferDependent', - // 'hideBufferDependent' and 'hideGraphics'. + // And connect the signals 'updateBufferDependent', + // 'hideBufferDependent' and 'hideGraphics'. u_ = d_->updateBufferDependent.connect(slot(this, - &FormGraphics::update)); + &FormGraphics::update)); h_ = d_->hideBufferDependent.connect(slot(this, - &FormGraphics::hide)); + &FormGraphics::hide)); } } void FormGraphics::showDialog(InsetGraphics* inset) { -#ifdef ENABLE_ASSERTIONS - Assert(inset != 0); -#endif + Assert(inset != 0); - // If we are connected to another inset, disconnect. - if (inset_) - ih_.disconnect(); - - inset_ = inset; - - if (inset_) { - ih_ = inset_->hide.connect(slot(this, &FormGraphics::hide)); - show(); - } + // If we are connected to another inset, disconnect. + if (inset_) + ih_.disconnect(); + + inset_ = inset; + + if (inset_) { + ih_ = inset_->hide.connect(slot(this, &FormGraphics::hide)); + show(); + } } void FormGraphics::hide() { - // If the dialog exists, and the form is allocated and visible. + // If the dialog exists, and the form is allocated and visible. if (dialog_ && dialog_->form && dialog_->form->visible) { - // Hide the form + // Hide the form fl_hide_form(dialog_->form); - // And disconnect the signals. - u_.disconnect(); + // And disconnect the signals. + u_.disconnect(); h_.disconnect(); - ih_.disconnect(); + ih_.disconnect(); - // Forget the inset. - inset_ = 0; + // Forget the inset. + inset_ = 0; } - // Most of the time, the dialog is not needed anymore, we'll free it - // now to save memory. - free(); + // Most of the time, the dialog is not needed anymore, we'll free it + // now to save memory. + free(); } @@ -229,7 +223,7 @@ void FormGraphics::free() widthButtons.reset(); heightButtons.reset(); displayButtons.reset(); - + // Free the form. delete dialog_; dialog_ = 0; @@ -237,156 +231,146 @@ void FormGraphics::free() void FormGraphics::apply() { -#ifdef ENABLE_ASSERTIONS - Assert(inset_ != 0); -#endif - if (! inset_) - return; + Assert(inset_ != 0); - // Take all dialog details and insert them to the inset. + // Take all dialog details and insert them to the inset. - // Create the parameters structure and fill the data from the dialog. - InsetGraphicsParams igp; + // Create the parameters structure and fill the data from the dialog. + InsetGraphicsParams igp; - igp.filename = fl_get_input(dialog_->input_filename); + igp.filename = fl_get_input(dialog_->input_filename); - igp.display = static_cast - (displayButtons.getButton()); - - igp.widthResize = static_cast - (widthButtons.getButton()); - igp.widthSize = strToDbl(fl_get_input(dialog_->input_width)); + igp.display = static_cast < InsetGraphicsParams::DisplayType > + (displayButtons.getButton()); - igp.heightResize = static_cast - (heightButtons.getButton()); - igp.heightSize = strToDbl(fl_get_input(dialog_->input_height)); + igp.widthResize = static_cast < InsetGraphicsParams::Resize > + (widthButtons.getButton()); + igp.widthSize = strToDbl(fl_get_input(dialog_->input_width)); - igp.rotateAngle = strToInt(fl_get_input(dialog_->input_rotate_angle)); - if (igp.rotateAngle >= 360) - igp.rotateAngle = igp.rotateAngle % 360; - if (igp.rotateAngle <= -360) - igp.rotateAngle = - ((-igp.rotateAngle) % 360); - - igp.subcaption = fl_get_button(dialog_->check_subcaption); - igp.subcaptionText = fl_get_input(dialog_->input_subcaption); + igp.heightResize = static_cast < InsetGraphicsParams::Resize > + (heightButtons.getButton()); + igp.heightSize = strToDbl(fl_get_input(dialog_->input_height)); - igp.inlineFigure = fl_get_button(dialog_->check_inline); - -#ifdef ENABLE_ASSERTIONS - igp.testInvariant(); -#endif + igp.rotateAngle = strToInt(fl_get_input(dialog_->input_rotate_angle)); + if (igp.rotateAngle >= 360) + igp.rotateAngle = igp.rotateAngle % 360; + if (igp.rotateAngle <= -360) + igp.rotateAngle = - (( -igp.rotateAngle) % 360); - // Set the parameters in the inset, it also returns true if the new - // parameters are different from what was in the inset already. - bool changed = inset_->setParams(igp); + igp.subcaption = fl_get_button(dialog_->check_subcaption); + igp.subcaptionText = fl_get_input(dialog_->input_subcaption); - // Tell LyX we've got a change, and mark the document dirty, if it changed. - lv_->view()->updateInset(inset_, changed); + igp.inlineFigure = fl_get_button(dialog_->check_inline); + + igp.testInvariant(); + + // Set the parameters in the inset, it also returns true if the new + // parameters are different from what was in the inset already. + bool changed = inset_->setParams(igp); + + // Tell LyX we've got a change, and mark the document dirty, if it changed. + lv_->view()->updateInset(inset_, changed); } void FormGraphics::update() { -#ifdef ENABLE_ASSERTIONS - Assert(inset_ != 0); -#endif - if (! inset_) - return; + Assert(inset_ != 0); - // Update dialog with details from inset - InsetGraphicsParams igp = inset_->getParams(); + // Update dialog with details from inset + InsetGraphicsParams igp = inset_->getParams(); - // Update the filename input field - fl_set_input(dialog_->input_filename, - igp.filename.c_str()); + // Update the filename input field + fl_set_input(dialog_->input_filename, + igp.filename.c_str()); - // Update the display depth radio buttons - displayButtons.setButton(igp.display); - - // Update the width radio buttons and input field - widthButtons.setButton(igp.widthResize); - fl_set_input(dialog_->input_width, - tostr(igp.widthSize).c_str()); + // Update the display depth radio buttons + displayButtons.setButton(igp.display); - // Update the height radio buttons and input field - heightButtons.setButton(igp.heightResize); - fl_set_input(dialog_->input_height, - tostr(igp.heightSize).c_str()); + // Update the width radio buttons and input field + widthButtons.setButton(igp.widthResize); + fl_set_input(dialog_->input_width, + tostr(igp.widthSize).c_str()); - // Update the rotate angle - fl_set_input(dialog_->input_rotate_angle, - tostr(igp.rotateAngle).c_str()); - - // Update the subcaption check button and input field - fl_set_button(dialog_->check_subcaption, - igp.subcaption); - fl_set_input(dialog_->input_subcaption, - igp.subcaptionText.c_str()); - - // Update the inline figure check button - fl_set_button(dialog_->check_inline, - igp.inlineFigure); - - // Now make sure that the buttons are set correctly. - input(); + // Update the height radio buttons and input field + heightButtons.setButton(igp.heightResize); + fl_set_input(dialog_->input_height, + tostr(igp.heightSize).c_str()); + + // Update the rotate angle + fl_set_input(dialog_->input_rotate_angle, + tostr(igp.rotateAngle).c_str()); + + // Update the subcaption check button and input field + fl_set_button(dialog_->check_subcaption, + igp.subcaption); + fl_set_input(dialog_->input_subcaption, + igp.subcaptionText.c_str()); + + // Update the inline figure check button + fl_set_button(dialog_->check_inline, + igp.inlineFigure); + + // Now make sure that the buttons are set correctly. + input(); } -void FormGraphics::input() +void FormGraphics::input() { - // Put verifications that the dialog shows some sane values, - // if not disallow clicking on ok/apply. - // Possibly use a label in the bottom of the dialog to give the reason. + // Put verifications that the dialog shows some sane values, + // if not disallow clicking on ok/apply. + // Possibly use a label in the bottom of the dialog to give the reason. - // Is all input boxes convey a valid meaning? - bool inputOK = true; + // Is all input boxes convey a valid meaning? + bool inputOK = true; - // Things that we check (meaning they are incorrect states): - // 1. No filename specified. - // 2. Width radio button is not Default and width text is not a number. - // 3. Height radio button is not Default and height text is a not a number - - // Note: radio button default means that the user asks for the image - // to be included as is with no size change, in this case we don't need - // any width or height. - - // We verify now that there is a filename, it exists, it's a file - // and it's readable. - string filename = fl_get_input(dialog_->input_filename); - FileInfo file(filename); - if (filename.empty() - || !file.isOK() - || !file.exist() - || !file.isRegular() - || !file.readable() - ) - inputOK = false; + // Things that we check (meaning they are incorrect states): + // 1. No filename specified. + // 2. Width radio button is not Default and width text is not a number. + // 3. Height radio button is not Default and height text is a not a number - // Width radio button not default and no number. - if (!fl_get_button(dialog_->radio_width_default) - && strToDbl(fl_get_input(dialog_->input_width)) <= 0.0) { - - inputOK = false; - } + // Note: radio button default means that the user asks for the image + // to be included as is with no size change, in this case we don't need + // any width or height. - // Height radio button not default and no number. - if (!fl_get_button(dialog_->radio_height_default) - && strToDbl(fl_get_input(dialog_->input_height)) <= 0.0) { - - inputOK = false; - } + // We verify now that there is a filename, it exists, it's a file + // and it's readable. + string filename = fl_get_input(dialog_->input_filename); + FileInfo file(filename); + if (filename.empty() + || !file.isOK() + || !file.exist() + || !file.isRegular() + || !file.readable() + ) + inputOK = false; + + // Width radio button not default and no number. + if (!fl_get_button(dialog_->radio_width_default) + && strToDbl(fl_get_input(dialog_->input_width)) <= 0.0) { + + inputOK = false; + } + + // Height radio button not default and no number. + if (!fl_get_button(dialog_->radio_height_default) + && strToDbl(fl_get_input(dialog_->input_height)) <= 0.0) { + + inputOK = false; + } - // Now set the buttons to the correct state. - if (inputOK && ! lv_->buffer()->isReadonly()) { - fl_activate_object(dialog_->button_ok); - fl_activate_object(dialog_->button_apply); - fl_set_object_lcol(dialog_->button_ok, FL_BLACK); - fl_set_object_lcol(dialog_->button_apply, FL_BLACK); - } else { - fl_deactivate_object(dialog_->button_ok); - fl_deactivate_object(dialog_->button_apply); - fl_set_object_lcol(dialog_->button_ok, FL_INACTIVE); - fl_set_object_lcol(dialog_->button_apply, FL_INACTIVE); - } + // Now set the buttons to the correct state. + if (inputOK && ! lv_->buffer()->isReadonly()) { + fl_activate_object(dialog_->button_ok); + fl_activate_object(dialog_->button_apply); + fl_set_object_lcol(dialog_->button_ok, FL_BLACK); + fl_set_object_lcol(dialog_->button_apply, FL_BLACK); + } else { + fl_deactivate_object(dialog_->button_ok); + fl_deactivate_object(dialog_->button_apply); + fl_set_object_lcol(dialog_->button_ok, FL_INACTIVE); + fl_set_object_lcol(dialog_->button_apply, FL_INACTIVE); + } } @@ -398,40 +382,40 @@ extern string user_lyxdir; // Need to move this to the form_graphics string FormGraphics::browseFile(string const & filename) { - if (! filename.empty() ) - last_image_path = OnlyPath(filename); + if (! filename.empty() ) + last_image_path = OnlyPath(filename); - // Does user clipart directory exist? - string bufclip = AddName (user_lyxdir, "clipart"); - FileInfo fileInfo(bufclip); - if (!(fileInfo.isOK() && fileInfo.isDir())) - // No - bail out to system clipart directory - bufclip = AddName (system_lyxdir, "clipart"); + // Does user clipart directory exist? + string bufclip = AddName (user_lyxdir, "clipart"); + FileInfo fileInfo(bufclip); + if (!(fileInfo.isOK() && fileInfo.isDir())) + // No - bail out to system clipart directory + bufclip = AddName (system_lyxdir, "clipart"); - LyXFileDlg fileDlg; - fileDlg.SetButton(0, _("Clipart"), bufclip); + LyXFileDlg fileDlg; + fileDlg.SetButton(0, _("Clipart"), bufclip); - bool error = false; - string buf; - do { - string p = fileDlg.Select(_("Graphics"), - last_image_path, - "*(ps|png)", filename); + bool error = false; + string buf; + do { + string p = fileDlg.Select(_("Graphics"), + last_image_path, + "*(ps|png)", filename); - if (p.empty()) return p; + if (p.empty()) return p; - last_image_path = OnlyPath(p); + last_image_path = OnlyPath(p); - if (p.find_first_of("#~$% ") != string::npos) { + if (p.find_first_of("#~$% ") != string::npos) { WriteAlert(_("Filename can't contain any " - "of these characters:"), - // xgettext:no-c-format - _("space, '#', '~', '$' or '%'.")); + "of these characters:"), + // xgettext:no-c-format + _("space, '#', '~', '$' or '%'.")); error = true; } else { - error = false; - buf = p; - } + error = false; + buf = p; + } } while (error); return buf; @@ -439,29 +423,29 @@ string FormGraphics::browseFile(string const & filename) void FormGraphics::browse() { - // Get the filename from the dialog - string filename = fl_get_input(dialog_->input_filename); + // Get the filename from the dialog + string filename = fl_get_input(dialog_->input_filename); - // Show the file browser dialog - string new_filename = browseFile(filename); + // Show the file browser dialog + string new_filename = browseFile(filename); + + // Save the filename to the dialog + if (new_filename != filename && ! new_filename.empty()) { + fl_set_input(dialog_->input_filename, + new_filename.c_str()); + // The above set input doesn't cause an input event so we do + // it manually. Otherwise the user needs to cause an input event + // to get the ok/apply buttons to be activated. + input(); + } - // Save the filename to the dialog - if (new_filename != filename && ! new_filename.empty()) { - fl_set_input(dialog_->input_filename, - new_filename.c_str()); - // The above set input doesn't cause an input event so we do - // it manually. Otherwise the user needs to cause an input event - // to get the ok/apply buttons to be activated. - input(); - } - } int FormGraphics::WMHideCB(FL_FORM * form, void *) { // Ensure that the signal h is disconnected even if the // window manager is used to close the dialog. - FormGraphics * pre = static_cast(form->u_vdata); + FormGraphics * pre = static_cast < FormGraphics* > (form->u_vdata); pre->hide(); return FL_CANCEL; } @@ -469,41 +453,41 @@ int FormGraphics::WMHideCB(FL_FORM * form, void *) void FormGraphics::OKCB(FL_OBJECT * ob, long) { - FormGraphics * pre = static_cast(ob->form->u_vdata); - pre->apply(); + FormGraphics * pre = static_cast < FormGraphics* > (ob->form->u_vdata); + pre->apply(); pre->hide(); } void FormGraphics::ApplyCB(FL_OBJECT * ob, long) { - FormGraphics * pre = static_cast(ob->form->u_vdata); + FormGraphics * pre = static_cast < FormGraphics* > (ob->form->u_vdata); pre->apply(); } void FormGraphics::CancelCB(FL_OBJECT * ob, long) { - FormGraphics * pre = static_cast(ob->form->u_vdata); + FormGraphics * pre = static_cast < FormGraphics* > (ob->form->u_vdata); pre->hide(); } void FormGraphics::BrowseCB(FL_OBJECT * ob, long) { - FormGraphics * pre = static_cast(ob->form->u_vdata); - pre->browse(); + FormGraphics * pre = static_cast < FormGraphics* > (ob->form->u_vdata); + pre->browse(); } void FormGraphics::AdvancedOptionsCB(FL_OBJECT * /* ob */, long) { -// FormGraphics * pre = static_cast(ob->form->u_vdata); -// pre->showAdvancedOptions(); - lyxerr << "Advanced Options button depressed, " - "show advanced options dialog" - << endl; + // FormGraphics * pre = static_cast(ob->form->u_vdata); + // pre->showAdvancedOptions(); + lyxerr << "Advanced Options button depressed, " + "show advanced options dialog" + << endl; } void FormGraphics::InputCB(FL_OBJECT * ob, long) { - FormGraphics * pre = static_cast(ob->form->u_vdata); + FormGraphics * pre = static_cast < FormGraphics* > (ob->form->u_vdata); pre->input(); } diff --git a/src/frontends/xforms/FormGraphics.h b/src/frontends/xforms/FormGraphics.h index 4cba3e2ba6..111a5469ba 100644 --- a/src/frontends/xforms/FormGraphics.h +++ b/src/frontends/xforms/FormGraphics.h @@ -18,8 +18,6 @@ #ifndef FORMGRAPHICS_H #define FORMGRAPHICS_H -#include - #include "LString.h" #include "frontends/DialogBase.h" //#include "form_graphics.h" @@ -27,7 +25,7 @@ #ifdef __GNUG__ #pragma interface -#endif +#endif class Dialogs; // same arguement as in Dialogs.h s/LyX/UI/ @@ -38,14 +36,15 @@ struct FD_form_graphics; /** This class provides an XForms implementation of the FormGraphics Dialog. */ -class FormGraphics: public DialogBase { +class FormGraphics: public DialogBase +{ public: /// #FormGraphics x(LyXFunc ..., Dialogs ...);# FormGraphics(LyXView *, Dialogs *); /// ~FormGraphics(); /// - static int WMHideCB(FL_FORM *, void *); + static int WMHideCB(FL_FORM *, void *); /// static void OKCB(FL_OBJECT *, long); /// @@ -62,31 +61,31 @@ public: private: /// FormGraphics() - : widthButtons(5), heightButtons(4), displayButtons(4) {} +: widthButtons(5), heightButtons(4), displayButtons(4) {} // - FormGraphics(FormGraphics const &) : DialogBase() {} - +FormGraphics(FormGraphics const &) : DialogBase() {} + /// The maximum digits for the image width (cm, inch, percent) enum { - /// - WIDTH_MAXDIGITS = 3 - }; + /// + WIDTH_MAXDIGITS = 3 + }; /// The maximum digits for the image height (cm, inch, percent) enum { - /// - HEIGHT_MAXDIGITS = 3 + /// + HEIGHT_MAXDIGITS = 3 }; /// The maximum characters in the rotation angle (minus sign and 3 digits) enum { - /// - ROTATE_MAXCHARS = 4 + /// + ROTATE_MAXCHARS = 4 }; /// The maximum characters in a filename. enum { - /// - FILENAME_MAXCHARS = 1024 + /// + FILENAME_MAXCHARS = 1024 }; - + /**@name Slot Methods */ //@{ /// Save the active inset and show the dialog. @@ -108,7 +107,7 @@ private: /// Open the file browse dialog to select an image file. void browse(); //@} - + /// Build the dialog void build(); /// @@ -152,6 +151,7 @@ private: string last_image_path; //@} -}; +} +; -#endif +#endif diff --git a/src/frontends/xforms/RadioButtonGroup.C b/src/frontends/xforms/RadioButtonGroup.C index c90b43e98a..863aafff1f 100644 --- a/src/frontends/xforms/RadioButtonGroup.C +++ b/src/frontends/xforms/RadioButtonGroup.C @@ -9,12 +9,12 @@ * This file Copyright 2000 Baruch Even * ================================================= */ +#include #ifdef __GNUG__ #pragma implementation -#endif +#endif -#include #include "RadioButtonGroup.h" #include "debug.h" // for lyxerr @@ -28,76 +28,78 @@ using std::endl; void RadioButtonGroup::registerRadioButton(FL_OBJECT *button, int value) { - map.push_back( ButtonValuePair(button, value) ); + map.push_back( ButtonValuePair(button, value) ); } void RadioButtonGroup::reset() { - map.clear(); + map.clear(); } - // Functor to help us in our work, we should try to find how to achieve - // this with only STL predicates, but its easier to write this than to - // dig. If you can find the equivalent STL predicate combination, let me - // know. - // - // The idea is to take a pair and a value and return true when the second - // element in the pair equals the value. - template - struct equal_to_second_in_pair { - typedef bool result_type; - typedef T first_argument_type; - typedef typename T::second_type second_argument_type; +// Functor to help us in our work, we should try to find how to achieve +// this with only STL predicates, but its easier to write this than to +// dig. If you can find the equivalent STL predicate combination, let me +// know. +// +// The idea is to take a pair and a value and return true when the second +// element in the pair equals the value. +template < typename T > +struct equal_to_second_in_pair +{ + typedef bool result_type; + typedef T first_argument_type; + typedef typename T::second_type second_argument_type; - bool operator() ( - pair const & left, - typename T::second_type const & right) const - { - return left.second == right; - } - }; + bool operator() ( + pair < typename T::first_type, typename T::second_type > const & left, + typename T::second_type const & right) const + { + return left.second == right; + } +}; void RadioButtonGroup::setButton(int value) { - ButtonValueMap::const_iterator it = - find_if(map.begin(), map.end(), - bind2nd(equal_to_second_in_pair(), - value)); + ButtonValueMap::const_iterator it = + find_if(map.begin(), map.end(), + bind2nd(equal_to_second_in_pair < ButtonValuePair > (), + value)); + + // If we found nothing, report it and return + if (it == map.end()) { + lyxerr << "BUG: Requested value in RadioButtonGroup doesn't exists" + << endl; + } + else { + fl_set_button((*it).first, 1); + } - // If we found nothing, report it and return - if (it == map.end()) { - lyxerr << "BUG: Requested value in RadioButtonGroup doesn't exists" - << endl; - } else { - fl_set_button((*it).first, 1); - } - } -template +template < typename T > struct is_set_button { - bool operator() (T const & item) const - { - return fl_get_button( (item).first ); - } + bool operator() (T const & item) const + { + return fl_get_button( (item).first ); + } }; -int RadioButtonGroup::getButton() +int RadioButtonGroup::getButton() { - // Find the first button that is active - ButtonValueMap::iterator it = - find_if(map.begin(), map.end(), - is_set_button() ); + // Find the first button that is active + ButtonValueMap::iterator it = + find_if(map.begin(), map.end(), + is_set_button < ButtonValuePair > () ); - // If such a button was found, return its value. - if (it != map.end()) { - return (*it).second; - } + // If such a button was found, return its value. + if (it != map.end()) { + return (*it).second; + } - lyxerr << "BUG: No radio button found to be active." << endl; + lyxerr << "BUG: No radio button found to be active." << endl; - // Else return 0. - return 0; + // Else return 0. + return 0; } diff --git a/src/frontends/xforms/RadioButtonGroup.h b/src/frontends/xforms/RadioButtonGroup.h index 276ab0a748..77f223e2f7 100644 --- a/src/frontends/xforms/RadioButtonGroup.h +++ b/src/frontends/xforms/RadioButtonGroup.h @@ -21,38 +21,38 @@ #ifdef __GNUG__ #pragma interface -#endif +#endif -#include -#include +#include +#include using std::vector; using std::pair; #include FORMS_H_LOCATION -class RadioButtonGroup { +class RadioButtonGroup +{ public: - /// Constructor. Allocate space for 'n' items in the group. - RadioButtonGroup(unsigned n = 5) : map(n) - {}; - /// Destructor. Cleans up. - ~RadioButtonGroup() {}; - - /// Register a radio button with it's corresponding value. - void registerRadioButton(FL_OBJECT *button, int value); - /// Reset registrations. - void reset(); + /// Constructor. Allocate space for 'n' items in the group. + RadioButtonGroup(unsigned n = 5) : map(n) {}; + /// Destructor. Cleans up. + ~RadioButtonGroup() {}; - // Set the active button. - void setButton(int value); + /// Register a radio button with it's corresponding value. + void registerRadioButton(FL_OBJECT *button, int value); + /// Reset registrations. + void reset(); + + // Set the active button. + void setButton(int value); + + // Get the active button. + int getButton(); - // Get the active button. - int getButton(); - private: - typedef pair ButtonValuePair; - typedef vector ButtonValueMap; - ButtonValueMap map; + typedef pair < FL_OBJECT *, int > ButtonValuePair; + typedef vector < ButtonValuePair > ButtonValueMap; + ButtonValueMap map; }; -#endif +#endif diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 3a392cd681..806ffebbf6 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -32,7 +32,7 @@ Known BUGS: * Bug in FileDlg class (src/filedlg.[hC]) when selecting a file and then pressing ok, it counts as if no real selection done. Apparently it when choosing a file it doesn't update the select file input line. - + Current PROBLEMS: * How to support both PDF and PS output, should we do the conversion @@ -48,13 +48,13 @@ Current PROBLEMS: sizes, not to mention rotations! TODO Basics: - + * Add support for more features so that it will be better than insetfig. * Keep aspect ratio radio button - + * Create the GraphicsCache and FormatTranslator * Add inline viewing of image. - + TODO Before initial production release: * Replace insetfig everywhere * Read it's file format @@ -62,7 +62,7 @@ TODO Before initial production release: * Search for comments of the form // INSET_GRAPHICS: remove this when InsetFig is thrown. And act upon them. - + * Pop up a dialog if the widget version is higher than what we accept. * Finish the basic To-do list. * Extract the general logic of the dialog in order to allow easier porting @@ -70,7 +70,7 @@ TODO Before initial production release: platform dependent code in the appropriate dirs. TODO Extended features: - + * Advanced Latex tab folder. * Add even more options to make it better than insetfig. * Support for complete control over the latex parameters for TeXperts @@ -152,18 +152,18 @@ TODO Extended features: * transferring the file around. */ - + +#include + #ifdef __GNUG__ #pragma implementation -#endif - -#include +#endif #include "insets/insetgraphics.h" #include "insets/insetgraphicsParams.h" #include "graphics/GraphicsCache.h" #include "graphics/GraphicsCacheItem.h" - + #include "frontends/Dialogs.h" #include "LyXView.h" #include "buffer.h" @@ -184,21 +184,21 @@ using std::endl; // Initialize only those variables that do not have a constructor. InsetGraphics::InsetGraphics() -#ifdef IG_OLDPARAMS - : use_bb(false), hiresbb(false), angle(0.0), origin(DEFAULT) - ,keepaspectratio(false), scale(0.0), clip(false), draft(false) - ,cacheHandle(0) -#endif - : cacheHandle(0), pixmapInitialized(false) +#ifdef IG_OLDPARAMS + : use_bb(false), hiresbb(false), angle(0.0), origin(DEFAULT) + , keepaspectratio(false), scale(0.0), clip(false), draft(false) + , cacheHandle(0) +#endif + : cacheHandle(0), pixmapInitialized(false) {} InsetGraphics::~InsetGraphics() { - // Emits the hide signal to the dialog connected (if any) - hide(); + // Emits the hide signal to the dialog connected (if any) + hide(); } -int InsetGraphics::ascent(BufferView *, LyXFont const &) const +int InsetGraphics::ascent(BufferView *, LyXFont const &) const { if (pixmapInitialized) return cacheHandle->getHeight(); @@ -207,14 +207,14 @@ int InsetGraphics::ascent(BufferView *, LyXFont const &) const } -int InsetGraphics::descent(BufferView *, LyXFont const &) const +int InsetGraphics::descent(BufferView *, LyXFont const &) const { // this is not true if viewport is used and clip is not. return 0; } -int InsetGraphics::width(BufferView *, LyXFont const &) const +int InsetGraphics::width(BufferView *, LyXFont const &) const { if (pixmapInitialized) return cacheHandle->getWidth(); @@ -224,26 +224,29 @@ int InsetGraphics::width(BufferView *, LyXFont const &) const void InsetGraphics::draw(BufferView * bv, LyXFont const & font, - int baseline, float & x, bool) const + int baseline, float & x, bool) const { Painter & paint = bv->painter(); + int lwidth = width(bv, font); + int ldescent = descent(bv, font); + int lascent = ascent(bv, font); + // This will draw the graphics. If the graphics has not been loaded yet, // we draw just a rectangle. if (pixmapInitialized) { - paint.pixmap(int(x)+2, baseline - ascent(bv, font), - width(bv, font) - 4, - ascent(bv,font) + descent(bv,font), - pixmap); - } else { - paint.rectangle(int(x)+2, baseline - ascent(bv, font), - width(bv, font) - 4, - ascent(bv, font) + descent(bv, font)); + paint.pixmap(int(x) + 2, baseline - lascent, + lwidth - 4, lascent + ldescent, + pixmap); + } else { + paint.rectangle(int(x) + 2, baseline - lascent, + lwidth - 4, + lascent + ldescent); // Check if the image is now ready. if (cacheHandle && - (cacheHandle->getImageStatus() == GraphicsCacheItem::Loaded)) { + (cacheHandle->getImageStatus() == GraphicsCacheItem::Loaded)) { pixmap = cacheHandle->getImage(); pixmapInitialized = true; @@ -252,13 +255,14 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font, } } - x += width(bv, font); + // Add the image width to the row width. + x += lwidth; } void InsetGraphics::Edit(BufferView *bv, int, int, unsigned int) { - bv->owner()->getDialogs() -> showGraphics(this); + bv->owner()->getDialogs() -> showGraphics(this); } @@ -272,7 +276,7 @@ void InsetGraphics::Write(Buffer const * buf, ostream & os) const { os << "GRAPHICS FormatVersion 1" << endl; - params.Write(buf, os); + params.Write(buf, os); } #if 0 @@ -284,7 +288,7 @@ void InsetGraphics::Write(Buffer const * buf, ostream & os) const // The questions are: // 1. Is this cleaner? // 2. Is there no hidden performance costs? -// +// // Regarding 2 I can already see that we will have two copies of the strings // one in the data part of the program and one in the map, but that won't be // more than say 2K (overestimation here), there is no real benefit to put @@ -294,162 +298,163 @@ void InsetGraphics::Write(Buffer const * buf, ostream & os) const void InsetGraphics::Read(Buffer const * buf, LyXLex & lex) { - typedef map ReadActionMap; - static ReadActionMap const readMap; + typedef map < string, enum TOKENS > ReadActionMap; + static ReadActionMap const readMap; - bool finished = false; + bool finished = false; - while (lex.IsOK() && !finished) { - lex.next(); + while (lex.IsOK() && !finished) { + lex.next(); - string const token = lex.GetString(); - lyxerr.debug() << "Token: '" << token << '\'' << endl; + string const token = lex.GetString(); + lyxerr.debug() << "Token: '" << token << '\'' << endl; - if (token.empty()) - continue; - - ReadActionMap::const_iterator it = - readMap.find(token); + if (token.empty()) + continue; - if (it == readMap.end()) { - lyxerr << "Unknown keyword, skipping." << endl; - continue; - } - - switch (it.second) { - case FILENAME_TOKEN: - break; - case VERSION_TOKEN: - break; - default: - break; - } + ReadActionMap::const_iterator it = + readMap.find(token); - - } + if (it == readMap.end()) { + lyxerr << "Unknown keyword, skipping." << endl; + continue; + } + + switch (it.second) { + case FILENAME_TOKEN: + break; + case VERSION_TOKEN: + break; + default: + break; + } + + + } } -#endif +#endif -void InsetGraphics::Read(Buffer const * buf, LyXLex & lex) +void InsetGraphics::Read(Buffer const * buf, LyXLex & lex) { - bool finished = false; - - while (lex.IsOK() && !finished) { - lex.next(); - - string const token = lex.GetString(); - lyxerr.debug() << "Token: '" << token << '\'' << endl; + bool finished = false; - if (token.empty()) { - continue; - } else if (token == "\\end_inset") { - finished = true; - } else if (token == "FormatVersion") { - lex.next(); - int version = lex.GetInteger(); - if (version > 1) - lyxerr - << "This document was created with a newer Graphics widget" - ", You should use a newer version of LyX to read this" - " file." - << endl; - // TODO: Possibly open up a dialog? - } else { - if (! params.Read(buf, lex, token)) - lyxerr << "Unknown token, " << token << ",skipping." << endl; - } - } - - updateInset(); + while (lex.IsOK() && !finished) { + lex.next(); + + string const token = lex.GetString(); + lyxerr.debug() << "Token: '" << token << '\'' << endl; + + if (token.empty()) { + continue; + } else if (token == "\\end_inset") { + finished = true; + } else if (token == "FormatVersion") { + lex.next(); + int version = lex.GetInteger(); + if (version > 1) + lyxerr + << "This document was created with a newer Graphics widget" + ", You should use a newer version of LyX to read this" + " file." + << endl; + // TODO: Possibly open up a dialog? + } + else { + if (! params.Read(buf, lex, token)) + lyxerr << "Unknown token, " << token << ",skipping." << endl; + } + } + + updateInset(); } static void formatResize(ostream & os, char const *key, - InsetGraphicsParams::Resize resizeType, double size) + InsetGraphicsParams::Resize resizeType, double size) { - switch (resizeType) { - case InsetGraphicsParams::DEFAULT_SIZE: - break; - - case InsetGraphicsParams::CM: - os << key << '=' << size << "cm,"; - break; - - case InsetGraphicsParams::INCH: - os << key << '=' << size << "in,"; - break; - - case InsetGraphicsParams::PERCENT_PAGE: - os << key << '=' << size/100 << "\\text" << key << ','; - break; - - case InsetGraphicsParams::PERCENT_COLUMN: - os << key << '=' << size/100 << "\\column" << key << ','; - break; - - } + switch (resizeType) { + case InsetGraphicsParams::DEFAULT_SIZE: + break; + + case InsetGraphicsParams::CM: + os << key << '=' << size << "cm,"; + break; + + case InsetGraphicsParams::INCH: + os << key << '=' << size << "in,"; + break; + + case InsetGraphicsParams::PERCENT_PAGE: + os << key << '=' << size / 100 << "\\text" << key << ','; + break; + + case InsetGraphicsParams::PERCENT_COLUMN: + os << key << '=' << size / 100 << "\\column" << key << ','; + break; + + } } int InsetGraphics::Latex(Buffer const *buf, ostream & os, - bool /*fragile*/, bool/*fs*/) const + bool /*fragile*/, bool/*fs*/) const { // MISSING: We have to decide how to do the order of the options // that is dependent of order, like witdth, height, angle. Should // we rotate before scale? Should we let the user decide? // bool rot_before_scale; ? - // (BE) As a first step we should do a scale before rotate since this is - // more like the natural thought of how to do it. - // (BE) I believe that a priority list presented to the user with - // a default order would be the best, though it would be better to - // hide such a thing in an "Advanced options" dialog. - // (BE) This should go an advanced LaTeX options dialog. + // (BE) As a first step we should do a scale before rotate since this is + // more like the natural thought of how to do it. + // (BE) I believe that a priority list presented to the user with + // a default order would be the best, though it would be better to + // hide such a thing in an "Advanced options" dialog. + // (BE) This should go an advanced LaTeX options dialog. - // If there is no file specified, just output a message about it in - // the latex output. - if (params.filename.empty()) { - os << "\\fbox{\\rule[-0.5in]{0pt}{1in}" - << _("empty figure path") - << '}' - << endl; + // If there is no file specified, just output a message about it in + // the latex output. + if (params.filename.empty()) { + os << "\\fbox{\\rule[-0.5in]{0pt}{1in}" + << _("empty figure path") + << '}' + << endl; - return 1; - } + return 1; + } - // Calculate the options part of the command, we must do it to a string - // stream since we might have a trailing comma that we would like to remove - // before writing it to the output stream. + // Calculate the options part of the command, we must do it to a string + // stream since we might have a trailing comma that we would like to remove + // before writing it to the output stream. #ifdef HAVE_SSTREAM std::ostringstream options; #else ostrstream options; -#endif - - formatResize(options, "width", params.widthResize, params.widthSize); - formatResize(options, "height", params.heightResize, params.heightSize); +#endif - if (params.rotateAngle != 0) { - options << "angle=" - << params.rotateAngle << ','; - } - -#ifdef IG_OLDPARAMS + formatResize(options, "width", params.widthResize, params.widthSize); + formatResize(options, "height", params.heightResize, params.heightSize); + + if (params.rotateAngle != 0) { + options << "angle=" + << params.rotateAngle << ','; + } + +#ifdef IG_OLDPARAMS if (bb.isSet() && use_bb) { options << "bb=" - << bb.llx << ' ' << bb.lly << ' ' - << bb.urx << ' ' << bb.ury << ','; + << bb.llx << ' ' << bb.lly << ' ' + << bb.urx << ' ' << bb.ury << ','; } if (hiresbb) { options << "hiresbb,"; } if (viewport.isSet()) { options << "viewport=" - << viewport.llx << ' ' << viewport.lly << ' ' - << viewport.urx << ' ' << viewport.ury << ','; + << viewport.llx << ' ' << viewport.lly << ' ' + << viewport.urx << ' ' << viewport.ury << ','; } if (trim.isSet()) { options << "trim=" - << trim.llx << ' ' << trim.lly << ' ' - << trim.urx << ' ' << trim.ury << ','; + << trim.llx << ' ' << trim.lly << ' ' + << trim.urx << ' ' << trim.ury << ','; } if (natheight.value() != 0) { options << "natheight=" << natheight.asString() << ','; @@ -461,7 +466,7 @@ int InsetGraphics::Latex(Buffer const *buf, ostream & os, options << "angle=" << angle << ','; } if (origin != DEFAULT) { - switch(origin) { + switch (origin) { case DEFAULT: break; case LEFTTOP: options << "origin=lt,"; @@ -524,19 +529,19 @@ int InsetGraphics::Latex(Buffer const *buf, ostream & os, } if (!type.empty()) { options << "type=" << type << ','; - - // These should be present only when type is used. - if (!ext.empty()) { - options << "ext=" << type << ','; - } - if (!read.empty()) { - options << "read=" << type << ','; - } - if (!command.empty()) { - options << "command=" << type << ','; - } - } -#endif + + // These should be present only when type is used. + if (!ext.empty()) { + options << "ext=" << type << ','; + } + if (!read.empty()) { + options << "read=" << type << ','; + } + if (!command.empty()) { + options << "command=" << type << ','; + } + } +#endif #ifdef HAVE_SSTREAM string opts(options.str().c_str()); @@ -545,96 +550,96 @@ int InsetGraphics::Latex(Buffer const *buf, ostream & os, char * tmp = options.str(); string opts(tmp); delete [] tmp; -#endif +#endif opts = strip(opts, ','); - - // If it's not an inline image, surround it with the centering paragraph. - if (! params.inlineFigure) { - os << endl - << "\\vspace{0.3cm}" << endl - << "{\\par\\centering "; - } - - // Do we want subcaptions? - if (params.subcaption) { - os << "\\subfigure[" << params.subcaptionText << "]{"; - } - + + // If it's not an inline image, surround it with the centering paragraph. + if (! params.inlineFigure) { + os << endl + << "\\vspace{0.3cm}" << endl + << "{\\par\\centering "; + } + + // Do we want subcaptions? + if (params.subcaption) { + os << "\\subfigure[" << params.subcaptionText << "]{"; + } + // We never used the starred form, we use the "clip" option instead. - os << "\\includegraphics"; + os << "\\includegraphics"; if (!opts.empty()) { os << '[' << opts << ']'; } - // Make the filename relative to the lyx file - string filename = MakeRelPath(params.filename, OnlyPath(buf->fileName())); + // Make the filename relative to the lyx file + string filename = MakeRelPath(params.filename, OnlyPath(buf->fileName())); - // and remove the extension so the LaTeX will use whatever is - // appropriate (when there are several versions in different formats) - filename = ChangeExtension(filename, string()); + // and remove the extension so the LaTeX will use whatever is + // appropriate (when there are several versions in different formats) + filename = ChangeExtension(filename, string()); os << '{' << filename << '}'; - // Do we want a subcaption? - if (params.subcaption) { - // Close the subcaption command - os << '}'; - } - - // Is this an inline graphics? - if (!params.inlineFigure) { - os << " \\par}" << endl - << "\\vspace{0.3cm}" << endl; - } + // Do we want a subcaption? + if (params.subcaption) { + // Close the subcaption command + os << '}'; + } + + // Is this an inline graphics? + if (!params.inlineFigure) { + os << " \\par}" << endl + << "\\vspace{0.3cm}" << endl; + } + + // How do we decide to what format should we export? + // cacheHandle->>export(ImageType::EPS); + // cacheHandle->>export(ImageType::PNG); - // How do we decide to what format should we export? -// cacheHandle->>export(ImageType::EPS); -// cacheHandle->>export(ImageType::PNG); - return 1; } int InsetGraphics::Ascii(Buffer const *, ostream &) const { - // No graphics in ascii output. + // No graphics in ascii output. return 0; } int InsetGraphics::Linuxdoc(Buffer const *, ostream &) const { - // No graphics in LinuxDoc output. Should check how/what to add. + // No graphics in LinuxDoc output. Should check how/what to add. return 0; } int InsetGraphics::DocBook(Buffer const *, ostream &) const { - // No graphics in DocBook output. Should check how/what to add. + // No graphics in DocBook output. Should check how/what to add. return 0; } void InsetGraphics::Validate(LaTeXFeatures & features) const { - // If we have no image, we should not require anything. - if (params.filename.empty()) - return; + // If we have no image, we should not require anything. + if (params.filename.empty()) + return ; features.graphicx = true; - if (params.subcaption) - features.subfigure = true; + if (params.subcaption) + features.subfigure = true; } // Update the inset after parameters changed (read from file or changed in // dialog. void InsetGraphics::updateInset() { - // If file changed... + // If file changed... GraphicsCache * gc = GraphicsCache::getInstance(); GraphicsCacheItem * temp = 0; @@ -650,22 +655,22 @@ void InsetGraphics::updateInset() bool InsetGraphics::setParams(InsetGraphicsParams const & params) { // If nothing is changed, just return and say so. - if (this->params == params) - return false; + if (this->params == params) + return false; - // Copy the new parameters. - this->params = params; + // Copy the new parameters. + this->params = params; - // Update the inset with the new parameters. - updateInset(); - - // We have changed data, report it. - return true; + // Update the inset with the new parameters. + updateInset(); + + // We have changed data, report it. + return true; } InsetGraphicsParams InsetGraphics::getParams() const { - return params; + return params; } Inset * InsetGraphics::Clone() const diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index ddaeb84f92..a285b7929a 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -15,9 +15,7 @@ #ifdef __GNUG__ #pragma interface -#endif - -#include +#endif #include "insets/lyxinset.h" #include "insets/insetgraphicsParams.h" @@ -31,21 +29,23 @@ using SigC::Signal0; using SigC::slot; using SigC::Object; -#endif +#endif class Dialogs; /// #ifdef SIGC_CXX_NAMESPACES -class InsetGraphics : public Inset, public SigC::Object { +class InsetGraphics : public Inset, public SigC::Object +{ #else -class InsetGraphics : public Inset, public Object { -#endif +class InsetGraphics : public Inset, public Object +{ +#endif public: /// InsetGraphics(); - /// - ~InsetGraphics(); + /// + ~InsetGraphics(); /// int ascent(BufferView *, LyXFont const &) const; /// @@ -70,7 +70,7 @@ public: fragile commands by adding a \protect before. */ int Latex(Buffer const *, std::ostream &, - bool fragile, bool free_spc) const; + bool fragile, bool free_spc) const; /// int Ascii(Buffer const *, std::ostream &) const; /// @@ -79,43 +79,43 @@ public: int DocBook(Buffer const *, std::ostream &) const; /** Tell LyX what the latex features you need i.e. what latex packages - * you need to be included. - */ + * you need to be included. + */ void Validate(LaTeXFeatures & features) const; /// returns LyX code associated with the inset. Used for TOC, ...) Inset::Code LyxCode() const { return Inset::GRAPHICS_CODE; } - + /// Inset * Clone() const; - /// Set the inset parameters, used by the GUIndependent dialog. - /// Return true of new params are different from what was so far. - bool setParams(InsetGraphicsParams const & params); + /// Set the inset parameters, used by the GUIndependent dialog. + /// Return true of new params are different from what was so far. + bool setParams(InsetGraphicsParams const & params); - /// Get the inset parameters, used by the GUIndependent dialog. - InsetGraphicsParams getParams() const; + /// Get the inset parameters, used by the GUIndependent dialog. + InsetGraphicsParams getParams() const; - /// This signal is connected by our dialog and called when the inset - /// is deleted. - Signal0 hide; + /// This signal is connected by our dialog and called when the inset + /// is deleted. + Signal0 < void > hide; private: - /// Update the inset after parameter change. - void updateInset(); + /// Update the inset after parameter change. + void updateInset(); - /// The graphics cache handle. - GraphicsCacheItem * cacheHandle; + /// The graphics cache handle. + GraphicsCacheItem * cacheHandle; - /// The pixmap - mutable Pixmap pixmap; - /// is the pixmap initialized? - mutable bool pixmapInitialized; - - InsetGraphicsParams params; + /// The pixmap + mutable Pixmap pixmap; + /// is the pixmap initialized? + mutable bool pixmapInitialized; - // Baruch Even (baruch.even@writeme.com) 2000-07-17 - // This was the intended way however it is not flexible enough and - // only provides for LaTeX output. + InsetGraphicsParams params; + + // Baruch Even (baruch.even@writeme.com) 2000-07-17 + // This was the intended way however it is not flexible enough and + // only provides for LaTeX output. #ifdef IG_OLDPARAMS // We need variables to store the size of the boundingbox and // to store a pointer to the pixmap in.. The question is if @@ -132,7 +132,7 @@ private: bounding box in the LaTex command or not. (i.e. if the user has manually set the bb.) */ bool use_bb; - + /** When a graphics file is parsed we first check for BoundingBox and then for HiResBoundingBox, and set hiresbb depending on this. This key makes LaTeX search for %%HiResBoundingBox comments @@ -141,73 +141,73 @@ private: can normally only have integer values. It is a Boolean, either "true" or "false". */ bool hiresbb; - + /** This key takes four arguments (like bb), but in this case the origin is taken with respect to the bounding box specified in the file. So to view a 20 bp square at the lower left-hand corner of the picture, specify viewport=0 0 20 20. */ BoundingBox viewport; - + /** Similar to the viewport key, but the four dimensions correspond to the amount of space to be trimmed (cut off) at the left-hand side, bottom, right-hand side and top of the included graphics. */ BoundingBox trim; - + /// Natural height of figure LyXLength natheight; - + /// Natural width of figure. LyXLength natwidth; - + /// Rotation angle (in degrees, counterclockwise). float angle; /** Origin for rotation, similar to the origin parameter of the \rotatebox command described on p.46 and Fig. 2.2 on p.46. */ Origin origin; - + /// Required width (the width of the image is scaled to that value). LyXLength g_width; - + /// Required height (the height of the image is scaled to that value). LyXLength g_height; - + /** Required total height (the total height of the image is scaled to that value). This key should be used instead of height if images are rotated over 90 degrees, since the height can disappear (and become the depth) and LaTeX will have difficulties satisfying the user's request. */ LyXLength totalheight; - + /** Boolean variable that can have the values "true" and "false" (se above for defaults). When true, specifying both width and height parameters does not distort the picture, but the image is scaled so that neither of the width of height exceeds the given dimensions. */ bool keepaspectratio; - + /// Scale factor float scale; - + /** Clip the graphic to the bounding box. It is a Boolean, either "true" or "false". */ bool clip; - + /// Locally switch to draft mode. A Boolean valued key, like clip. bool draft; - + /// The graphics type. string type; - + /// The file extension of the file containing the image data. string ext; - + /// The file extension of the file "read" by LaTeX. string read; - + /// Any command to be applied to the file. string command; -#endif +#endif }; -#endif +#endif diff --git a/src/insets/insetgraphicsParams.C b/src/insets/insetgraphicsParams.C index b5d300bc9a..7c3b0e89b9 100644 --- a/src/insets/insetgraphicsParams.C +++ b/src/insets/insetgraphicsParams.C @@ -9,12 +9,11 @@ * This file Copyright 2000 Baruch Even * ================================================= */ +#include #ifdef __GNUG__ #pragma implementation -#endif - -#include +#endif #include "insetgraphicsParams.h" @@ -31,413 +30,414 @@ static bool translatorsSet = false; /// This is the translator between the Resize enum and corresponding lyx /// file strings. -static Translator - resizeTranslator(InsetGraphicsParams::DEFAULT_SIZE, "default"); +static Translator < InsetGraphicsParams::Resize, string > +resizeTranslator(InsetGraphicsParams::DEFAULT_SIZE, "default"); /// This is the translator between the Origin enum and corresponding lyx /// file strings. -static Translator - originTranslator(InsetGraphicsParams::DEFAULT, "default"); +static Translator < InsetGraphicsParams::Origin, string > +originTranslator(InsetGraphicsParams::DEFAULT, "default"); /// This is the translator between the Display enum and corresponding lyx /// file strings. -static Translator - displayTranslator(InsetGraphicsParams::MONOCHROME, "monochrome"); +static Translator < InsetGraphicsParams::DisplayType, string > +displayTranslator(InsetGraphicsParams::MONOCHROME, "monochrome"); InsetGraphicsParams::InsetGraphicsParams() { - init(); + init(); - // Set translators - if (! translatorsSet) { - translatorsSet = true; + // Set translators + if (! translatorsSet) { + translatorsSet = true; - // Fill the resize translator - resizeTranslator.addPair(DEFAULT_SIZE, "default"); - resizeTranslator.addPair(CM, "cm"); - resizeTranslator.addPair(INCH, "inch"); - resizeTranslator.addPair(PERCENT_PAGE, "percentOfPage"); - resizeTranslator.addPair(PERCENT_COLUMN, "percentOfColumn"); + // Fill the resize translator + resizeTranslator.addPair(DEFAULT_SIZE, "default"); + resizeTranslator.addPair(CM, "cm"); + resizeTranslator.addPair(INCH, "inch"); + resizeTranslator.addPair(PERCENT_PAGE, "percentOfPage"); + resizeTranslator.addPair(PERCENT_COLUMN, "percentOfColumn"); + + // Fill the origin translator + originTranslator.addPair(DEFAULT, "default"); + originTranslator.addPair(LEFTTOP, "leftTop"); + originTranslator.addPair(LEFTCENTER, "leftCenter"); + originTranslator.addPair(LEFTBASELINE, "leftBaseLine"); + originTranslator.addPair(LEFTBOTTOM, "leftBottom"); + originTranslator.addPair(CENTERTOP, "centerTop"); + originTranslator.addPair(CENTER, "center"); + originTranslator.addPair(CENTERBASELINE, "centerBaseLine"); + originTranslator.addPair(CENTERBOTTOM, "centerBottom"); + originTranslator.addPair(RIGHTTOP, "rightTop"); + originTranslator.addPair(RIGHTCENTER, "rightCenter"); + originTranslator.addPair(RIGHTBASELINE, "rightBaseLine"); + originTranslator.addPair(RIGHTBOTTOM, "rightBottom"); + originTranslator.addPair(REFERENCE_POINT, "referencePoint"); + + // Fill the display translator + displayTranslator.addPair(MONOCHROME, "monochrome"); + displayTranslator.addPair(GRAYSCALE, "grayscale"); + displayTranslator.addPair(COLOR, "color"); + displayTranslator.addPair(NONE, "none"); + } - // Fill the origin translator - originTranslator.addPair(DEFAULT, "default"); - originTranslator.addPair(LEFTTOP, "leftTop"); - originTranslator.addPair(LEFTCENTER, "leftCenter"); - originTranslator.addPair(LEFTBASELINE, "leftBaseLine"); - originTranslator.addPair(LEFTBOTTOM, "leftBottom"); - originTranslator.addPair(CENTERTOP, "centerTop"); - originTranslator.addPair(CENTER, "center"); - originTranslator.addPair(CENTERBASELINE, "centerBaseLine"); - originTranslator.addPair(CENTERBOTTOM, "centerBottom"); - originTranslator.addPair(RIGHTTOP, "rightTop"); - originTranslator.addPair(RIGHTCENTER, "rightCenter"); - originTranslator.addPair(RIGHTBASELINE, "rightBaseLine"); - originTranslator.addPair(RIGHTBOTTOM, "rightBottom"); - originTranslator.addPair(REFERENCE_POINT, "referencePoint"); - - // Fill the display translator - displayTranslator.addPair(MONOCHROME, "monochrome"); - displayTranslator.addPair(GRAYSCALE, "grayscale"); - displayTranslator.addPair(COLOR, "color"); - displayTranslator.addPair(NONE, "none"); - } - } InsetGraphicsParams::InsetGraphicsParams(InsetGraphicsParams const & igp) { - // I decided to skip the initialization since the copy will overwrite - // everything anyway. -// init(); - copy(igp); + // I decided to skip the initialization since the copy will overwrite + // everything anyway. + // init(); + copy(igp); } -InsetGraphicsParams const & +InsetGraphicsParams const & InsetGraphicsParams::operator=(InsetGraphicsParams const ¶ms) { - // Are we assigning the object into itself? - if (this == ¶ms) - return *this; - - copy(params); - return *this; + // Are we assigning the object into itself? + if (this == ¶ms) + return * this; + + copy(params); + return *this; } void InsetGraphicsParams::init() { - subcaptionText = filename = string(); - display = MONOCHROME; - inlineFigure = false; - subcaption = false; - keepAspectRatio = true; - widthResize = DEFAULT_SIZE; - widthSize = 0.0; - heightResize = DEFAULT_SIZE; - heightSize = 0.0; - rotateOrigin = DEFAULT; - rotateAngle = 0; + subcaptionText = filename = string(); + display = MONOCHROME; + inlineFigure = false; + subcaption = false; + keepAspectRatio = true; + widthResize = DEFAULT_SIZE; + widthSize = 0.0; + heightResize = DEFAULT_SIZE; + heightSize = 0.0; + rotateOrigin = DEFAULT; + rotateAngle = 0; - testInvariant(); + testInvariant(); } void InsetGraphicsParams::copy(InsetGraphicsParams const & igp) { - filename = igp.filename; - display = igp.display; - inlineFigure = igp.inlineFigure; - subcaption = igp.subcaption; - subcaptionText = igp.subcaptionText; - keepAspectRatio = igp.keepAspectRatio; - widthResize = igp.widthResize; - widthSize = igp.widthSize; - heightResize = igp.heightResize; - heightSize = igp.heightSize; - rotateOrigin = igp.rotateOrigin; - rotateAngle = igp.rotateAngle; + filename = igp.filename; + display = igp.display; + inlineFigure = igp.inlineFigure; + subcaption = igp.subcaption; + subcaptionText = igp.subcaptionText; + keepAspectRatio = igp.keepAspectRatio; + widthResize = igp.widthResize; + widthSize = igp.widthSize; + heightResize = igp.heightResize; + heightSize = igp.heightSize; + rotateOrigin = igp.rotateOrigin; + rotateAngle = igp.rotateAngle; - testInvariant(); + testInvariant(); } void InsetGraphicsParams::testInvariant() const { - // Filename might be empty (when the dialog is first created). - // Assert(!filename.empty()); - - Assert(display == COLOR || - display == MONOCHROME || - display == GRAYSCALE || - display == NONE - ); - - Assert(widthResize == DEFAULT_SIZE || - widthResize == CM || - widthResize == INCH || - widthResize == PERCENT_PAGE || - widthResize == PERCENT_COLUMN - ); + // Filename might be empty (when the dialog is first created). + // Assert(!filename.empty()); - Assert(heightResize == DEFAULT_SIZE || - heightResize == CM || - heightResize == INCH || - heightResize == PERCENT_PAGE - ); - - Assert(widthSize >= 0.0); - Assert(heightSize >= 0.0); - - // Angle is in degrees and ranges -360 < angle < 360 - // The reason for this is that in latex there is a meaning for the - // different angles and they are not necessarliy interchangeable, - // it depends on the rotation origin. - Assert(rotateAngle < 360); - Assert(rotateAngle > -360); + Assert(display == COLOR || + display == MONOCHROME || + display == GRAYSCALE || + display == NONE + ); + + Assert(widthResize == DEFAULT_SIZE || + widthResize == CM || + widthResize == INCH || + widthResize == PERCENT_PAGE || + widthResize == PERCENT_COLUMN + ); + + Assert(heightResize == DEFAULT_SIZE || + heightResize == CM || + heightResize == INCH || + heightResize == PERCENT_PAGE + ); + + Assert(widthSize >= 0.0); + Assert(heightSize >= 0.0); + + // Angle is in degrees and ranges -360 < angle < 360 + // The reason for this is that in latex there is a meaning for the + // different angles and they are not necessarliy interchangeable, + // it depends on the rotation origin. + Assert(rotateAngle < 360); + Assert(rotateAngle > -360); } -bool operator==(InsetGraphicsParams const & left, - InsetGraphicsParams const & right) +bool operator==(InsetGraphicsParams const & left, + InsetGraphicsParams const & right) { - if (left.filename == right.filename && - left.display == right.display && - left.inlineFigure == right.inlineFigure && - left.subcaption == right.subcaption && - left.subcaptionText == right.subcaptionText && - left.keepAspectRatio == right.keepAspectRatio && - left.widthResize == right.widthResize && - left.widthSize == right.widthSize && - left.heightResize == right.heightResize && - left.heightSize == right.heightSize && - left.rotateOrigin == right.rotateOrigin && - left.rotateAngle == right.rotateAngle - ) - return true; + if (left.filename == right.filename && + left.display == right.display && + left.inlineFigure == right.inlineFigure && + left.subcaption == right.subcaption && + left.subcaptionText == right.subcaptionText && + left.keepAspectRatio == right.keepAspectRatio && + left.widthResize == right.widthResize && + left.widthSize == right.widthSize && + left.heightResize == right.heightResize && + left.heightSize == right.heightSize && + left.rotateOrigin == right.rotateOrigin && + left.rotateAngle == right.rotateAngle + ) + return true; - return false; + return false; } -static void writeResize(ostream & os, char const * key, - InsetGraphicsParams::Resize resize, double size) +static void writeResize(ostream & os, char const * key, + InsetGraphicsParams::Resize resize, double size) { - os << ' ' << key << "Resize "; + os << ' ' << key << "Resize "; - os << resizeTranslator.find(resize); + os << resizeTranslator.find(resize); #if 0 - // Old code, before using translators - switch (resize) { - case InsetGraphicsParams::DEFAULT_SIZE: - os << "default"; - break; - - case InsetGraphicsParams::CM: - os << "cm"; - break; - - case InsetGraphicsParams::INCH: - os << "inch"; - break; - - case InsetGraphicsParams::PERCENT_PAGE: - os << "percentOfPage"; - break; - - case InsetGraphicsParams::PERCENT_COLUMN: - os << "percentOfColumnt"; - break; - } -#endif - os << ' ' << key << ' ' << size << endl; + // Old code, before using translators + switch (resize) { + case InsetGraphicsParams::DEFAULT_SIZE: + os << "default"; + break; + + case InsetGraphicsParams::CM: + os << "cm"; + break; + + case InsetGraphicsParams::INCH: + os << "inch"; + break; + + case InsetGraphicsParams::PERCENT_PAGE: + os << "percentOfPage"; + break; + + case InsetGraphicsParams::PERCENT_COLUMN: + os << "percentOfColumnt"; + break; + } +#endif + os << ' ' << key << ' ' << size << endl; } -static void writeOrigin(ostream & os, - InsetGraphicsParams::Origin origin) +static void writeOrigin(ostream & os, + InsetGraphicsParams::Origin origin) { - os << " rotateOrigin " << originTranslator.find(origin); - + os << " rotateOrigin " << originTranslator.find(origin); + #if 0 - // Old method. - switch (origin) { - case InsetGraphicsParams:: DEFAULT: - os << "default"; - break; - case InsetGraphicsParams:: LEFTTOP: - os << "LeftTop"; - break; - case InsetGraphicsParams:: LEFTCENTER: - os << "LeftCenter"; - break; - case InsetGraphicsParams:: LEFTBASELINE: - os << "LeftBaseLine"; - break; - case InsetGraphicsParams:: LEFTBOTTOM: - os << "LeftBottom"; - break; - case InsetGraphicsParams:: CENTERTOP: - os << "CenterTop"; - break; - case InsetGraphicsParams:: CENTER: - os << "Center"; - break; - case InsetGraphicsParams:: CENTERBASELINE: - os << "CenterBaseLine"; - break; - case InsetGraphicsParams:: CENTERBOTTOM: - os << "CenterBottom"; - break; - case InsetGraphicsParams:: RIGHTTOP: - os << "RightTop"; - break; - case InsetGraphicsParams:: RIGHTCENTER: - os << "RightCenter"; - break; - case InsetGraphicsParams:: RIGHTBASELINE: - os << "RightBaseLine"; - break; - case InsetGraphicsParams:: RIGHTBOTTOM: - os << "RightBottom"; - break; - // Current REFERENCE_POINT is aliased to LEFTBASELINE -// case InsetGraphicsParams:: REFERENCE_POINT: - } -#endif - - os << endl; + // Old method. + switch (origin) { + case InsetGraphicsParams:: DEFAULT: + os << "default"; + break; + case InsetGraphicsParams:: LEFTTOP: + os << "LeftTop"; + break; + case InsetGraphicsParams:: LEFTCENTER: + os << "LeftCenter"; + break; + case InsetGraphicsParams:: LEFTBASELINE: + os << "LeftBaseLine"; + break; + case InsetGraphicsParams:: LEFTBOTTOM: + os << "LeftBottom"; + break; + case InsetGraphicsParams:: CENTERTOP: + os << "CenterTop"; + break; + case InsetGraphicsParams:: CENTER: + os << "Center"; + break; + case InsetGraphicsParams:: CENTERBASELINE: + os << "CenterBaseLine"; + break; + case InsetGraphicsParams:: CENTERBOTTOM: + os << "CenterBottom"; + break; + case InsetGraphicsParams:: RIGHTTOP: + os << "RightTop"; + break; + case InsetGraphicsParams:: RIGHTCENTER: + os << "RightCenter"; + break; + case InsetGraphicsParams:: RIGHTBASELINE: + os << "RightBaseLine"; + break; + case InsetGraphicsParams:: RIGHTBOTTOM: + os << "RightBottom"; + break; + // Current REFERENCE_POINT is aliased to LEFTBASELINE + // case InsetGraphicsParams:: REFERENCE_POINT: + } + +#endif + + os << endl; } void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const { - // If there is no filename, write nothing for it. - if (! filename.empty()) { - os << "filename " - << MakeRelPath(filename, OnlyPath(buf->fileName())) - << endl; - } + // If there is no filename, write nothing for it. + if (! filename.empty()) { + os << "filename " + << MakeRelPath(filename, OnlyPath(buf->fileName())) + << endl; + } - // Save the display type - os << " display " << displayTranslator.find(display) << endl; + // Save the display type + os << " display " << displayTranslator.find(display) << endl; #if 0 - switch (display) { - case COLOR: - os << "color"; - break; + switch (display) { + case COLOR: + os << "color"; + break; - case GRAYSCALE: - os << "grayscale"; - break; + case GRAYSCALE: + os << "grayscale"; + break; - case MONOCHROME: - os << "monochrome"; - break; + case MONOCHROME: + os << "monochrome"; + break; - case NONE: - os << "none"; - break; - } - os << endl; -#endif - - // Save the inline status - if (inlineFigure) - os << " inline"; - - // Save the subcaption status - if (subcaption) - os << " subcaption"; - - if (! subcaptionText.empty()) - os << " subcaptionText \"" << subcaptionText << '\"' << endl; - - writeResize(os, "width", widthResize, widthSize); - writeResize(os, "height", heightResize, heightSize); - - writeOrigin(os, rotateOrigin); - if (rotateAngle != 0) - os << " rotateAngle " << rotateAngle << endl; -} - -static void readResize(InsetGraphicsParams * igp, bool height, - string const & token) -{ - InsetGraphicsParams::Resize resize = InsetGraphicsParams::DEFAULT_SIZE; - - resize = resizeTranslator.find(token); -#if 0 - // Old code, before translator. - if (token == "default") - resize = InsetGraphicsParams::DEFAULT_SIZE; - else if (token == "cm") - resize = InsetGraphicsParams::CM; - else if (token == "inch") - resize = InsetGraphicsParams::INCH; - else if (token == "percentOfPage") - resize = InsetGraphicsParams::PERCENT_PAGE; - else if (token == "percentOfColumn") - resize = InsetGraphicsParams::PERCENT_COLUMN; - else { - lyxerr << "BUG: When reading resize value of InsetGraphicsParam" - " unknown token found '" << token << '\'' << endl; - } + case NONE: + os << "none"; + break; + } + os << endl; #endif - - if (height) - igp->heightResize = resize; - else - igp->widthResize = resize; + + // Save the inline status + if (inlineFigure) + os << " inline"; + + // Save the subcaption status + if (subcaption) + os << " subcaption"; + + if (! subcaptionText.empty()) + os << " subcaptionText \"" << subcaptionText << '\"' << endl; + + writeResize(os, "width", widthResize, widthSize); + writeResize(os, "height", heightResize, heightSize); + + writeOrigin(os, rotateOrigin); + if (rotateAngle != 0) + os << " rotateAngle " << rotateAngle << endl; } - + +static void readResize(InsetGraphicsParams * igp, bool height, + string const & token) +{ + InsetGraphicsParams::Resize resize = InsetGraphicsParams::DEFAULT_SIZE; + + resize = resizeTranslator.find(token); +#if 0 + // Old code, before translator. + if (token == "default") + resize = InsetGraphicsParams::DEFAULT_SIZE; + else if (token == "cm") + resize = InsetGraphicsParams::CM; + else if (token == "inch") + resize = InsetGraphicsParams::INCH; + else if (token == "percentOfPage") + resize = InsetGraphicsParams::PERCENT_PAGE; + else if (token == "percentOfColumn") + resize = InsetGraphicsParams::PERCENT_COLUMN; + else { + lyxerr << "BUG: When reading resize value of InsetGraphicsParam" + " unknown token found '" << token << '\'' << endl; + } +#endif + + if (height) + igp->heightResize = resize; + else + igp->widthResize = resize; +} + static void readOrigin(InsetGraphicsParams * igp, string const & token) { // TODO: complete this function. - igp->rotateOrigin = originTranslator.find(token); + igp->rotateOrigin = originTranslator.find(token); } - -bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex, - string const& token) + +bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex, + string const& token) { - if (token == "filename") { - lex.next(); - filename = lex.GetString(); + if (token == "filename") { + lex.next(); + filename = lex.GetString(); - if (!filename.empty()) { - // Make the filename with absolute directory. - filename = MakeAbsPath(filename, OnlyPath(buf->fileName())); - } - } else if (token == "display") { - lex.next(); - string const type = lex.GetString(); + if (!filename.empty()) { + // Make the filename with absolute directory. + filename = MakeAbsPath(filename, OnlyPath(buf->fileName())); + } + } else if (token == "display") { + lex.next(); + string const type = lex.GetString(); - display = displayTranslator.find(type); + display = displayTranslator.find(type); #if 0 - if (type == "color") - display = COLOR; - else if (type == "grayscale") - display = GRAYSCALE; - else if (type == "monochrome") - display = MONOCHROME; - else if (type == "none") - display = NONE; - else { - display = MONOCHROME; - lyxerr << "BUG: When reading InsetGraphicsParams" - " display has an unknown type " << type << endl; - } + if (type == "color") + display = COLOR; + else if (type == "grayscale") + display = GRAYSCALE; + else if (type == "monochrome") + display = MONOCHROME; + else if (type == "none") + display = NONE; + else { + display = MONOCHROME; + lyxerr << "BUG: When reading InsetGraphicsParams" + " display has an unknown type " << type << endl; + } #endif - } else if (token == "inline") { - inlineFigure = true; - } else if (token == "subcaption") { - subcaption = true; - } else if (token == "subcaptionText") { - lex.next(); - subcaptionText = lex.GetString(); - } else if (token == "widthResize") { - lex.next(); - string const token = lex.GetString(); - - readResize(this, false, token); - } else if (token == "width") { - lex.next(); - widthSize = lex.GetFloat(); - } else if (token == "heightResize") { - lex.next(); - string const token = lex.GetString(); - - readResize(this, true, token); - } else if (token == "height") { - lex.next(); - heightSize = lex.GetFloat(); - } else if (token == "rotateOrigin") { - lex.next(); - string const token = lex.GetString(); + } else if (token == "inline") { + inlineFigure = true; + } else if (token == "subcaption") { + subcaption = true; + } else if (token == "subcaptionText") { + lex.next(); + subcaptionText = lex.GetString(); + } else if (token == "widthResize") { + lex.next(); + string const token = lex.GetString(); - readOrigin(this, token); - } else if (token == "rotateAngle") { - lex.next(); - rotateAngle = lex.GetInteger(); - } else { - // If it's none of the above, its not ours. - return false; - } + readResize(this, false, token); + } else if (token == "width") { + lex.next(); + widthSize = lex.GetFloat(); + } else if (token == "heightResize") { + lex.next(); + string const token = lex.GetString(); - return true; + readResize(this, true, token); + } else if (token == "height") { + lex.next(); + heightSize = lex.GetFloat(); + } else if (token == "rotateOrigin") { + lex.next(); + string const token = lex.GetString(); + + readOrigin(this, token); + } else if (token == "rotateAngle") { + lex.next(); + rotateAngle = lex.GetInteger(); + } else { + // If it's none of the above, its not ours. + return false; + } + + return true; } diff --git a/src/insets/insetgraphicsParams.h b/src/insets/insetgraphicsParams.h index 2611672099..f6bce4aeef 100644 --- a/src/insets/insetgraphicsParams.h +++ b/src/insets/insetgraphicsParams.h @@ -14,9 +14,7 @@ #ifdef __GNUG__ #pragma interface -#endif - -#include +#endif #include "LString.h" @@ -26,102 +24,103 @@ using std::ostream; /// This struct holds all the parameters needed by insetGraphics. -struct InsetGraphicsParams { - /// Image filename. - string filename; - - /// How do we display the image? - enum DisplayType { - /// In full color range (if it's not in color we show it as it is) - COLOR, - /// In Grayscale (256 shades of gray). - GRAYSCALE, - /// In black and white. - MONOCHROME, - /// Don't display it on screen, only keep a frame in place. - NONE - }; +struct InsetGraphicsParams +{ + /// Image filename. + string filename; - /// How to display the image - DisplayType display; - - /// Is the figure inlined? (not in a paragraph of its own). - bool inlineFigure; - - /// Do we have a subcaption? - bool subcaption; - - /// The text of the subcaption. - string subcaptionText; - - /// This is the different origins that the graphicx package support. - enum Origin { - DEFAULT, - LEFTTOP, - LEFTCENTER, - LEFTBASELINE, - LEFTBOTTOM, - CENTERTOP, - CENTER, - CENTERBASELINE, - CENTERBOTTOM, - RIGHTTOP, - RIGHTCENTER, - RIGHTBASELINE, - RIGHTBOTTOM, - REFERENCE_POINT = LEFTBASELINE + /// How do we display the image? + enum DisplayType { + /// In full color range (if it's not in color we show it as it is) + COLOR, + /// In Grayscale (256 shades of gray). + GRAYSCALE, + /// In black and white. + MONOCHROME, + /// Don't display it on screen, only keep a frame in place. + NONE }; - /// The resize of the image, is it the default size, in cm, inch or - /// percentage of the page/column width/height - enum Resize { - DEFAULT_SIZE, - CM, - INCH, - PERCENT_PAGE, - PERCENT_COLUMN - }; + /// How to display the image + DisplayType display; - - /// Keep the ratio between height and width when resizing. - bool keepAspectRatio; + /// Is the figure inlined? (not in a paragraph of its own). + bool inlineFigure; - // What width resize to do? - Resize widthResize; - // Value of width resize - float widthSize; - // What height resize to do? - Resize heightResize; - // Value of height resize - float heightSize; + /// Do we have a subcaption? + bool subcaption; - // Origin point of rotation - Origin rotateOrigin; - // Rotation angle. - int rotateAngle; + /// The text of the subcaption. + string subcaptionText; - InsetGraphicsParams(); + /// This is the different origins that the graphicx package support. + enum Origin { + DEFAULT, + LEFTTOP, + LEFTCENTER, + LEFTBASELINE, + LEFTBOTTOM, + CENTERTOP, + CENTER, + CENTERBASELINE, + CENTERBOTTOM, + RIGHTTOP, + RIGHTCENTER, + RIGHTBASELINE, + RIGHTBOTTOM, + REFERENCE_POINT = LEFTBASELINE + }; - InsetGraphicsParams(InsetGraphicsParams const &); - InsetGraphicsParams const & operator=(InsetGraphicsParams const &); + /// The resize of the image, is it the default size, in cm, inch or + /// percentage of the page/column width/height + enum Resize { + DEFAULT_SIZE, + CM, + INCH, + PERCENT_PAGE, + PERCENT_COLUMN + }; - /// Save the parameters in the LyX format stream. - void Write(Buffer const * buf, ostream & os) const; - - /// If the token belongs to our parameters, read it. - bool Read(Buffer const * buf, LyXLex & lex, string const & token); - - /// Test the struct to make sure that all the options have legal values. - void testInvariant() const; + + /// Keep the ratio between height and width when resizing. + bool keepAspectRatio; + + // What width resize to do? + Resize widthResize; + // Value of width resize + float widthSize; + // What height resize to do? + Resize heightResize; + // Value of height resize + float heightSize; + + // Origin point of rotation + Origin rotateOrigin; + // Rotation angle. + int rotateAngle; + + InsetGraphicsParams(); + + InsetGraphicsParams(InsetGraphicsParams const &); + InsetGraphicsParams const & operator=(InsetGraphicsParams const &); + + /// Save the parameters in the LyX format stream. + void Write(Buffer const * buf, ostream & os) const; + + /// If the token belongs to our parameters, read it. + bool Read(Buffer const * buf, LyXLex & lex, string const & token); + + /// Test the struct to make sure that all the options have legal values. + void testInvariant() const; private: - /// Initialize the object to a default status. - void init(); + /// Initialize the object to a default status. + void init(); - /// Copy the other objects content to us, used in copy c-tor and assignment - void copy(InsetGraphicsParams const & params); + /// Copy the other objects content to us, used in copy c-tor and assignment + void copy(InsetGraphicsParams const & params); }; bool operator==(InsetGraphicsParams const&, InsetGraphicsParams const &); -#endif +#endif diff --git a/src/lyx_gui.C b/src/lyx_gui.C index 72399342ce..55daaf72f6 100644 --- a/src/lyx_gui.C +++ b/src/lyx_gui.C @@ -575,7 +575,7 @@ void LyXGUI::runTime() kapp->processEvents(); #endif #ifdef GTKGUI - Gnome::Main::instance()->iteration(FALSE); + while(Gnome::Main::instance()->events_pending()) Gnome::Main::instance()->iteration(FALSE); #endif if (fl_check_forms() == FL_EVENT) {