2
* Copyright (C) 2007 The GNOME Foundation
3
* Written by Jonathan Blandford <jrb@gnome.org>
4
* Jens Granseuer <jensgr@gmx.net>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program 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
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License along
18
* with this program; if not, write to the Free Software Foundation, Inc.,
19
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
#include "appearance.h"
30
#include <X11/Xft/Xft.h>
31
#endif /* HAVE_XFT2 */
32
#include <glib/gi18n.h>
34
#include "capplet-util.h"
35
#include "gconf-property-editor.h"
37
#define GTK_FONT_KEY "/desktop/gnome/interface/font_name"
38
#define DESKTOP_FONT_KEY "/apps/nautilus/preferences/desktop_font"
40
#define METACITY_DIR "/apps/metacity/general"
41
#define WINDOW_TITLE_FONT_KEY METACITY_DIR "/titlebar_font"
42
#define WINDOW_TITLE_USES_SYSTEM_KEY METACITY_DIR "/titlebar_uses_system_font"
43
#define MONOSPACE_FONT_KEY "/desktop/gnome/interface/monospace_font_name"
44
#define DOCUMENT_FONT_KEY "/desktop/gnome/interface/document_font_name"
47
#define FONT_RENDER_DIR "/desktop/gnome/font_rendering"
48
#define FONT_ANTIALIASING_KEY FONT_RENDER_DIR "/antialiasing"
49
#define FONT_HINTING_KEY FONT_RENDER_DIR "/hinting"
50
#define FONT_RGBA_ORDER_KEY FONT_RENDER_DIR "/rgba_order"
51
#define FONT_DPI_KEY FONT_RENDER_DIR "/dpi"
53
/* X servers sometimes lie about the screen's physical dimensions, so we cannot
54
* compute an accurate DPI value. When this happens, the user gets fonts that
55
* are too huge or too tiny. So, we see what the server returns: if it reports
56
* something outside of the range [DPI_LOW_REASONABLE_VALUE,
57
* DPI_HIGH_REASONABLE_VALUE], then we assume that it is lying and we use
58
* DPI_FALLBACK instead.
60
* See get_dpi_from_gconf_or_server() below, and also
61
* https://bugzilla.novell.com/show_bug.cgi?id=217790
63
#define DPI_FALLBACK 96
64
#define DPI_LOW_REASONABLE_VALUE 50
65
#define DPI_HIGH_REASONABLE_VALUE 500
66
#endif /* HAVE_XFT2 */
68
static gboolean in_change = FALSE;
69
static gchar *old_font = NULL;
71
#define MAX_FONT_POINT_WITHOUT_WARNING 32
72
#define MAX_FONT_SIZE_WITHOUT_WARNING MAX_FONT_POINT_WITHOUT_WARNING*1024
77
* Code for displaying previews of font rendering with various Xft options
81
sample_size_request (GtkWidget *darea,
82
GtkRequisition *requisition)
84
GdkPixbuf *pixbuf = g_object_get_data (G_OBJECT (darea), "sample-pixbuf");
86
requisition->width = gdk_pixbuf_get_width (pixbuf) + 2;
87
requisition->height = gdk_pixbuf_get_height (pixbuf) + 2;
91
sample_expose (GtkWidget *darea,
92
GdkEventExpose *expose)
94
GtkAllocation allocation;
95
GdkPixbuf *pixbuf = g_object_get_data (G_OBJECT (darea), "sample-pixbuf");
96
GdkWindow *window = gtk_widget_get_window (darea);
97
GtkStyle *style = gtk_widget_get_style (darea);
98
int width = gdk_pixbuf_get_width (pixbuf);
99
int height = gdk_pixbuf_get_height (pixbuf);
103
gtk_widget_get_allocation (darea, &allocation);
104
x = (allocation.width - width) / 2;
105
y = (allocation.height - height) / 2;
106
gdk_draw_rectangle (window, style->white_gc, TRUE,
108
allocation.width, allocation.height);
109
gdk_draw_rectangle (window, style->black_gc, FALSE,
111
allocation.width - 1, allocation.height - 1);
113
gdk_draw_pixbuf (window, NULL, pixbuf, 0, 0, x, y, width, height,
114
GDK_RGB_DITHER_NORMAL, 0, 0);
123
static GConfEnumStringPair antialias_enums[] = {
124
{ ANTIALIAS_NONE, "none" },
125
{ ANTIALIAS_GRAYSCALE, "grayscale" },
126
{ ANTIALIAS_RGBA, "rgba" },
137
static GConfEnumStringPair hint_enums[] = {
138
{ HINT_NONE, "none" },
139
{ HINT_SLIGHT, "slight" },
140
{ HINT_MEDIUM, "medium" },
141
{ HINT_FULL, "full" },
152
static GConfEnumStringPair rgba_order_enums[] = {
155
{ RGBA_VRGB, "vrgb" },
156
{ RGBA_VBGR, "vbgr" },
161
open_pattern (FcPattern *pattern,
162
Antialiasing antialiasing,
166
static const int hintstyles[] = {
167
FC_HINT_NONE, FC_HINT_SLIGHT, FC_HINT_MEDIUM, FC_HINT_FULL
169
#endif /* FC_HINT_STYLE */
171
FcPattern *res_pattern;
175
Display *xdisplay = gdk_x11_get_default_xdisplay ();
176
int screen = gdk_x11_get_default_screen ();
178
res_pattern = XftFontMatch (xdisplay, screen, pattern, &result);
179
if (res_pattern == NULL)
182
FcPatternDel (res_pattern, FC_HINTING);
183
FcPatternAddBool (res_pattern, FC_HINTING, hinting != HINT_NONE);
186
FcPatternDel (res_pattern, FC_HINT_STYLE);
187
FcPatternAddInteger (res_pattern, FC_HINT_STYLE, hintstyles[hinting]);
188
#endif /* FC_HINT_STYLE */
190
FcPatternDel (res_pattern, FC_ANTIALIAS);
191
FcPatternAddBool (res_pattern, FC_ANTIALIAS, antialiasing != ANTIALIAS_NONE);
193
FcPatternDel (res_pattern, FC_RGBA);
194
FcPatternAddInteger (res_pattern, FC_RGBA,
195
antialiasing == ANTIALIAS_RGBA ? FC_RGBA_RGB : FC_RGBA_NONE);
197
FcPatternDel (res_pattern, FC_DPI);
198
FcPatternAddInteger (res_pattern, FC_DPI, 96);
200
font = XftFontOpenPattern (xdisplay, res_pattern);
202
FcPatternDestroy (res_pattern);
208
setup_font_sample (GtkWidget *darea,
209
Antialiasing antialiasing,
212
const char *string1 = "abcfgop AO ";
213
const char *string2 = "abcfgop";
215
XftColor black, white;
216
XRenderColor rendcolor;
218
Display *xdisplay = gdk_x11_get_default_xdisplay ();
220
GdkColormap *colormap = gdk_rgb_get_colormap ();
221
Colormap xcolormap = GDK_COLORMAP_XCOLORMAP (colormap);
223
GdkVisual *visual = gdk_colormap_get_visual (colormap);
224
Visual *xvisual = GDK_VISUAL_XVISUAL (visual);
227
XftFont *font1, *font2;
228
XGlyphInfo extents1 = { 0 };
229
XGlyphInfo extents2 = { 0 };
232
GdkPixbuf *tmp_pixbuf, *pixbuf;
237
pattern = FcPatternBuild (NULL,
238
FC_FAMILY, FcTypeString, "Serif",
239
FC_SLANT, FcTypeInteger, FC_SLANT_ROMAN,
240
FC_SIZE, FcTypeDouble, 18.,
242
font1 = open_pattern (pattern, antialiasing, hinting);
243
FcPatternDestroy (pattern);
245
pattern = FcPatternBuild (NULL,
246
FC_FAMILY, FcTypeString, "Serif",
247
FC_SLANT, FcTypeInteger, FC_SLANT_ITALIC,
248
FC_SIZE, FcTypeDouble, 20.,
250
font2 = open_pattern (pattern, antialiasing, hinting);
251
FcPatternDestroy (pattern);
256
XftTextExtentsUtf8 (xdisplay, font1, (unsigned char *) string1,
257
strlen (string1), &extents1);
258
ascent = MAX (ascent, font1->ascent);
259
descent = MAX (descent, font1->descent);
263
XftTextExtentsUtf8 (xdisplay, font2, (unsigned char *) string2,
264
strlen (string2), &extents2);
265
ascent = MAX (ascent, font2->ascent);
266
descent = MAX (descent, font2->descent);
269
width = extents1.xOff + extents2.xOff + 4;
270
height = ascent + descent + 2;
272
pixmap = gdk_pixmap_new (NULL, width, height, visual->depth);
274
draw = XftDrawCreate (xdisplay, GDK_DRAWABLE_XID (pixmap), xvisual, xcolormap);
279
rendcolor.alpha = 0xffff;
280
XftColorAllocValue (xdisplay, xvisual, xcolormap, &rendcolor, &black);
282
rendcolor.red = 0xffff;
283
rendcolor.green = 0xffff;
284
rendcolor.blue = 0xffff;
285
rendcolor.alpha = 0xffff;
286
XftColorAllocValue (xdisplay, xvisual, xcolormap, &rendcolor, &white);
287
XftDrawRect (draw, &white, 0, 0, width, height);
289
XftDrawStringUtf8 (draw, &black, font1,
291
(unsigned char *) string1, strlen (string1));
293
XftDrawStringUtf8 (draw, &black, font2,
294
2 + extents1.xOff, 2 + ascent,
295
(unsigned char *) string2, strlen (string2));
297
XftDrawDestroy (draw);
300
XftFontClose (xdisplay, font1);
302
XftFontClose (xdisplay, font2);
304
tmp_pixbuf = gdk_pixbuf_get_from_drawable (NULL, pixmap, colormap, 0, 0, 0, 0, width, height);
305
pixbuf = gdk_pixbuf_scale_simple (tmp_pixbuf, 1 * width, 1 * height, GDK_INTERP_TILES);
307
g_object_unref (pixmap);
308
g_object_unref (tmp_pixbuf);
310
g_object_set_data_full (G_OBJECT (darea), "sample-pixbuf",
311
pixbuf, (GDestroyNotify) g_object_unref);
313
g_signal_connect (darea, "size_request", G_CALLBACK (sample_size_request), NULL);
314
g_signal_connect (darea, "expose_event", G_CALLBACK (sample_expose), NULL);
318
* Code implementing a group of radio buttons with different Xft option combinations.
319
* If one of the buttons is matched by the GConf key, we pick it. Otherwise we
320
* show the group as inconsistent.
323
font_render_get_gconf (GConfClient *client,
324
Antialiasing *antialiasing,
327
gchar *antialias_str = gconf_client_get_string (client, FONT_ANTIALIASING_KEY, NULL);
328
gchar *hint_str = gconf_client_get_string (client, FONT_HINTING_KEY, NULL);
331
val = ANTIALIAS_GRAYSCALE;
333
gconf_string_to_enum (antialias_enums, antialias_str, &val);
334
g_free (antialias_str);
340
gconf_string_to_enum (hint_enums, hint_str, &val);
347
Antialiasing antialiasing;
349
GtkToggleButton *radio;
352
static GSList *font_pairs = NULL;
355
font_render_load (GConfClient *client)
357
Antialiasing antialiasing;
359
gboolean inconsistent = TRUE;
362
font_render_get_gconf (client, &antialiasing, &hinting);
366
for (tmp_list = font_pairs; tmp_list; tmp_list = tmp_list->next) {
367
FontPair *pair = tmp_list->data;
369
if (antialiasing == pair->antialiasing && hinting == pair->hinting) {
370
gtk_toggle_button_set_active (pair->radio, TRUE);
371
inconsistent = FALSE;
376
for (tmp_list = font_pairs; tmp_list; tmp_list = tmp_list->next) {
377
FontPair *pair = tmp_list->data;
379
gtk_toggle_button_set_inconsistent (pair->radio, inconsistent);
386
font_render_changed (GConfClient *client,
391
font_render_load (client);
395
font_radio_toggled (GtkToggleButton *toggle_button,
399
GConfClient *client = gconf_client_get_default ();
401
gconf_client_set_string (client, FONT_ANTIALIASING_KEY,
402
gconf_enum_to_string (antialias_enums, pair->antialiasing),
404
gconf_client_set_string (client, FONT_HINTING_KEY,
405
gconf_enum_to_string (hint_enums, pair->hinting),
408
/* Restore back to the previous state until we get notification */
409
font_render_load (client);
410
g_object_unref (client);
415
setup_font_pair (GtkWidget *radio,
417
Antialiasing antialiasing,
420
FontPair *pair = g_new (FontPair, 1);
422
pair->antialiasing = antialiasing;
423
pair->hinting = hinting;
424
pair->radio = GTK_TOGGLE_BUTTON (radio);
426
setup_font_sample (darea, antialiasing, hinting);
427
font_pairs = g_slist_prepend (font_pairs, pair);
429
g_signal_connect (radio, "toggled",
430
G_CALLBACK (font_radio_toggled), pair);
432
#endif /* HAVE_XFT2 */
435
metacity_titlebar_load_sensitivity (AppearanceData *data)
437
gtk_widget_set_sensitive (appearance_capplet_get_widget (data, "window_title_font"),
438
!gconf_client_get_bool (data->client,
439
WINDOW_TITLE_USES_SYSTEM_KEY,
444
metacity_changed (GConfClient *client,
449
metacity_titlebar_load_sensitivity (user_data);
452
/* returns 0 if the font is safe, otherwise returns the size in points. */
454
font_dangerous (const char *font)
456
PangoFontDescription *pfd;
459
pfd = pango_font_description_from_string (font);
461
/* an invalid font was passed in. This isn't our problem. */
464
if ((pango_font_description_get_set_fields (pfd) & PANGO_FONT_MASK_SIZE) &&
465
(pango_font_description_get_size (pfd) >= MAX_FONT_SIZE_WITHOUT_WARNING)) {
466
retval = pango_font_description_get_size (pfd)/1024;
468
pango_font_description_free (pfd);
474
application_font_to_gconf (GConfPropertyEditor *peditor,
477
GConfValue *new_value;
478
const char *new_font;
479
GtkWidget *font_button;
482
font_button = GTK_WIDGET (gconf_property_editor_get_ui_control (peditor));
483
g_return_val_if_fail (font_button != NULL, NULL);
485
new_value = gconf_value_new (GCONF_VALUE_STRING);
486
new_font = gconf_value_get_string (value);
487
if (font_dangerous (old_font)) {
488
/* If we're already too large, we don't warn again. */
489
gconf_value_set_string (new_value, new_font);
493
danger_level = font_dangerous (new_font);
495
GtkWidget *warning_dialog, *apply_button;
496
const gchar *warning_label;
497
gchar *warning_label2;
499
warning_label = _("Font may be too large");
501
if (danger_level > MAX_FONT_POINT_WITHOUT_WARNING) {
502
warning_label2 = g_strdup_printf (ngettext (
503
"The font selected is %d point large, "
504
"and may make it difficult to effectively "
505
"use the computer. It is recommended that "
506
"you select a size smaller than %d.",
507
"The font selected is %d points large, "
508
"and may make it difficult to effectively "
509
"use the computer. It is recommended that "
510
"you select a size smaller than %d.",
513
MAX_FONT_POINT_WITHOUT_WARNING);
515
warning_label2 = g_strdup_printf (ngettext (
516
"The font selected is %d point large, "
517
"and may make it difficult to effectively "
518
"use the computer. It is recommended that "
519
"you select a smaller sized font.",
520
"The font selected is %d points large, "
521
"and may make it difficult to effectively "
522
"use the computer. It is recommended that "
523
"you select a smaller sized font.",
528
warning_dialog = gtk_message_dialog_new (NULL,
535
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (warning_dialog),
536
"%s", warning_label2);
538
gtk_dialog_add_button (GTK_DIALOG (warning_dialog),
539
_("Use previous font"), GTK_RESPONSE_CLOSE);
541
apply_button = gtk_button_new_with_label (_("Use selected font"));
543
gtk_button_set_image (GTK_BUTTON (apply_button), gtk_image_new_from_stock (GTK_STOCK_APPLY, GTK_ICON_SIZE_BUTTON));
544
gtk_dialog_add_action_widget (GTK_DIALOG (warning_dialog), apply_button, GTK_RESPONSE_APPLY);
545
gtk_widget_set_can_default (apply_button, TRUE);
546
gtk_widget_show (apply_button);
548
gtk_dialog_set_default_response (GTK_DIALOG (warning_dialog), GTK_RESPONSE_CLOSE);
550
g_free (warning_label2);
552
if (gtk_dialog_run (GTK_DIALOG (warning_dialog)) == GTK_RESPONSE_APPLY) {
553
gconf_value_set_string (new_value, new_font);
555
gconf_value_set_string (new_value, old_font);
556
gtk_font_button_set_font_name (GTK_FONT_BUTTON (font_button), old_font);
559
gtk_widget_destroy (warning_dialog);
561
gconf_value_set_string (new_value, new_font);
568
application_font_changed (GtkWidget *font_button)
572
font = gtk_font_button_get_font_name (GTK_FONT_BUTTON (font_button));
574
old_font = g_strdup (font);
579
* EnumGroup - a group of radio buttons tied to a string enumeration
580
* value. We add this here because the gconf peditor
581
* equivalent of this is both painful to use (you have
582
* to supply functions to convert from enums to indices)
583
* and conceptually broken (the order of radio buttons
584
* in a group when using Glade is not predictable.
591
GConfEnumStringPair *enums;
598
GtkToggleButton *widget;
603
enum_group_load (EnumGroup *group)
605
gchar *str = gconf_client_get_string (group->client, group->gconf_key, NULL);
606
gint val = group->default_value;
610
gconf_string_to_enum (group->enums, str, &val);
616
for (tmp_list = group->items; tmp_list; tmp_list = tmp_list->next) {
617
EnumItem *item = tmp_list->data;
619
if (val == item->value)
620
gtk_toggle_button_set_active (item->widget, TRUE);
627
enum_group_changed (GConfClient *client,
632
enum_group_load (user_data);
636
enum_item_toggled (GtkToggleButton *toggle_button,
639
EnumGroup *group = item->group;
642
gconf_client_set_string (group->client, group->gconf_key,
643
gconf_enum_to_string (group->enums, item->value),
647
/* Restore back to the previous state until we get notification */
648
enum_group_load (group);
652
enum_group_create (const gchar *gconf_key,
653
GConfEnumStringPair *enums,
655
GtkWidget *first_widget,
662
group = g_new (EnumGroup, 1);
664
group->client = gconf_client_get_default ();
665
group->gconf_key = g_strdup (gconf_key);
666
group->enums = enums;
667
group->default_value = default_value;
670
va_start (args, first_widget);
672
widget = first_widget;
676
item = g_new (EnumItem, 1);
678
item->widget = GTK_TOGGLE_BUTTON (widget);
679
item->value = va_arg (args, int);
681
g_signal_connect (item->widget, "toggled",
682
G_CALLBACK (enum_item_toggled), item);
684
group->items = g_slist_prepend (group->items, item);
686
widget = va_arg (args, GtkWidget *);
691
enum_group_load (group);
693
gconf_client_notify_add (group->client, gconf_key,
701
enum_group_destroy (EnumGroup *group)
703
g_object_unref (group->client);
704
g_free (group->gconf_key);
706
g_slist_foreach (group->items, (GFunc) g_free, NULL);
707
g_slist_free (group->items);
713
dpi_from_pixels_and_mm (int pixels, int mm)
718
dpi = pixels / (mm / 25.4);
726
get_dpi_from_x_server (void)
731
screen = gdk_screen_get_default ();
733
double width_dpi, height_dpi;
735
width_dpi = dpi_from_pixels_and_mm (gdk_screen_get_width (screen),
736
gdk_screen_get_width_mm (screen));
737
height_dpi = dpi_from_pixels_and_mm (gdk_screen_get_height (screen),
738
gdk_screen_get_height_mm (screen));
740
if (width_dpi < DPI_LOW_REASONABLE_VALUE || width_dpi > DPI_HIGH_REASONABLE_VALUE ||
741
height_dpi < DPI_LOW_REASONABLE_VALUE || height_dpi > DPI_HIGH_REASONABLE_VALUE)
744
dpi = (width_dpi + height_dpi) / 2.0;
746
/* Huh!? No screen? */
754
* The font rendering details dialog
757
dpi_load (GConfClient *client,
758
GtkSpinButton *spinner)
763
value = gconf_client_get_without_default (client, FONT_DPI_KEY, NULL);
766
dpi = gconf_value_get_float (value);
767
gconf_value_free (value);
769
dpi = get_dpi_from_x_server ();
771
if (dpi < DPI_LOW_REASONABLE_VALUE)
772
dpi = DPI_LOW_REASONABLE_VALUE;
775
gtk_spin_button_set_value (spinner, dpi);
780
dpi_changed (GConfClient *client,
785
dpi_load (client, user_data);
789
dpi_value_changed (GtkSpinButton *spinner,
792
/* Like any time when using a spin button with GConf, there is
793
* a race condition here. When we change, we send the new
794
* value to GConf, then restore to the old value until
795
* we get a response to emulate the proper model/view behavior.
797
* If the user changes the value faster than responses are
798
* received from GConf, this may cause mildly strange effects.
801
gdouble new_dpi = gtk_spin_button_get_value (spinner);
803
gconf_client_set_float (client, FONT_DPI_KEY, new_dpi, NULL);
805
dpi_load (client, spinner);
810
cb_details_response (GtkDialog *dialog, gint response_id)
812
if (response_id == GTK_RESPONSE_HELP) {
813
capplet_help (GTK_WINDOW (dialog),
816
gtk_widget_hide (GTK_WIDGET (dialog));
820
cb_show_details (GtkWidget *button,
821
AppearanceData *data)
823
if (!data->font_details) {
824
GtkAdjustment *adjustment;
828
data->font_details = appearance_capplet_get_widget (data, "render_details");
830
gtk_window_set_transient_for (GTK_WINDOW (data->font_details),
831
GTK_WINDOW (appearance_capplet_get_widget (data, "appearance_window")));
833
widget = appearance_capplet_get_widget (data, "dpi_spinner");
835
/* pick a sensible maximum dpi */
836
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
837
gtk_adjustment_set_lower (adjustment, DPI_LOW_REASONABLE_VALUE);
838
gtk_adjustment_set_upper (adjustment, DPI_HIGH_REASONABLE_VALUE);
839
gtk_adjustment_set_step_increment (adjustment, 1);
841
dpi_load (data->client, GTK_SPIN_BUTTON (widget));
842
g_signal_connect (widget, "value_changed",
843
G_CALLBACK (dpi_value_changed), data->client);
845
gconf_client_notify_add (data->client, FONT_DPI_KEY,
846
dpi_changed, widget, NULL, NULL);
848
setup_font_sample (appearance_capplet_get_widget (data, "antialias_none_sample"), ANTIALIAS_NONE, HINT_FULL);
849
setup_font_sample (appearance_capplet_get_widget (data, "antialias_grayscale_sample"), ANTIALIAS_GRAYSCALE, HINT_FULL);
850
setup_font_sample (appearance_capplet_get_widget (data, "antialias_subpixel_sample"), ANTIALIAS_RGBA, HINT_FULL);
852
group = enum_group_create (
853
FONT_ANTIALIASING_KEY, antialias_enums, ANTIALIAS_GRAYSCALE,
854
appearance_capplet_get_widget (data, "antialias_none_radio"), ANTIALIAS_NONE,
855
appearance_capplet_get_widget (data, "antialias_grayscale_radio"), ANTIALIAS_GRAYSCALE,
856
appearance_capplet_get_widget (data, "antialias_subpixel_radio"), ANTIALIAS_RGBA,
858
data->font_groups = g_slist_prepend (data->font_groups, group);
860
setup_font_sample (appearance_capplet_get_widget (data, "hint_none_sample"), ANTIALIAS_GRAYSCALE, HINT_NONE);
861
setup_font_sample (appearance_capplet_get_widget (data, "hint_slight_sample"), ANTIALIAS_GRAYSCALE, HINT_SLIGHT);
862
setup_font_sample (appearance_capplet_get_widget (data, "hint_medium_sample"), ANTIALIAS_GRAYSCALE, HINT_MEDIUM);
863
setup_font_sample (appearance_capplet_get_widget (data, "hint_full_sample"), ANTIALIAS_GRAYSCALE, HINT_FULL);
865
group = enum_group_create (FONT_HINTING_KEY, hint_enums, HINT_FULL,
866
appearance_capplet_get_widget (data, "hint_none_radio"), HINT_NONE,
867
appearance_capplet_get_widget (data, "hint_slight_radio"), HINT_SLIGHT,
868
appearance_capplet_get_widget (data, "hint_medium_radio"), HINT_MEDIUM,
869
appearance_capplet_get_widget (data, "hint_full_radio"), HINT_FULL,
871
data->font_groups = g_slist_prepend (data->font_groups, group);
873
gtk_image_set_from_file (GTK_IMAGE (appearance_capplet_get_widget (data, "subpixel_rgb_image")),
874
GNOMECC_PIXMAP_DIR "/subpixel-rgb.png");
875
gtk_image_set_from_file (GTK_IMAGE (appearance_capplet_get_widget (data, "subpixel_bgr_image")),
876
GNOMECC_PIXMAP_DIR "/subpixel-bgr.png");
877
gtk_image_set_from_file (GTK_IMAGE (appearance_capplet_get_widget (data, "subpixel_vrgb_image")),
878
GNOMECC_PIXMAP_DIR "/subpixel-vrgb.png");
879
gtk_image_set_from_file (GTK_IMAGE (appearance_capplet_get_widget (data, "subpixel_vbgr_image")),
880
GNOMECC_PIXMAP_DIR "/subpixel-vbgr.png");
882
group = enum_group_create (FONT_RGBA_ORDER_KEY, rgba_order_enums, RGBA_RGB,
883
appearance_capplet_get_widget (data, "subpixel_rgb_radio"), RGBA_RGB,
884
appearance_capplet_get_widget (data, "subpixel_bgr_radio"), RGBA_BGR,
885
appearance_capplet_get_widget (data, "subpixel_vrgb_radio"), RGBA_VRGB,
886
appearance_capplet_get_widget (data, "subpixel_vbgr_radio"), RGBA_VBGR,
888
data->font_groups = g_slist_prepend (data->font_groups, group);
890
g_signal_connect (G_OBJECT (data->font_details),
892
G_CALLBACK (cb_details_response), NULL);
893
g_signal_connect (G_OBJECT (data->font_details),
895
G_CALLBACK (gtk_true), NULL);
898
gtk_window_present (GTK_WINDOW (data->font_details));
900
#endif /* HAVE_XFT2 */
903
font_init (AppearanceData *data)
908
data->font_details = NULL;
909
data->font_groups = NULL;
911
gconf_client_add_dir (data->client, "/desktop/gnome/interface",
912
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
913
gconf_client_add_dir (data->client, "/apps/nautilus/preferences",
914
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
915
gconf_client_add_dir (data->client, METACITY_DIR,
916
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
918
gconf_client_add_dir (data->client, FONT_RENDER_DIR,
919
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
920
#endif /* HAVE_XFT2 */
922
widget = appearance_capplet_get_widget (data, "application_font");
923
peditor = gconf_peditor_new_font (NULL, GTK_FONT_KEY,
925
"conv-from-widget-cb", application_font_to_gconf,
927
g_signal_connect_swapped (peditor, "value-changed",
928
G_CALLBACK (application_font_changed),
930
application_font_changed (widget);
932
peditor = gconf_peditor_new_font (NULL, DOCUMENT_FONT_KEY,
933
appearance_capplet_get_widget (data, "document_font"),
936
peditor = gconf_peditor_new_font (NULL, DESKTOP_FONT_KEY,
937
appearance_capplet_get_widget (data, "desktop_font"),
940
peditor = gconf_peditor_new_font (NULL, WINDOW_TITLE_FONT_KEY,
941
appearance_capplet_get_widget (data, "window_title_font"),
944
peditor = gconf_peditor_new_font (NULL, MONOSPACE_FONT_KEY,
945
appearance_capplet_get_widget (data, "monospace_font"),
948
gconf_client_notify_add (data->client, WINDOW_TITLE_USES_SYSTEM_KEY,
952
metacity_titlebar_load_sensitivity (data);
955
setup_font_pair (appearance_capplet_get_widget (data, "monochrome_radio"),
956
appearance_capplet_get_widget (data, "monochrome_sample"),
957
ANTIALIAS_NONE, HINT_FULL);
958
setup_font_pair (appearance_capplet_get_widget (data, "best_shapes_radio"),
959
appearance_capplet_get_widget (data, "best_shapes_sample"),
960
ANTIALIAS_GRAYSCALE, HINT_MEDIUM);
961
setup_font_pair (appearance_capplet_get_widget (data, "best_contrast_radio"),
962
appearance_capplet_get_widget (data, "best_contrast_sample"),
963
ANTIALIAS_GRAYSCALE, HINT_FULL);
964
setup_font_pair (appearance_capplet_get_widget (data, "subpixel_radio"),
965
appearance_capplet_get_widget (data, "subpixel_sample"),
966
ANTIALIAS_RGBA, HINT_FULL);
968
font_render_load (data->client);
970
gconf_client_notify_add (data->client, FONT_RENDER_DIR,
972
data->client, NULL, NULL);
974
g_signal_connect (appearance_capplet_get_widget (data, "details_button"),
975
"clicked", G_CALLBACK (cb_show_details), data);
976
#else /* !HAVE_XFT2 */
977
gtk_widget_hide (appearance_capplet_get_widget (data, "font_render_frame"));
978
#endif /* HAVE_XFT2 */
982
font_shutdown (AppearanceData *data)
984
g_slist_foreach (data->font_groups, (GFunc) enum_group_destroy, NULL);
985
g_slist_free (data->font_groups);
986
g_slist_foreach (font_pairs, (GFunc) g_free, NULL);
987
g_slist_free (font_pairs);