Package: gtk

Class gtk-tool-palette

Superclasses

gtk-container, gtk-widget, gtk-buildable, gtk-orientable, gtk-scrollable, g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

icon-size
The icon-size property of type gtk-icon-size (Read / Write)
The size of the icons in a tool palette is normally determined by the gtk-toolbar-icon-size setting. When this property is set, it overrides the setting. This should only be used for special purpose tool palettes, normal application tool palettes should respect the user preferences for the size of icons.
Default value: :small-toolbar
icon-size-set
The icon-size-set property of type :boolean (Read / Write)
Is true if the icon-size property has been set.
Default value: false
toolbar-style
The toolbar-style property of type gtk-toolbar-style (Read / Write)
The style of items in the tool palette.
Default value: :icons

Details

A gtk-tool-palette widget allows you to add gtk-tool-item widgets to a palette-like container with different categories and drag and drop support.



A gtk-tool-palette widget is created with a call to the function gtk-tool-palette-new.

gtk-tool-item widgets cannot be added directly to a gtk-tool-palette widget - instead they are added to a gtk-tool-item-group widget which can than be added to a gtk-tool-palette widget. To add a gtk-tool-item-group widget to a gtk-tool-palette widget, use the function gtk-container-add.
(let ((palette (gtk-tool-palette-new))
      (group (gtk-tool-item-group-new "Test Category"))
      (item (make-instance 'gtk-tool-button
                           :icon-name "gtk-ok")))
  (gtk-container-add palette group)
  (gtk-tool-item-group-insert group item -1)
  ... )  
The easiest way to use drag and drop with the gtk-tool-palette widget is to call the function gtk-tool-palette-add-drag-dest with the desired drag source palette and the desired drag target widget. Then the function gtk-tool-palette-drag-item can be used to get the dragged item in the "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

The gtk-tool-palette widget has a single CSS node named toolpalette.

Child Property Details

exclusive
The exclusive child property of type :boolean (Read / Write)
Whether the item group should be the only one that is expanded at a given time.
Default value: false
expand
The expand child property of type :boolean (Read / Write)
Whether the item group should receive extra space when the palette grows at a given time.
Default value: false
 

Slot Access Functions

Inherited Slot Access Functions

See also

*2021-3-14