summaryrefslogtreecommitdiffhomepage
path: root/mixgtk/mixgtk_gen_handlers.c
diff options
context:
space:
mode:
Diffstat (limited to 'mixgtk/mixgtk_gen_handlers.c')
-rw-r--r--mixgtk/mixgtk_gen_handlers.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/mixgtk/mixgtk_gen_handlers.c b/mixgtk/mixgtk_gen_handlers.c
index 63314f1..0d3daa3 100644
--- a/mixgtk/mixgtk_gen_handlers.c
+++ b/mixgtk/mixgtk_gen_handlers.c
@@ -26,10 +26,9 @@
#include "mixgtk_cmd_dispatcher.h"
#include "mixgtk_config.h"
-typedef void (*file_callback_t)(const gchar *file);
-
static file_callback_t callback_ = NULL;
+
static void
on_file_ok_ (GtkWidget *w, gpointer fs)
{
@@ -66,6 +65,17 @@ static void show_dlg_ (const gchar *title, const gchar *pattern)
gtk_grab_add (file);
}
+/* grab a file with an externally provided callback */
+void
+mixgtk_get_file (file_callback_t callback,
+ const gchar *title, const gchar *pattern)
+{
+ g_return_if_fail (callback != NULL);
+ callback_ = callback;
+ show_dlg_ (title, pattern);
+}
+
+
/* exec prompt command */
static void exec_cmd_ (mix_vm_command_t cmd, const gchar *arg)
{
@@ -90,8 +100,7 @@ static void open_cb_ (const gchar *file)
void
on_file_open_activate (GtkWidget *w, gpointer data)
{
- callback_ = open_cb_;
- show_dlg_ ("Load MIX program...", "*.mix");
+ mixgtk_get_file (open_cb_, "Load MIX program...", "*.mix");
}
/* edit mixal source */
@@ -103,9 +112,8 @@ static void edit_cb_ (const gchar *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 ());
+ mixgtk_get_file (edit_cb_, "Edit MIXAL source file...",
+ mixgtk_cmd_dispatcher_get_src_path ());
}
/* compile mixal source */
@@ -117,9 +125,8 @@ static void compile_cb_ (const gchar *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 ());
+ mixgtk_get_file (compile_cb_, "Compile MIXAL source file...",
+ mixgtk_cmd_dispatcher_get_src_path ());
}
void
@@ -141,7 +148,6 @@ on_file_exit_activate (GtkWidget *w, gpointer data)
gtk_main_quit ();
}
-
void
on_clear_breakpoints_activate (GtkWidget *w, gpointer data)
{