From b86afb94db26dba9d67d274736f07866b41b185d Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 8 Jul 2001 21:55:13 +0000 Subject: devdir command via menu --- mixgtk/mixgtk.glade | 184 ++++++++++++++++++++++++++++++++++++++++++- mixgtk/mixgtk_device.c | 54 +++++++++++++ mixgtk/mixgtk_gen_handlers.c | 28 ++++--- mixgtk/mixgtk_gen_handlers.h | 6 +- mixgtk/mixgtk_widgets.c | 3 +- mixgtk/mixgtk_widgets.h | 3 +- 6 files changed, 263 insertions(+), 15 deletions(-) (limited to 'mixgtk') diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade index cd73289..34eab7e 100644 --- a/mixgtk/mixgtk.glade +++ b/mixgtk/mixgtk.glade @@ -333,6 +333,18 @@ False + + GtkMenuItem + devices_dir + + activate + on_devdir_activate + Sun, 08 Jul 2001 20:58:13 GMT + + + False + + GtkMenuItem external_programs1 @@ -1731,6 +1743,18 @@ False + + GtkMenuItem + devices_dir + + activate + on_devdir_activate + Sun, 08 Jul 2001 20:58:35 GMT + + + False + + GtkMenuItem external_programs1 @@ -1791,7 +1815,7 @@ Sun, 29 Apr 2001 10:26:16 GMT - False + True True @@ -4327,4 +4351,162 @@ + + GtkDialog + devdir_dialog + False + + delete_event + gtk_widget_hide + Sun, 08 Jul 2001 20:42:29 GMT + + + destroy_event + gtk_widget_hide + Sun, 08 Jul 2001 20:42:41 GMT + + + destroy + gtk_widget_hide + Sun, 08 Jul 2001 20:42:53 GMT + + Devices directory + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + + + GtkVBox + Dialog:vbox + dialog-vbox11 + False + 0 + + + GtkHBox + Dialog:action_area + dialog-action_area11 + 1 + False + 0 + + 0 + False + False + GTK_PACK_END + + + + GtkHButtonBox + hbuttonbox10 + GTK_BUTTONBOX_END + 0 + 91 + 25 + 0 + 0 + + 0 + True + True + + + + GtkButton + devdir_cancel + True + True + + clicked + on_devdir_cancel_clicked + Sun, 08 Jul 2001 20:44:06 GMT + + + GTK_RELIEF_NORMAL + + + + GtkButton + devdir_ok + True + True + + clicked + on_devdir_ok_clicked + Sun, 08 Jul 2001 20:44:28 GMT + + + GTK_RELIEF_NORMAL + + + + + + GtkHBox + hbox1 + 25 + False + 11 + + 0 + False + True + + + + GtkLabel + label239 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkEntry + devdir_entry + True + False + True + 0 + + + 0 + True + True + + + + + GtkButton + devdir_browse + True + + clicked + on_devdir_browse_clicked + Sun, 08 Jul 2001 20:43:50 GMT + + + GTK_RELIEF_NORMAL + + 0 + False + False + + + + + + diff --git a/mixgtk/mixgtk_device.c b/mixgtk/mixgtk_device.c index 2b0bf2e..274d5eb 100644 --- a/mixgtk/mixgtk_device.c +++ b/mixgtk/mixgtk_device.c @@ -24,10 +24,13 @@ #include #include +#include #include #include "mixgtk.h" +#include "mixgtk_gen_handlers.h" #include "mixgtk_widgets.h" #include "mixgtk_config.h" +#include "mixgtk_cmd_dispatcher.h" #include "mixgtk_device.h" #define BIN_DEV_COL_ 5 @@ -36,6 +39,10 @@ static const gchar *DEV_FORMAT_KEY_ = "Device.format"; /* device container */ static GtkNotebook *container_ = NULL; +/* devdir dialog */ +static GtkWidget *devdir_dlg_ = NULL; +static GtkEntry *devdir_entry_ = NULL; + /** configuration stuff */ #define LAST_BIN_DEV_ mix_dev_DISK_7 static GtkWidget *devdlg_ = NULL; @@ -364,6 +371,8 @@ mixgtk_device_init (GtkNotebook *container, mix_vm_t *vm) vm_ = vm; last_pos_ = 0; devdlg_ = NULL; + devdir_dlg_ = NULL; + devdir_entry_ = NULL; dtoggle_ = NULL; wtoggle_ = NULL; combo_ = NULL; @@ -513,3 +522,48 @@ on_devset_button_clicked () ON : OFF; } +void +on_devdir_activate () +{ + static const gchar *DEVDIR_ENTRY_NAME = "devdir_entry"; + if (devdir_dlg_ == NULL) + { + devdir_dlg_ = mixgtk_widget_factory_get_dialog (MIXGTK_DEVDIR_DIALOG); + g_assert (devdir_dlg_); + devdir_entry_ = GTK_ENTRY + (mixgtk_widget_factory_get_child_by_name (MIXGTK_DEVDIR_DIALOG, + DEVDIR_ENTRY_NAME)); + g_assert (devdir_entry_); + } + gtk_entry_set_text (devdir_entry_, mix_device_get_dir ()); + gtk_widget_show (devdir_dlg_); +} + +static void +devdir_callback (const gchar *file) +{ + gtk_entry_set_text (devdir_entry_, file); +} + +void +on_devdir_browse_clicked () +{ + mixgtk_get_file (devdir_callback, "Devices dir", mix_device_get_dir ()); +} + +void +on_devdir_cancel_clicked () +{ + gtk_widget_hide (devdir_dlg_); +} + +void +on_devdir_ok_clicked () +{ + const gchar *dirname = gtk_entry_get_text (devdir_entry_); + gchar *cmd = g_strconcat (mix_vm_command_to_string (MIX_CMD_DEVDIR), + " ", dirname, NULL); + gtk_widget_hide (devdir_dlg_); + mixgtk_cmd_dispatcher_dispatch (cmd); + g_free (cmd); +} 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) { diff --git a/mixgtk/mixgtk_gen_handlers.h b/mixgtk/mixgtk_gen_handlers.h index 7b63b68..1e435c3 100644 --- a/mixgtk/mixgtk_gen_handlers.h +++ b/mixgtk/mixgtk_gen_handlers.h @@ -42,7 +42,6 @@ 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); @@ -52,6 +51,11 @@ on_save_on_exit_toggle (GtkWidget *w, gpointer data); extern void on_save_activate (GtkWidget *w, gpointer data); +typedef void (*file_callback_t)(const gchar *file); + +extern void +mixgtk_get_file (file_callback_t callback, const gchar *title, + const gchar *pattern); #endif /* MIXGTK_GEN_HANDLERS_H */ diff --git a/mixgtk/mixgtk_widgets.c b/mixgtk/mixgtk_widgets.c index 0a1acda..c286467 100644 --- a/mixgtk/mixgtk_widgets.c +++ b/mixgtk/mixgtk_widgets.c @@ -42,7 +42,8 @@ static const gchar * dnames_[] = { "fontsel_dialog", "devform_dialog", "external_dialog", - "symbols_dialog" + "symbols_dialog", + "devdir_dialog" }; const gchar *SPLIT_MAIN_NAME_ = "split_main_window"; diff --git a/mixgtk/mixgtk_widgets.h b/mixgtk/mixgtk_widgets.h index 1fafc71..a38d4e9 100644 --- a/mixgtk/mixgtk_widgets.h +++ b/mixgtk/mixgtk_widgets.h @@ -42,7 +42,8 @@ typedef enum { MIXGTK_FONTSEL_DIALOG, /* font selection dialog */ MIXGTK_DEVFORM_DIALOG, /* device format config dialog */ MIXGTK_EXTERNPROG_DIALOG, /* external programs dialog */ - MIXGTK_SYMBOLS_DIALOG /* symbol table dialog */ + MIXGTK_SYMBOLS_DIALOG, /* symbol table dialog */ + MIXGTK_DEVDIR_DIALOG } mixgtk_dialog_id_t; /* enumeration of mixvm widget ids */ -- cgit v1.2.3