summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2001-06-08 22:27:45 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2001-06-08 22:27:45 +0000
commitdcecb720e3f2409add20c2606d70260d41e23508 (patch)
treefa6fb0357aaa5d5d535bd1a6f85e463e1ef7680b
parent8b066a1f0a6bc9d8cb9a44e6c45f5e97f505ebb1 (diff)
downloadmdk-dcecb720e3f2409add20c2606d70260d41e23508.tar.gz
mdk-dcecb720e3f2409add20c2606d70260d41e23508.tar.bz2
edit and compile menu entries added
-rw-r--r--mixgtk/mixgtk.glade48
-rw-r--r--mixgtk/mixgtk_cmd_dispatcher.c7
-rw-r--r--mixgtk/mixgtk_cmd_dispatcher.h8
-rw-r--r--mixgtk/mixgtk_gen_handlers.c92
-rw-r--r--mixgtk/mixgtk_gen_handlers.h7
5 files changed, 137 insertions, 25 deletions
diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade
index 5a74485..e33233a 100644
--- a/mixgtk/mixgtk.glade
+++ b/mixgtk/mixgtk.glade
@@ -81,6 +81,48 @@
<widget>
<class>GtkMenuItem</class>
+ <name>edit</name>
+ <tooltip>Edit a MIXAL source file</tooltip>
+ <accelerator>
+ <modifiers>GDK_MOD1_MASK</modifiers>
+ <key>GDK_F4</key>
+ <signal>activate</signal>
+ </accelerator>
+ <signal>
+ <name>activate</name>
+ <handler>on_file_edit_activate</handler>
+ <last_modification_time>Fri, 08 Jun 2001 21:11:13 GMT</last_modification_time>
+ </signal>
+ <label>_Edit...</label>
+ <right_justify>False</right_justify>
+ </widget>
+
+ <widget>
+ <class>GtkMenuItem</class>
+ <name>compile</name>
+ <tooltip>Compile a MIXAL source file</tooltip>
+ <accelerator>
+ <modifiers>GDK_MOD1_MASK</modifiers>
+ <key>GDK_F5</key>
+ <signal>activate</signal>
+ </accelerator>
+ <signal>
+ <name>activate</name>
+ <handler>on_file_compile_activate</handler>
+ <last_modification_time>Fri, 08 Jun 2001 21:11:33 GMT</last_modification_time>
+ </signal>
+ <label>_Compile...</label>
+ <right_justify>False</right_justify>
+ </widget>
+
+ <widget>
+ <class>GtkMenuItem</class>
+ <name>separator2</name>
+ <right_justify>False</right_justify>
+ </widget>
+
+ <widget>
+ <class>GtkMenuItem</class>
<name>file_exit</name>
<tooltip>Exit application</tooltip>
<accelerator>
@@ -1701,16 +1743,16 @@
<x>0</x>
<y>7</y>
<width>16</width>
- <height>83</height>
+ <height>81</height>
</widget>
<widget>
<class>GtkVSeparator</class>
<name>vseparator5</name>
- <x>352</x>
+ <x>354</x>
<y>8</y>
<width>16</width>
- <height>83</height>
+ <height>81</height>
</widget>
</widget>
</widget>
diff --git a/mixgtk/mixgtk_cmd_dispatcher.c b/mixgtk/mixgtk_cmd_dispatcher.c
index 5076727..240cf9e 100644
--- a/mixgtk/mixgtk_cmd_dispatcher.c
+++ b/mixgtk/mixgtk_cmd_dispatcher.c
@@ -374,6 +374,13 @@ mixgtk_cmd_dispatcher_get_vm (void)
return (mix_vm_t *) mix_vm_cmd_dispatcher_get_vm (dis_data_.dispatcher);
}
+/* get the current source file */
+const gchar *
+mixgtk_cmd_dispatcher_get_src_path (void)
+{
+ return mix_vm_cmd_dispatcher_get_src_file_path (dis_data_.dispatcher);
+}
+
/* process commands */
void
complete_command_ (void)
diff --git a/mixgtk/mixgtk_cmd_dispatcher.h b/mixgtk/mixgtk_cmd_dispatcher.h
index 686ba4d..915f72b 100644
--- a/mixgtk/mixgtk_cmd_dispatcher.h
+++ b/mixgtk/mixgtk_cmd_dispatcher.h
@@ -44,11 +44,9 @@ mixgtk_cmd_dispatcher_get_times (gint *uptime, gint *progtime, gint *laptime);
extern mix_vm_t *
mixgtk_cmd_dispatcher_get_vm (void);
-/* make gtk signal callbacks accessible to glade */
-/* new command handler */
-extern void
-on_mixvm_cmd_entry_activate (GtkWidget *w, gpointer e);
-
+/* get the current source file */
+extern const gchar *
+mixgtk_cmd_dispatcher_get_src_path (void);
#endif /* MIXGTK_CMD_DISPATCHER_H */
diff --git a/mixgtk/mixgtk_gen_handlers.c b/mixgtk/mixgtk_gen_handlers.c
index b687a6d..904bcb3 100644
--- a/mixgtk/mixgtk_gen_handlers.c
+++ b/mixgtk/mixgtk_gen_handlers.c
@@ -26,39 +26,35 @@
#include "mixgtk_cmd_dispatcher.h"
#include "mixgtk_config.h"
-void
-on_main_window_destroy (GtkWidget *w, gpointer data)
-{
- gtk_main_quit ();
-}
+typedef void (*file_callback_t)(const gchar *file);
+
+static file_callback_t callback_ = NULL;
static void
-on_file_open_ok_ (GtkWidget *w, gpointer fs)
+on_file_ok_ (GtkWidget *w, gpointer fs)
{
const gchar *file = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs));
- gchar *command = g_strdup_printf ("%s %s",
- mix_vm_command_to_string (MIX_CMD_LOAD),
- file);
gtk_widget_destroy (GTK_WIDGET (fs));
- mixgtk_cmd_dispatcher_dispatch (command);
- g_free (command);
+ if (callback_) callback_ (file);
}
static void
-on_file_open_destroy_ (GtkWidget *w, gpointer data)
+on_file_destroy_ (GtkWidget *w, gpointer data)
{
gtk_grab_remove (GTK_WIDGET (w));
}
-void
-on_file_open_activate (GtkWidget *w, gpointer data)
+static void show_dlg_ (const gchar *title, const gchar *pattern)
{
- GtkWidget *file = gtk_file_selection_new ("Open program");
+ GtkWidget *file = gtk_file_selection_new (title);
+ if (pattern)
+ gtk_file_selection_complete (GTK_FILE_SELECTION (file), pattern);
+
gtk_signal_connect (GTK_OBJECT (file), "destroy",
- (GtkSignalFunc) on_file_open_destroy_,
+ (GtkSignalFunc) on_file_destroy_,
GTK_OBJECT (file));
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file)->ok_button),
- "clicked", (GtkSignalFunc) on_file_open_ok_,
+ "clicked", (GtkSignalFunc) on_file_ok_,
GTK_OBJECT (file));
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION
(file)->cancel_button),
@@ -68,6 +64,68 @@ on_file_open_activate (GtkWidget *w, gpointer data)
gtk_grab_add (file);
}
+/* exec prompt command */
+static void exec_cmd_ (mix_vm_command_t cmd, const gchar *arg)
+{
+ gchar *command;
+ if (arg)
+ command = g_strdup_printf ("%s %s",
+ mix_vm_command_to_string (cmd),
+ arg);
+ else
+ command = g_strdup (mix_vm_command_to_string (cmd));
+ mixgtk_cmd_dispatcher_dispatch (command);
+ g_free (command);
+}
+
+/* load mix binary */
+static void open_cb_ (const gchar *file)
+{
+ if (file)
+ exec_cmd_ (MIX_CMD_LOAD, file);
+}
+
+void
+on_file_open_activate (GtkWidget *w, gpointer data)
+{
+ callback_ = open_cb_;
+ show_dlg_ ("Load MIX program...", "*.mix");
+}
+
+/* edit mixal source */
+static void edit_cb_ (const gchar *file)
+{
+ exec_cmd_ (MIX_CMD_EDIT, file);
+}
+
+void
+on_file_edit_activate (GtkWidget *w, gpointer data)
+{
+ callback_ = edit_cb_;
+ show_dlg_ ("Edit MIXAL source file...",
+ mixgtk_cmd_dispatcher_get_src_path ());
+}
+
+/* compile mixal source */
+static void compile_cb_ (const gchar *file)
+{
+ exec_cmd_ (MIX_CMD_COMPILE, file);
+}
+
+void
+on_file_compile_activate (GtkWidget *w, gpointer data)
+{
+ callback_ = compile_cb_;
+ show_dlg_ ("Compile MIXAL source file...",
+ mixgtk_cmd_dispatcher_get_src_path ());
+}
+
+void
+on_main_window_destroy (GtkWidget *w, gpointer data)
+{
+ gtk_main_quit ();
+}
+
void
on_debug_run_activate (GtkWidget *w, gpointer p)
{
diff --git a/mixgtk/mixgtk_gen_handlers.h b/mixgtk/mixgtk_gen_handlers.h
index 0442d22..7b63b68 100644
--- a/mixgtk/mixgtk_gen_handlers.h
+++ b/mixgtk/mixgtk_gen_handlers.h
@@ -37,6 +37,13 @@ extern void
on_file_exit_activate (GtkWidget *w, gpointer data);
extern void
+on_file_edit_activate (GtkWidget *w, gpointer data);
+
+extern void
+on_file_compile_activate (GtkWidget *w, gpointer data);
+
+
+extern void
on_clear_breakpoints_activate (GtkWidget *w, gpointer data);
extern void