From 8440205d3e76356739f0f610ea2519a9d2dc4ec5 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 4 Jul 2004 22:34:15 +0000 Subject: new menu item to change all fonts at once. --- mixgtk/mixgtk.glade | 47 ++++++++++++++++++++++++++++-------------- mixgtk/mixgtk_cmd_dispatcher.c | 9 +++++++- mixgtk/mixgtk_cmd_dispatcher.h | 15 ++++++++------ mixgtk/mixgtk_device.c | 32 ++++++++++++++++++++++++---- mixgtk/mixgtk_device.h | 3 +++ mixgtk/mixgtk_fontsel.c | 42 ++++++++++++++++++++++++++++++++++--- mixgtk/mixgtk_fontsel.h | 3 ++- mixgtk/mixgtk_mixal.c | 19 +++++++++-------- mixgtk/mixgtk_mixal.h | 5 ++++- mixgtk/mixgtk_mixvm.c | 43 ++++++++++++++++++++++++++++---------- mixgtk/mixgtk_mixvm.h | 5 ++++- 11 files changed, 171 insertions(+), 52 deletions(-) (limited to 'mixgtk') diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade index aaac693..0f8b6bc 100644 --- a/mixgtk/mixgtk.glade +++ b/mixgtk/mixgtk.glade @@ -12,6 +12,7 @@ 550 True False + gmixvm-main True False False @@ -48,7 +49,7 @@ - + True gtk-open 1 @@ -71,7 +72,7 @@ - + True gtk-justify-fill 1 @@ -94,7 +95,7 @@ - + True gtk-execute 1 @@ -123,7 +124,7 @@ - + True gtk-quit 1 @@ -159,7 +160,7 @@ - + True gtk-go-forward 1 @@ -182,7 +183,7 @@ - + True gtk-goto-last 1 @@ -205,7 +206,7 @@ - + True gtk-clear 1 @@ -228,7 +229,7 @@ - + True gtk-index 1 @@ -270,7 +271,7 @@ True - + True gtk-dnd-multiple 1 @@ -335,7 +336,7 @@ True - + True gtk-select-font 1 @@ -393,6 +394,22 @@ + + + + True + + + + + + True + Change all fonts at once + _All + True + + + @@ -407,7 +424,7 @@ - + True gtk-zoom-100 1 @@ -428,7 +445,7 @@ - + True gtk-home 1 @@ -449,7 +466,7 @@ - + True gtk-preferences 1 @@ -477,7 +494,7 @@ - + True gtk-save 1 @@ -522,7 +539,7 @@ - + True gtk-help 1 diff --git a/mixgtk/mixgtk_cmd_dispatcher.c b/mixgtk/mixgtk_cmd_dispatcher.c index a87913b..1ea7df7 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.18 2004/07/02 00:06:26 jao Exp $ + * $Id: mixgtk_cmd_dispatcher.c,v 1.19 2004/07/04 22:34:15 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. * @@ -539,3 +539,10 @@ on_prompt_font_activate () GtkWidget *w[] = { dis_data_.prompt }; mixgtk_fontsel_query_font (MIX_FONT_PROMPT, w, 1); } + +void +mixgtk_cmd_dispatcher_update_fonts (void) +{ + mixgtk_fontsel_set_font (MIX_FONT_LOG, dis_data_.log); + mixgtk_fontsel_set_font (MIX_FONT_PROMPT, dis_data_.prompt); +} diff --git a/mixgtk/mixgtk_cmd_dispatcher.h b/mixgtk/mixgtk_cmd_dispatcher.h index 6ea840c..d72160f 100644 --- a/mixgtk/mixgtk_cmd_dispatcher.h +++ b/mixgtk/mixgtk_cmd_dispatcher.h @@ -1,24 +1,24 @@ /* -*-c-*- ---------------- mixgtk_cmd_dispatcher.h : * functions to access the command dispatcher * ------------------------------------------------------------------ - * Last change: Time-stamp: <01/03/09 22:08:08 jose> + * $Id: mixgtk_cmd_dispatcher.h,v 1.5 2004/07/04 22:34:15 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. - * + * */ @@ -33,6 +33,9 @@ extern gboolean mixgtk_cmd_dispatcher_init (mixgtk_dialog_id_t top); +extern void +mixgtk_cmd_dispatcher_update_fonts (void); + /* dispatch an externally provided command */ extern void mixgtk_cmd_dispatcher_dispatch (const gchar *command); diff --git a/mixgtk/mixgtk_device.c b/mixgtk/mixgtk_device.c index 1b3a78a..30e5bf3 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.24 2004/07/02 00:08:28 jao Exp $ + * $Id: mixgtk_device.c,v 1.25 2004/07/04 22:34:15 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. * @@ -578,8 +578,11 @@ on_devdir_ok_clicked () g_free (cmd); } -void -on_devices_font_activate () + + +/* fonts */ +static GtkWidget ** +font_widgets_ (gint * n) { gint no = gtk_notebook_get_n_pages (dev_nb_); GtkWidget **w = g_new (GtkWidget *, no + 1); @@ -595,7 +598,28 @@ on_devices_font_activate () g_assert (k == no); w[k] = GTK_WIDGET (dev_nb_); - mixgtk_fontsel_query_font (MIX_FONT_DEVICES, w, no + 1); + if (n) *n = no; + return w; +} + +void +on_devices_font_activate () +{ + gint no = 0; + GtkWidget **w = font_widgets_ (&no); + mixgtk_fontsel_query_font (MIX_FONT_DEVICES, w, no + 1); g_free (w); } + +void +mixgtk_device_update_fonts (void) +{ + gint k, n = 0; + GtkWidget **w = font_widgets_ (&n); + + g_assert (n >= 0); + + for (k = 0; k < n; ++k) + mixgtk_fontsel_set_font (MIX_FONT_DEVICES, w[k]); +} diff --git a/mixgtk/mixgtk_device.h b/mixgtk/mixgtk_device.h index b15cbb4..a4f095f 100644 --- a/mixgtk/mixgtk_device.h +++ b/mixgtk/mixgtk_device.h @@ -33,6 +33,9 @@ extern GtkWidget * mixgtk_device_init (mix_vm_t *vm); +extern void +mixgtk_device_update_fonts (void); + /* change the output format of a device */ extern void mixgtk_device_set_format (mix_device_type_t dev, gboolean dec); diff --git a/mixgtk/mixgtk_fontsel.c b/mixgtk/mixgtk_fontsel.c index 59849b1..37cc9c8 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.16 2004/06/24 01:40:47 jao Exp $ + * $Id: mixgtk_fontsel.c,v 1.17 2004/07/04 22:34:15 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2004 Free Software Foundation, Inc. * @@ -24,12 +24,17 @@ #include #include "mixgtk_widgets.h" #include "mixgtk_config.h" +#include "mixgtk_mixvm.h" +#include "mixgtk_mixal.h" +#include "mixgtk_cmd_dispatcher.h" +#include "mixgtk_device.h" #include "mixgtk_fontsel.h" static GtkFontSelectionDialog *fontsel_dialog_ = NULL; static const gchar *keys_[MIX_FONT_NO] = { - "MIX.font", "Prompt.font", "Log.font", "MIXAL.font", "Devices.font" + "MIX.font", "Prompt.font", "Log.font", "MIXAL.font", "Devices.font", + "Default.font" }; @@ -72,7 +77,7 @@ mixgtk_fontsel_set_font (mixgtk_font_t f, GtkWidget *w) } -extern gboolean +gboolean mixgtk_fontsel_query_font (mixgtk_font_t f, GtkWidget **w, size_t no) { gint result = GTK_RESPONSE_APPLY; @@ -104,3 +109,34 @@ mixgtk_fontsel_query_font (mixgtk_font_t f, GtkWidget **w, size_t no) return ret; } +void +on_all_fonts_activate (void) +{ + gint result = GTK_RESPONSE_APPLY; + const gchar *current; + + if (!fontsel_dialog_) init_fontsel_ (); + + current = mixgtk_config_get (keys_[MIX_FONT_DEFAULT]); + gtk_font_selection_dialog_set_font_name (fontsel_dialog_, + current? current : "Monospace"); + + while (result == GTK_RESPONSE_APPLY) + { + result = gtk_dialog_run (GTK_DIALOG (fontsel_dialog_)); + if (result != GTK_RESPONSE_CANCEL) + { + gint k; + current = gtk_font_selection_dialog_get_font_name (fontsel_dialog_); + + for (k = 0; k < MIX_FONT_NO; ++k) + mixgtk_config_update (keys_[k], current); + + mixgtk_mixal_update_fonts (); + mixgtk_mixvm_update_fonts (); + mixgtk_device_update_fonts (); + mixgtk_cmd_dispatcher_update_fonts (); + } + } + gtk_widget_hide (GTK_WIDGET (fontsel_dialog_)); +} diff --git a/mixgtk/mixgtk_fontsel.h b/mixgtk/mixgtk_fontsel.h index 0b288d4..df2a040 100644 --- a/mixgtk/mixgtk_fontsel.h +++ b/mixgtk/mixgtk_fontsel.h @@ -1,7 +1,7 @@ /* -*-c-*- ---------------- mixgtk_fontsel.h : * Functions for handling font selection. * ------------------------------------------------------------------ - * $Id: mixgtk_fontsel.h,v 1.5 2004/06/24 01:40:47 jao Exp $ + * $Id: mixgtk_fontsel.h,v 1.6 2004/07/04 22:34:15 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2004 Free Software Foundation, Inc. * @@ -34,6 +34,7 @@ typedef enum { MIX_FONT_PROMPT, MIX_FONT_MIXAL, MIX_FONT_DEVICES, + MIX_FONT_DEFAULT, MIX_FONT_NO } mixgtk_font_t; diff --git a/mixgtk/mixgtk_mixal.c b/mixgtk/mixgtk_mixal.c index 1ee9475..3b2d42d 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.19 2004/06/30 14:07:53 jao Exp $ + * $Id: mixgtk_mixal.c,v 1.20 2004/07/04 22:34:15 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. * @@ -83,6 +83,8 @@ init_symbols_ (void) (MIXGTK_SYMBOLS_DIALOG, SYMBOLS_VIEW_NAME_)); g_assert (symbols_view_); + mixgtk_fontsel_set_font (MIX_FONT_DEFAULT, GTK_WIDGET (symbols_view_)); + symbols_store_ = gtk_list_store_new (SYMBOLS_COL_NO, G_TYPE_STRING, G_TYPE_STRING, @@ -240,6 +242,13 @@ mixgtk_mixal_reparent (GtkStatusbar *status) status_context_ = gtk_statusbar_get_context_id (status_, "MIXAL status"); } +void +mixgtk_mixal_update_fonts (void) +{ + mixgtk_fontsel_set_font (MIX_FONT_MIXAL, GTK_WIDGET (clist_)); + mixgtk_fontsel_set_font (MIX_FONT_DEFAULT, GTK_WIDGET (symbols_view_)); +} + void mixgtk_mixal_pop_status (void) { @@ -547,14 +556,6 @@ on_symbols_activate () gtk_widget_show (symbols_dlg_); } -void -on_notebook_switch_page (GtkNotebook *notebook) -{ -/* gint p = gtk_notebook_get_current_page (notebook); */ -/* if (p != MIXAL_TAB_POS_) gtk_statusbar_pop (status_, status_context_); */ -/* if (p == MIXAL_TAB_POS_) mixgtk_mixal_update (); */ -} - void on_mixal_leave_notify_event () { diff --git a/mixgtk/mixgtk_mixal.h b/mixgtk/mixgtk_mixal.h index 248cf64..5fb7cbb 100644 --- a/mixgtk/mixgtk_mixal.h +++ b/mixgtk/mixgtk_mixal.h @@ -1,7 +1,7 @@ /* -*-c-*- ---------------- mixgtk_mixal.h : * Declarations for functions displaying the mixal source file * ------------------------------------------------------------------ - * $Id: mixgtk_mixal.h,v 1.6 2004/06/30 14:07:53 jao Exp $ + * $Id: mixgtk_mixal.h,v 1.7 2004/07/04 22:34:15 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2004 Free Software Foundation, Inc. * @@ -45,6 +45,9 @@ mixgtk_mixal_load_file (void); extern void mixgtk_mixal_update (void); +extern void +mixgtk_mixal_update_fonts (void); + extern void mixgtk_mixal_pop_status (void); diff --git a/mixgtk/mixgtk_mixvm.c b/mixgtk/mixgtk_mixvm.c index cea52bb..10a34e1 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.14 2004/07/02 00:09:55 jao Exp $ + * $Id: mixgtk_mixvm.c,v 1.15 2004/07/04 22:34:15 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. * @@ -122,6 +122,34 @@ mixgtk_mixvm_init (mix_vm_t *vm) return TRUE; } +static GtkWidget ** +text_widgets_ (gint *n) +{ + static GtkWidget *w[REGISTER_NO_ + 2] = { NULL}; + + if (w[0] == NULL) + { + gint k; + w[0] = GTK_WIDGET (loc_entry_); + w[1] = GTK_WIDGET (memory_); + for (k = 0; k < REGISTER_NO_; ++k) + w[k + 2] = GTK_WIDGET (reg_entries_[k]); + }; + + if (n) *n = REGISTER_NO_ + 2; + + return w; +} + +void +mixgtk_mixvm_update_fonts (void) +{ + gint k, n = 0; + GtkWidget **w = text_widgets_ (&n); + for (k = 0; k < n; ++k) + mixgtk_fontsel_set_font (MIX_FONT_MIXVM, w[k]); +} + /* update register widgets */ void mixgtk_mixvm_update_registers (void) @@ -329,16 +357,9 @@ mem_cell_ (mix_word_t w, gpointer a) 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); - + gint n; + GtkWidget **w = text_widgets_ (&n); + mixgtk_fontsel_query_font (MIX_FONT_MIXVM, w, n); } diff --git a/mixgtk/mixgtk_mixvm.h b/mixgtk/mixgtk_mixvm.h index 2288715..6e80f70 100644 --- a/mixgtk/mixgtk_mixvm.h +++ b/mixgtk/mixgtk_mixvm.h @@ -1,7 +1,7 @@ /* -*-c-*- ---------------- mixgtk_mixvm.h : * Functions dealing with the mixvm widgets * ------------------------------------------------------------------ - * $Id: mixgtk_mixvm.h,v 1.4 2004/06/30 14:07:53 jao Exp $ + * $Id: mixgtk_mixvm.h,v 1.5 2004/07/04 22:34:15 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001, 2004 Free Software Foundation, Inc. * @@ -33,6 +33,9 @@ extern gboolean mixgtk_mixvm_init (mix_vm_t *vm); +extern void +mixgtk_mixvm_update_fonts (void); + /* update register widgets */ extern void mixgtk_mixvm_update_registers (void); -- cgit v1.2.3