Menubar and toolbar fixes. New OptItem menu option. Add gtk.m4.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@918 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2000-07-25 10:46:18 +00:00
parent d8b75819d6
commit b8072fd6f7
23 changed files with 615 additions and 101 deletions

View File

@ -1,3 +1,47 @@
2000-07-25 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* config/gnome/gtk.m4: added (and added to the list of files in
autogen.sh).
* src/insets/insetinclude.C (unique_id): fix when we are using
lyxstring instead of basic_string<>.
* src/insets/insettext.C (LocalDispatch): ditto.
* src/support/filetools.C: ditto.
* lib/configure.m4: create the ui/ directory if necessary.
* src/LyXView.[Ch] (updateToolbar): new method.
* src/BufferView_pimpl.C (buffer): update the toolbar when
opening/closing buffer.
2000-07-24 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/LyXAction.C (getActionName): enhance to return also the name
and options of pseudo-actions.
(init): New lyxfunc LFUN_MATH_PANEL=="math-panel".
* lib/ui/default.ui: use OptItem in the vc submenu (intented just
as an example of what is possible). Used in File->Build too (more
useful) and in the import/export menus (to mimick the complicated
handling of linuxdoc and friends). Try to update all the entries.
* src/frontends/xforms/Menubar_pimpl.C (create_submenu): handle
optional entries.
* src/MenuBackend.C (read): Parse the new OptItem tag.
* src/MenuBackend.h: Add a new optional_ data member (used if the
entry should be omitted when the lyxfunc is disabled).
* src/frontends/xforms/Menubar_pimpl.C (string_width): new
function, used as a shortcut.
(create_submenu): align correctly the shortcuts on the widest
entry.
* src/MenuBackend.h: MenuItem.label() only returns the label of
the menu without shortcut; new method shortcut().
2000-07-14 Marko Vendelin <markov@ioc.ee>
* src/frontends/gtk/Dialogs.C:

View File

@ -4358,6 +4358,200 @@ if test -n "$LIBXDMCP"; then
ac_cpp=$ac_cpp_safe
fi
])
# 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 <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
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, &micro) != 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 <gtk/gtk.h>
#include <stdio.h>
], [ 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
])
# aclocal-include.m4
#

View File

@ -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/gnome/aclocal-include.m4 config/gnome/gnome-print-check.m4 config/gnome/compiler-flags.m4 config/gnome/gnome-pthread-check.m4 config/gnome/curses.m4 config/gnome/gnome-support.m4 config/gnome/gnome-bonobo-check.m4 config/gnome/gnome-undelfs.m4 config/gnome/gnome-common.m4 config/gnome/gnome-vfs.m4 config/gnome/gnome-fileutils.m4 config/gnome/gnome-x-checks.m4 config/gnome/gnome-ghttp-check.m4 config/gnome/gnome-xml-check.m4 config/gnome/gnome-gnorba-check.m4 config/gnome/gnome.m4 config/gnome/gnome-guile-checks.m4 config/gnome/gperf-check.m4 config/gnome/gnome-libgtop-check.m4 config/gnome/linger.m4 config/gnome/gnome-objc-checks.m4 config/gnome/need-declaration.m4 config/gnome/gnome-orbit-check.m4 config/gnome/gtk--.m4 config/gnome/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/gnome/gtk.m4 config/gnome/aclocal-include.m4 config/gnome/gnome-print-check.m4 config/gnome/compiler-flags.m4 config/gnome/gnome-pthread-check.m4 config/gnome/curses.m4 config/gnome/gnome-support.m4 config/gnome/gnome-bonobo-check.m4 config/gnome/gnome-undelfs.m4 config/gnome/gnome-common.m4 config/gnome/gnome-vfs.m4 config/gnome/gnome-fileutils.m4 config/gnome/gnome-x-checks.m4 config/gnome/gnome-ghttp-check.m4 config/gnome/gnome-xml-check.m4 config/gnome/gnome-gnorba-check.m4 config/gnome/gnome.m4 config/gnome/gnome-guile-checks.m4 config/gnome/gperf-check.m4 config/gnome/gnome-libgtop-check.m4 config/gnome/linger.m4 config/gnome/gnome-objc-checks.m4 config/gnome/need-declaration.m4 config/gnome/gnome-orbit-check.m4 config/gnome/gtk--.m4 config/gnome/gnome--.m4 ; do
cat $fil >> acinclude.m4
done
touch sigc++/acinclude.m4

