diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2001-06-25 23:52:29 +0000 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2001-06-25 23:52:29 +0000 |
commit | 2f0c4e4aa87209194f8fcb1296525a032d00f8c6 (patch) | |
tree | eb73cc608a66d87fcd6808a03a820a6db9ef139c | |
parent | a934de6c26ede02f0c988d45b16183ce578d57a1 (diff) | |
download | mdk-2f0c4e4aa87209194f8fcb1296525a032d00f8c6.tar.gz mdk-2f0c4e4aa87209194f8fcb1296525a032d00f8c6.tar.bz2 |
hot split/unsplit
-rw-r--r-- | mixgtk/mixgtk.c | 68 | ||||
-rw-r--r-- | mixgtk/mixgtk.h | 4 | ||||
-rw-r--r-- | mixgtk/mixgtk_cmd_dispatcher.c | 68 | ||||
-rw-r--r-- | mixgtk/mixgtk_colorsel.c | 12 | ||||
-rw-r--r-- | mixgtk/mixgtk_colorsel.h | 4 | ||||
-rw-r--r-- | mixgtk/mixgtk_device.c | 19 | ||||
-rw-r--r-- | mixgtk/mixgtk_fontsel.c | 17 | ||||
-rw-r--r-- | mixgtk/mixgtk_gen_handlers.c | 6 | ||||
-rw-r--r-- | mixgtk/mixgtk_input.c | 7 | ||||
-rw-r--r-- | mixgtk/mixgtk_input.h | 4 | ||||
-rw-r--r-- | mixgtk/mixgtk_mixal.c | 11 | ||||
-rw-r--r-- | mixgtk/mixgtk_widgets.c | 43 | ||||
-rw-r--r-- | mixgtk/mixgtk_wm.c | 15 |
13 files changed, 182 insertions, 96 deletions
diff --git a/mixgtk/mixgtk.c b/mixgtk/mixgtk.c index 6089dd2..2f60cb2 100644 --- a/mixgtk/mixgtk.c +++ b/mixgtk/mixgtk.c @@ -38,33 +38,11 @@ static const gchar *SPLIT_ARG_ = "-s"; static const gchar *SPLIT_LONG_ARG_ = "--s"; -/* initialise the app */ gboolean -mixgtk_init (int argc, char *argv[]) +mixgtk_restart (gboolean split) { mix_vm_t *vm; - gboolean split = FALSE; - gint k; - - mix_init_lib (); - - if (!mixgtk_config_load ()) - { - g_error ("Unable to read configuration\n"); - return FALSE; - } - for (k = 0; k < argc; ++k) - if (!strcmp (argv[k], SPLIT_ARG_) || !strcmp (argv[k], SPLIT_LONG_ARG_)) - { - split = TRUE; - break; - } - if (!split && mixgtk_config_is_split ()) split = TRUE; - mixgtk_config_set_split (split); - - gtk_init (&argc, &argv); - if (!mixgtk_widget_factory_init (split)) { g_error ("Unable to initialise application: missing glade file"); @@ -77,9 +55,6 @@ mixgtk_init (int argc, char *argv[]) return FALSE; } - if (split) - gtk_widget_show (mixgtk_widget_factory_get_dialog (MIXGTK_MAIN)); - vm = mixgtk_cmd_dispatcher_get_vm (); if (!mixgtk_mixvm_init (vm, MIXGTK_MIXVM_DIALOG)) @@ -108,19 +83,50 @@ mixgtk_init (int argc, char *argv[]) g_error ("Unable to initialise application (visibility)\n"); return FALSE; } - + + mixgtk_input_init (); + mixgtk_colorsel_init (); mixgtk_fontsel_load_defaults (split); - + + gtk_widget_show (mixgtk_widget_factory_get_dialog (MIXGTK_MAIN)); + mixgtk_mixvm_update_vm_widgets (); + return TRUE; } +/* initialise the app */ +gboolean +mixgtk_init (int argc, char *argv[]) +{ + gboolean split = FALSE; + gint k; + + mix_init_lib (); + + if (!mixgtk_config_load ()) + { + g_error ("Unable to read configuration\n"); + return FALSE; + } + + for (k = 0; k < argc; ++k) + if (!strcmp (argv[k], SPLIT_ARG_) || !strcmp (argv[k], SPLIT_LONG_ARG_)) + { + split = TRUE; + break; + } + if (!split && mixgtk_config_is_split ()) split = TRUE; + mixgtk_config_set_split (split); + + gtk_init (&argc, &argv); + + return mixgtk_restart (split); +} + /* main loop */ void mixgtk_main (void) { - gtk_widget_show (mixgtk_widget_factory_get_dialog (MIXGTK_MAIN)); - mixgtk_mixvm_update_vm_widgets (); - gtk_main (); } diff --git a/mixgtk/mixgtk.h b/mixgtk/mixgtk.h index 403847c..e26302e 100644 --- a/mixgtk/mixgtk.h +++ b/mixgtk/mixgtk.h @@ -35,6 +35,10 @@ extern gboolean mixgtk_init (int argc, char *argv[]); +/* restart the gui */ +extern gboolean +mixgtk_restart (gboolean split); + /* enter the main mixgtk loop */ extern void mixgtk_main (void); diff --git a/mixgtk/mixgtk_cmd_dispatcher.c b/mixgtk/mixgtk_cmd_dispatcher.c index 024c09d..f034cd3 100644 --- a/mixgtk/mixgtk_cmd_dispatcher.c +++ b/mixgtk/mixgtk_cmd_dispatcher.c @@ -58,6 +58,14 @@ typedef struct mixgtk_dispatch_ static struct mixgtk_dispatch_ dis_data_ = {NULL}; +static GtkWidget *ext_dlg_ = NULL; +static GtkWidget *ed_entry_ = NULL; +static GtkWidget *asm_entry_ = NULL; + +static const gchar *ED_NAME_ = "editor_entry"; +static const gchar *ASM_NAME_ = "mixasm_entry"; + + static void log_command_ (mixgtk_dispatch_data_t *dis, const gchar *cmd) { @@ -247,13 +255,6 @@ read_config_ (void) } -static GtkWidget *ext_dlg_ = NULL; -static GtkWidget *ed_entry_ = NULL; -static GtkWidget *asm_entry_ = NULL; - -static const gchar *ED_NAME_ = "editor_entry"; -static const gchar *ASM_NAME_ = "mixasm_entry"; - void on_external_programs_activate () { @@ -298,24 +299,27 @@ on_extern_ok_button_clicked () gboolean mixgtk_cmd_dispatcher_init (mixgtk_dialog_id_t top) { - if (!dis_data_.prompt) - { - dis_data_.prompt = - mixgtk_widget_factory_get (top, MIXGTK_WIDGET_PROMPT); - g_return_val_if_fail (dis_data_.prompt != NULL, FALSE); - dis_data_.log = - mixgtk_widget_factory_get (top, MIXGTK_WIDGET_LOG); - g_return_val_if_fail (dis_data_.log != NULL, FALSE); - } + static gboolean restart = FALSE; + + ext_dlg_ = NULL; + ed_entry_ = NULL; + asm_entry_ = NULL; + + dis_data_.prompt = + mixgtk_widget_factory_get (top, MIXGTK_WIDGET_PROMPT); + g_return_val_if_fail (dis_data_.prompt != NULL, FALSE); + dis_data_.log = + mixgtk_widget_factory_get (top, MIXGTK_WIDGET_LOG); + g_return_val_if_fail (dis_data_.log != NULL, FALSE); if (!dis_data_.dispatcher) { int r = pipe (dis_data_.fildes); g_return_val_if_fail (r == 0, FALSE); - /* connect stdout/stderr to the pipe's write end */ + /* connect stdout/stderr to the pipe's write end if (dup2 (dis_data_.fildes[1], STDOUT_FILENO) == -1 || dup2 (dis_data_.fildes[1], STDERR_FILENO) == -1) - return FALSE; + return FALSE;*/ dis_data_.out = fdopen (dis_data_.fildes[1], "w"); g_return_val_if_fail (dis_data_.out != NULL, FALSE); r = fcntl (dis_data_.fildes[0], F_GETFL, 0); @@ -330,24 +334,24 @@ mixgtk_cmd_dispatcher_init (mixgtk_dialog_id_t top) install_hooks_ (); } - if (!dis_data_.status) - { - dis_data_.status = - mixgtk_widget_factory_get (MIXGTK_MAIN, MIXGTK_WIDGET_STATUSBAR); - g_return_val_if_fail (dis_data_.status != NULL, FALSE); - dis_data_.context = gtk_statusbar_get_context_id (GTK_STATUSBAR - (dis_data_.status), - "cmd_dis_context"); - } - + dis_data_.status = + mixgtk_widget_factory_get (MIXGTK_MAIN, MIXGTK_WIDGET_STATUSBAR); + g_return_val_if_fail (dis_data_.status != NULL, FALSE); + dis_data_.context = gtk_statusbar_get_context_id (GTK_STATUSBAR + (dis_data_.status), + "cmd_dis_context"); if (!dis_data_.completions) init_completions_ (); - read_config_ (); + if (!restart) read_config_ (); #ifdef HAVE_LIBHISTORY - using_history (); - stifle_history (MAX_HISTORY_); + if (!restart) + { + using_history (); + stifle_history (MAX_HISTORY_); + } #endif - + + restart = TRUE; return TRUE; } diff --git a/mixgtk/mixgtk_colorsel.c b/mixgtk/mixgtk_colorsel.c index b40f6d2..c257255 100644 --- a/mixgtk/mixgtk_colorsel.c +++ b/mixgtk/mixgtk_colorsel.c @@ -49,7 +49,17 @@ typedef struct static area_id_t areas_[LNO_][ZNO_]; static area_id_t *current_ = NULL; -static GtkWidget *colorseldlg_ = NULL; +static GtkWidget *colorseldlg_ = NULL; + + +void +mixgtk_colorsel_init (void) +{ + color_dialog_ = NULL; + colorseldlg_ = NULL; + current_ = NULL; +} + static void set_area_color_ (GtkWidget *area, const GdkColor *color) { diff --git a/mixgtk/mixgtk_colorsel.h b/mixgtk/mixgtk_colorsel.h index 99253a7..0b30427 100644 --- a/mixgtk/mixgtk_colorsel.h +++ b/mixgtk/mixgtk_colorsel.h @@ -27,9 +27,9 @@ #include <gtk/gtk.h> -/* gtk callbacks */ +/* init */ extern void -on_colors_activate (GtkWidget *w, gpointer p); +mixgtk_colorsel_init (void); #endif /* MIXGTK_COLORSEL_H */ diff --git a/mixgtk/mixgtk_device.c b/mixgtk/mixgtk_device.c index 18bc121..ac0092d 100644 --- a/mixgtk/mixgtk_device.c +++ b/mixgtk/mixgtk_device.c @@ -36,6 +36,13 @@ static const gchar *DEV_FORMAT_KEY_ = "Device.format"; /* device container */ static GtkNotebook *container_ = NULL; +/** configuration stuff */ +#define LAST_BIN_DEV_ mix_dev_DISK_7 +static GtkWidget *devdlg_ = NULL; +static GtkWidget *dtoggle_ = NULL; +static GtkWidget *wtoggle_ = NULL; +static GtkWidget *combo_ = NULL; + static gint last_pos_ = 0; /* virtual machine */ static mix_vm_t *vm_ = NULL; @@ -323,6 +330,11 @@ mixgtk_device_init (GtkNotebook *container, mix_vm_t *vm) g_return_val_if_fail (vm != NULL, FALSE); container_ = container; vm_ = vm; + /** configuration stuff */ + devdlg_ = NULL; + dtoggle_ = NULL; + wtoggle_ = NULL; + combo_ = NULL; /* remove dummy page from container */ gtk_notebook_remove_page (container_, 0); @@ -367,13 +379,6 @@ mixgtk_device_set_format (mix_device_type_t dev, gboolean dec) } -/** configuration stuff */ -#define LAST_BIN_DEV_ mix_dev_DISK_7 -static GtkWidget *devdlg_ = NULL; -static GtkWidget *dtoggle_ = NULL; -static GtkWidget *wtoggle_ = NULL; -static GtkWidget *combo_ = NULL; - static mix_device_type_t get_device_idx_ (void) { diff --git a/mixgtk/mixgtk_fontsel.c b/mixgtk/mixgtk_fontsel.c index ffb2209..a72c5e7 100644 --- a/mixgtk/mixgtk_fontsel.c +++ b/mixgtk/mixgtk_fontsel.c @@ -46,7 +46,15 @@ static mixgtk_widget_id_t widget_ids_[] = { MIXGTK_WIDGET_DEVICE }; -static mixgtk_dialog_id_t dialog_ids_[] = { +static mixgtk_dialog_id_t dialog_ids_no_split_[] = { + MIXGTK_MAIN, + MIXGTK_MAIN, + MIXGTK_MAIN, + MIXGTK_MAIN, + MIXGTK_MAIN, +}; + +static mixgtk_dialog_id_t dialog_ids_split_[] = { MIXGTK_MIXVM_DIALOG, MIXGTK_MAIN, MIXGTK_MAIN, @@ -54,6 +62,8 @@ static mixgtk_dialog_id_t dialog_ids_[] = { MIXGTK_DEVICES_DIALOG }; +static mixgtk_dialog_id_t *dialog_ids_ = NULL; + static const gchar *keys_[] = { "MIX.font", "Prompt.font", "Log.font", "MIXAL.font", "Device.font" }; @@ -92,9 +102,10 @@ mixgtk_fontsel_load_defaults (gboolean split) { int i; const gchar *font = NULL; + fontsel_dialog_ = NULL; + if (winfo_) g_hash_table_destroy (winfo_); winfo_ = g_hash_table_new (NULL, NULL); - if (!split) - for (i - 0; i < WIDGET_NO_; ++i) dialog_ids_[i] = MIXGTK_MAIN; + dialog_ids_ = split? dialog_ids_split_ : dialog_ids_no_split_; for (i = 0; i < WIDGET_NO_; ++i) { infos_[i].widget = diff --git a/mixgtk/mixgtk_gen_handlers.c b/mixgtk/mixgtk_gen_handlers.c index 983c16c..63314f1 100644 --- a/mixgtk/mixgtk_gen_handlers.c +++ b/mixgtk/mixgtk_gen_handlers.c @@ -123,12 +123,6 @@ on_file_compile_activate (GtkWidget *w, gpointer data) } void -on_main_window_destroy (GtkWidget *w, gpointer data) -{ - gtk_main_quit (); -} - -void on_debug_run_activate (GtkWidget *w, gpointer p) { mixgtk_cmd_dispatcher_dispatch (mix_vm_command_to_string (MIX_CMD_RUN)); diff --git a/mixgtk/mixgtk_input.c b/mixgtk/mixgtk_input.c index 95c697a..6a04a75 100644 --- a/mixgtk/mixgtk_input.c +++ b/mixgtk/mixgtk_input.c @@ -42,6 +42,13 @@ static GtkWidget *childs_[SIZE_]; static input_callback_t callback_; static gpointer data_; +/* init */ +void +mixgtk_input_init (void) +{ + dialog_ = NULL; +} + static void init_dialog_ (void) { diff --git a/mixgtk/mixgtk_input.h b/mixgtk/mixgtk_input.h index 61ea2a5..7332ccd 100644 --- a/mixgtk/mixgtk_input.h +++ b/mixgtk/mixgtk_input.h @@ -30,6 +30,10 @@ /* callback function type */ typedef void (*input_callback_t)(mix_word_t result, gpointer data); +/* init */ +extern void +mixgtk_input_init (void); + /* get a word */ extern void mixgtk_input_word (const gchar *message, mix_word_t def, diff --git a/mixgtk/mixgtk_mixal.c b/mixgtk/mixgtk_mixal.c index 73e9fc0..d79e601 100644 --- a/mixgtk/mixgtk_mixal.c +++ b/mixgtk/mixgtk_mixal.c @@ -32,7 +32,7 @@ #define MIXAL_TAB_POS_ 2 -static mix_vm_t *vm_; +static mix_vm_t *vm_ = NULL; static GtkCList *clist_; static gulong lineno_; static GtkStatusbar *status_; @@ -133,7 +133,6 @@ mixgtk_mixal_init (mix_vm_t *vm, mixgtk_dialog_id_t top) int i,j; g_return_val_if_fail (vm != NULL, FALSE); - vm_ = vm; clist_ = GTK_CLIST (mixgtk_widget_factory_get (top, MIXGTK_WIDGET_MIXAL)); g_return_val_if_fail (clist_ != NULL, FALSE); @@ -142,6 +141,8 @@ mixgtk_mixal_init (mix_vm_t *vm, mixgtk_dialog_id_t top) g_return_val_if_fail (status_ != NULL, FALSE); status_context_ = gtk_statusbar_get_context_id (status_, "MIXAL status"); + symbols_dlg_ = symbols_clist_ = NULL; + /* allocate colors */ colormap_ = gtk_widget_get_colormap (GTK_WIDGET (clist_)); for (i = 0; i < 3; ++i) @@ -160,6 +161,12 @@ mixgtk_mixal_init (mix_vm_t *vm, mixgtk_dialog_id_t top) FALSE); } } + + if (!vm_) + vm_ = vm; + else + mixgtk_mixal_load_file (); + return TRUE; } diff --git a/mixgtk/mixgtk_widgets.c b/mixgtk/mixgtk_widgets.c index 243c6b3..95fd6f0 100644 --- a/mixgtk/mixgtk_widgets.c +++ b/mixgtk/mixgtk_widgets.c @@ -46,6 +46,7 @@ static const gchar * dnames_[] = { }; const gchar *SPLIT_MAIN_NAME_ = "split_main_window"; +const gchar *MAIN_NAME_ = "main_window"; #define DLG_NO_ (sizeof (dnames_) / sizeof(dnames_[0])) @@ -134,20 +135,38 @@ mixgtk_widget_factory_init (gboolean split) const gchar *glade_file = GLADE_FILE; const gchar *local_glade_file = LOCAL_GLADE_FILE; FILE *f; + + about_ = NULL; + + if (!file_) + { + glade_init (); + f = fopen (glade_file, "r"); + if (!f) { + f = fopen (local_glade_file, "r"); + if (!f) return FALSE; + glade_file = local_glade_file; + } + fclose (f); + file_ = g_strdup (glade_file); + } + else + { + gint k; + for (k = 0; k < DLG_NO_; ++k) + { + if (xml_[k]) + { + if (k != MIXGTK_MAIN) + gtk_widget_destroy (mixgtk_widget_factory_get_dialog (k)); + xml_[k] = NULL; + } + } + } - glade_init (); split_ = split; - - f = fopen (glade_file, "r"); - if (!f) { - f = fopen (local_glade_file, "r"); - if (!f) return FALSE; - glade_file = local_glade_file; - } - fclose (f); - file_ = g_strdup (glade_file); - - if (split_) dnames_[MIXGTK_MAIN] = SPLIT_MAIN_NAME_; + + dnames_[MIXGTK_MAIN] = split_? SPLIT_MAIN_NAME_ : MAIN_NAME_; init_xml_ (MIXGTK_MAIN); init_autosave_ (); diff --git a/mixgtk/mixgtk_wm.c b/mixgtk/mixgtk_wm.c index 2666180..0804cc3 100644 --- a/mixgtk/mixgtk_wm.c +++ b/mixgtk/mixgtk_wm.c @@ -121,10 +121,14 @@ on_view_toggled (GtkCheckMenuItem *item) mixgtk_wm_hide_window (k); } +static gboolean restart_ = FALSE; + void on_split_windows_toggled (GtkCheckMenuItem *item) { mixgtk_config_set_split (item->active); + restart_ = TRUE; + gtk_widget_destroy (mixgtk_widget_factory_get_dialog (MIXGTK_MAIN)); } void @@ -137,3 +141,14 @@ on_window_hide (GtkWidget *w) mixgtk_wm_hide_window (k); } +void +on_main_window_destroy (GtkWidget *w, gpointer data) +{ + if (restart_) + { + restart_ = FALSE; + mixgtk_restart (mixgtk_config_is_split ()); + } + else gtk_main_quit (); +} + |