source: trunk/third/gtkhtml/src/htmlsettings.c @ 16767

Revision 16767, 2.9 KB checked in by ghudson, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r16766, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/* This file is part of the KDE libraries
3    Copyright (C) 1999 Anders Carlsson (andersca@gnu.org)
4              (C) 1997 Martin Jones (mjones@kde.org)
5              (C) 1997 Torben Weis (weis@kde.org)
6
7    This library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Library General Public
9    License as published by the Free Software Foundation; either
10    version 2 of the License, or (at your option) any later version.
11
12    This library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Library General Public License for more details.
16
17    You should have received a copy of the GNU Library General Public License
18    along with this library; see the file COPYING.LIB.  If not, write to
19    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20    Boston, MA 02111-1307, USA.
21*/
22
23#include <config.h>
24#include <string.h>
25#include <gdk/gdk.h>
26#include "htmlsettings.h"
27
28
29static const int defaultFontSizes[HTML_NUM_FONT_SIZES] = { 8, 10, 12, 14, 18, 24, 32 };
30
31
32
33HTMLSettings *
34html_settings_new (GtkWidget *w)
35{
36        HTMLSettings *s = g_new0 (HTMLSettings, 1);
37       
38        s->fontBaseSize = 3;
39        s->fontBaseFace = g_strdup ("times");
40        s->fixedFontFace = g_strdup ("courier");
41        s->underlineLinks = TRUE;
42        s->forceDefault = FALSE;
43
44        html_settings_reset_font_sizes (s);
45
46        s->color_set = html_colorset_new (w);
47
48        return s;
49}
50
51void
52html_settings_destroy (HTMLSettings *settings)
53{
54        g_return_if_fail (settings != NULL);
55
56        g_free (settings->fontBaseFace);
57        g_free (settings->fixedFontFace);
58
59        html_colorset_destroy (settings->color_set);
60
61        g_free (settings);
62}
63
64void
65html_settings_set_font_sizes (HTMLSettings *settings,
66                              const gint *newFontSizes)
67{
68        guint i;
69
70        for (i = 0; i < HTML_NUM_FONT_SIZES; i++)
71                settings->fontSizes[i] = newFontSizes[i];
72}
73
74void
75html_settings_get_font_sizes (HTMLSettings *settings,
76                              gint *fontSizes)
77{
78        guint i;
79
80        for (i = 0; i < HTML_NUM_FONT_SIZES; i++)
81                fontSizes[i] = settings->fontSizes[i];
82}
83
84void
85html_settings_reset_font_sizes (HTMLSettings *settings)
86{
87        html_settings_set_font_sizes (settings, defaultFontSizes);
88}
89
90void
91html_settings_copy (HTMLSettings *dest,
92                    HTMLSettings *src)
93{
94        g_free (dest->fontBaseFace);
95        g_free (dest->fixedFontFace);
96
97        memcpy (dest, src, sizeof (*dest));
98
99        dest->fontBaseFace = g_strdup (src->fontBaseFace);
100        dest->fixedFontFace = g_strdup (src->fixedFontFace);
101}
102
103void
104html_settings_set_font_base_face (HTMLSettings *settings,
105                                  const gchar *face)
106{
107        g_free (settings->fontBaseFace);
108        settings->fontBaseFace = g_strdup (face);
109}
110
111void
112html_settings_set_fixed_font_face (HTMLSettings *settings,
113                                   const gchar *face)
114{
115        g_free (settings->fixedFontFace);
116        settings->fixedFontFace = g_strdup (face);
117}
Note: See TracBrowser for help on using the repository browser.