1
/* This program was written with lots of love under the GPL by Jonathan
2
* Blandford <jrb@gnome.org>
9
#include <gconf/gconf-client.h>
10
#include <glade/glade.h>
16
#include <X11/Xft/Xft.h>
17
#endif /* HAVE_XFT2 */
19
#include "capplet-util.h"
20
#include "activate-settings-daemon.h"
21
#include "gconf-property-editor.h"
24
static void cb_show_details (GtkWidget *button,
26
#endif /* HAVE_XFT2 */
28
#define GTK_FONT_KEY "/desktop/gnome/interface/font_name"
29
#define DESKTOP_FONT_KEY "/apps/nautilus/preferences/desktop_font"
31
#define METACITY_DIR "/apps/metacity/general"
32
#define WINDOW_TITLE_FONT_KEY METACITY_DIR "/titlebar_font"
33
#define WINDOW_TITLE_USES_SYSTEM_KEY METACITY_DIR "/titlebar_uses_system_font"
34
#define MONOSPACE_FONT_KEY "/desktop/gnome/interface/monospace_font_name"
35
#define DOCUMENT_FONT_KEY "/desktop/gnome/interface/document_font_name"
38
#define FONT_RENDER_DIR "/desktop/gnome/font_rendering"
39
#define FONT_ANTIALIASING_KEY FONT_RENDER_DIR "/antialiasing"
40
#define FONT_HINTING_KEY FONT_RENDER_DIR "/hinting"
41
#define FONT_RGBA_ORDER_KEY FONT_RENDER_DIR "/rgba_order"
42
#define FONT_DPI_KEY FONT_RENDER_DIR "/dpi"
44
/* X servers sometimes lie about the screen's physical dimensions, so we cannot
45
* compute an accurate DPI value. When this happens, the user gets fonts that
46
* are too huge or too tiny. So, we see what the server returns: if it reports
47
* something outside of the range [DPI_LOW_REASONABLE_VALUE,
48
* DPI_HIGH_REASONABLE_VALUE], then we assume that it is lying and we use
49
* DPI_FALLBACK instead.
51
* See get_dpi_from_gconf_or_server() below, and also
52
* https://bugzilla.novell.com/show_bug.cgi?id=217790
54
#define DPI_FALLBACK 96
55
#define DPI_LOW_REASONABLE_VALUE 50
56
#define DPI_HIGH_REASONABLE_VALUE 500
57
#endif /* HAVE_XFT2 */
58
static gboolean in_change = FALSE;
59
static gchar *old_font = NULL;
61
#define MAX_FONT_POINT_WITHOUT_WARNING 32
62
#define MAX_FONT_SIZE_WITHOUT_WARNING MAX_FONT_POINT_WITHOUT_WARNING*1024
65
cb_dialog_response (GtkDialog *dialog, gint response_id)
67
if (response_id == GTK_RESPONSE_HELP)
68
capplet_help (GTK_WINDOW (dialog),
78
* Code for displaying previews of font rendering with various Xft options
82
sample_size_request (GtkWidget *darea,
83
GtkRequisition *requisition)
85
GdkPixbuf *pixbuf = g_object_get_data (G_OBJECT (darea), "sample-pixbuf");
87
requisition->width = gdk_pixbuf_get_width (pixbuf) + 2;
88
requisition->height = gdk_pixbuf_get_height (pixbuf) + 2;
92
sample_expose (GtkWidget *darea,
93
GdkEventExpose *expose)
95
GdkPixbuf *pixbuf = g_object_get_data (G_OBJECT (darea), "sample-pixbuf");
96
int width = gdk_pixbuf_get_width (pixbuf);
97
int height = gdk_pixbuf_get_height (pixbuf);
99
int x = (darea->allocation.width - width) / 2;
100
int y = (darea->allocation.height - height) / 2;
102
gdk_draw_rectangle (darea->window, darea->style->white_gc, TRUE,
104
darea->allocation.width, darea->allocation.height);
105
gdk_draw_rectangle (darea->window, darea->style->black_gc, FALSE,
107
darea->allocation.width - 1, darea->allocation.height - 1);
109
gdk_pixbuf_render_to_drawable (pixbuf, darea->window, NULL,
110
0, 0, x, y, width, height,
111
GDK_RGB_DITHER_NORMAL, 0, 0);
120
static GConfEnumStringPair antialias_enums[] = {
121
{ ANTIALIAS_NONE, "none" },
122
{ ANTIALIAS_GRAYSCALE, "grayscale" },
123
{ ANTIALIAS_RGBA, "rgba" },
134
static GConfEnumStringPair hint_enums[] = {
135
{ HINT_NONE, "none" },
136
{ HINT_SLIGHT, "slight" },
137
{ HINT_MEDIUM, "medium" },
138
{ HINT_FULL, "full" },
149
static GConfEnumStringPair rgba_order_enums[] = {
152
{ RGBA_VRGB, "vrgb" },
153
{ RGBA_VBGR, "vbgr" },
158
open_pattern (FcPattern *pattern,
159
Antialiasing antialiasing,
163
static const int hintstyles[] = { FC_HINT_NONE, FC_HINT_SLIGHT, FC_HINT_MEDIUM, FC_HINT_FULL };
164
#endif /* FC_HINT_STYLE */
166
FcPattern *res_pattern;
170
Display *xdisplay = gdk_x11_get_default_xdisplay ();
171
int screen = gdk_x11_get_default_screen ();
173
res_pattern = XftFontMatch (xdisplay, screen, pattern, &result);
174
if (res_pattern == NULL)
177
FcPatternDel (res_pattern, FC_HINTING);
178
FcPatternAddBool (res_pattern, FC_HINTING, hinting != HINT_NONE);
181
FcPatternDel (res_pattern, FC_HINT_STYLE);
182
FcPatternAddInteger (res_pattern, FC_HINT_STYLE, hintstyles[hinting]);
183
#endif /* FC_HINT_STYLE */
185
FcPatternDel (res_pattern, FC_ANTIALIAS);
186
FcPatternAddBool (res_pattern, FC_ANTIALIAS, antialiasing != ANTIALIAS_NONE);
188
FcPatternDel (res_pattern, FC_RGBA);
189
FcPatternAddInteger (res_pattern, FC_RGBA,
190
antialiasing == ANTIALIAS_RGBA ? FC_RGBA_RGB : FC_RGBA_NONE);
192
FcPatternDel (res_pattern, FC_DPI);
193
FcPatternAddInteger (res_pattern, FC_DPI, 96);
195
font = XftFontOpenPattern (xdisplay, res_pattern);
197
FcPatternDestroy (res_pattern);
203
setup_font_sample (GtkWidget *darea,
204
Antialiasing antialiasing,
207
const char *string1 = "abcfgop AO ";
208
const char *string2 = "abcfgop";
210
XftColor black, white;
211
XRenderColor rendcolor;
213
Display *xdisplay = gdk_x11_get_default_xdisplay ();
215
GdkColormap *colormap = gdk_rgb_get_colormap ();
216
Colormap xcolormap = GDK_COLORMAP_XCOLORMAP (colormap);
218
GdkVisual *visual = gdk_colormap_get_visual (colormap);
219
Visual *xvisual = GDK_VISUAL_XVISUAL (visual);
222
XftFont *font1, *font2;
223
XGlyphInfo extents1 = { 0 };
224
XGlyphInfo extents2 = { 0 };
227
GdkPixbuf *tmp_pixbuf, *pixbuf;
232
pattern = FcPatternBuild (NULL,
233
FC_FAMILY, FcTypeString, "Serif",
234
FC_SLANT, FcTypeInteger, FC_SLANT_ROMAN,
235
FC_SIZE, FcTypeDouble, 18.,
237
font1 = open_pattern (pattern, antialiasing, hinting);
238
FcPatternDestroy (pattern);
240
pattern = FcPatternBuild (NULL,
241
FC_FAMILY, FcTypeString, "Serif",
242
FC_SLANT, FcTypeInteger, FC_SLANT_ITALIC,
243
FC_SIZE, FcTypeDouble, 20.,
245
font2 = open_pattern (pattern, antialiasing, hinting);
246
FcPatternDestroy (pattern);
249
XftTextExtentsUtf8 (xdisplay, font1, (unsigned char *)string1, strlen (string1), &extents1);
251
XftTextExtentsUtf8 (xdisplay, font2, (unsigned char *)string2, strlen (string2), &extents2);
255
ascent = MAX (ascent, font1->ascent);
257
ascent = MAX (ascent, font2->ascent);
261
descent = MAX (descent, font1->descent);
263
descent = MAX (descent, font2->descent);
265
width = extents1.xOff + extents2.xOff + 4;
267
height = ascent + descent + 2;
269
pixmap = gdk_pixmap_new (NULL, width, height, visual->depth);
271
draw = XftDrawCreate (xdisplay, GDK_DRAWABLE_XID (pixmap), xvisual, xcolormap);
276
rendcolor.alpha = 0xffff;
277
XftColorAllocValue (xdisplay, xvisual, xcolormap, &rendcolor, &black);
279
rendcolor.red = 0xffff;
280
rendcolor.green = 0xffff;
281
rendcolor.blue = 0xffff;
282
rendcolor.alpha = 0xffff;
283
XftColorAllocValue (xdisplay, xvisual, xcolormap, &rendcolor, &white);
284
XftDrawRect (draw, &white, 0, 0, width, height);
286
XftDrawStringUtf8 (draw, &black, font1,
288
(unsigned char *)string1, strlen (string1));
290
XftDrawStringUtf8 (draw, &black, font2,
291
2 + extents1.xOff, 2 + ascent,
292
(unsigned char *)string2, strlen (string2));
294
XftDrawDestroy (draw);
297
XftFontClose (xdisplay, font1);
299
XftFontClose (xdisplay, font2);
301
tmp_pixbuf = gdk_pixbuf_get_from_drawable (NULL, pixmap, colormap, 0, 0, 0, 0, width, height);
302
pixbuf = gdk_pixbuf_scale_simple (tmp_pixbuf, 1 * width, 1 * height, GDK_INTERP_TILES);
304
g_object_unref (pixmap);
305
g_object_unref (tmp_pixbuf);
307
g_object_set_data_full (G_OBJECT (darea), "sample-pixbuf",
308
pixbuf, (GDestroyNotify)g_object_unref);
310
g_signal_connect (darea, "size_request", G_CALLBACK (sample_size_request), NULL);
311
g_signal_connect (darea, "expose_event", G_CALLBACK (sample_expose), NULL);
315
* Code implementing a group of radio buttons with different Xft option combinations.
316
* If one of the buttons is matched by the GConf key, we pick it. Otherwise we
317
* show the group as inconsistent.
320
font_render_get_gconf (Antialiasing *antialiasing,
323
GConfClient *client = gconf_client_get_default ();
324
char *antialias_str = gconf_client_get_string (client, FONT_ANTIALIASING_KEY, NULL);
325
char *hint_str = gconf_client_get_string (client, FONT_HINTING_KEY, NULL);
328
val = ANTIALIAS_GRAYSCALE;
330
gconf_string_to_enum (antialias_enums, antialias_str, &val);
331
g_free (antialias_str);
337
gconf_string_to_enum (hint_enums, hint_str, &val);
342
g_object_unref (client);
346
Antialiasing antialiasing;
351
static GSList *font_pairs = NULL;
354
font_render_load (void)
356
Antialiasing antialiasing;
358
gboolean inconsistent = TRUE;
361
font_render_get_gconf (&antialiasing, &hinting);
365
for (tmp_list = font_pairs; tmp_list; tmp_list = tmp_list->next) {
366
FontPair *pair = tmp_list->data;
368
if (antialiasing == pair->antialiasing && hinting == pair->hinting) {
369
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pair->radio), TRUE);
370
inconsistent = FALSE;
374
for (tmp_list = font_pairs; tmp_list; tmp_list = tmp_list->next) {
375
FontPair *pair = tmp_list->data;
377
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (pair->radio), inconsistent);
384
font_render_changed (GConfClient *client,
393
font_radio_toggled (GtkToggleButton *toggle_button,
397
GConfClient *client = gconf_client_get_default ();
399
gconf_client_set_string (client, FONT_ANTIALIASING_KEY,
400
gconf_enum_to_string (antialias_enums, pair->antialiasing),
402
gconf_client_set_string (client, FONT_HINTING_KEY,
403
gconf_enum_to_string (hint_enums, pair->hinting),
406
g_object_unref (client);
409
/* Restore back to the previous state until we get notification
415
setup_font_pair (GtkWidget *radio,
417
Antialiasing antialiasing,
420
FontPair *pair = g_new (FontPair, 1);
422
pair->antialiasing = antialiasing;
423
pair->hinting = hinting;
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 (GConfClient *client,
438
gtk_widget_set_sensitive (WID ("window_title_font"),
439
!gconf_client_get_bool (client,
440
WINDOW_TITLE_USES_SYSTEM_KEY,
445
metacity_changed (GConfClient *client,
450
if (strcmp (entry->key, WINDOW_TITLE_USES_SYSTEM_KEY) == 0)
451
metacity_titlebar_load_sensitivity (client, user_data);
454
/* returns 0 if the font is safe, otherwise returns the size in points. */
456
new_font_dangerous (const char *new_font)
458
PangoFontDescription *pfd;
461
pfd = pango_font_description_from_string (new_font);
463
/* an invalid font was passed in. This isn't our problem. */
466
if (pango_font_description_get_set_fields (pfd) & PANGO_FONT_MASK_SIZE) {
467
if (pango_font_description_get_size (pfd) >= MAX_FONT_SIZE_WITHOUT_WARNING) {
468
retval = pango_font_description_get_size (pfd)/1024;
471
pango_font_description_free (pfd);
477
application_font_to_gconf (GConfPropertyEditor *peditor,
480
GConfValue *new_value;
481
const char *new_font;
482
GtkWidget *font_button;
485
font_button = GTK_WIDGET (gconf_property_editor_get_ui_control (peditor));
486
g_return_val_if_fail (font_button != NULL, NULL);
488
new_value = gconf_value_new (GCONF_VALUE_STRING);
489
new_font = gconf_value_get_string (value);
490
if (new_font_dangerous (old_font)) {
491
/* If we're already too large, we don't warn again. */
492
gconf_value_set_string (new_value, new_font);
496
danger_level = new_font_dangerous (new_font);
498
GtkWidget *warning_dialog, *apply_button;
499
gchar *warning_label;
500
gchar *warning_label2;
502
warning_label = g_strdup (_("Font may be too large"));
504
if (danger_level > MAX_FONT_POINT_WITHOUT_WARNING) {
505
warning_label2 = g_strdup_printf (ngettext (
506
"The font selected is %d point large, "
507
"and may make it difficult to effectively "
508
"use the computer. It is recommended that "
509
"you select a size smaller than %d.",
510
"The font selected is %d points large, "
511
"and may make it difficult to effectively "
512
"use the computer. It is recommended that "
513
"you select a size smaller than %d.",
516
MAX_FONT_POINT_WITHOUT_WARNING);
518
warning_label2 = g_strdup_printf (ngettext (
519
"The font selected is %d point large, "
520
"and may make it difficult to effectively "
521
"use the computer. It is recommended that "
522
"you select a smaller sized font.",
523
"The font selected is %d points large, "
524
"and may make it difficult to effectively "
525
"use the computer. It is recommended that "
526
"you select a smaller sized font.",
531
warning_dialog = gtk_message_dialog_new (NULL,
537
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (warning_dialog),
540
gtk_dialog_add_button (GTK_DIALOG (warning_dialog), _("Use previous font"), GTK_RESPONSE_CLOSE);
542
apply_button = gtk_button_new_with_label (_("Use selected font"));
544
gtk_button_set_image (GTK_BUTTON (apply_button), gtk_image_new_from_stock (GTK_STOCK_APPLY, GTK_ICON_SIZE_BUTTON));
545
gtk_dialog_add_action_widget (GTK_DIALOG (warning_dialog), apply_button, GTK_RESPONSE_APPLY);
546
GTK_WIDGET_SET_FLAGS (apply_button, GTK_CAN_DEFAULT);
547
gtk_widget_show (apply_button);
549
gtk_dialog_set_default_response (GTK_DIALOG (warning_dialog), GTK_RESPONSE_CLOSE);
551
g_free (warning_label);
552
g_free (warning_label2);
554
if (gtk_dialog_run (GTK_DIALOG (warning_dialog)) == GTK_RESPONSE_APPLY) {
555
gconf_value_set_string (new_value, new_font);
557
gconf_value_set_string (new_value, old_font);
558
gtk_font_button_set_font_name (GTK_FONT_BUTTON (font_button), old_font);
561
gtk_widget_destroy (warning_dialog);
563
gconf_value_set_string (new_value, new_font);
570
application_font_changed (GtkWidget *font_button)
574
font = gtk_font_button_get_font_name (GTK_FONT_BUTTON (font_button));
576
old_font = g_strdup (font);
587
dialog = glade_xml_new (GLADEDIR "/font-properties.glade", "font_dialog", NULL);
589
g_warning ("could not load font-properties.glade");
593
client = gconf_client_get_default ();
595
gconf_client_add_dir (client, "/desktop/gnome/interface", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
596
gconf_client_add_dir (client, "/apps/nautilus/preferences", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
597
gconf_client_add_dir (client, METACITY_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
599
gconf_client_add_dir (client, FONT_RENDER_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
600
#endif /* HAVE_XFT2 */
602
peditor = gconf_peditor_new_font (NULL, GTK_FONT_KEY,
603
WID ("application_font"),
604
"conv-from-widget-cb", application_font_to_gconf,
606
g_signal_connect_swapped (peditor, "value-changed",
607
G_CALLBACK (application_font_changed), WID ("application_font"));
608
application_font_changed (WID ("application_font"));
610
peditor = gconf_peditor_new_font (NULL, DOCUMENT_FONT_KEY,
611
WID ("document_font"),
614
peditor = gconf_peditor_new_font (NULL, DESKTOP_FONT_KEY,
615
WID ("desktop_font"),
618
peditor = gconf_peditor_new_font (NULL, WINDOW_TITLE_FONT_KEY,
619
WID ("window_title_font"),
622
peditor = gconf_peditor_new_font (NULL, MONOSPACE_FONT_KEY,
623
WID ("monospace_font"),
626
gconf_client_notify_add (client, METACITY_DIR,
630
metacity_titlebar_load_sensitivity (client, dialog);
632
widget = WID ("font_dialog");
633
capplet_set_icon (widget, "gnome-settings-font");
636
setup_font_pair (WID ("monochrome_radio"), WID ("monochrome_sample"), ANTIALIAS_NONE, HINT_FULL);
637
setup_font_pair (WID ("best_shapes_radio"), WID ("best_shapes_sample"), ANTIALIAS_GRAYSCALE, HINT_MEDIUM);
638
setup_font_pair (WID ("best_contrast_radio"), WID ("best_contrast_sample"), ANTIALIAS_GRAYSCALE, HINT_FULL);
639
setup_font_pair (WID ("subpixel_radio"), WID ("subpixel_sample"), ANTIALIAS_RGBA, HINT_FULL);
643
gconf_client_notify_add (client, FONT_RENDER_DIR,
647
g_signal_connect (WID ("details_button"), "clicked",
648
G_CALLBACK (cb_show_details), widget);
649
#else /* !HAVE_XFT2 */
650
gtk_widget_hide (WID ("font_render_frame"));
651
#endif /* HAVE_XFT2 */
653
g_signal_connect (widget, "response",
654
G_CALLBACK (cb_dialog_response), NULL);
656
gtk_widget_show (widget);
658
g_object_unref (client);
663
* EnumGroup - a group of radio buttons tied to a string enumeration
664
* value. We add this here because the gconf peditor
665
* equivalent of this is both painful to use (you have
666
* to supply functions to convert from enums to indices)
667
* and conceptually broken (the order of radio buttons
668
* in a group when using Glade is not predictable.
674
const gchar *gconf_key;
675
GConfEnumStringPair *enums;
687
enum_group_load (EnumGroup *group)
689
char *str = gconf_client_get_string (group->client, group->gconf_key, NULL);
690
int val = group->default_value;
694
gconf_string_to_enum (group->enums, str, &val);
700
for (tmp_list = group->items; tmp_list; tmp_list = tmp_list->next) {
701
EnumItem *item = tmp_list->data;
703
if (val == item->value)
704
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item->widget), TRUE);
713
enum_group_changed (GConfClient *client,
718
enum_group_load (user_data);
722
enum_item_toggled (GtkToggleButton *toggle_button,
725
EnumGroup *group = item->group;
728
gconf_client_set_string (group->client, group->gconf_key,
729
gconf_enum_to_string (group->enums, item->value),
733
/* Restore back to the previous state until we get notification
735
enum_group_load (group);
739
enum_group_create (const gchar *gconf_key,
740
GConfEnumStringPair *enums,
742
GtkWidget *first_widget,
749
group = g_new (EnumGroup, 1);
751
group->client = gconf_client_get_default ();
752
group->gconf_key = g_strdup (gconf_key);
753
group->enums = enums;
754
group->default_value = default_value;
757
va_start (args, first_widget);
759
widget = first_widget;
764
item = g_new (EnumItem, 1);
766
item->widget = widget;
767
item->value = va_arg (args, int);
769
g_signal_connect (item->widget, "toggled",
770
G_CALLBACK (enum_item_toggled), item);
772
group->items = g_slist_prepend (group->items, item);
774
widget = va_arg (args, GtkWidget *);
779
enum_group_load (group);
781
gconf_client_notify_add (group->client, gconf_key,
789
dpi_from_pixels_and_mm (int pixels, int mm)
794
dpi = pixels / (mm / 25.4);
802
get_dpi_from_x_server (void)
807
screen = gdk_screen_get_default ();
810
double width_dpi, height_dpi;
812
width_dpi = dpi_from_pixels_and_mm (gdk_screen_get_width (screen), gdk_screen_get_width_mm (screen));
813
height_dpi = dpi_from_pixels_and_mm (gdk_screen_get_height (screen), gdk_screen_get_height_mm (screen));
815
if (width_dpi < DPI_LOW_REASONABLE_VALUE || width_dpi > DPI_HIGH_REASONABLE_VALUE
816
|| height_dpi < DPI_LOW_REASONABLE_VALUE || height_dpi > DPI_HIGH_REASONABLE_VALUE)
819
dpi = (width_dpi + height_dpi) / 2.0;
823
/* Huh!? No screen? */
832
* The font rendering details dialog
835
dpi_load (GConfClient *client,
836
GtkSpinButton *spinner)
841
value = gconf_client_get_without_default (client, FONT_DPI_KEY, NULL);
844
dpi = gconf_value_get_float (value);
845
gconf_value_free (value);
847
dpi = get_dpi_from_x_server ();
853
gtk_spin_button_set_value (spinner, dpi);
858
dpi_changed (GConfClient *client,
863
dpi_load (client, user_data);
867
dpi_value_changed (GtkSpinButton *spinner,
870
/* Like any time when using a spin button with GConf, there is
871
* a race condition here. When we change, we send the new
872
* value to GCOnf, then restore to the old value until
873
* we get a response to emulate the proper model/view behavior.
875
* If the user changes the value faster than responses are
876
* received from GConf, this may cause mild strange effects.
878
gdouble new_dpi = gtk_spin_button_get_value (spinner);
880
gconf_client_set_float (client, FONT_DPI_KEY, new_dpi, NULL);
882
dpi_load (client, spinner);
886
cb_details_response (GtkDialog *dialog, gint response_id)
888
if (response_id == GTK_RESPONSE_HELP)
889
capplet_help (GTK_WINDOW (dialog),
892
else if (response_id == 1) {
893
/* "Go to font folder" was clicked */
894
g_spawn_command_line_async ("nautilus --no-desktop fonts:///", NULL);
896
gtk_widget_hide (GTK_WIDGET (dialog));
900
cb_show_details (GtkWidget *button,
903
static GtkWidget *details_dialog = NULL;
905
if (!details_dialog) {
906
GConfClient *client = gconf_client_get_default ();
908
GtkWidget *dpi_spinner;
911
GtkAdjustment *adjustment;
913
dialog = glade_xml_new (GLADEDIR "/font-properties.glade", "render_details", NULL);
915
g_warning ("could not load font-properties.glade");
919
details_dialog = WID ("render_details");
920
uri = gnome_vfs_uri_new ("fonts:///");
922
gtk_widget_hide (WID ("go_to_font_button"));
924
gnome_vfs_uri_unref (uri);
925
gtk_widget_show (WID ("go_to_font_button"));
928
gtk_window_set_transient_for (GTK_WINDOW (details_dialog), parent);
930
dpi_spinner = WID ("dpi_spinner");
932
/* pick a sensible maximum dpi */
933
dpi = floor ((gdk_screen_width () / gdk_screen_width_mm () +
934
gdk_screen_height () / gdk_screen_height_mm ()) * 25.4 / 2. + .5);
936
dpi = 50; /* be extra careful */
937
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (dpi_spinner));
938
adjustment->upper = dpi * 3;
940
dpi_load (client, GTK_SPIN_BUTTON (dpi_spinner));
941
g_signal_connect (dpi_spinner, "value_changed",
942
G_CALLBACK (dpi_value_changed), client);
944
gconf_client_notify_add (client, FONT_DPI_KEY,
946
dpi_spinner, NULL, NULL);
948
setup_font_sample (WID ("antialias_none_sample"), ANTIALIAS_NONE, HINT_FULL);
949
setup_font_sample (WID ("antialias_grayscale_sample"), ANTIALIAS_GRAYSCALE, HINT_FULL);
950
setup_font_sample (WID ("antialias_subpixel_sample"), ANTIALIAS_RGBA, HINT_FULL);
952
enum_group_create (FONT_ANTIALIASING_KEY, antialias_enums, ANTIALIAS_GRAYSCALE,
953
WID ("antialias_none_radio"), ANTIALIAS_NONE,
954
WID ("antialias_grayscale_radio"), ANTIALIAS_GRAYSCALE,
955
WID ("antialias_subpixel_radio"), ANTIALIAS_RGBA,
958
setup_font_sample (WID ("hint_none_sample"), ANTIALIAS_GRAYSCALE, HINT_NONE);
959
setup_font_sample (WID ("hint_slight_sample"), ANTIALIAS_GRAYSCALE, HINT_SLIGHT);
960
setup_font_sample (WID ("hint_medium_sample"), ANTIALIAS_GRAYSCALE, HINT_MEDIUM);
961
setup_font_sample (WID ("hint_full_sample"), ANTIALIAS_GRAYSCALE, HINT_FULL);
963
enum_group_create (FONT_HINTING_KEY, hint_enums, HINT_FULL,
964
WID ("hint_none_radio"), HINT_NONE,
965
WID ("hint_slight_radio"), HINT_SLIGHT,
966
WID ("hint_medium_radio"), HINT_MEDIUM,
967
WID ("hint_full_radio"), HINT_FULL,
970
gtk_image_set_from_file (GTK_IMAGE (WID ("subpixel_rgb_image")),
971
PIXMAPDIR "/subpixel-rgb.png");
972
gtk_image_set_from_file (GTK_IMAGE (WID ("subpixel_bgr_image")),
973
PIXMAPDIR "/subpixel-bgr.png");
974
gtk_image_set_from_file (GTK_IMAGE (WID ("subpixel_vrgb_image")),
975
PIXMAPDIR "/subpixel-vrgb.png");
976
gtk_image_set_from_file (GTK_IMAGE (WID ("subpixel_vbgr_image")),
977
PIXMAPDIR "/subpixel-vbgr.png");
979
enum_group_create (FONT_RGBA_ORDER_KEY, rgba_order_enums, RGBA_RGB,
980
WID ("subpixel_rgb_radio"), RGBA_RGB,
981
WID ("subpixel_bgr_radio"), RGBA_BGR,
982
WID ("subpixel_vrgb_radio"), RGBA_VRGB,
983
WID ("subpixel_vbgr_radio"), RGBA_VBGR,
986
g_signal_connect (G_OBJECT (details_dialog),
988
G_CALLBACK (cb_details_response), NULL);
989
g_signal_connect (G_OBJECT (details_dialog),
991
G_CALLBACK (gtk_true), NULL);
993
g_object_unref (dialog);
994
g_object_unref (client);
997
gtk_window_present (GTK_WINDOW (details_dialog));
999
#endif /* HAVE_XFT2 */
1002
main (int argc, char *argv[])
1004
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
1005
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1006
textdomain (GETTEXT_PACKAGE);
1008
gnome_program_init ("gnome-font-properties", VERSION,
1009
LIBGNOMEUI_MODULE, argc, argv,
1010
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
1013
activate_settings_daemon ();