Adding upstream version 0.5.6.
[debian/lxappearance.git] / src / font.c
CommitLineData
6ec93802
DB
1// font.c
2//
3// Copyright 2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18// MA 02110-1301, USA.
19
20
21#include "lxappearance.h"
22#include "font.h"
23#include <glib/gi18n.h>
24
25static const char* font_hinting_style[]={
26 "hintnone",
27 "hintslight",
28 "hintmedium",
29 "hintfull"
30};
31
32static const char* font_rgba[]={
33 "none",
34 "rgb",
35 "bgr",
36 "vrgb",
37 "vbgr"
38 };
39
40static void on_hinting_style_changed(GtkComboBox* combo, gpointer user_data)
41{
42 gint pos_combo = gtk_combo_box_get_active(combo);
43 if (pos_combo >= 0)
44 {
45 app.hinting_style = font_hinting_style[pos_combo];
46 lxappearance_changed();
47 }
48
49}
50
51static void on_font_rgba_changed(GtkComboBox* combo, gpointer user_data)
52{
53 gint pos_combo = gtk_combo_box_get_active(combo);
54 if (pos_combo >= 0)
55 {
56 app.font_rgba = font_rgba[pos_combo];
57 lxappearance_changed();
58 }
59}
60
f80d2712 61static int convert_list_to_pos(const char* font, const char* list[])
6ec93802
DB
62{
63
f80d2712 64 int pos = -1, i;
6ec93802
DB
65
66 for (i = 0; i <= 3; i = i + 1)
67 {
68 if (g_strcmp0(list[i],font) == 0)
69 pos = i;
70 }
71
72 return pos ;
73
74}
75
76void font_init(GtkBuilder* b)
77{
78 int idx;
79 app.enable_antialising_check = GTK_WIDGET(gtk_builder_get_object(b, "enable_antialising"));
80 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.enable_antialising_check), app.enable_antialising);
81 g_signal_connect(app.enable_antialising_check, "toggled", G_CALLBACK(on_check_button_toggled), &app.enable_antialising);
82
83 app.enable_hinting_check = GTK_WIDGET(gtk_builder_get_object(b, "enable_hinting"));
84 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.enable_hinting_check), app.enable_hinting);
85 g_signal_connect(app.enable_hinting_check, "toggled", G_CALLBACK(on_check_button_toggled), &app.enable_hinting);
86
87 app.hinting_style_combo = GTK_WIDGET(gtk_builder_get_object(b, "hinting_style"));
88 idx = convert_list_to_pos(app.hinting_style, font_hinting_style);
89 gtk_combo_box_set_active(GTK_COMBO_BOX(app.hinting_style_combo), idx);
90 g_signal_connect(app.hinting_style_combo, "changed", G_CALLBACK(on_hinting_style_changed), NULL);
91
92 app.font_rgba_combo = GTK_WIDGET(gtk_builder_get_object(b, "font_rgba"));
93 idx = convert_list_to_pos(app.font_rgba, font_rgba);
94 gtk_combo_box_set_active(GTK_COMBO_BOX(app.font_rgba_combo), idx);
95 g_signal_connect(app.font_rgba_combo, "changed", G_CALLBACK(on_font_rgba_changed), NULL);
96
97}
98