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 _getGType() static nothrow
GType _gType() @property nothrow
ToolPalette self() nothrowReturns `this`, for use in `with` statements.
ToolPaletteGidBuilder builder() static nothrowGet builder for [gtk.tool_palette.ToolPalette] Returns: New builder object
gtk.types.IconSize iconSize() @property nothrowGet `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) @property nothrowSet `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() @property nothrowGet `iconSizeSet` property. Returns: Is true if the #GtkToolPalette:icon-size property has been set.
void iconSizeSet(bool propval) @property nothrowSet `iconSizeSet` property. Params: propval = Is true if the #GtkToolPalette:icon-size property has been set.
gtk.types.ToolbarStyle toolbarStyle() @property nothrowGet `toolbarStyle` property. Returns: The style of items in the tool palette.
void toolbarStyle(gtk.types.ToolbarStyle propval) @property nothrowSet `toolbarStyle` property. Params: propval = The style of items in the tool palette.
gtk.target_entry.TargetEntry getDragTargetGroup() static nothrowGet the target entry for a dragged #GtkToolItemGroup. Returns: the #GtkTargetEntry for a dragged group
gtk.target_entry.TargetEntry getDragTargetItem() static nothrowGets 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) nothrowSets 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) nothrowGet the dragged item from the selection. This could be a #GtkToolItem or a #GtkToolItemGroup.
gtk.tool_item_group.ToolItemGroup getDropGroup(int x, int y) nothrowGets the group at position (x, y).
gtk.tool_item.ToolItem getDropItem(int x, int y) nothrowGets the item at position (x, y). See [gtk.tool_palette.ToolPalette.getDropGroup].
bool getExclusive(gtk.tool_item_group.ToolItemGroup group) nothrowGets whether group is exclusive or not. See [gtk.tool_palette.ToolPalette.setExclusive].
bool getExpand(gtk.tool_item_group.ToolItemGroup group) nothrowGets whether group should be given extra space. See [gtk.tool_palette.ToolPalette.setExpand].
int getGroupPosition(gtk.tool_item_group.ToolItemGroup group) nothrowGets the position of group in palette as index. See [gtk.tool_palette.ToolPalette.setGroupPosition].
gtk.adjustment.Adjustment getHadjustment() nothrowGets the horizontal adjustment of the tool palette. Returns: the horizontal adjustment of palette
gtk.types.IconSize getIconSize() nothrowGets 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() nothrowGets 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() nothrowGets the vertical adjustment of the tool palette. Returns: the vertical adjustment of palette
void setDragSource(gtk.types.ToolPaletteDragTargets targets) nothrowSets 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) nothrowSets 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) nothrowSets whether the group should be given extra space.
void setGroupPosition(gtk.tool_item_group.ToolItemGroup group, int position) nothrowSets 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) nothrowSets the size of icons in the tool palette.
void setStyle(gtk.types.ToolbarStyle style) nothrowSets the style (text, icons or both) of items in the tool palette.
void unsetIconSize() nothrowUnsets 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() nothrowUnsets 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

Fluent builder implementation template for gtk.tool_palette.ToolPalette

Methods
T iconSize(gtk.types.IconSize propval) nothrowSet `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) nothrowSet `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) nothrowSet `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

Methods
ToolPalette build() nothrowCreate object from builder. Returns: New object