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"
|
|
|
|
|
|
|
|
/**
|
2011-05-11 13:21:55 +00:00
|
|
|
* SECTION:gtkfontchooser
|
2011-09-11 23:49:26 +00:00
|
|
|
* @Short_description: Interface implemented by widgets displaying fonts
|
2011-05-11 13:21:55 +00:00
|
|
|
* @Title: GtkFontChooser
|
2011-09-11 23:49:26 +00:00
|
|
|
* @See_also: #GtkFontChooserDialog, #GtkFontChooserWidget, #GtkFontButton
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
2011-09-11 23:49:26 +00:00
|
|
|
* #GtkFontChooser is an interface that can be implemented by widgets
|
2015-05-07 11:32:40 +00:00
|
|
|
* displaying the list of fonts. In GTK+, the main objects
|
2011-09-11 23:49:26 +00:00
|
|
|
* that implement this interface are #GtkFontChooserWidget,
|
2015-05-07 11:32:40 +00:00
|
|
|
* #GtkFontChooserDialog and #GtkFontButton. The GtkFontChooser interface
|
|
|
|
* has been introducted in GTK+ 3.2.
|
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
|
|
|
/**
|
|
|
|
* GtkFontChooser:font:
|
|
|
|
*
|
|
|
|
* 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"),
|
2011-09-11 22:13:26 +00:00
|
|
|
P_("Font description as a string, e.g. \"Sans Italic 12\""),
|
|
|
|
GTK_FONT_CHOOSER_DEFAULT_FONT_NAME,
|
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkFontChooser:font-desc:
|
|
|
|
*
|
|
|
|
* The font description as a #PangoFontDescription.
|
|
|
|
*/
|
|
|
|
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
|
|
|
/**
|
|
|
|
* GtkFontChooser:preview-text:
|
|
|
|
*
|
|
|
|
* 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
|
|
|
/**
|
|
|
|
* GtkFontChooser:show-preview-entry:
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
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.
|
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] =
|
2011-08-24 04:49:16 +00:00
|
|
|
g_signal_new ("font-activated",
|
|
|
|
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:
|
2011-05-11 13:21:55 +00:00
|
|
|
* @fontchooser: a #GtkFontChooser
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
|
|
|
* Gets the #PangoFontFamily representing the selected font family.
|
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.
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: (transfer none): A #PangoFontFamily representing the
|
2011-09-11 23:21:04 +00:00
|
|
|
* selected font family, or %NULL. The returned object is owned by @fontchooser
|
2011-08-08 22:10:00 +00:00
|
|
|
* and must not be modified or freed.
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
2011-05-11 13:59:23 +00:00
|
|
|
* Since: 3.2
|
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:
|
2011-05-11 13:21:55 +00:00
|
|
|
* @fontchooser: a #GtkFontChooser
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
|
|
|
* Gets the #PangoFontFace representing the selected font group
|
|
|
|
* 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.
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: (transfer none): A #PangoFontFace representing the
|
2011-09-11 23:21:04 +00:00
|
|
|
* selected font group details, or %NULL. The returned object is owned by
|
2011-05-11 13:21:55 +00:00
|
|
|
* @fontchooser and must not be modified or freed.
|
2011-04-15 20:07:32 +00:00
|
|
|
*
|
2011-05-11 13:59:23 +00:00
|
|
|
* Since: 3.2
|
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:
|
2011-05-11 13:21:55 +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,
|
2011-04-15 20:07:32 +00:00
|
|
|
* or -1 if no font size is selected.
|
|
|
|
*
|
2011-05-11 13:59:23 +00:00
|
|
|
* Since: 3.2
|
2011-08-09 07:24:39 +00:00
|
|
|
*/
|
2011-04-15 20:07:32 +00:00
|
|
|
gint
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-09-05 11:26:49 +00:00
|
|
|
* gtk_font_chooser_get_font:
|
2011-05-11 13:21:55 +00:00
|
|
|
* @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
|
2011-09-11 01:41:59 +00:00
|
|
|
* gtk_font_chooser_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
|
|
|
*
|
|
|
|
* Use pango_font_description_equal() if you want to compare two
|
|
|
|
* font descriptions.
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: (transfer full) (allow-none): A string with the name
|
2011-08-08 22:10:00 +00:00
|
|
|
* of the current font, or %NULL if no font is selected. You must
|
|
|
|
* free this string with g_free().
|
2011-05-11 13:59:23 +00:00
|
|
|
*
|
|
|
|
* Since: 3.2
|
2011-04-15 20:07:32 +00:00
|
|
|
*/
|
|
|
|
gchar *
|
2011-09-05 11:26:49 +00:00
|
|
|
gtk_font_chooser_get_font (GtkFontChooser *fontchooser)
|
2011-04-15 20:07:32 +00:00
|
|
|
{
|
2011-09-05 20:55:05 +00:00
|
|
|
gchar *fontname;
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-09-05 11:26:49 +00:00
|
|
|
* gtk_font_chooser_set_font:
|
2011-05-11 13:21:55 +00:00
|
|
|
* @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-05-11 13:59:23 +00:00
|
|
|
* Since: 3.2
|
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,
|
|
|
|
const gchar *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
|
|
|
/**
|
|
|
|
* gtk_font_chooser_get_font_desc:
|
|
|
|
* @fontchooser: a #GtkFontChooser
|
|
|
|
*
|
|
|
|
* Gets the currently-selected font.
|
|
|
|
*
|
|
|
|
* Note that this can be a different string than what you set with
|
|
|
|
* gtk_font_chooser_set_font(), as the font chooser widget may
|
|
|
|
* 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
|
|
|
*
|
|
|
|
* Use pango_font_description_equal() if you want to compare two
|
|
|
|
* font descriptions.
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: (transfer full) (allow-none): A #PangoFontDescription for the
|
2011-09-11 22:13:26 +00:00
|
|
|
* current font, or %NULL if no font is selected.
|
|
|
|
*
|
|
|
|
* Since: 3.2
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_font_chooser_set_font_desc:
|
|
|
|
* @fontchooser: a #GtkFontChooser
|
|
|
|
* @font_desc: a #PangoFontDescription
|
|
|
|
*
|
|
|
|
* Sets the currently-selected font from @font_desc.
|
|
|
|
*
|
|
|
|
* Since: 3.2
|
|
|
|
*/
|
|
|
|
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
|
|
|
/**
|
2011-05-11 13:21:55 +00:00
|
|
|
* gtk_font_chooser_get_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
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: (transfer full): the text displayed in the
|
2011-09-11 23:49:26 +00:00
|
|
|
* preview area
|
2011-05-11 13:59:23 +00:00
|
|
|
*
|
|
|
|
* Since: 3.2
|
2011-04-15 20:07:32 +00:00
|
|
|
*/
|
2011-09-11 23:49:26 +00:00
|
|
|
gchar *
|
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
|
|
|
|
|
|
|
/**
|
2011-05-11 13:21:55 +00:00
|
|
|
* gtk_font_chooser_set_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.
|
|
|
|
* The @text is used to show how the selected font looks.
|
2011-05-11 13:59:23 +00:00
|
|
|
*
|
|
|
|
* Since: 3.2
|
2011-04-15 20:07:32 +00:00
|
|
|
*/
|
|
|
|
void
|
2011-08-08 22:10:00 +00:00
|
|
|
gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
|
|
|
|
const gchar *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
|
|
|
/**
|
2011-05-11 13:21:55 +00:00
|
|
|
* gtk_font_chooser_get_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.
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: %TRUE if the preview entry is shown
|
2011-08-08 22:10:00 +00:00
|
|
|
* or %FALSE if it is hidden.
|
|
|
|
*
|
2011-05-04 19:29:26 +00:00
|
|
|
* Since: 3.2
|
|
|
|
*/
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-05-11 13:21:55 +00:00
|
|
|
* gtk_font_chooser_set_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.
|
2011-08-08 22:10:00 +00:00
|
|
|
*
|
2011-05-04 19:29:26 +00:00
|
|
|
* Since: 3.2
|
|
|
|
*/
|
|
|
|
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:
|
|
|
|
* @fontchooser: a #GtkFontChooser
|
|
|
|
* @filter: (allow-none): a #GtkFontFilterFunc, or %NULL
|
2011-09-11 23:49:26 +00:00
|
|
|
* @user_data: 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.
|
|
|
|
*
|
|
|
|
* Since: 3.2
|
|
|
|
*/
|
|
|
|
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,
|
|
|
|
const gchar *fontname)
|
|
|
|
{
|
|
|
|
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:
|
|
|
|
* @fontchooser: a #GtkFontChooser
|
|
|
|
* @fontmap: (allow-none): a #PangoFontMap
|
|
|
|
*
|
|
|
|
* Sets a custom font map to use for this font chooser widget.
|
|
|
|
* A custom font map can be used to present application-specific
|
|
|
|
* fonts instead of or in addition to the normal system fonts.
|
|
|
|
*
|
2015-05-07 11:32:40 +00:00
|
|
|
* |[<!-- language="C" -->
|
|
|
|
* 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);
|
|
|
|
* ]|
|
|
|
|
*
|
|
|
|
* 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:
|
|
|
|
*
|
|
|
|
* |[
|
|
|
|
* context = gtk_widget_get_pango_context (label);
|
|
|
|
* pango_context_set_font_map (context, fontmap);
|
|
|
|
* ]|
|
|
|
|
*
|
2015-05-05 03:21:17 +00:00
|
|
|
* Since: 3.18
|
|
|
|
*/
|
|
|
|
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:
|
|
|
|
* @fontchooser: a #GtkFontChooser
|
|
|
|
*
|
|
|
|
* Gets the custom font map of this font chooser widget,
|
|
|
|
* or %NULL if it does not have one.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full) (allow-none): a #PangoFontMap, or %NULL
|
|
|
|
*
|
|
|
|
* Since: 3.18
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|