1/* GTK - The GIMP Toolkit
2 * gtkfontchooser.h - Abstract interface for font file selectors GUIs
3 *
4 * Copyright (C) 2006, Emmanuele Bassi
5 * Copyright (C) 2011 Alberto Ruiz <[email protected]>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser 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 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef __GTK_FONT_CHOOSER_H__
22#define __GTK_FONT_CHOOSER_H__
23
24#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
25#error "Only <gtk/gtk.h> can be included directly."
26#endif
27
28#include <gtk/gtkwidget.h>
29
30G_BEGIN_DECLS
31
32/**
33 * GtkFontFilterFunc:
34 * @family: a #PangoFontFamily
35 * @face: a #PangoFontFace belonging to @family
36 * @data: (closure): user data passed to gtk_font_chooser_set_filter_func()
37 *
38 * The type of function that is used for deciding what fonts get
39 * shown in a #GtkFontChooser. See gtk_font_chooser_set_filter_func().
40 *
41 * Returns: %TRUE if the font should be displayed
42 */
43typedef gboolean (*GtkFontFilterFunc) (const PangoFontFamily *family,
44 const PangoFontFace *face,
45 gpointer data);
46
47/**
48 * GtkFontChooserLevel:
49 * @GTK_FONT_CHOOSER_LEVEL_FAMILY: Allow selecting a font family
50 * @GTK_FONT_CHOOSER_LEVEL_STYLE: Allow selecting a specific font face
51 * @GTK_FONT_CHOOSER_LEVEL_SIZE: Allow selecting a specific font size
52 * @GTK_FONT_CHOOSER_LEVEL_VARIATION: Allow changing OpenType font variation axes
53 * @GTK_FONT_CHOOSER_LEVEL_FEATURES: Allow selecting specific OpenType font features
54 *
55 * This enumeration specifies the granularity of font selection
56 * that is desired in a font chooser.
57 *
58 * This enumeration may be extended in the future; applications should
59 * ignore unknown values.
60 */
61typedef enum {
62 GTK_FONT_CHOOSER_LEVEL_FAMILY = 0,
63 GTK_FONT_CHOOSER_LEVEL_STYLE = 1 << 0,
64 GTK_FONT_CHOOSER_LEVEL_SIZE = 1 << 1,
65 GTK_FONT_CHOOSER_LEVEL_VARIATIONS = 1 << 2,
66 GTK_FONT_CHOOSER_LEVEL_FEATURES = 1 << 3
67} GtkFontChooserLevel;
68
69#define GTK_TYPE_FONT_CHOOSER (gtk_font_chooser_get_type ())
70#define GTK_FONT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_CHOOSER, GtkFontChooser))
71#define GTK_IS_FONT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_CHOOSER))
72#define GTK_FONT_CHOOSER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FONT_CHOOSER, GtkFontChooserIface))
73
74typedef struct _GtkFontChooser GtkFontChooser; /* dummy */
75typedef struct _GtkFontChooserIface GtkFontChooserIface;
76
77struct _GtkFontChooserIface
78{
79 GTypeInterface base_iface;
80
81 /* Methods */
82 PangoFontFamily * (* get_font_family) (GtkFontChooser *fontchooser);
83 PangoFontFace * (* get_font_face) (GtkFontChooser *fontchooser);
84 gint (* get_font_size) (GtkFontChooser *fontchooser);
85
86 void (* set_filter_func) (GtkFontChooser *fontchooser,
87 GtkFontFilterFunc filter,
88 gpointer user_data,
89 GDestroyNotify destroy);
90
91 /* Signals */
92 void (* font_activated) (GtkFontChooser *chooser,
93 const gchar *fontname);
94
95 /* More methods */
96 void (* set_font_map) (GtkFontChooser *fontchooser,
97 PangoFontMap *fontmap);
98 PangoFontMap * (* get_font_map) (GtkFontChooser *fontchooser);
99
100 /* Padding */
101 gpointer padding[10];
102};
103
104GDK_AVAILABLE_IN_3_2
105GType gtk_font_chooser_get_type (void) G_GNUC_CONST;
106
107GDK_AVAILABLE_IN_3_2
108PangoFontFamily *gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser);
109GDK_AVAILABLE_IN_3_2
110PangoFontFace *gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser);
111GDK_AVAILABLE_IN_3_2
112gint gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser);
113
114GDK_AVAILABLE_IN_3_2
115PangoFontDescription *
116 gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser);
117GDK_AVAILABLE_IN_3_2
118void gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser,
119 const PangoFontDescription *font_desc);
120
121GDK_AVAILABLE_IN_3_2
122gchar* gtk_font_chooser_get_font (GtkFontChooser *fontchooser);
123
124GDK_AVAILABLE_IN_3_2
125void gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
126 const gchar *fontname);
127GDK_AVAILABLE_IN_3_2
128gchar* gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser);
129GDK_AVAILABLE_IN_3_2
130void gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
131 const gchar *text);
132GDK_AVAILABLE_IN_3_2
133gboolean gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser);
134GDK_AVAILABLE_IN_3_2
135void gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
136 gboolean show_preview_entry);
137GDK_AVAILABLE_IN_3_2
138void gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser,
139 GtkFontFilterFunc filter,
140 gpointer user_data,
141 GDestroyNotify destroy);
142GDK_AVAILABLE_IN_3_18
143void gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser,
144 PangoFontMap *fontmap);
145GDK_AVAILABLE_IN_3_18
146PangoFontMap * gtk_font_chooser_get_font_map (GtkFontChooser *fontchooser);
147
148GDK_AVAILABLE_IN_3_24
149void gtk_font_chooser_set_level (GtkFontChooser *fontchooser,
150 GtkFontChooserLevel level);
151GDK_AVAILABLE_IN_3_24
152GtkFontChooserLevel
153 gtk_font_chooser_get_level (GtkFontChooser *fontchooser);
154GDK_AVAILABLE_IN_3_24
155char * gtk_font_chooser_get_font_features (GtkFontChooser *fontchooser);
156GDK_AVAILABLE_IN_3_24
157char * gtk_font_chooser_get_language (GtkFontChooser *fontchooser);
158GDK_AVAILABLE_IN_3_24
159void gtk_font_chooser_set_language (GtkFontChooser *fontchooser,
160 const char *language);
161
162G_END_DECLS
163
164#endif /* __GTK_FONT_CHOOSER_H__ */
165