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 --- 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 +++ 10 files changed, 1629 insertions(+) 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 (limited to 'mixgtk') 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