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.

  • ptr

    Untyped pointer to the underlying GtkToolPalette instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • tool_palette_ptr Default implementation

    Typed pointer to the underlying GtkToolPalette instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkToolPalette instance.

    Declaration

    Swift

    var tool_palette_ptr: UnsafeMutablePointer<GtkToolPalette>! { get }
  • Required Initialiser for types conforming to ToolPaletteProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

ToolPalette Class

  • Bind a ToolPalettePropertyName source 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 : 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 transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a ToolPalette property

    Declaration

    Swift

    @inlinable
    func get(property: ToolPalettePropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    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

    property

    the property to get the value for

    Return Value

    the value of the named property

ToolPalette Class: ToolPaletteProtocol extension (methods and fields)

  • Sets palette as drag source (see gtk_tool_palette_set_drag_source()) and sets widget as a drag destination for drags from palette. See gtk_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 GtkToolItem or a GtkToolItemGroup.

    Declaration

    Swift

    @inlinable
    func getDragItem<SelectionDataT>(selection: SelectionDataT) -> WidgetRef! where SelectionDataT : SelectionDataProtocol
  • getDropGroup(x:y:) Extension method

    Gets the group at position (x, y).

    Declaration

    Swift

    @inlinable
    func getDropGroup(x: Int, y: Int) -> ToolItemGroupRef!
  • getDropItem(x:y:) Extension method

    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 group is exclusive or not. See gtk_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 group in palette as index. See gtk_tool_palette_set_group_position().

    Declaration

    Swift

    @inlinable
    func getGroupPosition<ToolItemGroupT>(group: ToolItemGroupT) -> Int where ToolItemGroupT : ToolItemGroupProtocol
  • getHadjustment() Extension method

    Gets 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 method

    Gets the size of icons in the tool palette. See gtk_tool_palette_set_icon_size().

    Declaration

    Swift

    @inlinable
    func getIconSize() -> GtkIconSize
  • getStyle() Extension method

    Gets the style (icons, text or both) of items in the tool palette.

    Declaration

    Swift

    @inlinable
    func getStyle() -> GtkToolbarStyle
  • getVadjustment() Extension method

    Gets 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)
  • 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:expand:) Extension method

    Sets whether the group should be given extra space.

    Declaration

    Swift

    @inlinable
    func setExpand<ToolItemGroupT>(group: ToolItemGroupT, expand: Bool) where ToolItemGroupT : ToolItemGroupProtocol
  • 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 method

    Unsets 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 method

    Unsets 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()
  • hadjustment Extension method

    Gets the horizontal adjustment of the tool palette.

    get_hadjustment is deprecated: Use gtk_scrollable_get_hadjustment()

    Declaration

    Swift

    @inlinable
    var hadjustment: AdjustmentRef! { get }
  • iconSize Extension method

    Gets the size of icons in the tool palette. See gtk_tool_palette_set_icon_size().

    Declaration

    Swift

    @inlinable
    var iconSize: GtkIconSize { get nonmutating set }
  • style Extension method

    Gets the style (icons, text or both) of items in the tool palette.

    Declaration

    Swift

    @inlinable
    var style: GtkToolbarStyle { get nonmutating set }
  • vadjustment Extension method

    Gets the vertical adjustment of the tool palette.

    get_vadjustment is deprecated: Use gtk_scrollable_get_vadjustment()

    Declaration

    Swift

    @inlinable
    var vadjustment: AdjustmentRef! { get }
  • parentInstance Extension method

    Undocumented

    Declaration

    Swift

    @inlinable
    var parentInstance: GtkContainer { get }