194
config/gnome/gtk.m4 Normal file
View File

@ -0,0 +1,194 @@
# 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 <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
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, &micro) != 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 <gtk/gtk.h>
#include <stdio.h>
], [ 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
])

View File

@ -62,7 +62,7 @@ LYX_SCO
AC_EXEEXT
### Check for a C++ compiler
#AC_LANG_CPLUSPLUS
AC_LANG_CPLUSPLUS
LYX_PROG_CXX
AC_PROG_CXXCPP
AC_DISABLE_SHARED
@ -85,6 +85,8 @@ dnl we disable rtti for now
dnl LYX_CXX_RTTI
AC_CHECK_HEADERS(ostream istream sstream)
LYX_CXX_STL_MODERN_STREAMS
dnl It seems this is needed by gtk/gnome stuff
AC_LANG_C
### We need a regex implementation, so we provide our own if none is found.
LYX_REGEX

2
lib/configure vendored
View File

@ -71,7 +71,7 @@ fi
#### Create the build directories if necessary
for dir in bind clipart doc examples images kbd layouts reLyX \
scripts templates ; do
scripts templates ui ; do
test ! -d $dir && mkdir $dir
done

View File

@ -147,7 +147,7 @@ fi
#### Create the build directories if necessary
for dir in bind clipart doc examples images kbd layouts reLyX \
scripts templates ; do
scripts templates ui ; do
test ! -d $dir && mkdir $dir
done

View File

@ -36,7 +36,7 @@ Menuset
Item "View Postscript|w" "buffer-view-ps"
Item "Update dvi|v" "buffer-typeset"
Item "Update Postscript|u" "buffer-typeset-ps"
Item "Build program|B" "build-program"
OptItem "Build program|B" "build-program"
Separator
Item "Print...|P" "buffer-print"
Item "Fax...|F" "buffer-fax"
@ -68,11 +68,16 @@ Menuset
End
Menu "export"
Item "LaTeX|L" "buffer-export latex"
Item "DVI|D" "buffer-export dvi"
Item "Postscript|P" "buffer-export postscript"
Item "Ascii|A" "buffer-export ascii"
Item "Custom...|C" "buffer-export custom"
OptItem "as LaTeX|L" "buffer-export latex"
OptItem "as LinuxDoc|L" "buffer-export linuxdoc"
OptItem "as DocBook|B" "buffer-export docbook"
Item "as DVI|D" "buffer-export dvi"
Item "as Postscript|P" "buffer-export postscript"
Item "as Ascii|A" "buffer-export ascii"
OptItem "as HTML|H" "buffer-export html"
OptItem "as HTML|H" "buffer-export html-linuxdoc"
OptItem "as HTML|H" "buffer-export html-docbook"
OptItem "Custom...|C" "buffer-export custom"
End
Menu "edit"
@ -86,8 +91,8 @@ Menuset
Item "Find & Replace...|F" "find-replace"
Item "Go to Error|E" "error-next"
Item "Go to Note|N" "note-next"
Submenu "Floats & Insets|I" "floats"
Submenu "Table" "table"
Submenu "Floats & Insets|I" "edit_floats"
Submenu "Table" "edit_table"
Item "Spellchecker...|S" "spellchecker"
Item "Check TeX|h" "buffer-chktex"
Item "Table of Contents|b" "toc-view"
@ -96,23 +101,27 @@ Menuset
Separator
Item "View LaTeX log file|w" "latex-view-log"
Separator
Item "Paste primary selection as Lines|L" "primary-selection-paste"
Item "Paste primary selection as Paragraphs|g" "primary-selection-paste paragraph"
SubMenu "Paste primary selection" "edit_paste"
End
Menu "floats"
Menu "edit_floats"
End
Menu "table"
Menu "edit_table"
End
Menu "edit_paste"
Item "as Lines|L" "primary-selection-paste"
Item "as Paragraphs|g" "primary-selection-paste paragraph"
End
Menu "vc"
Item "Register|R" "vc-register"
Item "Check In Changes|I" "vc-check-in"
Item "Check Out for Edit|O" "vc-check-out"
Item "Revert to last version|l" "vc-revert"
Item "Undo last check in|U" "vc-undo-last"
Item "Show History|H" "vc-history"
OptItem "Register|R" "vc-register"
OptItem "Check In Changes|I" "vc-check-in"
OptItem "Check Out for Edit|O" "vc-check-out"
OptItem "Revert to last version|l" "vc-revert"
OptItem "Undo last check in|U" "vc-undo-last"
OptItem "Show History|H" "vc-history"
End
Menu "layout"
@ -141,6 +150,7 @@ Menuset
Item "Include File...|I" "buffer-child-insert"
Submenu "Import ascii file|a" "insert_ascii"
Item "Insert LyX file|X" "file-insert"
Item "Insert external material...|e" "external-inset-insert"
Separator
Item "Footnote|F" "footnote-insert"
Item "Marginnote|M" "marginpar-insert"
@ -190,6 +200,7 @@ Menuset
Item "Ellipsis|i" "dots-insert"
Item "End of sentence|E" "end-of-sentence-period-insert"
Item "Ordinary Quote|Q" "quote-insert"
Item "Menu Separator|M" "menu-separator-insert"
End
Menu "math"

