diff options
| author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2001-04-27 22:54:00 +0000 | 
|---|---|---|
| committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2001-04-27 22:54:00 +0000 | 
| commit | 75008f7cd9831b65de6e452860a6908b2019d9d1 (patch) | |
| tree | a1a95da76f551bf4f4783eac3173cff0b94c0f55 /mixgtk | |
| parent | 0c1b65942150d82cd5964fc8216aa5cf831ad1fe (diff) | |
| download | mdk-75008f7cd9831b65de6e452860a6908b2019d9d1.tar.gz mdk-75008f7cd9831b65de6e452860a6908b2019d9d1.tar.bz2 | |
font customization added
Diffstat (limited to 'mixgtk')
| -rw-r--r-- | mixgtk/.cvsignore | 1 | ||||
| -rw-r--r-- | mixgtk/Makefile.am | 3 | ||||
| -rw-r--r-- | mixgtk/mixgtk.c | 13 | ||||
| -rw-r--r-- | mixgtk/mixgtk.glade | 154 | ||||
| -rw-r--r-- | mixgtk/mixgtk_fontsel.c | 181 | ||||
| -rw-r--r-- | mixgtk/mixgtk_fontsel.h | 45 | ||||
| -rw-r--r-- | mixgtk/mixgtk_widgets.c | 10 | ||||
| -rw-r--r-- | mixgtk/mixgtk_widgets.h | 12 | 
8 files changed, 390 insertions, 29 deletions
| diff --git a/mixgtk/.cvsignore b/mixgtk/.cvsignore index 12ed8c2..dd99c76 100644 --- a/mixgtk/.cvsignore +++ b/mixgtk/.cvsignore @@ -2,6 +2,7 @@  Makefile  Makefile.in  gmixvm +gmixvm.core  hello.mix  mixgtk  paper.dev diff --git a/mixgtk/Makefile.am b/mixgtk/Makefile.am index adf036e..c0a3788 100644 --- a/mixgtk/Makefile.am +++ b/mixgtk/Makefile.am @@ -26,7 +26,8 @@ gmixvm_SOURCES = mixgtk.c mixgtk_gen_handlers.h mixgtk_gen_handlers.c \                   mixgtk_mixvm.h mixgtk_mixvm.c \                   mixgtk_mixal.h mixgtk_mixal.c \                   mixgtk_input.h mixgtk_input.c \ -		 mixgtk_colorsel.h mixgtk_colorsel.c +		 mixgtk_colorsel.h mixgtk_colorsel.c \ +		 mixgtk_fontsel.h mixgtk_fontsel.c  endif diff --git a/mixgtk/mixgtk.c b/mixgtk/mixgtk.c index 2e2b44c..127780b 100644 --- a/mixgtk/mixgtk.c +++ b/mixgtk/mixgtk.c @@ -1,7 +1,7 @@  /* -*-c-*- -------------- mixgtk.c :   * Main function of the mix gtk front-end   * ------------------------------------------------------------------ - *  Last change: Time-stamp: "2001-04-22 01:00:42 jao" + *  Last change: Time-stamp: "2001-04-24 00:52:32 jao"   * ------------------------------------------------------------------   * Copyright (C) 2001 Free Software Foundation, Inc.   *   @@ -31,13 +31,14 @@  #include "mixgtk_mixal.h"  #include "mixgtk_input.h"  #include "mixgtk_colorsel.h" +#include "mixgtk_fontsel.h"  int  main(int argc, char *argv[])  {    mix_vm_t *vm; -  gtk_init(&argc, &argv); +  gtk_init (&argc, &argv);    mix_init_lib (); @@ -71,7 +72,7 @@ main(int argc, char *argv[])        return EXIT_FAILURE;      } -  if (!mixgtk_mixal_init (vm) || !mixgtk_colorsel_init ()) +  if (!mixgtk_mixal_init (vm))      {        g_error ("Unable to initialise application (mixal widgets)\n");        return EXIT_FAILURE; @@ -82,6 +83,12 @@ main(int argc, char *argv[])        g_error ("Unable to initialise application (word input widgets)\n");        return EXIT_FAILURE;      } + +  if (!mixgtk_fontsel_init () || !mixgtk_colorsel_init ()) +    { +      g_error ("Unable to initialise application (customization widgets)\n"); +      return EXIT_FAILURE; +    }    gtk_main(); diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade index 665c8ec..eb3af1e 100644 --- a/mixgtk/mixgtk.glade +++ b/mixgtk/mixgtk.glade @@ -187,13 +187,61 @@  	  <widget>  	    <class>GtkMenuItem</class>  	    <name>fonts1</name> -	    <signal> -	      <name>activate</name> -	      <handler>on_fonts1_activate</handler> -	      <last_modification_time>Wed, 11 Apr 2001 23:15:11 GMT</last_modification_time> -	    </signal> -	    <label>_Fonts...</label> +	    <label>Change _font</label>  	    <right_justify>False</right_justify> + +	    <widget> +	      <class>GtkMenu</class> +	      <name>fonts1_menu</name> + +	      <widget> +		<class>GtkMenuItem</class> +		<name>mix</name> +		<signal> +		  <name>activate</name> +		  <handler>on_mix_font_activate</handler> +		  <last_modification_time>Wed, 25 Apr 2001 01:55:53 GMT</last_modification_time> +		</signal> +		<label>MIX</label> +		<right_justify>False</right_justify> +	      </widget> + +	      <widget> +		<class>GtkMenuItem</class> +		<name>mixal</name> +		<signal> +		  <name>activate</name> +		  <handler>on_mixal_font_activate</handler> +		  <last_modification_time>Wed, 25 Apr 2001 01:55:53 GMT</last_modification_time> +		</signal> +		<label>MIXAL</label> +		<right_justify>False</right_justify> +	      </widget> + +	      <widget> +		<class>GtkMenuItem</class> +		<name>command_prompt</name> +		<signal> +		  <name>activate</name> +		  <handler>on_prompt_font_activate</handler> +		  <last_modification_time>Wed, 25 Apr 2001 01:55:53 GMT</last_modification_time> +		</signal> +		<label>Command prompt</label> +		<right_justify>False</right_justify> +	      </widget> + +	      <widget> +		<class>GtkMenuItem</class> +		<name>command_log</name> +		<signal> +		  <name>activate</name> +		  <handler>on_log_font_activate</handler> +		  <last_modification_time>Wed, 25 Apr 2001 01:55:53 GMT</last_modification_time> +		</signal> +		<label>Command log</label> +		<right_justify>False</right_justify> +	      </widget> +	    </widget>  	  </widget>  	</widget>        </widget> @@ -580,15 +628,6 @@  	  </widget>  	  <widget> -	    <class>GtkHSeparator</class> -	    <name>hseparator3</name> -	    <x>6</x> -	    <y>1</y> -	    <width>627</width> -	    <height>16</height> -	  </widget> - -	  <widget>  	    <class>GtkVSeparator</class>  	    <name>vseparator3</name>  	    <x>626</x> @@ -943,6 +982,15 @@  	      </widget>  	    </widget>  	  </widget> + +	  <widget> +	    <class>GtkHSeparator</class> +	    <name>hseparator3</name> +	    <x>6</x> +	    <y>1</y> +	    <width>627</width> +	    <height>16</height> +	  </widget>  	</widget>  	<widget> @@ -1979,7 +2027,7 @@  	<class>GtkDrawingArea</class>  	<name>bpbg_area</name>  	<x>90</x> -	<y>93</y> +	<y>94</y>  	<width>75</width>  	<height>15</height>        </widget> @@ -2082,4 +2130,78 @@    </widget>  </widget> +<widget> +  <class>GtkFontSelectionDialog</class> +  <name>fontsel_dialog</name> +  <border_width>4</border_width> +  <visible>False</visible> +  <signal> +    <name>delete_event</name> +    <handler>gtk_widget_hide</handler> +    <last_modification_time>Thu, 26 Apr 2001 21:14:34 GMT</last_modification_time> +  </signal> +  <signal> +    <name>destroy_event</name> +    <handler>gtk_widget_hide</handler> +    <last_modification_time>Thu, 26 Apr 2001 21:15:02 GMT</last_modification_time> +  </signal> +  <signal> +    <name>destroy</name> +    <handler>gtk_widget_hide</handler> +    <last_modification_time>Thu, 26 Apr 2001 21:15:13 GMT</last_modification_time> +  </signal> +  <title>Select Font</title> +  <type>GTK_WINDOW_DIALOG</type> +  <position>GTK_WIN_POS_NONE</position> +  <modal>False</modal> +  <allow_shrink>False</allow_shrink> +  <allow_grow>True</allow_grow> +  <auto_shrink>True</auto_shrink> + +  <widget> +    <class>GtkButton</class> +    <child_name>FontSel:ok_button</child_name> +    <name>ok_button1</name> +    <can_default>True</can_default> +    <can_focus>True</can_focus> +    <signal> +      <name>clicked</name> +      <handler>on_fontsel_ok_clicked</handler> +      <last_modification_time>Thu, 26 Apr 2001 21:40:53 GMT</last_modification_time> +    </signal> +    <label>OK</label> +    <relief>GTK_RELIEF_NORMAL</relief> +  </widget> + +  <widget> +    <class>GtkButton</class> +    <child_name>FontSel:apply_button</child_name> +    <name>apply_button1</name> +    <can_default>True</can_default> +    <can_focus>True</can_focus> +    <signal> +      <name>clicked</name> +      <handler>on_fontsel_apply_clicked</handler> +      <last_modification_time>Thu, 26 Apr 2001 21:41:12 GMT</last_modification_time> +    </signal> +    <label>Apply</label> +    <relief>GTK_RELIEF_NORMAL</relief> +  </widget> + +  <widget> +    <class>GtkButton</class> +    <child_name>FontSel:cancel_button</child_name> +    <name>cancel_button1</name> +    <can_default>True</can_default> +    <can_focus>True</can_focus> +    <signal> +      <name>clicked</name> +      <handler>on_fontsel_cancel_clicked</handler> +      <last_modification_time>Thu, 26 Apr 2001 21:41:33 GMT</last_modification_time> +    </signal> +    <label>Cancel</label> +    <relief>GTK_RELIEF_NORMAL</relief> +  </widget> +</widget> +  </GTK-Interface> diff --git a/mixgtk/mixgtk_fontsel.c b/mixgtk/mixgtk_fontsel.c new file mode 100644 index 0000000..139fe9d --- /dev/null +++ b/mixgtk/mixgtk_fontsel.c @@ -0,0 +1,181 @@ +/* -*-c-*- -------------- mixgtk_fontsel.c : + * Implementation of the functions declared in mixgtk_fontsel.h + * ------------------------------------------------------------------ + *  Last change: Time-stamp: "2001-04-28 00:42:21 jao" + * ------------------------------------------------------------------ + * Copyright (C) 2001 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. + *   + */ + +#include <mixlib/mix.h> +#include "mixgtk_widgets.h" +#include "mixgtk_fontsel.h" + +static GtkWidget *fontsel_dialog_ = NULL; +static mixgtk_widget_id_t widget_; +static GHashTable *winfo_ = NULL; + +typedef struct winfo +{ +  GtkWidget *widget; +  GtkStyle *style; +  gchar *font; +} winfo; + +static mixgtk_widget_id_t widget_ids_[] = { +  MIXGTK_WIDGET_MIXVM, +  MIXGTK_WIDGET_PROMPT, +  MIXGTK_WIDGET_LOG, +  MIXGTK_WIDGET_MIXAL, +  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 +}; + +#define WIDGET_NO_  (sizeof (widget_ids_) / sizeof (widget_ids_[0])) + +static winfo infos_[WIDGET_NO_]; + +void +change_font_ (mixgtk_widget_id_t widget) +{ +  widget_ = widget; +  gtk_widget_show (fontsel_dialog_); +} + + +/* initialise the font selection dialog */ +gboolean +mixgtk_fontsel_init (void)  +{ +  int i; +  fontsel_dialog_ = mixgtk_widget_factory_get (MIXGTK_WIDGET_FONTSEL_DIALOG); +  g_return_val_if_fail (fontsel_dialog_ != NULL, FALSE); +  winfo_ = g_hash_table_new (NULL, NULL); +  for (i = 0; i < WIDGET_NO_; ++i) +    { +      infos_[i].widget = mixgtk_widget_factory_get (widget_ids_[i]); +      g_return_val_if_fail (infos_[i].widget != NULL, FALSE); +      infos_[i].style = gtk_style_copy +	(gtk_widget_get_style (infos_[i].widget)); +      gtk_widget_set_style (infos_[i].widget, infos_[i].style); +      infos_[i].font = NULL; +      g_hash_table_insert (winfo_, GINT_TO_POINTER (widget_ids_[i]), +			   (gpointer)(infos_ + i)); +    } +  return TRUE; +} + +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) +    { +      GdkFont *f = gdk_font_load (font); +      if (f != NULL) +	{ +	  gdk_font_unref (w->style->font); +	  w->style->font = f; +	  if (w->font != NULL) g_free (w->font); +	  w->font = g_strdup (font); +	  //      gtk_widget_set_style (w, style); +	  gtk_widget_draw (w->widget, FALSE); +	} +    } + +  if (widget == MIXGTK_WIDGET_MIXVM) +    { +      int k; +      for (k = MIXGTK_WIDGET_rA; k <= MIXGTK_WIDGET_UPTIME; ++k) +	mixgtk_fontsel_set (k, font); +    } +} + +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) +{ +  change_font_ (MIXGTK_WIDGET_LOG); +} + +void +on_mixal_font_activate (void) +{ +  change_font_ (MIXGTK_WIDGET_MIXAL); +} + +void +on_prompt_font_activate (void) +{ +  change_font_ (MIXGTK_WIDGET_PROMPT); +} + +void +on_mix_font_activate (void)  +{ +  change_font_ (MIXGTK_WIDGET_MIXVM); +} + + +void +on_fontsel_apply_clicked (void) +{ +  const gchar * name = gtk_font_selection_dialog_get_font_name +    (GTK_FONT_SELECTION_DIALOG (fontsel_dialog_)); +  mixgtk_fontsel_set (widget_, name); +} + +void +on_fontsel_ok_clicked (void) +{ +  on_fontsel_apply_clicked (); +  gtk_widget_hide (fontsel_dialog_); +} + +void +on_fontsel_cancel_clicked (void) +{ +  gtk_widget_hide (fontsel_dialog_); +} + + diff --git a/mixgtk/mixgtk_fontsel.h b/mixgtk/mixgtk_fontsel.h new file mode 100644 index 0000000..5b9b1f6 --- /dev/null +++ b/mixgtk/mixgtk_fontsel.h @@ -0,0 +1,45 @@ +/* -*-c-*- ---------------- mixgtk_fontsel.h : + * Functions for handling font selection. + * ------------------------------------------------------------------ + *  Last change: Time-stamp: <2001-04-28 00:42:39 jao> + * ------------------------------------------------------------------ + * Copyright (C) 2001 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. + *   + */ + + +#ifndef MIXGTK_FONTSEL_H +#define MIXGTK_FONTSEL_H + +#include <glib.h> +#include "mixgtk_widgets.h" + +/* initialise the font selection dialog */ +extern gboolean +mixgtk_fontsel_init (void); + +/* set a widget's font */ +extern void +mixgtk_fontsel_set (mixgtk_widget_id_t widget, const gchar *font); + +/* get a widget's font */ +extern const gchar * +mixgtk_fontsel_get (mixgtk_widget_id_t widget); + + +#endif /* MIXGTK_FONTSEL_H */ + diff --git a/mixgtk/mixgtk_widgets.c b/mixgtk/mixgtk_widgets.c index c27b707..a26d886 100644 --- a/mixgtk/mixgtk_widgets.c +++ b/mixgtk/mixgtk_widgets.c @@ -1,7 +1,7 @@  /* -*-c-*- -------------- mixgtk_widgets.c :   * Implementation of the functions declared in mixgtk_widgets.h   * ------------------------------------------------------------------ - *  Last change: Time-stamp: "2001-04-22 00:01:30 jao" + *  Last change: Time-stamp: "2001-04-27 23:32:32 jao"   * ------------------------------------------------------------------   * Copyright (C) 2001 Free Software Foundation, Inc.   *   @@ -38,6 +38,8 @@ static const gchar *names_[] = {    "about_dialog",    "goto_dialog",    "color_dialog", +  "fontsel_dialog", +  "mixvm_widget",    "command_prompt",    "command_log",    "mixal_clist", @@ -55,12 +57,12 @@ static const gchar *names_[] = {    "greater_radio",    "over_toggle",    "memory_cells", -  "memory_scroll", -  "devices_notebook", -  "loc_entry",    "elapsed_label",    "program_label",    "uptime_label", +  "memory_scroll", +  "devices_notebook", +  "loc_entry",    NULL  }; diff --git a/mixgtk/mixgtk_widgets.h b/mixgtk/mixgtk_widgets.h index 00147fc..461e1bf 100644 --- a/mixgtk/mixgtk_widgets.h +++ b/mixgtk/mixgtk_widgets.h @@ -1,7 +1,7 @@  /* -*-c-*- ---------------- mixgtk_widgets.h :   * glade-based factory of mixvm widgets   * ------------------------------------------------------------------ - *  Last change: Time-stamp: <2001-04-22 00:01:13 jao> + *  Last change: Time-stamp: <2001-04-27 23:32:16 jao>   * ------------------------------------------------------------------   * Copyright (C) 2001 Free Software Foundation, Inc.   *   @@ -35,7 +35,9 @@ typedef enum {    MIXGTK_WIDGET_WORD_DIALOG,	/* input dialog for a mix word */    MIXGTK_WIDGET_ABOUT_DIALOG,    MIXGTK_WIDGET_GOTO_DIALOG, -  MIXGTK_WIDGET_COLORSEL_DIALOG, /* color selection dialog */ +  MIXGTK_WIDGET_COLORSEL_DIALOG, /* color customization dialog */ +  MIXGTK_WIDGET_FONTSEL_DIALOG,	/* font selection dialog */ +  MIXGTK_WIDGET_MIXVM,		/* virtual machine */    MIXGTK_WIDGET_PROMPT,		/* command prompt */    MIXGTK_WIDGET_LOG,		/* command output */    MIXGTK_WIDGET_MIXAL,		/* mixal source file */ @@ -53,12 +55,12 @@ typedef enum {    MIXGTK_WIDGET_CMP_G,    MIXGTK_WIDGET_OVER,    MIXGTK_WIDGET_CELLS, -  MIXGTK_WIDGET_CELLS_SCROLL, -  MIXGTK_WIDGET_DEVICE, -  MIXGTK_WIDGET_LOC,    MIXGTK_WIDGET_LAPTIME,    MIXGTK_WIDGET_PROGTIME,    MIXGTK_WIDGET_UPTIME, +  MIXGTK_WIDGET_CELLS_SCROLL, +  MIXGTK_WIDGET_DEVICE, +  MIXGTK_WIDGET_LOC,    MIXGTK_WIDGET_NONE  } mixgtk_widget_id_t; | 
