ToolPalette
open class ToolPalette : Container, ToolPaletteProtocol
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 ToolPalette
type acts as a reference-counted owner of an underlying GtkToolPalette
instance.
It provides the methods that can operate on this data type through ToolPaletteProtocol
conformance.
Use ToolPalette
as a strong reference or owner of a GtkToolPalette
instance.
-
Designated initialiser from the underlying `C` data type.
This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the
ToolPalette
instance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GtkToolPalette>)
Parameters
op
pointer to the underlying object
-
Designated initialiser from a constant pointer to the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theToolPalette
instance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GtkToolPalette>)
Parameters
op
pointer to the underlying object
-
Optional initialiser from a non-mutating
gpointer
to the underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theToolPalette
instance.Declaration
Swift
@inlinable override public init!(gpointer op: gpointer?)
Parameters
op
gpointer to the underlying object
-
Optional initialiser from a non-mutating
gconstpointer
to the underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theToolPalette
instance.Declaration
Swift
@inlinable override public init!(gconstpointer op: gconstpointer?)
Parameters
op
pointer to the underlying object
-
Optional initialiser from a constant pointer to the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theToolPalette
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GtkToolPalette>?)
Parameters
op
pointer to the underlying object
-
Optional initialiser from the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theToolPalette
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GtkToolPalette>?)
Parameters
op
pointer to the underlying object
-
Designated initialiser from the underlying
C
data type. Will retainGtkToolPalette
. i.e., ownership is transferred to theToolPalette
instance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GtkToolPalette>)
Parameters
op
pointer to the underlying object
-
Reference intialiser for a related type that implements
ToolPaletteProtocol
Will retainGtkToolPalette
.Declaration
Swift
@inlinable public init<T>(toolPalette other: T) where T : ToolPaletteProtocol
Parameters
other
an instance of a related type that implements
ToolPaletteProtocol
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ToolPaletteProtocol
.Declaration
Swift
@inlinable override public init<T>(cPointer p: UnsafeMutablePointer<T>)
Parameters
cPointer
pointer to the underlying object
-
Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ToolPaletteProtocol
.Declaration
Swift
@inlinable override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)
Parameters
cPointer
pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ToolPaletteProtocol
.Declaration
Swift
@inlinable override public init(raw p: UnsafeRawPointer)
Parameters
p
raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ToolPaletteProtocol
.Declaration
Swift
@inlinable override public init(retainingRaw raw: UnsafeRawPointer)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ToolPaletteProtocol
.Declaration
Swift
@inlinable public required init(raw p: UnsafeMutableRawPointer)
Parameters
p
mutable raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ToolPaletteProtocol
.Declaration
Swift
@inlinable required public init(retainingRaw raw: UnsafeMutableRawPointer)
Parameters
raw
mutable raw pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ToolPaletteProtocol
.Declaration
Swift
@inlinable override public init(opaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ToolPaletteProtocol
.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object
-
Creates a new tool palette.
Declaration
Swift
@inlinable public init()