diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | aclocal.m4 | 244 | ||||
-rw-r--r-- | configure.in | 12 | ||||
-rw-r--r-- | mixgtk/.cvsignore | 4 | ||||
-rw-r--r-- | mixgtk/Makefile.am | 20 | ||||
-rw-r--r-- | mixgtk/mixgtk.c | 49 | ||||
-rw-r--r-- | mixgtk/mixgtk.glade | 1125 | ||||
-rw-r--r-- | mixgtk/mixgtk_cmd_dispatcher.c | 117 | ||||
-rw-r--r-- | mixgtk/mixgtk_cmd_dispatcher.h | 43 | ||||
-rw-r--r-- | mixgtk/mixgtk_gen_handlers.c | 79 | ||||
-rw-r--r-- | mixgtk/mixgtk_gen_handlers.h | 46 | ||||
-rw-r--r-- | mixgtk/mixgtk_widgets.c | 71 | ||||
-rw-r--r-- | mixgtk/mixgtk_widgets.h | 75 |
13 files changed, 1885 insertions, 2 deletions
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 @@ -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 <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, µ) != 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 +]) + +# 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 <stdlib.h> +#include <gtk/gtk.h> +#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 @@ +<?xml version="1.0"?> +<GTK-Interface> + +<project> + <name>mixgtk</name> + <program_name>mixgtk</program_name> + <directory></directory> + <source_directory>src</source_directory> + <pixmaps_directory>pixmaps</pixmaps_directory> + <language>C</language> + <gnome_support>False</gnome_support> + <gettext_support>True</gettext_support> + <use_widget_names>True</use_widget_names> +</project> + +<widget> + <class>GtkWindow</class> + <name>main_window</name> + <signal> + <name>destroy</name> + <handler>on_main_window_destroy</handler> + <last_modification_time>Tue, 20 Feb 2001 21:58:29 GMT</last_modification_time> + </signal> + <title>mixgtk</title> + <type>GTK_WINDOW_TOPLEVEL</type> + <position>GTK_WIN_POS_NONE</position> + <modal>False</modal> + <default_width>650</default_width> + <default_height>500</default_height> + <allow_shrink>False</allow_shrink> + <allow_grow>True</allow_grow> + <auto_shrink>True</auto_shrink> + + <widget> + <class>GtkVBox</class> + <name>main_vbox</name> + <border_width>2</border_width> + <homogeneous>False</homogeneous> + <spacing>2</spacing> + + <widget> + <class>GtkMenuBar</class> + <name>mainmenubar</name> + <shadow_type>GTK_SHADOW_OUT</shadow_type> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + + <widget> + <class>GtkMenuItem</class> + <name>file</name> + <label>_File</label> + <right_justify>False</right_justify> + + <widget> + <class>GtkMenu</class> + <name>file_menu</name> + + <widget> + <class>GtkMenuItem</class> + <name>file_open</name> + <accelerator> + <modifiers>GDK_MOD1_MASK</modifiers> + <key>GDK_F3</key> + <signal>activate</signal> + </accelerator> + <signal> + <name>activate</name> + <handler>on_file_open_activate</handler> + <last_modification_time>Tue, 20 Feb 2001 22:37:58 GMT</last_modification_time> + </signal> + <label>_Open...</label> + <right_justify>False</right_justify> + </widget> + + <widget> + <class>GtkMenuItem</class> + <name>file_exit</name> + <accelerator> + <modifiers>GDK_MOD1_MASK</modifiers> + <key>GDK_Q</key> + <signal>activate</signal> + </accelerator> + <signal> + <name>activate</name> + <handler>on_file_exit_activate</handler> + <last_modification_time>Tue, 20 Feb 2001 22:37:58 GMT</last_modification_time> + </signal> + <label>_Exit</label> + <right_justify>False</right_justify> + </widget> + </widget> + </widget> + + <widget> + <class>GtkMenuItem</class> + <name>debug</name> + <label>_Debug</label> + <right_justify>False</right_justify> + </widget> + </widget> + + <widget> + <class>GtkToolbar</class> + <name>main_toolbar</name> + <orientation>GTK_ORIENTATION_HORIZONTAL</orientation> + <type>GTK_TOOLBAR_ICONS</type> + <space_size>5</space_size> + <space_style>GTK_TOOLBAR_SPACE_LINE</space_style> + <relief>GTK_RELIEF_NORMAL</relief> + <tooltips>True</tooltips> + <child> + <padding>1</padding> + <expand>False</expand> + <fill>False</fill> + </child> + + <widget> + <class>Placeholder</class> + </widget> + + <widget> + <class>Placeholder</class> + </widget> + + <widget> + <class>Placeholder</class> + </widget> + </widget> + + <widget> + <class>GtkVBox</class> + <name>inner_vbox</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkNotebook</class> + <name>main_notebook</name> + <can_focus>True</can_focus> + <show_tabs>True</show_tabs> + <show_border>True</show_border> + <tab_pos>GTK_POS_TOP</tab_pos> + <scrollable>False</scrollable> + <tab_hborder>2</tab_hborder> + <tab_vborder>2</tab_vborder> + <popup_enable>False</popup_enable> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkFixed</class> + <name>mixvm_widget</name> + <border_width>10</border_width> + <width>375</width> + <height>287</height> + + <widget> + <class>GtkCList</class> + <name>cells_clist</name> + <x>128</x> + <y>64</y> + <width>225</width> + <height>208</height> + <can_focus>True</can_focus> + <columns>2</columns> + <column_widths>80,80</column_widths> + <selection_mode>GTK_SELECTION_SINGLE</selection_mode> + <show_titles>True</show_titles> + <shadow_type>GTK_SHADOW_IN</shadow_type> + + <widget> + <class>GtkLabel</class> + <child_name>CList:title</child_name> + <name>label95</name> + <label>address</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>CList:title</child_name> + <name>label96</name> + <label>contents</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + </widget> + + <widget> + <class>GtkEntry</class> + <name>rJ_entry</name> + <x>40</x> + <y>48</y> + <width>60</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>- 00 23</text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>rA_entry</name> + <x>40</x> + <y>8</y> + <width>118</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>+ 01 45 34 49 49</text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>rX_entry</name> + <x>232</x> + <y>8</y> + <width>118</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>rI2_entry</name> + <x>40</x> + <y>120</y> + <width>60</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>rI1_entry</name> + <x>40</x> + <y>88</y> + <width>60</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>rI3_entry</name> + <x>40</x> + <y>152</y> + <width>60</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>rI4_entry</name> + <x>40</x> + <y>184</y> + <width>60</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>rI5_entry</name> + <x>40</x> + <y>216</y> + <width>60</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>rI6_entry</name> + <x>40</x> + <y>248</y> + <width>60</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label99</name> + <x>8</x> + <y>50</y> + <width>31</width> + <height>16</height> + <label>J</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label100</name> + <x>8</x> + <y>91</y> + <width>31</width> + <height>16</height> + <label>I1</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label101</name> + <x>8</x> + <y>124</y> + <width>31</width> + <height>16</height> + <label>I2</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label102</name> + <x>8</x> + <y>155</y> + <width>31</width> + <height>16</height> + <label>I3</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label103</name> + <x>8</x> + <y>187</y> + <width>31</width> + <height>16</height> + <label>I4</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label104</name> + <x>8</x> + <y>219</y> + <width>31</width> + <height>16</height> + <label>I5</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label105</name> + <x>8</x> + <y>251</y> + <width>31</width> + <height>16</height> + <label>I6</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkNotebook</class> + <name>devices_notebook</name> + <x>380</x> + <y>10</y> + <width>252</width> + <height>262</height> + <can_focus>True</can_focus> + <show_tabs>True</show_tabs> + <show_border>True</show_border> + <tab_pos>GTK_POS_TOP</tab_pos> + <scrollable>False</scrollable> + <tab_hborder>2</tab_hborder> + <tab_vborder>2</tab_vborder> + <popup_enable>False</popup_enable> + + <widget> + <class>GtkScrolledWindow</class> + <name>scrolledwindow45</name> + <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> + <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> + <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> + <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> + + <widget> + <class>GtkText</class> + <name>text37</name> + <can_focus>True</can_focus> + <editable>False</editable> + <text></text> + </widget> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label156</name> + <label>term</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkScrolledWindow</class> + <name>scrolledwindow46</name> + <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> + <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> + <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> + <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> + + <widget> + <class>GtkText</class> + <name>text38</name> + <can_focus>True</can_focus> + <editable>False</editable> + <text></text> + </widget> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label157</name> + <label>disk1</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkScrolledWindow</class> + <name>scrolledwindow47</name> + <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> + <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> + <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> + <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> + + <widget> + <class>GtkText</class> + <name>text39</name> + <can_focus>True</can_focus> + <editable>False</editable> + <text></text> + </widget> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label158</name> + <label>paper</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + </widget> + + <widget> + <class>GtkVSeparator</class> + <name>vseparator1</name> + <x>360</x> + <y>8</y> + <width>16</width> + <height>264</height> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label97</name> + <x>8</x> + <y>12</y> + <width>31</width> + <height>16</height> + <label>A</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label98</name> + <x>200</x> + <y>11</y> + <width>31</width> + <height>16</height> + <label>X</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkRadioButton</class> + <name>lesser_radio</name> + <x>136</x> + <y>40</y> + <width>35</width> + <height>24</height> + <can_focus>True</can_focus> + <label>L</label> + <active>False</active> + <draw_indicator>True</draw_indicator> + </widget> + + <widget> + <class>GtkRadioButton</class> + <name>equal_radio</name> + <x>176</x> + <y>40</y> + <width>31</width> + <height>24</height> + <can_focus>True</can_focus> + <label>E</label> + <active>False</active> + <draw_indicator>True</draw_indicator> + </widget> + + <widget> + <class>GtkRadioButton</class> + <name>greater_radio</name> + <x>216</x> + <y>40</y> + <width>32</width> + <height>24</height> + <can_focus>True</can_focus> + <label>G</label> + <active>False</active> + <draw_indicator>True</draw_indicator> + </widget> + + <widget> + <class>GtkRadioButton</class> + <name>over_radio</name> + <x>279</x> + <y>45</y> + <width>76</width> + <height>14</height> + <can_focus>True</can_focus> + <label>Overflow</label> + <active>False</active> + <draw_indicator>True</draw_indicator> + </widget> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label105</name> + <label>MIX</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkVBox</class> + <name>vbox2</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + + <widget> + <class>GtkScrolledWindow</class> + <name>scrolledwindow26</name> + <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> + <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> + <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> + <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkText</class> + <name>mixal_text</name> + <can_focus>True</can_focus> + <editable>False</editable> + <text>*** sample program + ORG 2000 +START LDA 1000 +....</text> + </widget> + </widget> + + <widget> + <class>GtkScrolledWindow</class> + <name>scrolledwindow27</name> + <hscrollbar_policy>GTK_POLICY_ALWAYS</hscrollbar_policy> + <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> + <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> + <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkCList</class> + <name>prog_info_clist</name> + <can_focus>True</can_focus> + <columns>3</columns> + <column_widths>80,173,80</column_widths> + <selection_mode>GTK_SELECTION_SINGLE</selection_mode> + <show_titles>True</show_titles> + <shadow_type>GTK_SHADOW_IN</shadow_type> + + <widget> + <class>GtkLabel</class> + <child_name>CList:title</child_name> + <name>label110</name> + <label>address</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>CList:title</child_name> + <name>label111</name> + <label>translation</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>CList:title</child_name> + <name>label112</name> + <label>binary</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + </widget> + </widget> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>Notebook:tab</child_name> + <name>label106</name> + <label>MIXAL</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + </widget> + + <widget> + <class>GtkScrolledWindow</class> + <name>scrolledwindow25</name> + <border_width>2</border_width> + <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy> + <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> + <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> + <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkViewport</class> + <name>viewport1</name> + <shadow_type>GTK_SHADOW_IN</shadow_type> + + <widget> + <class>GtkVBox</class> + <name>prompt_vbox</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + + <widget> + <class>GtkScrolledWindow</class> + <name>scrolledwindow48</name> + <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> + <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> + <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> + <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkText</class> + <name>command_log</name> + <can_focus>True</can_focus> + <editable>False</editable> + <text></text> + </widget> + </widget> + + <widget> + <class>GtkEntry</class> + <name>command_prompt</name> + <tooltip>Enter MIXVM command here</tooltip> + <can_focus>True</can_focus> + <signal> + <name>activate</name> + <handler>on_mixvm_cmd_entry_activate</handler> + <last_modification_time>Thu, 22 Feb 2001 23:26:28 GMT</last_modification_time> + </signal> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + </widget> + </widget> + </widget> + </widget> + </widget> + + <widget> + <class>GtkStatusbar</class> + <name>main_statusbar</name> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + </widget> + </widget> +</widget> + +<widget> + <class>GtkDialog</class> + <name>word_dialog</name> + <visible>False</visible> + <title>Enter word</title> + <type>GTK_WINDOW_DIALOG</type> + <position>GTK_WIN_POS_NONE</position> + <modal>True</modal> + <default_width>250</default_width> + <allow_shrink>False</allow_shrink> + <allow_grow>False</allow_grow> + <auto_shrink>False</auto_shrink> + + <widget> + <class>GtkVBox</class> + <child_name>Dialog:vbox</child_name> + <name>dialog-vbox5</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + + <widget> + <class>GtkHBox</class> + <child_name>Dialog:action_area</child_name> + <name>dialog-action_area5</name> + <border_width>10</border_width> + <width>250</width> + <homogeneous>True</homogeneous> + <spacing>5</spacing> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + <pack>GTK_PACK_END</pack> + </child> + + <widget> + <class>GtkHButtonBox</class> + <name>hbuttonbox5</name> + <width>250</width> + <layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style> + <spacing>30</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + + <widget> + <class>GtkButton</class> + <name>button11</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <label>Reset</label> + <relief>GTK_RELIEF_NORMAL</relief> + </widget> + + <widget> + <class>GtkButton</class> + <name>button12</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <label>OK</label> + <relief>GTK_RELIEF_NORMAL</relief> + </widget> + + <widget> + <class>GtkButton</class> + <name>button13</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <label>Cancel</label> + <relief>GTK_RELIEF_NORMAL</relief> + </widget> + </widget> + </widget> + + <widget> + <class>GtkFixed</class> + <name>fixed3</name> + <width>250</width> + <height>97</height> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + + <widget> + <class>GtkEntry</class> + <name>entry31</name> + <x>88</x> + <y>32</y> + <width>143</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>-63</text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>entry34</name> + <x>136</x> + <y>64</y> + <width>22</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>00</text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>entry35</name> + <x>160</x> + <y>64</y> + <width>22</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>01</text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>entry38</name> + <x>160</x> + <y>64</y> + <width>22</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>00</text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>entry39</name> + <x>184</x> + <y>64</y> + <width>22</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>00</text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>entry41</name> + <x>208</x> + <y>64</y> + <width>22</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>63</text> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label60</name> + <x>16</x> + <y>34</y> + <width>67</width> + <height>20</height> + <label>Decimal</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkEntry</class> + <name>entry40</name> + <x>112</x> + <y>64</y> + <width>22</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>00</text> + </widget> + + <widget> + <class>GtkEntry</class> + <name>entry42</name> + <x>88</x> + <y>64</y> + <width>16</width> + <height>22</height> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>-</text> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label61</name> + <x>22</x> + <y>67</y> + <width>41</width> + <height>16</height> + <label>Bytes</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label63</name> + <x>152</x> + <y>8</y> + <width>80</width> + <height>16</height> + <label>Register A</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <name>label62</name> + <x>48</x> + <y>8</y> + <width>104</width> + <height>16</height> + <label>Enter word for:</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + </widget> + </widget> +</widget> + +</GTK-Interface> 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 <stdio.h> +#include <mixlib/mix_vm_command.h> +#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 <gtk/gtk.h> + +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 <glade/glade.h> + +/* 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 <gtk/gtk.h> +#include <mixlib/mix_vm.h> + +/* 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 */ + |