From 2c92c7e85faa068d4037c361df91ebed79e87916 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Thu, 24 Jun 2004 01:40:46 +0000 Subject: almost complete (barring bugs) reimplementation of all gmixvm functionality in non-split mode for gtk 2.0. --- mixgtk/mixgtk.c | 10 +- mixgtk/mixgtk.glade | 1628 +++++++--------------------------------- mixgtk/mixgtk_cmd_dispatcher.c | 20 +- mixgtk/mixgtk_device.c | 279 +++---- mixgtk/mixgtk_device.h | 12 +- mixgtk/mixgtk_fontsel.c | 240 ++---- mixgtk/mixgtk_fontsel.h | 32 +- mixgtk/mixgtk_mixal.c | 16 +- mixgtk/mixgtk_mixvm.c | 22 +- mixgtk/mixgtk_widgets.c | 2 +- mixgtk/mixgtk_widgets.h | 2 +- 11 files changed, 568 insertions(+), 1695 deletions(-) diff --git a/mixgtk/mixgtk.c b/mixgtk/mixgtk.c index 3b926b4..97f6a16 100644 --- a/mixgtk/mixgtk.c +++ b/mixgtk/mixgtk.c @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mixgtk.c : * Main functions of the mix gtk front-end * ------------------------------------------------------------------ - * $Id: mixgtk.c,v 1.16 2004/06/23 10:50:10 jao Exp $ + * $Id: mixgtk.c,v 1.17 2004/06/24 01:40:48 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. * @@ -36,7 +36,7 @@ #include "mixgtk.h" static const gchar *SPLIT_ARG_ = "-s"; -static const gchar *SPLIT_LONG_ARG_ = "--s"; +static const gchar *SPLIT_LONG_ARG_ = "--split"; gboolean mixgtk_restart (void) @@ -49,8 +49,6 @@ mixgtk_restart (void) return FALSE; } - mixgtk_fontsel_load_defaults (); - if (!mixgtk_cmd_dispatcher_init (MIXGTK_MAIN)) { g_error (_("Unable to initialise application (command dispatcher)\n")); @@ -71,9 +69,9 @@ mixgtk_restart (void) return FALSE; } - if (!mixgtk_device_init (GTK_NOTEBOOK + if (!mixgtk_device_init (GTK_CONTAINER (mixgtk_widget_factory_get - (MIXGTK_DEVICES_DIALOG, MIXGTK_WIDGET_DEVICE)), + (MIXGTK_DEVICES_DIALOG, MIXGTK_WIDGET_DEVICES)), vm)) { g_error (_("Unable to initialise application (devices)\n")); diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade index b246fff..a73dfc6 100644 --- a/mixgtk/mixgtk.glade +++ b/mixgtk/mixgtk.glade @@ -49,7 +49,7 @@ - + True gtk-open 1 @@ -72,7 +72,7 @@ - + True gtk-justify-fill 1 @@ -95,7 +95,7 @@ - + True gtk-execute 1 @@ -124,7 +124,7 @@ - + True gtk-quit 1 @@ -199,7 +199,7 @@ - + True gtk-go-forward 1 @@ -222,7 +222,7 @@ - + True gtk-goto-last 1 @@ -245,7 +245,7 @@ - + True gtk-clear 1 @@ -268,7 +268,7 @@ - + True gtk-index 1 @@ -301,7 +301,7 @@ True - + True gtk-select-font 1 @@ -365,12 +365,24 @@ - + True Change format of binary devices output _Device output... True + + + + True + gtk-zoom-100 + 1 + 0.5 + 0.5 + 0 + 0 + + @@ -382,7 +394,7 @@ - + True gtk-home 1 @@ -403,7 +415,7 @@ - + True gtk-preferences 1 @@ -431,7 +443,7 @@ - + True gtk-save 1 @@ -532,7 +544,7 @@ True Edit MIXAL source - + Edit True gtk-justify-fill True @@ -550,7 +562,7 @@ True Run - + Run True gtk-go-forward True @@ -568,7 +580,7 @@ True Next - + Next True gtk-goto-last True @@ -586,7 +598,7 @@ True Clear breakpoints - + Clear True gtk-clear True @@ -604,7 +616,7 @@ True Symbol table - + Symbols True gtk-index True @@ -635,7 +647,7 @@ True Device directory - + Devdir True gtk-home True @@ -653,9 +665,9 @@ True Output format - + Format True - gtk-find-and-replace + gtk-zoom-100 True True False @@ -671,7 +683,7 @@ True External programs - + Programs True gtk-properties True @@ -738,7 +750,7 @@ True GTK_POS_TOP False - False + True @@ -1863,36 +1875,23 @@ - + True True - True - True - GTK_POS_RIGHT - True - False - - - - + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT - + True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 + GTK_SHADOW_IN + + + + - - tab - @@ -3335,7 +3334,7 @@ Free Software Foundation, Inc. Select Font GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE - False + True True False True @@ -3354,7 +3353,6 @@ Free Software Foundation, Inc. True GTK_RELIEF_NORMAL True - @@ -3365,7 +3363,6 @@ Free Software Foundation, Inc. True GTK_RELIEF_NORMAL True - @@ -3376,7 +3373,6 @@ Free Software Foundation, Inc. True GTK_RELIEF_NORMAL True - @@ -3399,6 +3395,8 @@ Free Software Foundation, Inc. GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE True + 320 + 140 True False True @@ -3423,169 +3421,55 @@ Free Software Foundation, Inc. GTK_BUTTONBOX_END - - True - GTK_BUTTONBOX_DEFAULT_STYLE - 30 - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - - - - - - - True - True - True - gtk-apply - True - GTK_RELIEF_NORMAL - True - - - - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - - - - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - - - - 0 - 0 + True - True - True - False - True - False - - - - True - Choose a device - True - True - True - 0 - - True - * - False - - - - - - - True - GTK_SELECTION_BROWSE - - - - True - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - - - - + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 - - 135 - 46 - - - 0 - 0 + True - Show output as MIX words + True True - Word - True + gtk-apply + True GTK_RELIEF_NORMAL True - False - False - True + -10 - - 104 - 96 - - - 0 - 0 + True - Show output as decimal numbers + True True - Dec - True + gtk-ok + True GTK_RELIEF_NORMAL True - False - False - True - wordradio - + -5 - - 176 - 96 - + + + 0 + False + True + GTK_PACK_END + + + + + + True @@ -3601,17 +3485,17 @@ Free Software Foundation, Inc. - 16 - 112 + 233 + 31 - + 0 0 True - Format + Device False False GTK_JUSTIFY_CENTER @@ -3623,17 +3507,17 @@ Free Software Foundation, Inc. 0 - 48 - 80 + 24 + 10 - + 0 0 True - Device + Format False False GTK_JUSTIFY_CENTER @@ -3646,14 +3530,88 @@ Free Software Foundation, Inc. 24 - 8 + 38 + + + + + + 183 + 25 + True + tape0 +tape1 +tape2 +tape3 +tape4 +tape5 +tape6 +tape7 +disk0 +disk1 +disk2 +disk3 +disk4 +disk5 +disk6 +disk7 + + + + 90 + 2 + + + + + + 0 + 0 + True + Show output as MIX words + True + Word + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 89 + 34 + + + + + + 0 + 0 + True + Show output as decimal numbers + True + Decimal + True + GTK_RELIEF_NORMAL + True + False + False + True + wordradio + + + + 154 + 34 0 True - True + False + GTK_PACK_END @@ -4049,7 +4007,7 @@ Free Software Foundation, Inc. Run Run True - run.xpm + gtk-go-forward True True False @@ -4067,7 +4025,7 @@ Free Software Foundation, Inc. Next Step True - next.xpm + gtk-goto-last True True False @@ -4085,7 +4043,7 @@ Free Software Foundation, Inc. Clear breakpoints Clear True - clear.xpm + gtk-clear True True False @@ -4103,7 +4061,7 @@ Free Software Foundation, Inc. Symbol table Symbols True - symbols.xpm + gtk-index True True False @@ -4134,7 +4092,7 @@ Free Software Foundation, Inc. Source code font Font True - font.xpm + gtk-select-font True True False @@ -4145,24 +4103,6 @@ Free Software Foundation, Inc. True - - - - True - Colors - Colors - True - colors.xpm - True - True - False - - - - False - True - - 0 @@ -4254,12 +4194,12 @@ Free Software Foundation, Inc. True Device directory - Device dir + Directory True - devdir.xpm + gtk-home True True - False + True @@ -4274,7 +4214,7 @@ Free Software Foundation, Inc. Output format Output True - output.xpm + gtk-find-and-replace True True False @@ -4292,7 +4232,7 @@ Free Software Foundation, Inc. Output font Font True - font.xpm + gtk-select-font True True False @@ -4312,37 +4252,17 @@ Free Software Foundation, Inc. - + True True - True - True - GTK_POS_TOP - True - False + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT - - - - True - label - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - 0 @@ -4520,1103 +4440,133 @@ Free Software Foundation, Inc. GTK_SHADOW_ETCHED_IN - - True - False - 0 - - - - 1 - True - False - 1 - - - - 2 - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 8 - True - 3 - 6 - False - 6 - 11 - - - - 0 - 0 - True - A - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - 0 - 0 - True - I1 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 2 - 3 - 0 - 1 - fill - - - - - - - 0 - 0 - True - I2 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 2 - 3 - 1 - 2 - fill - - - + + - - - 0 - 0 - True - True - False - True - 0 - - True - * - False - 19 - - - - 1 - 2 - 0 - 1 - - - - + + + True + MIX Virtual Machine + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 2 + 0 + + + label_item + + + + + - - - 0 - 0 - True - True - False - True - 0 - - True - * - False - 9 - - - - 3 - 4 - 1 - 2 - - - - + + True + MIX Console input + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + True + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + + - - - 0 - 0 - True - True - False - True - 0 - + 00 00 - True - * - False - 9 - - - - 3 - 4 - 0 - 1 - - - - + + + True + False + 0 - - - 0 - 0 - True - X - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - + + + True + GTK_BUTTONBOX_END - - - 16 - 16 - True - I3 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 2 - 3 - 2 - 3 - fill - - - + + + True + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + - - - 0 - 0 - True - I4 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 4 - 5 - 0 - 1 - fill - - - + + + 3 + True + True + 0 - - - 16 - 16 - True - I5 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 4 - 5 - 1 - 2 - fill - - - - - - - 16 - 16 - True - I6 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 4 - 5 - 2 - 3 - fill - - - - - - - 0 - 0 - True - J - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - - 0 - 0 - True - True - False - True - 0 - + 00 00 00 00 00 - True - * - False - 19 - - - - 1 - 2 - 1 - 2 - - - - - - - - 0 - 0 - True - True - False - True - 0 - - True - * - False - 9 - - - - 5 - 6 - 0 - 1 - - - - - - - - 0 - 0 - True - True - False - True - 0 - - True - * - False - 9 - - - - 5 - 6 - 1 - 2 - - - - - - - - 0 - 0 - True - True - False - True - 0 - - True - * - False - 9 - - - - 5 - 6 - 2 - 3 - - - - - - - - 0 - 0 - True - True - False - True - 0 - - True - * - False - 9 - - - - 3 - 4 - 2 - 3 - - - - - - - - True - False - 0 - - - - 0 - 0 - True - True - False - True - 0 - - True - * - False - 9 - - - - 0 - False - False - - - - - - - - - 1 - 2 - 2 - 3 - fill - fill - - - - - - - - True - Registers - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 2 - 0 - - - label_item - - - - - 5 - False - True - - - - - - True - False - 0 - - - - 2 - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 1 - True - True - 5 - - - - 0 - 0 - True - Greater - True - G - True - GTK_RELIEF_NORMAL - True - False - False - True - - - - 0 - False - False - - - - - - 0 - 0 - True - Equal - True - E - True - GTK_RELIEF_NORMAL - True - False - False - True - - - - 0 - False - False - - - - - - 0 - 0 - True - Lesser - True - L - True - GTK_RELIEF_NORMAL - True - False - False - True - - - - 0 - False - False - - - - - - - - True - Comparison flag - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 2 - 0 - - - label_item - - - - - 0 - False - False - - - - - - 2 - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 2 - True - True - 2 - - - - 3 - 0 - 0 - True - Click to toggle - True - Off - True - GTK_RELIEF_NORMAL - True - False - False - True - - - - 5 - False - False - - - - - - - - True - Overflow toggle - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 2 - 0 - - - label_item - - - - - 15 - False - False - - - - - - 2 - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 4 - True - False - 1 - - - - 0 - 0 - True - True - False - True - 4 - 0 - True - * - False - 6 - - - 5 - False - False - - - - - - True - View loc address - True - GTK_RELIEF_NORMAL - True - - - - - True - gtk-jump-to - 4 - 0.5 - 0.5 - 0 - 0 - - - - - 1 - False - False - - - - - - - - True - Location - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 2 - 0 - - - label_item - - - - - 0 - False - False - GTK_PACK_END - - - - - 5 - False - True - - - - - - 2 - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 5 - True - False - 5 - - - - 0 - 0 - True - Up: - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - 0 - 0 - True - 00000000 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 5 - 0 - - - 0 - False - False - - - - - - 0 - 0 - True - Lap: - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 3 - False - False - - - - - - 0 - 0 - True - 000000 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 5 - 0 - - - 0 - False - False - - - - - - 0 - 0 - True - Program: - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - - - 2 - False - False - - - - - - 0 - 0 - True - 000000 - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 5 - 0 - - - 0 - False - False - - - - - - - - True - Times - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 2 - 0 - - - label_item - - - - - 5 - False - True - - - - - 2 - False - False - - + + + True + Enter up to 70 characters + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + - - 7 + True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 5 - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - 1 - True - Click cell to change value - True - True - True - False - True - - - - - - - - - - True - Memory - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 2 - 0 - - - label_item - - + True + True + True + 70 + + True + * + True + 70 - 3 - True - True - GTK_PACK_END + 0 + False + False - - - - - True - MIX Virtual Machine - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 2 - 0 - - label_item + 0 + False + False diff --git a/mixgtk/mixgtk_cmd_dispatcher.c b/mixgtk/mixgtk_cmd_dispatcher.c index f237a1a..98782ce 100644 --- a/mixgtk/mixgtk_cmd_dispatcher.c +++ b/mixgtk/mixgtk_cmd_dispatcher.c @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mixgtk_cmd_dispatcher.c : * Implementation of the functions declared in mixgtk_cmd_dispatcher.h * ------------------------------------------------------------------ - * $Id: mixgtk_cmd_dispatcher.c,v 1.16 2004/06/23 10:50:10 jao Exp $ + * $Id: mixgtk_cmd_dispatcher.c,v 1.17 2004/06/24 01:40:47 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. * @@ -43,6 +43,7 @@ #include #include "mixgtk_mixvm.h" #include "mixgtk_mixal.h" +#include "mixgtk_fontsel.h" #include "mixgtk_config.h" #include "mixgtk_cmd_dispatcher.h" @@ -361,6 +362,9 @@ mixgtk_cmd_dispatcher_init (mixgtk_dialog_id_t top) (GTK_WINDOW (mixgtk_widget_factory_get_dialog (MIXGTK_MAIN)), dis_data_.last_file); + mixgtk_fontsel_set_font (MIX_FONT_LOG, dis_data_.log); + mixgtk_fontsel_set_font (MIX_FONT_PROMPT, dis_data_.prompt); + restart = TRUE; return TRUE; } @@ -514,3 +518,17 @@ on_command_prompt_activate (GtkEntry *prompt, gpointer data) } g_free (text); } + +void +on_log_font_activate () +{ + GtkWidget *w[] = { dis_data_.log }; + mixgtk_fontsel_query_font (MIX_FONT_LOG, w, 1); +} + +void +on_prompt_font_activate () +{ + GtkWidget *w[] = { dis_data_.prompt }; + mixgtk_fontsel_query_font (MIX_FONT_PROMPT, w, 1); +} diff --git a/mixgtk/mixgtk_device.c b/mixgtk/mixgtk_device.c index 69faa02..e701728 100644 --- a/mixgtk/mixgtk_device.c +++ b/mixgtk/mixgtk_device.c @@ -1,7 +1,7 @@ /* -*-c-*- ---------------- mixgtk_device.c : * actual types for mixgtk devices * ------------------------------------------------------------------ - * $Id: mixgtk_device.c,v 1.21 2004/06/23 10:50:10 jao Exp $ + * $Id: mixgtk_device.c,v 1.22 2004/06/24 01:40:47 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. * @@ -32,6 +32,7 @@ #include "mixgtk.h" #include "mixgtk_gen_handlers.h" #include "mixgtk_widgets.h" +#include "mixgtk_fontsel.h" #include "mixgtk_config.h" #include "mixgtk_cmd_dispatcher.h" #include "mixgtk_device.h" @@ -41,7 +42,8 @@ static const gchar *DEV_FORMAT_KEY_ = "Device.format"; /* device container */ -static GtkNotebook *container_ = NULL; +static GtkContainer *container_ = NULL; +static GtkNotebook *dev_nb_ = NULL; /* devdir dialog */ static GtkWidget *devdir_dlg_ = NULL; static GtkEntry *devdir_entry_ = NULL; @@ -136,12 +138,15 @@ write_bin_ (struct mixgtk_bin_device_t *dev, const mix_word_t *block) dec = IS_DEC(decs_, dev->gtk_device.device.type); - for (k = 0, len = SIZES_[dev->gtk_device.device.type]; k < len; k += 5) + for (k = 0, len = SIZES_[dev->gtk_device.device.type]; + k < len; k += BIN_DEV_COL_) { gtk_list_store_append (store, &iter); - for (col = 0; col < 5; ++col) + for (col = 0; col < BIN_DEV_COL_; ++col) gtk_list_store_set (store, &iter, - col, get_word_string_ (block[k + col], dec), -1); + col, get_word_string_ (block[k + col], dec), + col + BIN_DEV_COL_, (guint)block[k + col], + -1); dev->last_insert++; } } @@ -157,8 +162,8 @@ write_ (mix_device_t *dev, const mix_word_t *block) if (MODES_[dev->type] == mix_dev_CHAR) write_char_ (gtkdev, block); else write_bin_ ((struct mixgtk_bin_device_t *)gtkdev, block); - gtk_notebook_set_current_page (container_, - gtk_notebook_page_num (container_, + gtk_notebook_set_current_page (dev_nb_, + gtk_notebook_page_num (dev_nb_, gtkdev->scroll)); return TRUE; @@ -179,8 +184,9 @@ read_cons_ (mix_word_t *block) g_assert (input_dlg_entry_); } - gtk_widget_show (input_dlg_); - gtk_main (); /* wait until dialog closes */ + gtk_entry_set_text (input_dlg_entry_, ""); + gtk_dialog_run (GTK_DIALOG (input_dlg_)); + gtk_widget_hide (input_dlg_); text = g_strdup_printf ("%-70s", gtk_entry_get_text (input_dlg_entry_)); for (i = 0; i < 70; ++i) for (j = 0; j < 5; ++j) @@ -204,8 +210,8 @@ read_ (mix_device_t *dev, mix_word_t *block) if (MODES_[dev->type] == mix_dev_CHAR) write_char_ (gtkdev, block); else write_bin_ ((struct mixgtk_bin_device_t *)gtkdev, block); - gtk_notebook_set_current_page (container_, - gtk_notebook_page_num (container_, + gtk_notebook_set_current_page (dev_nb_, + gtk_notebook_page_num (dev_nb_, gtkdev->scroll)); return TRUE; } @@ -232,8 +238,8 @@ destroy_ (mix_device_t *dev) g_object_unref ((gpointer)bdev->store); } (DEF_DEV_VTABLE_->destroy) (dev); - gtk_notebook_remove_page (container_, - gtk_notebook_page_num (container_, + gtk_notebook_remove_page (dev_nb_, + gtk_notebook_page_num (dev_nb_, gtkdev->scroll)); } @@ -263,15 +269,17 @@ mixgtk_device_construct_gui_ (struct mixgtk_device_t *dev) { gint k; struct mixgtk_bin_device_t *bindev = (struct mixgtk_bin_device_t *)dev; - GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); + GType *types = g_new (GType, BIN_DEV_COL_ * 2); + + for (k = 0; k < BIN_DEV_COL_; ++k) + { + types[k] = G_TYPE_STRING; + types[k + BIN_DEV_COL_] = G_TYPE_UINT; + } + + bindev->store = gtk_list_store_newv (BIN_DEV_COL_ * 2, types); - bindev->store = gtk_list_store_new (5, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING); dev->widget = gtk_tree_view_new_with_model (GTK_TREE_MODEL (bindev->store)); @@ -284,18 +292,54 @@ mixgtk_device_construct_gui_ (struct mixgtk_device_t *dev) gtk_tree_view_column_new_with_attributes ("", renderer, "text", k, NULL)); } + + g_free (types); } g_assert (dev->widget); gtk_container_add (GTK_CONTAINER (dev->scroll), dev->widget); - gtk_notebook_append_page (container_, dev->scroll, label); + gtk_notebook_append_page (dev_nb_, dev->scroll, label); gtk_widget_set_style (dev->widget, - gtk_widget_get_style (GTK_WIDGET (container_))); + gtk_widget_get_style (GTK_WIDGET (dev_nb_))); gtk_widget_show (label); gtk_widget_show (dev->scroll); gtk_widget_show (dev->widget); } +static void +redraw_bin_device_ (struct mixgtk_bin_device_t *dev) +{ + if (dev != NULL) + { + GtkTreeModel *store = GTK_TREE_MODEL (dev->store); + GtkTreeIter iter; + gboolean valid; + + g_assert (store); + + valid = + gtk_tree_model_get_iter_first (store, &iter); + + while (valid) + { + gint k; + guint word; + + for (k = 0; k < BIN_DEV_COL_; ++k) + { + gtk_tree_model_get (store, &iter, k + BIN_DEV_COL_, &word, -1); + gtk_list_store_set (GTK_LIST_STORE (store), &iter, + k, get_word_string_ ((mix_word_t)word, + dev->dec), + -1); + } + valid = gtk_tree_model_iter_next (store, &iter); + } + gtk_widget_queue_draw (((struct mixgtk_device_t *)dev)->widget); + } +} + + /* create a new mixgtk device */ static mix_device_t * mixgtk_device_new_ (mix_device_type_t type) @@ -323,42 +367,12 @@ mixgtk_device_new_ (mix_device_type_t type) return (mix_device_t *)dev; } -static mix_device_t * -mixgtk_device_copy_ (const struct mixgtk_device_t *from) -{ - struct mixgtk_device_t *result = - (struct mixgtk_device_t *)mixgtk_device_new_ (from->device.type); - g_return_val_if_fail (result != NULL, NULL); - if (MODES_[from->device.type] == mix_dev_CHAR) - { - gchar *text = gtk_editable_get_chars (GTK_EDITABLE (from->widget), - 0, -1); - gtk_text_buffer_insert_at_cursor - (gtk_text_view_get_buffer (GTK_TEXT_VIEW (result->widget)), text, -1); - g_free (text); - } - else - { - struct mixgtk_bin_device_t *to = (struct mixgtk_bin_device_t *) result; - struct mixgtk_bin_device_t *fr = (struct mixgtk_bin_device_t *) from; - to->last_insert = fr->last_insert; - to->dec = fr->dec; - gtk_tree_view_set_model (GTK_TREE_VIEW (result->widget), - GTK_TREE_MODEL (fr->store)); - to->store = fr->store; - } - return (mix_device_t *)result; -} - /* init default devices */ gboolean -mixgtk_device_init (GtkNotebook *container, mix_vm_t *vm) +mixgtk_device_init (GtkContainer *container, mix_vm_t *vm) { - gint k = 0; - g_return_val_if_fail (container != NULL, FALSE); g_return_val_if_fail (vm != NULL, FALSE); - container_ = container; vm_ = vm; devdlg_ = NULL; devdir_dlg_ = NULL; @@ -368,27 +382,31 @@ mixgtk_device_init (GtkNotebook *container, mix_vm_t *vm) wtoggle_ = NULL; combo_ = NULL; - /* remove dummy page from container */ - gtk_notebook_remove_page (container_, 0); - - mix_vm_set_device_factory (vm, mixgtk_device_new_); + if (dev_nb_ == NULL) + { + mix_vm_set_device_factory (vm, mixgtk_device_new_); - /* read format configuration */ - if (mixgtk_config_get (DEV_FORMAT_KEY_)) - decs_ = atoi (mixgtk_config_get (DEV_FORMAT_KEY_)); + /* read format configuration */ + if (mixgtk_config_get (DEV_FORMAT_KEY_)) + decs_ = atoi (mixgtk_config_get (DEV_FORMAT_KEY_)); - /* re-create existing devices */ - for (k = 0; k < mix_dev_INVALID; ++k) + dev_nb_ = GTK_NOTEBOOK (gtk_notebook_new ()); + gtk_notebook_set_tab_pos (dev_nb_, GTK_POS_RIGHT); + gtk_notebook_set_scrollable (dev_nb_, TRUE); + gtk_container_add (container, GTK_WIDGET (dev_nb_)); + } + else if (container_) { - mix_device_t *dev = mix_vm_get_device (vm, k); - if (dev != NULL) - { - mix_device_t *newdev = - mixgtk_device_copy_ ((struct mixgtk_device_t *)dev); - mix_vm_connect_device (vm, newdev); - } + gtk_widget_reparent (GTK_WIDGET (dev_nb_), GTK_WIDGET (container)); } + container_ = container; + + gtk_widget_show (GTK_WIDGET (dev_nb_)); + gtk_widget_show (GTK_WIDGET (container_)); + + mixgtk_fontsel_set_font (MIX_FONT_DEVICES, GTK_WIDGET (dev_nb_)); + return TRUE; } @@ -403,34 +421,32 @@ mixgtk_device_set_format (mix_device_type_t dev, gboolean dec) if (changed && (MODES_[dev] == mix_dev_BIN)) { - if (dec) SET_DEC (decs_, dev); - else CLEAR_DEC (decs_, dev); -/* redraw_bin_device_ ((struct mixgtk_bin_device_t *) */ -/* mix_vm_get_device (vm_, dev)); */ + struct mixgtk_bin_device_t *gdev = + (struct mixgtk_bin_device_t *) mix_vm_get_device (vm_, dev); + + if (gdev != NULL) + { + if (dec) SET_DEC (decs_, dev); else CLEAR_DEC (decs_, dev); + gdev->dec = !(gdev->dec); + redraw_bin_device_ (gdev); + } } - } static mix_device_type_t get_device_idx_ (void) { -/* const gchar *name = gtk_entry_get_text */ -/* (GTK_ENTRY (GTK_COMBO (combo_)->entry)); */ -/* /\* inefficient, but the list is short *\/ */ -/* int k; */ -/* for (k = 0; k <= LAST_BIN_DEV_; ++k) */ -/* if (!strcmp (name, DEF_NAMES_[k])) return k; */ -/* g_assert_not_reached (); */ - return 0; + int k; + const gchar *name = gtk_entry_get_text (GTK_ENTRY (GTK_BIN (combo_)->child)); + for (k = 0; k <= LAST_BIN_DEV_; ++k) + if (!strcmp (name, DEF_NAMES_[k])) break; + return k; } static void init_devform_ (void) { - GList *names = NULL; - int k; - devdlg_ = mixgtk_widget_factory_get_dialog (MIXGTK_DEVFORM_DIALOG); g_assert (devdlg_); dtoggle_ = mixgtk_widget_factory_get_child_by_name @@ -442,29 +458,47 @@ init_devform_ (void) combo_ = mixgtk_widget_factory_get_child_by_name (MIXGTK_DEVFORM_DIALOG, "dev_combo"); g_assert (combo_); - - for (k = 0; k <= LAST_BIN_DEV_; ++k) - names = g_list_append (names, (gchar *)DEF_NAMES_[k]); -/* gtk_combo_set_popdown_strings (GTK_COMBO (combo_), names); */ + gtk_editable_set_editable (GTK_EDITABLE (GTK_BIN (combo_)->child), FALSE); } void -on_deventry_changed () +on_dev_combo_changed () { mix_device_type_t dev = get_device_idx_ (); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dtoggle_), - IS_DEC (new_decs_, dev)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wtoggle_), - !IS_DEC (new_decs_, dev)); + if (dev <= LAST_BIN_DEV_) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dtoggle_), + IS_DEC (new_decs_, dev)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wtoggle_), + !IS_DEC (new_decs_, dev)); + } } void on_devform_activate () { + gint result = GTK_RESPONSE_APPLY; + if (!devdlg_) init_devform_ (); new_decs_ = decs_; - gtk_widget_show (devdlg_); - on_deventry_changed (); + + while (result == GTK_RESPONSE_APPLY) + { + //on_dev_combo_changed (); + result = gtk_dialog_run (GTK_DIALOG (devdlg_)); + if (result != GTK_RESPONSE_CANCEL) + { + int k; + gchar value[20]; + for (k = 0; k <= LAST_BIN_DEV_; ++k) + mixgtk_device_set_format (k, IS_DEC (new_decs_, k)); + decs_ = new_decs_; + g_snprintf (value, 20, "%d", decs_); + mixgtk_config_update (DEV_FORMAT_KEY_, value); + } + } + + gtk_widget_hide (devdlg_); } void @@ -476,31 +510,6 @@ on_decradio_toggled (GtkToggleButton *button) CLEAR_DEC (new_decs_, get_device_idx_ ()); } -void -on_devapp_button_clicked () -{ - int k; - gchar value[20]; - for (k = 0; k <= LAST_BIN_DEV_; ++k) - mixgtk_device_set_format (k, IS_DEC (new_decs_, k)); - decs_ = new_decs_; - g_snprintf (value, 20, "%d", decs_); - mixgtk_config_update (DEV_FORMAT_KEY_, value); -} - -void -on_devok_button_clicked () -{ - on_devapp_button_clicked (); - gtk_widget_hide (devdlg_); -} - -void -on_devcancel_button_clicked () -{ - gtk_widget_hide (devdlg_); -} - void on_devset_button_clicked () { @@ -572,20 +581,22 @@ on_devdir_ok_clicked () } void -on_input_ok_clicked () +on_devices_font_activate () { - gtk_widget_hide (input_dlg_); - gtk_main_quit (); -} + gint no = gtk_notebook_get_n_pages (dev_nb_); + GtkWidget **w = g_new (GtkWidget *, 2 * no + 1); + gint k; -void -on_input_clear_clicked () -{ - gtk_entry_set_text (input_dlg_entry_, ""); -} + w[2 * no] = GTK_WIDGET (dev_nb_); + for (k = 0; k < no; ++k) + { + w[k] = gtk_notebook_get_nth_page (dev_nb_, k); + w[k + no] = gtk_bin_get_child (GTK_BIN (w[k])); + g_assert (w[k]); + g_assert (w[k + no]); + } -void -on_input_entry_activate () -{ - on_input_ok_clicked (); + mixgtk_fontsel_query_font (MIX_FONT_DEVICES, w, 2 * no + 1); + + g_free (w); } diff --git a/mixgtk/mixgtk_device.h b/mixgtk/mixgtk_device.h index cdfec66..dde8a5c 100644 --- a/mixgtk/mixgtk_device.h +++ b/mixgtk/mixgtk_device.h @@ -3,22 +3,22 @@ * ------------------------------------------------------------------ * Last change: Time-stamp: <01/03/04 23:43:59 jose> * ------------------------------------------------------------------ - * Copyright (C) 2001 Free Software Foundation, Inc. - * + * Copyright (C) 2001, 2004 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. - * + * */ @@ -31,7 +31,7 @@ /* init default devices */ extern gboolean -mixgtk_device_init (GtkNotebook *container, mix_vm_t *vm); +mixgtk_device_init (GtkContainer *container, mix_vm_t *vm); /* change the output format of a device */ extern void diff --git a/mixgtk/mixgtk_fontsel.c b/mixgtk/mixgtk_fontsel.c index 50bcceb..59849b1 100644 --- a/mixgtk/mixgtk_fontsel.c +++ b/mixgtk/mixgtk_fontsel.c @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mixgtk_fontsel.c : * Implementation of the functions declared in mixgtk_fontsel.h * ------------------------------------------------------------------ - * $Id: mixgtk_fontsel.c,v 1.15 2004/06/23 10:50:10 jao Exp $ + * $Id: mixgtk_fontsel.c,v 1.16 2004/06/24 01:40:47 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2004 Free Software Foundation, Inc. * @@ -26,223 +26,81 @@ #include "mixgtk_config.h" #include "mixgtk_fontsel.h" -static GtkWidget *fontsel_dialog_ = NULL; -static mixgtk_widget_id_t widget_; -static GHashTable *winfo_ = NULL; +static GtkFontSelectionDialog *fontsel_dialog_ = NULL; -typedef struct winfo -{ - GtkWidget *widget; - const gchar *font; - const gchar *key; -} winfo; - -static mixgtk_widget_id_t widget_ids_[] = { - MIXGTK_WIDGET_MIXVM, - MIXGTK_WIDGET_PROMPT, - MIXGTK_WIDGET_LOG, - MIXGTK_WIDGET_MIXAL, - MIXGTK_WIDGET_DEVICE -}; - -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, - MIXGTK_MIXAL_DIALOG, - MIXGTK_DEVICES_DIALOG -}; - -static mixgtk_widget_id_t mixvm_children_[] = { - 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_L, - MIXGTK_WIDGET_CMP_E, - MIXGTK_WIDGET_CMP_G, - MIXGTK_WIDGET_OVER, - MIXGTK_WIDGET_CELLS, - MIXGTK_WIDGET_LAPTIME, - MIXGTK_WIDGET_PROGTIME, - MIXGTK_WIDGET_UPTIME, - MIXGTK_WIDGET_LOC +static const gchar *keys_[MIX_FONT_NO] = { + "MIX.font", "Prompt.font", "Log.font", "MIXAL.font", "Devices.font" }; -static const int CHILDREN_NO_ = -(sizeof (mixvm_children_) / sizeof (mixvm_children_[0])); - -static mixgtk_dialog_id_t *dialog_ids_ = NULL; - -static const gchar *keys_[] = { - "MIX.font", "Prompt.font", "Log.font", "MIXAL.font", "Device.font" -}; - - - -#define WIDGET_NO_ (sizeof (widget_ids_) / sizeof (widget_ids_[0])) - -static winfo infos_[WIDGET_NO_]; /* initialise the font selection dialog */ static void init_fontsel_ (void) { - fontsel_dialog_ = mixgtk_widget_factory_get_dialog (MIXGTK_FONTSEL_DIALOG); + fontsel_dialog_ = + GTK_FONT_SELECTION_DIALOG + (mixgtk_widget_factory_get_dialog (MIXGTK_FONTSEL_DIALOG)); g_assert (fontsel_dialog_ != NULL); } void -change_font_ (mixgtk_widget_id_t widget) +mixgtk_fontsel_set_font (mixgtk_font_t f, GtkWidget *w) { - winfo *info; - if (!fontsel_dialog_) init_fontsel_ (); - info = (winfo *) g_hash_table_lookup (winfo_, GINT_TO_POINTER (widget)); - g_assert (info); - widget_ = widget; - if (info->font) - gtk_font_selection_dialog_set_font_name - (GTK_FONT_SELECTION_DIALOG (fontsel_dialog_), info->font); - - gtk_widget_show (fontsel_dialog_); - -} - -void -mixgtk_fontsel_load_defaults (void) -{ - - int i; const gchar *font; - gboolean split = mixgtk_config_is_split (); + PangoFontDescription *font_desc; - fontsel_dialog_ = NULL; + if (f >= MIX_FONT_NO || w == NULL) return; - if (winfo_) g_hash_table_destroy (winfo_); - winfo_ = g_hash_table_new (NULL, NULL); - dialog_ids_ = split? dialog_ids_split_ : dialog_ids_no_split_; - for (i = 0; i < WIDGET_NO_; ++i) + font = mixgtk_config_get (keys_[f]); + if (!font) { - infos_[i].widget = - mixgtk_widget_factory_get (dialog_ids_[i], widget_ids_[i]); - g_assert (infos_[i].widget != NULL); - infos_[i].key = keys_[i]; - g_hash_table_insert (winfo_, GINT_TO_POINTER (widget_ids_[i]), - (gpointer)(infos_ + i)); - - infos_[i].font = NULL; - font = mixgtk_config_get (keys_[i]); - mixgtk_fontsel_set (widget_ids_[i], font? font : "Monospace"); + mixgtk_config_update (keys_[f], "Monospace"); + font = mixgtk_config_get (keys_[f]); + g_assert (font); } -} -void -mixgtk_fontsel_set (mixgtk_widget_id_t widget, const gchar *font) -{ - winfo *w = (winfo *) - g_hash_table_lookup (winfo_, GINT_TO_POINTER (widget)); - if (w != NULL && font != NULL) + font_desc = pango_font_description_from_string (font); + + if (font_desc) { - PangoFontDescription *font_desc = - pango_font_description_from_string (font); - if (font_desc != NULL) - { - gtk_widget_modify_font (w->widget, font_desc); - - if (widget == MIXGTK_WIDGET_MIXVM) - { - int k; - for (k = 0; k < CHILDREN_NO_; ++k) - { - GtkWidget *child = - mixgtk_widget_factory_get (MIXGTK_MIXVM_DIALOG, - mixvm_children_[k]); - gtk_widget_modify_font (child, font_desc); - } - } - w->font = font; - mixgtk_config_update (w->key, w->font); - pango_font_description_free (font_desc); - } - else - mixgtk_config_remove (w->key); + gtk_widget_modify_font (w, font_desc); + gtk_widget_queue_draw (w); + pango_font_description_free (font_desc); } -} + else + mixgtk_config_remove (keys_[f]); -const gchar * -mixgtk_fontsel_get (mixgtk_widget_id_t widget) -{ - const gchar *result = NULL; - winfo *w = (winfo *) - g_hash_table_lookup (winfo_, GINT_TO_POINTER (widget)); - if (w != NULL) result = w->font; - return result; } -/* callbacks */ -void -on_log_font_activate (void) +extern gboolean +mixgtk_fontsel_query_font (mixgtk_font_t f, GtkWidget **w, size_t no) { - change_font_ (MIXGTK_WIDGET_LOG); -} - -void -on_mixal_font_activate (void) -{ - change_font_ (MIXGTK_WIDGET_MIXAL); -} + gint result = GTK_RESPONSE_APPLY; + const gchar *current; + gboolean ret = FALSE; -void -on_prompt_font_activate (void) -{ - change_font_ (MIXGTK_WIDGET_PROMPT); -} - -void -on_mix_font_activate (void) -{ - change_font_ (MIXGTK_WIDGET_MIXVM); -} - -void -on_devices_font_activate (void) -{ - change_font_ (MIXGTK_WIDGET_DEVICE); -} - -void -on_fontsel_apply_clicked (void) -{ - gchar * name = gtk_font_selection_dialog_get_font_name - (GTK_FONT_SELECTION_DIALOG (fontsel_dialog_)); - mixgtk_fontsel_set (widget_, name); - g_free (name); -} + if (f >= MIX_FONT_NO) return FALSE; + if (!fontsel_dialog_) init_fontsel_ (); -void -on_fontsel_ok_clicked (void) -{ - on_fontsel_apply_clicked (); - gtk_widget_hide (fontsel_dialog_); -} + current = mixgtk_config_get (keys_[f]); + gtk_font_selection_dialog_set_font_name (fontsel_dialog_, + current? current : "Monospace"); -void -on_fontsel_cancel_clicked (void) -{ - gtk_widget_hide (fontsel_dialog_); + while (result == GTK_RESPONSE_APPLY) + { + result = gtk_dialog_run (GTK_DIALOG (fontsel_dialog_)); + if (result != GTK_RESPONSE_CANCEL) + { + gint k; + mixgtk_config_update + (keys_[f], + gtk_font_selection_dialog_get_font_name (fontsel_dialog_)); + for (k = 0; k < no; ++k) + mixgtk_fontsel_set_font (f, w[k]); + ret = TRUE; + } + } + gtk_widget_hide (GTK_WIDGET (fontsel_dialog_)); + return ret; } - diff --git a/mixgtk/mixgtk_fontsel.h b/mixgtk/mixgtk_fontsel.h index af09c15..0b288d4 100644 --- a/mixgtk/mixgtk_fontsel.h +++ b/mixgtk/mixgtk_fontsel.h @@ -1,24 +1,24 @@ /* -*-c-*- ---------------- mixgtk_fontsel.h : * Functions for handling font selection. * ------------------------------------------------------------------ - * Last change: Time-stamp: <2001-04-28 00:42:39 jao> + * $Id: mixgtk_fontsel.h,v 1.5 2004/06/24 01:40:47 jao Exp $ * ------------------------------------------------------------------ - * Copyright (C) 2001 Free Software Foundation, Inc. - * + * Copyright (C) 2001, 2004 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. - * + * */ @@ -28,17 +28,21 @@ #include #include "mixgtk_widgets.h" -/* load default (configured) fonts */ -extern void -mixgtk_fontsel_load_defaults (void); +typedef enum { + MIX_FONT_MIXVM, + MIX_FONT_LOG, + MIX_FONT_PROMPT, + MIX_FONT_MIXAL, + MIX_FONT_DEVICES, + MIX_FONT_NO +} mixgtk_font_t; -/* set a widget's font */ +/* configured fonts */ extern void -mixgtk_fontsel_set (mixgtk_widget_id_t widget, const gchar *font); +mixgtk_fontsel_set_font (mixgtk_font_t f, GtkWidget *w); -/* get a widget's font */ -extern const gchar * -mixgtk_fontsel_get (mixgtk_widget_id_t widget); +extern gboolean +mixgtk_fontsel_query_font (mixgtk_font_t f, GtkWidget **ws, size_t no); #endif /* MIXGTK_FONTSEL_H */ diff --git a/mixgtk/mixgtk_mixal.c b/mixgtk/mixgtk_mixal.c index b805c30..17f726f 100644 --- a/mixgtk/mixgtk_mixal.c +++ b/mixgtk/mixgtk_mixal.c @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mixgtk_mixal.c : * Implementation of the functions declared in mixgtk_mixal.h * ------------------------------------------------------------------ - * $Id: mixgtk_mixal.c,v 1.17 2004/06/23 10:50:10 jao Exp $ + * $Id: mixgtk_mixal.c,v 1.18 2004/06/24 01:40:47 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. * @@ -27,6 +27,7 @@ #include "mixgtk_widgets.h" #include "mixgtk_config.h" +#include "mixgtk_fontsel.h" #include "mixgtk_mixal.h" @@ -236,9 +237,12 @@ mixgtk_mixal_init (mix_vm_t *vm, mixgtk_dialog_id_t top) g_signal_connect (G_OBJECT (clist_), "event", G_CALLBACK (mixal_event_), NULL); + mixgtk_fontsel_set_font (MIX_FONT_MIXAL, GTK_WIDGET (clist_)); + if (restart) mixgtk_mixal_load_file (); else restart = TRUE; + return TRUE; } @@ -555,3 +559,13 @@ on_mixal_leave_notify_event () { gtk_statusbar_pop (status_, status_context_); } + +void +on_mixal_font_activate () +{ + GtkWidget *w[] = { GTK_WIDGET (clist_) }; + mixgtk_fontsel_query_font (MIX_FONT_MIXAL, w, 1); +} + + + diff --git a/mixgtk/mixgtk_mixvm.c b/mixgtk/mixgtk_mixvm.c index 57fbb90..ca4b482 100644 --- a/mixgtk/mixgtk_mixvm.c +++ b/mixgtk/mixgtk_mixvm.c @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mixgtk_mixvm.c : * Implementation of the functions declared in mixgtk_mixvm.h * ------------------------------------------------------------------ - * $Id: mixgtk_mixvm.c,v 1.11 2004/06/23 10:50:10 jao Exp $ + * $Id: mixgtk_mixvm.c,v 1.12 2004/06/24 01:40:47 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. * @@ -24,6 +24,7 @@ #include #include #include "mixgtk_widgets.h" +#include "mixgtk_fontsel.h" #include "mixgtk_mixvm.h" #include "mixgtk_cmd_dispatcher.h" #include "mixgtk_input.h" @@ -79,10 +80,12 @@ mixgtk_mixvm_init (mix_vm_t *vm, mixgtk_dialog_id_t top) reg_entries_[k] = GTK_ENTRY (mixgtk_widget_factory_get (top, MIXGTK_WIDGET_rA + k)); g_return_val_if_fail (reg_entries_[k] != NULL, FALSE); + mixgtk_fontsel_set_font (MIX_FONT_MIXVM, GTK_WIDGET (reg_entries_[k])); } loc_entry_ = GTK_ENTRY (mixgtk_widget_factory_get (top, MIXGTK_WIDGET_LOC)); g_return_val_if_fail (loc_entry_ != NULL, FALSE); + mixgtk_fontsel_set_font (MIX_FONT_MIXVM, GTK_WIDGET (loc_entry_)); uptime_ = GTK_LABEL (mixgtk_widget_factory_get (top, MIXGTK_WIDGET_UPTIME)); g_return_val_if_fail (uptime_ != NULL, FALSE); @@ -332,6 +335,21 @@ on_goto_ok_clicked (GtkWidget *w, gpointer data) } } +void +on_mix_font_activate (void) +{ + GtkWidget *w[REGISTER_NO_ + 2] = { + GTK_WIDGET (loc_entry_), GTK_WIDGET (memory_) + }; + + gint k; + + for (k = 0; k < REGISTER_NO_; ++k) w[k + 2] = GTK_WIDGET (reg_entries_[k]); + + mixgtk_fontsel_query_font (MIX_FONT_MIXVM, w, REGISTER_NO_ + 2); + +} + /* static functions */ @@ -485,6 +503,8 @@ init_mem_ (mixgtk_dialog_id_t top) g_signal_connect (G_OBJECT (memory_), "event-after", G_CALLBACK (cont_clicked_), NULL); + mixgtk_fontsel_set_font (MIX_FONT_MIXVM, GTK_WIDGET (memory_)); + return TRUE; } diff --git a/mixgtk/mixgtk_widgets.c b/mixgtk/mixgtk_widgets.c index 8a5e91f..6ffff1e 100644 --- a/mixgtk/mixgtk_widgets.c +++ b/mixgtk/mixgtk_widgets.c @@ -77,7 +77,7 @@ static const gchar *names_[] = { "program_label", "uptime_label", "memory_scroll", - "devices_notebook", + "devices_container", "loc_entry", NULL }; diff --git a/mixgtk/mixgtk_widgets.h b/mixgtk/mixgtk_widgets.h index 6d84fc5..5be3fb6 100644 --- a/mixgtk/mixgtk_widgets.h +++ b/mixgtk/mixgtk_widgets.h @@ -72,7 +72,7 @@ typedef enum { MIXGTK_WIDGET_PROGTIME, MIXGTK_WIDGET_UPTIME, MIXGTK_WIDGET_CELLS_SCROLL, - MIXGTK_WIDGET_DEVICE, + MIXGTK_WIDGET_DEVICES, MIXGTK_WIDGET_LOC, MIXGTK_WIDGET_NONE } mixgtk_widget_id_t; -- cgit v1.2.3