View File

@ -146,6 +146,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
#else
owner_->getMenus()->showMenus();
#endif
owner_->updateToolbar();
redraw();
owner_->getDialogs()->updateBufferDependent();
bv_->insetWakeup();
@ -156,6 +157,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
#else
owner_->getMenus()->hideMenus();
#endif
owner_->updateToolbar();
updateScrollbar();
workarea_->redraw();

View File

@ -322,6 +322,7 @@ void LyXAction::init()
{ LFUN_MATH_MODE, "math-mode", N_("Math mode"), Noop },
{ LFUN_MATH_NONUMBER, "math-nonumber", "", Noop },
{ LFUN_MATH_NUMBER, "math-number", "", Noop },
{ LFUN_MATH_PANEL, "math-panel", "", Noop },
{ LFUN_MATH_SIZE, "math-size", "", Noop },
{ LFUN_MELT, "melt", N_("Melt"), Noop },
{ LFUN_MENU_OPEN_BY_NAME, "menu-open", "", NoBuffer },
@ -597,10 +598,21 @@ string LyXAction::getApproxFuncName(string const & func) const
string LyXAction::getActionName(int action) const
{
info_map::const_iterator iit =
lyx_info_map.find(static_cast<kb_action>(action));
kb_action ac;
string arg;
if (isPseudoAction(action)) {
ac = retrieveActionArg(action, arg);
arg = " " +arg;
}
else
ac = static_cast<kb_action>(action);
return iit != lyx_info_map.end() ? (*iit).second.name : string();
info_map::const_iterator iit = lyx_info_map.find(ac);
if (iit != lyx_info_map.end())
return (*iit).second.name + arg;
else
return string();
}

View File

