gtk.tool_palette

Module for [ToolPalette] class

Types 3

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.ToolPalette.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.Container.add].

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.ToolPalette.addDragDest] with the desired drag source @palette and the desired drag target @widget. Then [gtk.tool_palette.ToolPalette.getDragItem] can be used to get the dragged item in the #GtkWidget::drag-data-received signal handler of the drag target.

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.

Methods
GType _gType() @property
ToolPalette self()Returns `this`, for use in `with` statements.
ToolPaletteGidBuilder builder()Get builder for [gtk.tool_palette.ToolPalette] Returns: New builder object
gtk.types.IconSize iconSize() @propertyGet `iconSize` property. Returns: The size of the icons in a tool palette. When this property is set, it overrides the default setting.
void iconSize(gtk.types.IconSize propval) @propertySet `iconSize` property. Params: propval = The size of the icons in a tool palette. When this property is set, it overrides the default setting.
bool iconSizeSet() @propertyGet `iconSizeSet` property. Returns: Is true if the #GtkToolPalette:icon-size property has been set.
void iconSizeSet(bool propval) @propertySet `iconSizeSet` property. Params: propval = Is true if the #GtkToolPalette:icon-size property has been set.
gtk.types.ToolbarStyle toolbarStyle() @propertyGet `toolbarStyle` property. Returns: The style of items in the tool palette.
void toolbarStyle(gtk.types.ToolbarStyle propval) @propertySet `toolbarStyle` property. Params: propval = The style of items in the tool palette.
gtk.target_entry.TargetEntry getDragTargetGroup()Get the target entry for a dragged #GtkToolItemGroup. Returns: the #GtkTargetEntry for a dragged group
gtk.target_entry.TargetEntry getDragTargetItem()Gets the target entry for a dragged #GtkToolItem. Returns: the #GtkTargetEntry for a dragged item.
void addDragDest(gtk.widget.Widget widget, gtk.types.DestDefaults flags, gtk.types.ToolPaletteDragTargets targets, gdk.types.DragAction actions)Sets palette as drag source (see [gtk.tool_palette.ToolPalette.setDragSource]) and sets widget as a drag destination for drags from palette. See [gtk.widget.Widget.dragDestSet].
gtk.widget.Widget getDragItem(gtk.selection_data.SelectionData selection)Get the dragged item from the selection. This could be a #GtkToolItem or a #GtkToolItemGroup.
gtk.tool_item_group.ToolItemGroup getDropGroup(int x, int y)Gets the group at position (x, y).
gtk.tool_item.ToolItem getDropItem(int x, int y)Gets the item at position (x, y). See [gtk.tool_palette.ToolPalette.getDropGroup].
bool getExclusive(gtk.tool_item_group.ToolItemGroup group)Gets whether group is exclusive or not. See [gtk.tool_palette.ToolPalette.setExclusive].
bool getExpand(gtk.tool_item_group.ToolItemGroup group)Gets whether group should be given extra space. See [gtk.tool_palette.ToolPalette.setExpand].
int getGroupPosition(gtk.tool_item_group.ToolItemGroup group)Gets the position of group in palette as index. See [gtk.tool_palette.ToolPalette.setGroupPosition].
gtk.adjustment.Adjustment getHadjustment()Gets the horizontal adjustment of the tool palette. Returns: the horizontal adjustment of palette
gtk.types.IconSize getIconSize()Gets the size of icons in the tool palette. See [gtk.tool_palette.ToolPalette.setIconSize]. Returns: the #GtkIconSize of icons in the tool palette
gtk.types.ToolbarStyle getStyle()Gets the style (icons, text or both) of items in the tool palette. Returns: the #GtkToolbarStyle of items in the tool palette.
gtk.adjustment.Adjustment getVadjustment()Gets the vertical adjustment of the tool palette. Returns: the vertical adjustment of palette
void setDragSource(gtk.types.ToolPaletteDragTargets targets)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.widget.Widget.dragSource...
void setExclusive(gtk.tool_item_group.ToolItemGroup group, bool exclusive)Sets whether the group should be exclusive or not. If an exclusive group is expanded all other groups are collapsed.
void setExpand(gtk.tool_item_group.ToolItemGroup group, bool expand)Sets whether the group should be given extra space.
void setGroupPosition(gtk.tool_item_group.ToolItemGroup group, int position)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.
void setIconSize(gtk.types.IconSize iconSize)Sets the size of icons in the tool palette.
void setStyle(gtk.types.ToolbarStyle style)Sets the style (text, icons or both) of items in the tool palette.
void unsetIconSize()Unsets the tool palette icon size set with [gtk.tool_palette.ToolPalette.setIconSize], so that user preferences will be used to determine the icon size.
void unsetStyle()Unsets a toolbar style set with [gtk.tool_palette.ToolPalette.setStyle], so that user preferences will be used to determine the toolbar style.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new tool palette. Returns: a new #GtkToolPalette
Methods
T iconSize(gtk.types.IconSize propval)Set `iconSize` property. Params: propval = The size of the icons in a tool palette. When this property is set, it overrides the default setting.
T iconSizeSet(bool propval)Set `iconSizeSet` property. Params: propval = Is true if the #GtkToolPalette:icon-size property has been set. Returns: Builder instance for fluent chaining
T toolbarStyle(gtk.types.ToolbarStyle propval)Set `toolbarStyle` property. Params: propval = The style of items in the tool palette. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.tool_palette.ToolPalette]