FontChooserProtocol
public protocol FontChooserProtocol
GtkFontChooser
is an interface that can be implemented by widgets
for choosing fonts.
In GTK, the main objects that implement this interface are
[classGtk.FontChooserWidget
], [classGtk.FontChooserDialog
] and
[classGtk.FontButton
].
The FontChooserProtocol
protocol exposes the methods and properties of an underlying GtkFontChooser
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see FontChooser
.
Alternatively, use FontChooserRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkFontChooser
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
font_chooser_ptr
Default implementationTyped pointer to the underlying
GtkFontChooser
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkFontChooser
instance.Declaration
Swift
var font_chooser_ptr: UnsafeMutablePointer<GtkFontChooser>! { get }
-
Required Initialiser for types conforming to
FontChooserProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
FontChooserPropertyName
source property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: FontChooserPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol
Parameters
source_property
the source property to bind
target
the target object to bind to
target_property
the target property to bind to
flags
the flags to pass to the
Binding
transform_from
ValueTransformer
to use for forward transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a FontChooser property
Declaration
Swift
@inlinable func get(property: FontChooserPropertyName) -> GLibObject.Value
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
set(property:
Extension methodvalue: ) Set the value of a FontChooser property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: FontChooserPropertyName, value v: GLibObject.Value)
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
connect(signal:
Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
FontChooserSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: FontChooserSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
handler
The Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:
Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
FontChooserSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: FontChooserSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
signalHandler
The C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onFontActivated(flags:
Extension methodhandler: ) Emitted when a font is activated.
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.
Note
This represents the underlyingfont-activated
signalDeclaration
Swift
@discardableResult @inlinable func onFontActivated(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: FontChooserRef, _ fontname: String) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
fontname
the font name
handler
The signal handler to call Run the given callback whenever the
fontActivated
signal is emitted -
fontActivatedSignal
Extension methodTyped
font-activated
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var fontActivatedSignal: FontChooserSignalName { get }
-
onNotifyFont(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::font
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyFont(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: FontChooserRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyFont
signal is emitted -
notifyFontSignal
Extension methodTyped
notify::font
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyFontSignal: FontChooserSignalName { get }
-
onNotifyFontDesc(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::font-desc
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyFontDesc(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: FontChooserRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyFontDesc
signal is emitted -
notifyFontDescSignal
Extension methodTyped
notify::font-desc
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyFontDescSignal: FontChooserSignalName { get }
-
onNotifyFontFeatures(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::font-features
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyFontFeatures(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: FontChooserRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyFontFeatures
signal is emitted -
notifyFontFeaturesSignal
Extension methodTyped
notify::font-features
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyFontFeaturesSignal: FontChooserSignalName { get }
-
onNotifyLanguage(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::language
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyLanguage(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: FontChooserRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyLanguage
signal is emitted -
notifyLanguageSignal
Extension methodTyped
notify::language
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyLanguageSignal: FontChooserSignalName { get }
-
onNotifyLevel(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::level
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyLevel(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: FontChooserRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyLevel
signal is emitted -
notifyLevelSignal
Extension methodTyped
notify::level
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyLevelSignal: FontChooserSignalName { get }
-
onNotifyPreviewText(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::preview-text
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyPreviewText(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: FontChooserRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyPreviewText
signal is emitted -
notifyPreviewTextSignal
Extension methodTyped
notify::preview-text
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyPreviewTextSignal: FontChooserSignalName { get }
-
onNotifyShowPreviewEntry(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::show-preview-entry
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyShowPreviewEntry(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: FontChooserRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyShowPreviewEntry
signal is emitted -
notifyShowPreviewEntrySignal
Extension methodTyped
notify::show-preview-entry
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyShowPreviewEntrySignal: FontChooserSignalName { get }
-
getFont()
Extension methodGets the currently-selected font name.
Note that this can be a different string than what you set with [method
Gtk.FontChooser.set_font
], as the font chooser widget may normalize font names and thus return a string with a different structure. For example, “Helvetica Italic Bold 12” could be normalized to “Helvetica Bold Italic 12”.Use [method
Pango.FontDescription.equal
] if you want to compare two font descriptions.Declaration
Swift
@inlinable func getFont() -> String!
-
getFontDesc()
Extension methodGets the currently-selected font.
Note that this can be a different string than what you set with [method
Gtk.FontChooser.set_font
], as the font chooser widget may normalize font names and thus return a string with a different structure. For example, “Helvetica Italic Bold 12” could be normalized to “Helvetica Bold Italic 12”.Use [method
Pango.FontDescription.equal
] if you want to compare two font descriptions.Declaration
Swift
@inlinable func getFontDesc() -> Pango.FontDescriptionRef!
-
getFontFace()
Extension methodGets the
PangoFontFace
representing the selected font group details (i.e. family, slant, weight, width, etc).If the selected font is not installed, returns
nil
.Declaration
Swift
@inlinable func getFontFace() -> Pango.FontFaceRef!
-
getFontFamily()
Extension methodGets the
PangoFontFamily
representing the selected font family.Font families are a collection of font faces.
If the selected font is not installed, returns
nil
.Declaration
Swift
@inlinable func getFontFamily() -> Pango.FontFamilyRef!
-
getFontFeatures()
Extension methodGets the currently-selected font features.
Declaration
Swift
@inlinable func getFontFeatures() -> String!
-
getFontMap()
Extension methodGets the custom font map of this font chooser widget, or
nil
if it does not have one.Declaration
Swift
@inlinable func getFontMap() -> Pango.FontMapRef!
-
getFontSize()
Extension methodThe selected font size.
Declaration
Swift
@inlinable func getFontSize() -> Int
-
getLanguage()
Extension methodGets the language that is used for font features.
Declaration
Swift
@inlinable func getLanguage() -> String!
-
getLevel()
Extension methodReturns the current level of granularity for selecting fonts.
Declaration
Swift
@inlinable func getLevel() -> FontChooserLevel
-
getPreviewText()
Extension methodGets the text displayed in the preview area.
Declaration
Swift
@inlinable func getPreviewText() -> String!
-
getShowPreviewEntry()
Extension methodReturns whether the preview entry is shown or not.
Declaration
Swift
@inlinable func getShowPreviewEntry() -> Bool
-
setFilterFunc(filter:
Extension methoduserData: destroy: ) Adds a filter function that decides which fonts to display in the font chooser.
Declaration
Swift
@inlinable func setFilterFunc(filter: GtkFontFilterFunc? = nil, userData: gpointer! = nil, destroy: GDestroyNotify?)
-
setFont(fontname:
Extension method) Sets the currently-selected font.
Declaration
Swift
@inlinable func setFont(fontname: UnsafePointer<CChar>!)
-
set(fontDesc:
Extension method) Sets the currently-selected font from
font_desc
.Declaration
Swift
@inlinable func set<FontDescriptionT>(fontDesc: FontDescriptionT) where FontDescriptionT : FontDescriptionProtocol
-
setFontMap(fontmap:
Extension method) 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.
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);
Declaration
Swift
@inlinable func setFontMap(fontmap: Pango.FontMapRef? = nil)
-
setFontMap(fontmap:
Extension method) 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.
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);
Declaration
Swift
@inlinable func setFontMap<FontMapT>(fontmap: FontMapT?) where FontMapT : FontMapProtocol
-
set(language:
Extension method) Sets the language to use for font features.
Declaration
Swift
@inlinable func set(language: UnsafePointer<CChar>!)
-
set(level:
Extension method) Sets the desired level of granularity for selecting fonts.
Declaration
Swift
@inlinable func set(level: FontChooserLevel)
-
setPreview(text:
Extension method) Sets the text displayed in the preview area.
The
text
is used to show how the selected font looks.Declaration
Swift
@inlinable func setPreview(text: UnsafePointer<CChar>!)
-
set(showPreviewEntry:
Extension method) Shows or hides the editable preview entry.
Declaration
Swift
@inlinable func set(showPreviewEntry: Bool)
-
font
Extension methodThe font description as a string, e.g. “Sans Italic 12”.
Declaration
Swift
@inlinable var font: String! { get nonmutating set }
-
fontDesc
Extension methodGets the currently-selected font.
Note that this can be a different string than what you set with [method
Gtk.FontChooser.set_font
], as the font chooser widget may normalize font names and thus return a string with a different structure. For example, “Helvetica Italic Bold 12” could be normalized to “Helvetica Bold Italic 12”.Use [method
Pango.FontDescription.equal
] if you want to compare two font descriptions.Declaration
Swift
@inlinable var fontDesc: Pango.FontDescriptionRef! { get nonmutating set }
-
fontFace
Extension methodGets the
PangoFontFace
representing the selected font group details (i.e. family, slant, weight, width, etc).If the selected font is not installed, returns
nil
.Declaration
Swift
@inlinable var fontFace: Pango.FontFaceRef! { get }
-
fontFamily
Extension methodGets the
PangoFontFamily
representing the selected font family.Font families are a collection of font faces.
If the selected font is not installed, returns
nil
.Declaration
Swift
@inlinable var fontFamily: Pango.FontFamilyRef! { get }
-
fontFeatures
Extension methodGets the currently-selected font features.
Declaration
Swift
@inlinable var fontFeatures: String! { get }
-
fontMap
Extension methodGets the custom font map of this font chooser widget, or
nil
if it does not have one.Declaration
Swift
@inlinable var fontMap: Pango.FontMapRef! { get nonmutating set }
-
fontSize
Extension methodThe selected font size.
Declaration
Swift
@inlinable var fontSize: Int { get }
-
language
Extension methodThe language for which the font features were selected.
Declaration
Swift
@inlinable var language: String! { get nonmutating set }
-
level
Extension methodThe level of granularity to offer for selecting fonts.
Declaration
Swift
@inlinable var level: FontChooserLevel { get nonmutating set }
-
previewText
Extension methodGets the text displayed in the preview area.
Declaration
Swift
@inlinable var previewText: String! { get nonmutating set }
-
showPreviewEntry
Extension methodReturns whether the preview entry is shown or not.
Declaration
Swift
@inlinable var showPreviewEntry: Bool { get nonmutating set }