ToolPaletteProtocol
public protocol ToolPaletteProtocol : ContainerProtocol, OrientableProtocol, ScrollableProtocol
A GtkToolPalette allows you to add GtkToolItems to a palette-like
container with different categories and drag and drop support.
A GtkToolPalette is created with a call to gtk_tool_palette_new().
GtkToolItems cannot be added directly to a GtkToolPalette -
instead they are added to a GtkToolItemGroup which can than be added
to a GtkToolPalette. To add a GtkToolItemGroup to a GtkToolPalette,
use gtk_container_add().
(C Language Example):
GtkWidget *palette, *group;
GtkToolItem *item;
palette = gtk_tool_palette_new ();
group = gtk_tool_item_group_new (_("Test Category"));
gtk_container_add (GTK_CONTAINER (palette), group);
item = gtk_tool_button_new (NULL, _("_Open"));
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "document-open");
gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);
The easiest way to use drag and drop with GtkToolPalette is to call
gtk_tool_palette_add_drag_dest() with the desired drag source palette
and the desired drag target widget. Then gtk_tool_palette_get_drag_item()
can be used to get the dragged item in the GtkWidget::drag-data-received
signal handler of the drag target.
(C Language Example):
static void
passive_canvas_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection,
guint info,
guint time,
gpointer data)
{
GtkWidget *palette;
GtkWidget *item;
// Get the dragged item
palette = gtk_widget_get_ancestor (gtk_drag_get_source_widget (context),
GTK_TYPE_TOOL_PALETTE);
if (palette != NULL)
item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (palette),
selection);
// Do something with item
}
GtkWidget *target, palette;
palette = gtk_tool_palette_new ();
target = gtk_drawing_area_new ();
g_signal_connect (G_OBJECT (target), "drag-data-received",
G_CALLBACK (passive_canvas_drag_data_received), NULL);
gtk_tool_palette_add_drag_dest (GTK_TOOL_PALETTE (palette), target,
GTK_DEST_DEFAULT_ALL,
GTK_TOOL_PALETTE_DRAG_ITEMS,
GDK_ACTION_COPY);
CSS nodes
GtkToolPalette has a single CSS node named toolpalette.
The ToolPaletteProtocol protocol exposes the methods and properties of an underlying GtkToolPalette 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 ToolPalette.
Alternatively, use ToolPaletteRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkToolPaletteinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
tool_palette_ptrDefault implementationTyped pointer to the underlying
GtkToolPaletteinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkToolPaletteinstance.Declaration
Swift
var tool_palette_ptr: UnsafeMutablePointer<GtkToolPalette>! { get } -
Required Initialiser for types conforming to
ToolPaletteProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
ToolPalettePropertyNamesource property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: ToolPalettePropertyName, 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 : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a ToolPalette property
Declaration
Swift
@inlinable func get(property: ToolPalettePropertyName) -> GLibObject.ValueParameters
propertythe property to get the value for
Return Value
the value of the named property
-
set(property:Extension methodvalue: ) Set the value of a ToolPalette property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: ToolPalettePropertyName, value v: GLibObject.Value)Parameters
propertythe property to get the value for
Return Value
the value of the named property
-
addDragDest(widget:Extension methodflags: targets: actions: ) Sets
paletteas drag source (seegtk_tool_palette_set_drag_source()) and setswidgetas a drag destination for drags frompalette. Seegtk_drag_dest_set().Declaration
Swift
@inlinable func addDragDest<WidgetT>(widget: WidgetT, flags: DestDefaults, targets: ToolPaletteDragTargets, actions: Gdk.DragAction) where WidgetT : WidgetProtocol -
getDragItem(selection:Extension method) Get the dragged item from the selection. This could be a
GtkToolItemor aGtkToolItemGroup.Declaration
Swift
@inlinable func getDragItem<SelectionDataT>(selection: SelectionDataT) -> WidgetRef! where SelectionDataT : SelectionDataProtocol -
getDropGroup(x:Extension methody: ) Gets the group at position (x, y).
Declaration
Swift
@inlinable func getDropGroup(x: Int, y: Int) -> ToolItemGroupRef! -
getDropItem(x:Extension methody: ) Gets the item at position (x, y). See
gtk_tool_palette_get_drop_group().Declaration
Swift
@inlinable func getDropItem(x: Int, y: Int) -> ToolItemRef! -
getExclusive(group:Extension method) Gets whether
groupis exclusive or not. Seegtk_tool_palette_set_exclusive().Declaration
Swift
@inlinable func getExclusive<ToolItemGroupT>(group: ToolItemGroupT) -> Bool where ToolItemGroupT : ToolItemGroupProtocol -
getExpand(group:Extension method) Gets whether group should be given extra space. See
gtk_tool_palette_set_expand().Declaration
Swift
@inlinable func getExpand<ToolItemGroupT>(group: ToolItemGroupT) -> Bool where ToolItemGroupT : ToolItemGroupProtocol -
getGroupPosition(group:Extension method) Gets the position of
groupinpaletteas index. Seegtk_tool_palette_set_group_position().Declaration
Swift
@inlinable func getGroupPosition<ToolItemGroupT>(group: ToolItemGroupT) -> Int where ToolItemGroupT : ToolItemGroupProtocol -
getHadjustment()Extension methodGets the horizontal adjustment of the tool palette.
get_hadjustment is deprecated: Use gtk_scrollable_get_hadjustment()
Declaration
Swift
@available(*, deprecated) @inlinable func getHadjustment() -> AdjustmentRef! -
getIconSize()Extension methodGets the size of icons in the tool palette. See
gtk_tool_palette_set_icon_size().Declaration
Swift
@inlinable func getIconSize() -> GtkIconSize -
getStyle()Extension methodGets the style (icons, text or both) of items in the tool palette.
Declaration
Swift
@inlinable func getStyle() -> GtkToolbarStyle -
getVadjustment()Extension methodGets the vertical adjustment of the tool palette.
get_vadjustment is deprecated: Use gtk_scrollable_get_vadjustment()
Declaration
Swift
@available(*, deprecated) @inlinable func getVadjustment() -> AdjustmentRef! -
setDragSource(targets:Extension method) Sets the tool palette as a drag source. Enables all groups and items in the tool palette as drag sources on button 1 and button 3 press with copy and move actions. See
gtk_drag_source_set().Declaration
Swift
@inlinable func setDragSource(targets: ToolPaletteDragTargets) -
setExclusive(group:Extension methodexclusive: ) Sets whether the group should be exclusive or not. If an exclusive group is expanded all other groups are collapsed.
Declaration
Swift
@inlinable func setExclusive<ToolItemGroupT>(group: ToolItemGroupT, exclusive: Bool) where ToolItemGroupT : ToolItemGroupProtocol -
setExpand(group:Extension methodexpand: ) Sets whether the group should be given extra space.
Declaration
Swift
@inlinable func setExpand<ToolItemGroupT>(group: ToolItemGroupT, expand: Bool) where ToolItemGroupT : ToolItemGroupProtocol -
setGroupPosition(group:Extension methodposition: ) Sets the position of the group as an index of the tool palette. If position is 0 the group will become the first child, if position is -1 it will become the last child.
Declaration
Swift
@inlinable func setGroupPosition<ToolItemGroupT>(group: ToolItemGroupT, position: Int) where ToolItemGroupT : ToolItemGroupProtocol -
set(iconSize:Extension method) Sets the size of icons in the tool palette.
Declaration
Swift
@inlinable func set(iconSize: GtkIconSize) -
set(style:Extension method) Sets the style (text, icons or both) of items in the tool palette.
Declaration
Swift
@inlinable func set(style: GtkToolbarStyle) -
unsetIconSize()Extension methodUnsets the tool palette icon size set with
gtk_tool_palette_set_icon_size(), so that user preferences will be used to determine the icon size.Declaration
Swift
@inlinable func unsetIconSize() -
unsetStyle()Extension methodUnsets a toolbar style set with
gtk_tool_palette_set_style(), so that user preferences will be used to determine the toolbar style.Declaration
Swift
@inlinable func unsetStyle() -
hadjustmentExtension methodGets the horizontal adjustment of the tool palette.
get_hadjustment is deprecated: Use gtk_scrollable_get_hadjustment()
Declaration
Swift
@inlinable var hadjustment: AdjustmentRef! { get } -
iconSizeExtension methodGets the size of icons in the tool palette. See
gtk_tool_palette_set_icon_size().Declaration
Swift
@inlinable var iconSize: GtkIconSize { get nonmutating set } -
styleExtension methodGets the style (icons, text or both) of items in the tool palette.
Declaration
Swift
@inlinable var style: GtkToolbarStyle { get nonmutating set } -
vadjustmentExtension methodGets the vertical adjustment of the tool palette.
get_vadjustment is deprecated: Use gtk_scrollable_get_vadjustment()
Declaration
Swift
@inlinable var vadjustment: AdjustmentRef! { get } -
parentInstanceExtension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GtkContainer { get }
View on GitHub
Install in Dash
ToolPaletteProtocol Protocol Reference