]> Pileus Git - ~andy/gtk/blob - gtk/gtkfontchooser.h
718f822b8a4accc49ba532330ad2fe655aac8a8e
[~andy/gtk] / gtk / gtkfontchooser.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2011      Alberto Ruiz <aruiz@gnome.org>
3  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4  *
5  * GtkFontChooser widget for Gtk+, by Damon Chaplin, May 1998.
6  * Based on the GnomeFontSelector widget, by Elliot Lee, but major changes.
7  * The GnomeFontSelector was derived from app/text_tool.c in the GIMP.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the
21  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22  * Boston, MA 02111-1307, USA.
23  */
24
25 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
26 #error "Only <gtk/gtk.h> can be included directly."
27 #endif
28
29 #ifndef __GTK_FONT_CHOOSER_H__
30 #define __GTK_FONT_CHOOSER_H__
31
32
33 #include <gtk/gtkdialog.h>
34 #include <gtk/gtkvbox.h>
35
36
37 G_BEGIN_DECLS
38
39 #define GTK_TYPE_FONT_CHOOSER              (gtk_font_chooser_get_type ())
40 #define GTK_FONT_CHOOSER(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_CHOOSER, GtkFontChooser))
41 #define GTK_FONT_CHOOSER_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FONT_CHOOSER, GtkFontChooserClass))
42 #define GTK_IS_FONT_CHOOSER(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_CHOOSER))
43 #define GTK_IS_FONT_CHOOSER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FONT_CHOOSER))
44 #define GTK_FONT_CHOOSER_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FONT_CHOOSER, GtkFontChooserClass))
45
46
47 #define GTK_TYPE_FONT_CHOOSER_DIALOG              (gtk_font_chooser_dialog_get_type ())
48 #define GTK_FONT_CHOOSER_DIALOG(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FONT_CHOOSER_DIALOG, GtkFontChooserDialog))
49 #define GTK_FONT_CHOOSER_DIALOG_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FONT_CHOOSER_DIALOG, GtkFontChooserDialogClass))
50 #define GTK_IS_FONT_CHOOSER_DIALOG(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FONT_CHOOSER_DIALOG))
51 #define GTK_IS_FONT_CHOOSER_DIALOG_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FONT_CHOOSER_DIALOG))
52 #define GTK_FONT_CHOOSER_DIALOG_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FONT_CHOOSER_DIALOG, GtkFontChooserDialogClass))
53
54
55 typedef struct _GtkFontChooser              GtkFontChooser;
56 typedef struct _GtkFontChooserPrivate       GtkFontChooserPrivate;
57 typedef struct _GtkFontChooserClass         GtkFontChooserClass;
58
59 typedef struct _GtkFontChooserDialog              GtkFontChooserDialog;
60 typedef struct _GtkFontChooserDialogPrivate       GtkFontChooserDialogPrivate;
61 typedef struct _GtkFontChooserDialogClass         GtkFontChooserDialogClass;
62
63 struct _GtkFontChooser
64 {
65   GtkVBox parent_instance;
66
67   /*< private >*/
68   GtkFontChooserPrivate *priv;
69 };
70
71 struct _GtkFontChooserClass
72 {
73   GtkVBoxClass parent_class;
74
75   /* Padding for future expansion */
76   void (*_gtk_reserved1) (void);
77   void (*_gtk_reserved2) (void);
78   void (*_gtk_reserved3) (void);
79   void (*_gtk_reserved4) (void);
80 };
81
82
83 struct _GtkFontChooserDialog
84 {
85   GtkDialog parent_instance;
86
87   /*< private >*/
88   GtkFontChooserDialogPrivate *priv;
89 };
90
91 struct _GtkFontChooserDialogClass
92 {
93   GtkDialogClass parent_class;
94
95   /* Padding for future expansion */
96   void (*_gtk_reserved1) (void);
97   void (*_gtk_reserved2) (void);
98   void (*_gtk_reserved3) (void);
99   void (*_gtk_reserved4) (void);
100 };
101
102
103
104 /*****************************************************************************
105  * GtkFontChooser functions.
106  *   see the comments in the GtkFontChooserDialog functions.
107  *****************************************************************************/
108
109 GType        gtk_font_chooser_get_type                 (void) G_GNUC_CONST;
110 GtkWidget*   gtk_font_chooser_new                      (void);
111 PangoFontFamily*
112              gtk_font_chooser_get_family               (GtkFontChooser *fontchooser);
113 PangoFontFace*
114              gtk_font_chooser_get_face                 (GtkFontChooser *fontchooser);
115 gint         gtk_font_chooser_get_size                 (GtkFontChooser *fontchooser);
116 gchar*       gtk_font_chooser_get_font_name            (GtkFontChooser *fontchooser);
117
118 gboolean     gtk_font_chooser_set_font_name            (GtkFontChooser *fontchooser,
119                                                         const gchar    *fontname);
120 const gchar* gtk_font_chooser_get_preview_text         (GtkFontChooser *fontchooser);
121 void         gtk_font_chooser_set_preview_text         (GtkFontChooser *fontchooser,
122                                                         const gchar    *text);
123 gboolean     gtk_font_chooser_get_show_preview_entry   (GtkFontChooser *fontchooser);
124 void         gtk_font_chooser_set_show_preview_entry   (GtkFontChooser *fontchooser,
125                                                         gboolean        show_preview_entry);
126 /*****************************************************************************
127  * GtkFontChooserDialog functions.
128  *   most of these functions simply call the corresponding function in the
129  *   GtkFontChooser.
130  *****************************************************************************/
131
132 GType        gtk_font_chooser_dialog_get_type         (void) G_GNUC_CONST;
133 GtkWidget* gtk_font_chooser_dialog_new              (const gchar            *title);
134
135 GtkWidget* gtk_font_chooser_dialog_get_font_selection (GtkFontChooserDialog *fcd);
136
137 /* This returns the X Logical Font Description fontname, or NULL if no font
138    is selected. Note that there is a slight possibility that the font might not
139    have been loaded OK. You should call gtk_font_chooser_dialog_get_font()
140    to see if it has been loaded OK.
141    You should g_free() the returned font name after you're done with it. */
142 gchar*     gtk_font_chooser_dialog_get_font_name     (GtkFontChooserDialog *fcd);
143
144 /* This sets the currently displayed font. It should be a valid X Logical
145    Font Description font name (anything else will be ignored), e.g.
146    "-adobe-courier-bold-o-normal--25-*-*-*-*-*-*-*" 
147    It returns TRUE on success. */
148 gboolean   gtk_font_chooser_dialog_set_font_name     (GtkFontChooserDialog *fcd,
149                                                       const gchar          *fontname);
150
151 /* This returns the text in the preview entry. You should copy the returned
152    text if you need it. */
153 G_CONST_RETURN gchar* 
154           gtk_font_chooser_dialog_get_preview_text   (GtkFontChooserDialog *fcd);
155
156 /* This sets the text in the preview entry. It will be copied by the entry,
157    so there's no need to g_strdup() it first. */
158 void      gtk_font_chooser_dialog_set_preview_text   (GtkFontChooserDialog *fcd,
159                                                     const gchar          *text);
160
161 G_END_DECLS
162
163
164 #endif /* __GTK_FONTSEL_H__ */