@ -128,11 +128,19 @@ Toolbar * LyXView::getToolbar() const
return toolbar;
}
void LyXView::setLayout(int layout)
{
toolbar->setLayout(layout);
}
void LyXView::updateToolbar()
{
toolbar->update();
}
LyXFunc * LyXView::getLyXFunc() const
{
return lyxfunc;

View File

@ -82,6 +82,9 @@ public:
/// sets the layout in the toolbar layout combox
void setLayout(int layout);
/// update the toolbar
void updateToolbar();
/// return a pointer to the lyxfunc
LyXFunc * getLyXFunc() const;

View File

@ -14,6 +14,7 @@
#endif
#include <config.h>
#include "support/LAssert.h"
#include "MenuBackend.h"
#include "lyxlex.h"
#include "LyXAction.h"
@ -27,8 +28,9 @@ using std::endl;
MenuBackend menubackend;
MenuItem::MenuItem(Kind kind, string const & label, string const & command)
: kind_(kind), label_(label)
MenuItem::MenuItem(Kind kind, string const & label,
string const & command, bool optional)
: kind_(kind), label_(label), optional_(optional)
{
switch(kind) {
case Separator:
@ -42,6 +44,9 @@ MenuItem::MenuItem(Kind kind, string const & label, string const & command)
lyxerr << "MenuItem(): LyX command `"
<< command << "' does not exist." << endl;
}
if (optional_)
lyxerr[Debug::GUI] << "Optional item "
<< command << endl;
break;
case Submenu:
submenu_ = command;
@ -64,6 +69,7 @@ void Menu::read(LyXLex & lex)
md_documents,
md_endmenu,
md_lastfiles,
md_optitem,
md_submenu,
md_separator,
md_last
@ -74,6 +80,7 @@ void Menu::read(LyXLex & lex)
{ "end", md_endmenu },
{ "item", md_item },
{ "lastfiles", md_lastfiles },
{ "optitem", md_optitem },
{ "separator", md_separator },
{ "submenu", md_submenu }
};
@ -83,15 +90,21 @@ void Menu::read(LyXLex & lex)
lex.printTable(lyxerr);
bool quit = false;
bool optional = false;
while (lex.IsOK() && !quit) {
switch(lex.lex()) {
case md_optitem:
optional = true;
// fallback to md_item
case md_item: {
lex.next();
string name = lex.GetString();
lex.next();
string command = lex.GetString();
add(MenuItem(MenuItem::Command, name, command));
add(MenuItem(MenuItem::Command, name,
command, optional));
optional = false;
break;
}
case md_separator:

View File

@ -19,7 +19,7 @@
#endif
#include "LString.h"
#include "support/LAssert.h"
#include "support/lstrings.h"
#include <vector>
class LyXLex;
@ -43,16 +43,22 @@ public:
Documents
};
/// Create a Command type MenuItem
MenuItem(Kind kind_, string const & label_ = string(),
string const & command_ = string());
MenuItem(Kind kind,
string const & label = string(),
string const & command = string(),
bool optional = false);
/// The label of a given menuitem
string const & label() const { return label_; }
string label() const { return token(label_, '|', 0); }
///
string shortcut() const { return token(label_, '|', 1); }
/// The kind of entry
Kind kind() const { return kind_; }
/// the action (if relevant)
int action() const { return action_; }
/// the description of the submenu (if relevant)
string const & submenu() const { return submenu_; }
/// returns true if the entry should be ommited when disabled
bool optional() const { return optional_; }
private:
///
Kind kind_;
@ -62,6 +68,8 @@ private:
int action_;
///
string submenu_;
///
bool optional_;
};

View File

@ -122,9 +122,6 @@ void ToolbarDefaults::read(LyXLex & lex)
while (lex.IsOK() && !quit) {
lyxerr[Debug::GUI] << "Toolbar::read: current lex text: `"
<< lex.GetString() << '\'' << endl;
switch(lex.lex()) {
case TO_ADD:
if (lex.next()) {

View File

@ -140,6 +140,7 @@ enum kb_action {
LFUN_MATH_SIZE, // Alejandro 150896
LFUN_MATH_MACRO, // 120 // ale970510
LFUN_MATH_MACROARG, // ale970510
LFUN_MATH_PANEL,
LFUN_FIGURE,
LFUN_TABLE, // schedule for deletion
LFUN_MELT,

View File

@ -26,7 +26,6 @@
#include "bufferlist.h"
#include "lastfiles.h"
#include "LyXView.h"
#include "lyx_gui_misc.h"
#include "MenuBackend.h"
#include "Menubar_pimpl.h"
@ -50,11 +49,6 @@ char const * menu_tabstop = "aa";
char const * default_tabstop = "aaaaaaaa";
//Defined later.
extern "C"
void C_Menubar_Pimpl_MenuCallback(FL_OBJECT * ob, long button);
Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mb)
: frame_(0), owner_(view), menubackend_(&mb)
{
@ -66,6 +60,18 @@ Menubar::Pimpl::~Pimpl()
// Should we do something here?
}
// This is used a few times below.
inline
int string_width(string const & str)
{
return fl_get_string_widthTAB(FL_NORMAL_STYLE, MENU_LABEL_SIZE,
str.c_str(), str.length());
}
//Defined later, used in set().
extern "C"
void C_Menubar_Pimpl_MenuCallback(FL_OBJECT * ob, long button);
void Menubar::Pimpl::set(string const & menu_name)
{
lyxerr[Debug::GUI] << "Entering Menubar::Pimpl::set "
@ -151,17 +157,14 @@ void Menubar::Pimpl::set(string const & menu_name)
" only submenus can appear in a menubar";
break;
}
char const * label = idex(i->label().c_str());
char const * shortcut = scex(i->label().c_str());
int width = fl_get_string_width(FL_NORMAL_STYLE,
MENU_LABEL_SIZE,
label,
strlen(label));
string label = i->label();
string shortcut = i->shortcut();
int width = string_width(label);
obj = fl_add_button(FL_TOUCH_BUTTON,
air + moffset, yloc,
width + mbadd,
mbheight,
label);
label.c_str());
fl_set_object_boxtype(obj, FL_FLAT_BOX);
fl_set_object_color(obj, FL_MCOL, FL_MCOL);
fl_set_object_lsize(obj, MENU_LABEL_SIZE);
@ -170,7 +173,7 @@ void Menubar::Pimpl::set(string const & menu_name)
fl_set_object_gravity(obj, NorthWestGravity,
NorthWestGravity);
moffset += obj->w + air;
fl_set_object_shortcut(obj, shortcut, 1);
fl_set_object_shortcut(obj, shortcut.c_str(), 1);
fl_set_object_callback(obj, C_Menubar_Pimpl_MenuCallback, 1);
ItemInfo * iteminfo = new ItemInfo(this,
new MenuItem(*i), obj);
@ -276,25 +279,22 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
// Compute the size of the largest label (because xforms is
// not able to support shortcuts correctly...)
int max_width = 0, max_tabs = 0;
int tab_width = fl_get_string_width(FL_NORMAL_STYLE, MENU_LABEL_SIZE,
menu_tabstop, strlen(menu_tabstop));
int max_width = 0;
string widest_label;
for (Menu::const_iterator i = md.begin(); i != md.end(); ++i) {
MenuItem item = (*i);
if (item.kind() == MenuItem::Command) {
string label = idex(item.label().c_str());
int width = fl_get_string_width(FL_NORMAL_STYLE,
MENU_LABEL_SIZE,
label.c_str(),
label.length());
if (width > max_width)
string label = item.label() + '\t';
int width = string_width(label);
if (width > max_width) {
max_width = width;
widest_label = label;
}
}
max_tabs = (max_width + 5)/tab_width + 1;
lyxerr[Debug::GUI] << "tab_width=" << tab_width
<< ", max_width=" << max_width
<< ", max_tabs=" << max_tabs << endl;
}
lyxerr[Debug::GUI] << "max_width=" << max_width
<< ", widest_label=`" << widest_label
<< "'" << endl;
for (Menu::const_iterator i = md.begin(); i != md.end(); ++i) {
MenuItem item = (*i);
@ -308,30 +308,27 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
case MenuItem::Command: {
LyXFunc::func_status flag =
view->getLyXFunc()->getStatus(item.action());
// handle optional entries.
if (item.optional() && (flag & LyXFunc::Disabled)) {
lyxerr[Debug::GUI]
<< "Skipping optional item "
<< item.label() << endl;
break;
}
// Get the keys bound to this action, but keep only the
// first one later
string accel = toplevel_keymap->findbinding(item.action());
lyxerr[Debug::GUI] << "Command: "
<< lyxaction.getActionName(item.action())
<< " Binding " << accel << endl;
// Build the menu label from all the info
string label = idex(item.label().c_str());
string label = item.label();
if (!accel.empty()) {
// Try to be clever and add enough
// Try to be clever and add just enough
// tabs to align shortcuts.
int width =
fl_get_string_width(FL_NORMAL_STYLE,
MENU_LABEL_SIZE,
label.c_str(),
label.length());
int nb = max_tabs - width/tab_width;
lyxerr[Debug::GUI] << "label=" << label
<< ", tabs=" << nb
<< endl;
if (nb > 0)
label += string(nb, '\t');
do
label += '\t';
while (string_width(label) < max_width);
label += accel.substr(1,accel.find(']') - 1);
}
label += "%x" + tostr(item.action()) + extra_label;
@ -347,10 +344,9 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
label += pupmode;
// Finally the menu shortcut
string shortcut = scex(item.label().c_str());
if (!shortcut.empty()) {
string shortcut = item.shortcut();
string xfshortcut;
if (!shortcut.empty()) {
xfshortcut += uppercase(shortcut[0]);
xfshortcut += '#';
xfshortcut += uppercase(shortcut[0]);
@ -365,6 +361,13 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
} else
fl_addtopup(menu, strpool.add(label));
lyxerr[Debug::GUI] << "Command: \""
<< lyxaction.getActionName(item.action())
<< "\", Binding " << accel
<< ", shortcut " << xfshortcut
<< endl;
break;
}
@ -374,9 +377,9 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
smn, strpool);
if (submenu == -1)
return -1;
string label = idex(item.label().c_str());
string label = item.label();
label += extra_label + "%m";
string shortcut = scex(item.label().c_str());
string shortcut = item.shortcut();
int n = fl_addtopup(menu, strpool.add(label), submenu);
fl_setpup_shortcut(menu, n, strpool.add(shortcut));
break;

View File

@ -238,7 +238,8 @@ void ToolbarCB(FL_OBJECT * ob, long ac)
string res = owner->getLyXFunc()->Dispatch(int(ac));
if(!res.empty())
lyxerr[Debug::GUI] << res << endl;
lyxerr[Debug::GUI] << "ToolbarCB: Function returned: "
<< res << endl;
}

View File

@ -201,7 +201,8 @@ static string unique_id() {
ost << "file" << ++seed << '\0';
#endif
return ost.str();
// Needed if we use lyxstring.
return ost.str().c_str();
}

View File

@ -918,7 +918,7 @@ InsetText::LocalDispatch(BufferView * bv,
}
#ifdef HAVE_SSTREAM
std::istringstream istr(arg);
std::istringstream istr(arg.c_str());
#else
istrstream istr(arg.c_str());
#endif

View File

@ -123,6 +123,7 @@ extern void MenuSendto();
extern void QuitLyX();
extern void MenuFax(Buffer *);
extern void MenuExport(Buffer *, string const &);
extern void show_symbols_form(LyXFunc *);
extern LyXAction lyxaction;
// (alkis)
@ -380,20 +381,31 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
disable = noLaTeX || lyxrc.fax_command == "none";
break;
case LFUN_IMPORT:
if (argument == "latex")
if (argument == "latex" || argument == "noweb")
disable = lyxrc.relyx_command == "none";
if (argument == "linuxdoc")
else if (argument == "linuxdoc")
disable = lyxrc.linuxdoc_to_lyx_command == "none";
break;
case LFUN_EXPORT:
if (argument == "dvi" || argument == "postscript")
if (argument == "latex")
disable = ! buf->isLatex();
else if (argument == "linuxdoc")
disable = ! buf->isLinuxDoc();
else if (argument == "docbook")
disable = ! buf->isDocBook();
else if (argument == "dvi" || argument == "postscript")
disable = noLaTeX;
if (argument == "html")
disable = lyxrc.html_command == "none";
if (argument == "html-linuxdoc")
disable = lyxrc.linuxdoc_to_html_command == "none";
if (argument == "html-docbook")
disable = lyxrc.docbook_to_html_command == "none";
else if (argument == "html")
disable = (! buf->isLatex()
|| lyxrc.html_command == "none");
else if (argument == "html-linuxdoc")
disable = (! buf->isLinuxDoc()
|| lyxrc.linuxdoc_to_html_command == "none");
else if (argument == "html-docbook")
disable = (! buf->isDocBook()
|| lyxrc.docbook_to_html_command == "none");
else if (argument == "custom")
disable == ! buf->isLatex();
break;
case LFUN_UNDO:
disable = buf->undostack.empty();
@ -407,6 +419,9 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
case LFUN_RUNCHKTEX:
disable = lyxrc.chktex_command == "none";
break;
case LFUN_BUILDPROG:
disable = (lyxrc.literate_command == "none"
|| ! buf->isLiterate());
#ifndef NEW_TABULAR
case LFUN_LAYOUT_TABLE:
disable = ! owner->view()->text->cursor.par()->table;
@ -2448,7 +2463,6 @@ string LyXFunc::Dispatch(int ac,
case LFUN_MATH_MODE: // Open or create a math inset
{
if (owner->view()->available())
owner->view()->open_new_inset(new InsetFormula);
setMessage(N_("Math editor mode"));
@ -2459,6 +2473,13 @@ string LyXFunc::Dispatch(int ac,
case LFUN_MATH_LIMITS:
{
setErrorMessage(N_("This is only allowed in math mode!"));
}
break;
case LFUN_MATH_PANEL:
{
show_symbols_form(this);
}
break;

View File

@ -68,7 +68,6 @@ extern BufferList bufferlist;
extern void MenuLayoutSave();
extern void ShowCredits();
extern void show_symbols_form(LyXFunc *);
// A bunch of wrappers
@ -1997,7 +1996,7 @@ void Menus::ShowMathMenu(FL_OBJECT * ob, long)
tmpfunc->Dispatch(LFUN_MATH_DISPLAY);
break;
case 9: /* Panel */
show_symbols_form(tmpfunc);
tmpfunc->Dispatch(LFUN_MATH_PANEL);
break;
}
men->currentView()->update(BufferView::SELECT|BufferView::FITCUR);

View File

@ -735,7 +735,7 @@ string GetFileContents(string const & fname) {
ofs << ifs.rdbuf();
ifs.close();
#ifdef HAVE_SSTREAM
return ofs.str();
return ofs.str().c_str();
#else
ofs << '\0';
char const * tmp = ofs.str();