2011-04-15 20:07:32 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
2011-09-11 23:49:26 +00:00
|
|
|
* gtkfontchooser.c - Abstract interface for font file selectors GUIs
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006, Emmanuele Bassi
|
2011-05-03 23:14:31 +00:00
|
|
|
* Copyright (C) 2011 Alberto Ruiz <aruiz@gnome.org>
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2011-04-15 20:07:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2011-05-11 13:21:55 +00:00
|
|
|
#include "gtkfontchooser.h"
|
2011-09-11 23:49:26 +00:00
|
|
|
#include "gtkfontchooserprivate.h"
|
2011-04-15 20:07:32 +00:00
|
|
|
#include "gtkintl.h"
|
2011-09-11 23:49:26 +00:00
|
|
|
#include "gtktypebuiltins.h"
|
2011-04-15 20:07:32 +00:00
|
|
|
#include "gtkprivate.h"
|
|
|
|
|
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* GtkFontChooser:
|
|
|
|
*
|
|
|
|
* `GtkFontChooser` is an interface that can be implemented by widgets
|
|
|
|
* for choosing fonts.
|
|
|
|
*
|
|
|
|
* In GTK, the main objects that implement this interface are
|
|
|
|
* [class@Gtk.FontChooserWidget], [class@Gtk.FontChooserDialog] and
|
|
|
|
* [class@Gtk.FontButton].
|
2011-04-15 20:07:32 +00:00
|
|
|
*/
|
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
enum
|
2011-04-15 20:07:32 +00:00
|
|
|
{
|
2011-08-24 04:49:16 +00:00
|
|
|
SIGNAL_FONT_ACTIVATED,
|
2011-09-11 23:49:26 +00:00
|
|
|
LAST_SIGNAL
|
2011-08-24 04:49:16 +00:00
|
|
|
};
|
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
static guint chooser_signals[LAST_SIGNAL];
|
2011-04-18 21:20:15 +00:00
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
typedef GtkFontChooserIface GtkFontChooserInterface;
|
|
|
|
G_DEFINE_INTERFACE (GtkFontChooser, gtk_font_chooser, G_TYPE_OBJECT);
|
2011-04-15 20:07:32 +00:00
|
|
|
|
|
|
|
static void
|
2011-09-11 23:49:26 +00:00
|
|
|
gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
|
|
|
|
{
|
2011-09-11 22:13:26 +00:00
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* GtkFontChooser:font: (attributes org.gtk.Property.get=gtk_font_chooser_get_font org.gtk.Property.set=gtk_font_chooser_set_font)
|
2011-09-11 22:13:26 +00:00
|
|
|
*
|
|
|
|
* The font description as a string, e.g. "Sans Italic 12".
|
|
|
|
*/
|
2011-09-11 23:49:26 +00:00
|
|
|
g_object_interface_install_property
|
|
|
|
(iface,
|
2011-09-05 11:26:49 +00:00
|
|
|
g_param_spec_string ("font",
|
|
|
|
P_("Font"),
|
2016-10-03 16:20:03 +00:00
|
|
|
P_("Font description as a string, e.g. “Sans Italic 12”"),
|
2011-09-11 22:13:26 +00:00
|
|
|
GTK_FONT_CHOOSER_DEFAULT_FONT_NAME,
|
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* GtkFontChooser:font-desc: (attributes org.gtk.Property.get=gtk_font_chooser_get_font_desc org.gtk.Property.set=gtk_font_chooser_set_font_desc)
|
2011-09-11 22:13:26 +00:00
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* The font description as a `PangoFontDescription`.
|
2011-09-11 22:13:26 +00:00
|
|
|
*/
|
|
|
|
g_object_interface_install_property
|
|
|
|
(iface,
|
|
|
|
g_param_spec_boxed ("font-desc",
|
2011-09-16 08:41:24 +00:00
|
|
|
P_("Font description"),
|
2011-09-11 22:13:26 +00:00
|
|
|
P_("Font description as a PangoFontDescription struct"),
|
|
|
|
PANGO_TYPE_FONT_DESCRIPTION,
|
2011-09-11 23:49:26 +00:00
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
2011-09-11 22:13:26 +00:00
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* GtkFontChooser:preview-text: (attributes org.gtk.Property.get=gtk_font_chooser_get_preview_text org.gtk.Property.set=gtk_font_chooser_set_preview_text)
|
2011-09-11 22:13:26 +00:00
|
|
|
*
|
|
|
|
* The string with which to preview the font.
|
|
|
|
*/
|
2011-09-11 23:49:26 +00:00
|
|
|
g_object_interface_install_property
|
|
|
|
(iface,
|
|
|
|
g_param_spec_string ("preview-text",
|
|
|
|
P_("Preview text"),
|
|
|
|
P_("The text to display in order to demonstrate the selected font"),
|
|
|
|
pango_language_get_sample_string (NULL),
|
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
2011-09-11 22:13:26 +00:00
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* GtkFontChooser:show-preview-entry: (attributes org.gtk.Property.get=gtk_font_chooser_get_show_preview_entry org.gtk.Property.set=gtk_font_chooser_set_show_preview_entry)
|
2011-09-11 22:13:26 +00:00
|
|
|
*
|
|
|
|
* Whether to show an entry to change the preview text.
|
|
|
|
*/
|
2011-09-11 23:49:26 +00:00
|
|
|
g_object_interface_install_property
|
|
|
|
(iface,
|
|
|
|
g_param_spec_boolean ("show-preview-entry",
|
|
|
|
P_("Show preview text entry"),
|
|
|
|
P_("Whether the preview text entry is shown or not"),
|
|
|
|
TRUE,
|
2014-06-08 15:58:19 +00:00
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2011-05-04 19:29:26 +00:00
|
|
|
|
2017-12-21 15:51:04 +00:00
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* GtkFontChooser:level: (attributes org.gtk.Property.get=gtk_font_chooser_get_level org.gtk.Property.set=gtk_font_chooser_set_level)
|
2017-12-21 15:51:04 +00:00
|
|
|
*
|
|
|
|
* The level of granularity to offer for selecting fonts.
|
|
|
|
*/
|
|
|
|
g_object_interface_install_property
|
|
|
|
(iface,
|
2018-03-27 20:10:19 +00:00
|
|
|
g_param_spec_flags ("level",
|
|
|
|
P_("Selection level"),
|
|
|
|
P_("Whether to select family, face or font"),
|
|
|
|
GTK_TYPE_FONT_CHOOSER_LEVEL,
|
|
|
|
GTK_FONT_CHOOSER_LEVEL_FAMILY |
|
|
|
|
GTK_FONT_CHOOSER_LEVEL_STYLE |
|
2018-04-01 00:59:35 +00:00
|
|
|
GTK_FONT_CHOOSER_LEVEL_SIZE,
|
2018-03-27 20:10:19 +00:00
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2017-12-21 15:51:04 +00:00
|
|
|
|
2018-01-03 04:52:24 +00:00
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* GtkFontChooser:font-features: (attributes org.gtk.Property.get=gtk_font_chooser_get_font_features)
|
2018-01-03 04:52:24 +00:00
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* The selected font features.
|
|
|
|
*
|
|
|
|
* The format of the string is compatible with
|
2018-01-03 04:52:24 +00:00
|
|
|
* CSS and with Pango attributes.
|
|
|
|
*/
|
|
|
|
g_object_interface_install_property
|
|
|
|
(iface,
|
|
|
|
g_param_spec_string ("font-features",
|
|
|
|
P_("Font features"),
|
|
|
|
P_("Font features as a string"),
|
|
|
|
"",
|
|
|
|
GTK_PARAM_READABLE));
|
|
|
|
|
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* GtkFontChooser:language: (attributes org.gtk.Property.get=gtk_font_chooser_get_language org.gtk.Property.set=gtk_font_chooser_set_language)
|
2018-01-03 04:52:24 +00:00
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* The language for which the font features were selected.
|
2018-01-03 04:52:24 +00:00
|
|
|
*/
|
|
|
|
g_object_interface_install_property
|
|
|
|
(iface,
|
|
|
|
g_param_spec_string ("language",
|
|
|
|
P_("Language"),
|
|
|
|
P_("Language for which features have been selected"),
|
|
|
|
"",
|
2018-04-02 17:34:22 +00:00
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2018-01-03 04:52:24 +00:00
|
|
|
|
2011-08-24 04:49:16 +00:00
|
|
|
/**
|
2013-03-15 00:24:19 +00:00
|
|
|
* GtkFontChooser::font-activated:
|
2011-08-24 04:49:16 +00:00
|
|
|
* @self: the object which received the signal
|
|
|
|
* @fontname: the font name
|
|
|
|
*
|
2013-03-15 00:24:19 +00:00
|
|
|
* Emitted when a font is activated.
|
2021-02-26 21:11:01 +00:00
|
|
|
*
|
2011-08-24 04:49:16 +00:00
|
|
|
* This usually happens when the user double clicks an item,
|
|
|
|
* or an item is selected and the user presses one of the keys
|
|
|
|
* Space, Shift+Space, Return or Enter.
|
2011-09-11 23:49:26 +00:00
|
|
|
*/
|
|
|
|
chooser_signals[SIGNAL_FONT_ACTIVATED] =
|
2015-09-12 13:13:00 +00:00
|
|
|
g_signal_new (I_("font-activated"),
|
2011-08-24 04:49:16 +00:00
|
|
|
GTK_TYPE_FONT_CHOOSER,
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2011-09-11 23:49:26 +00:00
|
|
|
G_STRUCT_OFFSET (GtkFontChooserIface, font_activated),
|
2011-08-24 04:49:16 +00:00
|
|
|
NULL, NULL,
|
|
|
|
NULL,
|
|
|
|
G_TYPE_NONE,
|
|
|
|
1, G_TYPE_STRING);
|
2011-04-15 20:07:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-09-11 22:17:58 +00:00
|
|
|
* gtk_font_chooser_get_font_family:
|
2021-02-26 21:11:01 +00:00
|
|
|
* @fontchooser: a `GtkFontChooser`
|
|
|
|
*
|
|
|
|
* Gets the `PangoFontFamily` representing the selected font family.
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
2011-08-08 22:10:00 +00:00
|
|
|
* Font families are a collection of font faces.
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
2011-09-11 23:21:04 +00:00
|
|
|
* If the selected font is not installed, returns %NULL.
|
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* Returns: (nullable) (transfer none): A `PangoFontFamily` representing the
|
2021-05-21 00:45:06 +00:00
|
|
|
* selected font family
|
2011-04-15 20:07:32 +00:00
|
|
|
*/
|
|
|
|
PangoFontFamily *
|
2011-09-11 22:17:58 +00:00
|
|
|
gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser)
|
2011-04-15 20:07:32 +00:00
|
|
|
{
|
2011-05-11 13:21:55 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
|
2011-04-15 20:07:32 +00:00
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
return GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_family (fontchooser);
|
2011-04-15 20:07:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-09-11 22:17:58 +00:00
|
|
|
* gtk_font_chooser_get_font_face:
|
2021-02-26 21:11:01 +00:00
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* Gets the `PangoFontFace` representing the selected font group
|
2011-04-15 20:07:32 +00:00
|
|
|
* details (i.e. family, slant, weight, width, etc).
|
|
|
|
*
|
2011-09-11 23:21:04 +00:00
|
|
|
* If the selected font is not installed, returns %NULL.
|
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* Returns: (nullable) (transfer none): A `PangoFontFace` representing the
|
2021-05-21 00:45:06 +00:00
|
|
|
* selected font group details
|
2011-04-15 20:07:32 +00:00
|
|
|
*/
|
|
|
|
PangoFontFace *
|
2011-09-11 22:17:58 +00:00
|
|
|
gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser)
|
2011-04-15 20:07:32 +00:00
|
|
|
{
|
2011-05-11 13:21:55 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
|
2011-04-15 20:07:32 +00:00
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
return GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_face (fontchooser);
|
2011-04-15 20:07:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-09-11 22:17:58 +00:00
|
|
|
* gtk_font_chooser_get_font_size:
|
2021-02-26 21:11:01 +00:00
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
|
|
|
* The selected font size.
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: A n integer representing the selected font size,
|
2021-02-26 21:11:01 +00:00
|
|
|
* or -1 if no font size is selected.
|
2011-08-09 07:24:39 +00:00
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
int
|
2011-09-11 22:17:58 +00:00
|
|
|
gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser)
|
2011-04-15 20:07:32 +00:00
|
|
|
{
|
2011-05-11 13:21:55 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), -1);
|
2011-04-15 20:07:32 +00:00
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
return GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_size (fontchooser);
|
2011-04-15 20:07:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* gtk_font_chooser_get_font: (attributes org.gtk.Method.get_property=font)
|
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
2011-08-08 22:10:00 +00:00
|
|
|
* Gets the currently-selected font name.
|
|
|
|
*
|
|
|
|
* Note that this can be a different string than what you set with
|
2021-02-26 21:11:01 +00:00
|
|
|
* [method@Gtk.FontChooser.set_font], as the font chooser widget may
|
2011-08-08 22:10:00 +00:00
|
|
|
* normalize font names and thus return a string with a different
|
2014-02-05 18:07:34 +00:00
|
|
|
* structure. For example, “Helvetica Italic Bold 12” could be
|
|
|
|
* normalized to “Helvetica Bold Italic 12”.
|
2011-08-08 22:10:00 +00:00
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* Use [method@Pango.FontDescription.equal] if you want to compare two
|
2011-08-08 22:10:00 +00:00
|
|
|
* font descriptions.
|
|
|
|
*
|
2015-12-28 20:14:08 +00:00
|
|
|
* Returns: (nullable) (transfer full): A string with the name
|
2021-05-21 00:45:06 +00:00
|
|
|
* of the current font
|
2011-04-15 20:07:32 +00:00
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
char *
|
2011-09-05 11:26:49 +00:00
|
|
|
gtk_font_chooser_get_font (GtkFontChooser *fontchooser)
|
2011-04-15 20:07:32 +00:00
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *fontname;
|
2011-09-05 20:55:05 +00:00
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
|
2011-08-24 04:49:16 +00:00
|
|
|
|
2011-09-05 20:55:05 +00:00
|
|
|
g_object_get (fontchooser, "font", &fontname, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
return fontname;
|
2011-04-15 20:07:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* gtk_font_chooser_set_font: (attributes org.gtk.Method.set_property=font)
|
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2014-02-05 18:07:34 +00:00
|
|
|
* @fontname: a font name like “Helvetica 12” or “Times Bold 18”
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
2011-08-08 22:10:00 +00:00
|
|
|
* Sets the currently-selected font.
|
2011-04-15 20:07:32 +00:00
|
|
|
*/
|
2011-09-05 20:45:44 +00:00
|
|
|
void
|
2011-09-05 11:26:49 +00:00
|
|
|
gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *fontname)
|
2011-04-15 20:07:32 +00:00
|
|
|
{
|
2011-09-05 20:45:44 +00:00
|
|
|
g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
|
|
|
|
g_return_if_fail (fontname != NULL);
|
2011-04-15 20:07:32 +00:00
|
|
|
|
2011-09-05 20:55:05 +00:00
|
|
|
g_object_set (fontchooser, "font", fontname, NULL);
|
2011-04-15 20:07:32 +00:00
|
|
|
}
|
|
|
|
|
2011-09-11 22:13:26 +00:00
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* gtk_font_chooser_get_font_desc: (attributes org.gtk.Method.get_property=font-desc)
|
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2011-09-11 22:13:26 +00:00
|
|
|
*
|
|
|
|
* Gets the currently-selected font.
|
|
|
|
*
|
|
|
|
* Note that this can be a different string than what you set with
|
2021-02-26 21:11:01 +00:00
|
|
|
* [method@Gtk.FontChooser.set_font], as the font chooser widget may
|
2011-09-11 22:13:26 +00:00
|
|
|
* normalize font names and thus return a string with a different
|
2014-02-05 18:07:34 +00:00
|
|
|
* structure. For example, “Helvetica Italic Bold 12” could be
|
|
|
|
* normalized to “Helvetica Bold Italic 12”.
|
2011-09-11 22:13:26 +00:00
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* Use [method@Pango.FontDescription.equal] if you want to compare two
|
2011-09-11 22:13:26 +00:00
|
|
|
* font descriptions.
|
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* Returns: (nullable) (transfer full): A `PangoFontDescription` for the
|
2021-05-21 00:45:06 +00:00
|
|
|
* current font
|
2011-09-11 22:13:26 +00:00
|
|
|
*/
|
|
|
|
PangoFontDescription *
|
|
|
|
gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser)
|
|
|
|
{
|
|
|
|
PangoFontDescription *font_desc;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
|
|
|
|
|
|
|
|
g_object_get (fontchooser, "font-desc", &font_desc, NULL);
|
|
|
|
|
|
|
|
return font_desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* gtk_font_chooser_set_font_desc: (attributes org.gtk.Method.set_property=font-desc)
|
|
|
|
* @fontchooser: a `GtkFontChooser`
|
|
|
|
* @font_desc: a `PangoFontDescription`
|
2011-09-11 22:13:26 +00:00
|
|
|
*
|
|
|
|
* Sets the currently-selected font from @font_desc.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser,
|
|
|
|
const PangoFontDescription *font_desc)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
|
|
|
|
g_return_if_fail (font_desc != NULL);
|
|
|
|
|
|
|
|
g_object_set (fontchooser, "font-desc", font_desc, NULL);
|
|
|
|
}
|
|
|
|
|
2011-04-15 20:07:32 +00:00
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* gtk_font_chooser_get_preview_text: (attributes org.gtk.Method.get_property=preview-text)
|
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
|
|
|
* Gets the text displayed in the preview area.
|
2011-08-08 22:10:00 +00:00
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* Returns: (transfer full): the text displayed in the preview area
|
2011-04-15 20:07:32 +00:00
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
char *
|
2011-05-11 13:21:55 +00:00
|
|
|
gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser)
|
2011-04-15 20:07:32 +00:00
|
|
|
{
|
2011-09-11 23:49:26 +00:00
|
|
|
char *text;
|
|
|
|
|
2011-05-11 13:21:55 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
|
2011-08-08 22:10:00 +00:00
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
g_object_get (fontchooser, "preview-text", &text, NULL);
|
2011-04-15 20:07:32 +00:00
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
return text;
|
|
|
|
}
|
2011-04-15 20:07:32 +00:00
|
|
|
|
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* gtk_font_chooser_set_preview_text: (attributes org.gtk.Method.set_property=preview-text)
|
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2011-08-08 22:10:00 +00:00
|
|
|
* @text: (transfer none): the text to display in the preview area
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
|
|
|
* Sets the text displayed in the preview area.
|
2021-02-26 21:11:01 +00:00
|
|
|
*
|
2011-04-15 20:07:32 +00:00
|
|
|
* The @text is used to show how the selected font looks.
|
|
|
|
*/
|
|
|
|
void
|
2011-08-08 22:10:00 +00:00
|
|
|
gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *text)
|
2011-04-15 20:07:32 +00:00
|
|
|
{
|
2011-05-11 13:21:55 +00:00
|
|
|
g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
|
2011-04-15 20:07:32 +00:00
|
|
|
g_return_if_fail (text != NULL);
|
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
g_object_set (fontchooser, "preview-text", text, NULL);
|
2011-04-15 20:07:32 +00:00
|
|
|
}
|
|
|
|
|
2011-05-04 19:29:26 +00:00
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* gtk_font_chooser_get_show_preview_entry: (attributes org.gtk.Method.get_property=show-preview-entry)
|
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2011-05-04 19:29:26 +00:00
|
|
|
*
|
2011-08-08 22:10:00 +00:00
|
|
|
* Returns whether the preview entry is shown or not.
|
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* Returns: %TRUE if the preview entry is shown or %FALSE if it is hidden.
|
2011-05-04 19:29:26 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2011-05-11 13:21:55 +00:00
|
|
|
gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser)
|
2011-05-04 19:29:26 +00:00
|
|
|
{
|
2011-09-11 23:49:26 +00:00
|
|
|
gboolean show;
|
|
|
|
|
2011-05-11 13:21:55 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), FALSE);
|
2011-05-04 19:29:26 +00:00
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
g_object_get (fontchooser, "show-preview-entry", &show, NULL);
|
|
|
|
|
|
|
|
return show;
|
2011-05-04 19:29:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* gtk_font_chooser_set_show_preview_entry: (attributes org.gtk.Method.set_property=show-preview-entry)
|
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2011-05-04 19:29:26 +00:00
|
|
|
* @show_preview_entry: whether to show the editable preview entry or not
|
|
|
|
*
|
|
|
|
* Shows or hides the editable preview entry.
|
|
|
|
*/
|
|
|
|
void
|
2011-05-11 13:21:55 +00:00
|
|
|
gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser,
|
2011-07-25 17:16:55 +00:00
|
|
|
gboolean show_preview_entry)
|
2011-05-04 19:29:26 +00:00
|
|
|
{
|
2011-05-11 13:21:55 +00:00
|
|
|
g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
|
2011-05-04 19:29:26 +00:00
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
show_preview_entry = show_preview_entry != FALSE;
|
|
|
|
g_object_set (fontchooser, "show-preview-entry", show_preview_entry, NULL);
|
2011-05-04 19:29:26 +00:00
|
|
|
}
|
2011-08-15 02:20:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_font_chooser_set_filter_func:
|
2021-02-26 21:11:01 +00:00
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2021-05-21 00:45:06 +00:00
|
|
|
* @filter: (nullable): a `GtkFontFilterFunc`
|
2020-01-13 01:26:50 +00:00
|
|
|
* @user_data: (closure): data to pass to @filter
|
2011-08-15 02:20:00 +00:00
|
|
|
* @destroy: function to call to free @data when it is no longer needed
|
|
|
|
*
|
|
|
|
* Adds a filter function that decides which fonts to display
|
|
|
|
* in the font chooser.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser,
|
|
|
|
GtkFontFilterFunc filter,
|
2011-09-11 23:49:26 +00:00
|
|
|
gpointer user_data,
|
2011-08-15 02:20:00 +00:00
|
|
|
GDestroyNotify destroy)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
|
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->set_filter_func (fontchooser,
|
|
|
|
filter,
|
|
|
|
user_data,
|
|
|
|
destroy);
|
|
|
|
}
|
2011-08-15 02:20:00 +00:00
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
void
|
|
|
|
_gtk_font_chooser_font_activated (GtkFontChooser *chooser,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *fontname)
|
2011-09-11 23:49:26 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_FONT_CHOOSER (chooser));
|
2011-08-15 02:20:00 +00:00
|
|
|
|
2011-09-11 23:49:26 +00:00
|
|
|
g_signal_emit (chooser, chooser_signals[SIGNAL_FONT_ACTIVATED], 0, fontname);
|
2011-08-15 02:20:00 +00:00
|
|
|
}
|
2015-05-05 03:21:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_font_chooser_set_font_map:
|
2021-02-26 21:11:01 +00:00
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2021-05-19 11:24:34 +00:00
|
|
|
* @fontmap: (nullable): a `PangoFontMap`
|
2015-05-05 03:21:17 +00:00
|
|
|
*
|
|
|
|
* Sets a custom font map to use for this font chooser widget.
|
2021-02-26 21:11:01 +00:00
|
|
|
*
|
2015-05-05 03:21:17 +00:00
|
|
|
* A custom font map can be used to present application-specific
|
|
|
|
* fonts instead of or in addition to the normal system fonts.
|
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* ```c
|
2015-05-07 11:32:40 +00:00
|
|
|
* FcConfig *config;
|
|
|
|
* PangoFontMap *fontmap;
|
|
|
|
*
|
|
|
|
* config = FcInitLoadConfigAndFonts ();
|
|
|
|
* FcConfigAppFontAddFile (config, my_app_font_file);
|
|
|
|
*
|
|
|
|
* fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
|
|
|
|
* pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config);
|
|
|
|
*
|
|
|
|
* gtk_font_chooser_set_font_map (font_chooser, fontmap);
|
2021-02-26 21:11:01 +00:00
|
|
|
* ```
|
2015-05-07 11:32:40 +00:00
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* Note that other GTK widgets will only be able to use the
|
|
|
|
* application-specific font if it is present in the font map they use:
|
2015-05-07 11:32:40 +00:00
|
|
|
*
|
2021-02-26 21:11:01 +00:00
|
|
|
* ```c
|
2015-05-07 11:32:40 +00:00
|
|
|
* context = gtk_widget_get_pango_context (label);
|
|
|
|
* pango_context_set_font_map (context, fontmap);
|
2021-02-26 21:11:01 +00:00
|
|
|
* ```
|
2015-05-05 03:21:17 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser,
|
|
|
|
PangoFontMap *fontmap)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
|
|
|
|
g_return_if_fail (fontmap == NULL || PANGO_IS_FONT_MAP (fontmap));
|
|
|
|
|
2015-06-13 03:55:30 +00:00
|
|
|
if (GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->set_font_map)
|
|
|
|
GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->set_font_map (fontchooser, fontmap);
|
2015-05-05 03:21:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_font_chooser_get_font_map:
|
2021-02-26 21:11:01 +00:00
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2015-05-05 03:21:17 +00:00
|
|
|
*
|
|
|
|
* Gets the custom font map of this font chooser widget,
|
|
|
|
* or %NULL if it does not have one.
|
|
|
|
*
|
2021-05-21 00:45:06 +00:00
|
|
|
* Returns: (nullable) (transfer full): a `PangoFontMap`
|
2015-05-05 03:21:17 +00:00
|
|
|
*/
|
|
|
|
PangoFontMap *
|
|
|
|
gtk_font_chooser_get_font_map (GtkFontChooser *fontchooser)
|
|
|
|
{
|
2015-06-13 03:55:30 +00:00
|
|
|
PangoFontMap *fontmap = NULL;
|
2015-05-05 03:21:17 +00:00
|
|
|
|
2015-05-12 02:23:59 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
|
2015-05-05 03:21:17 +00:00
|
|
|
|
2015-06-13 03:55:30 +00:00
|
|
|
if (GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_map)
|
|
|
|
fontmap = GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->get_font_map (fontchooser);
|
2015-05-05 03:21:17 +00:00
|
|
|
|
|
|
|
return fontmap;
|
|
|
|
}
|
2017-12-21 15:51:04 +00:00
|
|
|
|
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* gtk_font_chooser_set_level: (attributes org.gtk.Method.set_property=level)
|
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2017-12-21 15:51:04 +00:00
|
|
|
* @level: the desired level of granularity
|
|
|
|
*
|
|
|
|
* Sets the desired level of granularity for selecting fonts.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_font_chooser_set_level (GtkFontChooser *fontchooser,
|
|
|
|
GtkFontChooserLevel level)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
|
|
|
|
|
|
|
|
g_object_set (fontchooser, "level", level, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* gtk_font_chooser_get_level: (attributes org.gtk.Method.get_property=level)
|
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2017-12-21 15:51:04 +00:00
|
|
|
*
|
|
|
|
* Returns the current level of granularity for selecting fonts.
|
|
|
|
*
|
|
|
|
* Returns: the current granularity level
|
|
|
|
*/
|
|
|
|
GtkFontChooserLevel
|
|
|
|
gtk_font_chooser_get_level (GtkFontChooser *fontchooser)
|
|
|
|
{
|
|
|
|
GtkFontChooserLevel level;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), 0);
|
|
|
|
|
|
|
|
g_object_get (fontchooser, "level", &level, NULL);
|
|
|
|
|
|
|
|
return level;
|
|
|
|
}
|
2018-01-03 04:52:24 +00:00
|
|
|
|
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* gtk_font_chooser_get_font_features: (attributes org.gtk.Method.get_property=font-features)
|
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2018-01-03 04:52:24 +00:00
|
|
|
*
|
|
|
|
* Gets the currently-selected font features.
|
|
|
|
*
|
|
|
|
* Returns: the currently selected font features
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
gtk_font_chooser_get_font_features (GtkFontChooser *fontchooser)
|
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
|
|
|
|
|
|
|
|
g_object_get (fontchooser, "font-features", &text, NULL);
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* gtk_font_chooser_get_language: (attributes org.gtk.Method.get_property=language)
|
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2018-01-03 04:52:24 +00:00
|
|
|
*
|
2018-04-02 17:34:22 +00:00
|
|
|
* Gets the language that is used for font features.
|
2018-01-03 04:52:24 +00:00
|
|
|
*
|
|
|
|
* Returns: the currently selected language
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
gtk_font_chooser_get_language (GtkFontChooser *fontchooser)
|
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), NULL);
|
|
|
|
|
|
|
|
g_object_get (fontchooser, "language", &text, NULL);
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
2018-04-02 17:34:22 +00:00
|
|
|
|
|
|
|
/**
|
2021-02-26 21:11:01 +00:00
|
|
|
* gtk_font_chooser_set_language: (attributes org.gtk.Method.set_property=language)
|
|
|
|
* @fontchooser: a `GtkFontChooser`
|
2018-04-02 17:34:22 +00:00
|
|
|
* @language: a language
|
|
|
|
*
|
|
|
|
* Sets the language to use for font features.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_font_chooser_set_language (GtkFontChooser *fontchooser,
|
|
|
|
const char *language)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
|
|
|
|
|
|
|
|
g_object_set (fontchooser, "language", language, NULL);
|
|
|
|
}
|