From 119a5240f57ded266447b485e5a7c0eec6dd67f8 Mon Sep 17 00:00:00 2001 From: jaortega Date: Mon, 26 Feb 2001 23:16:00 +0000 Subject: gtk front-end files --- Makefile.am | 2 +- aclocal.m4 | 244 +++++++++ configure.in | 12 +- mixgtk/.cvsignore | 4 + mixgtk/Makefile.am | 20 + mixgtk/mixgtk.c | 49 ++ mixgtk/mixgtk.glade | 1125 ++++++++++++++++++++++++++++++++++++++++ mixgtk/mixgtk_cmd_dispatcher.c | 117 +++++ mixgtk/mixgtk_cmd_dispatcher.h | 43 ++ mixgtk/mixgtk_gen_handlers.c | 79 +++ mixgtk/mixgtk_gen_handlers.h | 46 ++ mixgtk/mixgtk_widgets.c | 71 +++ mixgtk/mixgtk_widgets.h | 75 +++ 13 files changed, 1885 insertions(+), 2 deletions(-) create mode 100644 mixgtk/.cvsignore create mode 100644 mixgtk/Makefile.am create mode 100644 mixgtk/mixgtk.c create mode 100644 mixgtk/mixgtk.glade create mode 100644 mixgtk/mixgtk_cmd_dispatcher.c create mode 100644 mixgtk/mixgtk_cmd_dispatcher.h create mode 100644 mixgtk/mixgtk_gen_handlers.c create mode 100644 mixgtk/mixgtk_gen_handlers.h create mode 100644 mixgtk/mixgtk_widgets.c create mode 100644 mixgtk/mixgtk_widgets.h diff --git a/Makefile.am b/Makefile.am index a7b52fb..95d1e62 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,5 +11,5 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. EXTRA_DIST = ABOUT-NLS autogen.sh configure -SUBDIRS = po intl doc mixlib mixutils misc samples +SUBDIRS = po intl doc mixlib mixutils mixgtk misc samples diff --git a/aclocal.m4 b/aclocal.m4 index bd51429..240d7b7 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -836,3 +836,247 @@ main () rm -f conf.glibtest ]) +# 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 +]) + +# a macro to get the libs/cflags for libglade +# serial 1 + +dnl AM_PATH_LIBGLADE([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]) +dnl Test to see if libglade is installed, and define LIBGLADE_CFLAGS, LIBS +dnl +AC_DEFUN(AM_PATH_LIBGLADE, +[dnl +dnl Get the cflags and libraries from the libglade-config script +dnl +AC_ARG_WITH(libglade-config, +[ --with-libglade-config=LIBGLADE_CONFIG Location of libglade-config], +LIBGLADE_CONFIG="$withval") + +module_args= +for module in . $3; do + case "$module" in + gnome) + module_args="$module_args gnome" + ;; + bonobo) + module_args="$module_args bonobo" + ;; + gnomedb) + module_args="$module_args gnomedb" + ;; + esac +done + +AC_PATH_PROG(LIBGLADE_CONFIG, libglade-config, no) +AC_MSG_CHECKING(for libglade) +if test "$LIBGLADE_CONFIG" = "no"; then + AC_MSG_RESULT(no) + ifelse([$2], , :, [$2]) +else + if $LIBGLADE_CONFIG --check $module_args; then + LIBGLADE_CFLAGS=`$LIBGLADE_CONFIG --cflags $module_args` + LIBGLADE_LIBS=`$LIBGLADE_CONFIG --libs $module_args` + AC_MSG_RESULT(yes) + ifelse([$1], , :, [$1]) + else + echo "*** libglade was not compiled with support for $module_args" 1>&2 + AC_MSG_RESULT(no) + ifelse([$2], , :, [$2]) + fi +fi +AC_SUBST(LIBGLADE_CFLAGS) +AC_SUBST(LIBGLADE_LIBS) +]) diff --git a/configure.in b/configure.in index 2f13085..02c9684 100644 --- a/configure.in +++ b/configure.in @@ -40,6 +40,15 @@ AM_PATH_GLIB(1.2.0, [LIBS="$LIBS $GLIB_LIBS" CFLAGS="$CFLAGS $GLIB_CFLAGS"], AC_MSG_ERROR(Cannot find GLIB), "gmodule" ) +dnl Check for gtk+ +AM_PATH_GTK(1.2.0, + [LIBS="$LIBS $GTK_LIBS" CFLAGS="$CFLAGS $GTK_CFLAGS"], + AC_MSG_ERROR(Cannot find GTK), "gmodule" ) + +dnl Check for libglade +AM_PATH_LIBGLADE([LIBS="$LIBS $LIBGLADE_LIBS" CFLAGS="$CFLAGS $LIBGLADE_CFLAGS"], + AC_MSG_ERROR(Cannot find libglade)) + CFLAGS="$CFLAGS -Wall" AC_SUBST(CFLAGS) @@ -49,7 +58,8 @@ doc/Makefile doc/html/Makefile mixlib/Makefile mixlib/testsuite/Makefile -mixutils/Makefile +mixutils/Makefile +mixgtk/Makefile misc/Makefile intl/Makefile samples/Makefile diff --git a/mixgtk/.cvsignore b/mixgtk/.cvsignore new file mode 100644 index 0000000..a285cd3 --- /dev/null +++ b/mixgtk/.cvsignore @@ -0,0 +1,4 @@ +.deps +Makefile +Makefile.in +mixgtk diff --git a/mixgtk/Makefile.am b/mixgtk/Makefile.am new file mode 100644 index 0000000..bb1881f --- /dev/null +++ b/mixgtk/Makefile.am @@ -0,0 +1,20 @@ +## Process this file with automake to produce Makefile.in + +# Copyright (C) 2001 Free Software Foundation, Inc. +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +EXTRA_DIST = mixgtk.glade +INCLUDES = -I$(includedir) +LDADD = $(top_builddir)/mixlib/libmix.a + +bin_PROGRAMS = mixgtk +mixgtk_SOURCES = mixgtk.c mixgtk_gen_handlers.h mixgtk_gen_handlers.c \ + mixgtk_cmd_dispatcher.h mixgtk_cmd_dispatcher.c \ + mixgtk_widgets.h mixgtk_widgets.c diff --git a/mixgtk/mixgtk.c b/mixgtk/mixgtk.c new file mode 100644 index 0000000..368f392 --- /dev/null +++ b/mixgtk/mixgtk.c @@ -0,0 +1,49 @@ +/* -*-c-*- -------------- mixgtk.c : + * Main function of the mix gtk front-end + * ------------------------------------------------------------------ + * Last change: Time-stamp: "01/02/26 02:54:24 jose" + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include +#include +#include "mixgtk_widgets.h" +#include "mixgtk_cmd_dispatcher.h" + +int +main(int argc, char *argv[]) +{ + const gchar *glade_file = "mixgtk.glade"; + + gtk_init(&argc, &argv); + + if (!mixgtk_widget_factory_init (glade_file)) { + g_error ("Unable to initialise application (using %s)\n", glade_file); + return EXIT_FAILURE; + } + + if (!mixgtk_cmd_dispatcher_init ()) { + g_error ("Unable to initialise application\n"); + return EXIT_FAILURE; + } + + gtk_main(); + + return EXIT_SUCCESS; +} diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade new file mode 100644 index 0000000..0100ad4 --- /dev/null +++ b/mixgtk/mixgtk.glade @@ -0,0 +1,1125 @@ + + + + + mixgtk + mixgtk + + src + pixmaps + C + False + True + True + + + + GtkWindow + main_window + + destroy + on_main_window_destroy + Tue, 20 Feb 2001 21:58:29 GMT + + mixgtk + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 650 + 500 + False + True + True + + + GtkVBox + main_vbox + 2 + False + 2 + + + GtkMenuBar + mainmenubar + GTK_SHADOW_OUT + + 0 + False + False + + + + GtkMenuItem + file + + False + + + GtkMenu + file_menu + + + GtkMenuItem + file_open + + GDK_MOD1_MASK + GDK_F3 + activate + + + activate + on_file_open_activate + Tue, 20 Feb 2001 22:37:58 GMT + + + False + + + + GtkMenuItem + file_exit + + GDK_MOD1_MASK + GDK_Q + activate + + + activate + on_file_exit_activate + Tue, 20 Feb 2001 22:37:58 GMT + + + False + + + + + + GtkMenuItem + debug + + False + + + + + GtkToolbar + main_toolbar + GTK_ORIENTATION_HORIZONTAL + GTK_TOOLBAR_ICONS + 5 + GTK_TOOLBAR_SPACE_LINE + GTK_RELIEF_NORMAL + True + + 1 + False + False + + + + Placeholder + + + + Placeholder + + + + Placeholder + + + + + GtkVBox + inner_vbox + False + 0 + + 0 + True + True + + + + GtkNotebook + main_notebook + True + True + True + GTK_POS_TOP + False + 2 + 2 + False + + 0 + False + True + + + + GtkFixed + mixvm_widget + 10 + 375 + 287 + + + GtkCList + cells_clist + 128 + 64 + 225 + 208 + True + 2 + 80,80 + GTK_SELECTION_SINGLE + True + GTK_SHADOW_IN + + + GtkLabel + CList:title + label95 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label96 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + GtkEntry + rJ_entry + 40 + 48 + 60 + 22 + True + True + True + 0 + - 00 23 + + + + GtkEntry + rA_entry + 40 + 8 + 118 + 22 + True + True + True + 0 + + 01 45 34 49 49 + + + + GtkEntry + rX_entry + 232 + 8 + 118 + 22 + True + True + True + 0 + + + + + GtkEntry + rI2_entry + 40 + 120 + 60 + 22 + True + True + True + 0 + + + + + GtkEntry + rI1_entry + 40 + 88 + 60 + 22 + True + True + True + 0 + + + + + GtkEntry + rI3_entry + 40 + 152 + 60 + 22 + True + True + True + 0 + + + + + GtkEntry + rI4_entry + 40 + 184 + 60 + 22 + True + True + True + 0 + + + + + GtkEntry + rI5_entry + 40 + 216 + 60 + 22 + True + True + True + 0 + + + + + GtkEntry + rI6_entry + 40 + 248 + 60 + 22 + True + True + True + 0 + + + + + GtkLabel + label99 + 8 + 50 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label100 + 8 + 91 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label101 + 8 + 124 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label102 + 8 + 155 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label103 + 8 + 187 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label104 + 8 + 219 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label105 + 8 + 251 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkNotebook + devices_notebook + 380 + 10 + 252 + 262 + True + True + True + GTK_POS_TOP + False + 2 + 2 + False + + + GtkScrolledWindow + scrolledwindow45 + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + GtkText + text37 + True + False + + + + + + GtkLabel + Notebook:tab + label156 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkScrolledWindow + scrolledwindow46 + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + GtkText + text38 + True + False + + + + + + GtkLabel + Notebook:tab + label157 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkScrolledWindow + scrolledwindow47 + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + GtkText + text39 + True + False + + + + + + GtkLabel + Notebook:tab + label158 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + GtkVSeparator + vseparator1 + 360 + 8 + 16 + 264 + + + + GtkLabel + label97 + 8 + 12 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label98 + 200 + 11 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkRadioButton + lesser_radio + 136 + 40 + 35 + 24 + True + + False + True + + + + GtkRadioButton + equal_radio + 176 + 40 + 31 + 24 + True + + False + True + + + + GtkRadioButton + greater_radio + 216 + 40 + 32 + 24 + True + + False + True + + + + GtkRadioButton + over_radio + 279 + 45 + 76 + 14 + True + + False + True + + + + + GtkLabel + Notebook:tab + label105 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkVBox + vbox2 + False + 0 + + + GtkScrolledWindow + scrolledwindow26 + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + GtkText + mixal_text + True + False + *** sample program + ORG 2000 +START LDA 1000 +.... + + + + + GtkScrolledWindow + scrolledwindow27 + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + GtkCList + prog_info_clist + True + 3 + 80,173,80 + GTK_SELECTION_SINGLE + True + GTK_SHADOW_IN + + + GtkLabel + CList:title + label110 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label111 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label112 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + + GtkLabel + Notebook:tab + label106 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + GtkScrolledWindow + scrolledwindow25 + 2 + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + GtkViewport + viewport1 + GTK_SHADOW_IN + + + GtkVBox + prompt_vbox + False + 0 + + + GtkScrolledWindow + scrolledwindow48 + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + GtkText + command_log + True + False + + + + + + GtkEntry + command_prompt + Enter MIXVM command here + True + + activate + on_mixvm_cmd_entry_activate + Thu, 22 Feb 2001 23:26:28 GMT + + True + True + 0 + + + 0 + False + False + + + + + + + + + GtkStatusbar + main_statusbar + + 0 + False + False + + + + + + + GtkDialog + word_dialog + False + Enter word + GTK_WINDOW_DIALOG + GTK_WIN_POS_NONE + True + 250 + False + False + False + + + GtkVBox + Dialog:vbox + dialog-vbox5 + False + 0 + + + GtkHBox + Dialog:action_area + dialog-action_area5 + 10 + 250 + True + 5 + + 0 + False + False + GTK_PACK_END + + + + GtkHButtonBox + hbuttonbox5 + 250 + GTK_BUTTONBOX_DEFAULT_STYLE + 30 + 85 + 27 + 7 + 0 + + 0 + False + False + + + + GtkButton + button11 + True + True + + GTK_RELIEF_NORMAL + + + + GtkButton + button12 + True + True + + GTK_RELIEF_NORMAL + + + + GtkButton + button13 + True + True + + GTK_RELIEF_NORMAL + + + + + + GtkFixed + fixed3 + 250 + 97 + + 0 + False + False + + + + GtkEntry + entry31 + 88 + 32 + 143 + 22 + True + True + True + 0 + -63 + + + + GtkEntry + entry34 + 136 + 64 + 22 + 22 + True + True + True + 0 + 00 + + + + GtkEntry + entry35 + 160 + 64 + 22 + 22 + True + True + True + 0 + 01 + + + + GtkEntry + entry38 + 160 + 64 + 22 + 22 + True + True + True + 0 + 00 + + + + GtkEntry + entry39 + 184 + 64 + 22 + 22 + True + True + True + 0 + 00 + + + + GtkEntry + entry41 + 208 + 64 + 22 + 22 + True + True + True + 0 + 63 + + + + GtkLabel + label60 + 16 + 34 + 67 + 20 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkEntry + entry40 + 112 + 64 + 22 + 22 + True + True + True + 0 + 00 + + + + GtkEntry + entry42 + 88 + 64 + 16 + 22 + True + True + True + 0 + - + + + + GtkLabel + label61 + 22 + 67 + 41 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label63 + 152 + 8 + 80 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label62 + 48 + 8 + 104 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + diff --git a/mixgtk/mixgtk_cmd_dispatcher.c b/mixgtk/mixgtk_cmd_dispatcher.c new file mode 100644 index 0000000..c5fef58 --- /dev/null +++ b/mixgtk/mixgtk_cmd_dispatcher.c @@ -0,0 +1,117 @@ +/* -*-c-*- -------------- mixgtk_cmd_dispatcher.c : + * Implementation of the functions declared in mixgtk_cmd_dispatcher.h + * ------------------------------------------------------------------ + * Last change: Time-stamp: "01/02/26 03:15:18 jose" + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#define _GNU_SOURCE 1 + +#include +#include +#include "mixgtk_cmd_dispatcher.h" + +/* a mix vm command dispatcher */ +struct mixgtk_dispatch_ +{ + mix_vm_cmd_dispatcher_t *dispatcher; + FILE *out; + char *out_buffer; + size_t out_buffer_size; + GtkWidget *prompt; + GtkWidget *log; +}; + +static struct mixgtk_dispatch_ dis_data_ = {NULL}; + +/* global hooks for the command dispatcher */ +static void +global_pre_hook_ (mix_vm_cmd_dispatcher_t *dis, + mix_vm_command_t cmd, const gchar *arg, gpointer data) +{ + if (cmd < MIX_CMD_INVALID) + { + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + "MIX> ", -1); + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + mix_vm_command_to_string (cmd), -1); + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + " ", -1); + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + arg, -1); + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + "\n", -1); + } + else + { + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + _("*** Invalid command\n"), -1); + } +} + +static void +global_post_hook_ (mix_vm_cmd_dispatcher_t *dis, + mix_vm_command_t cmd, const gchar *arg, gpointer data) +{ + fflush (dis_data_.out); + if (cmd < MIX_CMD_INVALID) + { + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + dis_data_.out_buffer, dis_data_.out_buffer_size); + } + rewind (dis_data_.out); +} + + +/* initialise the command dispatcher */ +gboolean +mixgtk_cmd_dispatcher_init (void) +{ + if (!dis_data_.prompt) + { + dis_data_.prompt = mixgtk_widget_factory_get (MIXGTK_WIDGET_PROMPT); + if (!dis_data_.prompt) return FALSE; + dis_data_.log = mixgtk_widget_factory_get (MIXGTK_WIDGET_LOG); + if (!dis_data_.log) return FALSE; + } + + if (!dis_data_.dispatcher) + { + FILE *out = open_memstream (&(dis_data_.out_buffer), + &(dis_data_.out_buffer_size)); + if (!out) return FALSE; + dis_data_.out = out; + dis_data_.dispatcher = mix_vm_cmd_dispatcher_new (out, out); + mix_vm_cmd_dispatcher_global_pre_hook(dis_data_.dispatcher, + global_pre_hook_, NULL); + mix_vm_cmd_dispatcher_global_post_hook(dis_data_.dispatcher, + global_post_hook_, NULL); + } + return TRUE; +} + +/* process new command */ +void +on_mixvm_cmd_entry_activate (GtkWidget *w, gpointer e) +{ + gchar *text; + text = gtk_entry_get_text (GTK_ENTRY (w)); + mix_vm_cmd_dispatcher_dispatch_text (dis_data_.dispatcher, text); + gtk_entry_set_text (GTK_ENTRY (w), ""); +} diff --git a/mixgtk/mixgtk_cmd_dispatcher.h b/mixgtk/mixgtk_cmd_dispatcher.h new file mode 100644 index 0000000..0169a5d --- /dev/null +++ b/mixgtk/mixgtk_cmd_dispatcher.h @@ -0,0 +1,43 @@ +/* -*-c-*- ---------------- mixgtk_cmd_dispatcher.h : + * functions to access the command dispatcher + * ------------------------------------------------------------------ + * Last change: Time-stamp: <01/02/25 17:24:28 jose> + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#ifndef MIXGTK_CMD_DISPATCHER_H +#define MIXGTK_CMD_DISPATCHER_H + +#include "mixgtk_widgets.h" + +/* initialise the command dispatcher */ +extern gboolean +mixgtk_cmd_dispatcher_init (); + + +/* make gtk signal callbacks accessible to glade */ +/* new command handler */ +extern void +on_mixvm_cmd_entry_activate (GtkWidget *w, gpointer e); + + + +#endif /* MIXGTK_CMD_DISPATCHER_H */ + diff --git a/mixgtk/mixgtk_gen_handlers.c b/mixgtk/mixgtk_gen_handlers.c new file mode 100644 index 0000000..e472341 --- /dev/null +++ b/mixgtk/mixgtk_gen_handlers.c @@ -0,0 +1,79 @@ +/* -*-c-*- -------------- mixgtk_gen_handlers.c : + * Implementation of the functions declared in mixgtk_gen_handlers.h + * ------------------------------------------------------------------ + * Last change: Time-stamp: "01/02/23 00:36:31 jose" + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#include "mixgtk_gen_handlers.h" + +void +on_main_window_destroy (GtkWidget *w, gpointer data) +{ + gtk_main_quit (); +} + +static void +on_file_open_ok_ (GtkWidget *w, gpointer fs) +{ + const gchar *file = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); + g_print ("File %s selected\n", file); + gtk_widget_destroy (GTK_WIDGET (fs)); +} + +static void +on_file_open_destroy_ (GtkWidget *w, gpointer data) +{ + gtk_grab_remove (GTK_WIDGET (w)); +} + +void +on_file_open_activate (GtkWidget *w, gpointer data) +{ + GtkWidget *file = gtk_file_selection_new ("Open program"); + gtk_signal_connect (GTK_OBJECT (file), "destroy", + (GtkSignalFunc) on_file_open_destroy_, + GTK_OBJECT (file)); + gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file)->ok_button), + "clicked", (GtkSignalFunc) on_file_open_ok_, + GTK_OBJECT (file)); + gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION + (file)->cancel_button), + "clicked", (GtkSignalFunc) gtk_widget_destroy, + GTK_OBJECT (file)); + gtk_widget_show (file); + gtk_grab_add (file); +} + +void +on_file_exit_activate (GtkWidget *w, gpointer data) +{ + g_message ("File_exit activated"); + gtk_main_quit (); +} + +void +on_debug_activate (GtkWidget *w, gpointer data) +{ +} + + + + diff --git a/mixgtk/mixgtk_gen_handlers.h b/mixgtk/mixgtk_gen_handlers.h new file mode 100644 index 0000000..e1aed47 --- /dev/null +++ b/mixgtk/mixgtk_gen_handlers.h @@ -0,0 +1,46 @@ +/* -*-c-*- ---------------- mixgtk_gen_handlers.h : + * general signal handlers declarations + * ------------------------------------------------------------------ + * Last change: Time-stamp: <01/02/23 00:36:35 jose> + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#ifndef MIXGTK_GEN_HANDLERS_H +#define MIXGTK_GEN_HANDLERS_H + +#include + +extern void +on_main_window_destroy (GtkWidget *w, gpointer data); + +extern void +on_file_open_activate (GtkWidget *w, gpointer data); + +extern void +on_file_exit_activate (GtkWidget *w, gpointer data); + +extern void +on_debug_activate (GtkWidget *w, gpointer data); + + + + +#endif /* MIXGTK_GEN_HANDLERS_H */ + diff --git a/mixgtk/mixgtk_widgets.c b/mixgtk/mixgtk_widgets.c new file mode 100644 index 0000000..aa06643 --- /dev/null +++ b/mixgtk/mixgtk_widgets.c @@ -0,0 +1,71 @@ +/* -*-c-*- -------------- mixgtk_widgets.c : + * Implementation of the functions declared in mixgtk_widgets.h + * ------------------------------------------------------------------ + * Last change: Time-stamp: "01/02/26 02:57:02 jose" + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#include "mixgtk_widgets.h" + +#include + +/* the glade spec */ +static GladeXML *xml_ = NULL; + +/* widget names */ +static const gchar *names_[] = { + "main_window", + "word_dialog", + "command_prompt", + "command_log" +}; + +#define WIDGET_NO_ (sizeof (names_) / sizeof (names_[0])) + +/* create a new factory from an xml glade file */ +gboolean +mixgtk_widget_factory_init (const char *glade_file) +{ + glade_init (); + xml_ = glade_xml_new (glade_file, NULL); + if (!xml_) return FALSE; + glade_xml_signal_autoconnect (xml_); + return TRUE; +} + +/* get a widget */ +GtkWidget * +mixgtk_widget_factory_get (mixgtk_widget_id_t widget) +{ + g_return_val_if_fail (widget < WIDGET_NO_, NULL); + return glade_xml_get_widget (xml_, names_[widget]); +} + +/* update a widget from a virtual machine */ +extern void +mixgtk_widget_factory_update_widget (mixgtk_widget_id_t widget, + const mix_vm_t *vm); + +/* update the virtual machine from a widget */ +extern void +mixgtk_widget_factory_update_vm (mixgtk_widget_id_t widget, + mix_vm_t *vm); + + diff --git a/mixgtk/mixgtk_widgets.h b/mixgtk/mixgtk_widgets.h new file mode 100644 index 0000000..60781e4 --- /dev/null +++ b/mixgtk/mixgtk_widgets.h @@ -0,0 +1,75 @@ +/* -*-c-*- ---------------- mixgtk_widgets.h : + * glade-based factory of mixvm widgets + * ------------------------------------------------------------------ + * Last change: Time-stamp: <01/02/25 12:51:58 jose> + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#ifndef MIXGTK_WIDGETS_H +#define MIXGTK_WIDGETS_H + +#include +#include + +/* enumeration of mixvm widget ids */ +typedef enum { + MIXGTK_WIDGET_MAIN, /* main app window */ + MIXGTK_WIDGET_WORD_DIALOG, /* input dialog for a mix word */ + MIXGTK_WIDGET_PROMPT, /* command prompt */ + MIXGTK_WIDGET_LOG, /* command output */ + MIXGTK_WIDGET_rA, + MIXGTK_WIDGET_rX, + MIXGTK_WIDGET_rJ, + MIXGTK_WIDGET_rI1, + MIXGTK_WIDGET_rI2, + MIXGTK_WIDGET_rI3, + MIXGTK_WIDGET_rI4, + MIXGTK_WIDGET_rI5, + MIXGTK_WIDGET_rI6, + MIXGTK_WIDGET_CMP, + MIXGTK_WIDGET_OVER, + MIXGTK_WIDGET_CELLS, + MIXGTK_WIDGET_DEVICE, + MIXGTK_WIDGET_NONE +} mixgtk_widget_id_t; + + +/* create a new factory from an xml glade file */ +extern gboolean +mixgtk_widget_factory_init (const char *glade_file); + + +/* get a widget */ +extern GtkWidget * +mixgtk_widget_factory_get (mixgtk_widget_id_t widget); + +/* update a widget from a virtual machine */ +extern void +mixgtk_widget_factory_update_widget (mixgtk_widget_id_t widget, + const mix_vm_t *vm); + +/* update the virtual machine from a widget */ +extern void +mixgtk_widget_factory_update_vm (mixgtk_widget_id_t widget, + mix_vm_t *vm); + + +#endif /* MIXGTK_WIDGETS_H */ + -- cgit v1.2.3