From 3cddb9545a4f634b46565717ef0a59a6f4a166ce Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Wed, 23 Jun 2004 10:50:10 +0000 Subject: First, incomplete port to gtk 2.0. Basic functionality in place. --- mixgtk/mixgtk_fontsel.c | 64 ++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 38 deletions(-) (limited to 'mixgtk/mixgtk_fontsel.c') diff --git a/mixgtk/mixgtk_fontsel.c b/mixgtk/mixgtk_fontsel.c index 7986f4d..50bcceb 100644 --- a/mixgtk/mixgtk_fontsel.c +++ b/mixgtk/mixgtk_fontsel.c @@ -1,24 +1,24 @@ /* -*-c-*- -------------- mixgtk_fontsel.c : * Implementation of the functions declared in mixgtk_fontsel.h * ------------------------------------------------------------------ - * $Id: mixgtk_fontsel.c,v 1.14 2001/09/18 22:51:29 jao Exp $ + * $Id: mixgtk_fontsel.c,v 1.15 2004/06/23 10:50:10 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. - * + * */ #include @@ -33,8 +33,7 @@ static GHashTable *winfo_ = NULL; typedef struct winfo { GtkWidget *widget; - GtkStyle *style; - gchar *font; + const gchar *font; const gchar *key; } winfo; @@ -100,7 +99,7 @@ static winfo infos_[WIDGET_NO_]; /* initialise the font selection dialog */ static void -init_fontsel_ (void) +init_fontsel_ (void) { fontsel_dialog_ = mixgtk_widget_factory_get_dialog (MIXGTK_FONTSEL_DIALOG); g_assert (fontsel_dialog_ != NULL); @@ -117,7 +116,7 @@ change_font_ (mixgtk_widget_id_t widget) if (info->font) gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (fontsel_dialog_), info->font); - + gtk_widget_show (fontsel_dialog_); } @@ -125,8 +124,9 @@ change_font_ (mixgtk_widget_id_t widget) void mixgtk_fontsel_load_defaults (void) { + int i; - const gchar *font = NULL; + const gchar *font; gboolean split = mixgtk_config_is_split (); fontsel_dialog_ = NULL; @@ -139,25 +139,13 @@ mixgtk_fontsel_load_defaults (void) infos_[i].widget = mixgtk_widget_factory_get (dialog_ids_[i], widget_ids_[i]); g_assert (infos_[i].widget != NULL); - if (infos_[i].style) gtk_style_unref (infos_[i].style); - infos_[i].style = gtk_style_copy - (gtk_widget_get_style (infos_[i].widget)); - gtk_widget_set_style (infos_[i].widget, infos_[i].style); - if (widget_ids_[i] == MIXGTK_WIDGET_MIXVM) - { - int k; - for (k = 0; k < CHILDREN_NO_; ++k) - gtk_widget_set_style (mixgtk_widget_factory_get - (MIXGTK_MIXVM_DIALOG, mixvm_children_[k]), - infos_[i].style); - } 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]); - if (font) mixgtk_fontsel_set (widget_ids_[i], font); + mixgtk_fontsel_set (widget_ids_[i], font? font : "Monospace"); } } @@ -168,30 +156,30 @@ mixgtk_fontsel_set (mixgtk_widget_id_t widget, const gchar *font) g_hash_table_lookup (winfo_, GINT_TO_POINTER (widget)); if (w != NULL && font != NULL) { - GdkFont *f = gdk_font_load (font); - if (f != NULL) + PangoFontDescription *font_desc = + pango_font_description_from_string (font); + if (font_desc != NULL) { - gdk_font_unref (w->style->font); - w->style->font = f; - if (w->font) g_free (w->font); - w->font = g_strdup (font); - gtk_widget_draw (w->widget, NULL); + gtk_widget_modify_font (w->widget, font_desc); if (widget == MIXGTK_WIDGET_MIXVM) { int k; for (k = 0; k < CHILDREN_NO_; ++k) - gtk_widget_draw - (mixgtk_widget_factory_get (MIXGTK_MIXVM_DIALOG, - mixvm_children_[k]), - NULL); + { + 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); } - } const gchar * @@ -224,13 +212,13 @@ on_prompt_font_activate (void) } void -on_mix_font_activate (void) +on_mix_font_activate (void) { change_font_ (MIXGTK_WIDGET_MIXVM); } void -on_devices_font_activate (void) +on_devices_font_activate (void) { change_font_ (MIXGTK_WIDGET_DEVICE); } -- cgit v1.2.3